Allow the panels to be temporarily dragged past their contents.
Once the user lets go, restore the "correct" height of the panel. Bug: 6999596 Change-Id: I2db393873cee876cf17fea25c9d25fe5e3a78424
This commit is contained in:
@@ -23,10 +23,11 @@
|
||||
xmlns:systemui="http://schemas.android.com/apk/res/com.android.systemui"
|
||||
android:id="@+id/notification_panel"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="@drawable/notification_panel_bg"
|
||||
android:paddingTop="@dimen/notification_panel_padding_top"
|
||||
android:layout_marginLeft="@dimen/notification_panel_margin_left"
|
||||
android:animateLayoutChanges="true"
|
||||
>
|
||||
|
||||
<TextView
|
||||
@@ -45,6 +46,7 @@
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginBottom="@dimen/close_handle_underlap"
|
||||
android:orientation="vertical"
|
||||
android:animateLayoutChanges="true"
|
||||
>
|
||||
|
||||
<include layout="@layout/status_bar_expanded_header"
|
||||
|
||||
@@ -69,14 +69,14 @@ public class PanelBar extends FrameLayout {
|
||||
return mPanels.get((int)(N * x / getMeasuredWidth()));
|
||||
}
|
||||
|
||||
public boolean isEnabled() {
|
||||
public boolean panelsEnabled() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onTouchEvent(MotionEvent event) {
|
||||
// Allow subclasses to implement enable/disable semantics
|
||||
if (!isEnabled()) return false;
|
||||
if (!panelsEnabled()) return false;
|
||||
|
||||
// figure out which panel needs to be talked to here
|
||||
if (event.getAction() == MotionEvent.ACTION_DOWN) {
|
||||
|
||||
@@ -22,6 +22,7 @@ public class PanelView extends FrameLayout {
|
||||
}
|
||||
|
||||
public static final boolean BRAKES = false;
|
||||
private static final boolean STRETCH_PAST_CONTENTS = true;
|
||||
|
||||
private float mSelfExpandVelocityPx; // classic value: 2000px/s
|
||||
private float mSelfCollapseVelocityPx; // classic value: 2000px/s (will be negated to collapse "up")
|
||||
@@ -45,6 +46,9 @@ public class PanelView extends FrameLayout {
|
||||
private float mTouchOffset;
|
||||
private float mExpandedFraction = 0;
|
||||
private float mExpandedHeight = 0;
|
||||
private boolean mClosing;
|
||||
private boolean mRubberbanding;
|
||||
private boolean mTracking;
|
||||
|
||||
private TimeAnimator mTimeAnimator;
|
||||
private VelocityTracker mVelocityTracker;
|
||||
@@ -61,12 +65,13 @@ public class PanelView extends FrameLayout {
|
||||
|
||||
private final Runnable mStopAnimator = new Runnable() { public void run() {
|
||||
if (mTimeAnimator.isStarted()) {
|
||||
mTimeAnimator.end(); }
|
||||
mTimeAnimator.end();
|
||||
}
|
||||
}};
|
||||
|
||||
private float mVel, mAccel;
|
||||
private int mFullHeight = 0;
|
||||
private String mViewName;
|
||||
private String mViewName;
|
||||
|
||||
private void animationTick(long dtms) {
|
||||
if (!mTimeAnimator.isStarted()) {
|
||||
@@ -75,16 +80,18 @@ public class PanelView extends FrameLayout {
|
||||
mTimeAnimator.setTimeListener(mAnimationCallback);
|
||||
|
||||
mTimeAnimator.start();
|
||||
|
||||
mRubberbanding = STRETCH_PAST_CONTENTS && mExpandedHeight > getFullHeight();
|
||||
mClosing = (mExpandedHeight > 0 && mVel < 0) || mRubberbanding;
|
||||
} else if (dtms > 0) {
|
||||
final float dt = dtms * 0.001f; // ms -> s
|
||||
LOG("tick: v=%.2fpx/s dt=%.4fs", mVel, dt);
|
||||
LOG("tick: before: h=%d", (int) mExpandedHeight);
|
||||
|
||||
final float fh = getFullHeight();
|
||||
final boolean closing = mExpandedHeight > 0 && mVel < 0;
|
||||
boolean braking = false;
|
||||
if (BRAKES) {
|
||||
if (closing) {
|
||||
if (mClosing) {
|
||||
braking = mExpandedHeight <= mCollapseBrakingDistancePx;
|
||||
mAccel = braking ? 10*mCollapseAccelPx : -mCollapseAccelPx;
|
||||
} else {
|
||||
@@ -92,36 +99,40 @@ public class PanelView extends FrameLayout {
|
||||
mAccel = braking ? 10*-mExpandAccelPx : mExpandAccelPx;
|
||||
}
|
||||
} else {
|
||||
mAccel = closing ? -mCollapseAccelPx : mExpandAccelPx;
|
||||
mAccel = mClosing ? -mCollapseAccelPx : mExpandAccelPx;
|
||||
}
|
||||
|
||||
mVel += mAccel * dt;
|
||||
|
||||
if (braking) {
|
||||
if (closing && mVel > -mBrakingSpeedPx) {
|
||||
if (mClosing && mVel > -mBrakingSpeedPx) {
|
||||
mVel = -mBrakingSpeedPx;
|
||||
} else if (!closing && mVel < mBrakingSpeedPx) {
|
||||
} else if (!mClosing && mVel < mBrakingSpeedPx) {
|
||||
mVel = mBrakingSpeedPx;
|
||||
}
|
||||
} else {
|
||||
if (closing && mVel > -mFlingCollapseMinVelocityPx) {
|
||||
if (mClosing && mVel > -mFlingCollapseMinVelocityPx) {
|
||||
mVel = -mFlingCollapseMinVelocityPx;
|
||||
} else if (!closing && mVel > mFlingGestureMaxOutputVelocityPx) {
|
||||
} else if (!mClosing && mVel > mFlingGestureMaxOutputVelocityPx) {
|
||||
mVel = mFlingGestureMaxOutputVelocityPx;
|
||||
}
|
||||
}
|
||||
|
||||
float h = mExpandedHeight + mVel * dt;
|
||||
|
||||
if (mRubberbanding && h < fh) {
|
||||
h = fh;
|
||||
}
|
||||
|
||||
LOG("tick: new h=%d closing=%s", (int) h, closing?"true":"false");
|
||||
LOG("tick: new h=%d closing=%s", (int) h, mClosing?"true":"false");
|
||||
|
||||
setExpandedHeightInternal(h);
|
||||
|
||||
mBar.panelExpansionChanged(PanelView.this, mExpandedFraction);
|
||||
|
||||
if (mVel == 0
|
||||
|| (closing && mExpandedHeight == 0)
|
||||
|| (!closing && mExpandedHeight == getFullHeight())) {
|
||||
|| (mClosing && mExpandedHeight == 0)
|
||||
|| ((mRubberbanding || !mClosing) && mExpandedHeight == fh)) {
|
||||
post(mStopAnimator);
|
||||
}
|
||||
}
|
||||
@@ -183,6 +194,7 @@ public class PanelView extends FrameLayout {
|
||||
|
||||
switch (event.getAction()) {
|
||||
case MotionEvent.ACTION_DOWN:
|
||||
mTracking = true;
|
||||
mVelocityTracker = VelocityTracker.obtain();
|
||||
trackMovement(event);
|
||||
mBar.onTrackingStarted(PanelView.this);
|
||||
@@ -190,7 +202,7 @@ public class PanelView extends FrameLayout {
|
||||
break;
|
||||
|
||||
case MotionEvent.ACTION_MOVE:
|
||||
PanelView.this.setExpandedHeight(rawY - mAbsPos[1] - mTouchOffset);
|
||||
PanelView.this.setExpandedHeightInternal(rawY - mAbsPos[1] - mTouchOffset);
|
||||
|
||||
mBar.panelExpansionChanged(PanelView.this, mExpandedFraction);
|
||||
|
||||
@@ -199,6 +211,7 @@ public class PanelView extends FrameLayout {
|
||||
|
||||
case MotionEvent.ACTION_UP:
|
||||
case MotionEvent.ACTION_CANCEL:
|
||||
mTracking = false;
|
||||
mBar.onTrackingStopped(PanelView.this);
|
||||
trackMovement(event);
|
||||
mVelocityTracker.computeCurrentVelocity(1000);
|
||||
@@ -275,6 +288,10 @@ 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;
|
||||
}
|
||||
heightMeasureSpec = MeasureSpec.makeMeasureSpec(
|
||||
(int) mExpandedHeight, MeasureSpec.AT_MOST); // MeasureSpec.getMode(heightMeasureSpec));
|
||||
setMeasuredDimension(widthMeasureSpec, heightMeasureSpec);
|
||||
@@ -286,17 +303,22 @@ public class PanelView extends FrameLayout {
|
||||
setExpandedHeightInternal(height);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onLayout (boolean changed, int left, int top, int right, int bottom) {
|
||||
LOG("onLayout: changed=%s, bottom=%d eh=%d fh=%d", changed?"T":"f", bottom, (int)mExpandedHeight, (int)mFullHeight);
|
||||
super.onLayout(changed, left, top, right, bottom);
|
||||
}
|
||||
|
||||
public void setExpandedHeightInternal(float h) {
|
||||
float fh = getFullHeight();
|
||||
if (fh == 0) {
|
||||
// Hmm, full height hasn't been computed yet
|
||||
}
|
||||
|
||||
LOG("setExpansion: height=%.1f fh=%.1f", h, fh);
|
||||
LOG("setExpansion: height=%.1f fh=%.1f tracking=%s rubber=%s", h, fh, mTracking?"T":"f", mRubberbanding?"T":"f");
|
||||
|
||||
if (h < 0) h = 0;
|
||||
else if (h > fh) h = fh;
|
||||
|
||||
if (!(STRETCH_PAST_CONTENTS && (mTracking || mRubberbanding)) && h > fh) h = fh;
|
||||
mExpandedHeight = h;
|
||||
|
||||
requestLayout();
|
||||
|
||||
@@ -109,7 +109,7 @@ public class PhoneStatusBar extends BaseStatusBar {
|
||||
public static final String ACTION_STATUSBAR_START
|
||||
= "com.android.internal.policy.statusbar.START";
|
||||
|
||||
private static final boolean SHOW_CARRIER_LABEL = true;
|
||||
private static final boolean SHOW_CARRIER_LABEL = false; // XXX: doesn't work with rubberband panels right now
|
||||
|
||||
private static final int MSG_OPEN_NOTIFICATION_PANEL = 1000;
|
||||
private static final int MSG_CLOSE_NOTIFICATION_PANEL = 1001;
|
||||
|
||||
@@ -71,7 +71,7 @@ public class PhoneStatusBarView extends PanelBar {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isEnabled() {
|
||||
public boolean panelsEnabled() {
|
||||
return ((mBar.mDisabled & StatusBarManager.DISABLE_EXPAND) == 0);
|
||||
}
|
||||
|
||||
|
||||
@@ -78,6 +78,7 @@ public class NotificationRowLayout
|
||||
super(context, attrs, defStyle);
|
||||
|
||||
mRealLayoutTransition = new LayoutTransition();
|
||||
mRealLayoutTransition.setAnimateParentHierarchy(true);
|
||||
setLayoutTransitionsEnabled(true);
|
||||
|
||||
setOrientation(LinearLayout.VERTICAL);
|
||||
|
||||
Reference in New Issue
Block a user