Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 50545f71 authored by Jacqueline Bronger's avatar Jacqueline Bronger Committed by Android (Google) Code Review
Browse files

Merge "Blur the background of aosp notification panel" into sc-dev

parents f41a01c8 c4acfcc4
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -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">

    <TextView
+2 −1
Original line number Diff line number Diff line
@@ -34,6 +34,7 @@
    <color name="tv_volume_dialog_seek_bar_fill">#FFF8F9FA</color>
    <color name="tv_volume_dialog_accent">#FFDADCE0</color>

    <color name="tv_notification_background_color">#383838</color>
    <color name="tv_notification_default_background_color">#383838</color>
    <color name="tv_notification_blur_background_color">#a0383838</color>
    <color name="tv_notification_text_color">#FFFFFF</color>
</resources>
+1 −0
Original line number Diff line number Diff line
@@ -16,4 +16,5 @@
  -->
<resources>
    <dimen name="tv_notification_panel_width">360dp</dimen>
    <dimen name="tv_notification_blur_radius">100dp</dimen>
</resources>
 No newline at end of file
+1 −0
Original line number Diff line number Diff line
@@ -30,5 +30,6 @@
        <item name="android:backgroundDimEnabled">false</item>
        <item name="android:windowNoTitle">true</item>
        <item name="android:windowContentOverlay">@null</item>
        <item name="android:windowIsFloating">true</item>
    </style>
</resources>
+32 −0
Original line number Diff line number Diff line
@@ -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<Boolean> 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();