From c4acfcc4d208737fae648d5e1771387d6ec12b6d Mon Sep 17 00:00:00 2001 From: Jacqueline Bronger Date: Thu, 4 Mar 2021 15:37:52 +0000 Subject: Blur the background of aosp notification panel Adds a blur to the panel itself, not the rest of the screen. Bug: 174025821 Test: manual Change-Id: Ia9df8f9f042dab55ba54eec741f9579c0208ac9b --- .../SystemUI/res/layout/tv_notification_panel.xml | 2 +- packages/SystemUI/res/values/colors_tv.xml | 3 +- packages/SystemUI/res/values/dimens_tv.xml | 1 + packages/SystemUI/res/values/styles_tv.xml | 1 + .../notifications/TvNotificationPanelActivity.java | 32 ++++++++++++++++++++++ 5 files changed, 37 insertions(+), 2 deletions(-) diff --git a/packages/SystemUI/res/layout/tv_notification_panel.xml b/packages/SystemUI/res/layout/tv_notification_panel.xml index 8f00a727b912..eae44c8bcbb8 100644 --- a/packages/SystemUI/res/layout/tv_notification_panel.xml +++ b/packages/SystemUI/res/layout/tv_notification_panel.xml @@ -20,7 +20,7 @@ android:layout_width="@dimen/tv_notification_panel_width" android:layout_height="match_parent" android:layout_gravity="end" - android:background="@color/tv_notification_background_color" + android:background="@android:color/transparent" android:orientation="vertical"> #FFF8F9FA #FFDADCE0 - #383838 + #383838 + #a0383838 #FFFFFF diff --git a/packages/SystemUI/res/values/dimens_tv.xml b/packages/SystemUI/res/values/dimens_tv.xml index 9545bfd088a0..5bd95ebc1c41 100644 --- a/packages/SystemUI/res/values/dimens_tv.xml +++ b/packages/SystemUI/res/values/dimens_tv.xml @@ -16,4 +16,5 @@ --> 360dp + 100dp \ No newline at end of file diff --git a/packages/SystemUI/res/values/styles_tv.xml b/packages/SystemUI/res/values/styles_tv.xml index cb433f3a6009..3e090269699b 100644 --- a/packages/SystemUI/res/values/styles_tv.xml +++ b/packages/SystemUI/res/values/styles_tv.xml @@ -30,5 +30,6 @@ false true @null + true diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/tv/notifications/TvNotificationPanelActivity.java b/packages/SystemUI/src/com/android/systemui/statusbar/tv/notifications/TvNotificationPanelActivity.java index 30f401b91d25..b325b10957f7 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/tv/notifications/TvNotificationPanelActivity.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/tv/notifications/TvNotificationPanelActivity.java @@ -20,15 +20,19 @@ import android.annotation.NonNull; import android.app.Activity; import android.app.NotificationManager; import android.content.Intent; +import android.graphics.drawable.ColorDrawable; import android.os.Bundle; import android.service.notification.StatusBarNotification; import android.util.SparseArray; +import android.view.Gravity; import android.view.View; import androidx.leanback.widget.VerticalGridView; import com.android.systemui.R; +import java.util.function.Consumer; + import javax.inject.Inject; /** @@ -42,6 +46,7 @@ public class TvNotificationPanelActivity extends Activity implements private VerticalGridView mNotificationListView; private View mNotificationPlaceholder; private boolean mPanelAlreadyOpen = false; + private final Consumer mBlurConsumer = this::enableBlur; @Inject public TvNotificationPanelActivity(TvNotificationHandler tvNotificationHandler) { @@ -102,6 +107,33 @@ public class TvNotificationPanelActivity extends Activity implements return false; } + @Override + public void onAttachedToWindow() { + super.onAttachedToWindow(); + getWindow().setGravity(Gravity.END); + getWindowManager().addCrossWindowBlurEnabledListener(mBlurConsumer); + } + + private void enableBlur(boolean enabled) { + if (enabled) { + int blurRadius = getResources().getDimensionPixelSize( + R.dimen.tv_notification_blur_radius); + getWindow().setBackgroundDrawable( + new ColorDrawable(getColor(R.color.tv_notification_blur_background_color))); + getWindow().setBackgroundBlurRadius(blurRadius); + } else { + getWindow().setBackgroundDrawable( + new ColorDrawable(getColor(R.color.tv_notification_default_background_color))); + getWindow().setBackgroundBlurRadius(0); + } + } + + @Override + public void onDetachedFromWindow() { + super.onDetachedFromWindow(); + getWindowManager().removeCrossWindowBlurEnabledListener(mBlurConsumer); + } + @Override public void onDestroy() { super.onDestroy(); -- cgit v1.2.3-59-g8ed1b