From 99d6fd01a334b4057e7b56ce3ece09c3e6124bf9 Mon Sep 17 00:00:00 2001 From: Konsta Date: Sun, 4 Jan 2015 20:30:55 +0200 Subject: Settings: Fix hiding button backlight option Recent change added volume rocker to hardware key configuration so config_deviceHardwareKeys is non-zero on pretty much any device. Button backlight settings are displayed on devices that don't necessarily have any hardware keys with backlight. Change-Id: I0f87b4043177e5d1b05b7d2e2565cddd298e3227 --- .../settings/cyanogenmod/ButtonBacklightBrightness.java | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) (limited to 'src/com/android') diff --git a/src/com/android/settings/cyanogenmod/ButtonBacklightBrightness.java b/src/com/android/settings/cyanogenmod/ButtonBacklightBrightness.java index 9a9b7b4..c9cae1e 100644 --- a/src/com/android/settings/cyanogenmod/ButtonBacklightBrightness.java +++ b/src/com/android/settings/cyanogenmod/ButtonBacklightBrightness.java @@ -40,6 +40,7 @@ import android.widget.SeekBar; import android.widget.TextView; import com.android.settings.R; +import com.android.settings.ButtonSettings; import cyanogenmod.providers.CMSettings; public class ButtonBacklightBrightness extends DialogPreference implements @@ -224,12 +225,18 @@ public class ButtonBacklightBrightness extends DialogPreference implements public boolean isButtonSupported() { final Resources res = getContext().getResources(); - boolean hasAnyKey = res.getInteger( - com.android.internal.R.integer.config_deviceHardwareKeys) != 0; + final int deviceKeys = res.getInteger( + com.android.internal.R.integer.config_deviceHardwareKeys); + // All hardware keys besides volume and camera can possibly have a backlight + boolean hasBacklightKey = (deviceKeys & ButtonSettings.KEY_MASK_HOME) != 0 + || (deviceKeys & ButtonSettings.KEY_MASK_BACK) != 0 + || (deviceKeys & ButtonSettings.KEY_MASK_MENU) != 0 + || (deviceKeys & ButtonSettings.KEY_MASK_ASSIST) != 0 + || (deviceKeys & ButtonSettings.KEY_MASK_APP_SWITCH) != 0; boolean hasBacklight = res.getInteger( com.android.internal.R.integer.config_buttonBrightnessSettingDefault) > 0; - return hasAnyKey && hasBacklight; + return hasBacklightKey && hasBacklight; } public boolean isKeyboardSupported() { -- cgit v1.1