Added DND icon on muted streams on volume dialog
Now users cannot toggle off dnd from the volume dialog since the ringer (volume footer) will be disabled if it's muted by dnd Test: manual Change-Id: I7d4dd552e0f791ee52135272d8d0837899abe152 Fixes: 72711020
This commit is contained in:
21
packages/SystemUI/res/color/accent_tint_color_selector.xml
Normal file
21
packages/SystemUI/res/color/accent_tint_color_selector.xml
Normal file
@@ -0,0 +1,21 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- Copyright (C) 2018 The Android Open Source Project
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
-->
|
||||
<selector xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<item android:state_enabled="false"
|
||||
android:color="?android:attr/colorButtonNormal"/>
|
||||
|
||||
<item android:color="?android:attr/colorAccent"/>
|
||||
</selector>
|
||||
@@ -38,59 +38,64 @@
|
||||
android:layout_height="wrap_content"
|
||||
android:clipChildren="false"
|
||||
android:clipToPadding="false"
|
||||
android:paddingTop="10dp"
|
||||
android:paddingBottom="10dp"
|
||||
android:background="@drawable/rounded_bg_full"
|
||||
android:translationZ="@dimen/volume_panel_elevation"
|
||||
android:orientation="horizontal" >
|
||||
<!-- volume rows added and removed here! :-) -->
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
<FrameLayout
|
||||
android:id="@+id/footer"
|
||||
android:layout_width="@dimen/volume_dialog_panel_width"
|
||||
android:layout_height="@dimen/volume_dialog_panel_width"
|
||||
android:clipChildren="false"
|
||||
android:clipToPadding="false"
|
||||
android:layout_marginTop="6dp"
|
||||
android:layout_marginBottom="6dp"
|
||||
android:layout_below="@id/volume_dialog_rows"
|
||||
android:background="@drawable/rounded_bg_full"
|
||||
android:gravity="center"
|
||||
android:layout_gravity="end"
|
||||
android:translationZ="@dimen/volume_panel_elevation"
|
||||
android:clickable="true"
|
||||
android:orientation="vertical" >
|
||||
android:background="@drawable/rounded_bg_full">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/ringer_title"
|
||||
android:text="@string/ring_toggle_title"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:ellipsize="end"
|
||||
android:maxLines="1"
|
||||
android:layout_centerVertical="true"
|
||||
android:textColor="?android:attr/colorControlNormal"
|
||||
android:textAppearance="@style/TextAppearance.Volume.Header" />
|
||||
<LinearLayout
|
||||
android:id="@+id/footer_linear_layout"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:clipChildren="false"
|
||||
android:clipToPadding="false"
|
||||
android:gravity="center"
|
||||
android:layout_gravity="end"
|
||||
android:translationZ="@dimen/volume_panel_elevation"
|
||||
android:clickable="true"
|
||||
android:orientation="vertical" >
|
||||
|
||||
<com.android.keyguard.AlphaOptimizedImageButton
|
||||
android:id="@+id/ringer_icon"
|
||||
style="@style/VolumeButtons"
|
||||
android:background="?android:selectableItemBackgroundBorderless"
|
||||
android:layout_width="@dimen/volume_dialog_panel_width"
|
||||
android:layout_height="@dimen/volume_button_size"
|
||||
android:tint="?android:attr/colorAccent"
|
||||
android:soundEffectsEnabled="false" />
|
||||
<TextView
|
||||
android:id="@+id/ringer_title"
|
||||
android:text="@string/ring_toggle_title"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:ellipsize="end"
|
||||
android:maxLines="1"
|
||||
android:layout_centerVertical="true"
|
||||
android:textColor="?android:attr/colorControlNormal"
|
||||
android:textAppearance="@style/TextAppearance.Volume.Header" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/ringer_status"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:ellipsize="end"
|
||||
android:maxLines="1"
|
||||
android:textColor="?android:attr/colorControlNormal"
|
||||
android:textAppearance="@style/TextAppearance.Volume.Header.Secondary" />
|
||||
<com.android.keyguard.AlphaOptimizedImageButton
|
||||
android:id="@+id/ringer_icon"
|
||||
style="@style/VolumeButtons"
|
||||
android:background="?android:selectableItemBackgroundBorderless"
|
||||
android:layout_width="@dimen/volume_dialog_panel_width"
|
||||
android:layout_height="@dimen/volume_button_size"
|
||||
android:tint="@color/accent_tint_color_selector"
|
||||
android:soundEffectsEnabled="false" />
|
||||
|
||||
</LinearLayout>
|
||||
<TextView
|
||||
android:id="@+id/ringer_status"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:ellipsize="end"
|
||||
android:maxLines="1"
|
||||
android:textColor="?android:attr/colorControlNormal"
|
||||
android:textAppearance="@style/TextAppearance.Volume.Header.Secondary" />
|
||||
</LinearLayout>
|
||||
|
||||
<include layout="@layout/volume_dnd_icon"/>
|
||||
</FrameLayout>
|
||||
</LinearLayout>
|
||||
</com.android.systemui.volume.VolumeUiLayout>
|
||||
@@ -13,89 +13,98 @@
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
-->
|
||||
<LinearLayout
|
||||
<FrameLayout
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:tag="row"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_width="@dimen/volume_dialog_panel_width"
|
||||
android:clipChildren="true"
|
||||
android:clipToPadding="true"
|
||||
android:theme="@style/qs_theme"
|
||||
android:gravity="center"
|
||||
android:orientation="vertical" >
|
||||
android:theme="@style/qs_theme">
|
||||
|
||||
<LinearLayout
|
||||
android:orientation="vertical"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_marginTop="10dp"
|
||||
android:layout_marginBottom="10dp"
|
||||
android:gravity="center"
|
||||
android:padding="5dp">
|
||||
<TextView
|
||||
android:id="@+id/volume_row_header"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:ellipsize="end"
|
||||
android:maxLength="10"
|
||||
android:maxLines="1"
|
||||
android:textColor="?android:attr/colorControlNormal"
|
||||
android:textAppearance="@style/TextAppearance.Volume.Header" />
|
||||
android:orientation="vertical" >
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/output_chooser"
|
||||
android:orientation="vertical"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:minWidth="48dp"
|
||||
android:minHeight="48dp"
|
||||
android:paddingTop="10dp"
|
||||
android:background="?android:selectableItemBackgroundBorderless"
|
||||
android:gravity="center">
|
||||
android:gravity="center"
|
||||
android:padding="5dp">
|
||||
<TextView
|
||||
android:id="@+id/volume_row_connected_device"
|
||||
android:visibility="gone"
|
||||
android:id="@+id/volume_row_header"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:maxLength="10"
|
||||
android:ellipsize="end"
|
||||
android:maxLength="10"
|
||||
android:maxLines="1"
|
||||
android:textAppearance="@style/TextAppearance.Volume.Header.Secondary" />
|
||||
<com.android.keyguard.AlphaOptimizedImageButton
|
||||
android:id="@+id/output_chooser_button"
|
||||
android:layout_width="24dp"
|
||||
android:layout_height="24dp"
|
||||
android:textColor="?android:attr/colorControlNormal"
|
||||
android:textAppearance="@style/TextAppearance.Volume.Header" />
|
||||
<LinearLayout
|
||||
android:id="@+id/output_chooser"
|
||||
android:orientation="vertical"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:minWidth="48dp"
|
||||
android:minHeight="48dp"
|
||||
android:paddingTop="10dp"
|
||||
android:background="?android:selectableItemBackgroundBorderless"
|
||||
android:contentDescription="@string/accessibility_output_chooser"
|
||||
style="@style/VolumeButtons"
|
||||
android:clickable="false"
|
||||
android:layout_centerVertical="true"
|
||||
android:src="@drawable/ic_swap"
|
||||
android:soundEffectsEnabled="false" />
|
||||
android:gravity="center">
|
||||
<TextView
|
||||
android:id="@+id/volume_row_connected_device"
|
||||
android:visibility="gone"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:maxLength="10"
|
||||
android:ellipsize="end"
|
||||
android:maxLines="1"
|
||||
android:textAppearance="@style/TextAppearance.Volume.Header.Secondary" />
|
||||
<com.android.keyguard.AlphaOptimizedImageButton
|
||||
android:id="@+id/output_chooser_button"
|
||||
android:layout_width="24dp"
|
||||
android:layout_height="24dp"
|
||||
android:background="?android:selectableItemBackgroundBorderless"
|
||||
android:contentDescription="@string/accessibility_output_chooser"
|
||||
style="@style/VolumeButtons"
|
||||
android:clickable="false"
|
||||
android:layout_centerVertical="true"
|
||||
android:src="@drawable/ic_swap"
|
||||
android:soundEffectsEnabled="false"/>
|
||||
</LinearLayout>
|
||||
</LinearLayout>
|
||||
</LinearLayout>
|
||||
<FrameLayout
|
||||
android:id="@+id/volume_row_slider_frame"
|
||||
android:padding="0dp"
|
||||
android:layout_width="@dimen/volume_dialog_panel_width"
|
||||
android:layoutDirection="rtl"
|
||||
android:layout_height="@dimen/volume_dialog_panel_width">
|
||||
<SeekBar
|
||||
android:id="@+id/volume_row_slider"
|
||||
android:clickable="true"
|
||||
<FrameLayout
|
||||
android:id="@+id/volume_row_slider_frame"
|
||||
android:padding="0dp"
|
||||
android:layout_margin="0dp"
|
||||
android:layout_width="@dimen/volume_dialog_panel_width"
|
||||
android:layout_height="@dimen/volume_dialog_panel_width"
|
||||
android:layoutDirection="rtl"
|
||||
android:layout_gravity="center"
|
||||
android:rotation="90" />
|
||||
</FrameLayout>
|
||||
android:layout_height="@dimen/volume_dialog_panel_width">
|
||||
<SeekBar
|
||||
android:id="@+id/volume_row_slider"
|
||||
android:clickable="true"
|
||||
android:padding="0dp"
|
||||
android:layout_margin="0dp"
|
||||
android:layout_width="@dimen/volume_dialog_panel_width"
|
||||
android:layout_height="@dimen/volume_dialog_panel_width"
|
||||
android:layoutDirection="rtl"
|
||||
android:layout_gravity="center"
|
||||
android:rotation="90" />
|
||||
</FrameLayout>
|
||||
|
||||
<com.android.keyguard.AlphaOptimizedImageButton
|
||||
android:id="@+id/volume_row_icon"
|
||||
style="@style/VolumeButtons"
|
||||
android:padding="10dp"
|
||||
android:layout_width="@dimen/volume_button_size"
|
||||
android:layout_height="@dimen/volume_button_size"
|
||||
android:background="?android:selectableItemBackgroundBorderless"
|
||||
android:soundEffectsEnabled="false" />
|
||||
<com.android.keyguard.AlphaOptimizedImageButton
|
||||
android:id="@+id/volume_row_icon"
|
||||
style="@style/VolumeButtons"
|
||||
android:padding="10dp"
|
||||
android:layout_width="@dimen/volume_button_size"
|
||||
android:layout_height="@dimen/volume_button_size"
|
||||
android:background="?android:selectableItemBackgroundBorderless"
|
||||
android:soundEffectsEnabled="false" />
|
||||
</LinearLayout>
|
||||
|
||||
</LinearLayout>
|
||||
<include layout="@layout/volume_dnd_icon"/>
|
||||
|
||||
</FrameLayout>
|
||||
|
||||
30
packages/SystemUI/res/layout/volume_dnd_icon.xml
Normal file
30
packages/SystemUI/res/layout/volume_dnd_icon.xml
Normal file
@@ -0,0 +1,30 @@
|
||||
<!--
|
||||
Copyright (C) 2018 The Android Open Source Project
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
-->
|
||||
<FrameLayout
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="14dp"
|
||||
android:layout_height="14dp"
|
||||
android:layout_marginTop="6dp"
|
||||
android:layout_marginRight="6dp"
|
||||
android:layout_gravity="right|top">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/dnd_icon"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:src="@drawable/ic_dnd"
|
||||
android:tint="?android:attr/textColorTertiary"/>
|
||||
</FrameLayout>
|
||||
@@ -68,6 +68,7 @@ import android.view.accessibility.AccessibilityEvent;
|
||||
import android.view.accessibility.AccessibilityManager.AccessibilityStateChangeListener;
|
||||
import android.view.animation.DecelerateInterpolator;
|
||||
import android.widget.ImageButton;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.SeekBar;
|
||||
import android.widget.SeekBar.OnSeekBarChangeListener;
|
||||
import android.widget.TextView;
|
||||
@@ -109,7 +110,9 @@ public class VolumeDialogImpl implements VolumeDialog {
|
||||
private ViewGroup mDialogRowsView;
|
||||
private ViewGroup mFooter;
|
||||
private ImageButton mRingerIcon;
|
||||
private ImageView mZenIcon;
|
||||
private TextView mRingerStatus;
|
||||
private TextView mRingerTitle;
|
||||
private final List<VolumeRow> mRows = new ArrayList<>();
|
||||
private ConfigurableTexts mConfigurableTexts;
|
||||
private final SparseBooleanArray mDynamic = new SparseBooleanArray();
|
||||
@@ -216,6 +219,8 @@ public class VolumeDialogImpl implements VolumeDialog {
|
||||
mFooter = mDialog.findViewById(R.id.footer);
|
||||
mRingerIcon = mFooter.findViewById(R.id.ringer_icon);
|
||||
mRingerStatus = mFooter.findViewById(R.id.ringer_status);
|
||||
mRingerTitle = mFooter.findViewById(R.id.ringer_title);
|
||||
mZenIcon = mFooter.findViewById(R.id.dnd_icon);
|
||||
|
||||
if (mRows.isEmpty()) {
|
||||
addRow(AudioManager.STREAM_MUSIC,
|
||||
@@ -349,6 +354,7 @@ public class VolumeDialogImpl implements VolumeDialog {
|
||||
if (stream == STREAM_ACCESSIBILITY) {
|
||||
row.header.setFilters(new InputFilter[] {new InputFilter.LengthFilter(13)});
|
||||
}
|
||||
row.dndIcon = row.view.findViewById(R.id.dnd_icon);
|
||||
row.slider = row.view.findViewById(R.id.volume_row_slider);
|
||||
row.slider.setOnSeekBarChangeListener(new VolumeSeekBarChangeListener(row));
|
||||
row.anim = null;
|
||||
@@ -559,6 +565,8 @@ public class VolumeDialogImpl implements VolumeDialog {
|
||||
if (ss == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
enableRingerViewsH(mState.zenMode == Global.ZEN_MODE_OFF || !mState.disallowRinger);
|
||||
switch (mState.ringerModeInternal) {
|
||||
case AudioManager.RINGER_MODE_VIBRATE:
|
||||
mRingerStatus.setText(R.string.volume_ringer_status_vibrate);
|
||||
@@ -603,6 +611,28 @@ public class VolumeDialogImpl implements VolumeDialog {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Toggles enable state of views in a VolumeRow (not including seekbar, outputChooser or icon)
|
||||
* Hides/shows zen icon
|
||||
* @param enable whether to enable volume row views and hide dnd icon
|
||||
*/
|
||||
private void enableVolumeRowViewsH(VolumeRow row, boolean enable) {
|
||||
row.header.setEnabled(enable);
|
||||
row.dndIcon.setVisibility(enable ? View.GONE : View.VISIBLE);
|
||||
}
|
||||
|
||||
/**
|
||||
* Toggles enable state of footer/ringer views
|
||||
* Hides/shows zen icon
|
||||
* @param enable whether to enable ringer views and hide dnd icon
|
||||
*/
|
||||
private void enableRingerViewsH(boolean enable) {
|
||||
mRingerTitle.setEnabled(enable);
|
||||
mRingerStatus.setEnabled(enable);
|
||||
mRingerIcon.setEnabled(enable);
|
||||
mZenIcon.setVisibility(enable ? View.GONE : View.VISIBLE);
|
||||
}
|
||||
|
||||
private void trimObsoleteH() {
|
||||
if (D.BUG) Log.d(TAG, "trimObsoleteH");
|
||||
for (int i = mRows.size() - 1; i >= 0; i--) {
|
||||
@@ -748,6 +778,7 @@ public class VolumeDialogImpl implements VolumeDialog {
|
||||
if (zenMuted) {
|
||||
row.tracking = false;
|
||||
}
|
||||
enableVolumeRowViewsH(row, !zenMuted);
|
||||
|
||||
// update slider
|
||||
final boolean enableSlider = !zenMuted;
|
||||
@@ -1178,5 +1209,6 @@ public class VolumeDialogImpl implements VolumeDialog {
|
||||
private int lastAudibleLevel = 1;
|
||||
private View outputChooser;
|
||||
private TextView connectedDevice;
|
||||
private ImageView dndIcon;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user