Add background blur to tv volume dialog
Bug: 182905790
Test: m && check volume dialog appears as expected
Test: disable blur with 'adb shell wm disable-blur 1' and check volume
control ui switches to fallback non-blurry variant
Change-Id: Icd0897bb33bf5d929a43d26df2ba64cbf4eb0267
This commit is contained in:
@@ -18,7 +18,7 @@
|
||||
<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"/>
|
||||
<solid android:color="@color/volume_dialog_background_color" />
|
||||
<corners android:radius="?android:attr/dialogCornerRadius"/>
|
||||
|
||||
</shape>
|
||||
|
||||
@@ -40,14 +40,15 @@
|
||||
android:translationZ="@dimen/volume_dialog_elevation"
|
||||
android:clipChildren="false"
|
||||
android:clipToPadding="false"
|
||||
android:background="@drawable/tv_volume_dialog_background">
|
||||
android:background="@android:color/transparent">
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/volume_dialog_rows"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:gravity="center"
|
||||
android:orientation="horizontal">
|
||||
android:orientation="horizontal"
|
||||
android:background="@drawable/tv_volume_dialog_background">
|
||||
<!-- volume rows added and removed here! :-) -->
|
||||
</LinearLayout>
|
||||
|
||||
|
||||
@@ -22,9 +22,9 @@
|
||||
<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="volume_dialog_background_blur_radius">100dp</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_thumb_diameter">24dp</dimen>
|
||||
|
||||
22
packages/SystemUI/res/values-television/colors.xml
Normal file
22
packages/SystemUI/res/values-television/colors.xml
Normal file
@@ -0,0 +1,22 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!--
|
||||
/*
|
||||
* Copyright 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.
|
||||
*/
|
||||
-->
|
||||
<resources>
|
||||
<color name="volume_dialog_background_color">#E61F232B</color>
|
||||
<color name="volume_dialog_background_color_above_blur">#C71F232B</color>
|
||||
</resources>
|
||||
@@ -60,4 +60,7 @@
|
||||
|
||||
<!-- The duraction of the hide animation for the volume dialog in milliseconds -->
|
||||
<integer name="config_dialogHideAnimationDurationMs">400</integer>
|
||||
|
||||
<!-- Whether to use window background blur for the volume dialog. -->
|
||||
<bool name="config_volumeDialogUseBackgroundBlur">true</bool>
|
||||
</resources>
|
||||
|
||||
@@ -25,5 +25,6 @@
|
||||
|
||||
<style name="volume_dialog_theme" parent="qs_theme">
|
||||
<item name="android:colorAccent">@color/tv_volume_dialog_accent</item>
|
||||
<item name="android:dialogCornerRadius">@dimen/volume_dialog_panel_width_half</item>
|
||||
</style>
|
||||
</resources>
|
||||
|
||||
@@ -243,6 +243,10 @@
|
||||
<color name="magnification_border_color">#FF9900</color>
|
||||
<color name="magnification_switch_button_color">#7F000000</color>
|
||||
|
||||
<!-- Volume dialog colors -->
|
||||
<color name="volume_dialog_background_color">@android:color/transparent</color>
|
||||
<color name="volume_dialog_background_color_above_blur">@android:color/transparent</color>
|
||||
|
||||
<!-- media -->
|
||||
<color name="media_disabled">#80ffffff</color>
|
||||
<color name="media_seamless_border">?android:attr/colorAccent</color>
|
||||
|
||||
@@ -26,7 +26,6 @@
|
||||
<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_seek_thumb_focus_ring">#1AFFFFFF</color>
|
||||
<color name="tv_volume_dialog_seek_thumb_shadow">#40000000</color>
|
||||
|
||||
@@ -599,4 +599,7 @@
|
||||
<!-- Whether a transition of ACTIVITY_TYPE_ASSISTANT to the home app should play a home sound
|
||||
effect -->
|
||||
<bool name="config_playHomeSoundAfterAssistant">false</bool>
|
||||
|
||||
<!-- Whether to use window background blur for the volume dialog. -->
|
||||
<bool name="config_volumeDialogUseBackgroundBlur">false</bool>
|
||||
</resources>
|
||||
|
||||
@@ -484,6 +484,8 @@
|
||||
|
||||
<dimen name="volume_dialog_elevation">9dp</dimen>
|
||||
|
||||
<dimen name="volume_dialog_background_blur_radius">0dp</dimen>
|
||||
|
||||
<dimen name="volume_tool_tip_right_margin">76dp</dimen>
|
||||
|
||||
<dimen name="volume_tool_tip_bottom_margin">32dp</dimen>
|
||||
|
||||
@@ -76,6 +76,7 @@ import android.view.ContextThemeWrapper;
|
||||
import android.view.MotionEvent;
|
||||
import android.view.View;
|
||||
import android.view.View.AccessibilityDelegate;
|
||||
import android.view.View.OnAttachStateChangeListener;
|
||||
import android.view.ViewGroup;
|
||||
import android.view.ViewPropertyAnimator;
|
||||
import android.view.ViewStub;
|
||||
@@ -95,6 +96,7 @@ import android.widget.SeekBar.OnSeekBarChangeListener;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
|
||||
import com.android.internal.graphics.drawable.BackgroundBlurDrawable;
|
||||
import com.android.settingslib.Utils;
|
||||
import com.android.systemui.Dependency;
|
||||
import com.android.systemui.Interpolators;
|
||||
@@ -115,6 +117,7 @@ import com.android.systemui.util.RoundedCornerProgressDrawable;
|
||||
import java.io.PrintWriter;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
/**
|
||||
* Visual presentation of the volume dialog.
|
||||
@@ -214,6 +217,10 @@ public class VolumeDialogImpl implements VolumeDialog,
|
||||
private ViewStub mODICaptionsTooltipViewStub;
|
||||
private View mODICaptionsTooltipView = null;
|
||||
|
||||
private final boolean mUseBackgroundBlur;
|
||||
private Consumer<Boolean> mCrossWindowBlurEnabledListener;
|
||||
private BackgroundBlurDrawable mDialogRowsViewBackground;
|
||||
|
||||
public VolumeDialogImpl(Context context) {
|
||||
mContext =
|
||||
new ContextThemeWrapper(context, R.style.volume_dialog_theme);
|
||||
@@ -233,6 +240,20 @@ public class VolumeDialogImpl implements VolumeDialog,
|
||||
mContext.getResources().getInteger(R.integer.config_dialogShowAnimationDurationMs);
|
||||
mDialogHideAnimationDurationMs =
|
||||
mContext.getResources().getInteger(R.integer.config_dialogHideAnimationDurationMs);
|
||||
mUseBackgroundBlur =
|
||||
mContext.getResources().getBoolean(R.bool.config_volumeDialogUseBackgroundBlur);
|
||||
|
||||
if (mUseBackgroundBlur) {
|
||||
final int dialogRowsViewColorAboveBlur = mContext.getColor(
|
||||
R.color.volume_dialog_background_color_above_blur);
|
||||
final int dialogRowsViewColorNoBlur = mContext.getColor(
|
||||
R.color.volume_dialog_background_color);
|
||||
mCrossWindowBlurEnabledListener = (enabled) -> {
|
||||
mDialogRowsViewBackground.setColor(
|
||||
enabled ? dialogRowsViewColorAboveBlur : dialogRowsViewColorNoBlur);
|
||||
mDialogRowsView.invalidate();
|
||||
};
|
||||
}
|
||||
mRingerDrawerItemSize = mContext.getResources().getDimensionPixelSize(
|
||||
R.dimen.volume_ringer_drawer_item_size);
|
||||
mShowVibrate = mController.hasVibrator();
|
||||
@@ -356,6 +377,32 @@ public class VolumeDialogImpl implements VolumeDialog,
|
||||
});
|
||||
|
||||
mDialogRowsView = mDialog.findViewById(R.id.volume_dialog_rows);
|
||||
if (mUseBackgroundBlur) {
|
||||
mDialogView.addOnAttachStateChangeListener(new OnAttachStateChangeListener() {
|
||||
@Override
|
||||
public void onViewAttachedToWindow(View v) {
|
||||
mWindow.getWindowManager().addCrossWindowBlurEnabledListener(
|
||||
mCrossWindowBlurEnabledListener);
|
||||
|
||||
mDialogRowsViewBackground = v.getViewRootImpl().createBackgroundBlurDrawable();
|
||||
|
||||
final Resources resources = mContext.getResources();
|
||||
mDialogRowsViewBackground.setCornerRadius(
|
||||
mContext.getResources().getDimensionPixelSize(Utils.getThemeAttr(
|
||||
mContext, android.R.attr.dialogCornerRadius)));
|
||||
mDialogRowsViewBackground.setBlurRadius(resources.getDimensionPixelSize(
|
||||
R.dimen.volume_dialog_background_blur_radius));
|
||||
mDialogRowsView.setBackground(mDialogRowsViewBackground);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onViewDetachedFromWindow(View v) {
|
||||
mWindow.getWindowManager().removeCrossWindowBlurEnabledListener(
|
||||
mCrossWindowBlurEnabledListener);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
mRinger = mDialog.findViewById(R.id.ringer);
|
||||
if (mRinger != null) {
|
||||
mRingerIcon = mRinger.findViewById(R.id.ringer_icon);
|
||||
|
||||
Reference in New Issue
Block a user