diff options
author | Jorim Jaggi <jjaggi@google.com> | 2014-08-05 16:22:30 +0200 |
---|---|---|
committer | Jorim Jaggi <jjaggi@google.com> | 2014-08-05 17:00:22 +0000 |
commit | 62a7c831d54d0a552f059e70176ccf7ac77e57f4 (patch) | |
tree | b5018d2897bb934915068e2e506d2741fb1d8c80 | |
parent | 106c16fbd9601ba23eea9b0f13c8f00933f67ee6 (diff) | |
download | frameworks_base-62a7c831d54d0a552f059e70176ccf7ac77e57f4.zip frameworks_base-62a7c831d54d0a552f059e70176ccf7ac77e57f4.tar.gz frameworks_base-62a7c831d54d0a552f059e70176ccf7ac77e57f4.tar.bz2 |
Clean up hiden notifications on Keyguard handling
Change-Id: Ifeabfdd1ed8c11b0796cc79bba81752518921be3
3 files changed, 57 insertions, 62 deletions
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/BaseStatusBar.java b/packages/SystemUI/src/com/android/systemui/statusbar/BaseStatusBar.java index af92e49..12c3dd5 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/BaseStatusBar.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/BaseStatusBar.java @@ -1364,13 +1364,9 @@ public abstract class BaseStatusBar extends SystemUI implements * Updates expanded, dimmed and locked states of notification rows. */ protected void updateRowStates() { - int maxKeyguardNotifications = getMaxKeyguardNotifications(); - mKeyguardIconOverflowContainer.getIconsView().removeAllViews(); - ArrayList<Entry> activeNotifications = mNotificationData.getActiveNotifications(); final int N = activeNotifications.size(); - int visibleNotifications = 0; boolean onKeyguard = mState == StatusBarState.KEYGUARD; for (int i = 0; i < N; i++) { NotificationData.Entry entry = activeNotifications.get(i); @@ -1383,38 +1379,7 @@ public abstract class BaseStatusBar extends SystemUI implements entry.row.setSystemExpanded(top); } } - boolean showOnKeyguard = shouldShowOnKeyguard(entry.notification); - if (onKeyguard && (visibleNotifications >= maxKeyguardNotifications - || !showOnKeyguard)) { - entry.row.setVisibility(View.GONE); - if (showOnKeyguard) { - mKeyguardIconOverflowContainer.getIconsView().addNotification(entry); - } - } else { - boolean wasGone = entry.row.getVisibility() == View.GONE; - entry.row.setVisibility(View.VISIBLE); - if (wasGone) { - // notify the scroller of a child addition - mStackScroller.generateAddAnimation(entry.row, true /* fromMoreCard */); - } - visibleNotifications++; - } } - - if (onKeyguard && mKeyguardIconOverflowContainer.getIconsView().getChildCount() > 0) { - mKeyguardIconOverflowContainer.setVisibility(View.VISIBLE); - } else { - mKeyguardIconOverflowContainer.setVisibility(View.GONE); - } - - mStackScroller.changeViewPosition(mKeyguardIconOverflowContainer, - mStackScroller.getChildCount() - 3); - mStackScroller.changeViewPosition(mDismissView, mStackScroller.getChildCount() - 2); - mStackScroller.changeViewPosition(mEmptyShadeView, mStackScroller.getChildCount() - 1); - } - - private boolean shouldShowOnKeyguard(StatusBarNotification sbn) { - return mShowLockscreenNotifications && !mNotificationData.isAmbient(sbn.getKey()); } protected void setZenMode(int mode) { diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java index ae7d500..e2a9702 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java @@ -158,6 +158,7 @@ import java.io.PrintWriter; import java.util.ArrayList; import java.util.Collection; import java.util.Collections; +import java.util.HashSet; import java.util.List; public class PhoneStatusBar extends BaseStatusBar implements DemoMode, @@ -337,6 +338,8 @@ public class PhoneStatusBar extends BaseStatusBar implements DemoMode, : null; private int mNavigationIconHints = 0; + private final HashSet<View> mOverflowNotifications = new HashSet<>(); + private final HashSet<View> mOldOverflowNotifications = new HashSet<>(); // ensure quick settings is disabled until the current user makes it through the setup wizard private boolean mUserSetup = false; @@ -1355,13 +1358,33 @@ public class PhoneStatusBar extends BaseStatusBar implements DemoMode, private void updateNotificationShade() { if (mStackScroller == null) return; + int speedbumpIndex = -1; + int maxKeyguardNotifications = getMaxKeyguardNotifications(); + mKeyguardIconOverflowContainer.getIconsView().removeAllViews(); + int visibleNotifications = 0; + boolean onKeyguard = mState == StatusBarState.KEYGUARD; + mOldOverflowNotifications.clear(); + mOldOverflowNotifications.addAll(mOverflowNotifications); + ArrayList<Entry> activeNotifications = mNotificationData.getActiveNotifications(); - ArrayList<ExpandableNotificationRow> toShow = new ArrayList<>(activeNotifications.size()); + ArrayList<View> toShow = new ArrayList<>(activeNotifications.size()); final int N = activeNotifications.size(); for (int i=0; i<N; i++) { Entry ent = activeNotifications.get(i); int vis = ent.notification.getNotification().visibility; + // Decide whether to hide to notification because of Keyguard showing. + boolean showOnKeyguard = mShowLockscreenNotifications + && !mNotificationData.isAmbient(ent.key); + if (onKeyguard && (visibleNotifications >= maxKeyguardNotifications + || !showOnKeyguard)) { + if (showOnKeyguard) { + mKeyguardIconOverflowContainer.getIconsView().addNotification(ent); + mOverflowNotifications.add(ent.row); + } + continue; + } + // Display public version of the notification if we need to redact. final boolean hideSensitive = !userAllowsPrivateNotificationsInPublic(ent.notification.getUserId()); @@ -1379,12 +1402,23 @@ public class PhoneStatusBar extends BaseStatusBar implements DemoMode, } } toShow.add(ent.row); + visibleNotifications++; + + // Handle speed bump. + if (speedbumpIndex == -1 && mNotificationData.isAmbient(ent.key)) { + speedbumpIndex = visibleNotifications-1; + } + } + + if (onKeyguard && mKeyguardIconOverflowContainer.getIconsView().getChildCount() > 0) { + toShow.add(mKeyguardIconOverflowContainer); } ArrayList<View> toRemove = new ArrayList<View>(); for (int i=0; i< mStackScroller.getChildCount(); i++) { View child = mStackScroller.getChildAt(i); - if (!toShow.contains(child) && child instanceof ExpandableNotificationRow) { + if ((child instanceof ExpandableNotificationRow + || child == mKeyguardIconOverflowContainer) && !toShow.contains(child)) { toRemove.add(child); } } @@ -1396,6 +1430,9 @@ public class PhoneStatusBar extends BaseStatusBar implements DemoMode, View v = toShow.get(i); if (v.getParent() == null) { mStackScroller.addView(v); + if (mOldOverflowNotifications.contains(v)) { + mStackScroller.notifyAddFromMoreCard(v); + } } } @@ -1422,7 +1459,15 @@ public class PhoneStatusBar extends BaseStatusBar implements DemoMode, j++; } updateRowStates(); - updateSpeedbump(); + + mStackScroller.changeViewPosition(mEmptyShadeView, + mStackScroller.getChildCount() - 1); + mStackScroller.changeViewPosition(mDismissView, + mStackScroller.getChildCount() - 2); + mStackScroller.changeViewPosition(mKeyguardIconOverflowContainer, + mStackScroller.getChildCount() - 3); + mStackScroller.updateSpeedBumpIndex(speedbumpIndex); + updateClearAll(); updateEmptyShadeView(); @@ -1444,23 +1489,6 @@ public class PhoneStatusBar extends BaseStatusBar implements DemoMode, mNotificationPanel.setShadeEmpty(showEmptyShade); } - private void updateSpeedbump() { - int speedbumpIndex = -1; - int currentIndex = 0; - ArrayList<Entry> activeNotifications = mNotificationData.getActiveNotifications(); - final int N = activeNotifications.size(); - for (int i = 0; i < N; i++) { - Entry entry = activeNotifications.get(i); - if (entry.row.getVisibility() != View.GONE && - mNotificationData.isAmbient(entry.key)) { - speedbumpIndex = currentIndex; - break; - } - currentIndex++; - } - mStackScroller.updateSpeedBumpIndex(speedbumpIndex); - } - @Override protected void updateNotifications() { // TODO: Move this into updateNotificationIcons()? @@ -2971,7 +2999,7 @@ public class PhoneStatusBar extends BaseStatusBar implements DemoMode, repositionNavigationBar(); updateExpandedViewPos(EXPANDED_LEAVE_ALONE); updateShowSearchHoldoff(); - updateRowStates(); + updateNotificationShade(); } @Override diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/stack/NotificationStackScrollLayout.java b/packages/SystemUI/src/com/android/systemui/statusbar/stack/NotificationStackScrollLayout.java index fcca5fa..6c6bd30 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/stack/NotificationStackScrollLayout.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/stack/NotificationStackScrollLayout.java @@ -1520,7 +1520,7 @@ public class NotificationStackScrollLayout extends ViewGroup super.onViewAdded(child); mStackScrollAlgorithm.notifyChildrenChanged(this); ((ExpandableView) child).setOnHeightChangedListener(this); - generateAddAnimation(child, false /* fromMoreCard */); + generateAddAnimation(child); } public void setAnimationsEnabled(boolean animationsEnabled) { @@ -1535,19 +1535,21 @@ public class NotificationStackScrollLayout extends ViewGroup * Generate an animation for an added child view. * * @param child The view to be added. - * @param fromMoreCard Whether this add is coming from the "more" card on lockscreen. */ - public void generateAddAnimation(View child, boolean fromMoreCard) { + private void generateAddAnimation(View child) { if (mIsExpanded && mAnimationsEnabled && !mChangePositionInProgress) { // Generate Animations mChildrenToAddAnimated.add(child); - if (fromMoreCard) { - mFromMoreCardAdditions.add(child); - } mNeedsAnimation = true; } } + public void notifyAddFromMoreCard(View v) { + if (mChildrenToAddAnimated.contains(v)) { + mFromMoreCardAdditions.add(v); + } + } + /** * Change the position of child to a new location * |