OSDN Git Service

Settings: set volume wake dependency in code
authorRoman Birg <roman@cyngn.com>
Tue, 24 Feb 2015 22:53:32 +0000 (14:53 -0800)
committerAdnan Begovic <adnan@cyngn.com>
Fri, 30 Oct 2015 00:36:28 +0000 (17:36 -0700)
It is possible for volume_wake_screen to be removed from the preference
list, but volbtn_music_controls has a hard dependency on
volume_wake_screen. Let's setup this depenency only if both exist.

Signed-off-by: Roman Birg <roman@cyngn.com>
Change-Id: I18b2ecc0de36779ebdea3a0d20c1971ce85549cb

src/com/android/settings/ButtonSettings.java

index ee81bcd..d682dc3 100644 (file)
@@ -70,7 +70,11 @@ public class ButtonSettings extends SettingsPreferenceFragment implements
     private static final String KEY_NAVIGATION_RECENTS_LONG_PRESS = "navigation_recents_long_press";
     private static final String KEY_POWER_END_CALL = "power_end_call";
     private static final String KEY_HOME_ANSWER_CALL = "home_answer_call";
+<<<<<<< HEAD
     private static final String KEY_BLUETOOTH_INPUT_SETTINGS = "bluetooth_input_settings";
+=======
+    private static final String KEY_VOLUME_MUSIC_CONTROLS = "volbtn_music_controls";
+>>>>>>> e9fe965... Settings: set volume wake dependency in code
 
     private static final String CATEGORY_POWER = "power_key";
     private static final String CATEGORY_HOME = "home_key";
@@ -115,6 +119,8 @@ public class ButtonSettings extends SettingsPreferenceFragment implements
     private ListPreference mAppSwitchPressAction;
     private ListPreference mAppSwitchLongPressAction;
     private ListPreference mVolumeKeyCursorControl;
+    private SwitchPreference mVolumeWakeScreen;
+    private SwitchPreference mVolumeMusicControls;
     private SwitchPreference mSwapVolumeButtons;
     private SwitchPreference mDisableNavigationKeys;
     private SwitchPreference mNavigationBarLeftPref;
@@ -376,6 +382,16 @@ public class ButtonSettings extends SettingsPreferenceFragment implements
 
         Utils.updatePreferenceToSpecificActivityFromMetaDataOrRemove(getActivity(),
                 getPreferenceScreen(), KEY_BLUETOOTH_INPUT_SETTINGS);
+
+        mVolumeWakeScreen = (SwitchPreference) findPreference(Settings.System.VOLUME_WAKE_SCREEN);
+        mVolumeMusicControls = (SwitchPreference) findPreference(KEY_VOLUME_MUSIC_CONTROLS);
+
+        if (mVolumeWakeScreen != null) {
+            if (mVolumeMusicControls != null) {
+                mVolumeMusicControls.setDependency(Settings.System.VOLUME_WAKE_SCREEN);
+                mVolumeWakeScreen.setDisableDependentsState(true);
+            }
+        }
     }
 
     @Override