aboutsummaryrefslogtreecommitdiffstats
path: root/main/src/cgeo
diff options
context:
space:
mode:
Diffstat (limited to 'main/src/cgeo')
-rw-r--r--main/src/cgeo/geocaching/CgeoApplication.java22
-rw-r--r--main/src/cgeo/geocaching/settings/Settings.java4
-rw-r--r--main/src/cgeo/geocaching/settings/SettingsActivity.java11
3 files changed, 37 insertions, 0 deletions
diff --git a/main/src/cgeo/geocaching/CgeoApplication.java b/main/src/cgeo/geocaching/CgeoApplication.java
index d503969..1456b0e 100644
--- a/main/src/cgeo/geocaching/CgeoApplication.java
+++ b/main/src/cgeo/geocaching/CgeoApplication.java
@@ -3,6 +3,7 @@ package cgeo.geocaching;
import cgeo.geocaching.sensors.DirectionProvider;
import cgeo.geocaching.sensors.GeoDataProvider;
import cgeo.geocaching.sensors.IGeoData;
+import cgeo.geocaching.settings.Settings;
import cgeo.geocaching.utils.Log;
import rx.Observable;
@@ -10,6 +11,9 @@ import rx.functions.Action1;
import rx.observables.ConnectableObservable;
import android.app.Application;
+import android.view.ViewConfiguration;
+
+import java.lang.reflect.Field;
import java.io.IOException;
import java.lang.Thread.UncaughtExceptionHandler;
@@ -66,6 +70,24 @@ public class CgeoApplication extends Application {
}
@Override
+ public void onCreate() {
+ if (Settings.isAlwaysShowOverlfowMenu()) {
+ try {
+ ViewConfiguration config = ViewConfiguration.get(this);
+ Field menuKeyField = ViewConfiguration.class.getDeclaredField("sHasPermanentMenuKey");
+
+ if (menuKeyField != null) {
+ menuKeyField.setAccessible(true);
+ menuKeyField.setBoolean(config, false);
+ }
+ } catch (Exception ex) {
+ // Ignore
+ }
+ }
+ }
+
+
+ @Override
public void onLowMemory() {
Log.i("Cleaning applications cache.");
DataStore.removeAllFromCache();
diff --git a/main/src/cgeo/geocaching/settings/Settings.java b/main/src/cgeo/geocaching/settings/Settings.java
index 7a4dfdd..a527fc5 100644
--- a/main/src/cgeo/geocaching/settings/Settings.java
+++ b/main/src/cgeo/geocaching/settings/Settings.java
@@ -557,6 +557,10 @@ public class Settings {
return getBoolean(R.string.pref_units, getImperialUnitsDefault());
}
+ public static boolean isAlwaysShowOverlfowMenu() {
+ return getBoolean(R.string.pref_alwaysshowoverflowmenu, false);
+ }
+
static boolean getImperialUnitsDefault() {
final String countryCode = Locale.getDefault().getCountry();
return "US".equals(countryCode) // USA
diff --git a/main/src/cgeo/geocaching/settings/SettingsActivity.java b/main/src/cgeo/geocaching/settings/SettingsActivity.java
index 74a9b32..c7933bd 100644
--- a/main/src/cgeo/geocaching/settings/SettingsActivity.java
+++ b/main/src/cgeo/geocaching/settings/SettingsActivity.java
@@ -90,8 +90,19 @@ public class SettingsActivity extends PreferenceActivity {
SettingsActivity.addPreferencesFromResource(this, R.xml.preferences);
initPreferences();
+ /* Remove the show overflow preference on Android version where the platform always or never
+ * shows the overflow menu and the app cannot influence the behaviour
+ */
+ if (Build.VERSION.SDK_INT < Build.VERSION_CODES.HONEYCOMB || Build.VERSION.SDK_INT > Build.VERSION_CODES.JELLY_BEAN_MR2) {
+ Preference pref = findPreference(this, getString(R.string.pref_alwaysshowoverflowmenu));
+ PreferenceScreen appearence = (PreferenceScreen) findPreference(this, getString(R.string.pref_appearance));
+ appearence.removePreference(pref);
+
+ }
Intent intent = getIntent();
openInitialScreen(intent.getIntExtra(INTENT_OPEN_SCREEN, 0));
+
+
}
private void openInitialScreen(int initialScreen) {