Fix TV volume dialog

Bug: 181864498
Test: m && check volume dialog looks right
Change-Id: Ia7011db6d5c2c74536e6c6cbaa888bbde55805de
This commit is contained in:
Galia Peycheva
2021-03-15 10:43:37 +01:00
parent 98f75fd2bb
commit ff07fa364c
9 changed files with 106 additions and 56 deletions

View File

@@ -0,0 +1,37 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
Copyright (C) 2021 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.
-->
<layer-list xmlns:android="http://schemas.android.com/apk/res/android"
android:paddingMode="stack">
<item android:id="@android:id/background"
android:gravity="center_vertical|fill_horizontal">
<layer-list>
<item android:id="@+id/volume_seekbar_background_solid">
<shape>
<size android:height="@dimen/volume_dialog_slider_width" />
<solid android:color="@color/tv_volume_dialog_seek_bar_background"/>
<corners android:radius="@dimen/volume_dialog_slider_corner_radius" />
</shape>
</item>
</layer-list>
</item>
<item android:id="@android:id/progress"
android:gravity="center_vertical|fill_horizontal">
<com.android.systemui.util.RoundedCornerProgressDrawable
android:drawable="@drawable/volume_row_seekbar_progress"
/>
</item>
</layer-list>

View File

@@ -0,0 +1,29 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
~ Copyright (C) 2021 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.
-->
<!-- Progress drawable for volume row SeekBars. This is the accent-colored round rect that moves up
and down as the progress value changes. -->
<layer-list xmlns:android="http://schemas.android.com/apk/res/android"
android:autoMirrored="true">
<item android:id="@+id/volume_seekbar_progress_solid">
<shape android:shape="rectangle">
<size android:height="@dimen/volume_dialog_slider_width"/>
<solid android:color="@color/tv_volume_dialog_seek_bar_fill" />
<corners android:radius="@dimen/volume_dialog_slider_width" />
</shape>
</item>
</layer-list>

View File

@@ -1,32 +0,0 @@
<?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.
-->
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item android:id="@android:id/background">
<shape android:shape="rectangle">
<solid android:color="@color/tv_volume_dialog_seek_bar_background" />
<corners android:radius="@dimen/tv_volume_seek_bar_width" />
</shape>
</item>
<item android:id="@android:id/progress">
<clip>
<shape android:shape="rectangle">
<solid android:color="@color/tv_volume_dialog_seek_bar_fill" />
<corners android:radius="@dimen/tv_volume_seek_bar_width" />
</shape>
</clip>
</item>
</layer-list>

View File

@@ -25,9 +25,9 @@
<layer-list>
<item android:id="@+id/volume_seekbar_background_solid">
<shape>
<size android:height="@dimen/volume_dialog_panel_width" />
<size android:height="@dimen/volume_dialog_slider_width" />
<solid android:color="?android:attr/colorBackgroundFloating" />
<corners android:radius="@dimen/volume_dialog_panel_width_half" />
<corners android:radius="@dimen/volume_dialog_slider_corner_radius" />
</shape>
</item>
<item
@@ -53,4 +53,4 @@
android:drawable="@drawable/volume_row_seekbar_progress"
/>
</item>
</layer-list>
</layer-list>

View File

@@ -17,7 +17,7 @@
xmlns:android="http://schemas.android.com/apk/res/android"
android:tag="row"
android:layout_width="wrap_content"
android:layout_height="@dimen/volume_dialog_row_height"
android:layout_height="@dimen/volume_dialog_panel_height"
android:background="@android:color/transparent"
android:clipChildren="false"
android:clipToPadding="false"
@@ -54,18 +54,18 @@
<FrameLayout
android:id="@+id/volume_row_slider_frame"
android:layout_width="match_parent"
android:layout_height="@dimen/volume_dialog_row_height">
android:layout_height="@dimen/volume_dialog_panel_height">
<SeekBar
android:id="@+id/volume_row_slider"
android:clickable="false"
android:layout_width="@dimen/volume_dialog_row_height"
android:layout_width="@dimen/volume_dialog_panel_height"
android:layout_height="match_parent"
android:layout_gravity="center"
android:layoutDirection="ltr"
android:maxHeight="@dimen/tv_volume_seek_bar_width"
android:minHeight="@dimen/tv_volume_seek_bar_width"
android:maxHeight="@dimen/volume_dialog_slider_width"
android:minHeight="@dimen/volume_dialog_slider_width"
android:progressDrawable="@drawable/volume_row_seekbar"
android:thumb="@drawable/tv_volume_row_seek_thumb"
android:progressDrawable="@drawable/tv_volume_row_seek_bar"
android:splitTrack="false"
android:rotation="270" />
</FrameLayout>

View File

@@ -54,6 +54,7 @@
android:layout_width="@dimen/volume_row_slider_height"
android:layout_height="match_parent"
android:layout_gravity="center"
android:thumb="@android:color/transparent"
android:rotation="270" />
</FrameLayout>

