aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/cgeo/geocaching/activity/AbstractActivity.java37
-rw-r--r--src/cgeo/geocaching/activity/AbstractListActivity.java40
-rw-r--r--src/cgeo/geocaching/activity/ActivityMixin.java42
-rw-r--r--src/cgeo/geocaching/activity/IAbstractActivity.java5
-rw-r--r--src/cgeo/geocaching/apps/AbstractApp.java2
-rw-r--r--src/cgeo/geocaching/apps/cache/navi/GoogleMapsApp.java8
-rw-r--r--src/cgeo/geocaching/apps/cache/navi/GoogleNavigationApp.java10
-rw-r--r--src/cgeo/geocaching/apps/cache/navi/InternalMap.java3
-rw-r--r--src/cgeo/geocaching/apps/cache/navi/LocusApp.java3
-rw-r--r--src/cgeo/geocaching/apps/cache/navi/NavigationApp.java3
-rw-r--r--src/cgeo/geocaching/apps/cache/navi/NavigationAppFactory.java5
-rw-r--r--src/cgeo/geocaching/apps/cache/navi/RMapsApp.java3
-rw-r--r--src/cgeo/geocaching/apps/cache/navi/RadarApp.java3
-rw-r--r--src/cgeo/geocaching/apps/cache/navi/StaticMapApp.java6
-rw-r--r--src/cgeo/geocaching/cgBase.java69
-rw-r--r--src/cgeo/geocaching/cgCacheListAdapter.java2
-rw-r--r--src/cgeo/geocaching/cgData.java70
-rw-r--r--src/cgeo/geocaching/cgDirection.java2
-rw-r--r--src/cgeo/geocaching/cgDirectionImg.java17
-rw-r--r--src/cgeo/geocaching/cgFileList.java39
-rw-r--r--src/cgeo/geocaching/cgGPXParser.java26
-rw-r--r--src/cgeo/geocaching/cgHtmlImg.java66
-rw-r--r--src/cgeo/geocaching/cgMapImg.java14
-rw-r--r--src/cgeo/geocaching/cgSettings.java6
-rw-r--r--src/cgeo/geocaching/cgWarning.java52
-rw-r--r--src/cgeo/geocaching/cgeo.java19
-rw-r--r--src/cgeo/geocaching/cgeoabout.java7
-rw-r--r--src/cgeo/geocaching/cgeoaddresses.java11
-rw-r--r--src/cgeo/geocaching/cgeoadvsearch.java41
-rw-r--r--src/cgeo/geocaching/cgeoapplication.java10
-rw-r--r--src/cgeo/geocaching/cgeoauth.java19
-rw-r--r--src/cgeo/geocaching/cgeocaches.java75
-rw-r--r--src/cgeo/geocaching/cgeodetail.java85
-rw-r--r--src/cgeo/geocaching/cgeogpxes.java12
-rw-r--r--src/cgeo/geocaching/cgeohelpers.java10
-rw-r--r--src/cgeo/geocaching/cgeoimages.java22
-rw-r--r--src/cgeo/geocaching/cgeoinit.java49
-rw-r--r--src/cgeo/geocaching/cgeonavigate.java29
-rw-r--r--src/cgeo/geocaching/cgeopoint.java65
-rw-r--r--src/cgeo/geocaching/cgeopopup.java39
-rw-r--r--src/cgeo/geocaching/cgeosmaps.java17
-rw-r--r--src/cgeo/geocaching/cgeotouch.java45
-rw-r--r--src/cgeo/geocaching/cgeotrackable.java39
-rw-r--r--src/cgeo/geocaching/cgeotrackables.java12
-rw-r--r--src/cgeo/geocaching/cgeovisit.java57
-rw-r--r--src/cgeo/geocaching/cgeowaypoint.java31
-rw-r--r--src/cgeo/geocaching/cgeowaypointadd.java61
-rw-r--r--src/cgeo/geocaching/mapcommon/cgeomap.java29
48 files changed, 557 insertions, 760 deletions
diff --git a/src/cgeo/geocaching/activity/AbstractActivity.java b/src/cgeo/geocaching/activity/AbstractActivity.java
index fa982b9..b42756a 100644
--- a/src/cgeo/geocaching/activity/AbstractActivity.java
+++ b/src/cgeo/geocaching/activity/AbstractActivity.java
@@ -1,12 +1,24 @@
package cgeo.geocaching.activity;
import android.app.Activity;
+import android.content.SharedPreferences;
+import android.content.res.Resources;
+import android.os.Bundle;
import android.view.View;
+import cgeo.geocaching.cgBase;
+import cgeo.geocaching.cgSettings;
+import cgeo.geocaching.cgeoapplication;
public abstract class AbstractActivity extends Activity implements IAbstractActivity {
private String helpTopic;
+ protected cgeoapplication app = null;
+ protected Resources res = null;
+ protected cgSettings settings = null;
+ protected cgBase base = null;
+ protected SharedPreferences prefs = null;
+
public AbstractActivity() {
this(null);
}
@@ -34,4 +46,29 @@ public abstract class AbstractActivity extends Activity implements IAbstractActi
final public void setTheme() {
ActivityMixin.setTheme(this);
}
+
+ public final void showToast(String text) {
+ ActivityMixin.showToast(this, text);
+ }
+
+ public final void showShortToast(String text) {
+ ActivityMixin.showShortToast(this, text);
+ }
+
+ public final void helpDialog(String title, String message) {
+ ActivityMixin.helpDialog(this, title, message);
+ }
+
+ @Override
+ public void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+
+ // init
+ res = this.getResources();
+ app = (cgeoapplication) this.getApplication();
+ prefs = getSharedPreferences(cgSettings.preferences, 0);
+ settings = new cgSettings(this, prefs);
+ base = new cgBase(app, settings, prefs);
+ }
+
}
diff --git a/src/cgeo/geocaching/activity/AbstractListActivity.java b/src/cgeo/geocaching/activity/AbstractListActivity.java
index 2a5dd7f..3985fe7 100644
--- a/src/cgeo/geocaching/activity/AbstractListActivity.java
+++ b/src/cgeo/geocaching/activity/AbstractListActivity.java
@@ -1,12 +1,25 @@
package cgeo.geocaching.activity;
import android.app.ListActivity;
+import android.content.SharedPreferences;
+import android.content.res.Resources;
+import android.os.Bundle;
import android.view.View;
+import cgeo.geocaching.cgBase;
+import cgeo.geocaching.cgSettings;
+import cgeo.geocaching.cgeoapplication;
-public abstract class AbstractListActivity extends ListActivity implements IAbstractActivity {
+public abstract class AbstractListActivity extends ListActivity implements
+ IAbstractActivity {
private String helpTopic;
+ protected cgeoapplication app = null;
+ protected Resources res = null;
+ protected cgSettings settings = null;
+ protected cgBase base = null;
+ protected SharedPreferences prefs = null;
+
public AbstractListActivity() {
this(null);
}
@@ -30,4 +43,29 @@ public abstract class AbstractListActivity extends ListActivity implements IAbst
final public void setTheme() {
ActivityMixin.setTheme(this);
}
+
+ public final void showToast(String text) {
+ ActivityMixin.showToast(this, text);
+ }
+
+ public final void showShortToast(String text) {
+ ActivityMixin.showShortToast(this, text);
+ }
+
+ public final void helpDialog(String title, String message) {
+ ActivityMixin.helpDialog(this, title, message);
+ }
+
+ @Override
+ public void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+
+ // init
+ res = this.getResources();
+ app = (cgeoapplication) this.getApplication();
+ prefs = getSharedPreferences(cgSettings.preferences, 0);
+ settings = new cgSettings(this, prefs);
+ base = new cgBase(app, settings, prefs);
+ }
+
}
diff --git a/src/cgeo/geocaching/activity/ActivityMixin.java b/src/cgeo/geocaching/activity/ActivityMixin.java
index 1dec962..541559c 100644
--- a/src/cgeo/geocaching/activity/ActivityMixin.java
+++ b/src/cgeo/geocaching/activity/ActivityMixin.java
@@ -2,11 +2,15 @@ package cgeo.geocaching.activity;
import gnu.android.app.appmanualclient.AppManualReaderClient;
import android.app.Activity;
+import android.app.AlertDialog;
import android.content.Context;
+import android.content.DialogInterface;
import android.content.Intent;
+import android.view.Gravity;
import android.view.View;
import android.widget.ProgressBar;
import android.widget.TextView;
+import android.widget.Toast;
import cgeo.geocaching.R;
import cgeo.geocaching.cgSettings;
import cgeo.geocaching.cgeo;
@@ -59,7 +63,7 @@ public final class ActivityMixin {
}
}
- public static void setTheme(final Activity activity) {
+ public final static void setTheme(final Activity activity) {
cgSettings settings = new cgSettings(activity, activity.getSharedPreferences(cgSettings.preferences, 0));
if (settings.skin == 1) {
activity.setTheme(R.style.light);
@@ -68,5 +72,41 @@ public final class ActivityMixin {
}
}
+ public final static void showToast(final Activity activity, final String text) {
+ if (text.length() > 0) {
+ Toast toast = Toast.makeText(activity, text, Toast.LENGTH_LONG);
+
+ toast.setGravity(Gravity.CENTER_HORIZONTAL|Gravity.BOTTOM, 0, 100);
+ toast.show();
+ }
+ }
+
+ public final static void showShortToast(final Activity activity, final String text) {
+ if (text.length() > 0) {
+ Toast toast = Toast.makeText(activity, text, Toast.LENGTH_SHORT);
+
+ toast.setGravity(Gravity.CENTER_HORIZONTAL|Gravity.BOTTOM, 0, 100);
+ toast.show();
+ }
+ }
+
+ public static final void helpDialog(final Activity activity, final String title, final String message) {
+ if (message == null || message.length() == 0) {
+ return;
+ }
+
+ AlertDialog.Builder dialog = new AlertDialog.Builder(activity);
+ dialog.setTitle(title);
+ dialog.setMessage(message);
+ dialog.setCancelable(true);
+ dialog.setNeutralButton("Ok", new DialogInterface.OnClickListener() {
+ public void onClick(DialogInterface dialog, int id) {
+ dialog.cancel();
+ }
+ });
+
+ AlertDialog alert = dialog.create();
+ alert.show();
+ }
}
diff --git a/src/cgeo/geocaching/activity/IAbstractActivity.java b/src/cgeo/geocaching/activity/IAbstractActivity.java
index e7cb7a8..c760b87 100644
--- a/src/cgeo/geocaching/activity/IAbstractActivity.java
+++ b/src/cgeo/geocaching/activity/IAbstractActivity.java
@@ -11,4 +11,9 @@ public interface IAbstractActivity {
public void setTheme();
+ public void showToast(String text);
+
+ public void showShortToast(String text);
+
+ public void helpDialog(String title, String message);
}
diff --git a/src/cgeo/geocaching/apps/AbstractApp.java b/src/cgeo/geocaching/apps/AbstractApp.java
index 155c9fd..ba8333c 100644
--- a/src/cgeo/geocaching/apps/AbstractApp.java
+++ b/src/cgeo/geocaching/apps/AbstractApp.java
@@ -67,7 +67,7 @@ public abstract class AbstractApp implements App {
return getName().hashCode();
}
- protected cgSettings getSettings(Activity activity) {
+ protected static cgSettings getSettings(Activity activity) {
return new cgSettings(activity,
activity.getSharedPreferences(cgSettings.preferences, 0));
}
diff --git a/src/cgeo/geocaching/apps/cache/navi/GoogleMapsApp.java b/src/cgeo/geocaching/apps/cache/navi/GoogleMapsApp.java
index 3b20210..6b05426 100644
--- a/src/cgeo/geocaching/apps/cache/navi/GoogleMapsApp.java
+++ b/src/cgeo/geocaching/apps/cache/navi/GoogleMapsApp.java
@@ -10,8 +10,8 @@ import cgeo.geocaching.R;
import cgeo.geocaching.cgCache;
import cgeo.geocaching.cgGeo;
import cgeo.geocaching.cgSettings;
-import cgeo.geocaching.cgWarning;
import cgeo.geocaching.cgWaypoint;
+import cgeo.geocaching.activity.ActivityMixin;
class GoogleMapsApp extends AbstractNavigationApp implements NavigationApp {
@@ -25,7 +25,7 @@ class GoogleMapsApp extends AbstractNavigationApp implements NavigationApp {
}
public boolean invoke(cgGeo geo, Activity activity, Resources res,
- cgWarning warning, cgCache cache,
+ cgCache cache,
Long searchId, cgWaypoint waypoint, Double latitude, Double longitude) {
if (cache == null && waypoint == null && latitude == null && longitude == null) {
return false;
@@ -47,8 +47,8 @@ class GoogleMapsApp extends AbstractNavigationApp implements NavigationApp {
Log.i(cgSettings.tag, "cgBase.runExternalMap: No maps application available.");
- if (warning != null && res != null) {
- warning.showToast(res.getString(R.string.err_application_no));
+ if (res != null) {
+ ActivityMixin.showToast(activity, res.getString(R.string.err_application_no));
}
return false;
diff --git a/src/cgeo/geocaching/apps/cache/navi/GoogleNavigationApp.java b/src/cgeo/geocaching/apps/cache/navi/GoogleNavigationApp.java
index cb81192..b8afb54 100644
--- a/src/cgeo/geocaching/apps/cache/navi/GoogleNavigationApp.java
+++ b/src/cgeo/geocaching/apps/cache/navi/GoogleNavigationApp.java
@@ -10,8 +10,8 @@ import cgeo.geocaching.R;
import cgeo.geocaching.cgCache;
import cgeo.geocaching.cgGeo;
import cgeo.geocaching.cgSettings;
-import cgeo.geocaching.cgWarning;
import cgeo.geocaching.cgWaypoint;
+import cgeo.geocaching.activity.ActivityMixin;
class GoogleNavigationApp extends AbstractNavigationApp implements
NavigationApp {
@@ -27,7 +27,7 @@ class GoogleNavigationApp extends AbstractNavigationApp implements
@Override
public boolean invoke(final cgGeo geo, final Activity activity, final Resources res,
- final cgWarning warning, final cgCache cache,
+ final cgCache cache,
final Long searchId, final cgWaypoint waypoint, final Double latitude, final Double longitude) {
if (activity == null) {
return false;
@@ -45,8 +45,8 @@ class GoogleNavigationApp extends AbstractNavigationApp implements
}
if (!navigationResult) {
- if (warning != null && res != null) {
- warning.showToast(res.getString(R.string.err_navigation_no));
+ if (res != null) {
+ ActivityMixin.showToast(activity, res.getString(R.string.err_navigation_no));
}
return false;
}
@@ -54,7 +54,7 @@ class GoogleNavigationApp extends AbstractNavigationApp implements
return true;
}
- private boolean navigateToCoordinates(cgGeo geo, Activity activity, Double latitude,
+ private static boolean navigateToCoordinates(cgGeo geo, Activity activity, Double latitude,
Double longitude) {
Double latitudeNow = null;
Double longitudeNow = null;
diff --git a/src/cgeo/geocaching/apps/cache/navi/InternalMap.java b/src/cgeo/geocaching/apps/cache/navi/InternalMap.java
index 75d073e..7604598 100644
--- a/src/cgeo/geocaching/apps/cache/navi/InternalMap.java
+++ b/src/cgeo/geocaching/apps/cache/navi/InternalMap.java
@@ -7,7 +7,6 @@ import cgeo.geocaching.R;
import cgeo.geocaching.cgCache;
import cgeo.geocaching.cgGeo;
import cgeo.geocaching.cgSettings;
-import cgeo.geocaching.cgWarning;
import cgeo.geocaching.cgWaypoint;
class InternalMap extends AbstractInternalMap implements
@@ -19,7 +18,7 @@ class InternalMap extends AbstractInternalMap implements
@Override
public boolean invoke(cgGeo geo, Activity activity, Resources res,
- cgWarning warning, cgCache cache,
+ cgCache cache,
Long searchId, cgWaypoint waypoint, Double latitude, Double longitude) {
cgSettings settings = getSettings(activity);
Intent mapIntent = new Intent(activity, settings.getMapFactory().getMapClass());
diff --git a/src/cgeo/geocaching/apps/cache/navi/LocusApp.java b/src/cgeo/geocaching/apps/cache/navi/LocusApp.java
index 6624d86..2d3a199 100644
--- a/src/cgeo/geocaching/apps/cache/navi/LocusApp.java
+++ b/src/cgeo/geocaching/apps/cache/navi/LocusApp.java
@@ -13,7 +13,6 @@ import android.net.Uri;
import cgeo.geocaching.cgBase;
import cgeo.geocaching.cgCache;
import cgeo.geocaching.cgGeo;
-import cgeo.geocaching.cgWarning;
import cgeo.geocaching.cgWaypoint;
import cgeo.geocaching.apps.AbstractLocusApp;
@@ -25,7 +24,7 @@ class LocusApp extends AbstractLocusApp implements NavigationApp {
@Override
public boolean invoke(cgGeo geo, Activity activity, Resources res,
- cgWarning warning, cgCache cache,
+ cgCache cache,
Long searchId, cgWaypoint waypoint, Double latitude, Double longitude) {
if (cache == null && waypoint == null && latitude == null
&& longitude == null) {
diff --git a/src/cgeo/geocaching/apps/cache/navi/NavigationApp.java b/src/cgeo/geocaching/apps/cache/navi/NavigationApp.java
index d3b3c36..2f52111 100644
--- a/src/cgeo/geocaching/apps/cache/navi/NavigationApp.java
+++ b/src/cgeo/geocaching/apps/cache/navi/NavigationApp.java
@@ -4,13 +4,12 @@ import android.app.Activity;
import android.content.res.Resources;
import cgeo.geocaching.cgCache;
import cgeo.geocaching.cgGeo;
-import cgeo.geocaching.cgWarning;
import cgeo.geocaching.cgWaypoint;
import cgeo.geocaching.apps.App;
interface NavigationApp extends App {
public boolean invoke(final cgGeo geo, final Activity activity,
- final Resources res, final cgWarning warning,
+ final Resources res,
final cgCache cache,
final Long searchId, final cgWaypoint waypoint,
final Double latitude, final Double longitude);
diff --git a/src/cgeo/geocaching/apps/cache/navi/NavigationAppFactory.java b/src/cgeo/geocaching/apps/cache/navi/NavigationAppFactory.java
index 47ec473..26b641f 100644
--- a/src/cgeo/geocaching/apps/cache/navi/NavigationAppFactory.java
+++ b/src/cgeo/geocaching/apps/cache/navi/NavigationAppFactory.java
@@ -8,7 +8,6 @@ import android.view.Menu;
import android.view.MenuItem;
import cgeo.geocaching.cgCache;
import cgeo.geocaching.cgGeo;
-import cgeo.geocaching.cgWarning;
import cgeo.geocaching.cgWaypoint;
import cgeo.geocaching.apps.AbstractAppFactory;
@@ -38,7 +37,7 @@ public final class NavigationAppFactory extends AbstractAppFactory {
public static boolean onMenuItemSelected(final MenuItem item,
final cgGeo geo, Activity activity, Resources res,
- cgWarning warning, cgCache cache,
+ cgCache cache,
Long searchId, cgWaypoint waypoint, ArrayList<Double> destination) {
NavigationApp app = (NavigationApp) getAppFromMenuItem(item, apps);
if (app != null) {
@@ -48,7 +47,7 @@ public final class NavigationAppFactory extends AbstractAppFactory {
latitude = destination.get(0);
longitude = destination.get(1);
}
- return app.invoke(geo, activity, res, warning, cache,
+ return app.invoke(geo, activity, res, cache,
searchId, waypoint, latitude, longitude);
}
return false;
diff --git a/src/cgeo/geocaching/apps/cache/navi/RMapsApp.java b/src/cgeo/geocaching/apps/cache/navi/RMapsApp.java
index 9de0053..80802ac 100644
--- a/src/cgeo/geocaching/apps/cache/navi/RMapsApp.java
+++ b/src/cgeo/geocaching/apps/cache/navi/RMapsApp.java
@@ -9,7 +9,6 @@ import android.content.res.Resources;
import cgeo.geocaching.R;
import cgeo.geocaching.cgCache;
import cgeo.geocaching.cgGeo;
-import cgeo.geocaching.cgWarning;
import cgeo.geocaching.cgWaypoint;
class RMapsApp extends AbstractNavigationApp implements NavigationApp {
@@ -22,7 +21,7 @@ class RMapsApp extends AbstractNavigationApp implements NavigationApp {
@Override
public boolean invoke(cgGeo geo, Activity activity, Resources res,
- cgWarning warning, cgCache cache,
+ cgCache cache,
Long searchId, cgWaypoint waypoint, Double latitude, Double longitude) {
if (cache == null && waypoint == null && latitude == null
&& longitude == null) {
diff --git a/src/cgeo/geocaching/apps/cache/navi/RadarApp.java b/src/cgeo/geocaching/apps/cache/navi/RadarApp.java
index 5bb1e6c..dff779d 100644
--- a/src/cgeo/geocaching/apps/cache/navi/RadarApp.java
+++ b/src/cgeo/geocaching/apps/cache/navi/RadarApp.java
@@ -7,7 +7,6 @@ import android.content.res.Resources;
import cgeo.geocaching.R;
import cgeo.geocaching.cgCache;
import cgeo.geocaching.cgGeo;
-import cgeo.geocaching.cgWarning;
import cgeo.geocaching.cgWaypoint;
class RadarApp extends AbstractNavigationApp implements NavigationApp {
@@ -33,7 +32,7 @@ class RadarApp extends AbstractNavigationApp implements NavigationApp {
@Override
public boolean invoke(cgGeo geo, Activity activity, Resources res,
- cgWarning warning, cgCache cache,
+ cgCache cache,
Long searchId, cgWaypoint waypoint, Double latitude, Double longitude) {
if (cache != null) {
if (cache.latitude != null && cache.longitude != null) {
diff --git a/src/cgeo/geocaching/apps/cache/navi/StaticMapApp.java b/src/cgeo/geocaching/apps/cache/navi/StaticMapApp.java
index 9082dd5..b6ae8c1 100644
--- a/src/cgeo/geocaching/apps/cache/navi/StaticMapApp.java
+++ b/src/cgeo/geocaching/apps/cache/navi/StaticMapApp.java
@@ -7,9 +7,9 @@ import android.content.res.Resources;
import cgeo.geocaching.R;
import cgeo.geocaching.cgCache;
import cgeo.geocaching.cgGeo;
-import cgeo.geocaching.cgWarning;
import cgeo.geocaching.cgWaypoint;
import cgeo.geocaching.cgeosmaps;
+import cgeo.geocaching.activity.ActivityMixin;
class StaticMapApp extends AbstractNavigationApp implements
NavigationApp {
@@ -25,11 +25,11 @@ class StaticMapApp extends AbstractNavigationApp implements
@Override
public boolean invoke(cgGeo geo, Activity activity, Resources res,
- cgWarning warning, cgCache cache,
+ cgCache cache,
Long searchId, cgWaypoint waypoint, Double latitude, Double longitude) {
if (cache == null || cache.reason == 0) {
- warning.showToast(res.getString(R.string.err_detail_no_map_static));
+ ActivityMixin.showToast(activity, res.getString(R.string.err_detail_no_map_static));
return true;
}
diff --git a/src/cgeo/geocaching/cgBase.java b/src/cgeo/geocaching/cgBase.java
index a4c7834..2001a01 100644
--- a/src/cgeo/geocaching/cgBase.java
+++ b/src/cgeo/geocaching/cgBase.java
@@ -65,6 +65,7 @@ import android.text.style.StrikethroughSpan;
import android.util.Log;
import android.view.Display;
import android.view.WindowManager;
+import cgeo.geocaching.activity.ActivityMixin;
public class cgBase {
@@ -355,7 +356,7 @@ public class cgBase {
}
}
- public String findViewstate(String page, int index) {
+ public static String findViewstate(String page, int index) {
String viewstate = null;
if (index == 0) {
@@ -472,13 +473,13 @@ public class cgBase {
return -5; // no login page
}
}
-
+
public static Boolean isPremium(String page)
{
if (checkLogin(page)) {
final Matcher matcherIsPremium = patternIsPremium.matcher(page);
return matcherIsPremium.find();
- } else
+ } else
return false;
}
@@ -953,13 +954,11 @@ public class cgBase {
}
// get direction images
- cgDirectionImg dirImgDownloader = new cgDirectionImg(settings);
for (cgCache oneCache : caches.cacheList) {
if (oneCache.latitude == null && oneCache.longitude == null && oneCache.direction == null && oneCache.directionImg != null) {
- dirImgDownloader.getDrawable(oneCache.geocode, oneCache.directionImg);
+ cgDirectionImg.getDrawable(oneCache.geocode, oneCache.directionImg);
}
}
- dirImgDownloader = null;
// get ratings
if (guids.size() > 0) {
@@ -988,7 +987,7 @@ public class cgBase {
return caches;
}
- public cgCacheWrap parseMapJSON(String url, String data) {
+ public static cgCacheWrap parseMapJSON(String url, String data) {
if (data == null || data.length() == 0) {
Log.e(cgSettings.tag, "cgeoBase.parseMapJSON: No page given");
return null;
@@ -1377,7 +1376,7 @@ public class cgBase {
if (matcherLatLon.groupCount() > 0) {
cache.latlon = getMatch(matcherLatLon.group(2)); // first is <b>
- HashMap<String, Object> tmp = this.parseLatlon(cache.latlon);
+ HashMap<String, Object> tmp = cgBase.parseLatlon(cache.latlon);
if (tmp.size() > 0) {
cache.latitude = (Double) tmp.get("latitude");
cache.longitude = (Double) tmp.get("longitude");
@@ -1848,7 +1847,7 @@ public class cgBase {
if (matcherWpLatLon.groupCount() > 1) {
waypoint.latlon = Html.fromHtml(matcherWpLatLon.group(2)).toString();
- final HashMap<String, Object> tmp = this.parseLatlon(waypoint.latlon);
+ final HashMap<String, Object> tmp = cgBase.parseLatlon(waypoint.latlon);
if (tmp.size() > 0) {
waypoint.latitude = (Double) tmp.get("latitude");
waypoint.longitude = (Double) tmp.get("longitude");
@@ -2092,12 +2091,12 @@ public class cgBase {
return ratings;
}
- public Long parseGPX(cgeoapplication app, File file, int listId, Handler handler) {
+ public static Long parseGPX(cgeoapplication app, File file, int listId, Handler handler) {
cgSearch search = new cgSearch();
long searchId = 0l;
try {
- cgGPXParser GPXparser = new cgGPXParser(app, this, listId, search);
+ cgGPXParser GPXparser = new cgGPXParser(app, listId, search);
searchId = GPXparser.parse(file, 10, handler);
if (searchId == 0l) {
@@ -2435,7 +2434,7 @@ public class cgBase {
return trackable;
}
- public ArrayList<Integer> parseTypes(String page) {
+ public static ArrayList<Integer> parseTypes(String page) {
if (page == null || page.length() == 0) {
return null;
}
@@ -2469,7 +2468,7 @@ public class cgBase {
return types;
}
- public ArrayList<cgTrackableLog> parseTrackableLog(String page) {
+ public static ArrayList<cgTrackableLog> parseTrackableLog(String page) {
if (page == null || page.length() == 0) {
return null;
}
@@ -2551,7 +2550,7 @@ public class cgBase {
return trackables;
}
- public int parseFindCount(String page) {
+ public static int parseFindCount(String page) {
if (page == null || page.length() == 0) {
return -1;
}
@@ -2716,7 +2715,7 @@ public class cgBase {
return result;
}
- public HashMap<String, Double> getRadialDistance(Double latitude, Double longitude, Double bearing, Double distance) {
+ public static HashMap<String, Double> getRadialDistance(Double latitude, Double longitude, Double bearing, Double distance) {
final Double rlat1 = latitude * deg2rad;
final Double rlon1 = longitude * deg2rad;
final Double rbearing = bearing * deg2rad;
@@ -2793,7 +2792,7 @@ public class cgBase {
}
}
- public HashMap<String, Object> parseLatlon(String latlon) {
+ public static HashMap<String, Object> parseLatlon(String latlon) {
final HashMap<String, Object> result = new HashMap<String, Object>();
final Pattern patternLatlon = Pattern.compile("([NS])[^\\d]*(\\d+)[^°]*° (\\d+)\\.(\\d+) ([WE])[^\\d]*(\\d+)[^°]*° (\\d+)\\.(\\d+)", Pattern.CASE_INSENSITIVE);
final Matcher matcherLatlon = patternLatlon.matcher(latlon);
@@ -2820,7 +2819,7 @@ public class cgBase {
return result;
}
- public String formatCoordinate(Double coord, String latlon, boolean degrees) {
+ public static String formatCoordinate(Double coord, String latlon, boolean degrees) {
String formatted = "";
if (coord == null) {
@@ -2862,7 +2861,7 @@ public class cgBase {
return formatted;
}
- public HashMap<String, Object> parseCoordinate(String coord, String latlon) {
+ public static HashMap<String, Object> parseCoordinate(String coord, String latlon) {
final HashMap<String, Object> coords = new HashMap<String, Object>();
final Pattern patternA = Pattern.compile("^([NSWE])[^\\d]*(\\d+)°? +(\\d+)([\\.|,](\\d+))?$", Pattern.CASE_INSENSITIVE);
@@ -4063,7 +4062,7 @@ public class cgBase {
}
}
- public void postTweetCache(cgeoapplication app, cgSettings settings, String geocode) {
+ public static void postTweetCache(cgeoapplication app, cgSettings settings, String geocode) {
final cgCache cache = app.getCacheByGeocode(geocode);
String name = cache.name;
if (name.length() > 84) {
@@ -4074,7 +4073,7 @@ public class cgBase {
postTweet(app, settings, status, null, null);
}
- public void postTweetTrackable(cgeoapplication app, cgSettings settings, String geocode) {
+ public static void postTweetTrackable(cgeoapplication app, cgSettings settings, String geocode) {
final cgTrackable trackable = app.getTrackableByGeocode(geocode);
String name = trackable.name;
if (name.length() > 82) {
@@ -4085,7 +4084,7 @@ public class cgBase {
postTweet(app, settings, status, null, null);
}
- public void postTweet(cgeoapplication app, cgSettings settings, String status, Double latitude, Double longitude) {
+ public static void postTweet(cgeoapplication app, cgSettings settings, String status, Double latitude, Double longitude) {
if (app == null) {
return;
}
@@ -4185,7 +4184,7 @@ public class cgBase {
}
}
- public String getLocalIpAddress() {
+ public static String getLocalIpAddress() {
try {
for (Enumeration<NetworkInterface> en = NetworkInterface.getNetworkInterfaces(); en.hasMoreElements();) {
NetworkInterface intf = en.nextElement();
@@ -4778,11 +4777,11 @@ public class cgBase {
}
}
- public String requestJSON(String host, String path, String params) {
+ public static String requestJSON(String host, String path, String params) {
return requestJSON("http://", host, path, "GET", params);
}
- public String requestJSON(String scheme, String host, String path, String method, String params) {
+ public static String requestJSON(String scheme, String host, String path, String method, String params) {
int httpCode = -1;
//String httpLocation = null;
@@ -5027,7 +5026,7 @@ public class cgBase {
return;
}
- final cgHtmlImg imgGetter = new cgHtmlImg(activity, settings, cache.geocode, false, listId, true);
+ final cgHtmlImg imgGetter = new cgHtmlImg(activity, cache.geocode, false, listId, true);
// store images from description
if (cache.description != null) {
@@ -5096,7 +5095,7 @@ public class cgBase {
final int finalEdge = edge;
Thread staticMapsThread = new Thread("getting static map") {@Override
public void run() {
- cgMapImg mapGetter = new cgMapImg(settings, code);
+ cgMapImg mapGetter = new cgMapImg(code);
mapGetter.getDrawable("http://maps.google.com/maps/api/staticmap?center=" + latlonMap + "&zoom=20&size=" + finalEdge + "x" + finalEdge + "&maptype=satellite&markers=icon%3A" + markerUrl + "%7C" + latlonMap + waypoints.toString() + "&sensor=false", 1);
mapGetter.getDrawable("http://maps.google.com/maps/api/staticmap?center=" + latlonMap + "&zoom=18&size=" + finalEdge + "x" + finalEdge + "&maptype=satellite&markers=icon%3A" + markerUrl + "%7C" + latlonMap + waypoints.toString() + "&sensor=false", 2);
@@ -5119,7 +5118,7 @@ public class cgBase {
}
}
- public void dropCache(cgeoapplication app, Activity activity, cgCache cache, Handler handler) {
+ public static void dropCache(cgeoapplication app, Activity activity, cgCache cache, Handler handler) {
try {
app.markDropped(cache.geocode);
app.removeCacheFromCache(cache.geocode);
@@ -5130,7 +5129,7 @@ public class cgBase {
}
}
- public boolean isInViewPort(int centerLat1, int centerLon1, int centerLat2, int centerLon2, int spanLat1, int spanLon1, int spanLat2, int spanLon2) {
+ public static boolean isInViewPort(int centerLat1, int centerLon1, int centerLat2, int centerLon2, int spanLat1, int spanLon1, int spanLat2, int spanLon2) {
try {
// expects coordinates in E6 format
final int left1 = centerLat1 - (spanLat1 / 2);
@@ -5163,7 +5162,7 @@ public class cgBase {
}
}
- public boolean isCacheInViewPort(int centerLat, int centerLon, int spanLat, int spanLon, Double cacheLat, Double cacheLon) {
+ public static boolean isCacheInViewPort(int centerLat, int centerLon, int spanLat, int spanLon, Double cacheLat, Double cacheLon) {
if (cacheLat == null || cacheLon == null) {
return false;
}
@@ -5415,11 +5414,11 @@ public class cgBase {
return icon;
}
- public boolean runNavigation(Activity activity, Resources res, cgSettings settings, cgWarning warning, Double latitude, Double longitude) {
- return runNavigation(activity, res, settings, warning, latitude, longitude, null, null);
+ public static boolean runNavigation(Activity activity, Resources res, cgSettings settings, Double latitude, Double longitude) {
+ return runNavigation(activity, res, settings, latitude, longitude, null, null);
}
- public boolean runNavigation(Activity activity, Resources res, cgSettings settings, cgWarning warning, Double latitude, Double longitude, Double latitudeNow, Double longitudeNow) {
+ public static boolean runNavigation(Activity activity, Resources res, cgSettings settings, Double latitude, Double longitude, Double latitudeNow, Double longitudeNow) {
if (activity == null) {
return false;
}
@@ -5453,8 +5452,8 @@ public class cgBase {
Log.i(cgSettings.tag, "cgBase.runNavigation: No navigation application available.");
- if (warning != null && res != null) {
- warning.showToast(res.getString(R.string.err_navigation_no));
+ if (res != null) {
+ ActivityMixin.showToast(activity, res.getString(R.string.err_navigation_no));
}
return false;
@@ -5483,7 +5482,7 @@ public class cgBase {
return usertoken;
}
- public Double getElevation(Double latitude, Double longitude) {
+ public static Double getElevation(Double latitude, Double longitude) {
Double elv = null;
try {
diff --git a/src/cgeo/geocaching/cgCacheListAdapter.java b/src/cgeo/geocaching/cgCacheListAdapter.java
index 6fa35e1..5ed88a3 100644
--- a/src/cgeo/geocaching/cgCacheListAdapter.java
+++ b/src/cgeo/geocaching/cgCacheListAdapter.java
@@ -520,7 +520,7 @@ public class cgCacheListAdapter extends ArrayAdapter<cgCache> {
Bitmap dirImgPre = null;
Bitmap dirImg = null;
try {
- dirImgPre = BitmapFactory.decodeFile(settings.getStorage() + cache.geocode + "/direction.png");
+ dirImgPre = BitmapFactory.decodeFile(cgSettings.getStorage() + cache.geocode + "/direction.png");
dirImg = dirImgPre.copy(Bitmap.Config.ARGB_8888, true);
dirImgPre.recycle();
diff --git a/src/cgeo/geocaching/cgData.java b/src/cgeo/geocaching/cgData.java
index 796e030..5429bac 100644
--- a/src/cgeo/geocaching/cgData.java
+++ b/src/cgeo/geocaching/cgData.java
@@ -156,7 +156,7 @@ public class cgData {
private static final String dbCreateLogImages = ""
+ "create table " + dbTableLogImages + " ("
+ "_id integer primary key autoincrement, "
- + "log_id integer not null, "
+ + "log_id integer not null, "
+ "title text not null, "
+ "url text not null"
+ "); ";
@@ -182,7 +182,7 @@ public class cgData {
+ "description text, "
+ "geocode text "
+ "); ";
-
+
private static final String dbCreateSearchDestinationHistory = ""
+ "create table " + dbTableSearchDestionationHistory + " ("
+ "_id integer primary key autoincrement, "
@@ -190,7 +190,7 @@ public class cgData {
+ "latitude double, "
+ "longitude double "
+ "); ";
-
+
public boolean initialized = false;
public cgData(Context contextIn) {
@@ -329,7 +329,7 @@ public class cgData {
return null;
}
- public File isRestoreFile() {
+ public static File isRestoreFile() {
final String directoryImg = cgSettings.cache;
final String fileSource = Environment.getExternalStorageDirectory() + "/" + directoryImg + "/cgeo.sqlite";
@@ -721,7 +721,7 @@ public class cgData {
Log.e(cgSettings.tag, "Failed to upgrade to ver. 52", e);
}
}
-
+
if (oldVersion < 53) { // upgrade to 53
try {
db.execSQL("alter table " + dbTableCaches + " add column onWatchlist integer");
@@ -734,7 +734,7 @@ public class cgData {
if (oldVersion < 54) { // update to 54
try {
- db.execSQL(dbCreateLogImages);
+ db.execSQL(dbCreateLogImages);
} catch (Exception e) {
Log.e(cgSettings.tag, "Failed to upgrade to ver. 54: " + e.toString());
@@ -743,7 +743,7 @@ public class cgData {
if (oldVersion < 55) { // update to 55
try {
- db.execSQL("alter table " + dbTableCaches + " add column personal_note text");
+ db.execSQL("alter table " + dbTableCaches + " add column personal_note text");
} catch (Exception e) {
Log.e(cgSettings.tag, "Failed to upgrade to ver. 55: " + e.toString());
@@ -1270,12 +1270,12 @@ public class cgData {
return true;
}
-
+
/**
- * Persists the given <code>destination</code> into the database.
- *
+ * Persists the given <code>destination</code> into the database.
+ *
* @param destinations
- * @return <code>true</code> if the given destination was successfully
+ * @return <code>true</code> if the given destination was successfully
* persisted <code>false</code> otherwise.
*/
public boolean saveSearchedDestination(cgDestination destination) {
@@ -1287,13 +1287,13 @@ public class cgData {
init();
databaseRW.beginTransaction();
-
+
try {
ContentValues values = new ContentValues();
values.put("date", destination.getDate());
values.put("latitude", destination.getLatitude());
values.put("longitude", destination.getLongitude());
-
+
long id = databaseRW.insert(dbTableSearchDestionationHistory, null, values);
destination.setId(id);
databaseRW.setTransactionSuccessful();
@@ -1475,10 +1475,10 @@ public class cgData {
values.put("log", oneLog.log);
values.put("date", oneLog.date);
values.put("found", oneLog.found);
-
+
long log_id = databaseRW.insert(dbTableLogs, null, values);
-
- if ((oneLog.logImages != null) && (oneLog.logImages.size() > 0)) {
+
+ if ((oneLog.logImages != null) && (oneLog.logImages.size() > 0)) {
for (cgImage img : oneLog.logImages) {
values.clear();
values.put("log_id", log_id);
@@ -1864,7 +1864,7 @@ public class cgData {
cache.attributes.addAll(attributes);
}
}
-
+
if (loadW == true) {
ArrayList<cgWaypoint> waypoints = loadWaypoints(cache.geocode);
if (waypoints != null && waypoints.isEmpty() == false) {
@@ -2128,11 +2128,11 @@ public class cgData {
return spoilers;
}
-
+
/**
* Loads the history of previously entered destinations from
* the database. If no destinations exist, an {@link Collections#emptyList()}
- * will be returned.
+ * will be returned.
* @return A list of previously entered destinations or an empty list.
*/
public List<cgDestination> loadHistoryOfSearchedLocations() {
@@ -2146,7 +2146,7 @@ public class cgData {
null, null, null, "date desc", "100");
destinations = new LinkedList<cgDestination>();
-
+
if (cursor != null && cursor.getCount() > 0) {
cursor.moveToFirst();
@@ -2162,19 +2162,19 @@ public class cgData {
} while (cursor.moveToNext());
}
-
+
if (cursor != null) {
cursor.close();
}
return destinations;
}
-
+
public boolean clearSearchedDestinations() {
boolean success = true;
init();
databaseRW.beginTransaction();
-
+
try {
databaseRW.delete(dbTableSearchDestionationHistory, null, null);
databaseRW.setTransactionSuccessful();
@@ -2185,7 +2185,7 @@ public class cgData {
finally{
databaseRW.endTransaction();
}
-
+
return success;
}
@@ -2221,7 +2221,7 @@ public class cgData {
log.date = (long) cursor.getLong(cursor.getColumnIndex("date"));
log.found = (int) cursor.getInt(cursor.getColumnIndex("found"));
log.logImages = loadLogImages(log.id);
-
+
logs.add(log);
} while (cursor.moveToNext());
}
@@ -2270,12 +2270,12 @@ public class cgData {
return logCounts;
}
-
+
public ArrayList<cgImage> loadLogImages(int log_id) {
init();
-
+
ArrayList<cgImage> logImgList = new ArrayList<cgImage>();
-
+
Cursor cursor = null;
cursor = databaseRO.query(
dbTableLogImages,
@@ -2286,7 +2286,7 @@ public class cgData {
null,
null,
"100");
-
+
if (cursor != null && cursor.getCount() > 0) {
cursor.moveToFirst();
@@ -2301,8 +2301,8 @@ public class cgData {
if (cursor != null) {
cursor.close();
}
-
- return logImgList;
+
+ return logImgList;
}
public ArrayList<cgTrackable> loadInventory(String geocode) {
@@ -3016,7 +3016,7 @@ public class cgData {
Log.e(cgSettings.tag, "cgData.saveVisitDate: " + e.toString());
}
}
-
+
public void clearVisitDate(String geocode) {
if (geocode == null || geocode.length() == 0) {
return;
@@ -3212,9 +3212,9 @@ public class cgData {
success = false;
} else{
init();
-
+
databaseRW.beginTransaction();
-
+
try {
databaseRW.delete(dbTableSearchDestionationHistory, "_id = " +destination.getId(), null);
databaseRW.setTransactionSuccessful();
@@ -3225,7 +3225,7 @@ public class cgData {
databaseRW.endTransaction();
}
}
-
+
return success;
}
}
diff --git a/src/cgeo/geocaching/cgDirection.java b/src/cgeo/geocaching/cgDirection.java
index 284e8ff..e99f898 100644
--- a/src/cgeo/geocaching/cgDirection.java
+++ b/src/cgeo/geocaching/cgDirection.java
@@ -17,7 +17,7 @@ public class cgDirection {
public Double directionNow = null;
- public cgDirection(cgeoapplication appIn, Context contextIn, cgUpdateDir dirUpdateIn, cgWarning warningIn) {
+ public cgDirection(Context contextIn, cgUpdateDir dirUpdateIn) {
context = contextIn;
dirUpdate = dirUpdateIn;
sensorListener = new cgeoSensorListener();
diff --git a/src/cgeo/geocaching/cgDirectionImg.java b/src/cgeo/geocaching/cgDirectionImg.java
index fdfc2c5..52ff7f3 100644
--- a/src/cgeo/geocaching/cgDirectionImg.java
+++ b/src/cgeo/geocaching/cgDirectionImg.java
@@ -1,10 +1,10 @@
package cgeo.geocaching;
-import android.util.Log;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
+
import org.apache.http.HttpEntity;
import org.apache.http.HttpResponse;
import org.apache.http.client.HttpClient;
@@ -12,14 +12,11 @@ import org.apache.http.client.methods.HttpGet;
import org.apache.http.entity.BufferedHttpEntity;
import org.apache.http.impl.client.DefaultHttpClient;
-public class cgDirectionImg {
- private cgSettings settings = null;
+import android.util.Log;
- public cgDirectionImg(cgSettings settingsIn) {
- settings = settingsIn;
- }
+public class cgDirectionImg {
- public void getDrawable(String geocode, String code) {
+ public static void getDrawable(String geocode, String code) {
String dirName;
String fileName;
@@ -28,14 +25,14 @@ public class cgDirectionImg {
}
if (geocode != null && geocode.length() > 0) {
- dirName = settings.getStorage() + geocode + "/";
- fileName = settings.getStorage() + geocode + "/direction.png";
+ dirName = cgSettings.getStorage() + geocode + "/";
+ fileName = cgSettings.getStorage() + geocode + "/direction.png";
} else {
return;
}
File dir = null;
- dir = new File(settings.getStorage());
+ dir = new File(cgSettings.getStorage());
if (dir.exists() == false) {
dir.mkdirs();
}
diff --git a/src/cgeo/geocaching/cgFileList.java b/src/cgeo/geocaching/cgFileList.java
index 21a6b6b..633e2fb 100644
--- a/src/cgeo/geocaching/cgFileList.java
+++ b/src/cgeo/geocaching/cgFileList.java
@@ -5,7 +5,6 @@ import java.util.ArrayList;
import android.app.ProgressDialog;
import android.content.DialogInterface;
-import android.content.res.Resources;
import android.os.Bundle;
import android.os.Environment;
import android.os.Handler;
@@ -17,13 +16,8 @@ import cgeo.geocaching.activity.AbstractListActivity;
public abstract class cgFileList<T extends ArrayAdapter<File>> extends AbstractListActivity {
private ArrayList<File> files = new ArrayList<File>();
- private cgeoapplication app = null;
- private cgSettings settings = null;
- private cgBase base = null;
- private cgWarning warning = null;
private T adapter = null;
private ProgressDialog waitDialog = null;
- private Resources res = null;
private loadFiles searchingThread = null;
private boolean endSearching = false;
private int listId = 1;
@@ -32,7 +26,7 @@ public abstract class cgFileList<T extends ArrayAdapter<File>> extends AbstractL
@Override
public void handleMessage(Message msg) {
if (msg.obj != null && waitDialog != null) {
- waitDialog.setMessage(getRes().getString(R.string.file_searching_in) + " " + (String) msg.obj);
+ waitDialog.setMessage(res.getString(R.string.file_searching_in) + " " + (String) msg.obj);
}
}
};
@@ -46,7 +40,7 @@ public abstract class cgFileList<T extends ArrayAdapter<File>> extends AbstractL
waitDialog.dismiss();
}
- getWarning().showToast(getRes().getString(R.string.file_list_no_files));
+ showToast(res.getString(R.string.file_list_no_files));
finish();
return;
@@ -72,16 +66,9 @@ public abstract class cgFileList<T extends ArrayAdapter<File>> extends AbstractL
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
- // init
- res = this.getResources();
- app = (cgeoapplication) this.getApplication();
- settings = new cgSettings(this, getSharedPreferences(cgSettings.preferences, 0));
- base = new cgBase(getApp(), getSettings(), getSharedPreferences(cgSettings.preferences, 0));
- warning = new cgWarning(this);
-
setTheme();
setContentView(R.layout.gpx);
- setTitle(getRes().getString(R.string.gpx_import_title));
+ setTitle(res.getString(R.string.gpx_import_title));
Bundle extras = getIntent().getExtras();
if (extras != null) {
@@ -95,8 +82,8 @@ public abstract class cgFileList<T extends ArrayAdapter<File>> extends AbstractL
waitDialog = ProgressDialog.show(
this,
- getRes().getString(R.string.file_title_searching),
- getRes().getString(R.string.file_searching),
+ res.getString(R.string.file_title_searching),
+ res.getString(R.string.file_searching),
true,
true,
new DialogInterface.OnCancelListener() {
@@ -241,20 +228,4 @@ public abstract class cgFileList<T extends ArrayAdapter<File>> extends AbstractL
return;
}
-
- protected cgeoapplication getApp() {
- return app;
- }
-
- protected cgBase getBase() {
- return base;
- }
-
- protected cgWarning getWarning() {
- return warning;
- }
-
- protected Resources getRes() {
- return res;
- }
}
diff --git a/src/cgeo/geocaching/cgGPXParser.java b/src/cgeo/geocaching/cgGPXParser.java
index e3cc3d2..ab76226 100644
--- a/src/cgeo/geocaching/cgGPXParser.java
+++ b/src/cgeo/geocaching/cgGPXParser.java
@@ -1,5 +1,14 @@
package cgeo.geocaching;
+import java.io.File;
+import java.io.FileInputStream;
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+import org.xml.sax.Attributes;
+
import android.os.Handler;
import android.os.Message;
import android.sax.Element;
@@ -10,18 +19,10 @@ import android.sax.StartElementListener;
import android.text.Html;
import android.util.Log;
import android.util.Xml;
-import java.io.File;
-import java.io.FileInputStream;
-import java.util.ArrayList;
-import java.util.Date;
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
-import org.xml.sax.Attributes;
public class cgGPXParser {
private cgeoapplication app = null;
- private cgBase base = null;
private int listId = 1;
private cgSearch search = null;
private Handler handler = null;
@@ -39,9 +40,8 @@ public class cgGPXParser {
private String cmt = null;
private String desc = null;
- public cgGPXParser(cgeoapplication appIn, cgBase baseIn, int listIdIn, cgSearch searchIn) {
+ public cgGPXParser(cgeoapplication appIn, int listIdIn, cgSearch searchIn) {
app = appIn;
- base = baseIn;
listId = listIdIn;
search = searchIn;
@@ -130,8 +130,8 @@ public class cgGPXParser {
&& ((type == null && sym == null)
|| (type != null && type.indexOf("geocache") > -1)
|| (sym != null && sym.indexOf("geocache") > -1))) {
- cache.latitudeString = base.formatCoordinate(cache.latitude, "lat", true);
- cache.longitudeString = base.formatCoordinate(cache.longitude, "lon", true);
+ cache.latitudeString = cgBase.formatCoordinate(cache.latitude, "lat", true);
+ cache.longitudeString = cgBase.formatCoordinate(cache.longitude, "lon", true);
if (cache.inventory != null) {
cache.inventoryItems = cache.inventory.size();
} else {
@@ -234,7 +234,7 @@ public class cgGPXParser {
}
}
});
-
+
// for GPX 1.0, cache info comes from waypoint node (so called private children,
// for GPX 1.1 from extensions node
final Element cacheParent = version == 11 ? waypoint.getChild(ns, "extensions") : waypoint;
diff --git a/src/cgeo/geocaching/cgHtmlImg.java b/src/cgeo/geocaching/cgHtmlImg.java
index 645e9d2..36fc1fc 100644
--- a/src/cgeo/geocaching/cgHtmlImg.java
+++ b/src/cgeo/geocaching/cgHtmlImg.java
@@ -1,21 +1,11 @@
package cgeo.geocaching;
-import android.app.Activity;
-import android.util.Log;
-import android.text.Html;
-import android.view.Display;
-import android.view.WindowManager;
-import android.content.Context;
-import android.graphics.Rect;
-import android.graphics.Bitmap;
-import android.graphics.BitmapFactory;
-import android.graphics.drawable.BitmapDrawable;
-import android.net.Uri;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.util.Date;
+
import org.apache.http.HttpEntity;
import org.apache.http.HttpResponse;
import org.apache.http.client.HttpClient;
@@ -23,10 +13,21 @@ import org.apache.http.client.methods.HttpGet;
import org.apache.http.entity.BufferedHttpEntity;
import org.apache.http.impl.client.DefaultHttpClient;
+import android.app.Activity;
+import android.content.Context;
+import android.graphics.Bitmap;
+import android.graphics.BitmapFactory;
+import android.graphics.Rect;
+import android.graphics.drawable.BitmapDrawable;
+import android.net.Uri;
+import android.text.Html;
+import android.util.Log;
+import android.view.Display;
+import android.view.WindowManager;
+
public class cgHtmlImg implements Html.ImageGetter {
private Activity activity = null;
- private cgSettings settings = null;
private String geocode = null;
private boolean placement = true;
private int reason = 0;
@@ -39,14 +40,13 @@ public class cgHtmlImg implements Html.ImageGetter {
private double ratio = 1.0d;
private int width = 0;
private int height = 0;
-
- public cgHtmlImg(Activity activityIn, cgSettings settingsIn, String geocodeIn, boolean placementIn, int reasonIn, boolean onlySaveIn) {
- this(activityIn, settingsIn, geocodeIn, placementIn, reasonIn, onlySaveIn, true);
+
+ public cgHtmlImg(Activity activityIn, String geocodeIn, boolean placementIn, int reasonIn, boolean onlySaveIn) {
+ this(activityIn, geocodeIn, placementIn, reasonIn, onlySaveIn, true);
}
-
- public cgHtmlImg(Activity activityIn, cgSettings settingsIn, String geocodeIn, boolean placementIn, int reasonIn, boolean onlySaveIn, boolean saveIn) {
+
+ public cgHtmlImg(Activity activityIn, String geocodeIn, boolean placementIn, int reasonIn, boolean onlySaveIn, boolean saveIn) {
activity = activityIn;
- settings = settingsIn;
geocode = geocodeIn;
placement = placementIn;
reason = reasonIn;
@@ -54,10 +54,10 @@ public class cgHtmlImg implements Html.ImageGetter {
save = saveIn;
bfOptions.inTempStorage = new byte[16 * 1024];
-
+
display = ((WindowManager) activity.getSystemService(Context.WINDOW_SERVICE)).getDefaultDisplay();
maxWidth = display.getWidth() - 25;
- maxHeight = display.getHeight() - 25;
+ maxHeight = display.getHeight() - 25;
}
@Override
@@ -83,17 +83,17 @@ public class cgHtmlImg implements Html.ImageGetter {
}
if (geocode != null && geocode.length() > 0) {
- dirName = settings.getStorage() + geocode + "/";
- fileName = settings.getStorage() + geocode + "/" + cgBase.md5(url) + urlExt;
- fileNameSec = settings.getStorageSec() + geocode + "/" + cgBase.md5(url) + urlExt;
+ dirName = cgSettings.getStorage() + geocode + "/";
+ fileName = cgSettings.getStorage() + geocode + "/" + cgBase.md5(url) + urlExt;
+ fileNameSec = cgSettings.getStorageSec() + geocode + "/" + cgBase.md5(url) + urlExt;
} else {
- dirName = settings.getStorage() + "_others/";
- fileName = settings.getStorage() + "_others/" + cgBase.md5(url) + urlExt;
- fileNameSec = settings.getStorageSec() + "_others/" + cgBase.md5(url) + urlExt;
+ dirName = cgSettings.getStorage() + "_others/";
+ fileName = cgSettings.getStorage() + "_others/" + cgBase.md5(url) + urlExt;
+ fileNameSec = cgSettings.getStorageSec() + "_others/" + cgBase.md5(url) + urlExt;
}
-
+
File dir = null;
- dir = new File(settings.getStorage());
+ dir = new File(cgSettings.getStorage());
if (dir.exists() == false) {
dir.mkdirs();
}
@@ -157,7 +157,7 @@ public class cgHtmlImg implements Html.ImageGetter {
Log.w(cgSettings.tag, "cgHtmlImg.getDrawable (reading cache): " + e.toString());
}
}
-
+
// download image and save it to the cache
if ((imagePre == null && reason == 0) || onlySave == true) {
Uri uri = null;
@@ -246,7 +246,7 @@ public class cgHtmlImg implements Html.ImageGetter {
entity = null;
bufferedEntity = null;
}
-
+
if (onlySave == true) {
return null;
}
@@ -264,7 +264,7 @@ public class cgHtmlImg implements Html.ImageGetter {
final int imgWidth = imagePre.getWidth();
final int imgHeight = imagePre.getHeight();
-
+
if (imgWidth > maxWidth || imgHeight > maxHeight) {
if ((maxWidth / imgWidth) > (maxHeight / imgHeight)) {
ratio = (double) maxHeight / (double) imgHeight;
@@ -288,7 +288,7 @@ public class cgHtmlImg implements Html.ImageGetter {
final BitmapDrawable image = new BitmapDrawable(imagePre);
image.setBounds(new Rect(0, 0, width, height));
-
+
return image;
- }
+ }
}
diff --git a/src/cgeo/geocaching/cgMapImg.java b/src/cgeo/geocaching/cgMapImg.java
index 57639ff..207971a 100644
--- a/src/cgeo/geocaching/cgMapImg.java
+++ b/src/cgeo/geocaching/cgMapImg.java
@@ -1,10 +1,10 @@
package cgeo.geocaching;
-import android.util.Log;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
+
import org.apache.http.HttpEntity;
import org.apache.http.HttpResponse;
import org.apache.http.client.HttpClient;
@@ -12,23 +12,23 @@ import org.apache.http.client.methods.HttpGet;
import org.apache.http.entity.BufferedHttpEntity;
import org.apache.http.impl.client.DefaultHttpClient;
+import android.util.Log;
+
public class cgMapImg {
/**
* in my tests the "no image available" image had 5470 bytes, while "street only" maps had at least 20000 bytes
*/
private static final int MIN_MAP_IMAGE_BYTES = 6000;
- private cgSettings settings = null;
private String geocode = null;
- public cgMapImg(cgSettings settingsIn, String geocodeIn) {
+ public cgMapImg(String geocodeIn) {
geocode = geocodeIn;
- settings = settingsIn;
if (geocode != null && geocode.length() > 0) {
- final String dirName = settings.getStorage() + geocode + "/";
+ final String dirName = cgSettings.getStorage() + geocode + "/";
File dir = null;
- dir = new File(settings.getStorage());
+ dir = new File(cgSettings.getStorage());
if (dir.exists() == false) {
dir.mkdirs();
}
@@ -49,7 +49,7 @@ public class cgMapImg {
return;
}
- final String fileName = settings.getStorage() + geocode + "/map_" + level;
+ final String fileName = cgSettings.getStorage() + geocode + "/map_" + level;
HttpClient client = null;
HttpGet getMethod = null;
HttpResponse httpResponse = null;
diff --git a/src/cgeo/geocaching/cgSettings.java b/src/cgeo/geocaching/cgSettings.java
index f63db7e..15ad6b9 100644
--- a/src/cgeo/geocaching/cgSettings.java
+++ b/src/cgeo/geocaching/cgSettings.java
@@ -224,15 +224,15 @@ public class cgSettings {
cacheType = prefs.getString(KEY_CACHE_TYPE, null);
}
- public String getStorage() {
+ public static String getStorage() {
return getStorageSpecific(null)[0];
}
- public String getStorageSec() {
+ public static String getStorageSec() {
return getStorageSpecific(null)[1];
}
- public String[] getStorageSpecific(Boolean hidden) {
+ public static String[] getStorageSpecific(Boolean hidden) {
String external = Environment.getExternalStorageDirectory() + "/" + cache + "/";
String data = Environment.getDataDirectory() + "/data/cgeo.geocaching/" + cache + "/";
diff --git a/src/cgeo/geocaching/cgWarning.java b/src/cgeo/geocaching/cgWarning.java
deleted file mode 100644
index 93ddec7..0000000
--- a/src/cgeo/geocaching/cgWarning.java
+++ /dev/null
@@ -1,52 +0,0 @@
-package cgeo.geocaching;
-
-import android.app.AlertDialog;
-import android.content.Context;
-import android.content.DialogInterface;
-import android.widget.Toast;
-import android.view.Gravity;
-
-public class cgWarning {
- public Context context = null;
-
- public cgWarning(Context contextIn) {
- context = contextIn;
- }
-
- public void showToast(String text) {
- if (text.length() > 0) {
- Toast toast = Toast.makeText(context, text, Toast.LENGTH_LONG);
-
- toast.setGravity(Gravity.CENTER_HORIZONTAL|Gravity.BOTTOM, 0, 100);
- toast.show();
- }
- }
-
- public void showShortToast(String text) {
- if (text.length() > 0) {
- Toast toast = Toast.makeText(context, text, Toast.LENGTH_SHORT);
-
- toast.setGravity(Gravity.CENTER_HORIZONTAL|Gravity.BOTTOM, 0, 100);
- toast.show();
- }
- }
-
- public void helpDialog(String title, String message) {
- if (message == null || message.length() == 0) {
- return;
- }
-
- AlertDialog.Builder dialog = new AlertDialog.Builder(context);
- dialog.setTitle(title);
- dialog.setMessage(message);
- dialog.setCancelable(true);
- dialog.setNeutralButton("Ok", new DialogInterface.OnClickListener() {
- public void onClick(DialogInterface dialog, int id) {
- dialog.cancel();
- }
- });
-
- AlertDialog alert = dialog.create();
- alert.show();
- }
-}
diff --git a/src/cgeo/geocaching/cgeo.java b/src/cgeo/geocaching/cgeo.java
index 285d8b4..790d5cc 100644
--- a/src/cgeo/geocaching/cgeo.java
+++ b/src/cgeo/geocaching/cgeo.java
@@ -13,7 +13,6 @@ import android.content.SharedPreferences;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import android.content.res.Configuration;
-import android.content.res.Resources;
import android.location.Address;
import android.location.Geocoder;
import android.os.Bundle;
@@ -32,13 +31,7 @@ import cgeo.geocaching.activity.ActivityMixin;
public class cgeo extends AbstractActivity {
- private Resources res = null;
- private cgeoapplication app = null;
private Context context = null;
- private cgSettings settings = null;
- private SharedPreferences prefs = null;
- private cgBase base = null;
- private cgWarning warning = null;
private Integer version = null;
private cgGeo geo = null;
private cgUpdateLoc geoUpdate = new update();
@@ -126,13 +119,7 @@ public class cgeo extends AbstractActivity {
super.onCreate(savedInstanceState);
context = this;
- res = this.getResources();
- app = (cgeoapplication) this.getApplication();
app.setAction(null);
- settings = new cgSettings(this, getSharedPreferences(cgSettings.preferences, 0));
- prefs = getSharedPreferences(cgSettings.preferences, 0);
- base = new cgBase(app, settings, getSharedPreferences(cgSettings.preferences, 0));
- warning = new cgWarning(this);
app.cleanGeo();
app.cleanDir();
@@ -381,7 +368,7 @@ public class cgeo extends AbstractActivity {
}
if (geo == null) {
- geo = app.startGeo(context, geoUpdate, base, settings, warning, 0, 0);
+ geo = app.startGeo(context, geoUpdate, base, settings, 0, 0);
}
navType = (TextView) findViewById(R.id.nav_type);
@@ -485,9 +472,9 @@ public class cgeo extends AbstractActivity {
} else {
humanAlt = String.format("%.0f", geo.altitudeNow) + " m";
}
- navLocation.setText(base.formatCoordinate(geo.latitudeNow, "lat", true) + " | " + base.formatCoordinate(geo.longitudeNow, "lon", true) + " | " + humanAlt);
+ navLocation.setText(cgBase.formatCoordinate(geo.latitudeNow, "lat", true) + " | " + cgBase.formatCoordinate(geo.longitudeNow, "lon", true) + " | " + humanAlt);
} else {
- navLocation.setText(base.formatCoordinate(geo.latitudeNow, "lat", true) + " | " + base.formatCoordinate(geo.longitudeNow, "lon", true));
+ navLocation.setText(cgBase.formatCoordinate(geo.latitudeNow, "lat", true) + " | " + cgBase.formatCoordinate(geo.longitudeNow, "lon", true));
}
}
} else {
diff --git a/src/cgeo/geocaching/cgeoabout.java b/src/cgeo/geocaching/cgeoabout.java
index db40b53..25219ab 100644
--- a/src/cgeo/geocaching/cgeoabout.java
+++ b/src/cgeo/geocaching/cgeoabout.java
@@ -3,7 +3,6 @@ package cgeo.geocaching;
import android.content.Intent;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
-import android.content.res.Resources;
import android.net.Uri;
import android.os.Bundle;
import android.text.method.LinkMovementMethod;
@@ -13,17 +12,11 @@ import android.widget.TextView;
import cgeo.geocaching.activity.AbstractActivity;
public class cgeoabout extends AbstractActivity {
- private Resources res = null;
- private cgSettings settings = null;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
- // init
- res = this.getResources();
- settings = new cgSettings(this, this.getSharedPreferences(cgSettings.preferences, 0));
-
setTheme();
setContentView(R.layout.about);
setTitle(res.getString(R.string.about));
diff --git a/src/cgeo/geocaching/cgeoaddresses.java b/src/cgeo/geocaching/cgeoaddresses.java
index 731cb8a..a5e7f37 100644
--- a/src/cgeo/geocaching/cgeoaddresses.java
+++ b/src/cgeo/geocaching/cgeoaddresses.java
@@ -6,7 +6,6 @@ import java.util.Locale;
import android.app.ProgressDialog;
import android.content.Intent;
-import android.content.res.Resources;
import android.location.Address;
import android.location.Geocoder;
import android.os.Bundle;
@@ -22,9 +21,6 @@ import cgeo.geocaching.activity.AbstractActivity;
public class cgeoaddresses extends AbstractActivity {
private final ArrayList<Address> addresses = new ArrayList<Address>();
private String keyword = null;
- private cgSettings settings = null;
- private Resources res = null;
- private cgWarning warning = null;
private LayoutInflater inflater = null;
private LinearLayout addList = null;
private ProgressDialog waitDialog = null;
@@ -42,7 +38,7 @@ public class cgeoaddresses extends AbstractActivity {
waitDialog.dismiss();
}
- warning.showToast(res.getString(R.string.err_search_address_no_match));
+ showToast(res.getString(R.string.err_search_address_no_match));
finish();
return;
@@ -95,9 +91,6 @@ public class cgeoaddresses extends AbstractActivity {
super.onCreate(savedInstanceState);
// init
- res = this.getResources();
- settings = new cgSettings(this, getSharedPreferences(cgSettings.preferences, 0));
- warning = new cgWarning(this);
inflater = getLayoutInflater();
setTheme();
@@ -113,7 +106,7 @@ public class cgeoaddresses extends AbstractActivity {
}
if (keyword == null) {
- warning.showToast(res.getString(R.string.err_search_address_forgot));
+ showToast(res.getString(R.string.err_search_address_forgot));
finish();
return;
}
diff --git a/src/cgeo/geocaching/cgeoadvsearch.java b/src/cgeo/geocaching/cgeoadvsearch.java
index f3fd16d..031ab5c 100644
--- a/src/cgeo/geocaching/cgeoadvsearch.java
+++ b/src/cgeo/geocaching/cgeoadvsearch.java
@@ -7,7 +7,6 @@ import java.util.regex.Pattern;
import android.app.SearchManager;
import android.content.Intent;
import android.content.res.Configuration;
-import android.content.res.Resources;
import android.os.Bundle;
import android.text.Editable;
import android.text.TextWatcher;
@@ -24,11 +23,6 @@ import cgeo.geocaching.activity.AbstractActivity;
public class cgeoadvsearch extends AbstractActivity {
- private Resources res = null;
- private cgeoapplication app = null;
- private cgSettings settings = null;
- private cgBase base = null;
- private cgWarning warning = null;
private cgGeo geo = null;
private cgUpdateLoc geoUpdate = new update();
private EditText latEdit = null;
@@ -44,12 +38,7 @@ public class cgeoadvsearch extends AbstractActivity {
super.onCreate(savedInstanceState);
// init
- res = this.getResources();
- app = (cgeoapplication) this.getApplication();
app.setAction(null);
- settings = new cgSettings(this, getSharedPreferences(cgSettings.preferences, 0));
- base = new cgBase(app, settings, getSharedPreferences(cgSettings.preferences, 0));
- warning = new cgWarning(this);
// search query
Intent intent = getIntent();
@@ -159,7 +148,7 @@ public class cgeoadvsearch extends AbstractActivity {
}
if (geo == null) {
- geo = app.startGeo(this, geoUpdate, base, settings, warning, 0, 0);
+ geo = app.startGeo(this, geoUpdate, base, settings, 0, 0);
}
((EditText) findViewById(R.id.latitude)).setOnEditorActionListener(new findByCoordsAction());
@@ -261,8 +250,8 @@ public class cgeoadvsearch extends AbstractActivity {
}
if (geo.latitudeNow != null && geo.longitudeNow != null) {
- latEdit.setHint(base.formatCoordinate(geo.latitudeNow, "lat", false));
- lonEdit.setHint(base.formatCoordinate(geo.longitudeNow, "lon", false));
+ latEdit.setHint(cgBase.formatCoordinate(geo.latitudeNow, "lat", false));
+ lonEdit.setHint(cgBase.formatCoordinate(geo.longitudeNow, "lon", false));
}
} catch (Exception e) {
Log.w(cgSettings.tag, "Failed to update location.");
@@ -297,19 +286,19 @@ public class cgeoadvsearch extends AbstractActivity {
final String lonText = lonView.getText().toString();
if (latText == null || latText.length() == 0 || lonText == null || lonText.length() == 0) {
- latView.setText(base.formatCoordinate(geo.latitudeNow, "lat", true));
- lonView.setText(base.formatCoordinate(geo.longitudeNow, "lon", true));
+ latView.setText(cgBase.formatCoordinate(geo.latitudeNow, "lat", true));
+ lonView.setText(cgBase.formatCoordinate(geo.longitudeNow, "lon", true));
} else {
- HashMap<String, Object> latParsed = base.parseCoordinate(latText, "lat");
- HashMap<String, Object> lonParsed = base.parseCoordinate(lonText, "lat");
+ HashMap<String, Object> latParsed = cgBase.parseCoordinate(latText, "lat");
+ HashMap<String, Object> lonParsed = cgBase.parseCoordinate(lonText, "lat");
if (latParsed == null || latParsed.get("coordinate") == null || latParsed.get("string") == null) {
- warning.showToast(res.getString(R.string.err_parse_lat));
+ showToast(res.getString(R.string.err_parse_lat));
return;
}
if (lonParsed == null || lonParsed.get("coordinate") == null || lonParsed.get("string") == null) {
- warning.showToast(res.getString(R.string.err_parse_lon));
+ showToast(res.getString(R.string.err_parse_lon));
return;
}
@@ -347,7 +336,7 @@ public class cgeoadvsearch extends AbstractActivity {
String keyText = ((EditText) findViewById(R.id.keyword)).getText().toString();
if (keyText == null || keyText.length() == 0) {
- warning.helpDialog(res.getString(R.string.warn_search_help_title), res.getString(R.string.warn_search_help_keyword));
+ helpDialog(res.getString(R.string.warn_search_help_title), res.getString(R.string.warn_search_help_keyword));
return;
}
@@ -382,7 +371,7 @@ public class cgeoadvsearch extends AbstractActivity {
final String addText = ((EditText) findViewById(R.id.address)).getText().toString();
if (addText == null || addText.length() == 0) {
- warning.helpDialog(res.getString(R.string.warn_search_help_title), res.getString(R.string.warn_search_help_address));
+ helpDialog(res.getString(R.string.warn_search_help_title), res.getString(R.string.warn_search_help_address));
return;
}
@@ -415,7 +404,7 @@ public class cgeoadvsearch extends AbstractActivity {
final String usernameText = ((EditText) findViewById(R.id.username)).getText().toString();
if (usernameText == null || usernameText.length() == 0) {
- warning.helpDialog(res.getString(R.string.warn_search_help_title), res.getString(R.string.warn_search_help_user));
+ helpDialog(res.getString(R.string.warn_search_help_title), res.getString(R.string.warn_search_help_user));
return;
}
@@ -450,7 +439,7 @@ public class cgeoadvsearch extends AbstractActivity {
final String usernameText = ((EditText) findViewById(R.id.owner)).getText().toString();
if (usernameText == null || usernameText.length() == 0) {
- warning.helpDialog(res.getString(R.string.warn_search_help_title), res.getString(R.string.warn_search_help_user));
+ helpDialog(res.getString(R.string.warn_search_help_title), res.getString(R.string.warn_search_help_user));
return;
}
@@ -485,7 +474,7 @@ public class cgeoadvsearch extends AbstractActivity {
final String geocodeText = ((EditText) findViewById(R.id.geocode)).getText().toString();
if (geocodeText == null || geocodeText.length() == 0 || geocodeText.equalsIgnoreCase("GC")) {
- warning.helpDialog(res.getString(R.string.warn_search_help_title), res.getString(R.string.warn_search_help_gccode));
+ helpDialog(res.getString(R.string.warn_search_help_title), res.getString(R.string.warn_search_help_gccode));
return;
}
@@ -518,7 +507,7 @@ public class cgeoadvsearch extends AbstractActivity {
final String trackableText = ((EditText) findViewById(R.id.trackable)).getText().toString();
if (trackableText == null || trackableText.length() == 0 || trackableText.equalsIgnoreCase("TB")) {
- warning.helpDialog(res.getString(R.string.warn_search_help_title), res.getString(R.string.warn_search_help_tb));
+ helpDialog(res.getString(R.string.warn_search_help_title), res.getString(R.string.warn_search_help_tb));
return;
}
diff --git a/src/cgeo/geocaching/cgeoapplication.java b/src/cgeo/geocaching/cgeoapplication.java
index 651fdbe..2560728 100644
--- a/src/cgeo/geocaching/cgeoapplication.java
+++ b/src/cgeo/geocaching/cgeoapplication.java
@@ -66,8 +66,8 @@ public class cgeoapplication extends Application {
return storage.backupDatabase();
}
- public File isRestoreFile() {
- return storage.isRestoreFile();
+ public static File isRestoreFile() {
+ return cgData.isRestoreFile();
}
public boolean restoreDatabase() {
@@ -96,7 +96,7 @@ public class cgeoapplication extends Application {
return true;
}
- public cgGeo startGeo(Context context, cgUpdateLoc geoUpdate, cgBase base, cgSettings settings, cgWarning warning, int time, int distance) {
+ public cgGeo startGeo(Context context, cgUpdateLoc geoUpdate, cgBase base, cgSettings settings, int time, int distance) {
if (geo == null) {
geo = new cgGeo(context, this, geoUpdate, base, settings, time, distance);
geo.initGeo();
@@ -140,9 +140,9 @@ public class cgeoapplication extends Application {
}
}
- public cgDirection startDir(Context context, cgUpdateDir dirUpdate, cgWarning warning) {
+ public cgDirection startDir(Context context, cgUpdateDir dirUpdate) {
if (dir == null) {
- dir = new cgDirection(this, context, dirUpdate, warning);
+ dir = new cgDirection(context, dirUpdate);
dir.initDir();
Log.i(cgSettings.tag, "Direction service started");
diff --git a/src/cgeo/geocaching/cgeoauth.java b/src/cgeo/geocaching/cgeoauth.java
index 7108c9d..8f1aa01 100644
--- a/src/cgeo/geocaching/cgeoauth.java
+++ b/src/cgeo/geocaching/cgeoauth.java
@@ -17,7 +17,6 @@ import javax.net.ssl.HttpsURLConnection;
import android.app.ProgressDialog;
import android.content.Intent;
import android.content.SharedPreferences;
-import android.content.res.Resources;
import android.net.Uri;
import android.os.Bundle;
import android.os.Handler;
@@ -29,11 +28,6 @@ import android.widget.EditText;
import cgeo.geocaching.activity.AbstractActivity;
public class cgeoauth extends AbstractActivity {
- private cgeoapplication app = null;
- private Resources res = null;
- private cgSettings settings = null;
- private cgWarning warning = null;
- private SharedPreferences prefs = null;
private String OAtoken = null;
private String OAtokenSecret = null;
private final Pattern paramsPattern1 = Pattern.compile("oauth_token=([a-zA-Z0-9\\-\\_\\.]+)");
@@ -61,7 +55,7 @@ public class cgeoauth extends AbstractActivity {
pinEntryButton.setVisibility(View.VISIBLE);
pinEntryButton.setOnClickListener(new confirmPINListener());
} else {
- warning.showToast(res.getString(R.string.err_auth_initialize));
+ showToast(res.getString(R.string.err_auth_initialize));
startButton.setText(res.getString(R.string.auth_start));
}
}
@@ -78,13 +72,13 @@ public class cgeoauth extends AbstractActivity {
pinEntryButton.setEnabled(true);
if (msg.what == 1) {
- warning.showToast(res.getString(R.string.auth_dialog_completed));
+ showToast(res.getString(R.string.auth_dialog_completed));
pinEntryButton.setVisibility(View.GONE);
finish();
} else {
- warning.showToast(res.getString(R.string.err_auth_process));
+ showToast(res.getString(R.string.err_auth_process));
pinEntry.setVisibility(View.GONE);
pinEntryButton.setVisibility(View.GONE);
@@ -98,12 +92,7 @@ public class cgeoauth extends AbstractActivity {
super.onCreate(savedInstanceState);
// init
- res = this.getResources();
- app = (cgeoapplication) this.getApplication();
app.setAction("setting up");
- prefs = getSharedPreferences(cgSettings.preferences, 0);
- settings = new cgSettings(this, prefs);
- warning = new cgWarning(this);
setTheme();
setContentView(R.layout.auth);
@@ -373,7 +362,7 @@ public class cgeoauth extends AbstractActivity {
public void onClick(View arg0) {
if (((EditText) findViewById(R.id.pin)).getText().toString().length() == 0) {
- warning.helpDialog(res.getString(R.string.auth_dialog_pin_title), res.getString(R.string.auth_dialog_pin_message));
+ helpDialog(res.getString(R.string.auth_dialog_pin_title), res.getString(R.string.auth_dialog_pin_message));
return;
}
diff --git a/src/cgeo/geocaching/cgeocaches.java b/src/cgeo/geocaching/cgeocaches.java
index f1fea9a..b045477 100644
--- a/src/cgeo/geocaching/cgeocaches.java
+++ b/src/cgeo/geocaching/cgeocaches.java
@@ -19,7 +19,6 @@ import android.app.ProgressDialog;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.res.Configuration;
-import android.content.res.Resources;
import android.net.Uri;
import android.os.Bundle;
import android.os.Environment;
@@ -132,15 +131,10 @@ public class cgeocaches extends AbstractListActivity {
private String username = null;
private Long searchId = null;
private ArrayList<cgCache> cacheList = new ArrayList<cgCache>();
- private cgeoapplication app = null;
- private Resources res = null;
private cgCacheListAdapter adapter = null;
private LayoutInflater inflater = null;
private View listFooter = null;
private TextView listFooterText = null;
- private cgSettings settings = null;
- private cgBase base = null;
- private cgWarning warning = null;
private ProgressDialog waitDialog = null;
private Double northHeading = new Double(0);
private cgGeo geo = null;
@@ -183,7 +177,7 @@ public class cgeocaches extends AbstractListActivity {
setAdapter();
if (cacheList == null) {
- warning.showToast(res.getString(R.string.err_list_load_fail));
+ showToast(res.getString(R.string.err_list_load_fail));
setMoreCaches(false);
} else {
final Integer count = app.getTotal(searchId);
@@ -222,7 +216,7 @@ public class cgeocaches extends AbstractListActivity {
AlertDialog alert = dialog.create();
alert.show();
} else if (app != null && app.getError(searchId) != null && app.getError(searchId).length() > 0) {
- warning.showToast(res.getString(R.string.err_download_fail) + app.getError(searchId) + ".");
+ showToast(res.getString(R.string.err_download_fail) + app.getError(searchId) + ".");
hideLoading();
showProgress(false);
@@ -236,7 +230,7 @@ public class cgeocaches extends AbstractListActivity {
adapter.setActualHeading(northHeading);
}
} catch (Exception e) {
- warning.showToast(res.getString(R.string.err_detail_cache_find_any));
+ showToast(res.getString(R.string.err_detail_cache_find_any));
Log.e(cgSettings.tag, "cgeocaches.loadCachesHandler: " + e.toString());
hideLoading();
@@ -283,7 +277,7 @@ public class cgeocaches extends AbstractListActivity {
setAdapter();
if (cacheList == null) {
- warning.showToast(res.getString(R.string.err_list_load_fail));
+ showToast(res.getString(R.string.err_list_load_fail));
setMoreCaches(false);
} else {
final Integer count = app.getTotal(searchId);
@@ -299,7 +293,7 @@ public class cgeocaches extends AbstractListActivity {
}
if (app.getError(searchId) != null && app.getError(searchId).length() > 0) {
- warning.showToast(res.getString(R.string.err_download_fail) + app.getError(searchId) + ".");
+ showToast(res.getString(R.string.err_download_fail) + app.getError(searchId) + ".");
listFooter.setOnClickListener(new moreCachesListener());
hideLoading();
@@ -314,7 +308,7 @@ public class cgeocaches extends AbstractListActivity {
adapter.setActualHeading(northHeading);
}
} catch (Exception e) {
- warning.showToast(res.getString(R.string.err_detail_cache_find_next));
+ showToast(res.getString(R.string.err_detail_cache_find_next));
Log.e(cgSettings.tag, "cgeocaches.loadNextPageHandler: " + e.toString());
}
@@ -377,10 +371,10 @@ public class cgeocaches extends AbstractListActivity {
}
if (geo == null) {
- geo = app.startGeo(cgeocaches.this, geoUpdate, base, settings, warning, 0, 0);
+ geo = app.startGeo(cgeocaches.this, geoUpdate, base, settings, 0, 0);
}
if (settings.livelist == 1 && settings.useCompass == 1 && dir == null) {
- dir = app.startDir(cgeocaches.this, dirUpdate, warning);
+ dir = app.startDir(cgeocaches.this, dirUpdate);
}
}
}
@@ -407,8 +401,8 @@ public class cgeocaches extends AbstractListActivity {
waitDialog.dismiss();
waitDialog.setOnCancelListener(null);
}
- getWindow().clearFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
- warning.showToast(res.getString(R.string.gpx_import_no_files));
+ getWindow().clearFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
+ showToast(res.getString(R.string.gpx_import_no_files));
finish();
return;
} else {
@@ -502,11 +496,11 @@ public class cgeocaches extends AbstractListActivity {
}
else if (-2 == msg.what)
{
- warning.showToast(res.getString(R.string.info_fieldnotes_exported_to) + ": " + msg.obj.toString());
+ showToast(res.getString(R.string.info_fieldnotes_exported_to) + ": " + msg.obj.toString());
}
else if (-3 == msg.what)
{
- warning.showToast(res.getString(R.string.err_fieldnotes_export_failed));
+ showToast(res.getString(R.string.err_fieldnotes_export_failed));
}
else
{
@@ -534,12 +528,7 @@ public class cgeocaches extends AbstractListActivity {
super.onCreate(savedInstanceState);
// init
- res = this.getResources();
- app = (cgeoapplication) this.getApplication();
app.setAction(action);
- settings = new cgSettings(this, getSharedPreferences(cgSettings.preferences, 0));
- base = new cgBase(app, settings, getSharedPreferences(cgSettings.preferences, 0));
- warning = new cgWarning(this);
setTheme();
setContentView(R.layout.caches);
@@ -602,7 +591,7 @@ public class cgeocaches extends AbstractListActivity {
thread.start();
} else if (type.equals("coordinate") == true) {
action = "planning";
- title = base.formatCoordinate(latitude, res.getString(R.string.search_lat), true) + " | " + base.formatCoordinate(longitude, res.getString(R.string.search_lon), true);
+ title = cgBase.formatCoordinate(latitude, res.getString(R.string.search_lat), true) + " | " + cgBase.formatCoordinate(longitude, res.getString(R.string.search_lon), true);
setTitle(title);
showProgress(true);
setLoadingCaches();
@@ -627,7 +616,7 @@ public class cgeocaches extends AbstractListActivity {
showProgress(true);
setLoadingCaches();
} else {
- title = base.formatCoordinate(latitude, res.getString(R.string.search_lat), true) + " | " + base.formatCoordinate(longitude, res.getString(R.string.search_lon), true);
+ title = cgBase.formatCoordinate(latitude, res.getString(R.string.search_lat), true) + " | " + cgBase.formatCoordinate(longitude, res.getString(R.string.search_lon), true);
setTitle(title);
showProgress(true);
setLoadingCaches();
@@ -1128,7 +1117,7 @@ public class cgeocaches extends AbstractListActivity {
return true;
} else if (id == MENU_LOG_VISIT) {
if (cache.cacheid == null || cache.cacheid.length() == 0) {
- warning.showToast(res.getString(R.string.err_cannot_log_visit));
+ showToast(res.getString(R.string.err_cannot_log_visit));
return true;
}
@@ -1200,7 +1189,7 @@ public class cgeocaches extends AbstractListActivity {
} else if (id == MENU_FILTER_TYPE_GPS) {
return setFilter(new cgFilterByType("gps"));
} else if (id == MENU_DROP_CACHE) {
- base.dropCache(app, this, cache, new Handler() {
+ cgBase.dropCache(app, this, cache, new Handler() {
@Override
public void handleMessage(Message msg) {
switchList(listId, -1); // refresh
@@ -1220,7 +1209,7 @@ public class cgeocaches extends AbstractListActivity {
lastMenuInfo = info;
return NavigationAppFactory.onMenuItemSelected(item, geo, this,
- res, warning, cache, null, null, null);
+ res, cache, null, null, null);
}
private boolean setFilter(cgFilter filter) {
@@ -1321,10 +1310,10 @@ public class cgeocaches extends AbstractListActivity {
private void init() {
// sensor & geolocation manager
if (geo == null) {
- geo = app.startGeo(this, geoUpdate, base, settings, warning, 0, 0);
+ geo = app.startGeo(this, geoUpdate, base, settings, 0, 0);
}
if (settings.livelist == 1 && settings.useCompass == 1 && dir == null) {
- dir = app.startDir(this, dirUpdate, warning);
+ dir = app.startDir(this, dirUpdate);
}
if (cacheList != null) {
@@ -1387,10 +1376,10 @@ public class cgeocaches extends AbstractListActivity {
}
if (geo == null) {
- geo = app.startGeo(cgeocaches.this, geoUpdate, base, settings, warning, 0, 0);
+ geo = app.startGeo(cgeocaches.this, geoUpdate, base, settings, 0, 0);
}
if (settings.livelist == 1 && settings.useCompass == 1 && dir == null) {
- dir = app.startDir(cgeocaches.this, dirUpdate, warning);
+ dir = app.startDir(cgeocaches.this, dirUpdate);
}
} catch (Exception e) {
Log.e(cgSettings.tag, "cgeocaches.onOptionsItemSelected.onCancel: " + e.toString());
@@ -1543,10 +1532,10 @@ public class cgeocaches extends AbstractListActivity {
}
if (geo == null) {
- geo = app.startGeo(cgeocaches.this, geoUpdate, base, settings, warning, 0, 0);
+ geo = app.startGeo(cgeocaches.this, geoUpdate, base, settings, 0, 0);
}
if (settings.livelist == 1 && settings.useCompass == 1 && dir == null) {
- dir = app.startDir(cgeocaches.this, dirUpdate, warning);
+ dir = app.startDir(cgeocaches.this, dirUpdate);
}
} catch (Exception e) {
Log.e(cgSettings.tag, "cgeocaches.importWeb.onCancel: " + e.toString());
@@ -1756,7 +1745,7 @@ public class cgeocaches extends AbstractListActivity {
cachetype = cachetypeIn;
if (latitude == null || longitude == null) {
- warning.showToast(res.getString(R.string.warn_no_coordinates));
+ showToast(res.getString(R.string.warn_no_coordinates));
finish();
return;
@@ -1790,7 +1779,7 @@ public class cgeocaches extends AbstractListActivity {
cachetype = cachetypeIn;
if (keyword == null) {
- warning.showToast(res.getString(R.string.warn_no_keyword));
+ showToast(res.getString(R.string.warn_no_keyword));
finish();
return;
@@ -1823,7 +1812,7 @@ public class cgeocaches extends AbstractListActivity {
cachetype = cachetypeIn;
if (username == null || username.length() == 0) {
- warning.showToast(res.getString(R.string.warn_no_username));
+ showToast(res.getString(R.string.warn_no_username));
finish();
return;
@@ -1856,7 +1845,7 @@ public class cgeocaches extends AbstractListActivity {
cachetype = cachetypeIn;
if (username == null || username.length() == 0) {
- warning.showToast(res.getString(R.string.warn_no_username));
+ showToast(res.getString(R.string.warn_no_username));
finish();
return;
@@ -2422,9 +2411,9 @@ public class cgeocaches extends AbstractListActivity {
int newId = app.createList(value);
if (newId >= 10) {
- warning.showToast(res.getString(R.string.list_dialog_create_ok));
+ showToast(res.getString(R.string.list_dialog_create_ok));
} else {
- warning.showToast(res.getString(R.string.list_dialog_create_err));
+ showToast(res.getString(R.string.list_dialog_create_err));
}
}
}
@@ -2448,10 +2437,10 @@ public class cgeocaches extends AbstractListActivity {
boolean status = app.removeList(listId);
if (status) {
- warning.showToast(res.getString(R.string.list_dialog_remove_ok));
+ showToast(res.getString(R.string.list_dialog_remove_ok));
switchListById(1);
} else {
- warning.showToast(res.getString(R.string.list_dialog_remove_err));
+ showToast(res.getString(R.string.list_dialog_remove_err));
}
}
});
@@ -2466,7 +2455,7 @@ public class cgeocaches extends AbstractListActivity {
public void goMap(View view) {
if (searchId == null || searchId == 0 || cacheList == null || cacheList.isEmpty() == true) {
- warning.showToast(res.getString(R.string.warn_no_cache_coord));
+ showToast(res.getString(R.string.warn_no_cache_coord));
return;
}
diff --git a/src/cgeo/geocaching/cgeodetail.java b/src/cgeo/geocaching/cgeodetail.java
index d929d85..8062dd0 100644
--- a/src/cgeo/geocaching/cgeodetail.java
+++ b/src/cgeo/geocaching/cgeodetail.java
@@ -16,7 +16,6 @@ import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.res.Configuration;
-import android.content.res.Resources;
import android.database.Cursor;
import android.graphics.drawable.BitmapDrawable;
import android.graphics.drawable.Drawable;
@@ -61,12 +60,7 @@ public class cgeodetail extends AbstractActivity {
public String geocode = null;
public String name = null;
public String guid = null;
- private Resources res = null;
private LayoutInflater inflater = null;
- private cgeoapplication app = null;
- private cgSettings settings = null;
- private cgBase base = null;
- private cgWarning warning = null;
private cgGeo geo = null;
private cgUpdateLoc geoUpdate = new update();
private float pixelRatio = 1;
@@ -95,7 +89,7 @@ public class cgeodetail extends AbstractActivity {
try {
cache = app.getCache(searchId); // reload cache details
} catch (Exception e) {
- warning.showToast(res.getString(R.string.err_store_failed));
+ showToast(res.getString(R.string.err_store_failed));
Log.e(cgSettings.tag, "cgeodetail.storeCacheHandler: " + e.toString());
}
@@ -112,7 +106,7 @@ public class cgeodetail extends AbstractActivity {
try {
cache = app.getCache(searchId); // reload cache details
} catch (Exception e) {
- warning.showToast(res.getString(R.string.err_refresh_failed));
+ showToast(res.getString(R.string.err_refresh_failed));
Log.e(cgSettings.tag, "cgeodetail.refreshCacheHandler: " + e.toString());
}
@@ -127,7 +121,7 @@ public class cgeodetail extends AbstractActivity {
try {
cache = app.getCache(searchId); // reload cache details
} catch (Exception e) {
- warning.showToast(res.getString(R.string.err_drop_failed));
+ showToast(res.getString(R.string.err_drop_failed));
Log.e(cgSettings.tag, "cgeodetail.dropCacheHandler: " + e.toString());
}
@@ -140,14 +134,14 @@ public class cgeodetail extends AbstractActivity {
@Override
public void handleMessage(Message msg) {
if (searchId == null || searchId <= 0) {
- warning.showToast(res.getString(R.string.err_dwld_details_failed));
+ showToast(res.getString(R.string.err_dwld_details_failed));
finish();
return;
}
if (app.getError(searchId) != null) {
- warning.showToast(res.getString(R.string.err_dwld_details_failed_reason) + " " + app.getError(searchId) + ".");
+ showToast(res.getString(R.string.err_dwld_details_failed_reason) + " " + app.getError(searchId) + ".");
finish();
return;
@@ -201,7 +195,7 @@ public class cgeodetail extends AbstractActivity {
@Override
public void handleMessage(Message msg) {
if (longDesc == null && cache != null && cache.description != null) {
- longDesc = Html.fromHtml(cache.description.trim(), new cgHtmlImg(cgeodetail.this, settings, geocode, true, cache.reason, false), null);
+ longDesc = Html.fromHtml(cache.description.trim(), new cgHtmlImg(cgeodetail.this, geocode, true, cache.reason, false), null);
}
if (longDesc != null) {
@@ -221,7 +215,7 @@ public class cgeodetail extends AbstractActivity {
showDesc.setOnTouchListener(null);
showDesc.setOnClickListener(null);
} else {
- warning.showToast(res.getString(R.string.err_load_descr_failed));
+ showToast(res.getString(R.string.err_load_descr_failed));
}
if (descDialog != null && descDialog.isShowing()) {
@@ -261,7 +255,7 @@ public class cgeodetail extends AbstractActivity {
if (watchlistDialog != null)
watchlistDialog.dismiss();
if (msg.what == -1) {
- warning.showToast(res.getString(R.string.err_watchlist_failed));
+ showToast(res.getString(R.string.err_watchlist_failed));
} else {
updateWatchlistBox();
}
@@ -271,13 +265,6 @@ public class cgeodetail extends AbstractActivity {
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
- // init
- res = this.getResources();
- app = (cgeoapplication) this.getApplication();
- settings = new cgSettings(this, getSharedPreferences(cgSettings.preferences, 0));
- base = new cgBase(app, settings, getSharedPreferences(cgSettings.preferences, 0));
- warning = new cgWarning(this);
-
setTheme();
setContentView(R.layout.detail);
setTitle(res.getString(R.string.cache));
@@ -318,7 +305,7 @@ public class cgeodetail extends AbstractActivity {
geocode = null;
guid = guid.toLowerCase();
} else {
- warning.showToast(res.getString(R.string.err_detail_open));
+ showToast(res.getString(R.string.err_detail_open));
finish();
return;
}
@@ -326,7 +313,7 @@ public class cgeodetail extends AbstractActivity {
if (uriPath != null && uriPath.startsWith("/gc") == true) {
geocode = uriPath.substring(1).toUpperCase();
} else {
- warning.showToast(res.getString(R.string.err_detail_open));
+ showToast(res.getString(R.string.err_detail_open));
finish();
return;
}
@@ -335,7 +322,7 @@ public class cgeodetail extends AbstractActivity {
// no given data
if (geocode == null && guid == null) {
- warning.showToast(res.getString(R.string.err_detail_cache));
+ showToast(res.getString(R.string.err_detail_cache));
finish();
return;
}
@@ -373,7 +360,7 @@ public class cgeodetail extends AbstractActivity {
settings.load();
if (geo == null) {
- geo = app.startGeo(this, geoUpdate, base, settings, warning, 0, 0);
+ geo = app.startGeo(this, geoUpdate, base, settings, 0, 0);
}
setView();
}
@@ -531,7 +518,7 @@ public class cgeodetail extends AbstractActivity {
shareCache();
return true;
}
- if (NavigationAppFactory.onMenuItemSelected(item, geo, this, res, warning, cache, searchId, null, null)) {
+ if (NavigationAppFactory.onMenuItemSelected(item, geo, this, res, cache, searchId, null, null)) {
return true;
}
return GeneralAppsFactory.onMenuItemSelected(item, this, cache);
@@ -545,7 +532,7 @@ public class cgeodetail extends AbstractActivity {
inflater = getLayoutInflater();
}
if (geo == null) {
- geo = app.startGeo(this, geoUpdate, base, settings, warning, 0, 0);
+ geo = app.startGeo(this, geoUpdate, base, settings, 0, 0);
}
if (searchId != null && searchId > 0) {
@@ -575,10 +562,10 @@ public class cgeodetail extends AbstractActivity {
if (waitDialog != null && waitDialog.isShowing()) waitDialog.dismiss();
if (geocode != null && geocode.length() > 0) {
- warning.showToast(res.getString(R.string.err_detail_cache_find) + " " + geocode + ".");
+ showToast(res.getString(R.string.err_detail_cache_find) + " " + geocode + ".");
} else {
geocode = null;
- warning.showToast(res.getString(R.string.err_detail_cache_find_some));
+ showToast(res.getString(R.string.err_detail_cache_find_some));
}
finish();
@@ -915,14 +902,14 @@ public class cgeodetail extends AbstractActivity {
TextView descView = (TextView) findViewById(R.id.shortdesc);
descView.setVisibility(View.VISIBLE);
- descView.setText(Html.fromHtml(cache.shortdesc.trim(), new cgHtmlImg(this, settings, geocode, true, cache.reason, false), null), TextView.BufferType.SPANNABLE);
+ descView.setText(Html.fromHtml(cache.shortdesc.trim(), new cgHtmlImg(this, geocode, true, cache.reason, false), null), TextView.BufferType.SPANNABLE);
descView.setMovementMethod(LinkMovementMethod.getInstance());
}
// cache long desc
if (longDescDisplayed == true) {
if (longDesc == null && cache != null && cache.description != null) {
- longDesc = Html.fromHtml(cache.description.trim(), new cgHtmlImg(this, settings, geocode, true, cache.reason, false), null);
+ longDesc = Html.fromHtml(cache.description.trim(), new cgHtmlImg(this, geocode, true, cache.reason, false), null);
}
if (longDesc != null && longDesc.length() > 0) {
@@ -1010,7 +997,7 @@ public class cgeodetail extends AbstractActivity {
TextView nameView = (TextView) waypointView.findViewById(R.id.name);
if (wpt.name.trim().length() == 0) {
- nameView.setText(base.formatCoordinate(wpt.latitude, "lat", true) + " | " + base.formatCoordinate(wpt.longitude, "lon", true));
+ nameView.setText(cgBase.formatCoordinate(wpt.latitude, "lat", true) + " | " + cgBase.formatCoordinate(wpt.longitude, "lon", true));
} else {
// avoid HTML parsing
if (wpt.name.indexOf('<') >= 0 || wpt.name.indexOf('&') >= 0) {
@@ -1177,7 +1164,7 @@ public class cgeodetail extends AbstractActivity {
}
// avoid parsing HTML if not necessary
if (log.log.indexOf('<') >= 0 || log.log.indexOf('&') >= 0) {
- ((TextView) rowView.findViewById(R.id.log)).setText(Html.fromHtml(log.log, new cgHtmlImg(this, settings, null, false, cache.reason, false), null), TextView.BufferType.SPANNABLE);
+ ((TextView) rowView.findViewById(R.id.log)).setText(Html.fromHtml(log.log, new cgHtmlImg(this, null, false, cache.reason, false), null), TextView.BufferType.SPANNABLE);
}
else {
((TextView) rowView.findViewById(R.id.log)).setText(log.log);
@@ -1256,7 +1243,7 @@ public class cgeodetail extends AbstractActivity {
guid = guidIn;
if (geocode == null && guid == null) {
- warning.showToast(res.getString(R.string.err_detail_cache_forgot));
+ showToast(res.getString(R.string.err_detail_cache_forgot));
finish();
return;
@@ -1304,7 +1291,7 @@ public class cgeodetail extends AbstractActivity {
String markerUrl = cgBase.urlencode_rfc3986("http://cgeo.carnero.cc/_markers/my_location_mdpi.png");
- cgHtmlImg mapGetter = new cgHtmlImg(cgeodetail.this, settings, cache.geocode, false, 0, false);
+ cgHtmlImg mapGetter = new cgHtmlImg(cgeodetail.this, cache.geocode, false, 0, false);
image = mapGetter.getDrawable("http://maps.google.com/maps/api/staticmap?center=" + latlonMap + "&zoom=15&size=" + width + "x" + height + "&maptype=terrain&markers=icon%3A" + markerUrl + "%7C" + latlonMap + "&sensor=false");
Message message = handler.obtainMessage(0, image);
handler.sendMessage(message);
@@ -1337,7 +1324,7 @@ public class cgeodetail extends AbstractActivity {
return;
}
- longDesc = Html.fromHtml(cache.description.trim(), new cgHtmlImg(cgeodetail.this, settings, geocode, true, cache.reason, false), null);
+ longDesc = Html.fromHtml(cache.description.trim(), new cgHtmlImg(cgeodetail.this, geocode, true, cache.reason, false), null);
handler.sendMessage(new Message());
}
}
@@ -1515,9 +1502,9 @@ public class cgeodetail extends AbstractActivity {
getContentResolver().insert(calendarProvider, event);
- warning.showToast(res.getString(R.string.event_success));
+ showToast(res.getString(R.string.event_success));
} catch (Exception e) {
- warning.showToast(res.getString(R.string.event_fail));
+ showToast(res.getString(R.string.event_fail));
Log.e(cgSettings.tag, "cgeodetail.addToCalendarFn: " + e.toString());
}
@@ -1525,7 +1512,7 @@ public class cgeodetail extends AbstractActivity {
private void navigateTo() {
if (cache == null || cache.latitude == null || cache.longitude == null) {
- warning.showToast(res.getString(R.string.err_location_unknown));
+ showToast(res.getString(R.string.err_location_unknown));
}
cgeonavigate navigateActivity = new cgeonavigate();
@@ -1592,7 +1579,7 @@ public class cgeodetail extends AbstractActivity {
private void showSpoilers() {
if (cache == null || cache.spoilers == null || cache.spoilers.isEmpty() == true) {
- warning.showToast(res.getString(R.string.err_detail_no_spoiler));
+ showToast(res.getString(R.string.err_detail_no_spoiler));
}
Intent spoilersIntent = new Intent(this, cgeoimages.class);
@@ -1669,11 +1656,11 @@ public class cgeodetail extends AbstractActivity {
private class storeCache implements View.OnClickListener {
public void onClick(View arg0) {
if (dropDialog != null && dropDialog.isShowing() == true) {
- warning.showToast(res.getString(R.string.err_detail_still_removing));
+ showToast(res.getString(R.string.err_detail_still_removing));
return;
}
if (refreshDialog != null && refreshDialog.isShowing() == true) {
- warning.showToast(res.getString(R.string.err_detail_still_refreshing));
+ showToast(res.getString(R.string.err_detail_still_refreshing));
return;
}
@@ -1692,11 +1679,11 @@ public class cgeodetail extends AbstractActivity {
private class refreshCache implements View.OnClickListener {
public void onClick(View arg0) {
if (dropDialog != null && dropDialog.isShowing() == true) {
- warning.showToast(res.getString(R.string.err_detail_still_removing));
+ showToast(res.getString(R.string.err_detail_still_removing));
return;
}
if (storeDialog != null && storeDialog.isShowing() == true) {
- warning.showToast(res.getString(R.string.err_detail_still_saving));
+ showToast(res.getString(R.string.err_detail_still_saving));
return;
}
@@ -1751,11 +1738,11 @@ public class cgeodetail extends AbstractActivity {
private class dropCache implements View.OnClickListener {
public void onClick(View arg0) {
if (storeDialog != null && storeDialog.isShowing() == true) {
- warning.showToast(res.getString(R.string.err_detail_still_saving));
+ showToast(res.getString(R.string.err_detail_still_saving));
return;
}
if (refreshDialog != null && refreshDialog.isShowing() == true) {
- warning.showToast(res.getString(R.string.err_detail_still_refreshing));
+ showToast(res.getString(R.string.err_detail_still_refreshing));
return;
}
@@ -1776,7 +1763,7 @@ public class cgeodetail extends AbstractActivity {
@Override
public void run() {
- base.dropCache(app, cgeodetail.this, cache, handler);
+ cgBase.dropCache(app, cgeodetail.this, cache, handler);
}
}
@@ -1786,7 +1773,7 @@ public class cgeodetail extends AbstractActivity {
private abstract class AbstractWatchlistClickListener implements View.OnClickListener {
public void doExecute(int titleId, int messageId, Thread thread) {
if (watchlistDialog != null && watchlistDialog.isShowing() == true) {
- warning.showToast(res.getString(R.string.err_watchlist_still_managing));
+ showToast(res.getString(R.string.err_watchlist_still_managing));
return;
}
watchlistDialog = ProgressDialog.show(cgeodetail.this,
@@ -1921,7 +1908,7 @@ public class cgeodetail extends AbstractActivity {
public void goCompass(View view) {
if (cache == null || cache.latitude == null || cache.longitude == null) {
- warning.showToast(res.getString(R.string.cache_coordinates_no));
+ showToast(res.getString(R.string.cache_coordinates_no));
return;
}
diff --git a/src/cgeo/geocaching/cgeogpxes.java b/src/cgeo/geocaching/cgeogpxes.java
index 16f6f88..09a6052 100644
--- a/src/cgeo/geocaching/cgeogpxes.java
+++ b/src/cgeo/geocaching/cgeogpxes.java
@@ -20,7 +20,7 @@ public class cgeogpxes extends cgFileList<cgGPXListAdapter> {
@Override
public void handleMessage(Message msg) {
if (msg.obj != null && parseDialog != null) {
- parseDialog.setMessage(getRes().getString(R.string.gpx_import_loading_stored) + " " + (Integer) msg.obj);
+ parseDialog.setMessage(res.getString(R.string.gpx_import_loading_stored) + " " + (Integer) msg.obj);
}
}
};
@@ -33,7 +33,7 @@ public class cgeogpxes extends cgFileList<cgGPXListAdapter> {
parseDialog.dismiss();
}
- getWarning().helpDialog(getRes().getString(R.string.gpx_import_title_caches_imported), imported + " " + getRes().getString(R.string.gpx_import_caches_imported));
+ helpDialog(res.getString(R.string.gpx_import_title_caches_imported), imported + " " + res.getString(R.string.gpx_import_caches_imported));
imported = 0;
} catch (Exception e) {
if (parseDialog != null) {
@@ -77,8 +77,8 @@ public class cgeogpxes extends cgFileList<cgGPXListAdapter> {
parseDialog = ProgressDialog.show(
this,
- getRes().getString(R.string.gpx_import_title_reading_file),
- getRes().getString(R.string.gpx_import_loading),
+ res.getString(R.string.gpx_import_title_reading_file),
+ res.getString(R.string.gpx_import_loading),
true,
false);
@@ -95,9 +95,9 @@ public class cgeogpxes extends cgFileList<cgGPXListAdapter> {
@Override
public void run() {
- final long searchId = getBase().parseGPX(getApp(), file, listId, changeParseDialogHandler);
+ final long searchId = cgBase.parseGPX(app, file, listId, changeParseDialogHandler);
- imported = getApp().getCount(searchId);
+ imported = app.getCount(searchId);
loadCachesHandler.sendMessage(new Message());
}
diff --git a/src/cgeo/geocaching/cgeohelpers.java b/src/cgeo/geocaching/cgeohelpers.java
index 0492656..056f631 100644
--- a/src/cgeo/geocaching/cgeohelpers.java
+++ b/src/cgeo/geocaching/cgeohelpers.java
@@ -3,8 +3,6 @@ package cgeo.geocaching;
import java.util.Locale;
import android.content.Intent;
-import android.content.SharedPreferences;
-import android.content.res.Resources;
import android.net.Uri;
import android.os.Bundle;
import android.view.View;
@@ -12,19 +10,11 @@ import cgeo.geocaching.activity.AbstractActivity;
public class cgeohelpers extends AbstractActivity {
- private Resources res = null;
- private cgSettings settings = null;
- private SharedPreferences prefs = null;
-
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// init
- res = this.getResources();
- prefs = getSharedPreferences(cgSettings.preferences, 0);
- settings = new cgSettings(this, prefs);
-
setTheme();
setContentView(R.layout.helpers);
setTitle(res.getString(R.string.helpers));
diff --git a/src/cgeo/geocaching/cgeoimages.java b/src/cgeo/geocaching/cgeoimages.java
index 3bdd7a6..09dd637 100644
--- a/src/cgeo/geocaching/cgeoimages.java
+++ b/src/cgeo/geocaching/cgeoimages.java
@@ -6,7 +6,6 @@ import java.util.ArrayList;
import android.app.ProgressDialog;
import android.content.Intent;
-import android.content.res.Resources;
import android.graphics.Bitmap.CompressFormat;
import android.graphics.Rect;
import android.graphics.drawable.BitmapDrawable;
@@ -32,13 +31,9 @@ public class cgeoimages extends AbstractActivity {
private int img_type;
private ArrayList<cgImage> images = new ArrayList<cgImage>();
- private Resources res = null;
private String geocode = null;
private String title = null;
private String url = null;
- private cgeoapplication app = null;
- private cgSettings settings = null;
- private cgWarning warning = null;
private LayoutInflater inflater = null;
private ProgressDialog progressDialog = null;
private ProgressDialog waitDialog = null;
@@ -60,10 +55,10 @@ public class cgeoimages extends AbstractActivity {
}
switch (img_type) {
case LOG_IMAGE:
- warning.showToast(res.getString(R.string.warn_load_log_image));
+ showToast(res.getString(R.string.warn_load_log_image));
break;
case SPOILER_IMAGE:
- warning.showToast(res.getString(R.string.warn_load_spoiler_image));
+ showToast(res.getString(R.string.warn_load_spoiler_image));
break;
}
@@ -111,7 +106,7 @@ public class cgeoimages extends AbstractActivity {
public void run() {
BitmapDrawable image = null;
try {
- cgHtmlImg imgGetter = new cgHtmlImg(cgeoimages.this, settings, geocode, true, offline, false, save);
+ cgHtmlImg imgGetter = new cgHtmlImg(cgeoimages.this, geocode, true, offline, false, save);
image = imgGetter.getDrawable(img.url);
Message message = handler.obtainMessage(0, image);
@@ -140,11 +135,6 @@ public class cgeoimages extends AbstractActivity {
super.onCreate(savedInstanceState);
// init
- res = this.getResources();
- app = (cgeoapplication) this.getApplication();
- settings = new cgSettings(this, getSharedPreferences(cgSettings.preferences, 0));
- warning = new cgWarning(this);
-
setTheme();
setContentView(R.layout.spoilers);
@@ -166,7 +156,7 @@ public class cgeoimages extends AbstractActivity {
}
if (geocode == null) {
- warning.showToast("Sorry, c:geo forgot for what cache you want to load spoiler images.");
+ showToast("Sorry, c:geo forgot for what cache you want to load spoiler images.");
finish();
return;
}
@@ -175,7 +165,7 @@ public class cgeoimages extends AbstractActivity {
title = extras.getString("title");
url = extras.getString("url");
if ((title == null) || (url == null)) {
- warning.showToast("Sorry, c:geo forgot which logimage you wanted to load.");
+ showToast("Sorry, c:geo forgot which logimage you wanted to load.");
finish();
return;
}
@@ -223,7 +213,7 @@ public class cgeoimages extends AbstractActivity {
(new loadSpoilers()).start();
break;
default:
- warning.showToast("Sorry, can't load unknown image type.");
+ showToast("Sorry, can't load unknown image type.");
finish();
}
diff --git a/src/cgeo/geocaching/cgeoinit.java b/src/cgeo/geocaching/cgeoinit.java
index 8a73497..9e1ccb6 100644
--- a/src/cgeo/geocaching/cgeoinit.java
+++ b/src/cgeo/geocaching/cgeoinit.java
@@ -6,7 +6,6 @@ import android.app.ProgressDialog;
import android.content.Intent;
import android.content.SharedPreferences;
import android.content.res.Configuration;
-import android.content.res.Resources;
import android.net.Uri;
import android.os.Bundle;
import android.os.Handler;
@@ -30,12 +29,6 @@ public class cgeoinit extends AbstractActivity {
private final int SELECT_MAPFILE_REQUEST=1;
- private cgeoapplication app = null;
- private Resources res = null;
- private cgSettings settings = null;
- private cgBase base = null;
- private cgWarning warning = null;
- private SharedPreferences prefs = null;
private ProgressDialog loginDialog = null;
private ProgressDialog webDialog = null;
private Handler logInHandler = new Handler() {
@@ -48,17 +41,17 @@ public class cgeoinit extends AbstractActivity {
}
if (msg.what == 1) {
- warning.helpDialog(res.getString(R.string.init_login_popup), res.getString(R.string.init_login_popup_ok));
+ helpDialog(res.getString(R.string.init_login_popup), res.getString(R.string.init_login_popup_ok));
} else {
if (cgBase.errorRetrieve.containsKey(msg.what) == true) {
- warning.helpDialog(res.getString(R.string.init_login_popup),
+ helpDialog(res.getString(R.string.init_login_popup),
res.getString(R.string.init_login_popup_failed_reason) + " " + cgBase.errorRetrieve.get(msg.what) + ".");
} else {
- warning.helpDialog(res.getString(R.string.init_login_popup), res.getString(R.string.init_login_popup_failed));
+ helpDialog(res.getString(R.string.init_login_popup), res.getString(R.string.init_login_popup_failed));
}
}
} catch (Exception e) {
- warning.showToast(res.getString(R.string.err_login_failed));
+ showToast(res.getString(R.string.err_login_failed));
Log.e(cgSettings.tag, "cgeoinit.logInHandler: " + e.toString());
}
@@ -81,12 +74,12 @@ public class cgeoinit extends AbstractActivity {
}
if (msg.what > 0) {
- warning.helpDialog(res.getString(R.string.init_sendToCgeo), res.getString(R.string.init_sendToCgeo_register_ok).replace("####", ""+msg.what));
+ helpDialog(res.getString(R.string.init_sendToCgeo), res.getString(R.string.init_sendToCgeo_register_ok).replace("####", ""+msg.what));
} else {
- warning.helpDialog(res.getString(R.string.init_sendToCgeo), res.getString(R.string.init_sendToCgeo_register_fail));
+ helpDialog(res.getString(R.string.init_sendToCgeo), res.getString(R.string.init_sendToCgeo_register_fail));
}
} catch (Exception e) {
- warning.showToast(res.getString(R.string.init_sendToCgeo_register_fail));
+ showToast(res.getString(R.string.init_sendToCgeo_register_fail));
Log.e(cgSettings.tag, "cgeoinit.webHandler: " + e.toString());
}
@@ -108,12 +101,6 @@ public class cgeoinit extends AbstractActivity {
super.onCreate(savedInstanceState);
// init
- res = this.getResources();
- app = (cgeoapplication) this.getApplication();
- prefs = getSharedPreferences(cgSettings.preferences, 0);
- settings = new cgSettings(this, prefs);
- base = new cgBase(app, settings, prefs);
- warning = new cgWarning(this);
setTheme();
setContentView(R.layout.init);
@@ -173,9 +160,9 @@ public class cgeoinit extends AbstractActivity {
status = saveValues();
if (status == true) {
- warning.showToast(res.getString(R.string.init_cleared));
+ showToast(res.getString(R.string.init_cleared));
} else {
- warning.showToast(res.getString(R.string.err_init_cleared));
+ showToast(res.getString(R.string.err_init_cleared));
}
finish();
@@ -258,7 +245,7 @@ public class cgeoinit extends AbstractActivity {
Button sigBtn = (Button) findViewById(R.id.signature_help);
sigBtn.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
- warning.helpDialog(res.getString(R.string.init_signature_help_title), res.getString(R.string.init_signature_help_text));
+ helpDialog(res.getString(R.string.init_signature_help_title), res.getString(R.string.init_signature_help_text));
}
});
CheckBox autoinsertButton = (CheckBox) findViewById(R.id.sigautoinsert);
@@ -433,7 +420,7 @@ public class cgeoinit extends AbstractActivity {
// Cache db backup
TextView lastBackup = (TextView) findViewById(R.id.backup_last);
- File lastBackupFile = app.isRestoreFile();
+ File lastBackupFile = cgeoapplication.isRestoreFile();
if (lastBackupFile != null) {
lastBackup.setText(res.getString(R.string.init_backup_last) + " " + cgBase.timeOut.format(lastBackupFile.lastModified()) + ", " + cgBase.dateOut.format(lastBackupFile.lastModified()));
} else {
@@ -459,13 +446,13 @@ public class cgeoinit extends AbstractActivity {
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);
+ 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));
+ 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();
+ File lastBackupFile = cgeoapplication.isRestoreFile();
if (lastBackupFile != null) {
lastBackup.setText(res.getString(R.string.init_backup_last) + " " + cgBase.timeOut.format(lastBackupFile.lastModified()) + ", " + cgBase.dateOut.format(lastBackupFile.lastModified()));
} else {
@@ -477,9 +464,9 @@ public class cgeoinit extends AbstractActivity {
final boolean status = app.restoreDatabase();
if (status) {
- warning.helpDialog(res.getString(R.string.init_backup_restore), res.getString(R.string.init_restore_success));
+ 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));
+ helpDialog(res.getString(R.string.init_backup_restore), res.getString(R.string.init_restore_failed));
}
}
@@ -977,7 +964,7 @@ public class cgeoinit extends AbstractActivity {
final String password = ((EditText) findViewById(R.id.password)).getText().toString();
if (username == null || username.length() == 0 || password == null || password.length() == 0) {
- warning.showToast(res.getString(R.string.err_missing_auth));
+ showToast(res.getString(R.string.err_missing_auth));
return;
}
@@ -1005,7 +992,7 @@ public class cgeoinit extends AbstractActivity {
if (deviceName == null || deviceName.length() == 0) {
- warning.showToast(res.getString(R.string.err_missing_device_name));
+ showToast(res.getString(R.string.err_missing_device_name));
return;
}
diff --git a/src/cgeo/geocaching/cgeonavigate.java b/src/cgeo/geocaching/cgeonavigate.java
index 61cf516..e6c5462 100644
--- a/src/cgeo/geocaching/cgeonavigate.java
+++ b/src/cgeo/geocaching/cgeonavigate.java
@@ -7,7 +7,6 @@ import java.util.Locale;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
-import android.content.res.Resources;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
@@ -24,11 +23,6 @@ import cgeo.geocaching.activity.AbstractActivity;
public class cgeonavigate extends AbstractActivity {
public static ArrayList<cgCoord> coordinates = new ArrayList<cgCoord>();
- private Resources res = null;
- private cgeoapplication app = null;
- private cgSettings settings = null;
- private cgBase base = null;
- private cgWarning warning = null;
private PowerManager pm = null;
private cgGeo geo = null;
private cgDirection dir = null;
@@ -70,13 +64,6 @@ public class cgeonavigate extends AbstractActivity {
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
- // class init
- res = this.getResources();
- app = (cgeoapplication) this.getApplication();
- settings = new cgSettings(this, getSharedPreferences(cgSettings.preferences, 0));
- base = new cgBase(app, settings, getSharedPreferences(cgSettings.preferences, 0));
- warning = new cgWarning(this);
-
// set layout
getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
setTheme();
@@ -85,10 +72,10 @@ public class cgeonavigate extends AbstractActivity {
// sensor & geolocation manager
if (geo == null) {
- geo = app.startGeo(this, geoUpdate, base, settings, warning, 0, 0);
+ geo = app.startGeo(this, geoUpdate, base, settings, 0, 0);
}
if (settings.useCompass == 1 && dir == null) {
- dir = app.startDir(this, dirUpdate, warning);
+ dir = app.startDir(this, dirUpdate);
}
// get parameters
@@ -153,10 +140,10 @@ public class cgeonavigate extends AbstractActivity {
// sensor & geolocation manager
if (geo == null) {
- geo = app.startGeo(this, geoUpdate, base, settings, warning, 0, 0);
+ geo = app.startGeo(this, geoUpdate, base, settings, 0, 0);
}
if (settings.useCompass == 1 && dir == null) {
- dir = app.startDir(this, dirUpdate, warning);
+ dir = app.startDir(this, dirUpdate);
}
// keep backlight on
@@ -277,7 +264,7 @@ public class cgeonavigate extends AbstractActivity {
settings.useCompass = 1;
if (dir == null) {
- dir = app.startDir(this, dirUpdate, warning);
+ dir = app.startDir(this, dirUpdate);
}
SharedPreferences.Editor prefsEdit = getSharedPreferences(cgSettings.preferences, 0).edit();
@@ -320,7 +307,7 @@ public class cgeonavigate extends AbstractActivity {
return;
}
- ((TextView) findViewById(R.id.destination)).setText(base.formatCoordinate(dstLatitude, "lat", true) + " | " + base.formatCoordinate(dstLongitude, "lon", true));
+ ((TextView) findViewById(R.id.destination)).setText(cgBase.formatCoordinate(dstLatitude, "lat", true) + " | " + cgBase.formatCoordinate(dstLongitude, "lon", true));
}
public void setDest(Double lat, Double lon) {
@@ -415,9 +402,9 @@ public class cgeonavigate extends AbstractActivity {
} else {
humanAlt = String.format("%.0f", geo.altitudeNow) + " m";
}
- navLocation.setText(base.formatCoordinate(geo.latitudeNow, "lat", true) + " | " + base.formatCoordinate(geo.longitudeNow, "lon", true) + " | " + humanAlt);
+ navLocation.setText(cgBase.formatCoordinate(geo.latitudeNow, "lat", true) + " | " + cgBase.formatCoordinate(geo.longitudeNow, "lon", true) + " | " + humanAlt);
} else {
- navLocation.setText(base.formatCoordinate(geo.latitudeNow, "lat", true) + " | " + base.formatCoordinate(geo.longitudeNow, "lon", true));
+ navLocation.setText(cgBase.formatCoordinate(geo.latitudeNow, "lat", true) + " | " + cgBase.formatCoordinate(geo.longitudeNow, "lon", true));
}
updateDistanceInfo();
diff --git a/src/cgeo/geocaching/cgeopoint.java b/src/cgeo/geocaching/cgeopoint.java
index 520881e..4e9fce9 100644
--- a/src/cgeo/geocaching/cgeopoint.java
+++ b/src/cgeo/geocaching/cgeopoint.java
@@ -11,7 +11,6 @@ import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.content.res.Configuration;
-import android.content.res.Resources;
import android.os.Bundle;
import android.text.format.DateFormat;
import android.util.Log;
@@ -60,9 +59,9 @@ public class cgeopoint extends AbstractActivity {
.findViewById(R.id.simple_way_point_latitude);
TextView date = (TextView) convertView.findViewById(R.id.date);
- String lonString = base.formatCoordinate(loc.getLongitude(), "lon",
+ String lonString = cgBase.formatCoordinate(loc.getLongitude(), "lon",
true);
- String latString = base.formatCoordinate(loc.getLatitude(), "lat",
+ String latString = cgBase.formatCoordinate(loc.getLatitude(), "lat",
true);
longitude.setText(lonString);
@@ -83,12 +82,6 @@ public class cgeopoint extends AbstractActivity {
}
}
- private Resources res = null;
- private cgeoapplication app = null;
- private cgSettings settings = null;
- private SharedPreferences prefs = null;
- private cgBase base = null;
- private cgWarning warning = null;
private cgGeo geo = null;
private cgUpdateLoc geoUpdate = new update();
private EditText latEdit = null;
@@ -109,14 +102,6 @@ public class cgeopoint extends AbstractActivity {
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
- // init
- app = (cgeoapplication) this.getApplication();
- res = this.getResources();
- settings = new cgSettings(this, this.getSharedPreferences(cgSettings.preferences, 0));
- prefs = getSharedPreferences(cgSettings.preferences, 0);
- base = new cgBase(app, settings, this.getSharedPreferences(cgSettings.preferences, 0));
- warning = new cgWarning(this);
-
setTheme();
setContentView(R.layout.point);
setTitle(res.getString(R.string.search_destination));
@@ -252,7 +237,7 @@ public class cgeopoint extends AbstractActivity {
private void init() {
if (geo == null) {
- geo = app.startGeo(this, geoUpdate, base, settings, warning, 0, 0);
+ geo = app.startGeo(this, geoUpdate, base, settings, 0, 0);
}
EditText latitudeEdit = (EditText) findViewById(R.id.latitude);
@@ -276,8 +261,8 @@ public class cgeopoint extends AbstractActivity {
});
if (prefs.contains("anylatitude") == true && prefs.contains("anylongitude") == true) {
- latitudeEdit.setText(base.formatCoordinate(new Double(prefs.getFloat("anylatitude", 0f)), "lat", true));
- longitudeEdit.setText(base.formatCoordinate(new Double(prefs.getFloat("anylongitude", 0f)), "lon", true));
+ latitudeEdit.setText(cgBase.formatCoordinate(new Double(prefs.getFloat("anylatitude", 0f)), "lat", true));
+ longitudeEdit.setText(cgBase.formatCoordinate(new Double(prefs.getFloat("anylongitude", 0f)), "lon", true));
}
Button buttonCurrent = (Button) findViewById(R.id.current);
@@ -350,7 +335,7 @@ public class cgeopoint extends AbstractActivity {
return true;
}
- return NavigationAppFactory.onMenuItemSelected(item, geo, this, res, warning, null, null, null, coords);
+ return NavigationAppFactory.onMenuItemSelected(item, geo, this, res, null, null, null, coords);
}
private void addToHistory(ArrayList<Double> coords) {
@@ -387,7 +372,7 @@ public class cgeopoint extends AbstractActivity {
getDestionationHistoryAdapter().notifyDataSetChanged();
- warning.showToast(res.getString(R.string.search_remove_destination));
+ showToast(res.getString(R.string.search_remove_destination));
}
}
@@ -404,7 +389,7 @@ public class cgeopoint extends AbstractActivity {
getDestionationHistoryAdapter().notifyDataSetChanged();
- warning.showToast(res.getString(R.string.search_history_cleared));
+ showToast(res.getString(R.string.search_history_cleared));
}
}
@@ -414,7 +399,7 @@ public class cgeopoint extends AbstractActivity {
private void navigateTo(List<Double> coords) {
if (coords == null || coords.get(0) == null || coords.get(1) == null) {
- warning.showToast(res.getString(R.string.err_location_unknown));
+ showToast(res.getString(R.string.err_location_unknown));
}
cgeonavigate navigateActivity = new cgeonavigate();
@@ -432,7 +417,7 @@ public class cgeopoint extends AbstractActivity {
ArrayList<Double> coords = getDestination();
if (coords == null || coords.get(0) == null || coords.get(1) == null) {
- warning.showToast(res.getString(R.string.err_location_unknown));
+ showToast(res.getString(R.string.err_location_unknown));
}
cgeocaches cachesActivity = new cgeocaches();
@@ -465,8 +450,8 @@ public class cgeopoint extends AbstractActivity {
lonEdit = (EditText) findViewById(R.id.longitude);
}
- latEdit.setHint(base.formatCoordinate(geo.latitudeNow, "lat", false));
- lonEdit.setHint(base.formatCoordinate(geo.longitudeNow, "lon", false));
+ latEdit.setHint(cgBase.formatCoordinate(geo.latitudeNow, "lat", false));
+ lonEdit.setHint(cgBase.formatCoordinate(geo.longitudeNow, "lon", false));
} catch (Exception e) {
Log.w(cgSettings.tag, "Failed to update location.");
}
@@ -477,12 +462,12 @@ public class cgeopoint extends AbstractActivity {
public void onClick(View arg0) {
if (geo == null || geo.latitudeNow == null || geo.longitudeNow == null) {
- warning.showToast(res.getString(R.string.err_point_unknown_position));
+ showToast(res.getString(R.string.err_point_unknown_position));
return;
}
- ((EditText) findViewById(R.id.latitude)).setText(base.formatCoordinate(geo.latitudeNow, "lat", true));
- ((EditText) findViewById(R.id.longitude)).setText(base.formatCoordinate(geo.longitudeNow, "lon", true));
+ ((EditText) findViewById(R.id.latitude)).setText(cgBase.formatCoordinate(geo.latitudeNow, "lat", true));
+ ((EditText) findViewById(R.id.longitude)).setText(cgBase.formatCoordinate(geo.longitudeNow, "lon", true));
changed = false;
}
@@ -500,22 +485,22 @@ public class cgeopoint extends AbstractActivity {
if ((bearingText == null || bearingText.length() == 0) && (distanceText == null || distanceText.length() == 0)
&& (latText == null || latText.length() == 0) && (lonText == null || lonText.length() == 0)) {
- warning.showToast(res.getString(R.string.err_point_no_position_given));
+ showToast(res.getString(R.string.err_point_no_position_given));
return null;
}
if (latText != null && latText.length() > 0 && lonText != null && lonText.length() > 0) {
// latitude & longitude
- HashMap<String, Object> latParsed = base.parseCoordinate(latText, "lat");
- HashMap<String, Object> lonParsed = base.parseCoordinate(lonText, "lon");
+ HashMap<String, Object> latParsed = cgBase.parseCoordinate(latText, "lat");
+ HashMap<String, Object> lonParsed = cgBase.parseCoordinate(lonText, "lon");
if (latParsed == null || latParsed.get("coordinate") == null || latParsed.get("string") == null) {
- warning.showToast(res.getString(R.string.err_parse_lat));
+ showToast(res.getString(R.string.err_parse_lat));
return null;
}
if (lonParsed == null || lonParsed.get("coordinate") == null || lonParsed.get("string") == null) {
- warning.showToast(res.getString(R.string.err_parse_lon));
+ showToast(res.getString(R.string.err_parse_lon));
return null;
}
@@ -523,7 +508,7 @@ public class cgeopoint extends AbstractActivity {
longitude = (Double) lonParsed.get("coordinate");
} else {
if (geo == null || geo.latitudeNow == null || geo.longitudeNow == null) {
- warning.showToast(res.getString(R.string.err_point_curr_position_unavailable));
+ showToast(res.getString(R.string.err_point_curr_position_unavailable));
return null;
}
@@ -540,7 +525,7 @@ public class cgeopoint extends AbstractActivity {
// probably not a number
}
if (bearing == null) {
- warning.helpDialog(res.getString(R.string.err_point_bear_and_dist_title), res.getString(R.string.err_point_bear_and_dist));
+ helpDialog(res.getString(R.string.err_point_bear_and_dist_title), res.getString(R.string.err_point_bear_and_dist));
return null;
}
@@ -581,20 +566,20 @@ public class cgeopoint extends AbstractActivity {
}
if (distance == null) {
- warning.showToast(res.getString(R.string.err_parse_dist));
+ showToast(res.getString(R.string.err_parse_dist));
return null;
}
Double latParsed = null;
Double lonParsed = null;
- HashMap<String, Double> coordsDst = base.getRadialDistance(latitude, longitude, bearing, distance);
+ HashMap<String, Double> coordsDst = cgBase.getRadialDistance(latitude, longitude, bearing, distance);
latParsed = coordsDst.get("latitude");
lonParsed = coordsDst.get("longitude");
if (latParsed == null || lonParsed == null) {
- warning.showToast(res.getString(R.string.err_point_location_error));
+ showToast(res.getString(R.string.err_point_location_error));
return null;
}
diff --git a/src/cgeo/geocaching/cgeopopup.java b/src/cgeo/geocaching/cgeopopup.java
index f25ba4e..aaaf130 100644
--- a/src/cgeo/geocaching/cgeopopup.java
+++ b/src/cgeo/geocaching/cgeopopup.java
@@ -6,7 +6,6 @@ import java.util.Locale;
import android.app.ProgressDialog;
import android.content.Intent;
import android.content.res.Configuration;
-import android.content.res.Resources;
import android.graphics.drawable.Drawable;
import android.net.Uri;
import android.os.Bundle;
@@ -30,11 +29,6 @@ import cgeo.geocaching.apps.cache.navi.NavigationAppFactory;
public class cgeopopup extends AbstractActivity {
- private Resources res = null;
- private cgeoapplication app = null;
- private cgSettings settings = null;
- private cgBase base = null;
- private cgWarning warning = null;
private Boolean fromDetail = false;
private LayoutInflater inflater = null;
private String geocode = null;
@@ -70,7 +64,7 @@ public class cgeopopup extends AbstractActivity {
finish();
return;
} catch (Exception e) {
- warning.showToast(res.getString(R.string.err_store));
+ showToast(res.getString(R.string.err_store));
Log.e(cgSettings.tag, "cgeopopup.storeCacheHandler: " + e.toString());
}
@@ -93,7 +87,7 @@ public class cgeopopup extends AbstractActivity {
finish();
return;
} catch (Exception e) {
- warning.showToast(res.getString(R.string.err_drop));
+ showToast(res.getString(R.string.err_drop));
Log.e(cgSettings.tag, "cgeopopup.dropCacheHandler: " + e.toString());
}
@@ -113,13 +107,6 @@ public class cgeopopup extends AbstractActivity {
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
- // init
- res = this.getResources();
- app = (cgeoapplication) this.getApplication();
- settings = new cgSettings(this, getSharedPreferences(cgSettings.preferences, 0));
- base = new cgBase(app, settings, getSharedPreferences(cgSettings.preferences, 0));
- warning = new cgWarning(this);
-
// set layout
setTheme(R.style.transparent);
setContentView(R.layout.popup);
@@ -133,7 +120,7 @@ public class cgeopopup extends AbstractActivity {
}
if (geocode == null || geocode.length() == 0) {
- warning.showToast(res.getString(R.string.err_detail_cache_find));
+ showToast(res.getString(R.string.err_detail_cache_find));
finish();
return;
@@ -193,7 +180,7 @@ public class cgeopopup extends AbstractActivity {
return true;
} else if (menuItem == 6) {
if (cache.cacheid == null || cache.cacheid.length() == 0) {
- warning.showToast(res.getString(R.string.err_cannot_log_visit));
+ showToast(res.getString(R.string.err_cannot_log_visit));
return false;
}
@@ -211,12 +198,12 @@ public class cgeopopup extends AbstractActivity {
return true;
}
- return NavigationAppFactory.onMenuItemSelected(item, geo, this, res, warning, cache, null, null, null);
+ return NavigationAppFactory.onMenuItemSelected(item, geo, this, res, cache, null, null, null);
}
private void init() {
if (geo == null) {
- geo = app.startGeo(this, geoUpdate, base, settings, warning, 0, 0);
+ geo = app.startGeo(this, geoUpdate, base, settings, 0, 0);
}
app.setAction(geocode);
@@ -224,7 +211,7 @@ public class cgeopopup extends AbstractActivity {
cache = app.getCacheByGeocode(geocode);
if (cache == null) {
- warning.showToast(res.getString(R.string.err_detail_cache_find));
+ showToast(res.getString(R.string.err_detail_cache_find));
finish();
return;
@@ -564,7 +551,7 @@ public class cgeopopup extends AbstractActivity {
private void navigateTo() {
if (cache == null || cache.latitude == null || cache.longitude == null) {
- warning.showToast(res.getString(R.string.err_location_unknown));
+ showToast(res.getString(R.string.err_location_unknown));
}
cgeonavigate navigateActivity = new cgeonavigate();
@@ -580,7 +567,7 @@ public class cgeopopup extends AbstractActivity {
private void cachesAround() {
if (cache == null || cache.latitude == null || cache.longitude == null) {
- warning.showToast(res.getString(R.string.err_location_unknown));
+ showToast(res.getString(R.string.err_location_unknown));
}
cgeocaches cachesActivity = new cgeocaches();
@@ -601,7 +588,7 @@ public class cgeopopup extends AbstractActivity {
public void onClick(View arg0) {
if (dropDialog != null && dropDialog.isShowing() == true) {
- warning.showToast("Still removing this cache.");
+ showToast("Still removing this cache.");
return;
}
@@ -630,7 +617,7 @@ public class cgeopopup extends AbstractActivity {
public void onClick(View arg0) {
if (storeDialog != null && storeDialog.isShowing() == true) {
- warning.showToast("Still saving this cache.");
+ showToast("Still saving this cache.");
return;
}
@@ -651,7 +638,7 @@ public class cgeopopup extends AbstractActivity {
@Override
public void run() {
- base.dropCache(app, cgeopopup.this, cache, handler);
+ cgBase.dropCache(app, cgeopopup.this, cache, handler);
}
}
@@ -694,7 +681,7 @@ public class cgeopopup extends AbstractActivity {
public void goCompass(View view) {
if (cache == null || cache.latitude == null || cache.longitude == null) {
- warning.showToast(res.getString(R.string.cache_coordinates_no));
+ showToast(res.getString(R.string.cache_coordinates_no));
return;
}
diff --git a/src/cgeo/geocaching/cgeosmaps.java b/src/cgeo/geocaching/cgeosmaps.java
index 354d32d..c09ea29 100644
--- a/src/cgeo/geocaching/cgeosmaps.java
+++ b/src/cgeo/geocaching/cgeosmaps.java
@@ -3,7 +3,6 @@ package cgeo.geocaching;
import java.util.ArrayList;
import android.app.ProgressDialog;
-import android.content.res.Resources;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.os.Bundle;
@@ -19,9 +18,6 @@ public class cgeosmaps extends AbstractActivity {
private ArrayList<Bitmap> maps = new ArrayList<Bitmap>();
private String geocode = null;
- private Resources res = null;
- private cgSettings settings = null;
- private cgWarning warning = null;
private LayoutInflater inflater = null;
private ProgressDialog waitDialog = null;
private LinearLayout smapsView = null;
@@ -36,7 +32,7 @@ public class cgeosmaps extends AbstractActivity {
waitDialog.dismiss();
}
- warning.showToast(res.getString(R.string.err_detail_not_load_map_static));
+ showToast(res.getString(R.string.err_detail_not_load_map_static));
finish();
return;
@@ -75,11 +71,6 @@ public class cgeosmaps extends AbstractActivity {
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
- // init
- res = this.getResources();
- settings = new cgSettings(this, getSharedPreferences(cgSettings.preferences, 0));
- warning = new cgWarning(this);
-
setTheme();
setContentView(R.layout.map_static);
setTitle(res.getString(R.string.map_static_title));
@@ -93,7 +84,7 @@ public class cgeosmaps extends AbstractActivity {
}
if (geocode == null) {
- warning.showToast("Sorry, c:geo forgot for what cache you want to load static maps.");
+ showToast("Sorry, c:geo forgot for what cache you want to load static maps.");
finish();
return;
}
@@ -122,7 +113,7 @@ public class cgeosmaps extends AbstractActivity {
for (int level = 1; level <= 5; level++) {
try {
- Bitmap image = BitmapFactory.decodeFile(settings.getStorage() + geocode + "/map_" + level);
+ Bitmap image = BitmapFactory.decodeFile(cgSettings.getStorage() + geocode + "/map_" + level);
if (image != null) {
maps.add(image);
}
@@ -134,7 +125,7 @@ public class cgeosmaps extends AbstractActivity {
if (maps.isEmpty() == true) {
for (int level = 1; level <= 5; level++) {
try {
- Bitmap image = BitmapFactory.decodeFile(settings.getStorageSec() + geocode + "/map_" + level);
+ Bitmap image = BitmapFactory.decodeFile(cgSettings.getStorageSec() + geocode + "/map_" + level);
if (image != null) {
maps.add(image);
}
diff --git a/src/cgeo/geocaching/cgeotouch.java b/src/cgeo/geocaching/cgeotouch.java
index b2ce64f..e1d9652 100644
--- a/src/cgeo/geocaching/cgeotouch.java
+++ b/src/cgeo/geocaching/cgeotouch.java
@@ -8,7 +8,6 @@ import java.util.HashMap;
import android.app.Dialog;
import android.app.ProgressDialog;
import android.content.res.Configuration;
-import android.content.res.Resources;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
@@ -25,11 +24,6 @@ import android.widget.LinearLayout;
import android.widget.TextView;
public class cgeotouch extends cgLogForm {
- private cgeoapplication app = null;
- private Resources res = null;
- private cgBase base = null;
- private cgSettings settings = null;
- private cgWarning warning = null;
private cgTrackable trackable = null;
private ArrayList<Integer> types = new ArrayList<Integer>();
private ProgressDialog waitDialog = null;
@@ -55,7 +49,7 @@ public class cgeotouch extends cgLogForm {
@Override
public void handleMessage(Message msg) {
if ((viewstate == null || viewstate.length() == 0) && attempts < 2) {
- warning.showToast(res.getString(R.string.err_log_load_data_again));
+ showToast(res.getString(R.string.err_log_load_data_again));
loadData thread;
thread = new loadData(guid);
@@ -63,7 +57,7 @@ public class cgeotouch extends cgLogForm {
return;
} else if ((viewstate == null || viewstate.length() == 0) && attempts >= 2) {
- warning.showToast(res.getString(R.string.err_log_load_data));
+ showToast(res.getString(R.string.err_log_load_data));
showProgress(false);
return;
@@ -83,7 +77,7 @@ public class cgeotouch extends cgLogForm {
@Override
public void handleMessage(Message msg) {
if (msg.what == 1) {
- warning.showToast(res.getString(R.string.info_log_posted));
+ showToast(res.getString(R.string.info_log_posted));
if (waitDialog != null) {
waitDialog.dismiss();
@@ -92,17 +86,17 @@ public class cgeotouch extends cgLogForm {
return;
} else if (msg.what >= 1000) {
if (msg.what == 1001) {
- warning.showToast(res.getString(R.string.warn_log_text_fill));
+ showToast(res.getString(R.string.warn_log_text_fill));
} else if(msg.what == 1002) {
- warning.showToast(res.getString(R.string.err_log_failed_server));
+ showToast(res.getString(R.string.err_log_failed_server));
} else {
- warning.showToast(res.getString(R.string.err_log_post_failed));
+ showToast(res.getString(R.string.err_log_post_failed));
}
} else {
if (cgBase.errorRetrieve.get(msg.what) != null) {
- warning.showToast(res.getString(R.string.err_log_post_failed_because) + cgBase.errorRetrieve.get(msg.what) + ".");
+ showToast(res.getString(R.string.err_log_post_failed_because) + cgBase.errorRetrieve.get(msg.what) + ".");
} else {
- warning.showToast(res.getString(R.string.err_log_post_failed));
+ showToast(res.getString(R.string.err_log_post_failed));
}
}
@@ -120,13 +114,6 @@ public class cgeotouch extends cgLogForm {
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
- // init
- res = this.getResources();
- app = (cgeoapplication)this.getApplication();
- settings = new cgSettings(this, getSharedPreferences(cgSettings.preferences, 0));
- base = new cgBase(app, settings, getSharedPreferences(cgSettings.preferences, 0));
- warning = new cgWarning(this);
-
setTheme();
setContentView(R.layout.touch);
setTitle(res.getString(R.string.trackable_touch));
@@ -149,7 +136,7 @@ public class cgeotouch extends cgLogForm {
app.setAction("logging trackable");
if (trackable == null || guid == null) {
- warning.showToast(res.getString(R.string.err_tb_forgot_saw));
+ showToast(res.getString(R.string.err_tb_forgot_saw));
finish();
return;
@@ -350,7 +337,7 @@ public class cgeotouch extends cgLogForm {
Thread thread = new postLog(postLogHandler, tracking, log);
thread.start();
} else {
- warning.showToast(res.getString(R.string.err_log_load_data_still));
+ showToast(res.getString(R.string.err_log_load_data_still));
}
}
}
@@ -362,7 +349,7 @@ public class cgeotouch extends cgLogForm {
guid = guidIn;
if (guid == null) {
- warning.showToast(res.getString(R.string.err_tb_forgot_saw));
+ showToast(res.getString(R.string.err_tb_forgot_saw));
finish();
return;
@@ -387,10 +374,10 @@ public class cgeotouch extends cgLogForm {
final String page = base.request(false, "www.geocaching.com", "/track/log.aspx", "GET", params, false, false, false).getData();
- viewstate = base.findViewstate(page, 0);
- viewstate1 = base.findViewstate(page, 1);
+ viewstate = cgBase.findViewstate(page, 0);
+ viewstate1 = cgBase.findViewstate(page, 1);
- final ArrayList<Integer> typesPre = base.parseTypes(page);
+ final ArrayList<Integer> typesPre = cgBase.parseTypes(page);
if (typesPre.size() > 0) {
types.clear();
types.addAll(typesPre);
@@ -400,7 +387,7 @@ public class cgeotouch extends cgLogForm {
if (types.contains(typeSelected) == false) {
typeSelected = types.get(0);
setType(typeSelected);
- warning.showToast(res.getString(R.string.info_log_type_changed));
+ showToast(res.getString(R.string.info_log_type_changed));
}
} catch (Exception e) {
Log.e(cgSettings.tag, "cgeotouch.loadData.run: " + e.toString());
@@ -445,7 +432,7 @@ public class cgeotouch extends cgLogForm {
settings.tokenPublic != null && settings.tokenPublic.length() > 0 && settings.tokenSecret != null && settings.tokenSecret.length() > 0 &&
tweetCheck.isChecked() == true && tweetBox.getVisibility() == View.VISIBLE
) {
- base.postTweetTrackable(app, settings, geocode);
+ cgBase.postTweetTrackable(app, settings, geocode);
}
return status;
diff --git a/src/cgeo/geocaching/cgeotrackable.java b/src/cgeo/geocaching/cgeotrackable.java
index 19ae77e..32bfd63 100644
--- a/src/cgeo/geocaching/cgeotrackable.java
+++ b/src/cgeo/geocaching/cgeotrackable.java
@@ -7,7 +7,6 @@ import java.util.HashMap;
import android.app.ProgressDialog;
import android.content.Intent;
-import android.content.res.Resources;
import android.graphics.drawable.BitmapDrawable;
import android.graphics.drawable.Drawable;
import android.net.Uri;
@@ -36,12 +35,7 @@ public class cgeotrackable extends AbstractActivity {
public String guid = null;
public String id = null;
private String contextMenuUser = null;
- private Resources res = null;
- private cgeoapplication app = null;
private LayoutInflater inflater = null;
- private cgSettings settings = null;
- private cgBase base = null;
- private cgWarning warning = null;
private ProgressDialog waitDialog = null;
private Handler loadTrackableHandler = new Handler() {
@@ -52,14 +46,14 @@ public class cgeotrackable extends AbstractActivity {
TextView itemValue;
if (trackable != null && trackable.errorRetrieve != 0) {
- warning.showToast(res.getString(R.string.err_tb_details_download) + " " + cgBase.errorRetrieve.get(trackable.errorRetrieve) + ".");
+ showToast(res.getString(R.string.err_tb_details_download) + " " + cgBase.errorRetrieve.get(trackable.errorRetrieve) + ".");
finish();
return;
}
if (trackable != null && trackable.error.length() > 0) {
- warning.showToast(res.getString(R.string.err_tb_details_download) + " " + trackable.error + ".");
+ showToast(res.getString(R.string.err_tb_details_download) + " " + trackable.error + ".");
finish();
return;
@@ -71,9 +65,9 @@ public class cgeotrackable extends AbstractActivity {
}
if (geocode != null && geocode.length() > 0) {
- warning.showToast(res.getString(R.string.err_tb_find) + " " + geocode + ".");
+ showToast(res.getString(R.string.err_tb_find) + " " + geocode + ".");
} else {
- warning.showToast(res.getString(R.string.err_tb_find_that));
+ showToast(res.getString(R.string.err_tb_find_that));
}
finish();
@@ -234,7 +228,7 @@ public class cgeotrackable extends AbstractActivity {
((LinearLayout) findViewById(R.id.goal_box)).setVisibility(View.VISIBLE);
TextView descView = (TextView) findViewById(R.id.goal);
descView.setVisibility(View.VISIBLE);
- descView.setText(Html.fromHtml(trackable.goal, new cgHtmlImg(cgeotrackable.this, settings, geocode, true, 0, false), null), TextView.BufferType.SPANNABLE);
+ descView.setText(Html.fromHtml(trackable.goal, new cgHtmlImg(cgeotrackable.this, geocode, true, 0, false), null), TextView.BufferType.SPANNABLE);
descView.setMovementMethod(LinkMovementMethod.getInstance());
}
@@ -243,7 +237,7 @@ public class cgeotrackable extends AbstractActivity {
((LinearLayout) findViewById(R.id.details_box)).setVisibility(View.VISIBLE);
TextView descView = (TextView) findViewById(R.id.details);
descView.setVisibility(View.VISIBLE);
- descView.setText(Html.fromHtml(trackable.details, new cgHtmlImg(cgeotrackable.this, settings, geocode, true, 0, false), null), TextView.BufferType.SPANNABLE);
+ descView.setText(Html.fromHtml(trackable.details, new cgHtmlImg(cgeotrackable.this, geocode, true, 0, false), null), TextView.BufferType.SPANNABLE);
descView.setMovementMethod(LinkMovementMethod.getInstance());
}
@@ -281,7 +275,7 @@ public class cgeotrackable extends AbstractActivity {
public void run() {
BitmapDrawable image = null;
try {
- cgHtmlImg imgGetter = new cgHtmlImg(cgeotrackable.this, settings, geocode, true, 0, false);
+ cgHtmlImg imgGetter = new cgHtmlImg(cgeotrackable.this, geocode, true, 0, false);
image = imgGetter.getDrawable(trackable.image);
Message message = handler.obtainMessage(0, image);
@@ -314,13 +308,6 @@ public class cgeotrackable extends AbstractActivity {
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
- // init
- res = this.getResources();
- app = (cgeoapplication) this.getApplication();
- settings = new cgSettings(this, getSharedPreferences(cgSettings.preferences, 0));
- base = new cgBase(app, settings, getSharedPreferences(cgSettings.preferences, 0));
- warning = new cgWarning(this);
-
setTheme();
setContentView(R.layout.trackable_detail);
setTitle(res.getString(R.string.trackable));
@@ -358,7 +345,7 @@ public class cgeotrackable extends AbstractActivity {
guid = null;
id = id.toLowerCase();
} else {
- warning.showToast(res.getString(R.string.err_tb_details_open));
+ showToast(res.getString(R.string.err_tb_details_open));
finish();
return;
}
@@ -369,7 +356,7 @@ public class cgeotrackable extends AbstractActivity {
guid = null;
id = null;
} else {
- warning.showToast(res.getString(R.string.err_tb_details_open));
+ showToast(res.getString(R.string.err_tb_details_open));
finish();
return;
}
@@ -378,7 +365,7 @@ public class cgeotrackable extends AbstractActivity {
// no given data
if (geocode == null && guid == null && id == null) {
- warning.showToast(res.getString(R.string.err_tb_display));
+ showToast(res.getString(R.string.err_tb_display));
finish();
return;
}
@@ -497,7 +484,7 @@ public class cgeotrackable extends AbstractActivity {
id = idIn;
if (geocode == null && guid == null && id == null) {
- warning.showToast(res.getString(R.string.err_tb_forgot));
+ showToast(res.getString(R.string.err_tb_forgot));
stop();
finish();
@@ -567,7 +554,7 @@ public class cgeotrackable extends AbstractActivity {
});
}
- ((TextView) rowView.findViewById(R.id.log)).setText(Html.fromHtml(log.log, new cgHtmlImg(cgeotrackable.this, settings, null, false, 0, false), null), TextView.BufferType.SPANNABLE);
+ ((TextView) rowView.findViewById(R.id.log)).setText(Html.fromHtml(log.log, new cgHtmlImg(cgeotrackable.this, null, false, 0, false), null), TextView.BufferType.SPANNABLE);
((TextView) rowView.findViewById(R.id.author)).setOnClickListener(new userActions());
listView.addView(rowView);
@@ -619,7 +606,7 @@ public class cgeotrackable extends AbstractActivity {
BitmapDrawable image = null;
try {
- cgHtmlImg imgGetter = new cgHtmlImg(cgeotrackable.this, settings, trackable.geocode, false, 0, false);
+ cgHtmlImg imgGetter = new cgHtmlImg(cgeotrackable.this, trackable.geocode, false, 0, false);
image = imgGetter.getDrawable(url);
Message message = handler.obtainMessage(0, image);
diff --git a/src/cgeo/geocaching/cgeotrackables.java b/src/cgeo/geocaching/cgeotrackables.java
index 094311a..3005ad4 100644
--- a/src/cgeo/geocaching/cgeotrackables.java
+++ b/src/cgeo/geocaching/cgeotrackables.java
@@ -18,9 +18,6 @@ import cgeo.geocaching.activity.AbstractActivity;
public class cgeotrackables extends AbstractActivity {
private ArrayList<cgTrackable> trackables = new ArrayList<cgTrackable>();
private String geocode = null;
- private cgeoapplication app = null;
- private cgSettings settings = null;
- private cgWarning warning = null;
private LayoutInflater inflater = null;
private LinearLayout addList = null;
private ProgressDialog waitDialog = null;
@@ -42,7 +39,7 @@ public class cgeotrackables extends AbstractActivity {
waitDialog.dismiss();
}
- warning.showToast("Sorry, c:geo failed to load cache inventory.");
+ showToast("Sorry, c:geo failed to load cache inventory.");
finish();
return;
@@ -84,11 +81,6 @@ public class cgeotrackables extends AbstractActivity {
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
- // init
- app = (cgeoapplication) this.getApplication();
- settings = new cgSettings(this, getSharedPreferences(cgSettings.preferences, 0));
- warning = new cgWarning(this);
-
setTheme();
setContentView(R.layout.trackables);
setTitle("Trackables");
@@ -102,7 +94,7 @@ public class cgeotrackables extends AbstractActivity {
}
if (geocode == null) {
- warning.showToast("Sorry, c:geo forgot for what cache you want to load trackables.");
+ showToast("Sorry, c:geo forgot for what cache you want to load trackables.");
finish();
return;
}
diff --git a/src/cgeo/geocaching/cgeovisit.java b/src/cgeo/geocaching/cgeovisit.java
index 59e26b0..d135c0a 100644
--- a/src/cgeo/geocaching/cgeovisit.java
+++ b/src/cgeo/geocaching/cgeovisit.java
@@ -10,7 +10,6 @@ import android.app.Dialog;
import android.app.ProgressDialog;
import android.content.Intent;
import android.content.res.Configuration;
-import android.content.res.Resources;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
@@ -28,12 +27,7 @@ import android.widget.LinearLayout;
import android.widget.TextView;
public class cgeovisit extends cgLogForm {
- private cgeoapplication app = null;
- private Resources res = null;
private LayoutInflater inflater = null;
- private cgBase base = null;
- private cgSettings settings = null;
- private cgWarning warning = null;
private cgCache cache = null;
private ArrayList<Integer> types = new ArrayList<Integer>();
private ProgressDialog waitDialog = null;
@@ -79,11 +73,11 @@ public class cgeovisit extends cgLogForm {
typeSelected = types.get(0);
setType(typeSelected);
- warning.showToast(res.getString(R.string.info_log_type_changed));
+ showToast(res.getString(R.string.info_log_type_changed));
}
if ((viewstate == null || viewstate.length() == 0) && attempts < 2) {
- warning.showToast(res.getString(R.string.err_log_load_data_again));
+ showToast(res.getString(R.string.err_log_load_data_again));
loadData thread;
thread = new loadData(cacheid);
@@ -91,7 +85,7 @@ public class cgeovisit extends cgLogForm {
return;
} else if ((viewstate == null || viewstate.length() == 0) && attempts >= 2) {
- warning.showToast(res.getString(R.string.err_log_load_data));
+ showToast(res.getString(R.string.err_log_load_data));
showProgress(false);
return;
@@ -177,7 +171,7 @@ public class cgeovisit extends cgLogForm {
@Override
public void handleMessage(Message msg) {
if (msg.what == 1) {
- warning.showToast(res.getString(R.string.info_log_posted));
+ showToast(res.getString(R.string.info_log_posted));
if (waitDialog != null) {
waitDialog.dismiss();
@@ -186,7 +180,7 @@ public class cgeovisit extends cgLogForm {
finish();
return;
} else if (msg.what == 2) {
- warning.showToast(res.getString(R.string.info_log_saved));
+ showToast(res.getString(R.string.info_log_saved));
if (waitDialog != null) {
waitDialog.dismiss();
@@ -196,17 +190,17 @@ public class cgeovisit extends cgLogForm {
return;
} else if (msg.what >= 1000) {
if (msg.what == 1001) {
- warning.showToast(res.getString(R.string.warn_log_text_fill));
+ showToast(res.getString(R.string.warn_log_text_fill));
} else if (msg.what == 1002) {
- warning.showToast(res.getString(R.string.err_log_failed_server));
+ showToast(res.getString(R.string.err_log_failed_server));
} else {
- warning.showToast(res.getString(R.string.err_log_post_failed));
+ showToast(res.getString(R.string.err_log_post_failed));
}
} else {
if (cgBase.errorRetrieve.get(msg.what) != null) {
- warning.showToast(res.getString(R.string.err_log_post_failed_because) + " " + cgBase.errorRetrieve.get(msg.what) + ".");
+ showToast(res.getString(R.string.err_log_post_failed_because) + " " + cgBase.errorRetrieve.get(msg.what) + ".");
} else {
- warning.showToast(res.getString(R.string.err_log_post_failed));
+ showToast(res.getString(R.string.err_log_post_failed));
}
}
@@ -224,13 +218,6 @@ public class cgeovisit extends cgLogForm {
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
- // init
- res = this.getResources();
- app = (cgeoapplication) this.getApplication();
- settings = new cgSettings(this, getSharedPreferences(cgSettings.preferences, 0));
- base = new cgBase(app, settings, getSharedPreferences(cgSettings.preferences, 0));
- warning = new cgWarning(this);
-
setTheme();
setContentView(R.layout.visit);
setTitle(res.getString(R.string.log_new_log));
@@ -262,7 +249,7 @@ public class cgeovisit extends cgLogForm {
app.setAction(geocode);
if (cache == null) {
- warning.showToast(res.getString(R.string.err_detail_cache_forgot_visit));
+ showToast(res.getString(R.string.err_detail_cache_forgot_visit));
finish();
return;
@@ -408,7 +395,7 @@ public class cgeovisit extends cgLogForm {
if (settings.getSignature().contains("[NUMBER]") == true) {
final HashMap<String, String> params = new HashMap<String, String>();
final String page = base.request(false, "www.geocaching.com", "/my/", "GET", params, false, false, false).getData();
- int current = base.parseFindCount(page);
+ int current = cgBase.parseFindCount(page);
if (current >= 0) {
findCount = "" + (current + 1);
@@ -729,7 +716,7 @@ public class cgeovisit extends cgLogForm {
Thread thread = new postLog(postLogHandler, log);
thread.start();
} else {
- warning.showToast(res.getString(R.string.err_log_load_data_still));
+ showToast(res.getString(R.string.err_log_load_data_still));
}
}
}
@@ -745,10 +732,10 @@ public class cgeovisit extends cgLogForm {
save.setOnClickListener(new saveListener());
if (status == true) {
- warning.showToast(res.getString(R.string.info_log_saved));
+ showToast(res.getString(R.string.info_log_saved));
app.saveVisitDate(geocode);
} else {
- warning.showToast(res.getString(R.string.err_log_post_failed));
+ showToast(res.getString(R.string.err_log_post_failed));
}
}
}
@@ -784,7 +771,7 @@ public class cgeovisit extends cgLogForm {
}
clear.setOnClickListener(new clearListener());
- warning.showToast(res.getString(R.string.info_log_cleared));
+ showToast(res.getString(R.string.info_log_cleared));
}
}
@@ -796,7 +783,7 @@ public class cgeovisit extends cgLogForm {
cacheid = cacheidIn;
if (cacheid == null) {
- warning.showToast(res.getString(R.string.err_detail_cache_forgot_visit));
+ showToast(res.getString(R.string.err_detail_cache_forgot_visit));
finish();
return;
@@ -821,11 +808,11 @@ public class cgeovisit extends cgLogForm {
final String page = base.request(false, "www.geocaching.com", "/seek/log.aspx", "GET", params, false, false, false).getData();
- viewstate = base.findViewstate(page, 0);
- viewstate1 = base.findViewstate(page, 1);
- trackables = base.parseTrackableLog(page);
+ viewstate = cgBase.findViewstate(page, 0);
+ viewstate1 = cgBase.findViewstate(page, 1);
+ trackables = cgBase.parseTrackableLog(page);
- final ArrayList<Integer> typesPre = base.parseTypes(page);
+ final ArrayList<Integer> typesPre = cgBase.parseTypes(page);
if (typesPre.size() > 0) {
types.clear();
types.addAll(typesPre);
@@ -906,7 +893,7 @@ public class cgeovisit extends cgLogForm {
&& settings.tokenPublic != null && settings.tokenPublic.length() > 0 && settings.tokenSecret != null
&& settings.tokenSecret.length() > 0 && tweetCheck.isChecked() == true && tweetBox.getVisibility() == View.VISIBLE
) {
- base.postTweetCache(app, settings, geocode);
+ cgBase.postTweetCache(app, settings, geocode);
}
if (status == 1 && typeSelected == cgBase.LOG_FOUND_IT && settings.isGCvoteLogin() == true) {
diff --git a/src/cgeo/geocaching/cgeowaypoint.java b/src/cgeo/geocaching/cgeowaypoint.java
index b17f278..138bf7e 100644
--- a/src/cgeo/geocaching/cgeowaypoint.java
+++ b/src/cgeo/geocaching/cgeowaypoint.java
@@ -4,7 +4,6 @@ import java.util.ArrayList;
import android.app.ProgressDialog;
import android.content.Intent;
-import android.content.res.Resources;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
@@ -30,11 +29,6 @@ public class cgeowaypoint extends AbstractActivity {
private cgWaypoint waypoint = null;
private String geocode = null;
private int id = -1;
- private cgeoapplication app = null;
- private Resources res = null;
- private cgSettings settings = null;
- private cgBase base = null;
- private cgWarning warning = null;
private ProgressDialog waitDialog = null;
private cgGeo geo = null;
private cgUpdateLoc geoUpdate = new update();
@@ -49,7 +43,7 @@ public class cgeowaypoint extends AbstractActivity {
waitDialog = null;
}
- warning.showToast(res.getString(R.string.err_waypoint_load_failed));
+ showToast(res.getString(R.string.err_waypoint_load_failed));
finish();
return;
@@ -77,7 +71,7 @@ public class cgeowaypoint extends AbstractActivity {
waypoint.setIcon(res, base, identification);
if (waypoint.latitude != null && waypoint.longitude != null) {
- coords.setText(Html.fromHtml(base.formatCoordinate(waypoint.latitude, "lat", true) + " | " + base.formatCoordinate(waypoint.longitude, "lon", true)), TextView.BufferType.SPANNABLE);
+ coords.setText(Html.fromHtml(cgBase.formatCoordinate(waypoint.latitude, "lat", true) + " | " + cgBase.formatCoordinate(waypoint.longitude, "lon", true)), TextView.BufferType.SPANNABLE);
compass.setVisibility(View.VISIBLE);
separator.setVisibility(View.VISIBLE);
} else {
@@ -136,13 +130,6 @@ public class cgeowaypoint extends AbstractActivity {
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
- // init
- res = this.getResources();
- app = (cgeoapplication) this.getApplication();
- settings = new cgSettings(this, getSharedPreferences(cgSettings.preferences, 0));
- base = new cgBase(app, settings, getSharedPreferences(cgSettings.preferences, 0));
- warning = new cgWarning(this);
-
setTheme();
setContentView(R.layout.waypoint);
setTitle("waypoint");
@@ -157,13 +144,13 @@ public class cgeowaypoint extends AbstractActivity {
}
if (id <= 0) {
- warning.showToast(res.getString(R.string.err_waypoint_unknown));
+ showToast(res.getString(R.string.err_waypoint_unknown));
finish();
return;
}
if (geo == null) {
- geo = app.startGeo(this, geoUpdate, base, settings, warning, 0, 0);
+ geo = app.startGeo(this, geoUpdate, base, settings, 0, 0);
}
waitDialog = ProgressDialog.show(this, null, res.getString(R.string.waypoint_loading), true);
@@ -179,7 +166,7 @@ public class cgeowaypoint extends AbstractActivity {
settings.load();
if (geo == null) {
- geo = app.startGeo(this, geoUpdate, base, settings, warning, 0, 0);
+ geo = app.startGeo(this, geoUpdate, base, settings, 0, 0);
}
if (waitDialog == null) {
@@ -260,12 +247,12 @@ public class cgeowaypoint extends AbstractActivity {
return true;
}
- return NavigationAppFactory.onMenuItemSelected(item, geo, this, res, warning, null, null, waypoint, null);
+ return NavigationAppFactory.onMenuItemSelected(item, geo, this, res, null, null, waypoint, null);
}
private void cachesAround() {
if (waypoint == null || waypoint.latitude == null || waypoint.longitude == null) {
- warning.showToast(res.getString(R.string.err_location_unknown));
+ showToast(res.getString(R.string.err_location_unknown));
}
cgeocaches cachesActivity = new cgeocaches();
@@ -328,7 +315,7 @@ public class cgeowaypoint extends AbstractActivity {
public void onClick(View arg0) {
if (app.deleteWaypoint(id) == false) {
- warning.showToast(res.getString(R.string.err_waypoint_delete_failed));
+ showToast(res.getString(R.string.err_waypoint_delete_failed));
} else {
app.removeCacheFromCache(geocode);
@@ -340,7 +327,7 @@ public class cgeowaypoint extends AbstractActivity {
public void goCompass(View view) {
if (waypoint == null || waypoint.latitude == null || waypoint.longitude == null) {
- warning.showToast(res.getString(R.string.err_location_unknown));
+ showToast(res.getString(R.string.err_location_unknown));
}
Intent navigateIntent = new Intent(this, cgeonavigate.class);
diff --git a/src/cgeo/geocaching/cgeowaypointadd.java b/src/cgeo/geocaching/cgeowaypointadd.java
index 6d13cb8..2da4faf 100644
--- a/src/cgeo/geocaching/cgeowaypointadd.java
+++ b/src/cgeo/geocaching/cgeowaypointadd.java
@@ -6,7 +6,6 @@ import java.util.regex.Matcher;
import java.util.regex.Pattern;
import android.app.ProgressDialog;
-import android.content.res.Resources;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
@@ -22,11 +21,6 @@ import cgeo.geocaching.activity.ActivityMixin;
public class cgeowaypointadd extends AbstractActivity {
- private cgeoapplication app = null;
- private Resources res = null;
- private cgSettings settings = null;
- private cgBase base = null;
- private cgWarning warning = null;
private String geocode = null;
private int id = -1;
private cgGeo geo = null;
@@ -62,8 +56,8 @@ public class cgeowaypointadd extends AbstractActivity {
app.setAction(geocode);
- ((EditText) findViewById(R.id.latitude)).setText(base.formatCoordinate(waypoint.latitude, "lat", true));
- ((EditText) findViewById(R.id.longitude)).setText(base.formatCoordinate(waypoint.longitude, "lon", true));
+ ((EditText) findViewById(R.id.latitude)).setText(cgBase.formatCoordinate(waypoint.latitude, "lat", true));
+ ((EditText) findViewById(R.id.longitude)).setText(cgBase.formatCoordinate(waypoint.longitude, "lon", true));
((EditText) findViewById(R.id.name)).setText(Html.fromHtml(waypoint.name.trim()).toString());
((EditText) findViewById(R.id.note)).setText(Html.fromHtml(waypoint.note.trim()).toString());
@@ -86,19 +80,12 @@ public class cgeowaypointadd extends AbstractActivity {
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
- // init
- res = this.getResources();
- app = (cgeoapplication) this.getApplication();
- settings = new cgSettings(this, getSharedPreferences(cgSettings.preferences, 0));
- base = new cgBase(app, settings, getSharedPreferences(cgSettings.preferences, 0));
- warning = new cgWarning(this);
-
setTheme();
setContentView(R.layout.waypoint_new);
setTitle("waypoint");
if (geo == null) {
- geo = app.startGeo(this, geoUpdate, base, settings, warning, 0, 0);
+ geo = app.startGeo(this, geoUpdate, base, settings, 0, 0);
}
// get parameters
@@ -110,7 +97,7 @@ public class cgeowaypointadd extends AbstractActivity {
}
if ((geocode == null || geocode.length() == 0) && id <= 0) {
- warning.showToast(res.getString(R.string.err_waypoint_cache_unknown));
+ showToast(res.getString(R.string.err_waypoint_cache_unknown));
finish();
return;
@@ -153,7 +140,7 @@ public class cgeowaypointadd extends AbstractActivity {
settings.load();
if (geo == null) {
- geo = app.startGeo(this, geoUpdate, base, settings, warning, 0, 0);
+ geo = app.startGeo(this, geoUpdate, base, settings, 0, 0);
}
if (id > 0) {
@@ -209,8 +196,8 @@ public class cgeowaypointadd extends AbstractActivity {
lonEdit = (EditText) findViewById(R.id.longitude);
}
- latEdit.setHint(base.formatCoordinate(geo.latitudeNow, "lat", false));
- lonEdit.setHint(base.formatCoordinate(geo.longitudeNow, "lon", false));
+ latEdit.setHint(cgBase.formatCoordinate(geo.latitudeNow, "lat", false));
+ lonEdit.setHint(cgBase.formatCoordinate(geo.longitudeNow, "lon", false));
} catch (Exception e) {
Log.w(cgSettings.tag, "Failed to update location.");
}
@@ -235,12 +222,12 @@ public class cgeowaypointadd extends AbstractActivity {
public void onClick(View arg0) {
if (geo == null || geo.latitudeNow == null || geo.longitudeNow == null) {
- warning.showToast(res.getString(R.string.err_point_unknown_position));
+ showToast(res.getString(R.string.err_point_unknown_position));
return;
}
- ((EditText) findViewById(R.id.latitude)).setText(base.formatCoordinate(geo.latitudeNow, "lat", true));
- ((EditText) findViewById(R.id.longitude)).setText(base.formatCoordinate(geo.longitudeNow, "lon", true));
+ ((EditText) findViewById(R.id.latitude)).setText(cgBase.formatCoordinate(geo.latitudeNow, "lat", true));
+ ((EditText) findViewById(R.id.longitude)).setText(cgBase.formatCoordinate(geo.longitudeNow, "lon", true));
}
}
@@ -258,22 +245,22 @@ public class cgeowaypointadd extends AbstractActivity {
if ((bearingText == null || bearingText.length() == 0) && (distanceText == null || distanceText.length() == 0)
&& (latText == null || latText.length() == 0) && (lonText == null || lonText.length() == 0)) {
- warning.helpDialog(res.getString(R.string.err_point_no_position_given_title), res.getString(R.string.err_point_no_position_given));
+ helpDialog(res.getString(R.string.err_point_no_position_given_title), res.getString(R.string.err_point_no_position_given));
return;
}
if (latText != null && latText.length() > 0 && lonText != null && lonText.length() > 0) {
// latitude & longitude
- HashMap<String, Object> latParsed = base.parseCoordinate(latText, "lat");
- HashMap<String, Object> lonParsed = base.parseCoordinate(lonText, "lat");
+ HashMap<String, Object> latParsed = cgBase.parseCoordinate(latText, "lat");
+ HashMap<String, Object> lonParsed = cgBase.parseCoordinate(lonText, "lat");
if (latParsed == null || latParsed.get("coordinate") == null || latParsed.get("string") == null) {
- warning.showToast(res.getString(R.string.err_parse_lat));
+ showToast(res.getString(R.string.err_parse_lat));
return;
}
if (lonParsed == null || lonParsed.get("coordinate") == null || lonParsed.get("string") == null) {
- warning.showToast(res.getString(R.string.err_parse_lon));
+ showToast(res.getString(R.string.err_parse_lon));
return;
}
@@ -281,7 +268,7 @@ public class cgeowaypointadd extends AbstractActivity {
longitude = (Double) lonParsed.get("coordinate");
} else {
if (geo == null || geo.latitudeNow == null || geo.longitudeNow == null) {
- warning.showToast(res.getString(R.string.err_point_curr_position_unavailable));
+ showToast(res.getString(R.string.err_point_curr_position_unavailable));
return;
}
@@ -298,7 +285,7 @@ public class cgeowaypointadd extends AbstractActivity {
// probably not a number
}
if (bearing == null) {
- warning.helpDialog(res.getString(R.string.err_point_bear_and_dist_title), res.getString(R.string.err_point_bear_and_dist));
+ helpDialog(res.getString(R.string.err_point_bear_and_dist_title), res.getString(R.string.err_point_bear_and_dist));
return;
}
@@ -339,20 +326,20 @@ public class cgeowaypointadd extends AbstractActivity {
}
if (distance == null) {
- warning.showToast(res.getString(R.string.err_parse_dist));
+ showToast(res.getString(R.string.err_parse_dist));
return;
}
Double latParsed = null;
Double lonParsed = null;
- HashMap<String, Double> coordsDst = base.getRadialDistance(latitude, longitude, bearing, distance);
+ HashMap<String, Double> coordsDst = cgBase.getRadialDistance(latitude, longitude, bearing, distance);
latParsed = coordsDst.get("latitude");
lonParsed = coordsDst.get("longitude");
if (latParsed == null || lonParsed == null) {
- warning.showToast(res.getString(R.string.err_point_location_error));
+ showToast(res.getString(R.string.err_point_location_error));
return;
}
@@ -362,7 +349,7 @@ public class cgeowaypointadd extends AbstractActivity {
coords.add(0, latitude);
coords.add(1, longitude);
} else {
- warning.showToast(res.getString(R.string.err_point_location_error));
+ showToast(res.getString(R.string.err_point_location_error));
return;
}
@@ -381,8 +368,8 @@ public class cgeowaypointadd extends AbstractActivity {
waypoint.name = name;
waypoint.latitude = coords.get(0);
waypoint.longitude = coords.get(1);
- waypoint.latitudeString = base.formatCoordinate(coords.get(0), "lat", true);
- waypoint.longitudeString = base.formatCoordinate(coords.get(1), "lon", true);
+ waypoint.latitudeString = cgBase.formatCoordinate(coords.get(0), "lat", true);
+ waypoint.longitudeString = cgBase.formatCoordinate(coords.get(1), "lon", true);
waypoint.note = note;
if (app.saveOwnWaypoint(id, geocode, waypoint) == true) {
@@ -391,7 +378,7 @@ public class cgeowaypointadd extends AbstractActivity {
finish();
return;
} else {
- warning.showToast(res.getString(R.string.err_waypoint_add_failed));
+ showToast(res.getString(R.string.err_waypoint_add_failed));
}
}
}
diff --git a/src/cgeo/geocaching/mapcommon/cgeomap.java b/src/cgeo/geocaching/mapcommon/cgeomap.java
index 25f0b4e..9ea03e5 100644
--- a/src/cgeo/geocaching/mapcommon/cgeomap.java
+++ b/src/cgeo/geocaching/mapcommon/cgeomap.java
@@ -32,7 +32,6 @@ import cgeo.geocaching.cgSettings.mapSourceEnum;
import cgeo.geocaching.cgUpdateDir;
import cgeo.geocaching.cgUpdateLoc;
import cgeo.geocaching.cgUser;
-import cgeo.geocaching.cgWarning;
import cgeo.geocaching.cgWaypoint;
import cgeo.geocaching.cgeoapplication;
import cgeo.geocaching.activity.ActivityMixin;
@@ -65,7 +64,6 @@ public class cgeomap extends MapBase {
private MapControllerImpl mapController = null;
private cgSettings settings = null;
private cgBase base = null;
- private cgWarning warning = null;
private cgeoapplication app = null;
private SharedPreferences.Editor prefsEdit = null;
private cgGeo geo = null;
@@ -202,10 +200,10 @@ public class cgeomap extends MapBase {
}
if (geo == null) {
- geo = app.startGeo(activity, geoUpdate, base, settings, warning, 0, 0);
+ geo = app.startGeo(activity, geoUpdate, base, settings, 0, 0);
}
if (settings.useCompass == 1 && dir == null) {
- dir = app.startDir(activity, dirUpdate, warning);
+ dir = app.startDir(activity, dirUpdate);
}
}
}
@@ -215,7 +213,7 @@ public class cgeomap extends MapBase {
@Override
public void handleMessage(Message msg) {
if (!noMapTokenShowed) {
- warning.showToast(res.getString(R.string.map_token_err));
+ ActivityMixin.showToast(activity, res.getString(R.string.map_token_err));
noMapTokenShowed = true;
}
@@ -237,7 +235,6 @@ public class cgeomap extends MapBase {
app.setAction(null);
settings = new cgSettings(activity, activity.getSharedPreferences(cgSettings.preferences, 0));
base = new cgBase(app, settings, activity.getSharedPreferences(cgSettings.preferences, 0));
- warning = new cgWarning(activity);
prefsEdit = activity.getSharedPreferences(cgSettings.preferences, 0).edit();
MapFactory mapFactory = settings.getMapFactory();
@@ -253,10 +250,10 @@ public class cgeomap extends MapBase {
ActivityMixin.setTitle(activity, res.getString(R.string.map_map));
if (geo == null) {
- geo = app.startGeo(activity, geoUpdate, base, settings, warning, 0, 0);
+ geo = app.startGeo(activity, geoUpdate, base, settings, 0, 0);
}
if (settings.useCompass == 1 && dir == null) {
- dir = app.startDir(activity, dirUpdate, warning);
+ dir = app.startDir(activity, dirUpdate);
}
// initialize map
@@ -355,10 +352,10 @@ public class cgeomap extends MapBase {
app.setAction(null);
if (geo == null) {
- geo = app.startGeo(activity, geoUpdate, base, settings, warning, 0, 0);
+ geo = app.startGeo(activity, geoUpdate, base, settings, 0, 0);
}
if (settings.useCompass == 1 && dir == null) {
- dir = app.startDir(activity, dirUpdate, warning);
+ dir = app.startDir(activity, dirUpdate);
}
if (geo != null) {
@@ -572,7 +569,7 @@ public class cgeomap extends MapBase {
for (cgCache oneCache : cachesProtected) {
if (oneCache != null && oneCache.latitude != null && oneCache.longitude != null) {
- if (base.isCacheInViewPort(mapCenterLat, mapCenterLon, mapSpanLat, mapSpanLon, oneCache.latitude, oneCache.longitude) && app.isOffline(oneCache.geocode, null) == false) {
+ if (cgBase.isCacheInViewPort(mapCenterLat, mapCenterLon, mapSpanLat, mapSpanLon, oneCache.latitude, oneCache.longitude) && app.isOffline(oneCache.geocode, null) == false) {
geocodes.add(oneCache.geocode);
}
}
@@ -585,7 +582,7 @@ public class cgeomap extends MapBase {
detailTotal = geocodes.size();
if (detailTotal == 0) {
- warning.showToast(res.getString(R.string.warn_save_nothing));
+ ActivityMixin.showToast(activity, res.getString(R.string.warn_save_nothing));
return true;
}
@@ -603,10 +600,10 @@ public class cgeomap extends MapBase {
}
if (geo == null) {
- geo = app.startGeo(activity, geoUpdate, base, settings, warning, 0, 0);
+ geo = app.startGeo(activity, geoUpdate, base, settings, 0, 0);
}
if (settings.useCompass == 1 && dir == null) {
- dir = app.startDir(activity, dirUpdate, warning);
+ dir = app.startDir(activity, dirUpdate);
}
} catch (Exception e) {
Log.e(cgSettings.tag, "cgeocaches.onPrepareOptionsMenu.onCancel: " + e.toString());
@@ -878,7 +875,7 @@ public class cgeomap extends MapBase {
} else if (((Math.abs(spanLatitudeNow - spanLatitude) > 50) || (Math.abs(spanLongitudeNow - spanLongitude) > 50) || // changed zoom
(Math.abs(centerLatitudeNow - centerLatitude) > (spanLatitudeNow / 4)) || (Math.abs(centerLongitudeNow - centerLongitude) > (spanLongitudeNow / 4)) // map moved
) && (cachesCnt <= 0 || caches == null || caches.isEmpty()
- || !base.isInViewPort(centerLatitude, centerLongitude, centerLatitudeNow, centerLongitudeNow, spanLatitude, spanLongitude, spanLatitudeNow, spanLongitudeNow))) {
+ || !cgBase.isInViewPort(centerLatitude, centerLongitude, centerLatitudeNow, centerLongitudeNow, spanLatitude, spanLongitude, spanLatitudeNow, spanLongitudeNow))) {
moved = true;
}
@@ -993,7 +990,7 @@ public class cgeomap extends MapBase {
moved = true;
} else if (((Math.abs(spanLatitudeNow - spanLatitudeUsers) > 50) || (Math.abs(spanLongitudeNow - spanLongitudeUsers) > 50) || // changed zoom
(Math.abs(centerLatitudeNow - centerLatitudeUsers) > (spanLatitudeNow / 4)) || (Math.abs(centerLongitudeNow - centerLongitudeUsers) > (spanLongitudeNow / 4)) // map moved
- ) && !base.isInViewPort(centerLatitudeUsers, centerLongitudeUsers, centerLatitudeNow, centerLongitudeNow, spanLatitudeUsers, spanLongitudeUsers, spanLatitudeNow, spanLongitudeNow)) {
+ ) && !cgBase.isInViewPort(centerLatitudeUsers, centerLongitudeUsers, centerLatitudeNow, centerLongitudeNow, spanLatitudeUsers, spanLongitudeUsers, spanLatitudeNow, spanLongitudeNow)) {
moved = true;
}