Skip to content

Commit dfa6c26

Browse files
cwrenAndroid (Google) Code Review
authored andcommitted
Merge "Venetian blinds policy for one-finger notification expansion." into jb-mr1-dev
2 parents 26ea2e5 + 86d00fb commit dfa6c26

File tree

3 files changed

+29
-91
lines changed

3 files changed

+29
-91
lines changed

packages/SystemUI/res/values/dimens.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,5 +152,5 @@
152152
<dimen name="carrier_label_height">24dp</dimen>
153153

154154
<!-- The distance you can pull a notificaiton before it pops open -->
155-
<dimen name="one_finger_pop_limit">96dp</dimen>
155+
<dimen name="one_finger_pop_limit">32dp</dimen>
156156
</resources>

packages/SystemUI/src/com/android/systemui/ExpandHelper.java

Lines changed: 28 additions & 76 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,6 @@ public class ExpandHelper implements Gefingerpoken, OnClickListener {
3838
public interface Callback {
3939
View getChildAtRawPosition(float x, float y);
4040
View getChildAtPosition(float x, float y);
41-
View getPreviousChild(View currentChild);
4241
boolean canChildBeExpanded(View v);
4342
boolean setUserExpandedChild(View v, boolean userxpanded);
4443
}
@@ -142,17 +141,6 @@ public int getNaturalHeight(int maximum) {
142141
}
143142
}
144143

145-
class PopState {
146-
View mCurrView;
147-
View mCurrViewTopGlow;
148-
View mCurrViewBottomGlow;
149-
float mOldHeight;
150-
float mNaturalHeight;
151-
float mInitialTouchY;
152-
}
153-
154-
private Stack<PopState> popStack;
155-
156144
/**
157145
* Handle expansion gestures to expand and contract children of the callback.
158146
*
@@ -168,7 +156,6 @@ public ExpandHelper(Context context, Callback callback, int small, int large) {
168156
mLargeSize = large;
169157
mContext = context;
170158
mCallback = callback;
171-
popStack = new Stack<PopState>();
172159
mScaler = new ViewScaler();
173160
mGravity = Gravity.TOP;
174161
mScaleAnimation = ObjectAnimator.ofFloat(mScaler, "height", 0f);
@@ -416,45 +403,40 @@ public boolean onTouchEvent(MotionEvent ev) {
416403
switch (action) {
417404
case MotionEvent.ACTION_MOVE: {
418405
if (mPullingWithOneFinger) {
419-
float target = ev.getY() - mInitialTouchY + mOldHeight;
420-
float newHeight = clamp(target);
421-
if (mHasPopped || target > mPopLimit) {
406+
final float rawHeight = ev.getY() - mInitialTouchY + mOldHeight;
407+
final float newHeight = clamp(rawHeight);
408+
final boolean wasClosed = (mOldHeight == mSmallSize);
409+
boolean isFinished = false;
410+
if (rawHeight > mNaturalHeight) {
411+
isFinished = true;
412+
}
413+
if (rawHeight < mSmallSize) {
414+
isFinished = true;
415+
}
416+
417+
final float pull = Math.abs(ev.getY() - mInitialTouchY);
418+
if (mHasPopped || pull > mPopLimit) {
422419
if (!mHasPopped) {
423420
vibrate(mPopDuration);
424421
mHasPopped = true;
425422
}
423+
}
424+
425+
if (mHasPopped) {
426426
mScaler.setHeight(newHeight);
427-
// glow if overscale
428-
if (target > mNaturalHeight) {
429-
View previous = mCallback.getPreviousChild(mCurrView);
430-
if (previous != null) {
431-
setGlow(0f);
432-
pushView(previous);
433-
initScale(previous);
434-
mInitialTouchY = ev.getY();
435-
target = mOldHeight;
436-
newHeight = clamp(target);
437-
mHasPopped = false;
438-
} else {
439-
setGlow(calculateGlow(target, newHeight));
440-
}
441-
} else if (target < mSmallSize && !popStack.empty()) {
442-
setGlow(0f);
443-
initScale(popView());
444-
mInitialTouchY = ev.getY();
445-
setGlow(GLOW_BASE);
446-
} else {
447-
setGlow(calculateGlow(target, newHeight));
448-
}
427+
setGlow(GLOW_BASE);
449428
} else {
450-
if (target < mSmallSize && !popStack.empty()) {
451-
setGlow(0f);
452-
initScale(popView());
453-
mInitialTouchY = ev.getY();
454-
setGlow(GLOW_BASE);
455-
} else {
456-
setGlow(calculateGlow(4f * target, mSmallSize));
457-
}
429+
setGlow(calculateGlow(4f * pull, 0f));
430+
}
431+
432+
final int x = (int) ev.getX();
433+
final int y = (int) ev.getY();
434+
View underPointer = findView(x, y);
435+
if (isFinished && underPointer != null && underPointer != mCurrView) {
436+
setGlow(0f);
437+
initScale(underPointer);
438+
mInitialTouchY = ev.getY();
439+
mHasPopped = false;
458440
}
459441
return true;
460442
}
@@ -516,9 +498,6 @@ private void finishScale(boolean force) {
516498
}
517499

518500
private void clearView() {
519-
while (!popStack.empty()) {
520-
popStack.pop();
521-
}
522501
mCurrView = null;
523502
mCurrViewTopGlow = null;
524503
mCurrViewBottomGlow = null;
@@ -539,33 +518,6 @@ private void setView(View v) {
539518
}
540519
}
541520

542-
private void pushView(View v) {
543-
PopState state = new PopState();
544-
state.mCurrView = mCurrView;
545-
state.mCurrViewTopGlow = mCurrViewTopGlow;
546-
state.mCurrViewBottomGlow = mCurrViewBottomGlow;
547-
state.mOldHeight = mOldHeight;
548-
state.mNaturalHeight = mNaturalHeight;
549-
state.mInitialTouchY = mInitialTouchY;
550-
popStack.push(state);
551-
}
552-
553-
private View popView() {
554-
if (popStack.empty()) {
555-
return null;
556-
}
557-
558-
PopState state = popStack.pop();
559-
mCurrView = state.mCurrView;
560-
mCurrViewTopGlow = state.mCurrViewTopGlow;
561-
mCurrViewBottomGlow = state.mCurrViewBottomGlow;
562-
mOldHeight = state.mOldHeight;
563-
mNaturalHeight = state.mNaturalHeight;
564-
mInitialTouchY = state.mInitialTouchY;
565-
566-
return mCurrView;
567-
}
568-
569521
@Override
570522
public void onClick(View v) {
571523
initScale(v);

packages/SystemUI/src/com/android/systemui/statusbar/policy/NotificationRowLayout.java

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -204,20 +204,6 @@ public View getChildAtPosition(float touchX, float touchY) {
204204
return null;
205205
}
206206

207-
public View getPreviousChild(View currentChild) {
208-
final int count = getChildCount();
209-
for (int childIdx = 0; childIdx < count; childIdx++) {
210-
if (getChildAt(childIdx) == currentChild) {
211-
if (childIdx == 0) {
212-
return null;
213-
} else {
214-
return getChildAt(childIdx - 1);
215-
}
216-
}
217-
}
218-
return null;
219-
}
220-
221207
public View getChildContentView(View v) {
222208
return v;
223209
}

0 commit comments

Comments
 (0)