Skip to content

Commit 4d179dc

Browse files
committed
Fix animation of notification handle bar when panel changes height
The notification panel uses LayoutTransition to animate changes to the list of notifications. This works for the items themselves as items are added or removed; the new/old items animate in/out and the existing items animate to make or remove space. But the handle at the bottom of the list (the gray translucent line) does not play well with these changes. For example, when an item is swiped away the handle snaps into its new location before the rest of the items have finished animating. The problem comes from a constraint of LayoutTransition; it handles changes to the container it operates on, and to the parent hierarchy all the way up to the root. However, it cannot animate changes to siblings of the parents. So when the list resizes due to item changes, the handle (which is in a sibling of the list) does not animate this change, but just reacts instantly. The fix is to draw the handle not as a view itself, but rather as part of the parent container of the list. So as the list animates a resize, the container will also animate, and any graphics in the container will animate along with it. No matter what size the container of the list is, the line will be drawn at the bottom of it. Issue #7024902 Notification panel animation incorrect when swiping notification out Change-Id: Ifc412cb6bcdc6ead35993b0320364a2a95a16e11
1 parent 2bd65b6 commit 4d179dc

File tree

2 files changed

+31
-12
lines changed

2 files changed

+31
-12
lines changed

packages/SystemUI/res/layout/status_bar_expanded.xml

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@
2727
android:background="@drawable/notification_panel_bg"
2828
android:paddingTop="@dimen/notification_panel_padding_top"
2929
android:layout_marginLeft="@dimen/notification_panel_margin_left"
30-
android:animateLayoutChanges="true"
3130
>
3231

3332
<TextView
@@ -80,18 +79,10 @@
8079
</ScrollView>
8180
</LinearLayout>
8281

83-
<LinearLayout android:id="@+id/handle"
82+
<View android:id="@+id/handle"
8483
android:layout_width="match_parent"
8584
android:layout_height="@dimen/close_handle_height"
8685
android:layout_gravity="bottom"
87-
android:orientation="vertical"
88-
>
89-
<ImageView
90-
android:layout_width="match_parent"
91-
android:layout_height="@dimen/close_handle_height"
92-
android:layout_gravity="bottom"
93-
android:scaleType="fitXY"
94-
android:src="@drawable/status_bar_close"
95-
/>
96-
</LinearLayout>
86+
/>
87+
9788
</com.android.systemui.statusbar.phone.NotificationPanelView><!-- end of sliding panel -->

packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationPanelView.java

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,23 @@
1717
package com.android.systemui.statusbar.phone;
1818

1919
import android.content.Context;
20+
import android.content.res.Resources;
21+
import android.graphics.Canvas;
22+
import android.graphics.drawable.Drawable;
2023
import android.util.AttributeSet;
24+
import com.android.systemui.R;
2125

2226
public class NotificationPanelView extends PanelView {
27+
28+
Drawable mHandleBar;
29+
float mHandleBarHeight;
30+
2331
public NotificationPanelView(Context context, AttributeSet attrs) {
2432
super(context, attrs);
33+
34+
Resources resources = context.getResources();
35+
mHandleBar = resources.getDrawable(R.drawable.status_bar_close);
36+
mHandleBarHeight = resources.getDimension(R.dimen.close_handle_height);
2537
}
2638

2739
@Override
@@ -31,4 +43,20 @@ public void fling(float vel, boolean always) {
3143
"notifications,v=" + vel);
3244
super.fling(vel, always);
3345
}
46+
47+
@Override
48+
protected void onLayout(boolean changed, int left, int top, int right, int bottom) {
49+
super.onLayout(changed, left, top, right, bottom);
50+
if (changed) {
51+
mHandleBar.setBounds(0, 0, getWidth(), (int) mHandleBarHeight);
52+
}
53+
}
54+
55+
@Override
56+
public void draw(Canvas canvas) {
57+
super.draw(canvas);
58+
canvas.translate(0, getHeight() - mHandleBarHeight);
59+
mHandleBar.draw(canvas);
60+
canvas.translate(0, -getHeight() + mHandleBarHeight);
61+
}
3462
}

0 commit comments

Comments
 (0)