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