Fix the seesaw behavior on the status panels.
The code in onMeasure that attempts to accommodate changing
child boundaries (i.e. an expanding/collapsing notification)
was locking the window size to the child measurement, even
though another window was trying to seesaw it closed. We now
only activate the rubberband behavior when the size of the
children changes, not on each onMeasure().
Lots of other small fixes to the panel expansion logic, too,
including ensuring that the expanded fraction doesn't jump
to 1.0f when the panel content hasn't been laid out yet
(causing the entire screen to become dim for a second thanks
to PhoneStatusBarView.panelExpansionChanged).
This change also restores the ability of Binder clients
(such as accessibility systems) to expand and collapse the
status bar.
Bug: 7008196
Bug: 6995518
Bug: 6628429
Change-Id: Ib0244a27aef2b4dbe19be98f7e039a9d38f1b80e
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 1c244d4..a4a3a6a 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/PanelView.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/PanelView.java
@@ -9,6 +9,7 @@
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.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 @@
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 void setExpandedHeight(float height) {
+ mTracking = mRubberbanding = false;
post(mStopAnimator);
setExpandedHeightInternal(height);
}
@@ -326,21 +334,26 @@
// 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 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");
}
}
}