Merge "Confine the quick settings trigger to the right third of the status bar." into jb-mr1-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
2b197db786
@@ -14,7 +14,7 @@
|
||||
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"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
@@ -42,4 +42,4 @@
|
||||
android:src="@drawable/status_bar_close"
|
||||
/>
|
||||
</LinearLayout>
|
||||
</com.android.systemui.statusbar.phone.PanelView>
|
||||
</com.android.systemui.statusbar.phone.SettingsPanelView >
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -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
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user