Merge "Single volume control when config_useMasterVolume is true"

This commit is contained in:
Eric Laurent
2013-05-20 19:13:45 +00:00
committed by Android (Google) Code Review
2 changed files with 86 additions and 44 deletions

View File

@@ -50,6 +50,12 @@
/>
<!-- Used for the media volume -->
<LinearLayout
android:id="@+id/media_section"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
@@ -73,6 +79,8 @@
android:layout_marginEnd="@dimen/volume_seekbar_side_margin" />
</LinearLayout>
</LinearLayout>
<!-- Used for the ringer/notification volume -->
<LinearLayout
android:id="@+id/ringer_section"
@@ -159,6 +167,13 @@
</LinearLayout>
<!-- Used for the alarm volume -->
<LinearLayout
android:id="@+id/alarm_section"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<TextView
android:textAppearance="?android:attr/textAppearanceSmall"
android:layout_width="wrap_content"
@@ -193,4 +208,6 @@
</LinearLayout>
</LinearLayout>
</ScrollView>

View File

@@ -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,6 +205,23 @@ public class RingerVolumePreference extends VolumePreference {
getContext().registerReceiver(mRingModeChangedReceiver, filter);
}
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 {
// Disable either ringer+notifications or notifications
int id;
if (!Utils.isVoiceCapable(getContext())) {
@@ -208,6 +232,7 @@ public class RingerVolumePreference extends VolumePreference {
View hideSection = view.findViewById(id);
hideSection.setVisibility(View.GONE);
}
}
private Uri getMediaVolumeUri(Context context) {
return Uri.parse(ContentResolver.SCHEME_ANDROID_RESOURCE + "://"