Skip to content

Commit ac47ff7

Browse files
committed
Reset ExpandHelper when the panel is collapsed.
Fixes a rather unpleasant bug in which the ExpandHelper could get locked in "expanding" mode if the panel was closed (for example, with the back button) while you were in the middle of an expand gesture. In this situation ExpandHelper would hungrily eat all future touch events destined for the notification panel, making it impossible to click or even clear any notifications. Bug: 7330828 Change-Id: I9c493db5e8fd8ef1aca53f77820780d60fa4e5a7
1 parent 36425d1 commit ac47ff7

File tree

3 files changed

+44
-27
lines changed

3 files changed

+44
-27
lines changed

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

Lines changed: 39 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -27,13 +27,12 @@
2727
import android.view.Gravity;
2828
import android.view.MotionEvent;
2929
import android.view.ScaleGestureDetector;
30+
import android.view.ScaleGestureDetector.OnScaleGestureListener;
3031
import android.view.View;
3132
import android.view.ViewConfiguration;
3233
import android.view.ViewGroup;
3334
import android.view.View.OnClickListener;
3435

35-
import java.util.Stack;
36-
3736
public class ExpandHelper implements Gefingerpoken, OnClickListener {
3837
public interface Callback {
3938
View getChildAtRawPosition(float x, float y);
@@ -110,6 +109,32 @@ public interface Callback {
110109

111110
private View mScrollView;
112111

112+
private OnScaleGestureListener mScaleGestureListener
113+
= new ScaleGestureDetector.SimpleOnScaleGestureListener() {
114+
@Override
115+
public boolean onScaleBegin(ScaleGestureDetector detector) {
116+
if (DEBUG_SCALE) Slog.v(TAG, "onscalebegin()");
117+
float focusX = detector.getFocusX();
118+
float focusY = detector.getFocusY();
119+
120+
final View underFocus = findView(focusX, focusY);
121+
if (underFocus != null) {
122+
startExpanding(underFocus, STRETCH);
123+
}
124+
return mExpanding;
125+
}
126+
127+
@Override
128+
public boolean onScale(ScaleGestureDetector detector) {
129+
if (DEBUG_SCALE) Slog.v(TAG, "onscale() on " + mCurrView);
130+
return true;
131+
}
132+
133+
@Override
134+
public void onScaleEnd(ScaleGestureDetector detector) {
135+
}
136+
};
137+
113138
private class ViewScaler {
114139
View mView;
115140

@@ -201,31 +226,7 @@ public void onAnimationEnd(Animator animation) {
201226
final ViewConfiguration configuration = ViewConfiguration.get(mContext);
202227
mTouchSlop = configuration.getScaledTouchSlop();
203228

204-
mSGD = new ScaleGestureDetector(context,
205-
new ScaleGestureDetector.SimpleOnScaleGestureListener() {
206-
@Override
207-
public boolean onScaleBegin(ScaleGestureDetector detector) {
208-
if (DEBUG_SCALE) Slog.v(TAG, "onscalebegin()");
209-
float focusX = detector.getFocusX();
210-
float focusY = detector.getFocusY();
211-
212-
final View underFocus = findView(focusX, focusY);
213-
if (underFocus != null) {
214-
startExpanding(underFocus, STRETCH);
215-
}
216-
return mExpanding;
217-
}
218-
219-
@Override
220-
public boolean onScale(ScaleGestureDetector detector) {
221-
if (DEBUG_SCALE) Slog.v(TAG, "onscale() on " + mCurrView);
222-
return true;
223-
}
224-
225-
@Override
226-
public void onScaleEnd(ScaleGestureDetector detector) {
227-
}
228-
});
229+
mSGD = new ScaleGestureDetector(context, mScaleGestureListener);
229230
}
230231

231232
private void updateExpansion() {
@@ -586,6 +587,17 @@ public void onClick(View v) {
586587
clearView();
587588
}
588589

590+
/**
591+
* Use this to abort any pending expansions in progress.
592+
*/
593+
public void cancel() {
594+
finishExpanding(true);
595+
clearView();
596+
597+
// reset the gesture detector
598+
mSGD = new ScaleGestureDetector(mContext, mScaleGestureListener);
599+
}
600+
589601
/**
590602
* Triggers haptic feedback.
591603
*/

packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1368,6 +1368,7 @@ public void animateCollapsePanels(int flags) {
13681368
mHandler.sendEmptyMessage(MSG_CLOSE_SEARCH_PANEL);
13691369
}
13701370

1371+
mStatusBarWindow.cancelExpandHelper();
13711372
mStatusBarView.collapseAllPanels(true);
13721373
}
13731374

packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarWindowView.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,5 +119,9 @@ public void onDraw(Canvas canvas) {
119119
canvas.drawRect(0, 0, canvas.getWidth(), canvas.getHeight(), pt);
120120
}
121121
}
122+
123+
public void cancelExpandHelper() {
124+
mExpandHelper.cancel();
125+
}
122126
}
123127

0 commit comments

Comments
 (0)