Skip to content

Commit 061a4de

Browse files
cwrenAndroid (Google) Code Review
authored andcommitted
Merge "resolve conflicting assumptions from the merge." into jb-mr1-dev
2 parents a2f7ca7 + cea5207 commit 061a4de

File tree

1 file changed

+32
-16
lines changed

1 file changed

+32
-16
lines changed

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

Lines changed: 32 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,8 @@ public interface Callback {
8686
private float mInitialTouchFocusY;
8787
private float mInitialTouchY;
8888
private float mInitialTouchSpan;
89+
private float mLastFocusY;
90+
private float mLastSpanY;
8991
private int mTouchSlop;
9092
private int mLastMotionY;
9193
private float mPopLimit;
@@ -207,11 +209,6 @@ public boolean onScaleBegin(ScaleGestureDetector detector) {
207209
float focusX = detector.getFocusX();
208210
float focusY = detector.getFocusY();
209211

210-
// your fingers have to be somewhat close to the bounds of the view in question
211-
mInitialTouchFocusY = focusY;
212-
mInitialTouchSpan = Math.abs(detector.getCurrentSpan());
213-
if (DEBUG_SCALE) Slog.d(TAG, "got mInitialTouchSpan: (" + mInitialTouchSpan + ")");
214-
215212
final View underFocus = findView(focusX, focusY);
216213
if (underFocus != null) {
217214
startExpanding(underFocus, STRETCH);
@@ -222,24 +219,19 @@ public boolean onScaleBegin(ScaleGestureDetector detector) {
222219
@Override
223220
public boolean onScale(ScaleGestureDetector detector) {
224221
if (DEBUG_SCALE) Slog.v(TAG, "onscale() on " + mCurrView);
225-
updateExpansion();
226222
return true;
227223
}
228224

229225
@Override
230226
public void onScaleEnd(ScaleGestureDetector detector) {
231-
if (DEBUG_SCALE) Slog.v(TAG, "onscaleend()");
232-
// I guess we're alone now
233-
if (DEBUG_SCALE) Slog.d(TAG, "scale end");
234-
finishExpanding(false);
235-
clearView();
236227
}
237228
});
238229
}
239230

240231
private void updateExpansion() {
232+
if (DEBUG_SCALE) Slog.v(TAG, "updateExpansion()");
241233
// are we scaling or dragging?
242-
float span = Math.abs(mSGD.getCurrentSpan()) - mInitialTouchSpan;
234+
float span = mSGD.getCurrentSpan() - mInitialTouchSpan;
243235
span *= USE_SPAN ? 1f : 0f;
244236
float drag = mSGD.getFocusY() - mInitialTouchFocusY;
245237
drag *= USE_DRAG ? 1f : 0f;
@@ -251,6 +243,8 @@ private void updateExpansion() {
251243
mScaler.setHeight(newHeight);
252244

253245
setGlow(calculateGlow(target, newHeight));
246+
mLastFocusY = mSGD.getFocusY();
247+
mLastSpanY = mSGD.getCurrentSpan();
254248
}
255249

256250
private float clamp(float target) {
@@ -362,6 +356,13 @@ public boolean onInterceptTouchEvent(MotionEvent ev) {
362356
mSGD.onTouchEvent(ev);
363357
final int x = (int) mSGD.getFocusX();
364358
final int y = (int) mSGD.getFocusY();
359+
360+
mInitialTouchFocusY = y;
361+
mInitialTouchSpan = mSGD.getCurrentSpan();
362+
mLastFocusY = mInitialTouchFocusY;
363+
mLastSpanY = mInitialTouchSpan;
364+
if (DEBUG_SCALE) Slog.d(TAG, "set initial span: " + mInitialTouchSpan);
365+
365366
if (mExpanding) {
366367
return true;
367368
} else {
@@ -376,8 +377,6 @@ public boolean onInterceptTouchEvent(MotionEvent ev) {
376377
// detect a vertical pulling gesture with fingers somewhat separated
377378
if (DEBUG_SCALE) Slog.v(TAG, "got pull gesture (xspan=" + xspan + "px)");
378379

379-
mInitialTouchFocusY = y;
380-
381380
final View underFocus = findView(x, y);
382381
if (underFocus != null) {
383382
startExpanding(underFocus, PULL);
@@ -424,7 +423,7 @@ public boolean onInterceptTouchEvent(MotionEvent ev) {
424423

425424
@Override
426425
public boolean onTouchEvent(MotionEvent ev) {
427-
final int action = ev.getAction();
426+
final int action = ev.getActionMasked();
428427
if (DEBUG_SCALE) Slog.d(TAG, "touch: act=" + MotionEvent.actionToString(action) +
429428
" expanding=" + mExpanding +
430429
(0 != (mExpansionStyle & BLINDS) ? " (blinds)" : "") +
@@ -481,6 +480,14 @@ public boolean onTouchEvent(MotionEvent ev) {
481480

482481
break;
483482
}
483+
484+
case MotionEvent.ACTION_POINTER_UP:
485+
case MotionEvent.ACTION_POINTER_DOWN:
486+
if (DEBUG) Slog.d(TAG, "pointer change");
487+
mInitialTouchY += mSGD.getFocusY() - mLastFocusY;
488+
mInitialTouchSpan += mSGD.getCurrentSpan() - mLastSpanY;
489+
break;
490+
484491
case MotionEvent.ACTION_UP:
485492
case MotionEvent.ACTION_CANCEL:
486493
if (DEBUG) Slog.d(TAG, "up/cancel");
@@ -492,8 +499,11 @@ public boolean onTouchEvent(MotionEvent ev) {
492499
}
493500

494501
private void startExpanding(View v, int expandType) {
502+
mExpansionStyle = expandType;
503+
if (mExpanding && v == mCurrView) {
504+
return;
505+
}
495506
mExpanding = true;
496-
mExpansionStyle = expandType;
497507
if (DEBUG) Slog.d(TAG, "scale type " + expandType + " beginning on view: " + v);
498508
mCallback.setUserLockedChild(v, true);
499509
setView(v);
@@ -515,6 +525,8 @@ private void startExpanding(View v, int expandType) {
515525
private void finishExpanding(boolean force) {
516526
if (!mExpanding) return;
517527

528+
if (DEBUG) Slog.d(TAG, "scale in finishing on view: " + mCurrView);
529+
518530
float currentHeight = mScaler.getHeight();
519531
float targetHeight = mSmallSize;
520532
float h = mScaler.getHeight();
@@ -539,6 +551,10 @@ private void finishExpanding(boolean force) {
539551
mExpanding = false;
540552
mExpansionStyle = NONE;
541553

554+
if (DEBUG) Slog.d(TAG, "wasClosed is: " + wasClosed);
555+
if (DEBUG) Slog.d(TAG, "currentHeight is: " + currentHeight);
556+
if (DEBUG) Slog.d(TAG, "mSmallSize is: " + mSmallSize);
557+
if (DEBUG) Slog.d(TAG, "targetHeight is: " + targetHeight);
542558
if (DEBUG) Slog.d(TAG, "scale was finished on view: " + mCurrView);
543559
}
544560

0 commit comments

Comments
 (0)