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

Commit 799f3810 authored by Alison Cichowlas's avatar Alison Cichowlas Committed by Android (Google) Code Review
Browse files

Merge "Tweak temporary RON permission UI to make it clearer." into main

parents ca038b99 f739e48d
Loading
Loading
Loading
Loading
+24 −12
Original line number Diff line number Diff line
@@ -323,31 +323,43 @@ asked for it -->
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:minHeight="60dp"
            android:layout_marginTop="@dimen/notification_importance_button_separation"
            android:gravity="center_vertical"
            android:paddingStart="4dp"
            android:paddingEnd="4dp"
            android:background="@drawable/rounded_corners"
            android:backgroundTint="@androidprv:color/materialColorPrimaryContainer"
            >
            <TextView
                android:id="@+id/promoted_demote"
                android:text="@string/notification_inline_disable_promotion"
                android:layout_width="wrap_content"
                android:id="@+id/promoted_explain_title"
                android:text="@string/live_notifications_title"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_alignParentStart="true"
                android:gravity="start|center_vertical"
                android:minWidth="@dimen/notification_importance_toggle_size"
                android:minHeight="@dimen/notification_importance_toggle_size"
                android:maxWidth="200dp"
                android:padding="16dp"
                android:color="@androidprv:color/materialColorOnPrimary"
                style="@style/TextAppearance.NotificationInfo.Button"/>
            <TextView
                android:id="@+id/promoted_dismiss"
                android:text="@string/notification_inline_dismiss"
                android:id="@+id/promoted_explain"
                android:text="@string/live_notifications_desc"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_below="@id/promoted_explain_title"
                android:gravity="start|center_vertical"
                android:maxWidth="200dp"
                android:padding="16dp"
                style="@style/TextAppearance.NotificationImportanceDetail"/>
            <TextView
                android:id="@+id/promoted_demote"
                android:text="@string/notification_inline_disable_promotion"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_below="@id/promoted_explain"
                android:layout_alignParentEnd="true"
                android:gravity="end|center_vertical"
                android:padding="16dp"
                android:gravity="start|center_vertical"
                android:minWidth="@dimen/notification_importance_toggle_size"
                android:minHeight="@dimen/notification_importance_toggle_size"
                android:maxWidth="125dp"
                android:maxWidth="200dp"
                style="@style/TextAppearance.NotificationInfo.Button"/>
        </RelativeLayout>

+7 −1
Original line number Diff line number Diff line
@@ -2098,7 +2098,13 @@
    <string name="notification_inline_dismiss">Dismiss</string>

    <!-- [CHAR LIMIT=30] Text shown in button used to prevent app from showing Live Updates, for this notification and all future ones -->
    <string name="notification_inline_disable_promotion">Don\'t show again</string>
    <string name="notification_inline_disable_promotion">Don\'t show as pinned</string>

    <!-- Text accompanying the "Show live updates" switch explaining the purpose of the setting -->
    <string name="live_notifications_title">Showing Live Updates</string>

    <!-- Text accompanying the "Show live updates" switch explaining the purpose of the setting -->
    <string name="live_notifications_desc">Pinned notifications display live info from apps, and always appear on the status bar and lock screen</string>

    <!-- Notification: Control panel: Label that displays when the app's notifications cannot be blocked. -->
    <string name="notification_unblockable_desc">These notifications can\'t be modified.</string>
+9 −13
Original line number Diff line number Diff line
@@ -40,6 +40,7 @@ import com.android.systemui.statusbar.notification.collection.NotificationEntry;
public class PromotedNotificationInfo extends NotificationInfo {
    private static final String TAG = "PromotedNotifInfoGuts";
    private INotificationManager mNotificationManager;
    private NotificationGuts mGutsContainer;

    public PromotedNotificationInfo(Context context, AttributeSet attrs) {
        super(context, attrs);
@@ -71,32 +72,27 @@ public class PromotedNotificationInfo extends NotificationInfo {

        mNotificationManager = iNotificationManager;

        bindDismiss(entry.getSbn(), onCloseClick);
        bindDemote(entry.getSbn(), pkg);
    }


    protected void bindDismiss(StatusBarNotification sbn,
            View.OnClickListener onCloseClick) {
        View dismissButton = findViewById(R.id.promoted_dismiss);

        dismissButton.setOnClickListener(onCloseClick);
        dismissButton.setVisibility(!sbn.isNonDismissable()
                && dismissButton.hasOnClickListeners() ? VISIBLE : GONE);

    }

    protected void bindDemote(StatusBarNotification sbn, String packageName) {
        View demoteButton = findViewById(R.id.promoted_demote);
        demoteButton.setOnClickListener(getDemoteClickListener(sbn, packageName));
        demoteButton.setVisibility(demoteButton.hasOnClickListeners() ? VISIBLE : GONE);
    }

    @Override
    public void setGutsParent(NotificationGuts guts) {
        mGutsContainer = guts;
        super.setGutsParent(guts);
    }

    private OnClickListener getDemoteClickListener(StatusBarNotification sbn, String packageName) {
        return ((View unusedView) -> {
        return ((View v) -> {
            try {
                // TODO(b/391661009): Signal AutomaticPromotionCoordinator here
                mNotificationManager.setCanBePromoted(packageName, sbn.getUid(), false, true);
                mGutsContainer.closeControls(v, true);
            } catch (RemoteException e) {
                Log.e(TAG, "Couldn't revoke live update permission", e);
            }