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
|
||||
CommandQueue.Callbacks {
|
||||
static final String TAG = "StatusBar";
|
||||
private static final boolean DEBUG = false;
|
||||
public static final String TAG = "StatusBar";
|
||||
public static final boolean DEBUG = false;
|
||||
public static final boolean MULTIUSER_DEBUG = false;
|
||||
|
||||
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() {
|
||||
@Override
|
||||
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();
|
||||
if (isActivity) {
|
||||
try {
|
||||
|
||||
@@ -10,22 +10,23 @@ import android.widget.FrameLayout;
|
||||
|
||||
public class PanelBar extends FrameLayout {
|
||||
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) {
|
||||
if (!DEBUG) return;
|
||||
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 ArrayList<PanelView> mPanels = new ArrayList<PanelView>();
|
||||
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 boolean mTracking;
|
||||
|
||||
private void go(int state) {
|
||||
public void go(int state) {
|
||||
LOG("go state: %d -> %d", mState, state);
|
||||
mState = state;
|
||||
}
|
||||
@@ -80,18 +81,21 @@ public class PanelBar extends FrameLayout {
|
||||
|
||||
// figure out which panel needs to be talked to here
|
||||
if (event.getAction() == MotionEvent.ACTION_DOWN) {
|
||||
mTouchingPanel = selectPanelForTouchX(event.getX());
|
||||
mPanelHolder.setSelectedPanel(mTouchingPanel);
|
||||
LOG("PanelBar.onTouch: state=%d ACTION_DOWN: panel %s", mState, mTouchingPanel.getName());
|
||||
if (mState == STATE_CLOSED || mState == STATE_OPEN) {
|
||||
go(STATE_TRANSITIONING);
|
||||
onPanelPeeked();
|
||||
}
|
||||
final PanelView panel = selectPanelForTouchX(event.getX());
|
||||
LOG("PanelBar.onTouch: state=%d ACTION_DOWN: panel %s", mState, panel);
|
||||
startOpeningPanel(panel);
|
||||
}
|
||||
final boolean result = mTouchingPanel.getHandle().dispatchTouchEvent(event);
|
||||
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) {
|
||||
boolean fullyClosed = true;
|
||||
PanelView fullyOpenedPanel = null;
|
||||
@@ -99,6 +103,10 @@ public class PanelBar extends FrameLayout {
|
||||
for (PanelView pv : mPanels) {
|
||||
// adjust any other panels that may be partially visible
|
||||
if (pv.getExpandedHeight() > 0f) {
|
||||
if (mState == STATE_CLOSED) {
|
||||
go(STATE_OPENING);
|
||||
onPanelPeeked();
|
||||
}
|
||||
fullyClosed = false;
|
||||
final float thisFrac = pv.getExpandedFraction();
|
||||
LOG("panelExpansionChanged: -> %s: f=%.1f", pv.getName(), thisFrac);
|
||||
@@ -112,7 +120,7 @@ public class PanelBar extends FrameLayout {
|
||||
if (fullyOpenedPanel != null && !mTracking) {
|
||||
go(STATE_OPEN);
|
||||
onPanelFullyOpened(fullyOpenedPanel);
|
||||
} else if (fullyClosed && !mTracking) {
|
||||
} else if (fullyClosed && !mTracking && mState != STATE_CLOSED) {
|
||||
go(STATE_CLOSED);
|
||||
onAllPanelsCollapsed();
|
||||
}
|
||||
@@ -122,13 +130,21 @@ public class PanelBar extends FrameLayout {
|
||||
}
|
||||
|
||||
public void collapseAllPanels(boolean animate) {
|
||||
boolean waiting = false;
|
||||
for (PanelView pv : mPanels) {
|
||||
if (animate && pv == mTouchingPanel) {
|
||||
mTouchingPanel.collapse();
|
||||
if (animate && !pv.isFullyCollapsed()) {
|
||||
pv.collapse();
|
||||
waiting = true;
|
||||
} else {
|
||||
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() {
|
||||
|
||||
@@ -9,6 +9,7 @@ import android.util.Slog;
|
||||
import android.view.MotionEvent;
|
||||
import android.view.VelocityTracker;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.FrameLayout;
|
||||
|
||||
import com.android.systemui.R;
|
||||
@@ -18,7 +19,7 @@ import com.android.systemui.statusbar.policy.LocationController;
|
||||
import com.android.systemui.statusbar.policy.NetworkController;
|
||||
|
||||
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 final void LOG(String fmt, Object... args) {
|
||||
if (!DEBUG) return;
|
||||
@@ -298,10 +299,16 @@ public class PanelView extends FrameLayout {
|
||||
|
||||
LOG("onMeasure(%d, %d) -> (%d, %d)",
|
||||
widthMeasureSpec, heightMeasureSpec, getMeasuredWidth(), getMeasuredHeight());
|
||||
mFullHeight = getMeasuredHeight();
|
||||
// if one of our children is getting smaller, we should track that
|
||||
if (!mTracking && !mRubberbanding && !mTimeAnimator.isStarted() && mExpandedHeight > 0 && mExpandedHeight != mFullHeight) {
|
||||
mExpandedHeight = mFullHeight;
|
||||
|
||||
// Did one of our children change size?
|
||||
int newHeight = getMeasuredHeight();
|
||||
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(
|
||||
(int) mExpandedHeight, MeasureSpec.AT_MOST); // MeasureSpec.getMode(heightMeasureSpec));
|
||||
@@ -310,6 +317,7 @@ public class PanelView extends FrameLayout {
|
||||
|
||||
|
||||
public void setExpandedHeight(float height) {
|
||||
mTracking = mRubberbanding = false;
|
||||
post(mStopAnimator);
|
||||
setExpandedHeightInternal(height);
|
||||
}
|
||||
@@ -326,21 +334,26 @@ public class PanelView extends FrameLayout {
|
||||
// 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 (!(STRETCH_PAST_CONTENTS && (mTracking || mRubberbanding)) && h > fh) h = fh;
|
||||
mExpandedHeight = h;
|
||||
|
||||
LOG("setExpansion: height=%.1f fh=%.1f tracking=%s rubber=%s", h, fh, mTracking?"T":"f", mRubberbanding?"T":"f");
|
||||
|
||||
requestLayout();
|
||||
// FrameLayout.LayoutParams lp = (FrameLayout.LayoutParams) getLayoutParams();
|
||||
// lp.height = (int) mExpandedHeight;
|
||||
// setLayoutParams(lp);
|
||||
|
||||
mExpandedFraction = Math.min(1f, h / fh);
|
||||
mExpandedFraction = Math.min(1f, (fh == 0) ? 0 : h / fh);
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
@@ -385,8 +398,12 @@ public class PanelView extends FrameLayout {
|
||||
}
|
||||
|
||||
public void expand() {
|
||||
if (!isFullyExpanded()) {
|
||||
if (isFullyCollapsed()) {
|
||||
mBar.startOpeningPanel(this);
|
||||
LOG("expand: calling fling(%s, true)", mSelfExpandVelocityPx);
|
||||
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 {
|
||||
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 DUMPTRUCK = true; // extra dumpsys info
|
||||
|
||||
@@ -285,9 +285,6 @@ public class PhoneStatusBar extends BaseStatusBar {
|
||||
|
||||
mStatusBarWindow = (StatusBarWindowView) View.inflate(context,
|
||||
R.layout.super_status_bar, null);
|
||||
if (DEBUG) {
|
||||
mStatusBarWindow.setBackgroundColor(0x6000FF80);
|
||||
}
|
||||
mStatusBarWindow.mService = this;
|
||||
mStatusBarWindow.setOnTouchListener(new View.OnTouchListener() {
|
||||
@Override
|
||||
@@ -1160,7 +1157,7 @@ public class PhoneStatusBar extends BaseStatusBar {
|
||||
|
||||
public void animateCollapse(int flags) {
|
||||
if (SPEW) {
|
||||
Slog.d(TAG, "animateCollapse(): "
|
||||
Slog.d(TAG, "animateCollapse():"
|
||||
+ " mExpandedVisible=" + mExpandedVisible
|
||||
+ " mAnimating=" + mAnimating
|
||||
+ " mAnimatingReveal=" + mAnimatingReveal
|
||||
@@ -1203,7 +1200,7 @@ public class PhoneStatusBar extends BaseStatusBar {
|
||||
}
|
||||
|
||||
// Ensure the panel is fully collapsed (just in case; bug 6765842)
|
||||
mStatusBarView.collapseAllPanels(/*animate=*/ false);
|
||||
// @@@ mStatusBarView.collapseAllPanels(/*animate=*/ false);
|
||||
|
||||
mExpandedVisible = false;
|
||||
mPile.setLayoutTransitionsEnabled(false);
|
||||
|
||||
@@ -27,6 +27,7 @@ import android.graphics.Rect;
|
||||
import android.os.SystemClock;
|
||||
import android.util.AttributeSet;
|
||||
import android.util.Log;
|
||||
import android.util.Slog;
|
||||
import android.view.KeyEvent;
|
||||
import android.view.MotionEvent;
|
||||
import android.view.View;
|
||||
@@ -41,6 +42,8 @@ import com.android.systemui.statusbar.policy.FixedSizeDrawable;
|
||||
|
||||
public class PhoneStatusBarView extends PanelBar {
|
||||
private static final String TAG = "PhoneStatusBarView";
|
||||
private static final boolean DEBUG = PhoneStatusBar.DEBUG;
|
||||
|
||||
PhoneStatusBar mBar;
|
||||
int mScrimColor;
|
||||
float mMinFlingGutter;
|
||||
@@ -152,6 +155,10 @@ public class PhoneStatusBarView extends PanelBar {
|
||||
public void panelExpansionChanged(PanelView pv, float frac) {
|
||||
super.panelExpansionChanged(pv, frac);
|
||||
|
||||
if (DEBUG) {
|
||||
Slog.v(TAG, "panelExpansionChanged: f=" + frac);
|
||||
}
|
||||
|
||||
if (mFadingPanel == pv
|
||||
&& mScrimColor != 0 && ActivityManager.isHighEndGfx()) {
|
||||
// woo, special effects
|
||||
|
||||
@@ -17,6 +17,8 @@
|
||||
package com.android.systemui.statusbar.phone;
|
||||
|
||||
import android.content.Context;
|
||||
import android.graphics.Canvas;
|
||||
import android.graphics.Paint;
|
||||
import android.util.AttributeSet;
|
||||
import android.util.Log;
|
||||
import android.view.KeyEvent;
|
||||
@@ -28,12 +30,14 @@ import android.widget.TextSwitcher;
|
||||
|
||||
import com.android.systemui.ExpandHelper;
|
||||
import com.android.systemui.R;
|
||||
import com.android.systemui.statusbar.BaseStatusBar;
|
||||
import com.android.systemui.statusbar.policy.NotificationRowLayout;
|
||||
|
||||
|
||||
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 NotificationRowLayout latestItems;
|
||||
@@ -44,6 +48,7 @@ public class StatusBarWindowView extends FrameLayout
|
||||
public StatusBarWindowView(Context context, AttributeSet attrs) {
|
||||
super(context, attrs);
|
||||
setMotionEventSplittingEnabled(false);
|
||||
setWillNotDraw(!DEBUG);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -101,5 +106,17 @@ public class StatusBarWindowView extends FrameLayout
|
||||
}
|
||||
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