SetupWizard: Handle all touch events in EnableAccessibilityController

Change-Id: Icf15be21c90d32305a9c1f8b9835eb473acf1f33
(cherry picked from commit 0fde3a04cc62396b524aadb6a1a30f573a4b1b38)
This commit is contained in:
cretin45 2015-04-08 12:09:55 -07:00 committed by Ed Carrigan
parent e79aa7f0bf
commit 6d63e95342
2 changed files with 17 additions and 7 deletions

View File

@ -124,7 +124,9 @@ public class SetupWizardActivity extends Activity implements SetupDataCallbacks,
mRootView.setOnTouchListener(new View.OnTouchListener() { mRootView.setOnTouchListener(new View.OnTouchListener() {
@Override @Override
public boolean onTouch(View v, MotionEvent event) { public boolean onTouch(View v, MotionEvent event) {
return mEnableAccessibilityController.onInterceptTouchEvent(event); return
mEnableAccessibilityController.onInterceptTouchEvent(event) &
mEnableAccessibilityController.onTouchEvent(event);
} }
}); });
registerReceiver(mSetupData, mSetupData.getIntentFilter()); registerReceiver(mSetupData, mSetupData.getIntentFilter());

View File

@ -130,7 +130,7 @@ public class EnableAccessibilityController {
// accessibility service, then we have nothing to do. // accessibility service, then we have nothing to do.
if (accessibilityManager.isEnabled() if (accessibilityManager.isEnabled()
&& !accessibilityManager.getEnabledAccessibilityServiceList( && !accessibilityManager.getEnabledAccessibilityServiceList(
AccessibilityServiceInfo.FEEDBACK_SPOKEN).isEmpty()) { AccessibilityServiceInfo.FEEDBACK_SPOKEN).isEmpty()) {
return false; return false;
} }
@ -168,7 +168,7 @@ public class EnableAccessibilityController {
mHandler.sendEmptyMessageDelayed(MESSAGE_SPEAK_WARNING, mHandler.sendEmptyMessageDelayed(MESSAGE_SPEAK_WARNING,
SPEAK_WARNING_DELAY_MILLIS); SPEAK_WARNING_DELAY_MILLIS);
mHandler.sendEmptyMessageDelayed(MESSAGE_ENABLE_ACCESSIBILITY, mHandler.sendEmptyMessageDelayed(MESSAGE_ENABLE_ACCESSIBILITY,
ENABLE_ACCESSIBILITY_DELAY_MILLIS); ENABLE_ACCESSIBILITY_DELAY_MILLIS);
return true; return true;
} }
return false; return false;
@ -188,8 +188,14 @@ public class EnableAccessibilityController {
if (pointerCount > 2) { if (pointerCount > 2) {
cancel(); cancel();
} }
} break; }
break;
case MotionEvent.ACTION_MOVE: { case MotionEvent.ACTION_MOVE: {
//We only care about a 2 fingered move
if (pointerCount < 2) {
cancel();
return false;
}
final float firstPointerMove = MathUtils.dist(event.getX(0), final float firstPointerMove = MathUtils.dist(event.getX(0),
event.getY(0), mFirstPointerDownX, mFirstPointerDownY); event.getY(0), mFirstPointerDownX, mFirstPointerDownY);
if (Math.abs(firstPointerMove) > mTouchSlop) { if (Math.abs(firstPointerMove) > mTouchSlop) {
@ -200,11 +206,13 @@ public class EnableAccessibilityController {
if (Math.abs(secondPointerMove) > mTouchSlop) { if (Math.abs(secondPointerMove) > mTouchSlop) {
cancel(); cancel();
} }
} break; }
break;
case MotionEvent.ACTION_POINTER_UP: case MotionEvent.ACTION_POINTER_UP:
case MotionEvent.ACTION_CANCEL: { case MotionEvent.ACTION_CANCEL: {
cancel(); cancel();
} break; }
break;
} }
return true; return true;
} }
@ -287,4 +295,4 @@ public class EnableAccessibilityController {
} }
} }
} }
} }