8787import com .android .systemui .statusbar .policy .BatteryController ;
8888import com .android .systemui .statusbar .policy .LocationController ;
8989import com .android .systemui .statusbar .policy .NetworkController ;
90+ import com .android .systemui .statusbar .policy .NotificationRowLayout ;
9091
9192public class PhoneStatusBar extends StatusBar {
9293 static final String TAG = "PhoneStatusBar" ;
@@ -103,8 +104,10 @@ public class PhoneStatusBar extends StatusBar {
103104 static final int EXPANDED_LEAVE_ALONE = -10000 ;
104105 static final int EXPANDED_FULL_OPEN = -10001 ;
105106
106- private static final int MSG_ANIMATE = 1000 ;
107- private static final int MSG_ANIMATE_REVEAL = 1001 ;
107+ private static final int MSG_ANIMATE = 100 ;
108+ private static final int MSG_ANIMATE_REVEAL = 101 ;
109+ private static final int MSG_OPEN_NOTIFICATION_PANEL = 1000 ;
110+ private static final int MSG_CLOSE_NOTIFICATION_PANEL = 1001 ;
108111 private static final int MSG_SHOW_INTRUDER = 1002 ;
109112 private static final int MSG_HIDE_INTRUDER = 1003 ;
110113 private static final int MSG_OPEN_RECENTS_PANEL = 1020 ;
@@ -165,7 +168,7 @@ public class PhoneStatusBar extends StatusBar {
165168
166169 // all notifications
167170 NotificationData mNotificationData = new NotificationData ();
168- ViewGroup mPile ;
171+ NotificationRowLayout mPile ;
169172
170173 // position
171174 int [] mPositionTmp = new int [2 ];
@@ -324,14 +327,15 @@ public void onSystemUiVisibilityChange(int visibility) {
324327
325328 mExpandedDialog = new ExpandedDialog (context );
326329 mExpandedView = expanded ;
327- mPile = (ViewGroup )expanded .findViewById (R .id .latestItems );
330+ mPile = (NotificationRowLayout )expanded .findViewById (R .id .latestItems );
328331 mExpandedContents = mPile ; // was: expanded.findViewById(R.id.notificationLinearLayout);
329332 mNoNotificationsTitle = (TextView )expanded .findViewById (R .id .noNotificationsTitle );
330333 mNoNotificationsTitle .setVisibility (View .GONE ); // disabling for now
331334
332335 mClearButton = expanded .findViewById (R .id .clear_all_button );
333336 mClearButton .setOnClickListener (mClearButtonListener );
334337 mClearButton .setAlpha (0f );
338+ mClearButton .setEnabled (false );
335339 mDateView = (DateView )expanded .findViewById (R .id .date );
336340 mSettingsButton = expanded .findViewById (R .id .settings_button );
337341 mSettingsButton .setOnClickListener (mSettingsButtonListener );
@@ -1005,6 +1009,7 @@ private void setAreThereNotifications() {
10051009 } else {
10061010 mClearButton .setAlpha (clearable ? 1.0f : 0.0f );
10071011 }
1012+ mClearButton .setEnabled (clearable );
10081013
10091014 /*
10101015 if (mNoNotificationsTitle.isShown()) {
@@ -1114,6 +1119,12 @@ public void handleMessage(Message m) {
11141119 case MSG_ANIMATE_REVEAL :
11151120 doRevealAnimation ();
11161121 break ;
1122+ case MSG_OPEN_NOTIFICATION_PANEL :
1123+ animateExpand ();
1124+ break ;
1125+ case MSG_CLOSE_NOTIFICATION_PANEL :
1126+ animateCollapse ();
1127+ break ;
11171128 case MSG_SHOW_INTRUDER :
11181129 setIntruderAlertVisibility (true );
11191130 break ;
@@ -1181,6 +1192,10 @@ public void animateCollapse() {
11811192 }
11821193
11831194 public void animateCollapse (boolean excludeRecents ) {
1195+ animateCollapse (excludeRecents , 1.0f );
1196+ }
1197+
1198+ public void animateCollapse (boolean excludeRecents , float velocityMultiplier ) {
11841199 if (SPEW ) {
11851200 Slog .d (TAG , "animateCollapse(): mExpanded=" + mExpanded
11861201 + " mExpandedVisible=" + mExpandedVisible
@@ -1209,7 +1224,7 @@ public void animateCollapse(boolean excludeRecents) {
12091224 // and doesn't try to re-open the windowshade.
12101225 mExpanded = true ;
12111226 prepareTracking (y , false );
1212- performFling (y , -mSelfCollapseVelocityPx , true );
1227+ performFling (y , -mSelfCollapseVelocityPx * velocityMultiplier , true );
12131228 }
12141229
12151230 void performExpand () {
@@ -2086,13 +2101,57 @@ void performDisableActions(int net) {
20862101 }
20872102
20882103 private View .OnClickListener mClearButtonListener = new View .OnClickListener () {
2104+ final int mini (int a , int b ) {
2105+ return (b >a ?a :b );
2106+ }
20892107 public void onClick (View v ) {
2090- try {
2091- mBarService .onClearAllNotifications ();
2092- } catch (RemoteException ex ) {
2093- // system process is dead if we're here.
2108+ synchronized (mNotificationData ) {
2109+ // let's also queue up 400ms worth of animated dismissals
2110+ final int N = mini (5 , mPile .getChildCount ());
2111+
2112+ final ArrayList <View > snapshot = new ArrayList <View >(N );
2113+ for (int i =0 ; i <N ; i ++) {
2114+ final View child = mPile .getChildAt (i );
2115+ if (mPile .canChildBeDismissed (child )) snapshot .add (child );
2116+ }
2117+ new Thread (new Runnable () {
2118+ @ Override
2119+ public void run () {
2120+ final int ROW_DELAY = 100 ;
2121+
2122+ mHandler .postDelayed (new Runnable () {
2123+ public void run () {
2124+ animateCollapse (false , 0f );
2125+ }
2126+ }, (N -1 ) * ROW_DELAY );
2127+
2128+ mHandler .postDelayed (new Runnable () {
2129+ public void run () {
2130+ try {
2131+ mBarService .onClearAllNotifications ();
2132+ } catch (RemoteException ex ) { }
2133+ }
2134+ }, N * ROW_DELAY + 500 );
2135+
2136+ mPile .setAnimateBounds (false ); // temporarily disable some re-layouts
2137+
2138+ for (View v : snapshot ) {
2139+ final View _v = v ;
2140+ mHandler .post (new Runnable () {
2141+ @ Override
2142+ public void run () {
2143+ mPile .dismissRowAnimated (_v , (int )(ROW_DELAY *0.25f ));
2144+ }
2145+ });
2146+ try {
2147+ Thread .sleep (ROW_DELAY );
2148+ } catch (InterruptedException ex ) { }
2149+ }
2150+
2151+ mPile .setAnimateBounds (true ); // reenable layout animation
2152+ }
2153+ }).start ();
20942154 }
2095- animateCollapse ();
20962155 }
20972156 };
20982157
0 commit comments