aboutsummaryrefslogtreecommitdiffstats
path: root/main/src/cgeo/geocaching/apps
diff options
context:
space:
mode:
authorBananeweizen <bananeweizen@gmx.de>2011-10-03 13:47:07 +0200
committerBananeweizen <bananeweizen@gmx.de>2011-10-03 13:47:07 +0200
commitf52b1f0c1a58978efd5e8478f29484cb1f3b421e (patch)
tree39080018d83b12407a7df47153431464173e5e19 /main/src/cgeo/geocaching/apps
parente99ed4d71470da9efe59f4b363762d105dbfdc6d (diff)
downloadcgeo-f52b1f0c1a58978efd5e8478f29484cb1f3b421e.zip
cgeo-f52b1f0c1a58978efd5e8478f29484cb1f3b421e.tar.gz
cgeo-f52b1f0c1a58978efd5e8478f29484cb1f3b421e.tar.bz2
fix #120: make settings static (no singleton)
* Settings can no longer be instantiated, everything is static instead. * Most option values are no longer cached in fields. This has been done for clarity during the refactoring. I will add some performance tests afterwards and may re-introduce those fields for caching the option values. Sorry, if anyone gets merge issues afterwards. There was no easier way to implement this...
Diffstat (limited to 'main/src/cgeo/geocaching/apps')
-rw-r--r--main/src/cgeo/geocaching/apps/AbstractApp.java7
-rw-r--r--main/src/cgeo/geocaching/apps/AbstractLocusApp.java6
-rw-r--r--main/src/cgeo/geocaching/apps/cache/GeneralAppsFactory.java4
-rw-r--r--main/src/cgeo/geocaching/apps/cache/navi/GoogleMapsApp.java4
-rw-r--r--main/src/cgeo/geocaching/apps/cache/navi/GoogleNavigationApp.java8
-rw-r--r--main/src/cgeo/geocaching/apps/cache/navi/InternalMap.java5
-rw-r--r--main/src/cgeo/geocaching/apps/cache/navi/NavigationAppFactory.java4
-rw-r--r--main/src/cgeo/geocaching/apps/cachelist/CacheListAppFactory.java4
-rw-r--r--main/src/cgeo/geocaching/apps/cachelist/InternalCacheListMap.java3
9 files changed, 18 insertions, 27 deletions
diff --git a/main/src/cgeo/geocaching/apps/AbstractApp.java b/main/src/cgeo/geocaching/apps/AbstractApp.java
index f917563..1a166c6 100644
--- a/main/src/cgeo/geocaching/apps/AbstractApp.java
+++ b/main/src/cgeo/geocaching/apps/AbstractApp.java
@@ -1,9 +1,7 @@
package cgeo.geocaching.apps;
-import cgeo.geocaching.cgSettings;
import cgeo.geocaching.utils.CollectionUtils;
-import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.content.pm.PackageManager;
@@ -74,9 +72,4 @@ public abstract class AbstractApp implements App {
public int getId() {
return getName().hashCode();
}
-
- protected static cgSettings getSettings(Activity activity) {
- return new cgSettings(activity,
- activity.getSharedPreferences(cgSettings.preferences, Context.MODE_PRIVATE));
- }
}
diff --git a/main/src/cgeo/geocaching/apps/AbstractLocusApp.java b/main/src/cgeo/geocaching/apps/AbstractLocusApp.java
index 26874c4..6213899 100644
--- a/main/src/cgeo/geocaching/apps/AbstractLocusApp.java
+++ b/main/src/cgeo/geocaching/apps/AbstractLocusApp.java
@@ -2,7 +2,7 @@ package cgeo.geocaching.apps;
import cgeo.geocaching.R;
import cgeo.geocaching.cgCache;
-import cgeo.geocaching.cgSettings;
+import cgeo.geocaching.Settings;
import cgeo.geocaching.cgWaypoint;
import cgeo.geocaching.enumerations.CacheSize;
import cgeo.geocaching.enumerations.CacheType;
@@ -105,7 +105,7 @@ public abstract class AbstractLocusApp extends AbstractApp {
}
// create one simple point with location
- Location loc = new Location(cgSettings.tag);
+ Location loc = new Location(Settings.tag);
loc.setLatitude(cache.coords.getLatitude());
loc.setLongitude(cache.coords.getLongitude());
@@ -183,7 +183,7 @@ public abstract class AbstractLocusApp extends AbstractApp {
}
// create one simple point with location
- Location loc = new Location(cgSettings.tag);
+ Location loc = new Location(Settings.tag);
loc.setLatitude(waypoint.coords.getLatitude());
loc.setLongitude(waypoint.coords.getLongitude());
diff --git a/main/src/cgeo/geocaching/apps/cache/GeneralAppsFactory.java b/main/src/cgeo/geocaching/apps/cache/GeneralAppsFactory.java
index eb581ca..ad72dc9 100644
--- a/main/src/cgeo/geocaching/apps/cache/GeneralAppsFactory.java
+++ b/main/src/cgeo/geocaching/apps/cache/GeneralAppsFactory.java
@@ -1,7 +1,7 @@
package cgeo.geocaching.apps.cache;
import cgeo.geocaching.cgCache;
-import cgeo.geocaching.cgSettings;
+import cgeo.geocaching.Settings;
import cgeo.geocaching.apps.AbstractAppFactory;
import org.apache.commons.lang3.ArrayUtils;
@@ -39,7 +39,7 @@ public final class GeneralAppsFactory extends AbstractAppFactory {
try {
return app.invoke(activity, cache);
} catch (Exception e) {
- Log.e(cgSettings.tag, "GeneralAppsFactory.onMenuItemSelected: " + e.toString());
+ Log.e(Settings.tag, "GeneralAppsFactory.onMenuItemSelected: " + e.toString());
}
}
return false;
diff --git a/main/src/cgeo/geocaching/apps/cache/navi/GoogleMapsApp.java b/main/src/cgeo/geocaching/apps/cache/navi/GoogleMapsApp.java
index b60a635..961773f 100644
--- a/main/src/cgeo/geocaching/apps/cache/navi/GoogleMapsApp.java
+++ b/main/src/cgeo/geocaching/apps/cache/navi/GoogleMapsApp.java
@@ -3,7 +3,7 @@ package cgeo.geocaching.apps.cache.navi;
import cgeo.geocaching.R;
import cgeo.geocaching.cgCache;
import cgeo.geocaching.cgGeo;
-import cgeo.geocaching.cgSettings;
+import cgeo.geocaching.Settings;
import cgeo.geocaching.cgWaypoint;
import cgeo.geocaching.activity.ActivityMixin;
import cgeo.geocaching.geopoint.Geopoint;
@@ -49,7 +49,7 @@ class GoogleMapsApp extends AbstractNavigationApp implements NavigationApp {
// nothing
}
- Log.i(cgSettings.tag, "cgBase.runExternalMap: No maps application available.");
+ Log.i(Settings.tag, "cgBase.runExternalMap: No maps application available.");
if (res != null) {
ActivityMixin.showToast(activity, res.getString(R.string.err_application_no));
diff --git a/main/src/cgeo/geocaching/apps/cache/navi/GoogleNavigationApp.java b/main/src/cgeo/geocaching/apps/cache/navi/GoogleNavigationApp.java
index 2cd2b22..44a4cbd 100644
--- a/main/src/cgeo/geocaching/apps/cache/navi/GoogleNavigationApp.java
+++ b/main/src/cgeo/geocaching/apps/cache/navi/GoogleNavigationApp.java
@@ -3,7 +3,7 @@ package cgeo.geocaching.apps.cache.navi;
import cgeo.geocaching.R;
import cgeo.geocaching.cgCache;
import cgeo.geocaching.cgGeo;
-import cgeo.geocaching.cgSettings;
+import cgeo.geocaching.Settings;
import cgeo.geocaching.cgWaypoint;
import cgeo.geocaching.activity.ActivityMixin;
import cgeo.geocaching.geopoint.Geopoint;
@@ -61,10 +61,8 @@ class GoogleNavigationApp extends AbstractNavigationApp implements
private static boolean navigateToCoordinates(cgGeo geo, Activity activity, final Geopoint coords) {
final Geopoint coordsNow = geo == null ? null : geo.coordsNow;
- cgSettings settings = getSettings(activity);
-
// Google Navigation
- if (settings.useGNavigation == 1) {
+ if (Settings.isUseGoogleNavigation()) {
try {
activity.startActivity(new Intent(Intent.ACTION_VIEW, Uri
.parse("google.navigation:ll=" + coords.getLatitude() + ","
@@ -94,7 +92,7 @@ class GoogleNavigationApp extends AbstractNavigationApp implements
// nothing
}
- Log.i(cgSettings.tag,
+ Log.i(Settings.tag,
"cgBase.runNavigation: No navigation application available.");
return false;
}
diff --git a/main/src/cgeo/geocaching/apps/cache/navi/InternalMap.java b/main/src/cgeo/geocaching/apps/cache/navi/InternalMap.java
index e5069c5..57e67a5 100644
--- a/main/src/cgeo/geocaching/apps/cache/navi/InternalMap.java
+++ b/main/src/cgeo/geocaching/apps/cache/navi/InternalMap.java
@@ -3,7 +3,7 @@ package cgeo.geocaching.apps.cache.navi;
import cgeo.geocaching.R;
import cgeo.geocaching.cgCache;
import cgeo.geocaching.cgGeo;
-import cgeo.geocaching.cgSettings;
+import cgeo.geocaching.Settings;
import cgeo.geocaching.cgWaypoint;
import cgeo.geocaching.enumerations.WaypointType;
import cgeo.geocaching.geopoint.Geopoint;
@@ -25,8 +25,7 @@ class InternalMap extends AbstractInternalMap implements
public boolean invoke(cgGeo geo, Activity activity, Resources res,
cgCache cache,
final UUID searchId, cgWaypoint waypoint, final Geopoint coords) {
- cgSettings settings = getSettings(activity);
- Intent mapIntent = new Intent(activity, settings.getMapFactory().getMapClass());
+ Intent mapIntent = new Intent(activity, Settings.getMapFactory().getMapClass());
if (cache != null) {
mapIntent.putExtra("detail", false);
mapIntent.putExtra("geocode", cache.geocode);
diff --git a/main/src/cgeo/geocaching/apps/cache/navi/NavigationAppFactory.java b/main/src/cgeo/geocaching/apps/cache/navi/NavigationAppFactory.java
index 1a46200..15ee464 100644
--- a/main/src/cgeo/geocaching/apps/cache/navi/NavigationAppFactory.java
+++ b/main/src/cgeo/geocaching/apps/cache/navi/NavigationAppFactory.java
@@ -2,7 +2,7 @@ package cgeo.geocaching.apps.cache.navi;
import cgeo.geocaching.cgCache;
import cgeo.geocaching.cgGeo;
-import cgeo.geocaching.cgSettings;
+import cgeo.geocaching.Settings;
import cgeo.geocaching.cgWaypoint;
import cgeo.geocaching.apps.AbstractAppFactory;
import cgeo.geocaching.geopoint.Geopoint;
@@ -56,7 +56,7 @@ public final class NavigationAppFactory extends AbstractAppFactory {
return app.invoke(geo, activity, res, cache,
searchId, waypoint, destination);
} catch (Exception e) {
- Log.e(cgSettings.tag, "NavigationAppFactory.onMenuItemSelected: " + e.toString());
+ Log.e(Settings.tag, "NavigationAppFactory.onMenuItemSelected: " + e.toString());
}
}
return false;
diff --git a/main/src/cgeo/geocaching/apps/cachelist/CacheListAppFactory.java b/main/src/cgeo/geocaching/apps/cachelist/CacheListAppFactory.java
index 5359719..5b3dc9a 100644
--- a/main/src/cgeo/geocaching/apps/cachelist/CacheListAppFactory.java
+++ b/main/src/cgeo/geocaching/apps/cachelist/CacheListAppFactory.java
@@ -3,7 +3,7 @@ package cgeo.geocaching.apps.cachelist;
import cgeo.geocaching.R;
import cgeo.geocaching.cgCache;
import cgeo.geocaching.cgGeo;
-import cgeo.geocaching.cgSettings;
+import cgeo.geocaching.Settings;
import cgeo.geocaching.apps.AbstractAppFactory;
import org.apache.commons.lang3.ArrayUtils;
@@ -70,7 +70,7 @@ public final class CacheListAppFactory extends AbstractAppFactory {
try {
return app.invoke(geo, caches, activity, res, searchId);
} catch (Exception e) {
- Log.e(cgSettings.tag, "CacheListAppFactory.onMenuItemSelected: " + e.toString());
+ Log.e(Settings.tag, "CacheListAppFactory.onMenuItemSelected: " + e.toString());
}
}
return false;
diff --git a/main/src/cgeo/geocaching/apps/cachelist/InternalCacheListMap.java b/main/src/cgeo/geocaching/apps/cachelist/InternalCacheListMap.java
index 7eec0f8..75997e0 100644
--- a/main/src/cgeo/geocaching/apps/cachelist/InternalCacheListMap.java
+++ b/main/src/cgeo/geocaching/apps/cachelist/InternalCacheListMap.java
@@ -3,6 +3,7 @@ package cgeo.geocaching.apps.cachelist;
import cgeo.geocaching.R;
import cgeo.geocaching.cgCache;
import cgeo.geocaching.cgGeo;
+import cgeo.geocaching.Settings;
import cgeo.geocaching.apps.AbstractApp;
import android.app.Activity;
@@ -26,7 +27,7 @@ class InternalCacheListMap extends AbstractApp implements CacheListApp {
@Override
public boolean invoke(cgGeo geo, List<cgCache> caches, Activity activity, Resources res, final UUID searchId) {
- Intent mapIntent = new Intent(activity, getSettings(activity).getMapFactory()
+ Intent mapIntent = new Intent(activity, Settings.getMapFactory()
.getMapClass());
mapIntent.putExtra("detail", false); // this is the main difference to the activity for a single point
mapIntent.putExtra("searchid", searchId.toString());