diff options
| author | Bananeweizen <Bananeweizen@gmx.de> | 2013-07-29 10:40:35 +0200 |
|---|---|---|
| committer | Bananeweizen <Bananeweizen@gmx.de> | 2013-07-29 10:40:49 +0200 |
| commit | ce5b123bb226408271e7f00b290dc5f3d305638c (patch) | |
| tree | cc6fd8d41d9fc4cde8c5acc1ba2c2c5185b6e449 /main/src | |
| parent | 23a82e97f8cea5c1bc2c35c5f70af935d880bf35 (diff) | |
| download | cgeo-ce5b123bb226408271e7f00b290dc5f3d305638c.zip cgeo-ce5b123bb226408271e7f00b290dc5f3d305638c.tar.gz cgeo-ce5b123bb226408271e7f00b290dc5f3d305638c.tar.bz2 | |
fix #3040: new settings screen to disable navigation apps
Diffstat (limited to 'main/src')
4 files changed, 64 insertions, 39 deletions
diff --git a/main/src/cgeo/geocaching/apps/cache/navi/NavigationAppFactory.java b/main/src/cgeo/geocaching/apps/cache/navi/NavigationAppFactory.java index 4db889d..ec6b3e1 100644 --- a/main/src/cgeo/geocaching/apps/cache/navi/NavigationAppFactory.java +++ b/main/src/cgeo/geocaching/apps/cache/navi/NavigationAppFactory.java @@ -1,7 +1,6 @@ package cgeo.geocaching.apps.cache.navi; import cgeo.geocaching.Geocache; -import cgeo.geocaching.settings.Settings; import cgeo.geocaching.R; import cgeo.geocaching.Waypoint; import cgeo.geocaching.cgeoapplication; @@ -15,6 +14,7 @@ import cgeo.geocaching.apps.cache.navi.GoogleNavigationApp.GoogleNavigationBikeA import cgeo.geocaching.apps.cache.navi.GoogleNavigationApp.GoogleNavigationDrivingApp; import cgeo.geocaching.apps.cache.navi.GoogleNavigationApp.GoogleNavigationWalkingApp; import cgeo.geocaching.geopoint.Geopoint; +import cgeo.geocaching.settings.Settings; import android.app.Activity; import android.app.AlertDialog; @@ -30,51 +30,52 @@ public final class NavigationAppFactory extends AbstractAppFactory { public enum NavigationAppsEnum { /** The internal compass activity */ - COMPASS(new CompassApp(), 0), + COMPASS(new CompassApp(), 0, R.string.pref_navigation_menu_compass), /** The external radar app */ - RADAR(new RadarApp(), 1), + RADAR(new RadarApp(), 1, R.string.pref_navigation_menu_radar), /** The selected map */ - INTERNAL_MAP(new InternalMap(), 2), - /** The internal static map activity */ - STATIC_MAP(new StaticMapApp(), 3), - /** The external Locus app */ - DOWNLOAD_STATIC_MAPS(new DownloadStaticMapsApp(), 20), + INTERNAL_MAP(new InternalMap(), 2, R.string.pref_navigation_menu_internal_map), + /** The internal static map activity, when stored */ + STATIC_MAP(new StaticMapApp(), 3, R.string.pref_navigation_menu_static_map), + /** The internal static map activity, when not yet stored */ + DOWNLOAD_STATIC_MAPS(new DownloadStaticMapsApp(), 20, R.string.pref_navigation_menu_static_map_download), /** The external Locus app */ - LOCUS(new LocusApp(), 4), + LOCUS(new LocusApp(), 4, R.string.pref_navigation_menu_locus), /** The external RMaps app */ - RMAPS(new RMapsApp(), 5), + RMAPS(new RMapsApp(), 5, R.string.pref_navigation_menu_rmaps), /** Google Maps */ - GOOGLE_MAPS(new GoogleMapsApp(), 6), + GOOGLE_MAPS(new GoogleMapsApp(), 6, R.string.pref_navigation_menu_google_maps), /** Google Navigation */ - GOOGLE_NAVIGATION(new GoogleNavigationDrivingApp(), 7), + GOOGLE_NAVIGATION(new GoogleNavigationDrivingApp(), 7, R.string.pref_navigation_menu_google_navigation), /** Google Streetview */ - GOOGLE_STREETVIEW(new StreetviewApp(), 8), + GOOGLE_STREETVIEW(new StreetviewApp(), 8, R.string.pref_navigation_menu_google_streetview), /** The external OruxMaps app */ - ORUX_MAPS(new OruxMapsApp(), 9), + ORUX_MAPS(new OruxMapsApp(), 9, R.string.pref_navigation_menu_oruxmaps), /** The external navigon app */ - NAVIGON(new NavigonApp(), 10), + NAVIGON(new NavigonApp(), 10, R.string.pref_navigation_menu_navigon), /** The external Sygic app */ - SYGIC(new SygicNavigationApp(), 11), + SYGIC(new SygicNavigationApp(), 11, R.string.pref_navigation_menu_sygic), /** * Google Navigation in walking mode */ - GOOGLE_NAVIGATION_WALK(new GoogleNavigationWalkingApp(), 12), + GOOGLE_NAVIGATION_WALK(new GoogleNavigationWalkingApp(), 12, R.string.pref_navigation_menu_google_walk), /** * Google Navigation in walking mode */ - GOOGLE_NAVIGATION_BIKE(new GoogleNavigationBikeApp(), 21), + GOOGLE_NAVIGATION_BIKE(new GoogleNavigationBikeApp(), 21, R.string.pref_navigation_menu_google_bike), /** * Google Maps Directions */ - GOOGLE_MAPS_DIRECTIONS(new GoogleMapsDirectionApp(), 13), + GOOGLE_MAPS_DIRECTIONS(new GoogleMapsDirectionApp(), 13, R.string.pref_navigation_menu_google_maps_directions), - CACHE_BEACON(new CacheBeaconApp(), 14), - GCC(new GccApp(), 15), - WHERE_YOU_GO(new WhereYouGoApp(), 16); + CACHE_BEACON(new CacheBeaconApp(), 14, R.string.pref_navigation_menu_cache_beacon), + GCC(new GccApp(), 15, R.string.pref_navigation_menu_gcc), + WHERE_YOU_GO(new WhereYouGoApp(), 16, R.string.pref_navigation_menu_where_you_go); - NavigationAppsEnum(App app, int id) { + NavigationAppsEnum(final App app, final int id, final int preferenceKey) { this.app = app; this.id = id; + this.preferenceKey = preferenceKey; } /** @@ -86,6 +87,11 @@ public final class NavigationAppFactory extends AbstractAppFactory { */ public final int id; + /** + * key of the related preference in the navigation menu preference screen, used for disabling the preference UI + */ + public final int preferenceKey; + /* * display app name in array adapter * @@ -142,18 +148,20 @@ public final class NavigationAppFactory extends AbstractAppFactory { for (final NavigationAppsEnum navApp : getInstalledNavigationApps()) { if ((showInternalMap || !(navApp.app instanceof InternalMap)) && (showDefaultNavigation || defaultNavigationTool != navApp.id)) { - boolean add = false; - if (cache != null && navApp.app instanceof CacheNavigationApp && navApp.app.isEnabled(cache)) { - add = true; - } - if (waypoint != null && navApp.app instanceof WaypointNavigationApp && ((WaypointNavigationApp) navApp.app).isEnabled(waypoint)) { - add = true; - } - if (destination != null && navApp.app instanceof GeopointNavigationApp) { - add = true; - } - if (add) { - items.add(navApp); + if (Settings.isUseNavigationApp(navApp)) { + boolean add = false; + if (cache != null && navApp.app instanceof CacheNavigationApp && navApp.app.isEnabled(cache)) { + add = true; + } + if (waypoint != null && navApp.app instanceof WaypointNavigationApp && ((WaypointNavigationApp) navApp.app).isEnabled(waypoint)) { + add = true; + } + if (destination != null && navApp.app instanceof GeopointNavigationApp) { + add = true; + } + if (add) { + items.add(navApp); + } } } } @@ -233,7 +241,7 @@ public final class NavigationAppFactory extends AbstractAppFactory { for (final NavigationAppsEnum navApp : getInstalledNavigationApps()) { if (navApp.app instanceof CacheNavigationApp) { final CacheNavigationApp cacheApp = (CacheNavigationApp) navApp.app; - if (cacheApp.isEnabled(cache)) { + if (cacheApp.isEnabled(cache) && Settings.isUseNavigationApp(navApp)) { menu.add(0, MENU_ITEM_OFFSET + navApp.id, 0, navApp.app.getName()); } } @@ -244,7 +252,7 @@ public final class NavigationAppFactory extends AbstractAppFactory { for (final NavigationAppsEnum navApp : getInstalledNavigationApps()) { if (navApp.app instanceof WaypointNavigationApp) { final WaypointNavigationApp waypointApp = (WaypointNavigationApp) navApp.app; - if (waypointApp.isEnabled(waypoint)) { + if (waypointApp.isEnabled(waypoint) && Settings.isUseNavigationApp(navApp)) { menu.add(0, MENU_ITEM_OFFSET + navApp.id, 0, navApp.app.getName()); } } diff --git a/main/src/cgeo/geocaching/apps/cache/navi/NavigonApp.java b/main/src/cgeo/geocaching/apps/cache/navi/NavigonApp.java index 7ea86fb..7966733 100644 --- a/main/src/cgeo/geocaching/apps/cache/navi/NavigonApp.java +++ b/main/src/cgeo/geocaching/apps/cache/navi/NavigonApp.java @@ -1,5 +1,6 @@ package cgeo.geocaching.apps.cache.navi; +import cgeo.geocaching.R; import cgeo.geocaching.geopoint.Geopoint; import android.app.Activity; @@ -12,7 +13,7 @@ class NavigonApp extends AbstractPointNavigationApp { private static final String INTENT_EXTRA_KEY_LONGITUDE = "longitude"; NavigonApp() { - super("Navigon", INTENT); + super(getString(R.string.cache_menu_navigon), INTENT); } @Override diff --git a/main/src/cgeo/geocaching/settings/Settings.java b/main/src/cgeo/geocaching/settings/Settings.java index a4eeeec..caa2e07 100644 --- a/main/src/cgeo/geocaching/settings/Settings.java +++ b/main/src/cgeo/geocaching/settings/Settings.java @@ -267,7 +267,7 @@ public final class Settings { /** * Get login and password information. - * + * * @return a pair either with (login, password) or (empty, empty) if no valid information is stored */ public static ImmutablePair<String, String> getGcLogin() { @@ -992,4 +992,8 @@ public final class Settings { putLong(R.string.pref_fieldnoteExportDate, date); } + public static boolean isUseNavigationApp(NavigationAppsEnum navApp) { + return getBoolean(navApp.preferenceKey, true); + } + } diff --git a/main/src/cgeo/geocaching/settings/SettingsActivity.java b/main/src/cgeo/geocaching/settings/SettingsActivity.java index aa0848a..7ec15dd 100644 --- a/main/src/cgeo/geocaching/settings/SettingsActivity.java +++ b/main/src/cgeo/geocaching/settings/SettingsActivity.java @@ -125,6 +125,7 @@ public class SettingsActivity extends PreferenceActivity { initBasicMemberPreferences(); initSend2CgeoPreferences(); initServicePreferences(); + initNavigationMenuPreferences(); for (int k : new int[] { R.string.pref_username, R.string.pref_password, R.string.pref_pass_vote, R.string.pref_signature, @@ -137,6 +138,17 @@ public class SettingsActivity extends PreferenceActivity { } } + private void initNavigationMenuPreferences() { + for (NavigationAppsEnum appEnum : NavigationAppsEnum.values()) { + if (appEnum.app.isInstalled()) { + getPreference(appEnum.preferenceKey).setEnabled(true); + } + } + getPreference(R.string.pref_fakekey_basicmembers_screen) + .setEnabled(!Settings.isPremiumMember()); + redrawScreen(R.string.pref_fakekey_navigation_menu_screen); + } + private void initServicePreferences() { getPreference(R.string.pref_connectorOCActive).setOnPreferenceChangeListener(VALUE_CHANGE_LISTENER); getPreference(R.string.pref_connectorGCActive).setOnPreferenceChangeListener(VALUE_CHANGE_LISTENER); |
