am 2b197db7: Merge "Confine the quick settings trigger to the right third of the status bar." into jb-mr1-dev

* commit '2b197db7868ef756eef455184ea7eed1a2145264':
  Confine the quick settings trigger to the right third of the status bar.
This commit is contained in:
Daniel Sandler
2012-08-15 20:06:14 -07:00
committed by Android Git Automerger
6 changed files with 71 additions and 11 deletions

View File

@@ -14,7 +14,7 @@
limitations under the License. limitations under the License.
--> -->
<com.android.systemui.statusbar.phone.PanelView <com.android.systemui.statusbar.phone.SettingsPanelView
xmlns:android="http://schemas.android.com/apk/res/android" xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
@@ -42,4 +42,4 @@
android:src="@drawable/status_bar_close" android:src="@drawable/status_bar_close"
/> />
</LinearLayout> </LinearLayout>
</com.android.systemui.statusbar.phone.PanelView> </com.android.systemui.statusbar.phone.SettingsPanelView >

View File

@@ -22,15 +22,13 @@ import android.util.AttributeSet;
public class NotificationPanelView extends PanelView { public class NotificationPanelView extends PanelView {
public NotificationPanelView(Context context, AttributeSet attrs) { public NotificationPanelView(Context context, AttributeSet attrs) {
super(context, attrs); super(context, attrs);
android.util.Slog.v("NotificationPanelView", "ctor");
} }
@Override @Override
public void fling(float vel, boolean always) { public void fling(float vel, boolean always) {
((PhoneStatusBarView) mBar).mBar.getGestureRecorder().tag( ((PhoneStatusBarView) mBar).mBar.getGestureRecorder().tag(
"fling " + ((vel > 0) ? "open" : "closed"), "fling " + ((vel > 0) ? "open" : "closed"),
"v=" + vel); "notifications,v=" + vel);
super.fling(vel, always); super.fling(vel, always);
} }
} }

View File

@@ -64,15 +64,18 @@ public class PanelBar extends FrameLayout {
return getMeasuredHeight(); return getMeasuredHeight();
} }
public PanelView selectPanelForTouchX(float x) {
final int N = mPanels.size();
return mPanels.get((int)(N * x / getMeasuredWidth()));
}
@Override @Override
public boolean onTouchEvent(MotionEvent event) { public boolean onTouchEvent(MotionEvent event) {
// figure out which panel needs to be talked to here // figure out which panel needs to be talked to here
if (event.getAction() == MotionEvent.ACTION_DOWN) { if (event.getAction() == MotionEvent.ACTION_DOWN) {
final int N = mPanels.size(); mTouchingPanel = selectPanelForTouchX(event.getX());
final int i = (int)(N * event.getX() / getMeasuredWidth());
mTouchingPanel = mPanels.get(i);
mPanelHolder.setSelectedPanel(mTouchingPanel); mPanelHolder.setSelectedPanel(mTouchingPanel);
LOG("PanelBar.onTouch: state=%d ACTION_DOWN: panel %d", mState, i); LOG("PanelBar.onTouch: state=%d ACTION_DOWN: panel %s", mState, mTouchingPanel.getName());
if (mState == STATE_CLOSED || mState == STATE_OPEN) { if (mState == STATE_CLOSED || mState == STATE_OPEN) {
go(STATE_TRANSITIONING); go(STATE_TRANSITIONING);
onPanelPeeked(); onPanelPeeked();

View File

@@ -223,7 +223,7 @@ public class PanelView extends FrameLayout {
xVel, yVel, xVel, yVel,
vel); vel);
fling(vel, false); fling(vel, true);
mVelocityTracker.recycle(); mVelocityTracker.recycle();
mVelocityTracker = null; mVelocityTracker = null;
@@ -238,7 +238,7 @@ public class PanelView extends FrameLayout {
public void fling(float vel, boolean always) { public void fling(float vel, boolean always) {
mVel = vel; mVel = vel;
if (mVel != 0) { if (always||mVel != 0) {
animationTick(0); // begin the animation animationTick(0); // begin the animation
} }
} }

View File

@@ -43,6 +43,7 @@ public class PhoneStatusBarView extends PanelBar {
PhoneStatusBar mBar; PhoneStatusBar mBar;
int mScrimColor; int mScrimColor;
PanelView mFadingPanel = null; PanelView mFadingPanel = null;
PanelView mNotificationPanel, mSettingsPanel;
public PhoneStatusBarView(Context context, AttributeSet attrs) { public PhoneStatusBarView(Context context, AttributeSet attrs) {
super(context, attrs); super(context, attrs);
@@ -58,6 +59,16 @@ public class PhoneStatusBarView extends PanelBar {
mScrimColor = res.getColor(R.color.notification_panel_scrim_color); mScrimColor = res.getColor(R.color.notification_panel_scrim_color);
} }
@Override
public void addPanel(PanelView pv) {
super.addPanel(pv);
if (pv.getId() == R.id.notification_panel) {
mNotificationPanel = pv;
} else if (pv.getId() == R.id.settings_panel){
mSettingsPanel = pv;
}
}
@Override @Override
public boolean onRequestSendAccessibilityEvent(View child, AccessibilityEvent event) { public boolean onRequestSendAccessibilityEvent(View child, AccessibilityEvent event) {
if (super.onRequestSendAccessibilityEvent(child, event)) { if (super.onRequestSendAccessibilityEvent(child, event)) {
@@ -73,6 +84,20 @@ public class PhoneStatusBarView extends PanelBar {
return false; return false;
} }
@Override
public PanelView selectPanelForTouchX(float x) {
// We split the status bar into thirds: the left 2/3 are for notifications, and the
// right 1/3 for quick settings. If you pull the status bar down a second time you'll
// toggle panels no matter where you pull it down.
final float w = (float) getMeasuredWidth();
final float f = x / w;
if (f > 0.67f && mSettingsPanel.getExpandedFraction() != 1.0f
|| mNotificationPanel.getExpandedFraction() == 1.0f) {
return mSettingsPanel;
}
return mNotificationPanel;
}
@Override @Override
public void onPanelPeeked() { public void onPanelPeeked() {
super.onPanelPeeked(); super.onPanelPeeked();

View File

@@ -0,0 +1,34 @@
/*
* Copyright (C) 2012 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.android.systemui.statusbar.phone;
import android.content.Context;
import android.util.AttributeSet;
public class SettingsPanelView extends PanelView {
public SettingsPanelView(Context context, AttributeSet attrs) {
super(context, attrs);
}
@Override
public void fling(float vel, boolean always) {
((PhoneStatusBarView) mBar).mBar.getGestureRecorder().tag(
"fling " + ((vel > 0) ? "open" : "closed"),
"settings,v=" + vel);
super.fling(vel, always);
}
}