Esempio n. 1
0
  @Override
  public void onReceive(Context context, Intent intent) {
    if (!MyAccessibilityService.isServiceActive()) {
      return;
    }

    String action = intent.getAction();
    if (action.equals(Intent.ACTION_SCREEN_ON)) {
      onReloadPreferences();
    }
    if (action.equals(Intent.ACTION_SCREEN_OFF)) {
      mIntegratedTapDetector.stop();
    }
  }
Esempio n. 2
0
 /* Handle a double tap on the side of the device */
 @Override
 public void onDoubleTap(long timeStamp) {
   boolean talkBackActive = MyAccessibilityService.isServiceActive();
   boolean tapIsntFromScreenTouch =
       (Math.abs(timeStamp - mLastTouchTime) > MIN_TIME_BETWEEN_TOUCH_AND_TAP_NANOS);
   boolean tapIsntFromHaptic =
       (Math.abs(timeStamp - mLastHapticTime) > MIN_TIME_BETWEEN_HAPTIC_AND_TAP_NANOS);
   if (talkBackActive && tapIsntFromScreenTouch && tapIsntFromHaptic) {
     SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(mContext);
     mGestureController.performAction(
         prefs.getString(
             mContext.getString(R.string.pref_shortcut_double_tap_key),
             mContext.getString(R.string.pref_shortcut_double_tap_default)));
   }
 }