summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Alison Cichowlas <asc@google.com> 2025-03-13 08:08:32 -0700
committer Android (Google) Code Review <android-gerrit@google.com> 2025-03-13 08:08:32 -0700
commit5028abaad3044dff0d91efdd050b9156b7ea6b5b (patch)
treee05a8810d67bb2e4b69467ff4f2cae50a63c0bd6
parent278def075ed05834be238f854951bb6cc0c608b8 (diff)
parent82a05b63f767c67081b2e89c6bc226ea9965b955 (diff)
Merge "Notifications: Inline demote item." into main
-rw-r--r--packages/SystemUI/aconfig/systemui.aconfig9
-rw-r--r--packages/SystemUI/multivalentTests/src/com/android/systemui/statusbar/notification/row/NotificationMenuRowTest.java41
-rw-r--r--packages/SystemUI/res/drawable/unpin_icon.xml10
-rw-r--r--packages/SystemUI/res/layout/promoted_permission_guts.xml73
-rw-r--r--packages/SystemUI/res/values/strings.xml6
-rw-r--r--packages/SystemUI/src/com/android/systemui/statusbar/notification/row/ExpandableNotificationRow.java36
-rw-r--r--packages/SystemUI/src/com/android/systemui/statusbar/notification/row/ExpandableOutlineView.java3
-rw-r--r--packages/SystemUI/src/com/android/systemui/statusbar/notification/row/NotificationGutsManager.java29
-rw-r--r--packages/SystemUI/src/com/android/systemui/statusbar/notification/row/NotificationMenuRow.java50
-rw-r--r--packages/SystemUI/src/com/android/systemui/statusbar/notification/row/PromotedNotificationInfo.java1
-rw-r--r--packages/SystemUI/src/com/android/systemui/statusbar/notification/row/PromotedPermissionGutsContent.java173
-rw-r--r--packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/NotificationStackScrollLayout.java5
-rw-r--r--packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/row/ExpandableNotificationRowTest.java2
13 files changed, 377 insertions, 61 deletions
diff --git a/packages/SystemUI/aconfig/systemui.aconfig b/packages/SystemUI/aconfig/systemui.aconfig
index 4693377654f8..228bff6327eb 100644
--- a/packages/SystemUI/aconfig/systemui.aconfig
+++ b/packages/SystemUI/aconfig/systemui.aconfig
@@ -2021,7 +2021,14 @@ flag {
flag {
name: "permission_helper_ui_rich_ongoing"
namespace: "systemui"
- description: "[RONs] Guards inline permission helper for demoting RONs"
+ description: "[RONs] Guards inline permission helper for demoting RONs [Guts/card version]"
+ bug: "379186372"
+}
+
+flag {
+ name: "permission_helper_inline_ui_rich_ongoing"
+ namespace: "systemui"
+ description: "[RONs] Guards inline permission helper for demoting RONs [Inline version]"
bug: "379186372"
}
diff --git a/packages/SystemUI/multivalentTests/src/com/android/systemui/statusbar/notification/row/NotificationMenuRowTest.java b/packages/SystemUI/multivalentTests/src/com/android/systemui/statusbar/notification/row/NotificationMenuRowTest.java
index ce120c51db6a..4019c7082b36 100644
--- a/packages/SystemUI/multivalentTests/src/com/android/systemui/statusbar/notification/row/NotificationMenuRowTest.java
+++ b/packages/SystemUI/multivalentTests/src/com/android/systemui/statusbar/notification/row/NotificationMenuRowTest.java
@@ -101,46 +101,6 @@ public class NotificationMenuRowTest extends LeakCheckedTest {
row.resetMenu();
}
-
- @Test
- public void testNoAppOpsInSlowSwipe() {
- when(mRow.getShowSnooze()).thenReturn(false);
- Settings.Global.putInt(mContext.getContentResolver(), SHOW_NEW_NOTIF_DISMISS, 0);
-
- NotificationMenuRow row = new NotificationMenuRow(mContext, mPeopleNotificationIdentifier);
- row.createMenu(mRow);
-
- ViewGroup container = (ViewGroup) row.getMenuView();
- // noti blocking
- assertEquals(1, container.getChildCount());
- }
-
- @Test
- public void testNoSnoozeInSlowSwipe() {
- when(mRow.getShowSnooze()).thenReturn(false);
- Settings.Global.putInt(mContext.getContentResolver(), SHOW_NEW_NOTIF_DISMISS, 0);
-
- NotificationMenuRow row = new NotificationMenuRow(mContext, mPeopleNotificationIdentifier);
- row.createMenu(mRow);
-
- ViewGroup container = (ViewGroup) row.getMenuView();
- // just for noti blocking
- assertEquals(1, container.getChildCount());
- }
-
- @Test
- public void testSnoozeInSlowSwipe() {
- when(mRow.getShowSnooze()).thenReturn(true);
- Settings.Global.putInt(mContext.getContentResolver(), SHOW_NEW_NOTIF_DISMISS, 0);
-
- NotificationMenuRow row = new NotificationMenuRow(mContext, mPeopleNotificationIdentifier);
- row.createMenu(mRow);
-
- ViewGroup container = (ViewGroup) row.getMenuView();
- // one for snooze and one for noti blocking
- assertEquals(2, container.getChildCount());
- }
-
@Test
public void testSlowSwipe_newDismiss() {
when(mRow.getShowSnooze()).thenReturn(true);
@@ -235,6 +195,7 @@ public class NotificationMenuRowTest extends LeakCheckedTest {
new NotificationMenuRow(mContext, mPeopleNotificationIdentifier));
doReturn(30f).when(row).getSnapBackThreshold();
doReturn(50f).when(row).getDismissThreshold();
+ doReturn(70).when(row).getSpaceForMenu();
when(row.isMenuOnLeft()).thenReturn(true);
when(row.getTranslation()).thenReturn(40f);
diff --git a/packages/SystemUI/res/drawable/unpin_icon.xml b/packages/SystemUI/res/drawable/unpin_icon.xml
new file mode 100644
index 000000000000..4e2e15893884
--- /dev/null
+++ b/packages/SystemUI/res/drawable/unpin_icon.xml
@@ -0,0 +1,10 @@
+<vector xmlns:android="http://schemas.android.com/apk/res/android"
+ android:width="24dp"
+ android:height="24dp"
+ android:viewportWidth="960"
+ android:viewportHeight="960"
+ android:tint="?attr/colorControlNormal">
+ <path
+ android:fillColor="@android:color/white"
+ android:pathData="M680,120L680,200L640,200L640,527L560,447L560,200L400,200L400,287L313,200L280,167L280,167L280,120L680,120ZM480,920L440,880L440,640L240,640L240,560L320,480L320,434L56,168L112,112L848,848L790,904L526,640L520,640L520,880L480,920ZM354,560L446,560L402,516L400,514L354,560ZM480,367L480,367L480,367L480,367ZM402,516L402,516L402,516L402,516Z"/>
+</vector>
diff --git a/packages/SystemUI/res/layout/promoted_permission_guts.xml b/packages/SystemUI/res/layout/promoted_permission_guts.xml
new file mode 100644
index 000000000000..50e5ae3c05ed
--- /dev/null
+++ b/packages/SystemUI/res/layout/promoted_permission_guts.xml
@@ -0,0 +1,73 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ Copyright 2017, 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.
+-->
+
+<com.android.systemui.statusbar.notification.row.PromotedPermissionGutsContent
+ xmlns:android="http://schemas.android.com/apk/res/android"
+ xmlns:androidprv="http://schemas.android.com/apk/prv/res/android"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:orientation="vertical"
+ android:paddingTop="2dp"
+ android:paddingBottom="2dp"
+ android:background="@androidprv:color/materialColorSurfaceContainerHigh"
+ android:theme="@style/Theme.SystemUI"
+ >
+
+ <RelativeLayout
+ android:id="@+id/promoted_guts"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:minHeight="@dimen/notification_2025_min_height">
+
+ <ImageView
+ android:id="@+id/unpin_icon"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:src="@drawable/unpin_icon"
+ android:layout_alignParentTop="true"
+ android:layout_centerHorizontal="true"
+ android:padding="@dimen/notification_importance_button_padding"
+ />
+
+ <TextView
+ android:id="@+id/demote_explain"
+ android:layout_width="400dp"
+ android:layout_height="wrap_content"
+ android:layout_alignParentLeft="true"
+ android:layout_below="@id/unpin_icon"
+ android:layout_toLeftOf="@id/undo"
+ android:padding="@*android:dimen/notification_content_margin_end"
+ android:textColor="@androidprv:color/materialColorOnSurface"
+ android:minWidth="@dimen/min_clickable_item_size"
+ android:minHeight="@dimen/min_clickable_item_size"
+ style="@style/TextAppearance.NotificationInfo.Button" />
+
+ <TextView
+ android:id="@+id/undo"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_below="@id/unpin_icon"
+ android:layout_alignParentRight="true"
+ android:padding="@*android:dimen/notification_content_margin_end"
+ android:textColor="@androidprv:color/materialColorOnSurface"
+ android:minWidth="@dimen/min_clickable_item_size"
+ android:minHeight="@dimen/min_clickable_item_size"
+ android:text="@string/snooze_undo"
+ style="@style/TextAppearance.NotificationInfo.Button" />
+ </RelativeLayout>
+
+</com.android.systemui.statusbar.notification.row.PromotedPermissionGutsContent>
diff --git a/packages/SystemUI/res/values/strings.xml b/packages/SystemUI/res/values/strings.xml
index 3fdb98b4e00b..7ef03aef8530 100644
--- a/packages/SystemUI/res/values/strings.xml
+++ b/packages/SystemUI/res/values/strings.xml
@@ -4195,6 +4195,12 @@
All Quick Settings tiles will reset to the device’s original settings
</string>
+
+ <!-- Content of the Reset Tiles dialog in QS Edit mode. [CHAR LIMIT=NONE] -->
+ <string name="demote_explain_text">
+ <xliff:g id="application" example= "Superfast Food Delivery">%1$s</xliff:g> will no longer show Live Updates here. You can change this any time in Settings.
+ </string>
+
<!-- Template that joins disabled message with the label for the voice over. [CHAR LIMIT=NONE] -->
<string name="volume_slider_disabled_message_template"><xliff:g example="Notification" id="stream_name">%1$s</xliff:g>, <xliff:g example="Disabled because ring is muted" id="disabled_message">%2$s</xliff:g></string>
</resources>
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/ExpandableNotificationRow.java b/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/ExpandableNotificationRow.java
index 86ef0ff2a51e..c4fde20b612f 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/ExpandableNotificationRow.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/ExpandableNotificationRow.java
@@ -2680,30 +2680,58 @@ public class ExpandableNotificationRow extends ActivatableNotificationView
}
/**
+ * Whether to allow dismissal with the whole-row translation animation.
+ *
+ * If true, either animation is permissible.
+ * If false, usingRTX behavior is forbidden, only clipping animation should be used.
+ *
+ * Usually either is OK, except for promoted notifications, where we always need to
+ * dismiss with content clipping/partial translation animation instead, so that we
+ * can show the demotion options.
+ * @return
+ */
+ private boolean allowDismissUsingRowTranslationX() {
+ if (Flags.permissionHelperInlineUiRichOngoing()) {
+ return !isPromotedOngoing();
+ } else {
+ // Don't change behavior unless the flag is on.
+ return true;
+ }
+ }
+
+ /**
* Set the dismiss behavior of the view.
*
* @param usingRowTranslationX {@code true} if the view should translate using regular
* translationX, otherwise the contents will be
* translated.
+ * @param forceUpdateChildren {@code true} to force initialization, {@code false} if lazy
+ * behavior is OK.
*/
@Override
- public void setDismissUsingRowTranslationX(boolean usingRowTranslationX) {
- if (usingRowTranslationX != mDismissUsingRowTranslationX) {
+ public void setDismissUsingRowTranslationX(boolean usingRowTranslationX,
+ boolean forceUpdateChildren) {
+ // Before updating dismiss behavior, make sure this is an allowable configuration for this
+ // notification.
+ usingRowTranslationX = usingRowTranslationX && allowDismissUsingRowTranslationX();
+
+ if (forceUpdateChildren || (usingRowTranslationX != mDismissUsingRowTranslationX)) {
// In case we were already transitioning, let's switch over!
float previousTranslation = getTranslation();
if (previousTranslation != 0) {
setTranslation(0);
}
- super.setDismissUsingRowTranslationX(usingRowTranslationX);
+ super.setDismissUsingRowTranslationX(usingRowTranslationX, forceUpdateChildren);
if (previousTranslation != 0) {
setTranslation(previousTranslation);
}
+
if (mChildrenContainer != null) {
List<ExpandableNotificationRow> notificationChildren =
mChildrenContainer.getAttachedChildren();
for (int i = 0; i < notificationChildren.size(); i++) {
ExpandableNotificationRow child = notificationChildren.get(i);
- child.setDismissUsingRowTranslationX(usingRowTranslationX);
+ child.setDismissUsingRowTranslationX(usingRowTranslationX, forceUpdateChildren);
}
}
}
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/ExpandableOutlineView.java b/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/ExpandableOutlineView.java
index 80cf818e985f..6c990df5d05e 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/ExpandableOutlineView.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/ExpandableOutlineView.java
@@ -292,7 +292,8 @@ public abstract class ExpandableOutlineView extends ExpandableView {
* translationX, otherwise the contents will be
* translated.
*/
- public void setDismissUsingRowTranslationX(boolean usingRowTranslationX) {
+ public void setDismissUsingRowTranslationX(boolean usingRowTranslationX,
+ boolean forceUpdateChildren) {
mDismissUsingRowTranslationX = usingRowTranslationX;
}
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/NotificationGutsManager.java b/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/NotificationGutsManager.java
index cdb78d99538b..f4e01bf718d9 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/NotificationGutsManager.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/NotificationGutsManager.java
@@ -29,6 +29,7 @@ import android.content.pm.ShortcutManager;
import android.net.Uri;
import android.os.Bundle;
import android.os.Handler;
+import android.os.RemoteException;
import android.os.UserHandle;
import android.os.UserManager;
import android.provider.Settings;
@@ -309,6 +310,7 @@ public class NotificationGutsManager implements NotifGutsViewManager, CoreStarta
});
View gutsView = item.getGutsView();
+
try {
if (gutsView instanceof NotificationSnooze) {
initializeSnoozeView(row, (NotificationSnooze) gutsView);
@@ -322,6 +324,8 @@ public class NotificationGutsManager implements NotifGutsViewManager, CoreStarta
(PartialConversationInfo) gutsView);
} else if (gutsView instanceof FeedbackInfo) {
initializeFeedbackInfo(row, (FeedbackInfo) gutsView);
+ } else if (gutsView instanceof PromotedPermissionGutsContent) {
+ initializeDemoteView(row, (PromotedPermissionGutsContent) gutsView);
}
return true;
} catch (Exception e) {
@@ -351,6 +355,31 @@ public class NotificationGutsManager implements NotifGutsViewManager, CoreStarta
}
/**
+ * Sets up the {@link NotificationSnooze} inside the notification row's guts.
+ *
+ * @param row view to set up the guts for
+ * @param demoteGuts view to set up/bind within {@code row}
+ */
+ private void initializeDemoteView(
+ final ExpandableNotificationRow row,
+ PromotedPermissionGutsContent demoteGuts) {
+ StatusBarNotification sbn = row.getEntry().getSbn();
+ demoteGuts.setStatusBarNotification(sbn);
+ demoteGuts.setOnDemoteAction(new View.OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ try {
+ // TODO(b/391661009): Signal AutomaticPromotionCoordinator here
+ mNotificationManager.setCanBePromoted(
+ sbn.getPackageName(), sbn.getUid(), false, true);
+ } catch (RemoteException e) {
+ Log.e(TAG, "Couldn't revoke live update permission", e);
+ }
+ }
+ });
+ }
+
+ /**
* Sets up the {@link FeedbackInfo} inside the notification row's guts.
*
* @param row view to set up the guts for
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/NotificationMenuRow.java b/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/NotificationMenuRow.java
index 977936fa34fc..da8e44af15f3 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/NotificationMenuRow.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/NotificationMenuRow.java
@@ -273,6 +273,7 @@ public class NotificationMenuRow implements NotificationMenuRowPlugin, View.OnCl
} else if (personNotifType >= PeopleNotificationIdentifier.TYPE_FULL_PERSON) {
mInfoItem = createConversationItem(mContext);
} else if (android.app.Flags.uiRichOngoing()
+ && android.app.Flags.apiRichOngoing()
&& Flags.permissionHelperUiRichOngoing()
&& sbn.getNotification().isPromotedOngoing()) {
mInfoItem = createPromotedItem(mContext);
@@ -285,6 +286,12 @@ public class NotificationMenuRow implements NotificationMenuRowPlugin, View.OnCl
}
mRightMenuItems.add(mInfoItem);
mRightMenuItems.add(mFeedbackItem);
+ if (android.app.Flags.uiRichOngoing() && Flags.permissionHelperInlineUiRichOngoing()
+ && entry.isPromotedOngoing()) {
+ mRightMenuItems.add(createDemoteItem(mContext));
+ }
+
+
mLeftMenuItems.addAll(mRightMenuItems);
populateMenuViews();
@@ -306,15 +313,19 @@ public class NotificationMenuRow implements NotificationMenuRowPlugin, View.OnCl
} else {
mMenuContainer = new FrameLayout(mContext);
}
+
final int showDismissSetting = Settings.Global.getInt(mContext.getContentResolver(),
Settings.Global.SHOW_NEW_NOTIF_DISMISS, /* default = */ 1);
final boolean newFlowHideShelf = showDismissSetting == 1;
- if (newFlowHideShelf) {
- return;
- }
- List<MenuItem> menuItems = mOnLeft ? mLeftMenuItems : mRightMenuItems;
- for (int i = 0; i < menuItems.size(); i++) {
- addMenuView(menuItems.get(i), mMenuContainer);
+
+ // Populate menu items if we are using the new permission helper (U+) or if we are using
+ // the very old dismiss setting (SC-).
+ // TODO: SHOW_NEW_NOTIF_DISMISS==0 case can likely be removed.
+ if (Flags.permissionHelperInlineUiRichOngoing() || !newFlowHideShelf) {
+ List<MenuItem> menuItems = mOnLeft ? mLeftMenuItems : mRightMenuItems;
+ for (int i = 0; i < menuItems.size(); i++) {
+ addMenuView(menuItems.get(i), mMenuContainer);
+ }
}
}
@@ -678,6 +689,15 @@ public class NotificationMenuRow implements NotificationMenuRowPlugin, View.OnCl
return snooze;
}
+ static MenuItem createDemoteItem(Context context) {
+ PromotedPermissionGutsContent demoteContent =
+ (PromotedPermissionGutsContent) LayoutInflater.from(context).inflate(
+ R.layout.promoted_permission_guts, null, false);
+ MenuItem info = new NotificationMenuItem(context, null, demoteContent,
+ R.drawable.unpin_icon);
+ return info;
+ }
+
static NotificationMenuItem createConversationItem(Context context) {
Resources res = context.getResources();
String infoDescription = res.getString(R.string.notification_menu_gear_description);
@@ -685,7 +705,7 @@ public class NotificationMenuRow implements NotificationMenuRowPlugin, View.OnCl
(NotificationConversationInfo) LayoutInflater.from(context).inflate(
R.layout.notification_conversation_info, null, false);
return new NotificationMenuItem(context, infoDescription, infoContent,
- R.drawable.ic_settings);
+ NotificationMenuItem.OMIT_FROM_SWIPE_MENU);
}
static NotificationMenuItem createPromotedItem(Context context) {
@@ -695,7 +715,7 @@ public class NotificationMenuRow implements NotificationMenuRowPlugin, View.OnCl
(PromotedNotificationInfo) LayoutInflater.from(context).inflate(
R.layout.promoted_notification_info, null, false);
return new NotificationMenuItem(context, infoDescription, infoContent,
- R.drawable.ic_settings);
+ NotificationMenuItem.OMIT_FROM_SWIPE_MENU);
}
static NotificationMenuItem createPartialConversationItem(Context context) {
@@ -705,7 +725,7 @@ public class NotificationMenuRow implements NotificationMenuRowPlugin, View.OnCl
(PartialConversationInfo) LayoutInflater.from(context).inflate(
R.layout.partial_conversation_info, null, false);
return new NotificationMenuItem(context, infoDescription, infoContent,
- R.drawable.ic_settings);
+ NotificationMenuItem.OMIT_FROM_SWIPE_MENU);
}
static NotificationMenuItem createInfoItem(Context context) {
@@ -717,14 +737,14 @@ public class NotificationMenuRow implements NotificationMenuRowPlugin, View.OnCl
NotificationInfo infoContent = (NotificationInfo) LayoutInflater.from(context).inflate(
layoutId, null, false);
return new NotificationMenuItem(context, infoDescription, infoContent,
- R.drawable.ic_settings);
+ NotificationMenuItem.OMIT_FROM_SWIPE_MENU);
}
static MenuItem createFeedbackItem(Context context) {
FeedbackInfo feedbackContent = (FeedbackInfo) LayoutInflater.from(context).inflate(
R.layout.feedback_info, null, false);
MenuItem info = new NotificationMenuItem(context, null, feedbackContent,
- -1 /*don't show in slow swipe menu */);
+ NotificationMenuItem.OMIT_FROM_SWIPE_MENU);
return info;
}
@@ -761,6 +781,10 @@ public class NotificationMenuRow implements NotificationMenuRowPlugin, View.OnCl
@Override
public boolean isWithinSnapMenuThreshold() {
+ if (getSpaceForMenu() == 0) {
+ // don't snap open if there are no items
+ return false;
+ }
float translation = getTranslation();
float snapBackThreshold = getSnapBackThreshold();
float targetRight = getDismissThreshold();
@@ -802,6 +826,10 @@ public class NotificationMenuRow implements NotificationMenuRowPlugin, View.OnCl
}
public static class NotificationMenuItem implements MenuItem {
+
+ // Constant signaling that this MenuItem should not appear in slow swipe.
+ public static final int OMIT_FROM_SWIPE_MENU = -1;
+
View mMenuView;
GutsContent mGutsContent;
String mContentDescription;
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/PromotedNotificationInfo.java b/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/PromotedNotificationInfo.java
index 01ee788f7fd7..769f0b5a4fa4 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/PromotedNotificationInfo.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/PromotedNotificationInfo.java
@@ -80,6 +80,7 @@ public class PromotedNotificationInfo extends NotificationInfo {
assistantFeedbackController, metricsLogger, onCloseClick);
mNotificationManager = iNotificationManager;
+
mPackageDemotionInteractor = packageDemotionInteractor;
bindDemote(entry.getSbn(), pkg);
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/PromotedPermissionGutsContent.java b/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/PromotedPermissionGutsContent.java
new file mode 100644
index 000000000000..222a1f4d8adf
--- /dev/null
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/PromotedPermissionGutsContent.java
@@ -0,0 +1,173 @@
+/*
+ * Copyright (C) 2017 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.
+ */
+
+package com.android.systemui.statusbar.notification.row;
+
+import android.content.Context;
+import android.os.Bundle;
+import android.service.notification.StatusBarNotification;
+import android.util.AttributeSet;
+import android.view.View;
+import android.widget.LinearLayout;
+import android.widget.TextView;
+
+import com.android.internal.logging.MetricsLogger;
+import com.android.systemui.res.R;
+
+/**
+ * This GutsContent shows an explanatory interstitial telling the user they've just revoked this
+ * app's permission to post Promoted/Live notifications.
+ * If the guts are dismissed without further action, the revocation is committed.
+ * If the user hits undo, the permission is not revoked.
+ */
+public class PromotedPermissionGutsContent extends LinearLayout
+ implements NotificationGuts.GutsContent, View.OnClickListener {
+
+ private static final String TAG = "SnoozyPromotedGuts";
+
+ private NotificationGuts mGutsContainer;
+ private StatusBarNotification mSbn;
+
+ private TextView mUndoButton;
+
+ private MetricsLogger mMetricsLogger = new MetricsLogger();
+ private OnClickListener mDemoteAction;
+
+ public PromotedPermissionGutsContent(Context context, AttributeSet attrs) {
+ super(context, attrs);
+ }
+
+
+ @Override
+ protected void onFinishInflate() {
+ super.onFinishInflate();
+ mUndoButton = (TextView) findViewById(R.id.undo);
+ mUndoButton.setOnClickListener(this);
+ mUndoButton.setContentDescription(
+ getContext().getString(R.string.snooze_undo_content_description));
+
+ }
+
+ @Override
+ protected void onAttachedToWindow() {
+ super.onAttachedToWindow();
+ dispatchConfigurationChanged(getResources().getConfiguration());
+ }
+
+ /**
+ * Update the content description of the snooze view based on the snooze option and whether the
+ * snooze options are expanded or not.
+ * For example, this will be something like "Collapsed\u2029Snooze for 1 hour". The paragraph
+ * separator is added to introduce a break in speech, to match what TalkBack does by default
+ * when you e.g. press on a notification.
+ */
+ private void updateContentDescription() {
+ //
+ }
+
+
+ @Override
+ public boolean performAccessibilityActionInternal(int action, Bundle arguments) {
+ if (super.performAccessibilityActionInternal(action, arguments)) {
+ return true;
+ }
+ if (action == R.id.action_snooze_undo) {
+ undoDemote(mUndoButton);
+ return true;
+ }
+ return false;
+ }
+
+ /**
+ * TODO docs
+ * @param sbn
+ */
+ public void setStatusBarNotification(StatusBarNotification sbn) {
+ mSbn = sbn;
+ TextView demoteExplanation = (TextView) findViewById(R.id.demote_explain);
+ demoteExplanation.setText(mContext.getResources().getString(R.string.demote_explain_text,
+ mSbn.getPackageName()));
+ }
+
+ @Override
+ public void onClick(View v) {
+ if (mGutsContainer != null) {
+ mGutsContainer.resetFalsingCheck();
+ }
+ final int id = v.getId();
+ if (id == R.id.undo) {
+ undoDemote(v);
+ }
+
+ }
+
+ private void undoDemote(View v) {
+ // Don't commit the demote action, instead log the undo and dismiss the view.
+ mGutsContainer.closeControls(v, /* save= */ false);
+ }
+
+ @Override
+ public int getActualHeight() {
+ return getHeight();
+ }
+
+ @Override
+ public boolean willBeRemoved() {
+ return false;
+ }
+
+ @Override
+ public View getContentView() {
+ return this;
+ }
+
+ @Override
+ public void setGutsParent(NotificationGuts guts) {
+ mGutsContainer = guts;
+ }
+
+ @Override
+ public boolean handleCloseControls(boolean save, boolean force) {
+ if (!save) {
+ // Undo changes and let the guts handle closing the view
+ return false;
+ } else {
+ // Commit demote action.
+ mDemoteAction.onClick(this);
+ return false;
+ }
+ }
+
+ @Override
+ public boolean isLeavebehind() {
+ return true;
+ }
+
+ @Override
+ public boolean shouldBeSavedOnClose() {
+ return true;
+ }
+
+ @Override
+ public boolean needsFalsingProtection() {
+ return false;
+ }
+
+ public void setOnDemoteAction(OnClickListener demoteAction) {
+ mDemoteAction = demoteAction;
+ }
+
+}
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/NotificationStackScrollLayout.java b/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/NotificationStackScrollLayout.java
index 9fea75048e3e..503256accff0 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/NotificationStackScrollLayout.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/NotificationStackScrollLayout.java
@@ -3220,8 +3220,7 @@ public class NotificationStackScrollLayout
updateAnimationState(child);
updateChronometerForChild(child);
if (child instanceof ExpandableNotificationRow row) {
- row.setDismissUsingRowTranslationX(mDismissUsingRowTranslationX);
-
+ row.setDismissUsingRowTranslationX(mDismissUsingRowTranslationX, /* force= */ true);
}
}
@@ -6157,7 +6156,7 @@ public class NotificationStackScrollLayout
View child = getChildAt(i);
if (child instanceof ExpandableNotificationRow) {
((ExpandableNotificationRow) child).setDismissUsingRowTranslationX(
- dismissUsingRowTranslationX);
+ dismissUsingRowTranslationX, /* force= */ false);
}
}
}
diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/row/ExpandableNotificationRowTest.java b/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/row/ExpandableNotificationRowTest.java
index 2ea4e7f67b3c..bc7ab9d4fe3c 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/row/ExpandableNotificationRowTest.java
+++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/row/ExpandableNotificationRowTest.java
@@ -582,7 +582,7 @@ public class ExpandableNotificationRowTest extends SysuiTestCase {
public void testIconScrollXAfterTranslationAndReset() throws Exception {
ExpandableNotificationRow group = mNotificationTestHelper.createGroup();
- group.setDismissUsingRowTranslationX(false);
+ group.setDismissUsingRowTranslationX(false, false);
group.setTranslation(50);
assertEquals(50, -group.getEntry().getIcons().getShelfIcon().getScrollX());