Improved Notification Panel height logic
Due to a racecondition, the mMaxPanelheight of the PanelView could
get too small in certain cases, leading to an empty shade.
Change-Id: Ib1d7b5245cbb25a853698e1985b1e4bbf617505f
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 8c70517..dde2ebb 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/PanelView.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/PanelView.java
@@ -20,6 +20,7 @@
import android.animation.TimeAnimator;
import android.animation.TimeAnimator.TimeListener;
import android.content.Context;
+import android.content.res.Configuration;
import android.content.res.Resources;
import android.util.AttributeSet;
import android.util.Log;
@@ -218,7 +219,7 @@
};
private float mVel, mAccel;
- protected int mMaxPanelHeight = 0;
+ protected int mMaxPanelHeight = -1;
private String mViewName;
private float mInitialTouchY;
private float mInitialTouchX;
@@ -617,7 +618,8 @@
// Did one of our children change size?
int newHeight = getMeasuredHeight();
- if (newHeight != mMaxPanelHeight) {
+ if (newHeight > mMaxPanelHeight) {
+ // we only adapt the max height if it's bigger
mMaxPanelHeight = newHeight;
// If the user isn't actively poking us, let's rubberband to the content
if (!mTracking && !mTimeAnimator.isStarted()
@@ -695,6 +697,12 @@
mExpandedFraction = Math.min(1f, (fh == 0) ? 0 : h / fh);
}
+ @Override
+ protected void onConfigurationChanged(Configuration newConfig) {
+ super.onConfigurationChanged(newConfig);
+ mMaxPanelHeight = -1;
+ }
+
protected void onHeightUpdated(float expandedHeight) {
requestLayout();
}
@@ -706,6 +714,7 @@
* @return the default implementation simply returns the maximum height.
*/
protected int getMaxPanelHeight() {
+ mMaxPanelHeight = Math.max(mMaxPanelHeight, getHeight());
return mMaxPanelHeight;
}