summaryrefslogtreecommitdiffstats
path: root/packages
diff options
context:
space:
mode:
authorDanny Baumann <dannybaumann@web.de>2013-07-30 07:23:51 +0000
committerGerrit Code Review <gerrit@cyanogenmod.org>2013-07-30 07:23:51 +0000
commitea139154bea8497f8c0d493d597cfcdb8be13477 (patch)
tree7997079d5de3b450c7d36d16f2ab27f3407835b8 /packages
parent246a27b7ba7f3c8bb4328abbb5cd3e7c2a024d48 (diff)
parentc233a5bdf397b423c54f038935fcaf05b6d143e6 (diff)
downloadframeworks_base-ea139154bea8497f8c0d493d597cfcdb8be13477.zip
frameworks_base-ea139154bea8497f8c0d493d597cfcdb8be13477.tar.gz
frameworks_base-ea139154bea8497f8c0d493d597cfcdb8be13477.tar.bz2
Merge "Improve notification shade collapse code." into cm-10.1
Diffstat (limited to 'packages')
-rw-r--r--packages/SystemUI/res/values/ids.xml2
-rw-r--r--packages/SystemUI/src/com/android/systemui/SwipeHelper.java10
-rw-r--r--packages/SystemUI/src/com/android/systemui/recent/RecentsHorizontalScrollView.java2
-rw-r--r--packages/SystemUI/src/com/android/systemui/recent/RecentsVerticalScrollView.java2
-rw-r--r--packages/SystemUI/src/com/android/systemui/statusbar/BaseStatusBar.java29
-rw-r--r--packages/SystemUI/src/com/android/systemui/statusbar/NotificationData.java18
-rw-r--r--packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java107
-rw-r--r--packages/SystemUI/src/com/android/systemui/statusbar/policy/IntruderAlertView.java2
-rw-r--r--packages/SystemUI/src/com/android/systemui/statusbar/policy/NotificationRowLayout.java16
-rw-r--r--packages/SystemUI/src/com/android/systemui/statusbar/tablet/TabletStatusBar.java5
-rw-r--r--packages/SystemUI/src/com/android/systemui/statusbar/tv/TvStatusBar.java5
11 files changed, 107 insertions, 91 deletions
diff --git a/packages/SystemUI/res/values/ids.xml b/packages/SystemUI/res/values/ids.xml
index f7bc614..bd24f0f 100644
--- a/packages/SystemUI/res/values/ids.xml
+++ b/packages/SystemUI/res/values/ids.xml
@@ -19,6 +19,6 @@
<item type="id" name="expandable_tag" />
<item type="id" name="user_expanded_tag" />
<item type="id" name="user_lock_tag" />
- <item type="id" name="user_cleared_tag" />
+ <item type="id" name="user_dismissed_tag" />
<item type="id" name="status_bar_cling_stub" />
</resources>
diff --git a/packages/SystemUI/src/com/android/systemui/SwipeHelper.java b/packages/SystemUI/src/com/android/systemui/SwipeHelper.java
index 7be5949..ceb8654 100644
--- a/packages/SystemUI/src/com/android/systemui/SwipeHelper.java
+++ b/packages/SystemUI/src/com/android/systemui/SwipeHelper.java
@@ -257,10 +257,6 @@ public class SwipeHelper implements Gefingerpoken {
* @param velocity The desired pixels/second speed at which the view should move
*/
public void dismissChild(final View view, float velocity) {
- dismissChild(view, velocity, false);
- }
-
- private void dismissChild(final View view, float velocity, final boolean fromUser) {
final View animView = mCallback.getChildContentView(view);
final boolean canAnimViewBeDismissed = mCallback.canChildBeDismissed(view);
float newPos;
@@ -288,7 +284,7 @@ public class SwipeHelper implements Gefingerpoken {
anim.setDuration(duration);
anim.addListener(new AnimatorListenerAdapter() {
public void onAnimationEnd(Animator animation) {
- mCallback.onChildDismissed(view, fromUser);
+ mCallback.onChildDismissed(view);
animView.setLayerType(View.LAYER_TYPE_NONE, null);
}
});
@@ -378,7 +374,7 @@ public class SwipeHelper implements Gefingerpoken {
if (dismissChild) {
// flingadingy
- dismissChild(mCurrView, childSwipedFastEnough ? velocity : 0f, true);
+ dismissChild(mCurrView, childSwipedFastEnough ? velocity : 0f);
} else {
// snappity
mCallback.onDragCancelled(mCurrView);
@@ -399,7 +395,7 @@ public class SwipeHelper implements Gefingerpoken {
void onBeginDrag(View v);
- void onChildDismissed(View v, boolean fromUser);
+ void onChildDismissed(View v);
void onDragCancelled(View v);
}
diff --git a/packages/SystemUI/src/com/android/systemui/recent/RecentsHorizontalScrollView.java b/packages/SystemUI/src/com/android/systemui/recent/RecentsHorizontalScrollView.java
index b59acad..989ada0 100644
--- a/packages/SystemUI/src/com/android/systemui/recent/RecentsHorizontalScrollView.java
+++ b/packages/SystemUI/src/com/android/systemui/recent/RecentsHorizontalScrollView.java
@@ -212,7 +212,7 @@ public class RecentsHorizontalScrollView extends HorizontalScrollView
mSwipeHelper.dismissChild(v, 0);
}
- public void onChildDismissed(View v, boolean fromUser) {
+ public void onChildDismissed(View v) {
addToRecycledViews(v);
mLinearLayout.removeView(v);
mCallback.handleSwipe(v);
diff --git a/packages/SystemUI/src/com/android/systemui/recent/RecentsVerticalScrollView.java b/packages/SystemUI/src/com/android/systemui/recent/RecentsVerticalScrollView.java
index d6f417d..0f48751 100644
--- a/packages/SystemUI/src/com/android/systemui/recent/RecentsVerticalScrollView.java
+++ b/packages/SystemUI/src/com/android/systemui/recent/RecentsVerticalScrollView.java
@@ -220,7 +220,7 @@ public class RecentsVerticalScrollView extends ScrollView
mSwipeHelper.dismissChild(v, 0);
}
- public void onChildDismissed(View v, boolean fromUser) {
+ public void onChildDismissed(View v) {
addToRecycledViews(v);
mLinearLayout.removeView(v);
mCallback.handleSwipe(v);
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/BaseStatusBar.java b/packages/SystemUI/src/com/android/systemui/statusbar/BaseStatusBar.java
index 9f57e72..b2d4e85 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/BaseStatusBar.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/BaseStatusBar.java
@@ -108,6 +108,10 @@ public abstract class BaseStatusBar extends SystemUI implements
public static final int EXPANDED_LEAVE_ALONE = -10000;
public static final int EXPANDED_FULL_OPEN = -10001;
+ private static final boolean CLOSE_PANEL_WHEN_EMPTIED = true;
+ private static final int COLLAPSE_AFTER_DISMISS_DELAY = 200;
+ private static final int COLLAPSE_AFTER_REMOVE_DELAY = 400;
+
protected CommandQueue mCommandQueue;
protected IStatusBarService mBarService;
protected H mHandler = createHandler();
@@ -130,6 +134,13 @@ public abstract class BaseStatusBar extends SystemUI implements
protected FrameLayout mStatusBarContainer;
+ private Runnable mPanelCollapseRunnable = new Runnable() {
+ @Override
+ public void run() {
+ animateCollapsePanels(CommandQueue.FLAG_EXCLUDE_NONE);
+ }
+ };
+
/**
* An interface for navigation key bars to allow status bars to signal which keys are
* currently of interest to the user.<br>
@@ -940,14 +951,14 @@ public abstract class BaseStatusBar extends SystemUI implements
updateExpansionStates();
updateNotificationIcons();
- if (entry.userCleared() && !mNotificationData.hasClearableItems()) {
- // wait a bit to make the user aware of what's happening
- mHandler.postDelayed(new Runnable() {
- @Override
- public void run() {
- animateCollapsePanels(CommandQueue.FLAG_EXCLUDE_NONE);
- }
- }, 225);
+ if (CLOSE_PANEL_WHEN_EMPTIED && isNotificationPanelFullyVisible()) {
+ if (entry.userDismissed() && !mNotificationData.hasClearableItems()) {
+ mHandler.removeCallbacks(mPanelCollapseRunnable);
+ mHandler.postDelayed(mPanelCollapseRunnable, COLLAPSE_AFTER_DISMISS_DELAY);
+ } else if (mNotificationData.size() == 0) {
+ mHandler.removeCallbacks(mPanelCollapseRunnable);
+ mHandler.postDelayed(mPanelCollapseRunnable, COLLAPSE_AFTER_REMOVE_DELAY);
+ }
}
return entry.notification;
@@ -989,6 +1000,7 @@ public abstract class BaseStatusBar extends SystemUI implements
}
updateExpansionStates();
updateNotificationIcons();
+ mHandler.removeCallbacks(mPanelCollapseRunnable);
return iconView;
}
@@ -1036,6 +1048,7 @@ public abstract class BaseStatusBar extends SystemUI implements
protected abstract void tick(IBinder key, StatusBarNotification n, boolean firstTime);
protected abstract void updateExpandedViewPos(int expandedPosition);
protected abstract int getExpandedViewMaxHeight();
+ protected abstract boolean isNotificationPanelFullyVisible();
protected abstract boolean shouldDisableNavbarGestures();
protected boolean isTopNotification(ViewGroup parent, NotificationData.Entry entry) {
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/NotificationData.java b/packages/SystemUI/src/com/android/systemui/statusbar/NotificationData.java
index 7222c08..a457167 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/NotificationData.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/NotificationData.java
@@ -66,10 +66,10 @@ public class NotificationData {
return NotificationData.getUserExpanded(row);
}
/**
- * Return whether the entry has been manually cleared by the user.
+ * Return whether the entry has been manually dismissed by the user.
*/
- public boolean userCleared() {
- return NotificationData.getUserCleared(row);
+ public boolean userDismissed() {
+ return NotificationData.getUserDismissed(row);
}
/**
* Set the flag indicating that this was manually expanded by the user.
@@ -235,16 +235,16 @@ public class NotificationData {
}
/**
- * Return whether the entry was cleared by the user.
+ * Return whether the entry was dismissed by the user.
*/
- public static boolean getUserCleared(View row) {
- return readBooleanTag(row, R.id.user_cleared_tag);
+ public static boolean getUserDismissed(View row) {
+ return readBooleanTag(row, R.id.user_dismissed_tag);
}
/**
- * Set whether the entry is being touched by the user.
+ * Set whether the entry was dismissed by the user.
*/
- public static boolean setUserCleared(View row) {
- return writeBooleanTag(row, R.id.user_cleared_tag, true);
+ public static boolean setUserDismissed(View row) {
+ return writeBooleanTag(row, R.id.user_dismissed_tag, true);
}
}
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 82b6538..7d98350 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java
@@ -290,7 +290,6 @@ public class PhoneStatusBar extends BaseStatusBar {
float mFlingVelocity;
int mFlingY;
int[] mAbsPos = new int[2];
- Runnable mPostCollapseCleanup = null;
private Animator mLightsOutAnimation;
private Animator mLightsOnAnimation;
@@ -340,6 +339,19 @@ public class PhoneStatusBar extends BaseStatusBar {
}
};
+ private final Runnable mNotifyClearAll = new Runnable() {
+ @Override
+ public void run() {
+ if (DEBUG) {
+ Slog.v(TAG, "Notifying status bar of notification clear");
+ }
+ try {
+ mPile.setViewRemoval(true);
+ mBarService.onClearAllNotifications();
+ } catch (RemoteException ex) { }
+ }
+ };
+
class SettingsObserver extends ContentObserver {
SettingsObserver(Handler handler) {
super(handler);
@@ -1878,11 +1890,6 @@ public class PhoneStatusBar extends BaseStatusBar {
// Close any "App info" popups that might have snuck on-screen
dismissPopups();
-
- if (mPostCollapseCleanup != null) {
- mPostCollapseCleanup.run();
- mPostCollapseCleanup = null;
- }
}
/**
@@ -2487,6 +2494,11 @@ public class PhoneStatusBar extends BaseStatusBar {
}
@Override
+ protected boolean isNotificationPanelFullyVisible() {
+ return mExpandedVisible && !mAnimating && !isShowingSettings();
+ }
+
+ @Override
public void updateExpandedViewPos(int thingy) {
if (DEBUG) Slog.v(TAG, "updateExpandedViewPos");
@@ -2522,7 +2534,7 @@ public class PhoneStatusBar extends BaseStatusBar {
@Override
public void onClick(View v) {
synchronized (mNotificationData) {
- // animate-swipe all dismissable notifications, then animate the shade closed
+ // animate-swipe all dismissable notifications
int numChildren = mPile.getChildCount();
int scrollTop = mScrollView.getScrollY();
@@ -2535,63 +2547,40 @@ public class PhoneStatusBar extends BaseStatusBar {
snapshot.add(child);
}
}
+
if (snapshot.isEmpty()) {
animateCollapsePanels(CommandQueue.FLAG_EXCLUDE_NONE);
return;
}
- new Thread(new Runnable() {
- @Override
- public void run() {
- // Decrease the delay for every row we animate to give the sense of
- // accelerating the swipes
- final int ROW_DELAY_DECREMENT = 10;
- int currentDelay = 140;
- int totalDelay = 0;
-
- // Set the shade-animating state to avoid doing other work during
- // all of these animations. In particular, avoid layout and
- // redrawing when collapsing the shade.
- mPile.setViewRemoval(false);
-
- mPostCollapseCleanup = new Runnable() {
- @Override
- public void run() {
- if (DEBUG) {
- Slog.v(TAG, "running post-collapse cleanup");
- }
- try {
- mPile.setViewRemoval(true);
- mBarService.onClearAllNotifications();
- } catch (Exception ex) { }
- }
- };
-
- View sampleView = snapshot.get(0);
- int width = sampleView.getWidth();
- final int velocity = width * 8; // 1000/8 = 125 ms duration
- for (final View _v : snapshot) {
- mHandler.postDelayed(new Runnable() {
- @Override
- public void run() {
- mPile.dismissRowAnimated(_v, velocity);
- }
- }, totalDelay);
- currentDelay = Math.max(50, currentDelay - ROW_DELAY_DECREMENT);
- totalDelay += currentDelay;
+
+ // Decrease the delay for every row we animate to give the sense of
+ // accelerating the swipes
+ final int ROW_DELAY_DECREMENT = 10;
+ int currentDelay = 140;
+ int totalDelay = 0;
+
+ // Set the shade-animating state to avoid doing other work, in
+ // particular layout and redrawing, during all of these animations.
+ mPile.setViewRemoval(false);
+
+ View sampleView = snapshot.get(0);
+ int width = sampleView.getWidth();
+ final int velocity = width * 8; // 1000/8 = 125 ms duration
+ for (final View _v : snapshot) {
+ mHandler.postDelayed(new Runnable() {
+ @Override
+ public void run() {
+ mPile.dismissRowAnimated(_v, velocity);
}
- // Delay the collapse animation until after all swipe animations have
- // finished. Provide some buffer because there may be some extra delay
- // before actually starting each swipe animation. Ideally, we'd
- // synchronize the end of those animations with the start of the collaps
- // exactly.
- mHandler.postDelayed(new Runnable() {
- @Override
- public void run() {
- animateCollapsePanels(CommandQueue.FLAG_EXCLUDE_NONE);
- }
- }, totalDelay + 225);
- }
- }).start();
+ }, totalDelay);
+ currentDelay = Math.max(50, currentDelay - ROW_DELAY_DECREMENT);
+ totalDelay += currentDelay;
+ }
+
+ // After ending all animations, tell the service to remove the
+ // notifications, which will trigger collapsing the shade
+ final View lastEntry = snapshot.get(snapshot.size() - 1);
+ mPile.runOnDismiss(lastEntry, mNotifyClearAll);
}
}
};
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/policy/IntruderAlertView.java b/packages/SystemUI/src/com/android/systemui/statusbar/policy/IntruderAlertView.java
index 9cbd853..4adc6c0 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/policy/IntruderAlertView.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/policy/IntruderAlertView.java
@@ -101,7 +101,7 @@ public class IntruderAlertView extends LinearLayout implements SwipeHelper.Callb
return true;
}
- public void onChildDismissed(View v, boolean fromUser) {
+ public void onChildDismissed(View v) {
Slog.v(TAG, "User swiped intruder to dismiss");
mBar.dismissIntruder();
}
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/policy/NotificationRowLayout.java b/packages/SystemUI/src/com/android/systemui/statusbar/policy/NotificationRowLayout.java
index 9e9dec2..2aa0f5e 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/policy/NotificationRowLayout.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/policy/NotificationRowLayout.java
@@ -61,7 +61,8 @@ public class NotificationRowLayout
HashMap<View, ValueAnimator> mDisappearingViews = new HashMap<View, ValueAnimator>();
private SwipeHelper mSwipeHelper;
-
+ private HashMap<View, Runnable> mDismissRunnables = new HashMap<View, Runnable>();
+
private OnSizeChangedListener mOnSizeChangedListener;
// Flag set during notification removal animation to avoid causing too much work until
@@ -111,6 +112,10 @@ public class NotificationRowLayout
mOnSizeChangedListener = l;
}
+ public void runOnDismiss(View child, Runnable runnable) {
+ mDismissRunnables.put(child, runnable);
+ }
+
@Override
public void onWindowFocusChanged(boolean hasWindowFocus) {
super.onWindowFocusChanged(hasWindowFocus);
@@ -166,14 +171,17 @@ public class NotificationRowLayout
return NotificationData.setUserLocked(v, userLocked);
}
- public void onChildDismissed(View v, boolean fromUser) {
+ public void onChildDismissed(View v) {
if (DEBUG) Slog.v(TAG, "onChildDismissed: " + v + " mRemoveViews=" + mRemoveViews);
final View veto = v.findViewById(R.id.veto);
if (veto != null && veto.getVisibility() != View.GONE && mRemoveViews) {
veto.performClick();
}
- if (fromUser) {
- NotificationData.setUserCleared(v);
+ NotificationData.setUserDismissed(v);
+
+ Runnable dismissRunnable = mDismissRunnables.remove(v);
+ if (dismissRunnable != null) {
+ dismissRunnable.run();
}
}
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/tablet/TabletStatusBar.java b/packages/SystemUI/src/com/android/systemui/statusbar/tablet/TabletStatusBar.java
index d40bff6..2c9da8f 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/tablet/TabletStatusBar.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/tablet/TabletStatusBar.java
@@ -383,6 +383,11 @@ public class TabletStatusBar extends BaseStatusBar implements
return getNotificationPanelHeight();
}
+ @Override
+ protected boolean isNotificationPanelFullyVisible() {
+ return mNotificationPanel.getVisibility() == View.VISIBLE;
+ }
+
private int getNotificationPanelHeight() {
final Resources res = mContext.getResources();
final Display d = mWindowManager.getDefaultDisplay();
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/tv/TvStatusBar.java b/packages/SystemUI/src/com/android/systemui/statusbar/tv/TvStatusBar.java
index d43e4a4..509e97c 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/tv/TvStatusBar.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/tv/TvStatusBar.java
@@ -137,6 +137,11 @@ public class TvStatusBar extends BaseStatusBar {
}
@Override
+ protected boolean isNotificationPanelFullyVisible() {
+ return false;
+ }
+
+ @Override
protected boolean shouldDisableNavbarGestures() {
return true;
}