Skip to content

Commit 2b197db

Browse files
dsandlerAndroid (Google) Code Review
authored andcommitted
Merge "Confine the quick settings trigger to the right third of the status bar." into jb-mr1-dev
2 parents 524c878 + cf591db commit 2b197db

File tree

6 files changed

+71
-11
lines changed

6 files changed

+71
-11
lines changed

packages/SystemUI/res/layout/quick_settings.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
limitations under the License.
1515
-->
1616

17-
<com.android.systemui.statusbar.phone.PanelView
17+
<com.android.systemui.statusbar.phone.SettingsPanelView
1818
xmlns:android="http://schemas.android.com/apk/res/android"
1919
android:layout_width="match_parent"
2020
android:layout_height="wrap_content"
@@ -42,4 +42,4 @@
4242
android:src="@drawable/status_bar_close"
4343
/>
4444
</LinearLayout>
45-
</com.android.systemui.statusbar.phone.PanelView>
45+
</com.android.systemui.statusbar.phone.SettingsPanelView >

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

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,15 +22,13 @@
2222
public class NotificationPanelView extends PanelView {
2323
public NotificationPanelView(Context context, AttributeSet attrs) {
2424
super(context, attrs);
25-
android.util.Slog.v("NotificationPanelView", "ctor");
2625
}
2726

28-
2927
@Override
3028
public void fling(float vel, boolean always) {
3129
((PhoneStatusBarView) mBar).mBar.getGestureRecorder().tag(
3230
"fling " + ((vel > 0) ? "open" : "closed"),
33-
"v=" + vel);
31+
"notifications,v=" + vel);
3432
super.fling(vel, always);
3533
}
3634
}

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

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -64,15 +64,18 @@ public float getBarHeight() {
6464
return getMeasuredHeight();
6565
}
6666

67+
public PanelView selectPanelForTouchX(float x) {
68+
final int N = mPanels.size();
69+
return mPanels.get((int)(N * x / getMeasuredWidth()));
70+
}
71+
6772
@Override
6873
public boolean onTouchEvent(MotionEvent event) {
6974
// figure out which panel needs to be talked to here
7075
if (event.getAction() == MotionEvent.ACTION_DOWN) {
71-
final int N = mPanels.size();
72-
final int i = (int)(N * event.getX() / getMeasuredWidth());
73-
mTouchingPanel = mPanels.get(i);
76+
mTouchingPanel = selectPanelForTouchX(event.getX());
7477
mPanelHolder.setSelectedPanel(mTouchingPanel);
75-
LOG("PanelBar.onTouch: state=%d ACTION_DOWN: panel %d", mState, i);
78+
LOG("PanelBar.onTouch: state=%d ACTION_DOWN: panel %s", mState, mTouchingPanel.getName());
7679
if (mState == STATE_CLOSED || mState == STATE_OPEN) {
7780
go(STATE_TRANSITIONING);
7881
onPanelPeeked();

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -223,7 +223,7 @@ public boolean onTouch(View v, MotionEvent event) {
223223
xVel, yVel,
224224
vel);
225225

226-
fling(vel, false);
226+
fling(vel, true);
227227

228228
mVelocityTracker.recycle();
229229
mVelocityTracker = null;
@@ -238,7 +238,7 @@ public boolean onTouch(View v, MotionEvent event) {
238238
public void fling(float vel, boolean always) {
239239
mVel = vel;
240240

241-
if (mVel != 0) {
241+
if (always||mVel != 0) {
242242
animationTick(0); // begin the animation
243243
}
244244
}

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

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ public class PhoneStatusBarView extends PanelBar {
4343
PhoneStatusBar mBar;
4444
int mScrimColor;
4545
PanelView mFadingPanel = null;
46+
PanelView mNotificationPanel, mSettingsPanel;
4647

4748
public PhoneStatusBarView(Context context, AttributeSet attrs) {
4849
super(context, attrs);
@@ -58,6 +59,16 @@ public void onAttachedToWindow() {
5859
mScrimColor = res.getColor(R.color.notification_panel_scrim_color);
5960
}
6061

62+
@Override
63+
public void addPanel(PanelView pv) {
64+
super.addPanel(pv);
65+
if (pv.getId() == R.id.notification_panel) {
66+
mNotificationPanel = pv;
67+
} else if (pv.getId() == R.id.settings_panel){
68+
mSettingsPanel = pv;
69+
}
70+
}
71+
6172
@Override
6273
public boolean onRequestSendAccessibilityEvent(View child, AccessibilityEvent event) {
6374
if (super.onRequestSendAccessibilityEvent(child, event)) {
@@ -73,6 +84,20 @@ public boolean onRequestSendAccessibilityEvent(View child, AccessibilityEvent ev
7384
return false;
7485
}
7586

87+
@Override
88+
public PanelView selectPanelForTouchX(float x) {
89+
// We split the status bar into thirds: the left 2/3 are for notifications, and the
90+
// right 1/3 for quick settings. If you pull the status bar down a second time you'll
91+
// toggle panels no matter where you pull it down.
92+
final float w = (float) getMeasuredWidth();
93+
final float f = x / w;
94+
if (f > 0.67f && mSettingsPanel.getExpandedFraction() != 1.0f
95+
|| mNotificationPanel.getExpandedFraction() == 1.0f) {
96+
return mSettingsPanel;
97+
}
98+
return mNotificationPanel;
99+
}
100+
76101
@Override
77102
public void onPanelPeeked() {
78103
super.onPanelPeeked();
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
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 SettingsPanelView extends PanelView {
23+
public SettingsPanelView(Context context, AttributeSet attrs) {
24+
super(context, attrs);
25+
}
26+
27+
@Override
28+
public void fling(float vel, boolean always) {
29+
((PhoneStatusBarView) mBar).mBar.getGestureRecorder().tag(
30+
"fling " + ((vel > 0) ? "open" : "closed"),
31+
"settings,v=" + vel);
32+
super.fling(vel, always);
33+
}
34+
}

0 commit comments

Comments
 (0)