Merge "Fix the seesaw behavior on the status panels." into jb-mr1-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
a2facc33cd
@@ -84,8 +84,8 @@ import java.util.ArrayList;
|
|||||||
|
|
||||||
public abstract class BaseStatusBar extends SystemUI implements
|
public abstract class BaseStatusBar extends SystemUI implements
|
||||||
CommandQueue.Callbacks {
|
CommandQueue.Callbacks {
|
||||||
static final String TAG = "StatusBar";
|
public static final String TAG = "StatusBar";
|
||||||
private static final boolean DEBUG = false;
|
public static final boolean DEBUG = false;
|
||||||
public static final boolean MULTIUSER_DEBUG = false;
|
public static final boolean MULTIUSER_DEBUG = false;
|
||||||
|
|
||||||
protected static final int MSG_TOGGLE_RECENTS_PANEL = 1020;
|
protected static final int MSG_TOGGLE_RECENTS_PANEL = 1020;
|
||||||
@@ -162,6 +162,9 @@ public abstract class BaseStatusBar extends SystemUI implements
|
|||||||
private RemoteViews.OnClickHandler mOnClickHandler = new RemoteViews.OnClickHandler() {
|
private RemoteViews.OnClickHandler mOnClickHandler = new RemoteViews.OnClickHandler() {
|
||||||
@Override
|
@Override
|
||||||
public boolean onClickHandler(View view, PendingIntent pendingIntent, Intent fillInIntent) {
|
public boolean onClickHandler(View view, PendingIntent pendingIntent, Intent fillInIntent) {
|
||||||
|
if (DEBUG) {
|
||||||
|
Slog.v(TAG, "Notification click handler invoked for intent: " + pendingIntent);
|
||||||
|
}
|
||||||
final boolean isActivity = pendingIntent.isActivity();
|
final boolean isActivity = pendingIntent.isActivity();
|
||||||
if (isActivity) {
|
if (isActivity) {
|
||||||
try {
|
try {
|
||||||
|
|||||||
@@ -10,22 +10,23 @@ import android.widget.FrameLayout;
|
|||||||
|
|
||||||
public class PanelBar extends FrameLayout {
|
public class PanelBar extends FrameLayout {
|
||||||
public static final boolean DEBUG = false;
|
public static final boolean DEBUG = false;
|
||||||
public static final String TAG = PanelView.class.getSimpleName();
|
public static final String TAG = PanelBar.class.getSimpleName();
|
||||||
public static final void LOG(String fmt, Object... args) {
|
public static final void LOG(String fmt, Object... args) {
|
||||||
if (!DEBUG) return;
|
if (!DEBUG) return;
|
||||||
Slog.v(TAG, String.format(fmt, args));
|
Slog.v(TAG, String.format(fmt, args));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static final int STATE_CLOSED = 0;
|
||||||
|
public static final int STATE_OPENING = 1;
|
||||||
|
public static final int STATE_OPEN = 2;
|
||||||
|
|
||||||
private PanelHolder mPanelHolder;
|
private PanelHolder mPanelHolder;
|
||||||
private ArrayList<PanelView> mPanels = new ArrayList<PanelView>();
|
private ArrayList<PanelView> mPanels = new ArrayList<PanelView>();
|
||||||
protected PanelView mTouchingPanel;
|
protected PanelView mTouchingPanel;
|
||||||
private static final int STATE_CLOSED = 0;
|
|
||||||
private static final int STATE_TRANSITIONING = 1;
|
|
||||||
private static final int STATE_OPEN = 2;
|
|
||||||
private int mState = STATE_CLOSED;
|
private int mState = STATE_CLOSED;
|
||||||
private boolean mTracking;
|
private boolean mTracking;
|
||||||
|
|
||||||
private void go(int state) {
|
public void go(int state) {
|
||||||
LOG("go state: %d -> %d", mState, state);
|
LOG("go state: %d -> %d", mState, state);
|
||||||
mState = state;
|
mState = state;
|
||||||
}
|
}
|
||||||
@@ -80,18 +81,21 @@ public class PanelBar extends FrameLayout {
|
|||||||
|
|
||||||
// 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) {
|
||||||
mTouchingPanel = selectPanelForTouchX(event.getX());
|
final PanelView panel = selectPanelForTouchX(event.getX());
|
||||||
mPanelHolder.setSelectedPanel(mTouchingPanel);
|
LOG("PanelBar.onTouch: state=%d ACTION_DOWN: panel %s", mState, panel);
|
||||||
LOG("PanelBar.onTouch: state=%d ACTION_DOWN: panel %s", mState, mTouchingPanel.getName());
|
startOpeningPanel(panel);
|
||||||
if (mState == STATE_CLOSED || mState == STATE_OPEN) {
|
|
||||||
go(STATE_TRANSITIONING);
|
|
||||||
onPanelPeeked();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
final boolean result = mTouchingPanel.getHandle().dispatchTouchEvent(event);
|
final boolean result = mTouchingPanel.getHandle().dispatchTouchEvent(event);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// called from PanelView when self-expanding, too
|
||||||
|
public void startOpeningPanel(PanelView panel) {
|
||||||
|
LOG("startOpeningPanel: " + panel);
|
||||||
|
mTouchingPanel = panel;
|
||||||
|
mPanelHolder.setSelectedPanel(mTouchingPanel);
|
||||||
|
}
|
||||||
|
|
||||||
public void panelExpansionChanged(PanelView panel, float frac) {
|
public void panelExpansionChanged(PanelView panel, float frac) {
|
||||||
boolean fullyClosed = true;
|
boolean fullyClosed = true;
|
||||||
PanelView fullyOpenedPanel = null;
|
PanelView fullyOpenedPanel = null;
|
||||||
@@ -99,6 +103,10 @@ public class PanelBar extends FrameLayout {
|
|||||||
for (PanelView pv : mPanels) {
|
for (PanelView pv : mPanels) {
|
||||||
// adjust any other panels that may be partially visible
|
// adjust any other panels that may be partially visible
|
||||||
if (pv.getExpandedHeight() > 0f) {
|
if (pv.getExpandedHeight() > 0f) {
|
||||||
|
if (mState == STATE_CLOSED) {
|
||||||
|
go(STATE_OPENING);
|
||||||
|
onPanelPeeked();
|
||||||
|
}
|
||||||
fullyClosed = false;
|
fullyClosed = false;
|
||||||
final float thisFrac = pv.getExpandedFraction();
|
final float thisFrac = pv.getExpandedFraction();
|
||||||
LOG("panelExpansionChanged: -> %s: f=%.1f", pv.getName(), thisFrac);
|
LOG("panelExpansionChanged: -> %s: f=%.1f", pv.getName(), thisFrac);
|
||||||
@@ -112,7 +120,7 @@ public class PanelBar extends FrameLayout {
|
|||||||
if (fullyOpenedPanel != null && !mTracking) {
|
if (fullyOpenedPanel != null && !mTracking) {
|
||||||
go(STATE_OPEN);
|
go(STATE_OPEN);
|
||||||
onPanelFullyOpened(fullyOpenedPanel);
|
onPanelFullyOpened(fullyOpenedPanel);
|
||||||
} else if (fullyClosed && !mTracking) {
|
} else if (fullyClosed && !mTracking && mState != STATE_CLOSED) {
|
||||||
go(STATE_CLOSED);
|
go(STATE_CLOSED);
|
||||||
onAllPanelsCollapsed();
|
onAllPanelsCollapsed();
|
||||||
}
|
}
|
||||||
@@ -122,13 +130,21 @@ public class PanelBar extends FrameLayout {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void collapseAllPanels(boolean animate) {
|
public void collapseAllPanels(boolean animate) {
|
||||||
|
boolean waiting = false;
|
||||||
for (PanelView pv : mPanels) {
|
for (PanelView pv : mPanels) {
|
||||||
if (animate && pv == mTouchingPanel) {
|
if (animate && !pv.isFullyCollapsed()) {
|
||||||
mTouchingPanel.collapse();
|
pv.collapse();
|
||||||
|
waiting = true;
|
||||||
} else {
|
} else {
|
||||||
pv.setExpandedFraction(0); // just in case
|
pv.setExpandedFraction(0); // just in case
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (!waiting) {
|
||||||
|
// it's possible that nothing animated, so we replicate the termination
|
||||||
|
// conditions of panelExpansionChanged here
|
||||||
|
go(STATE_CLOSED);
|
||||||
|
onAllPanelsCollapsed();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void onPanelPeeked() {
|
public void onPanelPeeked() {
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ import android.util.Slog;
|
|||||||
import android.view.MotionEvent;
|
import android.view.MotionEvent;
|
||||||
import android.view.VelocityTracker;
|
import android.view.VelocityTracker;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
|
import android.view.ViewGroup;
|
||||||
import android.widget.FrameLayout;
|
import android.widget.FrameLayout;
|
||||||
|
|
||||||
import com.android.systemui.R;
|
import com.android.systemui.R;
|
||||||
@@ -18,7 +19,7 @@ import com.android.systemui.statusbar.policy.LocationController;
|
|||||||
import com.android.systemui.statusbar.policy.NetworkController;
|
import com.android.systemui.statusbar.policy.NetworkController;
|
||||||
|
|
||||||
public class PanelView extends FrameLayout {
|
public class PanelView extends FrameLayout {
|
||||||
public static final boolean DEBUG = false;
|
public static final boolean DEBUG = PanelBar.DEBUG;
|
||||||
public static final String TAG = PanelView.class.getSimpleName();
|
public static final String TAG = PanelView.class.getSimpleName();
|
||||||
public final void LOG(String fmt, Object... args) {
|
public final void LOG(String fmt, Object... args) {
|
||||||
if (!DEBUG) return;
|
if (!DEBUG) return;
|
||||||
@@ -298,10 +299,16 @@ public class PanelView extends FrameLayout {
|
|||||||
|
|
||||||
LOG("onMeasure(%d, %d) -> (%d, %d)",
|
LOG("onMeasure(%d, %d) -> (%d, %d)",
|
||||||
widthMeasureSpec, heightMeasureSpec, getMeasuredWidth(), getMeasuredHeight());
|
widthMeasureSpec, heightMeasureSpec, getMeasuredWidth(), getMeasuredHeight());
|
||||||
mFullHeight = getMeasuredHeight();
|
|
||||||
// if one of our children is getting smaller, we should track that
|
// Did one of our children change size?
|
||||||
if (!mTracking && !mRubberbanding && !mTimeAnimator.isStarted() && mExpandedHeight > 0 && mExpandedHeight != mFullHeight) {
|
int newHeight = getMeasuredHeight();
|
||||||
mExpandedHeight = mFullHeight;
|
if (newHeight != mFullHeight) {
|
||||||
|
mFullHeight = newHeight;
|
||||||
|
// If the user isn't actively poking us, let's rubberband to the content
|
||||||
|
if (!mTracking && !mRubberbanding && !mTimeAnimator.isStarted()
|
||||||
|
&& mExpandedHeight > 0 && mExpandedHeight != mFullHeight) {
|
||||||
|
mExpandedHeight = mFullHeight;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
heightMeasureSpec = MeasureSpec.makeMeasureSpec(
|
heightMeasureSpec = MeasureSpec.makeMeasureSpec(
|
||||||
(int) mExpandedHeight, MeasureSpec.AT_MOST); // MeasureSpec.getMode(heightMeasureSpec));
|
(int) mExpandedHeight, MeasureSpec.AT_MOST); // MeasureSpec.getMode(heightMeasureSpec));
|
||||||
@@ -310,6 +317,7 @@ public class PanelView extends FrameLayout {
|
|||||||
|
|
||||||
|
|
||||||
public void setExpandedHeight(float height) {
|
public void setExpandedHeight(float height) {
|
||||||
|
mTracking = mRubberbanding = false;
|
||||||
post(mStopAnimator);
|
post(mStopAnimator);
|
||||||
setExpandedHeightInternal(height);
|
setExpandedHeightInternal(height);
|
||||||
}
|
}
|
||||||
@@ -326,21 +334,26 @@ public class PanelView extends FrameLayout {
|
|||||||
// Hmm, full height hasn't been computed yet
|
// Hmm, full height hasn't been computed yet
|
||||||
}
|
}
|
||||||
|
|
||||||
LOG("setExpansion: height=%.1f fh=%.1f tracking=%s rubber=%s", h, fh, mTracking?"T":"f", mRubberbanding?"T":"f");
|
|
||||||
|
|
||||||
if (h < 0) h = 0;
|
if (h < 0) h = 0;
|
||||||
if (!(STRETCH_PAST_CONTENTS && (mTracking || mRubberbanding)) && h > fh) h = fh;
|
if (!(STRETCH_PAST_CONTENTS && (mTracking || mRubberbanding)) && h > fh) h = fh;
|
||||||
mExpandedHeight = h;
|
mExpandedHeight = h;
|
||||||
|
|
||||||
|
LOG("setExpansion: height=%.1f fh=%.1f tracking=%s rubber=%s", h, fh, mTracking?"T":"f", mRubberbanding?"T":"f");
|
||||||
|
|
||||||
requestLayout();
|
requestLayout();
|
||||||
// FrameLayout.LayoutParams lp = (FrameLayout.LayoutParams) getLayoutParams();
|
// FrameLayout.LayoutParams lp = (FrameLayout.LayoutParams) getLayoutParams();
|
||||||
// lp.height = (int) mExpandedHeight;
|
// lp.height = (int) mExpandedHeight;
|
||||||
// setLayoutParams(lp);
|
// setLayoutParams(lp);
|
||||||
|
|
||||||
mExpandedFraction = Math.min(1f, h / fh);
|
mExpandedFraction = Math.min(1f, (fh == 0) ? 0 : h / fh);
|
||||||
}
|
}
|
||||||
|
|
||||||
private float getFullHeight() {
|
private float getFullHeight() {
|
||||||
|
if (mFullHeight <= 0) {
|
||||||
|
LOG("Forcing measure() since fullHeight=" + mFullHeight);
|
||||||
|
measure(MeasureSpec.makeMeasureSpec(LayoutParams.WRAP_CONTENT, MeasureSpec.EXACTLY),
|
||||||
|
MeasureSpec.makeMeasureSpec(LayoutParams.WRAP_CONTENT, MeasureSpec.EXACTLY));
|
||||||
|
}
|
||||||
return mFullHeight;
|
return mFullHeight;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -385,8 +398,12 @@ public class PanelView extends FrameLayout {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void expand() {
|
public void expand() {
|
||||||
if (!isFullyExpanded()) {
|
if (isFullyCollapsed()) {
|
||||||
|
mBar.startOpeningPanel(this);
|
||||||
|
LOG("expand: calling fling(%s, true)", mSelfExpandVelocityPx);
|
||||||
fling (mSelfExpandVelocityPx, /*always=*/ true);
|
fling (mSelfExpandVelocityPx, /*always=*/ true);
|
||||||
|
} else if (DEBUG) {
|
||||||
|
LOG("skipping expansion: is expanded");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -95,7 +95,7 @@ import java.util.ArrayList;
|
|||||||
|
|
||||||
public class PhoneStatusBar extends BaseStatusBar {
|
public class PhoneStatusBar extends BaseStatusBar {
|
||||||
static final String TAG = "PhoneStatusBar";
|
static final String TAG = "PhoneStatusBar";
|
||||||
public static final boolean DEBUG = false;
|
public static final boolean DEBUG = BaseStatusBar.DEBUG;
|
||||||
public static final boolean SPEW = DEBUG;
|
public static final boolean SPEW = DEBUG;
|
||||||
public static final boolean DUMPTRUCK = true; // extra dumpsys info
|
public static final boolean DUMPTRUCK = true; // extra dumpsys info
|
||||||
|
|
||||||
@@ -285,9 +285,6 @@ public class PhoneStatusBar extends BaseStatusBar {
|
|||||||
|
|
||||||
mStatusBarWindow = (StatusBarWindowView) View.inflate(context,
|
mStatusBarWindow = (StatusBarWindowView) View.inflate(context,
|
||||||
R.layout.super_status_bar, null);
|
R.layout.super_status_bar, null);
|
||||||
if (DEBUG) {
|
|
||||||
mStatusBarWindow.setBackgroundColor(0x6000FF80);
|
|
||||||
}
|
|
||||||
mStatusBarWindow.mService = this;
|
mStatusBarWindow.mService = this;
|
||||||
mStatusBarWindow.setOnTouchListener(new View.OnTouchListener() {
|
mStatusBarWindow.setOnTouchListener(new View.OnTouchListener() {
|
||||||
@Override
|
@Override
|
||||||
@@ -1160,7 +1157,7 @@ public class PhoneStatusBar extends BaseStatusBar {
|
|||||||
|
|
||||||
public void animateCollapse(int flags) {
|
public void animateCollapse(int flags) {
|
||||||
if (SPEW) {
|
if (SPEW) {
|
||||||
Slog.d(TAG, "animateCollapse(): "
|
Slog.d(TAG, "animateCollapse():"
|
||||||
+ " mExpandedVisible=" + mExpandedVisible
|
+ " mExpandedVisible=" + mExpandedVisible
|
||||||
+ " mAnimating=" + mAnimating
|
+ " mAnimating=" + mAnimating
|
||||||
+ " mAnimatingReveal=" + mAnimatingReveal
|
+ " mAnimatingReveal=" + mAnimatingReveal
|
||||||
@@ -1203,7 +1200,7 @@ public class PhoneStatusBar extends BaseStatusBar {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Ensure the panel is fully collapsed (just in case; bug 6765842)
|
// Ensure the panel is fully collapsed (just in case; bug 6765842)
|
||||||
mStatusBarView.collapseAllPanels(/*animate=*/ false);
|
// @@@ mStatusBarView.collapseAllPanels(/*animate=*/ false);
|
||||||
|
|
||||||
mExpandedVisible = false;
|
mExpandedVisible = false;
|
||||||
mPile.setLayoutTransitionsEnabled(false);
|
mPile.setLayoutTransitionsEnabled(false);
|
||||||
|
|||||||
@@ -27,6 +27,7 @@ import android.graphics.Rect;
|
|||||||
import android.os.SystemClock;
|
import android.os.SystemClock;
|
||||||
import android.util.AttributeSet;
|
import android.util.AttributeSet;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
|
import android.util.Slog;
|
||||||
import android.view.KeyEvent;
|
import android.view.KeyEvent;
|
||||||
import android.view.MotionEvent;
|
import android.view.MotionEvent;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
@@ -41,6 +42,8 @@ import com.android.systemui.statusbar.policy.FixedSizeDrawable;
|
|||||||
|
|
||||||
public class PhoneStatusBarView extends PanelBar {
|
public class PhoneStatusBarView extends PanelBar {
|
||||||
private static final String TAG = "PhoneStatusBarView";
|
private static final String TAG = "PhoneStatusBarView";
|
||||||
|
private static final boolean DEBUG = PhoneStatusBar.DEBUG;
|
||||||
|
|
||||||
PhoneStatusBar mBar;
|
PhoneStatusBar mBar;
|
||||||
int mScrimColor;
|
int mScrimColor;
|
||||||
float mMinFlingGutter;
|
float mMinFlingGutter;
|
||||||
@@ -152,6 +155,10 @@ public class PhoneStatusBarView extends PanelBar {
|
|||||||
public void panelExpansionChanged(PanelView pv, float frac) {
|
public void panelExpansionChanged(PanelView pv, float frac) {
|
||||||
super.panelExpansionChanged(pv, frac);
|
super.panelExpansionChanged(pv, frac);
|
||||||
|
|
||||||
|
if (DEBUG) {
|
||||||
|
Slog.v(TAG, "panelExpansionChanged: f=" + frac);
|
||||||
|
}
|
||||||
|
|
||||||
if (mFadingPanel == pv
|
if (mFadingPanel == pv
|
||||||
&& mScrimColor != 0 && ActivityManager.isHighEndGfx()) {
|
&& mScrimColor != 0 && ActivityManager.isHighEndGfx()) {
|
||||||
// woo, special effects
|
// woo, special effects
|
||||||
|
|||||||
@@ -17,6 +17,8 @@
|
|||||||
package com.android.systemui.statusbar.phone;
|
package com.android.systemui.statusbar.phone;
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
|
import android.graphics.Canvas;
|
||||||
|
import android.graphics.Paint;
|
||||||
import android.util.AttributeSet;
|
import android.util.AttributeSet;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
import android.view.KeyEvent;
|
import android.view.KeyEvent;
|
||||||
@@ -28,12 +30,14 @@ import android.widget.TextSwitcher;
|
|||||||
|
|
||||||
import com.android.systemui.ExpandHelper;
|
import com.android.systemui.ExpandHelper;
|
||||||
import com.android.systemui.R;
|
import com.android.systemui.R;
|
||||||
|
import com.android.systemui.statusbar.BaseStatusBar;
|
||||||
import com.android.systemui.statusbar.policy.NotificationRowLayout;
|
import com.android.systemui.statusbar.policy.NotificationRowLayout;
|
||||||
|
|
||||||
|
|
||||||
public class StatusBarWindowView extends FrameLayout
|
public class StatusBarWindowView extends FrameLayout
|
||||||
{
|
{
|
||||||
private static final String TAG = "StatusBarWindowView";
|
public static final String TAG = "StatusBarWindowView";
|
||||||
|
public static final boolean DEBUG = BaseStatusBar.DEBUG;
|
||||||
|
|
||||||
private ExpandHelper mExpandHelper;
|
private ExpandHelper mExpandHelper;
|
||||||
private NotificationRowLayout latestItems;
|
private NotificationRowLayout latestItems;
|
||||||
@@ -44,6 +48,7 @@ public class StatusBarWindowView extends FrameLayout
|
|||||||
public StatusBarWindowView(Context context, AttributeSet attrs) {
|
public StatusBarWindowView(Context context, AttributeSet attrs) {
|
||||||
super(context, attrs);
|
super(context, attrs);
|
||||||
setMotionEventSplittingEnabled(false);
|
setMotionEventSplittingEnabled(false);
|
||||||
|
setWillNotDraw(!DEBUG);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -101,5 +106,17 @@ public class StatusBarWindowView extends FrameLayout
|
|||||||
}
|
}
|
||||||
return handled;
|
return handled;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onDraw(Canvas canvas) {
|
||||||
|
super.onDraw(canvas);
|
||||||
|
if (DEBUG) {
|
||||||
|
Paint pt = new Paint();
|
||||||
|
pt.setColor(0x80FFFF00);
|
||||||
|
pt.setStrokeWidth(12.0f);
|
||||||
|
pt.setStyle(Paint.Style.STROKE);
|
||||||
|
canvas.drawRect(0, 0, canvas.getWidth(), canvas.getHeight(), pt);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user