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
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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>
|
||||
|
||||
@@ -16,4 +16,5 @@
|
||||
-->
|
||||
<resources>
|
||||
<dimen name="tv_notification_panel_width">360dp</dimen>
|
||||
<dimen name="tv_notification_blur_radius">100dp</dimen>
|
||||
</resources>
|
||||
@@ -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>
|
||||
|
||||
@@ -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();
|
||||
|
||||
Reference in New Issue
Block a user