OmniGears: fix remove of button lights config
We must also check config_button_brightness_support
and while we are here remove that obsolete dependency
of hw key disable to show navbar. with the qs tile you
can always disable hw buttons so why limit it here
Also, remove HW keys disable config for devices with only
volume rocker but no dedicated HW home button/nav keys.
Change-Id: I27209f1efd1d8358c7c88a7bdc64fe62b5a3ca99
diff --git a/res/xml/button_settings.xml b/res/xml/button_settings.xml
index 65af3d6..839ce99 100644
--- a/res/xml/button_settings.xml
+++ b/res/xml/button_settings.xml
@@ -63,8 +63,7 @@
android:key="hardware_keys_disable"
android:title="@string/hardware_keys_disable_title"
android:summary="@string/hardware_keys_disable_summary"
- android:persistent="false"
- android:dependency="navigation_bar_show"/>
+ android:persistent="false" />
<Preference
android:key="button_brightness"
android:title="@string/button_backlight_title"
diff --git a/src/org/omnirom/omnigears/ButtonSettings.java b/src/org/omnirom/omnigears/ButtonSettings.java
index 7cf8edb..5fa89c8 100644
--- a/src/org/omnirom/omnigears/ButtonSettings.java
+++ b/src/org/omnirom/omnigears/ButtonSettings.java
@@ -90,6 +90,8 @@
final PreferenceScreen prefScreen = getPreferenceScreen();
final int deviceKeys = getResources().getInteger(
com.android.internal.R.integer.config_deviceHardwareKeys);
+ final boolean buttonLights = getResources().getBoolean(
+ com.android.internal.R.bool.config_button_brightness_support);
final PreferenceCategory keysCategory =
(PreferenceCategory) prefScreen.findPreference(CATEGORY_KEYS);
final PreferenceCategory otherCategory =
@@ -99,14 +101,17 @@
mDisabkeHWKeys = (SwitchPreference) prefScreen.findPreference(KEYS_DISABLE_HW_KEY);
mButtonLight = prefScreen.findPreference(KEY_BUTTON_LIGHT);
- if (deviceKeys == 0) {
+ // No keys or no dedicated HW home/nav keys
+ if (deviceKeys == 0 || deviceKeys % 8 == 0) {
keysCategory.removePreference(mDisabkeHWKeys);
- keysCategory.removePreference(mButtonLight);
} else {
boolean hardwareKeysDisable = Settings.System.getInt(resolver,
Settings.System.HARDWARE_KEYS_DISABLE, 0) == 1;
mDisabkeHWKeys.setChecked(hardwareKeysDisable);
}
+ if (!buttonLights || deviceKeys == 0) {
+ keysCategory.removePreference(mButtonLight);
+ }
boolean showNavBarDefault = DeviceUtils.deviceSupportNavigationBar(getActivity());
boolean showNavBar = Settings.System.getInt(resolver,
@@ -174,12 +179,6 @@
boolean checked = ((SwitchPreference)preference).isChecked();
Settings.System.putInt(getContentResolver(),
Settings.System.NAVIGATION_BAR_SHOW, checked ? 1:0);
- // remove hw button disable if we disable navbar
- if (!checked) {
- Settings.System.putInt(getContentResolver(),
- Settings.System.HARDWARE_KEYS_DISABLE, 0);
- mDisabkeHWKeys.setChecked(false);
- }
return true;
} else if (preference == mDisabkeHWKeys) {
boolean checked = ((SwitchPreference)preference).isChecked();