Merge "Single volume control when config_useMasterVolume is true"
This commit is contained in:
@@ -51,26 +51,34 @@
|
|||||||
|
|
||||||
<!-- Used for the media volume -->
|
<!-- Used for the media volume -->
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
|
android:id="@+id/media_section"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:paddingStart="8dip"
|
android:orientation="vertical">
|
||||||
android:orientation="horizontal"
|
|
||||||
android:gravity="center_vertical">
|
|
||||||
|
|
||||||
<ImageView android:id="@+id/media_mute_button"
|
<LinearLayout
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:padding="16dip"
|
android:paddingStart="8dip"
|
||||||
android:background="?android:attr/selectableItemBackground"
|
android:orientation="horizontal"
|
||||||
android:contentDescription="@string/volume_media_mute"
|
android:gravity="center_vertical">
|
||||||
/>
|
|
||||||
|
<ImageView android:id="@+id/media_mute_button"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:padding="16dip"
|
||||||
|
android:background="?android:attr/selectableItemBackground"
|
||||||
|
android:contentDescription="@string/volume_media_mute"
|
||||||
|
/>
|
||||||
|
|
||||||
|
<SeekBar android:id="@+id/media_volume_seekbar"
|
||||||
|
android:layout_width="0dip"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_weight="1"
|
||||||
|
android:paddingTop="2dip"
|
||||||
|
android:layout_marginEnd="@dimen/volume_seekbar_side_margin" />
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
<SeekBar android:id="@+id/media_volume_seekbar"
|
|
||||||
android:layout_width="0dip"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_weight="1"
|
|
||||||
android:paddingTop="2dip"
|
|
||||||
android:layout_marginEnd="@dimen/volume_seekbar_side_margin" />
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
<!-- Used for the ringer/notification volume -->
|
<!-- Used for the ringer/notification volume -->
|
||||||
@@ -159,36 +167,45 @@
|
|||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
<TextView
|
|
||||||
android:textAppearance="?android:attr/textAppearanceSmall"
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_marginTop="16dip"
|
|
||||||
android:paddingStart="16dip"
|
|
||||||
android:layout_gravity="start"
|
|
||||||
android:text="@string/volume_alarm_description"
|
|
||||||
/>
|
|
||||||
|
|
||||||
<!-- Used for the alarm volume -->
|
<!-- Used for the alarm volume -->
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
|
android:id="@+id/alarm_section"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:paddingStart="8dip"
|
android:orientation="vertical">
|
||||||
android:orientation="horizontal"
|
|
||||||
android:gravity="center_vertical">
|
|
||||||
|
|
||||||
<ImageView android:id="@+id/alarm_mute_button"
|
<TextView
|
||||||
|
android:textAppearance="?android:attr/textAppearanceSmall"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:padding="16dip"
|
android:layout_marginTop="16dip"
|
||||||
android:background="?android:attr/selectableItemBackground"
|
android:paddingStart="16dip"
|
||||||
android:contentDescription="@string/volume_alarm_mute" />
|
android:layout_gravity="start"
|
||||||
<SeekBar android:id="@+id/alarm_volume_seekbar"
|
android:text="@string/volume_alarm_description"
|
||||||
android:layout_width="0dip"
|
/>
|
||||||
|
|
||||||
|
<!-- Used for the alarm volume -->
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_weight="1"
|
android:paddingStart="8dip"
|
||||||
android:paddingTop="2dip"
|
android:orientation="horizontal"
|
||||||
android:layout_marginEnd="@dimen/volume_seekbar_side_margin" />
|
android:gravity="center_vertical">
|
||||||
|
|
||||||
|
<ImageView android:id="@+id/alarm_mute_button"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:padding="16dip"
|
||||||
|
android:background="?android:attr/selectableItemBackground"
|
||||||
|
android:contentDescription="@string/volume_alarm_mute" />
|
||||||
|
<SeekBar android:id="@+id/alarm_volume_seekbar"
|
||||||
|
android:layout_width="0dip"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_weight="1"
|
||||||
|
android:paddingTop="2dip"
|
||||||
|
android:layout_marginEnd="@dimen/volume_seekbar_side_margin" />
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
@@ -80,6 +80,13 @@ public class RingerVolumePreference extends VolumePreference {
|
|||||||
R.id.alarm_mute_button
|
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[] {
|
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_vol_mute,
|
||||||
com.android.internal.R.drawable.ic_audio_ring_notif_mute,
|
com.android.internal.R.drawable.ic_audio_ring_notif_mute,
|
||||||
@@ -198,15 +205,33 @@ public class RingerVolumePreference extends VolumePreference {
|
|||||||
getContext().registerReceiver(mRingModeChangedReceiver, filter);
|
getContext().registerReceiver(mRingModeChangedReceiver, filter);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Disable either ringer+notifications or notifications
|
boolean useMasterVolume = getContext().getResources().
|
||||||
int id;
|
getBoolean(com.android.internal.R.bool.config_useMasterVolume);
|
||||||
if (!Utils.isVoiceCapable(getContext())) {
|
if (useMasterVolume) {
|
||||||
id = R.id.ringer_section;
|
// 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 {
|
} 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) {
|
private Uri getMediaVolumeUri(Context context) {
|
||||||
|
Reference in New Issue
Block a user