Merge changes I07ffc243,I1151746c,I295cf055
* changes: Add volume dialog icons specific for tv Update volume control ui for tv Show volume number in volume control ui
This commit is contained in:
committed by
Android (Google) Code Review
commit
4a3931f7ab
@@ -0,0 +1,26 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!--
|
||||
Copyright (C) 2020 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
|
||||
-->
|
||||
|
||||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:width="24dp"
|
||||
android:height="24dp"
|
||||
android:viewportWidth="24.0"
|
||||
android:viewportHeight="24.0">
|
||||
<path
|
||||
android:fillColor="@color/tv_volume_dialog_accent"
|
||||
android:pathData="M3,9v6h4l5,5L12,4L7,9L3,9zM16.5,12c0,-1.77 -1.02,-3.29 -2.5,-4.03v8.05c1.48,-0.73 2.5,-2.25 2.5,-4.02zM14,3.23v2.06c2.89,0.86 5,3.54 5,6.71s-2.11,5.85 -5,6.71v2.06c4.01,-0.91 7,-4.49 7,-8.77s-2.99,-7.86 -7,-8.77z"/>
|
||||
</vector>
|
||||
@@ -0,0 +1,26 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!--
|
||||
Copyright (C) 2020 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
|
||||
-->
|
||||
|
||||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:width="24dp"
|
||||
android:height="24dp"
|
||||
android:viewportWidth="24.0"
|
||||
android:viewportHeight="24.0">
|
||||
<path
|
||||
android:fillColor="@color/tv_volume_dialog_accent"
|
||||
android:pathData="M3,15V9H7L12,4V20L7,15H3ZM14,7.97C15.48,8.71 16.5,10.23 16.5,12C16.5,13.77 15.48,15.29 14,16.02V7.97Z"/>
|
||||
</vector>
|
||||
@@ -0,0 +1,27 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!--
|
||||
Copyright (C) 2020 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
|
||||
-->
|
||||
|
||||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:width="24dp"
|
||||
android:height="24dp"
|
||||
android:viewportWidth="24.0"
|
||||
android:viewportHeight="24.0">
|
||||
<path
|
||||
android:fillColor="@color/tv_volume_dialog_accent"
|
||||
android:pathData="M16.5,12c0,-1.77 -1.02,-3.29 -2.5,-4.03v2.21l2.45,2.45c0.03,-0.2 0.05,-0.41 0.05,-0.63zM19,12c0,0.94 -0.2,1.82 -0.54,2.64l1.51,1.51C20.63,14.91 21,13.5 21,12c0,-4.28 -2.99,-7.86 -7,-8.77v2.06c2.89,0.86 5,3.54 5,6.71zM4.27,3L3,4.27 7.73,9L3,9v6h4l5,5v-6.73l4.25,4.25c-0.67,0.52 -1.42,0.93 -2.25,1.18v2.06c1.38,-0.31 2.63,-0.95 3.69,-1.81L19.73,21 21,19.73l-9,-9L4.27,3zM12,4L9.91,6.09 12,8.18L12,4z"/>
|
||||
</vector>
|
||||
|
||||
18
packages/SystemUI/res/drawable/ic_volume_media_low.xml
Normal file
18
packages/SystemUI/res/drawable/ic_volume_media_low.xml
Normal file
@@ -0,0 +1,18 @@
|
||||
<!--
|
||||
Copyright (C) 2020 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:drawable="@drawable/ic_volume_media" />
|
||||
</selector>
|
||||
@@ -0,0 +1,24 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!--
|
||||
~ Copyright (C) 2020 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.
|
||||
-->
|
||||
|
||||
<shape xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:shape="rectangle">
|
||||
|
||||
<solid android:color="@color/tv_volume_dialog_background" />
|
||||
<corners android:radius="@dimen/tv_volume_dialog_corner_radius"/>
|
||||
|
||||
</shape>
|
||||
22
packages/SystemUI/res/drawable/tv_volume_dialog_circle.xml
Normal file
22
packages/SystemUI/res/drawable/tv_volume_dialog_circle.xml
Normal file
@@ -0,0 +1,22 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!--
|
||||
~ Copyright (C) 2020 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.
|
||||
-->
|
||||
|
||||
<shape xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:shape="oval">
|
||||
<solid android:color="@color/tv_volume_dialog_circle" />
|
||||
|
||||
</shape>
|
||||
@@ -20,7 +20,7 @@
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="@android:color/transparent"
|
||||
android:theme="@style/qs_theme">
|
||||
android:theme="@style/volume_dialog_theme">
|
||||
|
||||
<FrameLayout
|
||||
android:id="@+id/volume_dialog"
|
||||
@@ -46,7 +46,7 @@
|
||||
android:translationZ="@dimen/volume_dialog_elevation"
|
||||
android:clipChildren="false"
|
||||
android:clipToPadding="false"
|
||||
android:background="@drawable/rounded_bg_full">
|
||||
android:background="@drawable/tv_volume_dialog_background">
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/volume_dialog_rows"
|
||||
@@ -54,9 +54,7 @@
|
||||
android:layout_height="wrap_content"
|
||||
android:minWidth="@dimen/volume_dialog_panel_width"
|
||||
android:gravity="center"
|
||||
android:orientation="horizontal"
|
||||
android:paddingRight="@dimen/volume_dialog_stream_padding"
|
||||
android:paddingLeft="@dimen/volume_dialog_stream_padding">
|
||||
android:orientation="horizontal">
|
||||
<!-- volume rows added and removed here! :-) -->
|
||||
</LinearLayout>
|
||||
|
||||
@@ -98,4 +96,4 @@
|
||||
|
||||
</FrameLayout>
|
||||
|
||||
</FrameLayout>
|
||||
</FrameLayout>
|
||||
|
||||
@@ -21,11 +21,12 @@
|
||||
android:background="@android:color/transparent"
|
||||
android:clipChildren="false"
|
||||
android:clipToPadding="false"
|
||||
android:theme="@style/qs_theme">
|
||||
android:theme="@style/volume_dialog_theme">
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="match_parent"
|
||||
android:padding="@dimen/tv_volume_dialog_row_padding"
|
||||
android:background="@android:color/transparent"
|
||||
android:gravity="center"
|
||||
android:layout_gravity="center"
|
||||
@@ -33,9 +34,9 @@
|
||||
<com.android.keyguard.AlphaOptimizedImageButton
|
||||
android:id="@+id/volume_row_icon"
|
||||
style="@style/VolumeButtons"
|
||||
android:layout_width="@dimen/volume_dialog_tap_target_size"
|
||||
android:layout_height="@dimen/volume_dialog_tap_target_size"
|
||||
android:background="@drawable/ripple_drawable_20dp"
|
||||
android:layout_width="@dimen/tv_volume_dialog_bubble_size"
|
||||
android:layout_height="@dimen/tv_volume_dialog_bubble_size"
|
||||
android:background="@drawable/tv_volume_dialog_circle"
|
||||
android:tint="@color/accent_tint_color_selector"
|
||||
android:soundEffectsEnabled="false" />
|
||||
<TextView
|
||||
@@ -62,6 +63,15 @@
|
||||
android:layout_gravity="center"
|
||||
android:rotation="0" />
|
||||
</FrameLayout>
|
||||
<TextView
|
||||
android:id="@+id/volume_number"
|
||||
android:layout_width="@dimen/tv_volume_dialog_bubble_size"
|
||||
android:layout_height="@dimen/tv_volume_dialog_bubble_size"
|
||||
android:maxLength="2"
|
||||
android:gravity="center"
|
||||
android:background="@drawable/tv_volume_dialog_circle"
|
||||
android:textSize="@dimen/tv_volume_number_text_size"
|
||||
android:textColor="@color/accent_tint_color_selector"/>
|
||||
</LinearLayout>
|
||||
|
||||
<include layout="@layout/volume_dnd_icon"/>
|
||||
|
||||
@@ -22,7 +22,7 @@
|
||||
android:gravity="right"
|
||||
android:layout_gravity="right"
|
||||
android:background="@android:color/transparent"
|
||||
android:theme="@style/qs_theme">
|
||||
android:theme="@style/volume_dialog_theme">
|
||||
|
||||
<FrameLayout
|
||||
android:id="@+id/volume_dialog"
|
||||
|
||||
@@ -22,7 +22,7 @@
|
||||
android:gravity="right"
|
||||
android:layout_gravity="right"
|
||||
android:background="@android:color/transparent"
|
||||
android:theme="@style/qs_theme">
|
||||
android:theme="@style/volume_dialog_theme">
|
||||
|
||||
<!-- right-aligned to be physically near volume button -->
|
||||
<LinearLayout
|
||||
|
||||
@@ -20,7 +20,7 @@
|
||||
android:layout_width="@dimen/volume_dialog_panel_width"
|
||||
android:clipChildren="false"
|
||||
android:clipToPadding="false"
|
||||
android:theme="@style/qs_theme">
|
||||
android:theme="@style/volume_dialog_theme">
|
||||
|
||||
<LinearLayout
|
||||
android:layout_height="wrap_content"
|
||||
|
||||
@@ -17,5 +17,8 @@
|
||||
<resources>
|
||||
<!-- Width of volume bar -->
|
||||
<dimen name="volume_dialog_row_width">252dp</dimen>
|
||||
<dimen name="volume_dialog_tap_target_size">36dp</dimen>
|
||||
<dimen name="tv_volume_dialog_bubble_size">36dp</dimen>
|
||||
<dimen name="tv_volume_dialog_corner_radius">40dp</dimen>
|
||||
<dimen name="tv_volume_dialog_row_padding">5dp</dimen>
|
||||
<dimen name="tv_volume_number_text_size">16dp</dimen>
|
||||
</resources>
|
||||
|
||||
@@ -43,4 +43,7 @@
|
||||
<item>com.android.systemui.toast.ToastUI</item>
|
||||
<item>com.android.systemui.onehanded.OneHandedUI</item>
|
||||
</string-array>
|
||||
|
||||
<!-- Show a separate icon for low and high volume on the volume dialog -->
|
||||
<bool name="config_showLowMediaVolumeIcon">true</bool>
|
||||
</resources>
|
||||
|
||||
@@ -22,4 +22,8 @@
|
||||
<item name="android:windowEnterAnimation">@null</item>
|
||||
<item name="android:windowExitAnimation">@null</item>
|
||||
</style>
|
||||
|
||||
<style name="volume_dialog_theme" parent="qs_theme">
|
||||
<item name="android:colorAccent">@color/tv_volume_dialog_accent</item>
|
||||
</style>
|
||||
</resources>
|
||||
|
||||
@@ -28,4 +28,7 @@
|
||||
<color name="tv_audio_recording_indicator_stroke">#33FFFFFF</color>
|
||||
|
||||
<color name="red">#FFCC0000</color>
|
||||
<color name="tv_volume_dialog_background">#E61F232B</color>
|
||||
<color name="tv_volume_dialog_circle">#08FFFFFF</color>
|
||||
<color name="tv_volume_dialog_accent">#FFDADCE0</color>
|
||||
</resources>
|
||||
|
||||
@@ -574,4 +574,6 @@
|
||||
<!-- Animation duration for translating of one handed when trigger / dismiss. -->
|
||||
<integer name="config_one_handed_translate_animation_duration">150</integer>
|
||||
|
||||
<!-- Show a separate icon for low and high volume on the volume dialog -->
|
||||
<bool name="config_showLowMediaVolumeIcon">false</bool>
|
||||
</resources>
|
||||
|
||||
@@ -387,6 +387,9 @@
|
||||
<item name="android:homeAsUpIndicator">@drawable/ic_arrow_back</item>
|
||||
</style>
|
||||
|
||||
<!-- Overridden by values-television/styles.xml with tv-specific settings -->
|
||||
<style name="volume_dialog_theme" parent="qs_theme"/>
|
||||
|
||||
<style name="systemui_theme_remote_input" parent="@android:style/Theme.DeviceDefault.Light">
|
||||
<item name="android:colorAccent">@color/remote_input_accent</item>
|
||||
</style>
|
||||
|
||||
@@ -150,6 +150,8 @@ public class VolumeDialogImpl implements VolumeDialog,
|
||||
private boolean mShowing;
|
||||
private boolean mShowA11yStream;
|
||||
|
||||
private final boolean mShowLowMediaVolumeIcon;
|
||||
|
||||
private int mActiveStream;
|
||||
private int mPrevActiveStream;
|
||||
private boolean mAutomute = VolumePrefs.DEFAULT_ENABLE_AUTOMUTE;
|
||||
@@ -166,7 +168,7 @@ public class VolumeDialogImpl implements VolumeDialog,
|
||||
|
||||
public VolumeDialogImpl(Context context) {
|
||||
mContext =
|
||||
new ContextThemeWrapper(context, R.style.qs_theme);
|
||||
new ContextThemeWrapper(context, R.style.volume_dialog_theme);
|
||||
mController = Dependency.get(VolumeDialogController.class);
|
||||
mKeyguard = (KeyguardManager) mContext.getSystemService(Context.KEYGUARD_SERVICE);
|
||||
mActivityManager = (ActivityManager) mContext.getSystemService(Context.ACTIVITY_SERVICE);
|
||||
@@ -175,6 +177,8 @@ public class VolumeDialogImpl implements VolumeDialog,
|
||||
mShowActiveStreamOnly = showActiveStreamOnly();
|
||||
mHasSeenODICaptionsTooltip =
|
||||
Prefs.getBoolean(context, Prefs.Key.HAS_SEEN_ODI_CAPTIONS_TOOLTIP, false);
|
||||
mShowLowMediaVolumeIcon =
|
||||
mContext.getResources().getBoolean(R.bool.config_showLowMediaVolumeIcon);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -421,6 +425,7 @@ public class VolumeDialogImpl implements VolumeDialog,
|
||||
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.number = row.view.findViewById(R.id.volume_number);
|
||||
|
||||
row.anim = null;
|
||||
|
||||
@@ -1024,19 +1029,28 @@ public class VolumeDialogImpl implements VolumeDialog,
|
||||
final boolean iconEnabled = (mAutomute || ss.muteSupported) && !zenMuted;
|
||||
row.icon.setEnabled(iconEnabled);
|
||||
row.icon.setAlpha(iconEnabled ? 1 : 0.5f);
|
||||
final int iconRes =
|
||||
isRingVibrate ? R.drawable.ic_volume_ringer_vibrate
|
||||
: isRingSilent || zenMuted ? row.iconMuteRes
|
||||
: ss.routedToBluetooth
|
||||
? isStreamMuted(ss) ? R.drawable.ic_volume_media_bt_mute
|
||||
: R.drawable.ic_volume_media_bt
|
||||
: isStreamMuted(ss) ? row.iconMuteRes : row.iconRes;
|
||||
final int iconRes;
|
||||
if (isRingVibrate) {
|
||||
iconRes = R.drawable.ic_volume_ringer_vibrate;
|
||||
} else if (isRingSilent || zenMuted) {
|
||||
iconRes = row.iconMuteRes;
|
||||
} else if (ss.routedToBluetooth) {
|
||||
iconRes = isStreamMuted(ss) ? R.drawable.ic_volume_media_bt_mute
|
||||
: R.drawable.ic_volume_media_bt;
|
||||
} else if (isStreamMuted(ss)) {
|
||||
iconRes = row.iconMuteRes;
|
||||
} else {
|
||||
iconRes = mShowLowMediaVolumeIcon && ss.level * 2 < (ss.levelMax + ss.levelMin)
|
||||
? R.drawable.ic_volume_media_low : row.iconRes;
|
||||
}
|
||||
|
||||
row.icon.setImageResource(iconRes);
|
||||
row.iconState =
|
||||
iconRes == R.drawable.ic_volume_ringer_vibrate ? Events.ICON_STATE_VIBRATE
|
||||
: (iconRes == R.drawable.ic_volume_media_bt_mute || iconRes == row.iconMuteRes)
|
||||
? Events.ICON_STATE_MUTE
|
||||
: (iconRes == R.drawable.ic_volume_media_bt || iconRes == row.iconRes)
|
||||
: (iconRes == R.drawable.ic_volume_media_bt || iconRes == row.iconRes
|
||||
|| iconRes == R.drawable.ic_volume_media_low)
|
||||
? Events.ICON_STATE_UNMUTE
|
||||
: Events.ICON_STATE_UNKNOWN;
|
||||
if (iconEnabled) {
|
||||
@@ -1090,6 +1104,7 @@ public class VolumeDialogImpl implements VolumeDialog,
|
||||
final int vlevel = row.ss.muted && (!isRingStream && !zenMuted) ? 0
|
||||
: row.ss.level;
|
||||
updateVolumeRowSliderH(row, enableSlider, vlevel);
|
||||
if (row.number != null) row.number.setText(Integer.toString(vlevel));
|
||||
}
|
||||
|
||||
private boolean isStreamMuted(final StreamState streamState) {
|
||||
@@ -1115,6 +1130,10 @@ public class VolumeDialogImpl implements VolumeDialog,
|
||||
row.icon.setImageTintList(tint);
|
||||
row.icon.setImageAlpha(alpha);
|
||||
row.cachedTint = tint;
|
||||
if (row.number != null) {
|
||||
row.number.setTextColor(tint);
|
||||
row.number.setAlpha(alpha);
|
||||
}
|
||||
}
|
||||
|
||||
private void updateVolumeRowSliderH(VolumeRow row, boolean enable, int vlevel) {
|
||||
@@ -1346,7 +1365,7 @@ public class VolumeDialogImpl implements VolumeDialog,
|
||||
|
||||
private final class CustomDialog extends Dialog implements DialogInterface {
|
||||
public CustomDialog(Context context) {
|
||||
super(context, R.style.qs_theme);
|
||||
super(context, R.style.volume_dialog_theme);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -1458,6 +1477,7 @@ public class VolumeDialogImpl implements VolumeDialog,
|
||||
private TextView header;
|
||||
private ImageButton icon;
|
||||
private SeekBar slider;
|
||||
private TextView number;
|
||||
private int stream;
|
||||
private StreamState ss;
|
||||
private long userAttempt; // last user-driven slider change
|
||||
|
||||
Reference in New Issue
Block a user