View File

@@ -16,14 +16,17 @@
<resources>
<!-- Height of volume bar -->
<dimen name="volume_dialog_row_height">190dp</dimen>
<dimen name="volume_dialog_row_width">48dp</dimen>
<dimen name="volume_dialog_panel_height">190dp</dimen>
<dimen name="volume_dialog_panel_width">48dp</dimen>
<dimen name="volume_dialog_panel_width_half">24dp</dimen>
<dimen name="volume_dialog_panel_transparent_padding">24dp</dimen>
<dimen name="volume_dialog_slider_width">4dp</dimen>
<dimen name="volume_dialog_slider_corner_radius">@dimen/volume_dialog_slider_width</dimen>
<dimen name="tv_volume_dialog_bubble_size">36dp</dimen>
<dimen name="tv_volume_dialog_corner_radius">36dp</dimen>
<dimen name="tv_volume_dialog_row_padding">6dp</dimen>
<dimen name="tv_volume_number_text_size">16sp</dimen>
<dimen name="tv_volume_seek_bar_width">4dp</dimen>
<dimen name="tv_volume_seek_bar_thumb_diameter">24dp</dimen>
<dimen name="tv_volume_seek_bar_thumb_focus_ring_width">8dp</dimen>
<dimen name="tv_volume_icons_size">20dp</dimen>

View File

@@ -463,6 +463,10 @@
<dimen name="volume_dialog_slider_height">116dp</dimen>
<dimen name="volume_dialog_slider_width">@dimen/volume_dialog_panel_width</dimen>
<dimen name="volume_dialog_slider_corner_radius">@dimen/volume_dialog_panel_width_half</dimen>
<dimen name="volume_dialog_ringer_size">64dp</dimen>
<dimen name="volume_dialog_ringer_icon_padding">20dp</dimen>

View File

@@ -546,9 +546,10 @@ public class VolumeDialogImpl implements VolumeDialog,
row.sliderBgSolid = seekbarBgDrawable.findDrawableByLayerId(
R.id.volume_seekbar_background_solid);
row.sliderBgIcon = (AlphaTintDrawableWrapper)
((RotateDrawable) seekbarBgDrawable.findDrawableByLayerId(
R.id.volume_seekbar_background_icon)).getDrawable();
final Drawable sliderBgIcon = seekbarBgDrawable.findDrawableByLayerId(
R.id.volume_seekbar_background_icon);
row.sliderBgIcon = sliderBgIcon != null ? (AlphaTintDrawableWrapper)
((RotateDrawable) sliderBgIcon).getDrawable() : null;
final LayerDrawable seekbarProgressDrawable = (LayerDrawable)
((RoundedCornerProgressDrawable) seekbarDrawable.findDrawableByLayerId(
@@ -556,13 +557,12 @@ public class VolumeDialogImpl implements VolumeDialog,
row.sliderProgressSolid = seekbarProgressDrawable.findDrawableByLayerId(
R.id.volume_seekbar_progress_solid);
row.sliderProgressIcon = (AlphaTintDrawableWrapper)
((RotateDrawable) seekbarProgressDrawable.findDrawableByLayerId(
R.id.volume_seekbar_progress_icon)).getDrawable();
final Drawable sliderProgressIcon = seekbarProgressDrawable.findDrawableByLayerId(
R.id.volume_seekbar_progress_icon);
row.sliderProgressIcon = sliderProgressIcon != null ? (AlphaTintDrawableWrapper)
((RotateDrawable) sliderProgressIcon).getDrawable() : null;
row.slider.setProgressDrawable(seekbarDrawable);
row.slider.setThumb(null);
row.icon = row.view.findViewById(R.id.volume_row_icon);
@@ -1484,10 +1484,14 @@ public class VolumeDialogImpl implements VolumeDialog,
mContext, android.R.attr.colorBackgroundFloating);
row.sliderProgressSolid.setTintList(colorTint);
row.sliderBgIcon.setTintList(colorTint);
if (row.sliderBgIcon != null) {
row.sliderBgIcon.setTintList(colorTint);
}
row.sliderBgSolid.setTintList(bgTint);
row.sliderProgressIcon.setTintList(bgTint);
if (row.sliderProgressIcon != null) {
row.sliderProgressIcon.setTintList(bgTint);
}
if (row.icon != null) {
row.icon.setImageTintList(colorTint);
@@ -1878,8 +1882,12 @@ public class VolumeDialogImpl implements VolumeDialog,
icon.setImageResource(iconRes);
}
sliderProgressIcon.setDrawable(view.getResources().getDrawable(iconRes, theme));
sliderBgIcon.setDrawable(view.getResources().getDrawable(iconRes, theme));
if (sliderProgressIcon != null) {
sliderProgressIcon.setDrawable(view.getResources().getDrawable(iconRes, theme));
}
if (sliderBgIcon != null) {
sliderBgIcon.setDrawable(view.getResources().getDrawable(iconRes, theme));
}
}
}