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

Commit a07ce03d authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Wait to unlock before changing notification importance" into oc-dev

parents 2692dafa 5278d3d3
Loading
Loading
Loading
Loading
+19 −4
Original line number Diff line number Diff line
@@ -76,6 +76,7 @@ public class NotificationInfo extends LinearLayout implements NotificationGuts.G
    private TextView mNumChannelsView;
    private View mChannelDisabledView;
    private Switch mChannelEnabledSwitch;
    private CheckSaveListener mCheckSaveListener;

    private NotificationGuts mGutsContainer;

@@ -83,6 +84,13 @@ public class NotificationInfo extends LinearLayout implements NotificationGuts.G
        super(context, attrs);
    }

    // Specify a CheckSaveListener to override when/if the user's changes are committed.
    public interface CheckSaveListener {
        // Invoked when importance has changed and the NotificationInfo wants to try to save it.
        // Listener should run saveImportance unless the change should be canceled.
        void checkSave(Runnable saveImportance);
    }

    public interface OnSettingsClickListener {
        void onClick(View v, NotificationChannel channel, int appUid);
    }
@@ -92,11 +100,14 @@ public class NotificationInfo extends LinearLayout implements NotificationGuts.G
            final String pkg,
            final List<NotificationChannel> notificationChannels,
            OnSettingsClickListener onSettingsClick,
            OnClickListener onDoneClick, final Set<String> nonBlockablePkgs)
            OnClickListener onDoneClick,
            CheckSaveListener checkSaveListener,
            final Set<String> nonBlockablePkgs)
            throws RemoteException {
        mINotificationManager = iNotificationManager;
        mPkg = pkg;
        mNotificationChannels = notificationChannels;
        mCheckSaveListener = checkSaveListener;
        boolean isSingleDefaultChannel = false;
        if (mNotificationChannels.isEmpty()) {
            throw new IllegalArgumentException("bindNotification requires at least one channel");
@@ -238,7 +249,7 @@ public class NotificationInfo extends LinearLayout implements NotificationGuts.G
        doneButton.setOnClickListener(onDoneClick);
    }

    public boolean hasImportanceChanged() {
    private boolean hasImportanceChanged() {
        return mSingleNotificationChannel != null &&
                mStartingUserImportance != getSelectedImportance();
    }
@@ -316,9 +327,13 @@ public class NotificationInfo extends LinearLayout implements NotificationGuts.G

    @Override
    public boolean handleCloseControls(boolean save) {
        if (save) {
        if (save && hasImportanceChanged()) {
            if (mCheckSaveListener != null) {
                mCheckSaveListener.checkSave(() -> { saveImportance(); });
            } else {
                saveImportance();
            }
        }
        return false;
    }
}
+10 −12
Original line number Diff line number Diff line
@@ -5778,21 +5778,19 @@ public class StatusBar extends SystemUI implements DemoMode,
                startAppNotificationSettingsActivity(pkg, appUid, channel);
            };
            final View.OnClickListener onDoneClick = (View v) -> {
                saveAndCloseNotificationMenu(info, row, guts, v);
            };
            final NotificationInfo.CheckSaveListener checkSaveListener = (Runnable saveImportance) -> {
                // If the user has security enabled, show challenge if the setting is changed.
                if (info.hasImportanceChanged()
                        && isLockscreenPublicMode(userHandle.getIdentifier())
                if (isLockscreenPublicMode(userHandle.getIdentifier())
                        && (mState == StatusBarState.KEYGUARD
                                || mState == StatusBarState.SHADE_LOCKED)) {
                    OnDismissAction dismissAction = new OnDismissAction() {
                        @Override
                        public boolean onDismiss() {
                            saveAndCloseNotificationMenu(info, row, guts, v);
                    onLockedNotificationImportanceChange(() -> {
                        saveImportance.run();
                        return true;
                        }
                    };
                    onLockedNotificationImportanceChange(dismissAction);
                    });
                } else {
                    saveAndCloseNotificationMenu(info, row, guts, v);
                    saveImportance.run();
                }
            };

@@ -5815,7 +5813,7 @@ public class StatusBar extends SystemUI implements DemoMode,
            }
            try {
                info.bindNotification(pmUser, iNotificationManager, pkg, new ArrayList(channels),
                        onSettingsClick, onDoneClick, mNonBlockablePkgs);
                        onSettingsClick, onDoneClick, checkSaveListener, mNonBlockablePkgs);
            } catch (RemoteException e) {
                Log.e(TAG, e.toString());
            }
+64 −51

File changed.

Preview size limit exceeded, changes collapsed.