OSDN Git Service

Remove duplicate charging sounds option
authorMichael Bestas <mikeioannina@cyanogenmod.org>
Wed, 10 Feb 2016 00:36:16 +0000 (02:36 +0200)
committerGerrit Code Review <gerrit@cyanogenmod.org>
Fri, 12 Feb 2016 21:30:42 +0000 (13:30 -0800)
* CM setting allows charging sounds on any power source, while AOSP
  allows charging sounds only on wireless charging
* The AOSP toggle has been broken since
  fw/base 42f4f2f2ff4278ca8411504617f55a712562c242
* Use the AOSP setting while keeping the improved CM code

Change-Id: Ia747d8949cf7ce94ad2a638f27aaa3c57f9aed19

res/xml/other_sound_settings.xml
src/com/android/settings/notification/OtherSoundSettings.java

index 3ba3dfb..ccedbb3 100644 (file)
             android:title="@string/screen_locking_sounds_title"
             android:persistent="false" />
 
-    <!-- Charging sounds -->
-    <SwitchPreference
-            android:key="charging_sounds"
-            android:title="@string/charging_sounds_title"
-            android:persistent="false" />
-
     <!-- Docking sounds -->
     <SwitchPreference
             android:key="docking_sounds"
             android:title="@string/emergency_tone_title"
             android:persistent="false" />
 
+    <!-- Charging sounds -->
     <PreferenceCategory
             android:title="@string/power_notifications_category_title">
 
-    <SwitchPreference
-            android:key="power_notifications"
-            android:title="@string/power_notifications_enable_title"
-            android:summary="@string/power_notifications_enable_summary"
-            android:defaultValue="false"
-            android:persistent="false" />
-
-    <SwitchPreference
-            android:key="power_notifications_vibrate"
-            android:title="@string/power_notifications_vibrate_title"
-            android:defaultValue="false"
-            android:dependency="power_notifications"
-            android:persistent="false" />
-
-    <Preference
-            android:key="power_notifications_ringtone"
-            android:title="@string/power_notifications_ringtone_title"
-            android:dependency="power_notifications"
-            android:persistent="false" />
+        <SwitchPreference
+                android:key="charging_sounds"
+                android:title="@string/power_notifications_enable_title"
+                android:summary="@string/power_notifications_enable_summary"
+                android:defaultValue="false"
+                android:persistent="false" />
+
+        <SwitchPreference
+                android:key="power_notifications_vibrate"
+                android:title="@string/power_notifications_vibrate_title"
+                android:defaultValue="false"
+                android:dependency="charging_sounds"
+                android:persistent="false" />
+
+        <Preference
+                android:key="power_notifications_ringtone"
+                android:title="@string/power_notifications_ringtone_title"
+                android:dependency="charging_sounds"
+                android:persistent="false" />
 
     </PreferenceCategory>
 </PreferenceScreen>
index 55d2309..935aea5 100644 (file)
@@ -56,6 +56,7 @@ import java.util.List;
 public class OtherSoundSettings extends SettingsPreferenceFragment implements Indexable {
     private static final String TAG = "OtherSoundSettings";
 
+    private static final int DEFAULT_OFF = 0;
     private static final int DEFAULT_ON = 1;
 
     private static final int EMERGENCY_TONE_SILENT = 0;
@@ -76,7 +77,6 @@ public class OtherSoundSettings extends SettingsPreferenceFragment implements In
     private static final String KEY_DOCK_AUDIO_MEDIA = "dock_audio_media";
     private static final String KEY_EMERGENCY_TONE = "emergency_tone";
 
-    private static final String KEY_POWER_NOTIFICATIONS = "power_notifications";
     private static final String KEY_POWER_NOTIFICATIONS_VIBRATE = "power_notifications_vibrate";
     private static final String KEY_POWER_NOTIFICATIONS_RINGTONE = "power_notifications_ringtone";
 
@@ -86,7 +86,6 @@ public class OtherSoundSettings extends SettingsPreferenceFragment implements In
     // Used for power notification uri string if set to silent
     private static final String POWER_NOTIFICATIONS_SILENT_URI = "silent";
 
-    private SwitchPreference mPowerSounds;
     private SwitchPreference mPowerSoundsVibrate;
     private Preference mPowerSoundsRingtone;
 
@@ -102,7 +101,7 @@ public class OtherSoundSettings extends SettingsPreferenceFragment implements In
             TYPE_SYSTEM, KEY_SCREEN_LOCKING_SOUNDS, System.LOCKSCREEN_SOUNDS_ENABLED, DEFAULT_ON);
 
     private static final SettingPref PREF_CHARGING_SOUNDS = new SettingPref(
-            TYPE_GLOBAL, KEY_CHARGING_SOUNDS, Global.CHARGING_SOUNDS_ENABLED, DEFAULT_ON);
+            TYPE_GLOBAL, KEY_CHARGING_SOUNDS, Global.CHARGING_SOUNDS_ENABLED, DEFAULT_OFF);
 
     private static final SettingPref PREF_DOCKING_SOUNDS = new SettingPref(
             TYPE_GLOBAL, KEY_DOCKING_SOUNDS, Global.DOCK_SOUNDS_ENABLED, DEFAULT_ON) {
@@ -214,9 +213,6 @@ public class OtherSoundSettings extends SettingsPreferenceFragment implements In
         mContext = getActivity();
 
         // power state change notification sounds
-        mPowerSounds = (SwitchPreference) findPreference(KEY_POWER_NOTIFICATIONS);
-        mPowerSounds.setChecked(CMSettings.Global.getInt(getContentResolver(),
-                CMSettings.Global.POWER_NOTIFICATIONS_ENABLED, 0) != 0);
         mPowerSoundsVibrate = (SwitchPreference) findPreference(KEY_POWER_NOTIFICATIONS_VIBRATE);
         mPowerSoundsVibrate.setChecked(CMSettings.Global.getInt(getContentResolver(),
                 CMSettings.Global.POWER_NOTIFICATIONS_VIBRATE, 0) != 0);
@@ -266,12 +262,7 @@ public class OtherSoundSettings extends SettingsPreferenceFragment implements In
 
     @Override
     public boolean onPreferenceTreeClick(PreferenceScreen preferenceScreen, Preference preference) {
-        if (preference == mPowerSounds) {
-            CMSettings.Global.putInt(getContentResolver(),
-                    CMSettings.Global.POWER_NOTIFICATIONS_ENABLED,
-                    mPowerSounds.isChecked() ? 1 : 0);
-
-        } else if (preference == mPowerSoundsVibrate) {
+        if (preference == mPowerSoundsVibrate) {
             CMSettings.Global.putInt(getContentResolver(),
                     CMSettings.Global.POWER_NOTIFICATIONS_VIBRATE,
                     mPowerSoundsVibrate.isChecked() ? 1 : 0);