diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/cgeo/geocaching/cgBase.java | 46 | ||||
| -rw-r--r-- | src/cgeo/geocaching/cgData.java | 2 | ||||
| -rw-r--r-- | src/cgeo/geocaching/cgeocoords.java | 66 | ||||
| -rw-r--r-- | src/cgeo/geocaching/compatibility/AndroidLevel8Internal.java | 2 | ||||
| -rw-r--r-- | src/cgeo/geocaching/files/GPXParser.java | 6 | ||||
| -rw-r--r-- | src/cgeo/geocaching/mapcommon/cgeomap.java | 14 |
6 files changed, 67 insertions, 69 deletions
diff --git a/src/cgeo/geocaching/cgBase.java b/src/cgeo/geocaching/cgBase.java index 4995919..fc13d7f 100644 --- a/src/cgeo/geocaching/cgBase.java +++ b/src/cgeo/geocaching/cgBase.java @@ -103,7 +103,7 @@ public class cgBase { private final static Pattern patternInventory = Pattern.compile("<span id=\"ctl00_ContentBody_uxTravelBugList_uxInventoryLabel\">\\W*Inventory[^<]*</span>[^<]*</h3>[^<]*<div class=\"WidgetBody\">([^<]*<ul>(([^<]*<li>[^<]*<a href=\"[^\"]+\"[^>]*>[^<]*<img src=\"[^\"]+\"[^>]*>[^<]*<span>[^<]+<\\/span>[^<]*<\\/a>[^<]*<\\/li>)+)[^<]*<\\/ul>)?", Pattern.CASE_INSENSITIVE); private final static Pattern patternInventoryInside = Pattern.compile("[^<]*<li>[^<]*<a href=\"[a-z0-9\\-\\_\\.\\?\\/\\:\\@]*\\/track\\/details\\.aspx\\?guid=([0-9a-z\\-]+)[^\"]*\"[^>]*>[^<]*<img src=\"[^\"]+\"[^>]*>[^<]*<span>([^<]+)<\\/span>[^<]*<\\/a>[^<]*<\\/li>", Pattern.CASE_INSENSITIVE); private final static Pattern patternOnWatchlist = Pattern.compile("<img\\s*src=\"\\/images\\/stockholm\\/16x16\\/icon_stop_watchlist.gif\"", Pattern.CASE_INSENSITIVE); - + public static HashMap<String, String> cacheTypes = new HashMap<String, String>(); public static HashMap<String, String> cacheTypesInv = new HashMap<String, String>(); public static HashMap<String, String> cacheIDs = new HashMap<String, String>(); @@ -392,17 +392,17 @@ public class cgBase { /** * read all viewstates from page - * + * * @return String[] with all view states */ public static String[] getViewstates(String page) { // Get the number of viewstates. - // If there is only one viewstate, __VIEWSTATEFIELDCOUNT is not present + // If there is only one viewstate, __VIEWSTATEFIELDCOUNT is not present int count = 1; final Matcher matcherViewstateCount = patternViewstateFieldCount.matcher(page); if (matcherViewstateCount.find()) count = Integer.parseInt(matcherViewstateCount.group(1)); - + String[] viewstates = new String[count]; // Get the viewstates @@ -424,10 +424,10 @@ public class cgBase { return viewstates; } - /** + /** * put viewstates into request parameters */ - public void setViewstates(String[] viewstates, HashMap<String, String> params) { + private static void setViewstates(String[] viewstates, HashMap<String, String> params) { if (viewstates == null || viewstates.length == 0) return; params.put("__VIEWSTATE", viewstates[0]); @@ -442,10 +442,10 @@ public class cgBase { * transfers the viewstates variables from a page (response) to parameters * (next request) */ - public void transferViewstates(String page, HashMap<String, String> params) { + public static void transferViewstates(String page, HashMap<String, String> params) { setViewstates(getViewstates(page), params); } - + /** * checks if an Array of Strings is empty or not. Empty means: * - Array is null @@ -458,7 +458,7 @@ public class cgBase { for (String s: a) if (s != null && s.length() > 0) return false; - + return true; } @@ -1591,7 +1591,7 @@ public class cgBase { try { // final Matcher matcherLogs = patternLogs.matcher(page); -// +// // if (matcherLogs.find()) // { /* @@ -1604,7 +1604,7 @@ public class cgBase { 7- The rest (e.g. log-images, maybe faster) */ final Matcher matcherLog = patternLog.matcher(page);//(matcherLogs.group(1)); - + while (matcherLog.find()) { final cgLog logDone = new cgLog(); @@ -1617,7 +1617,7 @@ public class cgBase { { logDone.type = logTypes.get("icon_note"); } - + try { if (matcherLog.group(5).indexOf(',') > 0) @@ -1645,7 +1645,7 @@ public class cgBase { { logDone.found = Integer.parseInt(matcherLog.group(2)); } - + logDone.log = matcherLog.group(6); final Matcher matcherImg = patternLogImgs.matcher(matcherLog.group(7)); @@ -1842,7 +1842,7 @@ public class cgBase { return caches; } - private void checkFields(cgCache cache) { + private static void checkFields(cgCache cache) { if (cache.geocode == null || cache.geocode.length() == 0) { Log.w(cgSettings.tag, "geo code not parsed correctly"); } @@ -3605,7 +3605,7 @@ public class cgBase { return trackable; } - public int postLog(cgeoapplication app, String geocode, String cacheid, String[] viewstates, + public int postLog(cgeoapplication app, String geocode, String cacheid, String[] viewstates, int logType, int year, int month, int day, String log, ArrayList<cgTrackableLog> trackables) { if (isEmpty(viewstates)) { Log.e(cgSettings.tag, "cgeoBase.postLog: No viewstate given"); @@ -3767,7 +3767,7 @@ public class cgBase { return 1000; } - public int postLogTrackable(String tbid, String trackingCode, String[] viewstates, + public int postLogTrackable(String tbid, String trackingCode, String[] viewstates, int logType, int year, int month, int day, String log) { if (isEmpty(viewstates)) { Log.e(cgSettings.tag, "cgeoBase.postLogTrackable: No viewstate given"); @@ -4115,7 +4115,7 @@ public class cgBase { if (params != null) { Set<Map.Entry<String, String>> entrySet = params.entrySet(); ArrayList<String> paramsEncoded = new ArrayList<String>(); - + for(Map.Entry<String, String> entry : entrySet) { String key = entry.getKey(); @@ -4379,7 +4379,7 @@ public class cgBase { final Map<String, ?> prefsAll = prefs.getAll(); final Set<? extends Map.Entry<String, ?>> entrySet = prefsAll.entrySet(); - + for(Map.Entry<String, ?> entry : entrySet){ String key = entry.getKey(); if (key.matches("cookie_.+")) { @@ -4394,7 +4394,7 @@ public class cgBase { if (cookies != null) { final Set<Map.Entry<String, String>> entrySet = cookies.entrySet(); final ArrayList<String> cookiesEncoded = new ArrayList<String>(); - + for(Map.Entry<String, String> entry : entrySet){ cookiesEncoded.add(entry.getKey() + "=" + entry.getValue()); } @@ -4414,7 +4414,7 @@ public class cgBase { for(Map.Entry<String, ?> entry : entrySet){ String key = entry.getKey(); if (key.length() > 7 && key.substring(0, 7).equals("cookie_")) { - cookiesEncoded.add(key + "=" + entry.getValue()); + cookiesEncoded.add(key + "=" + entry.getValue()); } } @@ -5320,7 +5320,7 @@ public class cgBase { public String getUserName() { return settings.getUsername(); } - + /** * insert text into the EditText at the current cursor position * @param editText @@ -5332,12 +5332,12 @@ public class cgBase { int selectionEnd = editText.getSelectionEnd(); int start = Math.min(selectionStart, selectionEnd); int end = Math.max(selectionStart, selectionEnd); - + String content = editText.getText().toString(); if (start > 0 && !Character.isWhitespace(content.charAt(start - 1))) { insertText = " " + insertText; } - + editText.getText().replace(start, end, insertText); int newCursor = start + insertText.length(); editText.setSelection(newCursor, newCursor); diff --git a/src/cgeo/geocaching/cgData.java b/src/cgeo/geocaching/cgData.java index 70226d0..ab24864 100644 --- a/src/cgeo/geocaching/cgData.java +++ b/src/cgeo/geocaching/cgData.java @@ -2072,7 +2072,7 @@ public class cgData { return waypoints; } - private cgWaypoint createWaypointFromDatabaseContent(Cursor cursor) { + private static cgWaypoint createWaypointFromDatabaseContent(Cursor cursor) { cgWaypoint waypoint = new cgWaypoint(); waypoint.id = (int) cursor.getInt(cursor.getColumnIndex("_id")); waypoint.geocode = (String) cursor.getString(cursor.getColumnIndex("geocode")); diff --git a/src/cgeo/geocaching/cgeocoords.java b/src/cgeo/geocaching/cgeocoords.java index b4f88ec..c206d44 100644 --- a/src/cgeo/geocaching/cgeocoords.java +++ b/src/cgeo/geocaching/cgeocoords.java @@ -26,18 +26,18 @@ public class cgeocoords extends Dialog { private cgSettings settings = null; private cgGeo geo = null; private Double latitude = 0.0, longitude = 0.0; - + private EditText eLat, eLon; private Button bLat, bLon; private EditText eLatDeg, eLatMin, eLatSec, eLatSub; private EditText eLonDeg, eLonMin, eLonSec, eLonSub; private TextView tLatSep1, tLatSep2, tLatSep3; - private TextView tLonSep1, tLonSep2, tLonSep3; - + private TextView tLonSep1, tLonSep2, tLonSep3; + CoordinateUpdate cuListener; - + coordInputFormatEnum currentFormat; - + public cgeocoords(final AbstractActivity contextIn, cgSettings settingsIn, final cgWaypoint waypoint, final cgGeo geoIn) { super(contextIn); context = contextIn; @@ -65,7 +65,7 @@ public class cgeocoords extends Dialog { } setContentView(R.layout.coords); - + Spinner s = (Spinner) findViewById(R.id.spinnerCoordinateFormats); ArrayAdapter<CharSequence> adapter = ArrayAdapter.createFromResource(context, @@ -74,9 +74,9 @@ public class cgeocoords extends Dialog { adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); s.setAdapter(adapter); s.setSelection(settings.getCoordInputFormat().ordinal()); - + s.setOnItemSelectedListener(new CoordinateFormatListener()); - + bLat = (Button) findViewById(R.id.ButtonLat); eLat = (EditText) findViewById(R.id.latitude); eLatDeg = (EditText) findViewById(R.id.EditTextLatDeg); @@ -95,7 +95,7 @@ public class cgeocoords extends Dialog { eLonSub = (EditText) findViewById(R.id.EditTextLonSecFrac); tLonSep1 = (TextView) findViewById(R.id.LonSeparator1); tLonSep2 = (TextView) findViewById(R.id.LonSeparator2); - tLonSep3 = (TextView) findViewById(R.id.LonSeparator3); + tLonSep3 = (TextView) findViewById(R.id.LonSeparator3); eLatDeg.addTextChangedListener(new textChangedListener(1)); eLatMin.addTextChangedListener(new textChangedListener(2)); @@ -109,13 +109,13 @@ public class cgeocoords extends Dialog { eLon.addTextChangedListener(new textChangedListener(11)); bLat.setOnClickListener(new buttonClickListener()); bLon.setOnClickListener(new buttonClickListener()); - + Button buttonCurrent = (Button) findViewById(R.id.current); buttonCurrent.setOnClickListener(new CurrentListener()); Button buttonDone = (Button) findViewById(R.id.done); - buttonDone.setOnClickListener(new InputDoneListener()); + buttonDone.setOnClickListener(new InputDoneListener()); } - + private void updateGUI() { Double lat = 0.0; if (latitude != null) { @@ -124,7 +124,7 @@ public class cgeocoords extends Dialog { } else { bLat.setText("N"); } - + lat = Math.abs(latitude); } Double lon = 0.0; @@ -134,7 +134,7 @@ public class cgeocoords extends Dialog { } else { bLon.setText("E"); } - + lon = Math.abs(longitude); } int latDeg = (int) Math.floor(lat); @@ -156,7 +156,7 @@ public class cgeocoords extends Dialog { int lonSecFrac = (int) Math.round((((lon - lonDeg) * 60 - lonMin) * 60 - lonSec) * 1000); switch (currentFormat) { - case Plain: + case Plain: findViewById(R.id.coordTable).setVisibility(View.GONE); eLat.setVisibility(View.VISIBLE); eLon.setVisibility(View.VISIBLE); @@ -164,7 +164,7 @@ public class cgeocoords extends Dialog { eLat.setText(cgBase.formatCoordinate(latitude, "lat", true)); } if (longitude != null) { - eLon.setText(cgBase.formatCoordinate(longitude, "lon", true)); + eLon.setText(cgBase.formatCoordinate(longitude, "lon", true)); } break; case Deg: // DDD.DDDDD° @@ -254,8 +254,8 @@ public class cgeocoords extends Dialog { break; } } - - private String addZeros(int value, int len) { + + private static String addZeros(int value, int len) { String zeros = ""; if (value == 0) { value = 1; @@ -290,7 +290,7 @@ public class cgeocoords extends Dialog { calc(); } } - + private class textChangedListener implements TextWatcher { private int editTextId; @@ -301,21 +301,21 @@ public class cgeocoords extends Dialog { @Override public void afterTextChanged(Editable s) { - + /* * Max lengths, depending on currentFormat - * + * * formatPlain = disabled * DEG MIN SEC SUB * formatDeg 2/3 5 - - * formatMin 2/3 2 3 - * formatSec 2/3 2 2 3 */ - + if (currentFormat == coordInputFormatEnum.Plain) { return; } - + int maxLength = 2; if (editTextId == 5 || editTextId == 4 || editTextId == 8) { maxLength = 3; @@ -326,7 +326,7 @@ public class cgeocoords extends Dialog { if ((editTextId == 3 || editTextId == 7) && currentFormat == coordInputFormatEnum.Min) { maxLength = 3; } - + if (s.length() == maxLength) { switch (editTextId) { case 1: @@ -380,12 +380,12 @@ public class cgeocoords extends Dialog { @Override public void onTextChanged(CharSequence s, int start, int before, int count) {} } - + private void calc() { if (currentFormat == coordInputFormatEnum.Plain) { return; } - + int latDeg = 0, latMin = 0, latSec = 0, latSub = 0; int lonDeg = 0, lonMin = 0, lonSec = 0, lonSub = 0; try { @@ -422,7 +422,7 @@ public class cgeocoords extends Dialog { lonMinFrac /= 10; } latitude = latDeg + latMin/60.0 + latMinFrac/60.0; - longitude = lonDeg + lonMin/60.0 + lonMinFrac/60.0; + longitude = lonDeg + lonMin/60.0 + lonMinFrac/60.0; break; case Sec: Double latSecFrac = latSub * 1.0; @@ -440,14 +440,14 @@ public class cgeocoords extends Dialog { latitude *= (bLat.getText().toString() == "S" ? -1 : 1); longitude *= (bLon.getText().toString() == "W" ? -1 : 1); } - + private class CoordinateFormatListener implements OnItemSelectedListener { @Override public void onItemSelected(AdapterView<?> parent, View view, int pos, long id) { currentFormat = coordInputFormatEnum.fromInt(pos); settings.setCoordInputFormat(currentFormat); - updateGUI(); + updateGUI(); } @Override @@ -463,13 +463,13 @@ public class cgeocoords extends Dialog { context.showToast(context.getResources().getString(R.string.err_point_unknown_position)); return; } - + latitude = geo.latitudeNow; longitude = geo.longitudeNow; updateGUI(); } } - + private class InputDoneListener implements View.OnClickListener { @Override @@ -509,11 +509,11 @@ public class cgeocoords extends Dialog { dismiss(); } } - + public void setOnCoordinateUpdate(CoordinateUpdate cu) { cuListener = cu; } - + public interface CoordinateUpdate { public void update(ArrayList<Double> coords); } diff --git a/src/cgeo/geocaching/compatibility/AndroidLevel8Internal.java b/src/cgeo/geocaching/compatibility/AndroidLevel8Internal.java index cfc56da..c68f20e 100644 --- a/src/cgeo/geocaching/compatibility/AndroidLevel8Internal.java +++ b/src/cgeo/geocaching/compatibility/AndroidLevel8Internal.java @@ -8,7 +8,7 @@ class AndroidLevel8Internal { public AndroidLevel8Internal() { } - public int getRotation(final Activity activity) { + public static int getRotation(final Activity activity) { Display display = activity.getWindowManager().getDefaultDisplay(); return display.getRotation(); } diff --git a/src/cgeo/geocaching/files/GPXParser.java b/src/cgeo/geocaching/files/GPXParser.java index 64c36d3..255bed0 100644 --- a/src/cgeo/geocaching/files/GPXParser.java +++ b/src/cgeo/geocaching/files/GPXParser.java @@ -57,7 +57,7 @@ public abstract class GPXParser extends FileParser { nsGCList.add("http://www.groundspeak.com/cache/1/1"); // PQ 1.1 nsGCList.add("http://www.groundspeak.com/cache/1/0/1"); // PQ 1.0.1 nsGCList.add("http://www.groundspeak.com/cache/1/0"); // PQ 1.0 - + namespace = namespaceIn; version = versionIn; } @@ -546,7 +546,7 @@ public abstract class GPXParser extends FileParser { protected abstract Element getCacheParent(Element waypoint); - protected String validate(String input) { + protected static String validate(String input) { if ("nil".equalsIgnoreCase(input)) { return ""; } @@ -564,7 +564,7 @@ public abstract class GPXParser extends FileParser { } } } - + public static Long parseGPX(cgeoapplication app, File file, int listId, Handler handler) { cgSearch search = new cgSearch(); long searchId = 0l; diff --git a/src/cgeo/geocaching/mapcommon/cgeomap.java b/src/cgeo/geocaching/mapcommon/cgeomap.java index a6c5066..474b881 100644 --- a/src/cgeo/geocaching/mapcommon/cgeomap.java +++ b/src/cgeo/geocaching/mapcommon/cgeomap.java @@ -102,7 +102,6 @@ public class cgeomap extends MapBase { private DisplayUsersThread displayUsersThread = null; private LoadDetails loadDetailsThread = null; private volatile long loadThreadRun = 0l; - private volatile long downloadThreadRun = 0l; private volatile long usersThreadRun = 0l; private volatile boolean downloaded = false; // overlays @@ -469,7 +468,7 @@ public class cgeomap extends MapBase { private void addMapViewMenuItems(final Menu menu) { String[] mapViews = res.getStringArray(R.array.map_sources); mapSourceEnum mapSource = settings.mapSource; - + menu.add(1, SUBMENU_VIEW_GOOGLE_MAP, 0, mapViews[0]).setCheckable(true).setChecked(mapSource == mapSourceEnum.googleMap); menu.add(1, SUBMENU_VIEW_GOOGLE_SAT, 0, mapViews[1]).setCheckable(true).setChecked(mapSource == mapSourceEnum.googleSat); menu.add(1, SUBMENU_VIEW_MF_MAPNIK, 0, mapViews[2]).setCheckable(true).setChecked(mapSource == mapSourceEnum.mapsforgeMapnik); @@ -648,7 +647,7 @@ public class cgeomap extends MapBase { if (mapRestartRequired) { // close old mapview activity.finish(); - + // prepare information to restart a similar view Intent mapIntent = new Intent(activity, settings.getMapFactory().getMapClass()); @@ -664,10 +663,10 @@ public class cgeomap extends MapBase { mapState[1] = mapCenter.getLongitudeE6(); mapState[2] = mapView.getMapZoomLevel(); mapIntent.putExtra("mapstate", mapState); - + // start the new map activity.startActivity(mapIntent); - + } return true; @@ -703,7 +702,7 @@ public class cgeomap extends MapBase { prefsEdit.putInt("mapsource", settings.mapSource.ordinal()); prefsEdit.commit(); - + boolean mapRestartRequired = settings.mapSource.isGoogleMapSource()!= settings.mapSourceUsed.isGoogleMapSource(); if (!mapRestartRequired) { @@ -1151,7 +1150,6 @@ public class cgeomap extends MapBase { try { stop = false; working = true; - downloadThreadRun = System.currentTimeMillis(); if (stop) { displayHandler.sendEmptyMessage(0); @@ -1658,7 +1656,7 @@ public class cgeomap extends MapBase { } else { viewport = app.getBounds(searchIdCenter); } - + if (viewport == null) return; Integer cnt = (Integer) viewport.get(0); |
