Merge "Venetian blinds policy for one-finger notification expansion." into jb-mr1-dev

This commit is contained in:
Chris Wren
2012-08-02 11:09:20 -07:00
committed by Android (Google) Code Review
3 changed files with 29 additions and 91 deletions

View File

@@ -152,5 +152,5 @@
<dimen name="carrier_label_height">24dp</dimen> <dimen name="carrier_label_height">24dp</dimen>
<!-- The distance you can pull a notificaiton before it pops open --> <!-- The distance you can pull a notificaiton before it pops open -->
<dimen name="one_finger_pop_limit">96dp</dimen> <dimen name="one_finger_pop_limit">32dp</dimen>
</resources> </resources>

View File

@@ -38,7 +38,6 @@ public class ExpandHelper implements Gefingerpoken, OnClickListener {
public interface Callback { public interface Callback {
View getChildAtRawPosition(float x, float y); View getChildAtRawPosition(float x, float y);
View getChildAtPosition(float x, float y); View getChildAtPosition(float x, float y);
View getPreviousChild(View currentChild);
boolean canChildBeExpanded(View v); boolean canChildBeExpanded(View v);
boolean setUserExpandedChild(View v, boolean userxpanded); boolean setUserExpandedChild(View v, boolean userxpanded);
} }
@@ -142,17 +141,6 @@ public class ExpandHelper implements Gefingerpoken, OnClickListener {
} }
} }
class PopState {
View mCurrView;
View mCurrViewTopGlow;
View mCurrViewBottomGlow;
float mOldHeight;
float mNaturalHeight;
float mInitialTouchY;
}
private Stack<PopState> popStack;
/** /**
* Handle expansion gestures to expand and contract children of the callback. * Handle expansion gestures to expand and contract children of the callback.
* *
@@ -168,7 +156,6 @@ public class ExpandHelper implements Gefingerpoken, OnClickListener {
mLargeSize = large; mLargeSize = large;
mContext = context; mContext = context;
mCallback = callback; mCallback = callback;
popStack = new Stack<PopState>();
mScaler = new ViewScaler(); mScaler = new ViewScaler();
mGravity = Gravity.TOP; mGravity = Gravity.TOP;
mScaleAnimation = ObjectAnimator.ofFloat(mScaler, "height", 0f); mScaleAnimation = ObjectAnimator.ofFloat(mScaler, "height", 0f);
@@ -416,45 +403,40 @@ public class ExpandHelper implements Gefingerpoken, OnClickListener {
switch (action) { switch (action) {
case MotionEvent.ACTION_MOVE: { case MotionEvent.ACTION_MOVE: {
if (mPullingWithOneFinger) { if (mPullingWithOneFinger) {
float target = ev.getY() - mInitialTouchY + mOldHeight; final float rawHeight = ev.getY() - mInitialTouchY + mOldHeight;
float newHeight = clamp(target); final float newHeight = clamp(rawHeight);
if (mHasPopped || target > mPopLimit) { final boolean wasClosed = (mOldHeight == mSmallSize);
boolean isFinished = false;
if (rawHeight > mNaturalHeight) {
isFinished = true;
}
if (rawHeight < mSmallSize) {
isFinished = true;
}
final float pull = Math.abs(ev.getY() - mInitialTouchY);
if (mHasPopped || pull > mPopLimit) {
if (!mHasPopped) { if (!mHasPopped) {
vibrate(mPopDuration); vibrate(mPopDuration);
mHasPopped = true; mHasPopped = true;
} }
}
if (mHasPopped) {
mScaler.setHeight(newHeight); mScaler.setHeight(newHeight);
// glow if overscale setGlow(GLOW_BASE);
if (target > mNaturalHeight) {
View previous = mCallback.getPreviousChild(mCurrView);
if (previous != null) {
setGlow(0f);
pushView(previous);
initScale(previous);
mInitialTouchY = ev.getY();
target = mOldHeight;
newHeight = clamp(target);
mHasPopped = false;
} else {
setGlow(calculateGlow(target, newHeight));
}
} else if (target < mSmallSize && !popStack.empty()) {
setGlow(0f);
initScale(popView());
mInitialTouchY = ev.getY();
setGlow(GLOW_BASE);
} else {
setGlow(calculateGlow(target, newHeight));
}
} else { } else {
if (target < mSmallSize && !popStack.empty()) { setGlow(calculateGlow(4f * pull, 0f));
setGlow(0f); }
initScale(popView());
mInitialTouchY = ev.getY(); final int x = (int) ev.getX();
setGlow(GLOW_BASE); final int y = (int) ev.getY();
} else { View underPointer = findView(x, y);
setGlow(calculateGlow(4f * target, mSmallSize)); if (isFinished && underPointer != null && underPointer != mCurrView) {
} setGlow(0f);
initScale(underPointer);
mInitialTouchY = ev.getY();
mHasPopped = false;
} }
return true; return true;
} }
@@ -516,9 +498,6 @@ public class ExpandHelper implements Gefingerpoken, OnClickListener {
} }
private void clearView() { private void clearView() {
while (!popStack.empty()) {
popStack.pop();
}
mCurrView = null; mCurrView = null;
mCurrViewTopGlow = null; mCurrViewTopGlow = null;
mCurrViewBottomGlow = null; mCurrViewBottomGlow = null;
@@ -539,33 +518,6 @@ public class ExpandHelper implements Gefingerpoken, OnClickListener {
} }
} }
private void pushView(View v) {
PopState state = new PopState();
state.mCurrView = mCurrView;
state.mCurrViewTopGlow = mCurrViewTopGlow;
state.mCurrViewBottomGlow = mCurrViewBottomGlow;
state.mOldHeight = mOldHeight;
state.mNaturalHeight = mNaturalHeight;
state.mInitialTouchY = mInitialTouchY;
popStack.push(state);
}
private View popView() {
if (popStack.empty()) {
return null;
}
PopState state = popStack.pop();
mCurrView = state.mCurrView;
mCurrViewTopGlow = state.mCurrViewTopGlow;
mCurrViewBottomGlow = state.mCurrViewBottomGlow;
mOldHeight = state.mOldHeight;
mNaturalHeight = state.mNaturalHeight;
mInitialTouchY = state.mInitialTouchY;
return mCurrView;
}
@Override @Override
public void onClick(View v) { public void onClick(View v) {
initScale(v); initScale(v);

View File

@@ -204,20 +204,6 @@ public class NotificationRowLayout
return null; return null;
} }
public View getPreviousChild(View currentChild) {
final int count = getChildCount();
for (int childIdx = 0; childIdx < count; childIdx++) {
if (getChildAt(childIdx) == currentChild) {
if (childIdx == 0) {
return null;
} else {
return getChildAt(childIdx - 1);
}
}
}
return null;
}
public View getChildContentView(View v) { public View getChildContentView(View v) {
return v; return v;
} }