From 31a0a340b3280704a064d744c16472790cc76ecb Mon Sep 17 00:00:00 2001 From: Jaewan Kim Date: Thu, 11 Apr 2013 13:18:03 +0900 Subject: [PATCH] Single volume control when config_useMasterVolume is true If config_useMasterVolume is true, all streams are considered as the STREAM_MASTER. Hide all volume sections except a stream because they are actually the same in this case. Bug: 8505295 Change-Id: I9822feaad2d43468ceb4c7fdb97da4b677995992 --- res/layout/preference_dialog_ringervolume.xml | 91 +++++++++++-------- .../settings/RingerVolumePreference.java | 39 ++++++-- 2 files changed, 86 insertions(+), 44 deletions(-) diff --git a/res/layout/preference_dialog_ringervolume.xml b/res/layout/preference_dialog_ringervolume.xml index 1643cabe082..2af1ba9f99e 100644 --- a/res/layout/preference_dialog_ringervolume.xml +++ b/res/layout/preference_dialog_ringervolume.xml @@ -51,26 +51,34 @@ + android:orientation="vertical"> - + android:paddingStart="8dip" + android:orientation="horizontal" + android:gravity="center_vertical"> + + + + + - @@ -159,36 +167,45 @@ - - + android:orientation="vertical"> - - + + + + android:paddingStart="8dip" + android:orientation="horizontal" + android:gravity="center_vertical"> + + + + + diff --git a/src/com/android/settings/RingerVolumePreference.java b/src/com/android/settings/RingerVolumePreference.java index 56393e0fc98..dd81ded0489 100644 --- a/src/com/android/settings/RingerVolumePreference.java +++ b/src/com/android/settings/RingerVolumePreference.java @@ -80,6 +80,13 @@ public class RingerVolumePreference extends VolumePreference { R.id.alarm_mute_button }; + private static final int[] SEEKBAR_SECTION_ID = new int[] { + R.id.media_section, + R.id.ringer_section, + R.id.notification_section, + R.id.alarm_section + }; + private static final int[] SEEKBAR_MUTED_RES_ID = new int[] { com.android.internal.R.drawable.ic_audio_vol_mute, com.android.internal.R.drawable.ic_audio_ring_notif_mute, @@ -198,15 +205,33 @@ public class RingerVolumePreference extends VolumePreference { getContext().registerReceiver(mRingModeChangedReceiver, filter); } - // Disable either ringer+notifications or notifications - int id; - if (!Utils.isVoiceCapable(getContext())) { - id = R.id.ringer_section; + boolean useMasterVolume = getContext().getResources(). + getBoolean(com.android.internal.R.bool.config_useMasterVolume); + if (useMasterVolume) { + // If config_useMasterVolume is true, all streams are treated as STREAM_MASTER. + // So hide all except a stream. + int id; + if (Utils.isVoiceCapable(getContext())) { + id = R.id.ringer_section; + } else { + id = R.id.media_section; + } + for (int i = 0; i < SEEKBAR_SECTION_ID.length; i++) { + if (SEEKBAR_SECTION_ID[i] != id) { + view.findViewById(SEEKBAR_SECTION_ID[i]).setVisibility(View.GONE); + } + } } else { - id = R.id.notification_section; + // Disable either ringer+notifications or notifications + int id; + if (!Utils.isVoiceCapable(getContext())) { + id = R.id.ringer_section; + } else { + id = R.id.notification_section; + } + View hideSection = view.findViewById(id); + hideSection.setVisibility(View.GONE); } - View hideSection = view.findViewById(id); - hideSection.setVisibility(View.GONE); } private Uri getMediaVolumeUri(Context context) {