From cf591db04914d8ceadd982451b325bd8c4817086 Mon Sep 17 00:00:00 2001 From: Daniel Sandler Date: Wed, 15 Aug 2012 16:11:55 -0400 Subject: [PATCH] Confine the quick settings trigger to the right third of the status bar. Pulling down anywhere on the status bar when a panel is already showing will switch to the other panel. Also adjust gesture recorder output to track the settings panel and annotate it separately. Change-Id: I0ca3b395b5f2c6c8767237126bce26d0e8c9b8c0 --- .../SystemUI/res/layout/quick_settings.xml | 4 +-- .../phone/NotificationPanelView.java | 4 +-- .../systemui/statusbar/phone/PanelBar.java | 11 +++--- .../systemui/statusbar/phone/PanelView.java | 4 +-- .../statusbar/phone/PhoneStatusBarView.java | 25 ++++++++++++++ .../statusbar/phone/SettingsPanelView.java | 34 +++++++++++++++++++ 6 files changed, 71 insertions(+), 11 deletions(-) create mode 100644 packages/SystemUI/src/com/android/systemui/statusbar/phone/SettingsPanelView.java diff --git a/packages/SystemUI/res/layout/quick_settings.xml b/packages/SystemUI/res/layout/quick_settings.xml index a62a470bbe025..c4b881e5b7da1 100644 --- a/packages/SystemUI/res/layout/quick_settings.xml +++ b/packages/SystemUI/res/layout/quick_settings.xml @@ -14,7 +14,7 @@ limitations under the License. --> - - \ No newline at end of file + \ No newline at end of file diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationPanelView.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationPanelView.java index ae7fb274bf120..13a34ad3b542a 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationPanelView.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationPanelView.java @@ -22,15 +22,13 @@ import android.util.AttributeSet; public class NotificationPanelView extends PanelView { public NotificationPanelView(Context context, AttributeSet attrs) { super(context, attrs); - android.util.Slog.v("NotificationPanelView", "ctor"); } - @Override public void fling(float vel, boolean always) { ((PhoneStatusBarView) mBar).mBar.getGestureRecorder().tag( "fling " + ((vel > 0) ? "open" : "closed"), - "v=" + vel); + "notifications,v=" + vel); super.fling(vel, always); } } diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/PanelBar.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/PanelBar.java index f44c5007425c6..78ec4b6373fff 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/PanelBar.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/PanelBar.java @@ -64,15 +64,18 @@ public class PanelBar extends FrameLayout { return getMeasuredHeight(); } + public PanelView selectPanelForTouchX(float x) { + final int N = mPanels.size(); + return mPanels.get((int)(N * x / getMeasuredWidth())); + } + @Override public boolean onTouchEvent(MotionEvent event) { // figure out which panel needs to be talked to here if (event.getAction() == MotionEvent.ACTION_DOWN) { - final int N = mPanels.size(); - final int i = (int)(N * event.getX() / getMeasuredWidth()); - mTouchingPanel = mPanels.get(i); + mTouchingPanel = selectPanelForTouchX(event.getX()); 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) { go(STATE_TRANSITIONING); onPanelPeeked(); diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/PanelView.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/PanelView.java index b5a50c68ae0e1..d0fba4256ba76 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/PanelView.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/PanelView.java @@ -223,7 +223,7 @@ public class PanelView extends FrameLayout { xVel, yVel, vel); - fling(vel, false); + fling(vel, true); mVelocityTracker.recycle(); mVelocityTracker = null; @@ -238,7 +238,7 @@ public class PanelView extends FrameLayout { public void fling(float vel, boolean always) { mVel = vel; - if (mVel != 0) { + if (always||mVel != 0) { animationTick(0); // begin the animation } } diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBarView.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBarView.java index 25ff9aa4b73fb..924e45d6d66db 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBarView.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBarView.java @@ -43,6 +43,7 @@ public class PhoneStatusBarView extends PanelBar { PhoneStatusBar mBar; int mScrimColor; PanelView mFadingPanel = null; + PanelView mNotificationPanel, mSettingsPanel; public PhoneStatusBarView(Context context, AttributeSet attrs) { super(context, attrs); @@ -58,6 +59,16 @@ public class PhoneStatusBarView extends PanelBar { 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 public boolean onRequestSendAccessibilityEvent(View child, AccessibilityEvent event) { if (super.onRequestSendAccessibilityEvent(child, event)) { @@ -73,6 +84,20 @@ public class PhoneStatusBarView extends PanelBar { 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 public void onPanelPeeked() { super.onPanelPeeked(); diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/SettingsPanelView.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/SettingsPanelView.java new file mode 100644 index 0000000000000..fb1528ff95e41 --- /dev/null +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/SettingsPanelView.java @@ -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); + } +}