OSDN Git Service

Profiles: Disable notification item if ringtone & notification volumes are linked
authorLuis Vidal <lvidal@cyngn.com>
Wed, 11 May 2016 23:58:54 +0000 (16:58 -0700)
committerGerrit Code Review <gerrit@cyanogenmod.org>
Fri, 13 May 2016 20:49:54 +0000 (13:49 -0700)
The notification item will be disabled if the notification and
ringtone volumes are linked. This is to keep consistency with the
sound settings

Change-Id: Ibbe7612eae5e9b7b18d63450ab8331f02becf5ca
TICKET: CYNGNOS-958

src/com/android/settings/profiles/actions/item/VolumeStreamItem.java

index 9bcf2ef..f4d76c7 100644 (file)
@@ -17,6 +17,7 @@ package com.android.settings.profiles.actions.item;
 
 import android.content.Context;
 import android.media.AudioManager;
+import android.provider.Settings;
 import android.view.LayoutInflater;
 import android.view.View;
 import android.view.ViewGroup;
@@ -30,6 +31,7 @@ import com.android.settings.profiles.actions.ItemListAdapter;
 public class VolumeStreamItem implements Item {
     private int mStreamId;
     private StreamSettings mStreamSettings;
+    private boolean mEnabled;
 
     public VolumeStreamItem(int streamId, StreamSettings streamSettings) {
         mStreamId = streamId;
@@ -43,7 +45,7 @@ public class VolumeStreamItem implements Item {
 
     @Override
     public boolean isEnabled() {
-        return true;
+        return mEnabled;
     }
 
     @Override
@@ -72,6 +74,15 @@ public class VolumeStreamItem implements Item {
             desc.setText(context.getString(R.string.profile_action_none));
         }
 
+        final boolean volumeLinkNotification = Settings.Secure.getInt(context
+                .getContentResolver(), Settings.Secure.VOLUME_LINK_NOTIFICATION, 1) == 1;
+        mEnabled = true;
+        if (mStreamId == AudioManager.STREAM_NOTIFICATION && volumeLinkNotification) {
+            mEnabled = false;
+            text.setEnabled(false);
+            desc.setEnabled(false);
+        }
+
         return view;
     }