Skip to content

Commit 08d05e3

Browse files
committed
New status bar capable of multiple sliding panels.
There are some visual glitches but almost everything should be put back pretty much where it was. Change-Id: I2f9b0591d44599b07bd83f03c4e09e6dd98e1448
1 parent f83d2d6 commit 08d05e3

File tree

12 files changed

+639
-646
lines changed

12 files changed

+639
-646
lines changed

core/java/android/animation/TimeAnimator.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,12 @@ public class TimeAnimator extends ValueAnimator {
1212
private TimeListener mListener;
1313
private long mPreviousTime = -1;
1414

15+
@Override
16+
public void start() {
17+
mPreviousTime = -1;
18+
super.start();
19+
}
20+
1521
@Override
1622
boolean animationFrame(long currentTime) {
1723
if (mListener != null) {

packages/SystemUI/res/layout-sw600dp/super_status_bar.xml

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,16 @@
3131
android:layout_height="@*android:dimen/status_bar_height"
3232
/>
3333

34-
<include layout="@layout/status_bar_expanded"
35-
android:layout_width="@dimen/notification_panel_width"
36-
android:layout_height="0dp"
37-
android:layout_gravity="center_horizontal|top"
38-
/>
3934

35+
<com.android.systemui.statusbar.phone.PanelHolder
36+
android:id="@+id/panel_holder"
37+
android:layout_width="match_parent"
38+
android:layout_height="match_parent"
39+
>
40+
<include layout="@layout/status_bar_expanded"
41+
android:layout_width="@dimen/notification_panel_width"
42+
android:layout_height="wrap_content"
43+
android:layout_gravity="center_horizontal|top"
44+
/>
45+
</com.android.systemui.statusbar.phone.PanelHolder>
4046
</com.android.systemui.statusbar.phone.StatusBarWindowView>

packages/SystemUI/res/layout/status_bar_expanded.xml

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,12 @@
1818
*/
1919
-->
2020

21-
<FrameLayout
21+
<com.android.systemui.statusbar.phone.NotificationPanelView
2222
xmlns:android="http://schemas.android.com/apk/res/android"
2323
xmlns:systemui="http://schemas.android.com/apk/res/com.android.systemui"
2424
android:id="@+id/notification_panel"
25-
android:layout_width="match_parent"
26-
android:layout_height="match_parent"
25+
android:layout_width="0dp"
26+
android:layout_height="0dp"
2727
android:background="@drawable/notification_panel_bg"
2828
android:paddingTop="@dimen/notification_panel_padding_top"
2929
android:layout_marginLeft="@dimen/notification_panel_margin_left"
@@ -42,7 +42,7 @@
4242

4343
<LinearLayout
4444
android:layout_width="match_parent"
45-
android:layout_height="match_parent"
45+
android:layout_height="wrap_content"
4646
android:layout_marginBottom="@dimen/close_handle_underlap"
4747
android:orientation="vertical"
4848
>
@@ -65,7 +65,7 @@
6565
<ScrollView
6666
android:id="@+id/scroll"
6767
android:layout_width="match_parent"
68-
android:layout_height="match_parent"
68+
android:layout_height="wrap_content"
6969
android:fadingEdge="none"
7070
android:overScrollMode="always"
7171
>
@@ -78,7 +78,7 @@
7878
</ScrollView>
7979
</LinearLayout>
8080

81-
<com.android.systemui.statusbar.phone.CloseDragHandle android:id="@+id/close"
81+
<LinearLayout android:id="@+id/handle"
8282
android:layout_width="match_parent"
8383
android:layout_height="@dimen/close_handle_height"
8484
android:layout_gravity="bottom"
@@ -91,6 +91,5 @@
9191
android:scaleType="fitXY"
9292
android:src="@drawable/status_bar_close"
9393
/>
94-
95-
</com.android.systemui.statusbar.phone.CloseDragHandle>
96-
</FrameLayout><!-- end of sliding panel -->
94+
</LinearLayout>
95+
</com.android.systemui.statusbar.phone.NotificationPanelView><!-- end of sliding panel -->

packages/SystemUI/res/layout/super_status_bar.xml

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,15 @@
3232
android:layout_height="@*android:dimen/status_bar_height"
3333
/>
3434

35-
<include layout="@layout/status_bar_expanded"
35+
<com.android.systemui.statusbar.phone.PanelHolder
36+
android:id="@+id/panel_holder"
3637
android:layout_width="match_parent"
37-
android:layout_height="0dp"
38-
/>
38+
android:layout_height="match_parent"
39+
>
40+
<include layout="@layout/status_bar_expanded"
41+
android:layout_width="match_parent"
42+
android:layout_height="wrap_content"
43+
/>
44+
</com.android.systemui.statusbar.phone.PanelHolder>
3945

4046
</com.android.systemui.statusbar.phone.StatusBarWindowView>
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
/*
2+
* Copyright (C) 2012 The Android Open Source Project
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
package com.android.systemui.statusbar.phone;
18+
19+
import android.content.Context;
20+
import android.util.AttributeSet;
21+
22+
public class NotificationPanelView extends PanelView {
23+
public NotificationPanelView(Context context, AttributeSet attrs) {
24+
super(context, attrs);
25+
android.util.Slog.v("NotificationPanelView", "ctor");
26+
}
27+
28+
29+
@Override
30+
public void fling(float vel, boolean always) {
31+
((PhoneStatusBarView) mBar).mBar.getGestureRecorder().tag(
32+
"fling " + ((vel > 0) ? "open" : "closed"),
33+
"v=" + vel);
34+
super.fling(vel, always);
35+
}
36+
}
Lines changed: 115 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,115 @@
1+
package com.android.systemui.statusbar.phone;
2+
3+
import java.util.ArrayList;
4+
5+
import android.content.Context;
6+
import android.util.AttributeSet;
7+
import android.util.Slog;
8+
import android.view.MotionEvent;
9+
import android.widget.FrameLayout;
10+
11+
public class PanelBar extends FrameLayout {
12+
public static final boolean DEBUG = true;
13+
public static final String TAG = PanelView.class.getSimpleName();
14+
public static final void LOG(String fmt, Object... args) {
15+
if (!DEBUG) return;
16+
Slog.v(TAG, String.format(fmt, args));
17+
}
18+
19+
private PanelHolder mPanelHolder;
20+
private ArrayList<PanelView> mPanels = new ArrayList<PanelView>();
21+
private PanelView mTouchingPanel;
22+
23+
public PanelBar(Context context, AttributeSet attrs) {
24+
super(context, attrs);
25+
}
26+
27+
@Override
28+
protected void onFinishInflate() {
29+
super.onFinishInflate();
30+
}
31+
32+
public void addPanel(PanelView pv) {
33+
mPanels.add(pv);
34+
pv.setBar(this);
35+
}
36+
37+
public void setPanelHolder(PanelHolder ph) {
38+
if (ph == null) {
39+
Slog.e(TAG, "setPanelHolder: null PanelHolder", new Throwable());
40+
return;
41+
}
42+
ph.setBar(this);
43+
mPanelHolder = ph;
44+
final int N = ph.getChildCount();
45+
for (int i=0; i<N; i++) {
46+
final PanelView v = (PanelView) ph.getChildAt(i);
47+
if (v != null) {
48+
addPanel(v);
49+
}
50+
}
51+
}
52+
53+
public float getBarHeight() {
54+
return getMeasuredHeight();
55+
}
56+
57+
@Override
58+
public boolean onTouchEvent(MotionEvent event) {
59+
// figure out which panel needs to be talked to here
60+
if (event.getAction() == MotionEvent.ACTION_DOWN) {
61+
final int N = mPanels.size();
62+
final int i = (int)(N * event.getX() / getMeasuredWidth());
63+
mTouchingPanel = mPanels.get(i);
64+
mPanelHolder.setSelectedPanel(mTouchingPanel);
65+
LOG("PanelBar.onTouch: ACTION_DOWN: panel %d", i);
66+
onPanelPeeked();
67+
}
68+
final boolean result = mTouchingPanel.getHandle().dispatchTouchEvent(event);
69+
return result;
70+
}
71+
72+
public void panelExpansionChanged(PanelView panel, float frac) {
73+
boolean fullyClosed = true;
74+
boolean fullyOpened = false;
75+
for (PanelView pv : mPanels) {
76+
if (pv.getExpandedHeight() > 0f) {
77+
fullyClosed = false;
78+
final float thisFrac = pv.getExpandedFraction();
79+
LOG("panel %s: f=%.1f", pv, thisFrac);
80+
if (panel == pv) {
81+
if (thisFrac == 1f) fullyOpened = true;
82+
} else {
83+
pv.setExpandedFraction(1f-frac);
84+
}
85+
}
86+
}
87+
if (fullyOpened) onPanelFullyOpened();
88+
if (fullyClosed) onAllPanelsCollapsed();
89+
else onPanelPeeked();
90+
91+
LOG("panelExpansionChanged: [%s%s ]", fullyOpened?" fullyOpened":"", fullyClosed?" fullyClosed":"");
92+
}
93+
94+
public void collapseAllPanels(boolean animate) {
95+
for (PanelView pv : mPanels) {
96+
if (animate && pv == mTouchingPanel) {
97+
mTouchingPanel.collapse();
98+
} else {
99+
pv.setExpandedFraction(0); // just in case
100+
}
101+
}
102+
}
103+
104+
public void onPanelPeeked() {
105+
LOG("onPanelPeeked");
106+
}
107+
108+
public void onAllPanelsCollapsed() {
109+
LOG("onAllPanelsCollapsed");
110+
}
111+
112+
public void onPanelFullyOpened() {
113+
LOG("onPanelFullyOpened");
114+
}
115+
}
Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
package com.android.systemui.statusbar.phone;
2+
3+
import android.content.Context;
4+
import android.util.AttributeSet;
5+
import android.view.MotionEvent;
6+
import android.widget.FrameLayout;
7+
8+
public class PanelHolder extends FrameLayout {
9+
10+
private int mSelectedPanelIndex;
11+
private PanelBar mBar;
12+
13+
public PanelHolder(Context context, AttributeSet attrs) {
14+
super(context, attrs);
15+
setChildrenDrawingOrderEnabled(true);
16+
}
17+
18+
@Override
19+
protected void onFinishInflate() {
20+
super.onFinishInflate();
21+
setChildrenDrawingOrderEnabled(true);
22+
}
23+
24+
public int getPanelIndex(PanelView pv) {
25+
final int N = getChildCount();
26+
for (int i=0; i<N; i++) {
27+
final PanelView v = (PanelView) getChildAt(i);
28+
if (pv == v) return i;
29+
}
30+
return -1;
31+
}
32+
33+
public void setSelectedPanel(PanelView pv) {
34+
mSelectedPanelIndex = getPanelIndex(pv);
35+
}
36+
37+
@Override
38+
protected int getChildDrawingOrder(int childCount, int i) {
39+
if (mSelectedPanelIndex == -1) {
40+
return i;
41+
} else {
42+
if (i == childCount - 1) {
43+
return mSelectedPanelIndex;
44+
} else if (i >= mSelectedPanelIndex) {
45+
return i + 1;
46+
} else {
47+
return i;
48+
}
49+
}
50+
}
51+
52+
@Override
53+
public boolean onTouchEvent(MotionEvent event) {
54+
switch (event.getAction()) {
55+
case MotionEvent.ACTION_DOWN:
56+
mBar.collapseAllPanels(true);
57+
break;
58+
}
59+
return false;
60+
}
61+
62+
public void setBar(PanelBar panelBar) {
63+
mBar = panelBar;
64+
}
65+
}

0 commit comments

Comments
 (0)