aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/cgeo/geocaching/apps/cache/navi/RadarApp.java2
-rw-r--r--src/cgeo/geocaching/cgBase.java131
-rw-r--r--src/cgeo/geocaching/cgCache.java29
-rw-r--r--src/cgeo/geocaching/cgSettings.java66
-rw-r--r--src/cgeo/geocaching/cgeoinit.java82
-rw-r--r--src/cgeo/geocaching/googlemaps/googleMapView.java13
-rw-r--r--src/cgeo/geocaching/mapcommon/cgeomap.java58
-rw-r--r--src/cgeo/geocaching/sorting/SizeComparator.java2
8 files changed, 144 insertions, 239 deletions
diff --git a/src/cgeo/geocaching/apps/cache/navi/RadarApp.java b/src/cgeo/geocaching/apps/cache/navi/RadarApp.java
index 66891d4..c7e8277 100644
--- a/src/cgeo/geocaching/apps/cache/navi/RadarApp.java
+++ b/src/cgeo/geocaching/apps/cache/navi/RadarApp.java
@@ -26,7 +26,7 @@ class RadarApp extends AbstractNavigationApp implements NavigationApp {
return true; // seems like Radar is assumed to be available always
}
- private void navigateTo(Activity activity, Double latitude, Double longitude) {
+ private static void navigateTo(Activity activity, Double latitude, Double longitude) {
Intent radarIntent = new Intent(INTENT);
radarIntent.putExtra("latitude", Float.valueOf(latitude.floatValue()));
radarIntent.putExtra("longitude", Float.valueOf(longitude.floatValue()));
diff --git a/src/cgeo/geocaching/cgBase.java b/src/cgeo/geocaching/cgBase.java
index 4573e97..51e6372 100644
--- a/src/cgeo/geocaching/cgBase.java
+++ b/src/cgeo/geocaching/cgBase.java
@@ -97,7 +97,7 @@ public class cgBase {
public static DateFormat dateOutShort = DateFormat.getDateInstance(DateFormat.SHORT, Locale.getDefault());
private Resources res = null;
private HashMap<String, String> cookies = new HashMap<String, String>();
- private final String passMatch = "[/\\?&]*[Pp]ass(word)?=[^&^#^$]+";
+ private static final String passMatch = "[/\\?&]*[Pp]ass(word)?=[^&^#^$]+";
private final Pattern patternLoggedIn = Pattern.compile("<span class=\"Success\">You are logged in as[^<]*<strong[^>]*>([^<]+)</strong>[^<]*</span>", Pattern.CASE_INSENSITIVE | Pattern.MULTILINE);
private final Pattern patternLogged2In = Pattern.compile("<strong>[^\\w]*Hello,[^<]*<a[^>]+>([^<]+)</a>[^<]*</strong>", Pattern.CASE_INSENSITIVE | Pattern.MULTILINE);
private final Pattern patternViewstate = Pattern.compile("id=\"__VIEWSTATE\"[^(value)]+value=\"([^\"]+)\"[^>]+>", Pattern.CASE_INSENSITIVE | Pattern.MULTILINE);
@@ -106,9 +106,6 @@ public class cgBase {
public static final double deg2rad = Math.PI / 180;
public static final double rad2deg = 180 / Math.PI;
public static final float erad = 6371.0f;
- public static final int mapAppAny = 0;
- public static final int mapAppLocus = 1;
- public static final int mapAppRmaps = 2;
private cgeoapplication app = null;
private cgSettings settings = null;
private SharedPreferences prefs = null;
@@ -1879,7 +1876,7 @@ public class cgBase {
return caches;
}
- private Date parseDate(String input) {
+ private static Date parseDate(String input) {
if (input == null) {
return null;
}
@@ -3969,7 +3966,7 @@ public class cgBase {
return -1; // error
}
- boolean guidOnPage = checkPageForGuid(cache, page);
+ boolean guidOnPage = cache.isGuidContainedInPage(page);
if (guidOnPage) {
Log.i(cgSettings.tag, "cgBase.addToWatchlist: cache is on watchlist");
cache.onWatchlist = true;
@@ -4010,7 +4007,7 @@ public class cgBase {
params.put("ctl00$ContentBody$btnYes", "Yes");
page = request(false, host, path, method, params, false, false, false).getData();
- boolean guidOnPage = checkPageForGuid(cache, page);
+ boolean guidOnPage = cache.isGuidContainedInPage(page);
if (! guidOnPage) {
Log.i(cgSettings.tag, "cgBase.removeFromWatchlist: cache removed from watchlist");
cache.onWatchlist = false;
@@ -4020,29 +4017,6 @@ public class cgBase {
return guidOnPage ? -1 : 0; // on watchlist (=error) / not on watchlist
}
- /**
- * checks if a page contains the guid of a cache
- *
- * @param cache the cache to look for
- * @param page the page to search in
- *
- * @return true: page contains guid of cache, false: otherwise
- */
- private boolean checkPageForGuid(cgCache cache, String page) {
- // check if the guid of the cache is anywhere in the page
- if (cache.guid == null || cache.guid.length() == 0)
- return false;
- Pattern patternOk = Pattern.compile(cache.guid, Pattern.CASE_INSENSITIVE);
- Matcher matcherOk = patternOk.matcher(page);
- if (matcherOk.find()) {
- Log.i(cgSettings.tag, "cgBase.checkPageForGuid: guid '" + cache.guid + "' found");
- return true;
- } else {
- Log.i(cgSettings.tag, "cgBase.checkPageForGuid: guid '" + cache.guid + "' not found");
- return false;
- }
- }
-
final public static HostnameVerifier doNotVerify = new HostnameVerifier() {
public boolean verify(String hostname, SSLSession session) {
@@ -4183,7 +4157,7 @@ public class cgBase {
}
}
- private void readIntoBuffer(BufferedReader br, StringBuffer buffer) throws IOException {
+ private static void readIntoBuffer(BufferedReader br, StringBuffer buffer) throws IOException {
int bufferSize = 1024*16;
char[] bytes = new char[bufferSize];
int bytesRead;
@@ -4197,99 +4171,6 @@ public class cgBase {
}
}
- /*
- public ArrayList<String> translate(ArrayList<String> text, String target) {
- if (settings.translate == false) {
- return text;
- }
-
- String[] languages = null;
- if (settings.languages != null) {
- languages = settings.languages.split(" ");
- }
-
- ArrayList<String> translated = new ArrayList<String>();
- String language = null;
-
- if (text == null || text.isEmpty()) {
- return text;
- }
-
- // cut to 5000 characters (limitation of Google Translation API)
- for (String textOne : text) {
- int len = urlencode_rfc3986(textOne).length();
- if (len > 5000) {
- textOne = Html.fromHtml(textOne).toString();
- len = urlencode_rfc3986(textOne).length();
-
- if (len > 5000) {
- int cut = 2000;
- if (textOne.length() > cut) {
- cut = 1000;
- }
-
- textOne = textOne.substring(0, cut) + "...";
- }
- }
- }
-
- try {
- if (target == null) {
- final Locale locale = Locale.getDefault();
- target = locale.getLanguage();
- }
-
- final String scheme = "https://";
- final String host = "www.googleapis.com";
- final String path = "/language/translate/v2";
-
- final ArrayList<String> params = new ArrayList<String>();
- params.add("key=" + urlencode_rfc3986("AIzaSyAJH8x5etFHUbFifmgChlWoCVmwBFSwShQ"));
- params.add("target=" + urlencode_rfc3986(target));
- for (String textOne : text) {
- params.add("q=" + urlencode_rfc3986(textOne));
- }
- params.add("format=" + urlencode_rfc3986("html"));
-
- String page = requestJSON(scheme, host, path, "POST", implode("&", params.toArray()));
-
- if (page == null || page.length() == 0) {
- return text;
- }
-
- JSONObject json = new JSONObject(page);
- JSONObject jsonData = json.getJSONObject("data");
- JSONArray jsonTranslations = jsonData.getJSONArray("translations");
- int translationCnt = jsonTranslations.length();
-
- for (int i = 0; i < translationCnt; i ++) {
- JSONObject jsonTranslation = jsonTranslations.getJSONObject(i);
- language = jsonTranslation.getString("detectedSourceLanguage");
-
- boolean toTranslate = true;
- if (languages != null) {
- for (String lng : languages) {
- if (lng.equalsIgnoreCase(language)) {
- toTranslate = false;
- }
- }
- }
-
- if (toTranslate == false) {
- translated.add(text.get(i));
- } else {
- Log.i(cgSettings.tag, "Translating #" + i + ": " + language + ">" + target);
- translated.add(jsonTranslation.getString("translatedText"));
- }
- }
- } catch (Exception e) {
- Log.w(cgSettings.tag, "cgBase.translate: " + e.toString());
- }
-
- return translated;
- }
- */
-
public String getLocalIpAddress() {
try {
for (Enumeration<NetworkInterface> en = NetworkInterface.getNetworkInterfaces(); en.hasMoreElements();) {
@@ -4673,7 +4554,7 @@ public class cgBase {
return response;
}
- private String replaceWhitespace(final StringBuffer buffer) {
+ private static String replaceWhitespace(final StringBuffer buffer) {
final int length = buffer.length();
final char[] bytes = new char[length];
buffer.getChars(0, length, bytes, 0);
diff --git a/src/cgeo/geocaching/cgCache.java b/src/cgeo/geocaching/cgCache.java
index 8b2bb00..dae75e6 100644
--- a/src/cgeo/geocaching/cgCache.java
+++ b/src/cgeo/geocaching/cgCache.java
@@ -3,8 +3,11 @@ package cgeo.geocaching;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
import android.text.Spannable;
+import android.util.Log;
public class cgCache {
@@ -233,4 +236,30 @@ public class cgCache {
}
return true;
}
+
+ /**
+ * checks if a page contains the guid of a cache
+ *
+ * @param cache the cache to look for
+ * @param page the page to search in
+ *
+ * @return true: page contains guid of cache, false: otherwise
+ */
+ boolean isGuidContainedInPage(final String page) {
+ // check if the guid of the cache is anywhere in the page
+ if (guid == null || guid.length() == 0) {
+ return false;
+ }
+ Pattern patternOk = Pattern.compile(guid, Pattern.CASE_INSENSITIVE);
+ Matcher matcherOk = patternOk.matcher(page);
+ if (matcherOk.find()) {
+ Log.i(cgSettings.tag, "cgCache.isGuidContainedInPage: guid '" + guid + "' found");
+ return true;
+ } else {
+ Log.i(cgSettings.tag, "cgCache.isGuidContainedInPage: guid '" + guid + "' not found");
+ return false;
+ }
+ }
+
+
}
diff --git a/src/cgeo/geocaching/cgSettings.java b/src/cgeo/geocaching/cgSettings.java
index 97e8c5c..6c7473b 100644
--- a/src/cgeo/geocaching/cgSettings.java
+++ b/src/cgeo/geocaching/cgSettings.java
@@ -1,23 +1,23 @@
package cgeo.geocaching;
+import java.util.HashMap;
import java.util.Locale;
import java.util.Map;
-import java.util.HashMap;
import org.mapsforge.android.maps.MapDatabase;
-import cgeo.geocaching.googlemaps.googleMapFactory;
-import cgeo.geocaching.mapinterfaces.MapFactory;
-import cgeo.geocaching.mapsforge.mfMapFactory;
-import android.os.Environment;
-import android.content.Intent;
import android.content.Context;
+import android.content.Intent;
import android.content.SharedPreferences;
import android.content.res.Configuration;
+import android.os.Environment;
import android.util.Log;
+import cgeo.geocaching.googlemaps.googleMapFactory;
+import cgeo.geocaching.mapinterfaces.MapFactory;
+import cgeo.geocaching.mapsforge.mfMapFactory;
public class cgSettings {
-
+
public enum mapSourceEnum {
googleMap,
googleSat,
@@ -25,7 +25,7 @@ public class cgSettings {
mapsforgeOsmarender,
mapsforgeCycle,
mapsforgeOffline;
-
+
static mapSourceEnum fromInt(int id) {
mapSourceEnum[] values = mapSourceEnum.values();
if (id >= 0 && id < values.length) {
@@ -39,11 +39,11 @@ public class cgSettings {
if (googleMap == this || googleSat == this) {
return true;
}
-
+
return false;
}
}
-
+
// constants
public final static int unitsMetric = 1;
public final static int unitsImperial = 2;
@@ -62,7 +62,7 @@ public class cgSettings {
public int buttonActive = R.drawable.action_button_dark;
public int buttonInactive = R.drawable.action_button_dark_off;
public int buttonPressed = R.drawable.action_button_dark_pressed;
-
+
// settings
public boolean loaded = false;
public boolean hideMySearch = false;
@@ -109,7 +109,7 @@ public class cgSettings {
private String username = null;
private String password = null;
private String passVote = null;
-
+
// maps
public MapFactory mapFactory = null;
public mapSourceEnum mapSourceUsed = mapSourceEnum.googleMap;
@@ -129,7 +129,7 @@ public class cgSettings {
initialized = prefs.getInt("initialized", 0);
helper = prefs.getInt("helper", 0);
-
+
skin = prefs.getInt("skin", 0);
setSkinDefaults();
@@ -164,10 +164,10 @@ public class cgSettings {
webDeviceCode = prefs.getString("webDeviceCode", null);
trackableAutovisit = prefs.getBoolean("trackautovisit", false);
signatureAutoinsert = prefs.getBoolean("sigautoinsert", false);
-
+
setLanguage(useEnglish);
}
-
+
private void setSkinDefaults() {
if (skin == 1) {
buttonActive = R.drawable.action_button_light;
@@ -190,7 +190,7 @@ public class cgSettings {
setSkinDefaults();
}
}
-
+
public void setLanguage(boolean useEnglish) {
Locale locale = Locale.getDefault();
if (useEnglish) {
@@ -306,7 +306,7 @@ public class cgSettings {
this.username = username;
this.password = password;
-
+
return prefsEdit.commit();
}
@@ -463,31 +463,31 @@ public class cgSettings {
maplive = 0;
}
}
-
+
public int getLastList() {
int listId = prefs.getInt("lastlist", -1);
-
+
return listId;
}
-
+
public void saveLastList(int listId) {
final SharedPreferences.Editor edit = prefs.edit();
-
+
edit.putInt("lastlist", listId);
edit.commit();
}
public void setWebNameCode(String name, String code) {
final SharedPreferences.Editor edit = prefs.edit();
-
+
this.webDeviceCode=code;
this.webDeviceName=name;
-
+
edit.putString("webDeviceName", name);
edit.putString("webDeviceCode", code);
edit.commit();
}
-
+
public MapFactory getMapFactory() {
if (mapSource.isGoogleMapSource()) {
if (!mapSourceUsed.isGoogleMapSource() || mapFactory == null) {
@@ -500,32 +500,32 @@ public class cgSettings {
mapSourceUsed = mapSource;
}
}
-
+
return mapFactory;
}
-
+
public String getMapFile() {
return mapFile;
}
-
+
public boolean setMapFile(String mapFileIn) {
final SharedPreferences.Editor prefsEdit = prefs.edit();
prefsEdit.putString("mfmapfile", mapFileIn);
-
- boolean commitResult = prefsEdit.commit();
+
+ boolean commitResult = prefsEdit.commit();
mapFile = mapFileIn;
mapFileValid = checkMapfile(mapFile);
-
+
return commitResult;
}
-
+
public boolean hasValidMapFile() {
return mapFileValid;
}
-
- private boolean checkMapfile(String mapFileIn) {
+
+ private static boolean checkMapfile(String mapFileIn) {
return MapDatabase.isValidMapFile(mapFileIn);
}
diff --git a/src/cgeo/geocaching/cgeoinit.java b/src/cgeo/geocaching/cgeoinit.java
index 8cd5533..39b36c4 100644
--- a/src/cgeo/geocaching/cgeoinit.java
+++ b/src/cgeo/geocaching/cgeoinit.java
@@ -1,33 +1,31 @@
package cgeo.geocaching;
-import gnu.android.app.appmanualclient.*;
+import gnu.android.app.appmanualclient.AppManualReaderClient;
+
+import java.io.File;
-import android.os.Bundle;
import android.app.Activity;
import android.app.ProgressDialog;
-import android.view.View;
-import android.widget.EditText;
import android.content.Intent;
import android.content.SharedPreferences;
import android.content.res.Configuration;
import android.content.res.Resources;
import android.net.Uri;
-import android.util.Log;
+import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
+import android.util.Log;
import android.view.Menu;
import android.view.MenuItem;
+import android.view.View;
import android.widget.AdapterView;
+import android.widget.AdapterView.OnItemSelectedListener;
import android.widget.ArrayAdapter;
import android.widget.Button;
import android.widget.CheckBox;
-import android.widget.LinearLayout;
+import android.widget.EditText;
import android.widget.Spinner;
import android.widget.TextView;
-import android.widget.AdapterView.OnItemSelectedListener;
-
-import java.io.File;
-
import cgeo.geocaching.cgSettings.mapSourceEnum;
public class cgeoinit extends Activity {
@@ -75,7 +73,7 @@ public class cgeoinit extends Activity {
init();
}
};
-
+
private Handler webAuthHandler = new Handler() {
@Override
@@ -135,7 +133,7 @@ public class cgeoinit extends Activity {
@Override
public void onResume() {
super.onResume();
-
+
settings.load();
}
@@ -195,7 +193,7 @@ public class cgeoinit extends Activity {
}
public void init() {
-
+
// geocaching.com settings
String usernameNow = prefs.getString("username", null);
if (usernameNow != null) {
@@ -205,7 +203,7 @@ public class cgeoinit extends Activity {
if (usernameNow != null) {
((EditText) findViewById(R.id.password)).setText(passwordNow);
}
-
+
Button logMeIn = (Button) findViewById(R.id.log_me_in);
logMeIn.setOnClickListener(new logIn());
@@ -327,7 +325,7 @@ public class cgeoinit extends Activity {
disabledButton.setChecked(true);
}
disabledButton.setOnClickListener(new cgeoChangeDisabled());
-
+
CheckBox autovisitButton = (CheckBox) findViewById(R.id.trackautovisit);
if (prefs.getBoolean("trackautovisit", false)) {
autovisitButton.setChecked(true);
@@ -383,14 +381,14 @@ public class cgeoinit extends Activity {
browserButton.setChecked(true);
}
browserButton.setOnClickListener(new cgeoChangeBrowser());
-
+
// Altitude settings
EditText altitudeEdit = (EditText) findViewById(R.id.altitude);
altitudeEdit.setText("" + prefs.getInt("altcorrection", 0));
//Send2cgeo settings
String webDeviceName = prefs.getString("webDeviceName", null);
-
+
if ((webDeviceName != null) &&(webDeviceName.length() > 0)) {
((EditText) findViewById(R.id.webDeviceName)).setText(webDeviceName);
} else {
@@ -400,7 +398,7 @@ public class cgeoinit extends Activity {
Button webAuth = (Button) findViewById(R.id.sendToCgeo_register);
webAuth.setOnClickListener(new webAuth());
-
+
/*TextView webText = (TextView) findViewById(R.id.sendToCgeo);
webText.setClickable(true);
webText.setOnClickListener(new View.OnClickListener() {
@@ -409,29 +407,29 @@ public class cgeoinit extends Activity {
activity.startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("http://send2cgeo.carnero.cc/")));
}
});*/
-
+
// Map source settings
Spinner mapSourceSelector = (Spinner) findViewById(R.id.mapsource);
ArrayAdapter<CharSequence> adapter = ArrayAdapter.createFromResource(
this, R.array.map_sources, android.R.layout.simple_spinner_item);
adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
- mapSourceSelector.setAdapter(adapter);
+ mapSourceSelector.setAdapter(adapter);
int mapsource = prefs.getInt("mapsource", 0);
mapSourceSelector.setSelection(mapsource);
mapSourceSelector.setOnItemSelectedListener(new cgeoChangeMapSource());
-
+
initMapfileEdittext(false);
-
+
Button selectMapfile = (Button) findViewById(R.id.select_mapfile);
selectMapfile.setOnClickListener(new View.OnClickListener() {
-
+
@Override
public void onClick(View v) {
Intent selectIntent = new Intent(activity, cgSelectMapfile.class);
activity.startActivityForResult(selectIntent, SELECT_MAPFILE_REQUEST);
}
});
-
+
// Cache db backup
TextView lastBackup = (TextView) findViewById(R.id.backup_last);
File lastBackupFile = app.isRestoreFile();
@@ -440,9 +438,9 @@ public class cgeoinit extends Activity {
} else {
lastBackup.setText(res.getString(R.string.init_backup_last_no));
}
-
+
}
-
+
private void initMapfileEdittext(boolean setFocus) {
EditText mfmapFileEdit = (EditText) findViewById(R.id.mapfile);
mfmapFileEdit.setText(prefs.getString("mfmapfile", ""));
@@ -453,13 +451,13 @@ public class cgeoinit extends Activity {
public void backup(View view) {
final String file = app.backupDatabase();
-
+
if (file != null) {
warning.helpDialog(res.getString(R.string.init_backup_backup), res.getString(R.string.init_backup_success) + "\n" + file);
} else {
warning.helpDialog(res.getString(R.string.init_backup_backup), res.getString(R.string.init_backup_failed));
}
-
+
TextView lastBackup = (TextView) findViewById(R.id.backup_last);
File lastBackupFile = app.isRestoreFile();
if (lastBackupFile != null) {
@@ -468,17 +466,17 @@ public class cgeoinit extends Activity {
lastBackup.setText(res.getString(R.string.init_backup_last_no));
}
}
-
+
public void restore(View view) {
final boolean status = app.restoreDatabase();
-
+
if (status) {
warning.helpDialog(res.getString(R.string.init_backup_restore), res.getString(R.string.init_restore_success));
} else {
warning.helpDialog(res.getString(R.string.init_backup_restore), res.getString(R.string.init_restore_failed));
}
}
-
+
public boolean saveValues() {
String usernameNew = ((EditText) findViewById(R.id.username)).getText().toString();
String passwordNew = ((EditText) findViewById(R.id.password)).getText().toString();
@@ -499,14 +497,14 @@ public class cgeoinit extends Activity {
if (signatureNew == null) {
signatureNew = "";
}
-
+
int altitudeNewInt = 0;
if (altitudeNew == null) {
altitudeNewInt = 0;
} else {
altitudeNewInt = new Integer(altitudeNew);
}
-
+
if (mfmapFileNew == null) {
mfmapFileNew = "";
}
@@ -708,7 +706,7 @@ public class cgeoinit extends Activity {
return;
}
}
-
+
private class cgeoChangeAutovisit implements View.OnClickListener {
public void onClick(View arg0) {
@@ -732,7 +730,7 @@ public class cgeoinit extends Activity {
return;
}
}
-
+
private class cgeoChangeSignatureAutoinsert implements View.OnClickListener {
public void onClick(View arg0) {
@@ -989,14 +987,14 @@ public class cgeoinit extends Activity {
@Override
public void run() {
int pin = 0;
-
+
String nam = deviceName==null?"":deviceName;
String cod = deviceCode==null?"":deviceCode;
-
+
String params = "name="+cgBase.urlencode_rfc3986(nam)+"&code="+cgBase.urlencode_rfc3986(cod);
-
+
cgResponse response = base.request(false, "send2cgeo.carnero.cc", "/authDev.php", "GET", params, 0, true);
-
+
if (response.getStatusCode() == 200)
{
//response was OK
@@ -1009,17 +1007,17 @@ public class cgeoinit extends Activity {
String code = strings[0];
settings.setWebNameCode(nam, code);
}
-
+
webAuthHandler.sendEmptyMessage(pin);
}
}).start();
}
}
-
+
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
-
+
if (requestCode == SELECT_MAPFILE_REQUEST) {
if (resultCode == RESULT_OK) {
if (data.hasExtra("mapfile")) {
diff --git a/src/cgeo/geocaching/googlemaps/googleMapView.java b/src/cgeo/geocaching/googlemaps/googleMapView.java
index 48b8a38..737e64e 100644
--- a/src/cgeo/geocaching/googlemaps/googleMapView.java
+++ b/src/cgeo/geocaching/googlemaps/googleMapView.java
@@ -1,8 +1,5 @@
package cgeo.geocaching.googlemaps;
-import org.mapsforge.android.maps.MapDatabase;
-import org.mapsforge.android.maps.MapViewMode;
-
import android.content.Context;
import android.graphics.Canvas;
import android.graphics.drawable.Drawable;
@@ -86,12 +83,12 @@ public class googleMapView extends MapView implements MapViewImpl{
@Override
public cgMapOverlay createAddMapOverlay(cgSettings settings,
Context context, Drawable drawable, boolean fromDetailIntent) {
-
+
googleCacheOverlay ovl = new googleCacheOverlay(settings, context, drawable, fromDetailIntent);
getOverlays().add(ovl);
return ovl.getBase();
}
-
+
@Override
public cgUsersOverlay createAddUsersOverlay(Context context, Drawable markerIn) {
googleUsersOverlay ovl = new googleUsersOverlay(context, markerIn);
@@ -106,7 +103,7 @@ public class googleMapView extends MapView implements MapViewImpl{
@Override
public void setMapSource(cgSettings settings) {
-
+
switch(settings.mapSource) {
case googleSat:
setSatellite(true);
@@ -114,8 +111,8 @@ public class googleMapView extends MapView implements MapViewImpl{
default:
setSatellite(false);
}
-
-
+
+
}
@Override
diff --git a/src/cgeo/geocaching/mapcommon/cgeomap.java b/src/cgeo/geocaching/mapcommon/cgeomap.java
index f0e7638..cf1760f 100644
--- a/src/cgeo/geocaching/mapcommon/cgeomap.java
+++ b/src/cgeo/geocaching/mapcommon/cgeomap.java
@@ -46,13 +46,13 @@ import cgeo.geocaching.mapinterfaces.MapViewImpl;
import cgeo.geocaching.mapinterfaces.UserOverlayItemImpl;
public class cgeomap extends MapBase {
-
+
private static final int MENU_SELECT_MAPVIEW = 1;
private static final int MENU_MAP_LIVE = 2;
- private static final int MENU_STORE_CACHES = 3;
+ private static final int MENU_STORE_CACHES = 3;
private static final int MENU_TRAIL_MODE = 4;
private static final int MENU_CIRCLE_MODE = 5;
-
+
private static final int SUBMENU_VIEW_GOOGLE_MAP = 10;
private static final int SUBMENU_VIEW_GOOGLE_SAT = 11;
private static final int SUBMENU_VIEW_MF_MAPNIK = 13;
@@ -350,8 +350,8 @@ public class cgeomap extends MapBase {
if (geocodeIntent != null || searchIdIntent != null || (latitudeIntent != null && longitudeIntent != null) || mapStateIntent != null) {
centerMap(geocodeIntent, searchIdIntent, latitudeIntent, longitudeIntent, mapStateIntent);
}
-
-
+
+
setMyLoc(null);
startTimer();
}
@@ -466,10 +466,10 @@ public class cgeomap extends MapBase {
@Override
public boolean onCreateOptionsMenu(Menu menu) {
-
+
SubMenu submenu = menu.addSubMenu(1, MENU_SELECT_MAPVIEW, 0, res.getString(R.string.map_view_map)).setIcon(android.R.drawable.ic_menu_more);
addMapViewMenuItems(submenu);
-
+
menu.add(0, MENU_MAP_LIVE, 0, res.getString(R.string.map_live_disable)).setIcon(android.R.drawable.ic_menu_close_clear_cancel);
menu.add(0, MENU_STORE_CACHES, 0, res.getString(R.string.caches_store_offline)).setIcon(android.R.drawable.ic_menu_set_as).setEnabled(false);
menu.add(0, MENU_TRAIL_MODE, 0, res.getString(R.string.map_trail_hide)).setIcon(android.R.drawable.ic_menu_recent_history);
@@ -477,10 +477,10 @@ public class cgeomap extends MapBase {
return true;
}
-
+
private void addMapViewMenuItems(final Menu menu) {
String[] mapViews = res.getStringArray(R.array.map_sources);
-
+
menu.add(0, SUBMENU_VIEW_GOOGLE_MAP, 0, mapViews[0]);
menu.add(0, SUBMENU_VIEW_GOOGLE_SAT, 0, mapViews[1]);
menu.add(0, SUBMENU_VIEW_MF_MAPNIK, 0, mapViews[2]);
@@ -527,7 +527,7 @@ public class cgeomap extends MapBase {
} else {
item.setTitle(res.getString(R.string.map_circles_show));
}
-
+
item = menu.findItem(SUBMENU_VIEW_MF_OFFLINE);
if (settings.hasValidMapFile()) {
item.setEnabled(true);
@@ -646,16 +646,16 @@ public class cgeomap extends MapBase {
}
overlayCaches.switchCircles();
-
+
} else if (SUBMENU_VIEW_GOOGLE_MAP <= id && SUBMENU_VIEW_MF_OFFLINE >= id) {
-
+
mapSourceEnum mapSource = getMapSourceFromMenuId(id);
-
+
boolean mapRestartRequired = switchMapSource(mapSource);
-
+
if (mapRestartRequired) {
Intent mapIntent = new Intent(activity, settings.getMapFactory().getMapClass());
-
+
mapIntent.putExtra("detail", fromDetailIntent);
mapIntent.putExtra("searchid", searchIdIntent);
mapIntent.putExtra("geocode", geocodeIntent);
@@ -668,21 +668,21 @@ public class cgeomap extends MapBase {
mapState[1] = mapCenter.getLongitudeE6();
mapState[2] = mapView.getMapZoomLevel();
mapIntent.putExtra("mapstate", mapState);
-
+
activity.startActivity(mapIntent);
-
+
activity.finish();
}
-
+
return true;
}
-
+
return false;
}
-
- private mapSourceEnum getMapSourceFromMenuId(int menuItemId) {
-
+
+ private static mapSourceEnum getMapSourceFromMenuId(int menuItemId) {
+
switch(menuItemId) {
case SUBMENU_VIEW_GOOGLE_MAP:
return mapSourceEnum.googleMap;
@@ -700,20 +700,20 @@ public class cgeomap extends MapBase {
return mapSourceEnum.googleMap;
}
}
-
+
private boolean switchMapSource(mapSourceEnum mapSource) {
settings.mapSource = mapSource;
-
+
prefsEdit.putInt("mapsource", settings.mapSource.ordinal());
prefsEdit.commit();
boolean mapRestartRequired = settings.mapSource.isGoogleMapSource()!= settings.mapSourceUsed.isGoogleMapSource();
-
+
if (!mapRestartRequired) {
mapView.setMapSource(settings);
}
-
+
return mapRestartRequired;
}
@@ -1651,7 +1651,7 @@ public class cgeomap extends MapBase {
// move map to view results of searchIdIntent
private void centerMap(String geocodeCenter, Long searchIdCenter, Double latitudeCenter, Double longitudeCenter, int[] mapState) {
-
+
if (!centered && mapState != null) {
try {
mapController.setCenter(settings.getMapFactory().getGeoPointBase(mapState[0], mapState[1]));
@@ -1659,9 +1659,9 @@ public class cgeomap extends MapBase {
} catch (Exception e) {
// nothing at all
}
-
+
centered = true;
- alreadyCentered = true;
+ alreadyCentered = true;
} else if (!centered && (geocodeCenter != null || searchIdIntent != null)) {
try {
ArrayList<Object> viewport;
diff --git a/src/cgeo/geocaching/sorting/SizeComparator.java b/src/cgeo/geocaching/sorting/SizeComparator.java
index f5bd643..dd9d448 100644
--- a/src/cgeo/geocaching/sorting/SizeComparator.java
+++ b/src/cgeo/geocaching/sorting/SizeComparator.java
@@ -30,7 +30,7 @@ public class SizeComparator extends AbstractCacheComparator {
* @param cache
* @return
*/
- private int getSize(final cgCache cache) {
+ private static int getSize(final cgCache cache) {
char c = cache.size.charAt(0);
switch (c) {
case 'm': // micro