diff --git a/res/values/cherish_strings.xml b/res/values/cherish_strings.xml
index 26be14a..31ace75 100644
--- a/res/values/cherish_strings.xml
+++ b/res/values/cherish_strings.xml
@@ -348,4 +348,8 @@
Button backlight touch
Button backlight will only appear when buttons are pressed rather than on all the time. Timeout still impacts this feature.
+
+ Hardware navigation buttons
+ Disable hardware buttons
+
diff --git a/res/xml/cherish_settings_button.xml b/res/xml/cherish_settings_button.xml
index 63ddfc2..bfb8a54 100644
--- a/res/xml/cherish_settings_button.xml
+++ b/res/xml/cherish_settings_button.xml
@@ -18,6 +18,13 @@
android:title="@string/button_title"
xmlns:settings="http://schemas.android.com/apk/res/com.android.settings">
+
+
+
+
+
diff --git a/src/com/cherish/settings/fragments/ButtonSettings.java b/src/com/cherish/settings/fragments/ButtonSettings.java
index b6cb20e..0dbbbec 100644
--- a/src/com/cherish/settings/fragments/ButtonSettings.java
+++ b/src/com/cherish/settings/fragments/ButtonSettings.java
@@ -59,7 +59,10 @@ import java.util.List;
@SearchIndexable(forTarget = SearchIndexable.ALL & ~SearchIndexable.ARC)
public class ButtonSettings extends ActionFragment implements OnPreferenceChangeListener {
+ private static final String HWKEY_DISABLE = "hardware_keys_disable";
+
// category keys
+ private static final String CATEGORY_HWKEY = "hardware_keys";
private static final String CATEGORY_BACK = "back_key";
private static final String CATEGORY_HOME = "home_key";
private static final String CATEGORY_MENU = "menu_key";
@@ -84,6 +87,7 @@ public class ButtonSettings extends ActionFragment implements OnPreferenceChange
private static final String TORCH_POWER_BUTTON_GESTURE = "torch_power_button_gesture";
+ private SwitchPreference mHwKeyDisable;
private ListPreference mTorchPowerButton;
private CustomSeekBarPreference mButtonTimoutBar;
private CustomSeekBarPreference mManualButtonBrightness;
@@ -97,6 +101,22 @@ public class ButtonSettings extends ActionFragment implements OnPreferenceChange
final Resources res = getResources();
final ContentResolver resolver = getActivity().getContentResolver();
final PreferenceScreen prefScreen = getPreferenceScreen();
+
+ final boolean needsNavbar = ActionUtils.hasNavbarByDefault(getActivity());
+ final PreferenceCategory hwkeyCat = (PreferenceCategory) prefScreen
+ .findPreference(CATEGORY_HWKEY);
+ int keysDisabled = 0;
+ if (!needsNavbar) {
+ mHwKeyDisable = (SwitchPreference) findPreference(HWKEY_DISABLE);
+ keysDisabled = Settings.System.getIntForUser(getContentResolver(),
+ Settings.System.HARDWARE_KEYS_DISABLE, 0,
+ UserHandle.USER_CURRENT);
+ mHwKeyDisable.setChecked(keysDisabled != 0);
+ mHwKeyDisable.setOnPreferenceChangeListener(this);
+ } else {
+ prefScreen.removePreference(hwkeyCat);
+ }
+
// bits for hardware keys present on device
final int deviceKeys = getResources().getInteger(
com.android.internal.R.integer.config_deviceHardwareKeys);
@@ -140,8 +160,11 @@ public class ButtonSettings extends ActionFragment implements OnPreferenceChange
}
// let super know we can load ActionPreferences
onPreferenceScreenLoaded(ActionConstants.getDefaults(ActionConstants.HWKEYS));
-
- // screen off torch
+
+ // load preferences first
+ setActionPreferencesEnabled(keysDisabled == 0);
+
+ // screen off torch
mTorchPowerButton = (ListPreference) findPreference(TORCH_POWER_BUTTON_GESTURE);
int mTorchPowerButtonValue = Settings.System.getInt(resolver,
Settings.System.TORCH_POWER_BUTTON_GESTURE, 0);
@@ -186,6 +209,11 @@ public class ButtonSettings extends ActionFragment implements OnPreferenceChange
Settings.System.putInt(resolver, Settings.System.TORCH_POWER_BUTTON_GESTURE,
mTorchPowerButtonValue);
return true;
+ } else if (preference == mHwKeyDisable) {
+ boolean value = (Boolean) newValue;
+ Settings.System.putInt(getContentResolver(), Settings.System.HARDWARE_KEYS_DISABLE,
+ value ? 1 : 0);
+ setActionPreferencesEnabled(!value);
} else if (preference == mButtonTimoutBar) {
int buttonTimeout = (Integer) newValue;
Settings.System.putInt(getContentResolver(),