Loading packages/SystemUI/src/com/android/systemui/statusbar/NotificationInfo.java +19 −4 Original line number Diff line number Diff line Loading @@ -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; Loading @@ -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); } Loading @@ -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"); Loading Loading @@ -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(); } Loading Loading @@ -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; } } packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBar.java +10 −12 Original line number Diff line number Diff line Loading @@ -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(); } }; Loading @@ -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()); } Loading packages/SystemUI/tests/src/com/android/systemui/statusbar/NotificationInfoTest.java +64 −51 File changed.Preview size limit exceeded, changes collapsed. Show changes Loading
packages/SystemUI/src/com/android/systemui/statusbar/NotificationInfo.java +19 −4 Original line number Diff line number Diff line Loading @@ -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; Loading @@ -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); } Loading @@ -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"); Loading Loading @@ -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(); } Loading Loading @@ -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; } }
packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBar.java +10 −12 Original line number Diff line number Diff line Loading @@ -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(); } }; Loading @@ -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()); } Loading
packages/SystemUI/tests/src/com/android/systemui/statusbar/NotificationInfoTest.java +64 −51 File changed.Preview size limit exceeded, changes collapsed. Show changes