Loading packages/SystemUI/src/com/android/systemui/statusbar/NotificationGuts.java +35 −9 Original line number Diff line number Diff line Loading @@ -95,14 +95,25 @@ public class NotificationGuts extends FrameLayout { /** * Called when the guts view have been told to close, typically after an outside * interaction. Returning {@code true} here will prevent the guts view to close. * interaction. * * @param save whether the state should be saved. * @param force whether the guts view should be forced closed regardless of state. * @return if closing the view has been handled. */ public boolean handleCloseControls(boolean save); public boolean handleCloseControls(boolean save, boolean force); /** * @return whether the notification associated with these guts is set to be removed. */ public boolean willBeRemoved(); /** * @return whether these guts are a leavebehind (e.g. {@link NotificationSnooze}). */ public default boolean isLeavebehind() { return false; } } public interface OnGutsClosedListener { Loading @@ -125,7 +136,7 @@ public class NotificationGuts extends FrameLayout { @Override public void run() { if (mNeedsFalsingProtection && mExposed) { closeControls(-1 /* x */, -1 /* y */, false /* save */); closeControls(-1 /* x */, -1 /* y */, false /* save */, false /* force */); } } }; Loading @@ -144,6 +155,10 @@ public class NotificationGuts extends FrameLayout { addView(mGutsContent.getContentView()); } public GutsContent getGutsContent() { return mGutsContent; } public void resetFalsingCheck() { mHandler.removeCallbacks(mFalsingCheck); if (mNeedsFalsingProtection && mExposed) { Loading Loading @@ -197,21 +212,32 @@ public class NotificationGuts extends FrameLayout { } } public void closeControls(int x, int y, boolean save) { public void closeControls(boolean leavebehinds, boolean controls, int x, int y, boolean force) { if (mGutsContent != null) { if (mGutsContent.isLeavebehind() && leavebehinds) { closeControls(x, y, true /* save */, force); } else if (!mGutsContent.isLeavebehind() && controls) { closeControls(x, y, true /* save */, force); } } } public void closeControls(int x, int y, boolean save, boolean force) { if (getWindowToken() == null) { if (mClosedListener != null) { mClosedListener.onGutsClosed(this); } return; } if (mGutsContent == null || !mGutsContent.handleCloseControls(save)) { if (mGutsContent == null || !mGutsContent.handleCloseControls(save, force)) { animateClose(x, y); } setExposed(false, mNeedsFalsingProtection); if (mClosedListener != null) { mClosedListener.onGutsClosed(this); } } } private void animateClose(int x, int y) { if (x == -1 || y == -1) { Loading packages/SystemUI/src/com/android/systemui/statusbar/NotificationInfo.java +1 −1 Original line number Diff line number Diff line Loading @@ -393,7 +393,7 @@ public class NotificationInfo extends LinearLayout implements NotificationGuts.G } @Override public boolean handleCloseControls(boolean save) { public boolean handleCloseControls(boolean save, boolean force) { if (save && hasImportanceChanged()) { if (mCheckSaveListener != null) { mCheckSaveListener.checkSave(() -> { saveImportance(); }); Loading packages/SystemUI/src/com/android/systemui/statusbar/NotificationSnooze.java +29 −15 Original line number Diff line number Diff line Loading @@ -103,6 +103,18 @@ public class NotificationSnooze extends LinearLayout createOptionViews(); } public boolean isExpanded() { return mExpanded; } public void setSnoozeListener(NotificationSwipeActionHelper listener) { mSnoozeListener = listener; } public void setStatusBarNotification(StatusBarNotification sbn) { mSbn = sbn; } private ArrayList<SnoozeOption> getDefaultSnoozeOptions() { ArrayList<SnoozeOption> options = new ArrayList<>(); options.add(createOption(R.string.snooze_option_15_min, 15)); Loading Loading @@ -203,7 +215,7 @@ public class NotificationSnooze extends LinearLayout final int x = targetLoc[0] - parentLoc[0] + centerX; final int y = targetLoc[1] - parentLoc[1] + centerY; showSnoozeOptions(false); mGutsContainer.closeControls(x, y, false /* save */); mGutsContainer.closeControls(x, y, false /* save */, false /* force */); } } Loading @@ -224,29 +236,31 @@ public class NotificationSnooze extends LinearLayout return this; } public void setStatusBarNotification(StatusBarNotification sbn) { mSbn = sbn; } @Override public void setGutsParent(NotificationGuts guts) { mGutsContainer = guts; } public void setSnoozeListener(NotificationSwipeActionHelper listener) { mSnoozeListener = listener; } @Override public boolean handleCloseControls(boolean save) { // When snooze is closed (i.e. there was interaction outside of the notification) // then we commit the snooze action. if (mSnoozeListener != null && mSelectedOption != null) { public boolean handleCloseControls(boolean save, boolean force) { if (mExpanded && !force) { // Collapse expanded state on outside touch showSnoozeOptions(false); return true; } else if (mSnoozeListener != null && mSelectedOption != null) { // Snooze option selected so commit it mSnoozing = true; mSnoozeListener.snooze(mSbn, mSelectedOption); return true; } else { // The view should actually be closed setSelected(mSnoozeOptions.get(0)); return false; // Return false here so that guts handles closing the view } } // The view should be closed return false; @Override public boolean isLeavebehind() { return true; } } packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationPanelView.java +4 −1 Original line number Diff line number Diff line Loading @@ -523,7 +523,8 @@ public class NotificationPanelView extends PanelView implements mLastCameraLaunchSource = KeyguardBottomAreaView.CAMERA_LAUNCH_SOURCE_AFFORDANCE; } closeQs(); mStatusBar.dismissPopups(); mStatusBar.closeAndSaveGuts(true /* leavebehind */, true /* force */, true /* controls */, -1 /* x */, -1 /* y */, true /* resetMenu */); mNotificationStackScroller.setOverScrollAmount(0f, true /* onTop */, false /* animate */, true /* cancelAnimators */); mNotificationStackScroller.resetScrollPosition(); Loading Loading @@ -1014,6 +1015,7 @@ public class NotificationPanelView extends PanelView implements float height = mQsExpansionHeight - overscrollAmount; setQsExpansion(height); requestPanelHeightUpdate(); mNotificationStackScroller.checkSnoozeLeavebehind(); } private void setQsExpanded(boolean expanded) { Loading Loading @@ -1380,6 +1382,7 @@ public class NotificationPanelView extends PanelView implements animator.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { mNotificationStackScroller.resetCheckSnoozeLeavebehind(); mQsExpansionAnimator = null; if (onFinishRunnable != null) { onFinishRunnable.run(); Loading packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBar.java +36 −25 Original line number Diff line number Diff line Loading @@ -2996,8 +2996,9 @@ public class StatusBar extends SystemUI implements DemoMode, mStatusBarWindowManager.setPanelVisible(false); mStatusBarWindowManager.setForceStatusBarVisible(false); // Close any "App info" popups that might have snuck on-screen dismissPopups(); // Close any guts that might be visible closeAndSaveGuts(true /* removeLeavebehind */, true /* force */, true /* removeControls */, -1 /* x */, -1 /* y */, true /* resetMenu */); runPostCollapseRunnables(); setInteracting(StatusBarManager.WINDOW_STATUS_BAR, false); Loading Loading @@ -4610,6 +4611,7 @@ public class StatusBar extends SystemUI implements DemoMode, public void onDragDownReset() { mStackScroller.setDimmed(true /* dimmed */, true /* animated */); mStackScroller.resetScrollPosition(); mStackScroller.resetCheckSnoozeLeavebehind(); } @Override Loading @@ -4620,6 +4622,7 @@ public class StatusBar extends SystemUI implements DemoMode, @Override public void onTouchSlopExceeded() { mStackScroller.removeLongPressCallback(); mStackScroller.checkSnoozeLeavebehind(); } @Override Loading Loading @@ -5799,8 +5802,10 @@ public class StatusBar extends SystemUI implements DemoMode, if (!g.willBeRemoved() && !row.isRemoved()) { mStackScroller.onHeightChanged(row, !isPanelFullyCollapsed() /* needsAnimation */); } if (mNotificationGutsExposed == g) { mNotificationGutsExposed = null; mGutsMenuItem = null; } }); View gutsView = item.getGutsView(); Loading Loading @@ -5896,7 +5901,8 @@ public class StatusBar extends SystemUI implements DemoMode, final int centerY = done.getHeight() / 2; final int x = doneLocation[0] - rowLocation[0] + centerX; final int y = doneLocation[1] - rowLocation[1] + centerY; dismissPopups(x, y); closeAndSaveGuts(false /* removeLeavebehind */, false /* force */, true /* removeControls */, x, y, true /* resetMenu */); } protected SwipeHelper.LongPressListener getNotificationLongClicker() { Loading @@ -5916,6 +5922,12 @@ public class StatusBar extends SystemUI implements DemoMode, if (row.isDark()) { return false; } if (row.areGutsExposed()) { closeAndSaveGuts(false /* removeLeavebehind */, false /* force */, true /* removeControls */, -1 /* x */, -1 /* y */, true /* resetMenu */); return false; } bindGuts(row, item); NotificationGuts guts = row.getGuts(); Loading @@ -5925,12 +5937,6 @@ public class StatusBar extends SystemUI implements DemoMode, return false; } // Already showing? if (guts.getVisibility() == View.VISIBLE) { dismissPopups(x, y); return false; } mMetricsLogger.action(MetricsEvent.ACTION_NOTE_CONTROLS); // ensure that it's laid but not visible until actually laid out Loading @@ -5944,8 +5950,9 @@ public class StatusBar extends SystemUI implements DemoMode, + "window"); return; } dismissPopups(-1 /* x */, -1 /* y */, false /* resetMenu */, false /* animate */); closeAndSaveGuts(true /* removeLeavebehind */, true /* force */, true /* removeControls */, -1 /* x */, -1 /* y */, false /* resetMenu */); guts.setVisibility(View.VISIBLE); final double horz = Math.max(guts.getWidth() - x, x); final double vert = Math.max(guts.getHeight() - y, y); Loading Loading @@ -5985,20 +5992,23 @@ public class StatusBar extends SystemUI implements DemoMode, return mNotificationGutsExposed; } public void dismissPopups() { dismissPopups(-1 /* x */, -1 /* y */, true /* resetMenu */, false /* animate */); } private void dismissPopups(int x, int y) { dismissPopups(x, y, true /* resetMenu */, false /* animate */); } public void dismissPopups(int x, int y, boolean resetMenu, boolean animate) { /** * Closes guts or notification menus that might be visible and saves any changes. * * @param removeLeavebehinds true if leavebehinds (e.g. snooze) should be closed. * @param force true if guts should be closed regardless of state (used for snooze only). * @param removeControls true if controls (e.g. info) should be closed. * @param x if closed based on touch location, this is the x touch location. * @param y if closed based on touch location, this is the y touch location. * @param resetMenu if any notification menus that might be revealed should be closed. */ public void closeAndSaveGuts(boolean removeLeavebehinds, boolean force, boolean removeControls, int x, int y, boolean resetMenu) { if (mNotificationGutsExposed != null) { mNotificationGutsExposed.closeControls(x, y, true /* save */); mNotificationGutsExposed.closeControls(removeLeavebehinds, removeControls, x, y, force); } if (resetMenu) { mStackScroller.resetExposedMenuView(animate, true /* force */); mStackScroller.resetExposedMenuView(false /* animate */, true /* force */); } } Loading Loading @@ -6527,7 +6537,8 @@ public class StatusBar extends SystemUI implements DemoMode, if (mVisible != visible) { mVisible = visible; if (!visible) { dismissPopups(); closeAndSaveGuts(true /* removeLeavebehind */, true /* force */, true /* removeControls */, -1 /* x */, -1 /* y */, true /* resetMenu */); } } updateVisibleToUser(); Loading Loading
packages/SystemUI/src/com/android/systemui/statusbar/NotificationGuts.java +35 −9 Original line number Diff line number Diff line Loading @@ -95,14 +95,25 @@ public class NotificationGuts extends FrameLayout { /** * Called when the guts view have been told to close, typically after an outside * interaction. Returning {@code true} here will prevent the guts view to close. * interaction. * * @param save whether the state should be saved. * @param force whether the guts view should be forced closed regardless of state. * @return if closing the view has been handled. */ public boolean handleCloseControls(boolean save); public boolean handleCloseControls(boolean save, boolean force); /** * @return whether the notification associated with these guts is set to be removed. */ public boolean willBeRemoved(); /** * @return whether these guts are a leavebehind (e.g. {@link NotificationSnooze}). */ public default boolean isLeavebehind() { return false; } } public interface OnGutsClosedListener { Loading @@ -125,7 +136,7 @@ public class NotificationGuts extends FrameLayout { @Override public void run() { if (mNeedsFalsingProtection && mExposed) { closeControls(-1 /* x */, -1 /* y */, false /* save */); closeControls(-1 /* x */, -1 /* y */, false /* save */, false /* force */); } } }; Loading @@ -144,6 +155,10 @@ public class NotificationGuts extends FrameLayout { addView(mGutsContent.getContentView()); } public GutsContent getGutsContent() { return mGutsContent; } public void resetFalsingCheck() { mHandler.removeCallbacks(mFalsingCheck); if (mNeedsFalsingProtection && mExposed) { Loading Loading @@ -197,21 +212,32 @@ public class NotificationGuts extends FrameLayout { } } public void closeControls(int x, int y, boolean save) { public void closeControls(boolean leavebehinds, boolean controls, int x, int y, boolean force) { if (mGutsContent != null) { if (mGutsContent.isLeavebehind() && leavebehinds) { closeControls(x, y, true /* save */, force); } else if (!mGutsContent.isLeavebehind() && controls) { closeControls(x, y, true /* save */, force); } } } public void closeControls(int x, int y, boolean save, boolean force) { if (getWindowToken() == null) { if (mClosedListener != null) { mClosedListener.onGutsClosed(this); } return; } if (mGutsContent == null || !mGutsContent.handleCloseControls(save)) { if (mGutsContent == null || !mGutsContent.handleCloseControls(save, force)) { animateClose(x, y); } setExposed(false, mNeedsFalsingProtection); if (mClosedListener != null) { mClosedListener.onGutsClosed(this); } } } private void animateClose(int x, int y) { if (x == -1 || y == -1) { Loading
packages/SystemUI/src/com/android/systemui/statusbar/NotificationInfo.java +1 −1 Original line number Diff line number Diff line Loading @@ -393,7 +393,7 @@ public class NotificationInfo extends LinearLayout implements NotificationGuts.G } @Override public boolean handleCloseControls(boolean save) { public boolean handleCloseControls(boolean save, boolean force) { if (save && hasImportanceChanged()) { if (mCheckSaveListener != null) { mCheckSaveListener.checkSave(() -> { saveImportance(); }); Loading
packages/SystemUI/src/com/android/systemui/statusbar/NotificationSnooze.java +29 −15 Original line number Diff line number Diff line Loading @@ -103,6 +103,18 @@ public class NotificationSnooze extends LinearLayout createOptionViews(); } public boolean isExpanded() { return mExpanded; } public void setSnoozeListener(NotificationSwipeActionHelper listener) { mSnoozeListener = listener; } public void setStatusBarNotification(StatusBarNotification sbn) { mSbn = sbn; } private ArrayList<SnoozeOption> getDefaultSnoozeOptions() { ArrayList<SnoozeOption> options = new ArrayList<>(); options.add(createOption(R.string.snooze_option_15_min, 15)); Loading Loading @@ -203,7 +215,7 @@ public class NotificationSnooze extends LinearLayout final int x = targetLoc[0] - parentLoc[0] + centerX; final int y = targetLoc[1] - parentLoc[1] + centerY; showSnoozeOptions(false); mGutsContainer.closeControls(x, y, false /* save */); mGutsContainer.closeControls(x, y, false /* save */, false /* force */); } } Loading @@ -224,29 +236,31 @@ public class NotificationSnooze extends LinearLayout return this; } public void setStatusBarNotification(StatusBarNotification sbn) { mSbn = sbn; } @Override public void setGutsParent(NotificationGuts guts) { mGutsContainer = guts; } public void setSnoozeListener(NotificationSwipeActionHelper listener) { mSnoozeListener = listener; } @Override public boolean handleCloseControls(boolean save) { // When snooze is closed (i.e. there was interaction outside of the notification) // then we commit the snooze action. if (mSnoozeListener != null && mSelectedOption != null) { public boolean handleCloseControls(boolean save, boolean force) { if (mExpanded && !force) { // Collapse expanded state on outside touch showSnoozeOptions(false); return true; } else if (mSnoozeListener != null && mSelectedOption != null) { // Snooze option selected so commit it mSnoozing = true; mSnoozeListener.snooze(mSbn, mSelectedOption); return true; } else { // The view should actually be closed setSelected(mSnoozeOptions.get(0)); return false; // Return false here so that guts handles closing the view } } // The view should be closed return false; @Override public boolean isLeavebehind() { return true; } }
packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationPanelView.java +4 −1 Original line number Diff line number Diff line Loading @@ -523,7 +523,8 @@ public class NotificationPanelView extends PanelView implements mLastCameraLaunchSource = KeyguardBottomAreaView.CAMERA_LAUNCH_SOURCE_AFFORDANCE; } closeQs(); mStatusBar.dismissPopups(); mStatusBar.closeAndSaveGuts(true /* leavebehind */, true /* force */, true /* controls */, -1 /* x */, -1 /* y */, true /* resetMenu */); mNotificationStackScroller.setOverScrollAmount(0f, true /* onTop */, false /* animate */, true /* cancelAnimators */); mNotificationStackScroller.resetScrollPosition(); Loading Loading @@ -1014,6 +1015,7 @@ public class NotificationPanelView extends PanelView implements float height = mQsExpansionHeight - overscrollAmount; setQsExpansion(height); requestPanelHeightUpdate(); mNotificationStackScroller.checkSnoozeLeavebehind(); } private void setQsExpanded(boolean expanded) { Loading Loading @@ -1380,6 +1382,7 @@ public class NotificationPanelView extends PanelView implements animator.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { mNotificationStackScroller.resetCheckSnoozeLeavebehind(); mQsExpansionAnimator = null; if (onFinishRunnable != null) { onFinishRunnable.run(); Loading
packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBar.java +36 −25 Original line number Diff line number Diff line Loading @@ -2996,8 +2996,9 @@ public class StatusBar extends SystemUI implements DemoMode, mStatusBarWindowManager.setPanelVisible(false); mStatusBarWindowManager.setForceStatusBarVisible(false); // Close any "App info" popups that might have snuck on-screen dismissPopups(); // Close any guts that might be visible closeAndSaveGuts(true /* removeLeavebehind */, true /* force */, true /* removeControls */, -1 /* x */, -1 /* y */, true /* resetMenu */); runPostCollapseRunnables(); setInteracting(StatusBarManager.WINDOW_STATUS_BAR, false); Loading Loading @@ -4610,6 +4611,7 @@ public class StatusBar extends SystemUI implements DemoMode, public void onDragDownReset() { mStackScroller.setDimmed(true /* dimmed */, true /* animated */); mStackScroller.resetScrollPosition(); mStackScroller.resetCheckSnoozeLeavebehind(); } @Override Loading @@ -4620,6 +4622,7 @@ public class StatusBar extends SystemUI implements DemoMode, @Override public void onTouchSlopExceeded() { mStackScroller.removeLongPressCallback(); mStackScroller.checkSnoozeLeavebehind(); } @Override Loading Loading @@ -5799,8 +5802,10 @@ public class StatusBar extends SystemUI implements DemoMode, if (!g.willBeRemoved() && !row.isRemoved()) { mStackScroller.onHeightChanged(row, !isPanelFullyCollapsed() /* needsAnimation */); } if (mNotificationGutsExposed == g) { mNotificationGutsExposed = null; mGutsMenuItem = null; } }); View gutsView = item.getGutsView(); Loading Loading @@ -5896,7 +5901,8 @@ public class StatusBar extends SystemUI implements DemoMode, final int centerY = done.getHeight() / 2; final int x = doneLocation[0] - rowLocation[0] + centerX; final int y = doneLocation[1] - rowLocation[1] + centerY; dismissPopups(x, y); closeAndSaveGuts(false /* removeLeavebehind */, false /* force */, true /* removeControls */, x, y, true /* resetMenu */); } protected SwipeHelper.LongPressListener getNotificationLongClicker() { Loading @@ -5916,6 +5922,12 @@ public class StatusBar extends SystemUI implements DemoMode, if (row.isDark()) { return false; } if (row.areGutsExposed()) { closeAndSaveGuts(false /* removeLeavebehind */, false /* force */, true /* removeControls */, -1 /* x */, -1 /* y */, true /* resetMenu */); return false; } bindGuts(row, item); NotificationGuts guts = row.getGuts(); Loading @@ -5925,12 +5937,6 @@ public class StatusBar extends SystemUI implements DemoMode, return false; } // Already showing? if (guts.getVisibility() == View.VISIBLE) { dismissPopups(x, y); return false; } mMetricsLogger.action(MetricsEvent.ACTION_NOTE_CONTROLS); // ensure that it's laid but not visible until actually laid out Loading @@ -5944,8 +5950,9 @@ public class StatusBar extends SystemUI implements DemoMode, + "window"); return; } dismissPopups(-1 /* x */, -1 /* y */, false /* resetMenu */, false /* animate */); closeAndSaveGuts(true /* removeLeavebehind */, true /* force */, true /* removeControls */, -1 /* x */, -1 /* y */, false /* resetMenu */); guts.setVisibility(View.VISIBLE); final double horz = Math.max(guts.getWidth() - x, x); final double vert = Math.max(guts.getHeight() - y, y); Loading Loading @@ -5985,20 +5992,23 @@ public class StatusBar extends SystemUI implements DemoMode, return mNotificationGutsExposed; } public void dismissPopups() { dismissPopups(-1 /* x */, -1 /* y */, true /* resetMenu */, false /* animate */); } private void dismissPopups(int x, int y) { dismissPopups(x, y, true /* resetMenu */, false /* animate */); } public void dismissPopups(int x, int y, boolean resetMenu, boolean animate) { /** * Closes guts or notification menus that might be visible and saves any changes. * * @param removeLeavebehinds true if leavebehinds (e.g. snooze) should be closed. * @param force true if guts should be closed regardless of state (used for snooze only). * @param removeControls true if controls (e.g. info) should be closed. * @param x if closed based on touch location, this is the x touch location. * @param y if closed based on touch location, this is the y touch location. * @param resetMenu if any notification menus that might be revealed should be closed. */ public void closeAndSaveGuts(boolean removeLeavebehinds, boolean force, boolean removeControls, int x, int y, boolean resetMenu) { if (mNotificationGutsExposed != null) { mNotificationGutsExposed.closeControls(x, y, true /* save */); mNotificationGutsExposed.closeControls(removeLeavebehinds, removeControls, x, y, force); } if (resetMenu) { mStackScroller.resetExposedMenuView(animate, true /* force */); mStackScroller.resetExposedMenuView(false /* animate */, true /* force */); } } Loading Loading @@ -6527,7 +6537,8 @@ public class StatusBar extends SystemUI implements DemoMode, if (mVisible != visible) { mVisible = visible; if (!visible) { dismissPopups(); closeAndSaveGuts(true /* removeLeavebehind */, true /* force */, true /* removeControls */, -1 /* x */, -1 /* y */, true /* resetMenu */); } } updateVisibleToUser(); Loading