/** * Updates the preference that controls whether TalkBack will attempt to request Explore by Touch. * * @param requestedState The state requested by the user. * @return Whether to update the reflected state. */ private boolean setTouchExplorationRequested(boolean requestedState) { final SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(TalkBackPreferencesActivity.this); // Update the "requested" state. This will trigger a listener in // TalkBack that changes the "actual" state. SharedPreferencesUtils.putBooleanPref( prefs, getResources(), R.string.pref_explore_by_touch_key, requestedState); // If TalkBack is inactive, we should immediately reflect the change in // "requested" state. if (!MyAccessibilityService.isServiceActive()) { return true; } if (requestedState && MyAccessibilityService.getInstance() != null) { // TODO // MyAccessibilityService.getInstance().showTutorial(); } // If accessibility is on, we should wait for the "actual" state to // change, then reflect that change. If the user declines the system's // touch exploration dialog, the "actual" state will not change and // nothing needs to happen. LogUtils.log(this, Log.DEBUG, "TalkBack active, waiting for EBT request to take effect"); return false; }
@Override public void onPause() { super.onPause(); MyAccessibilityService talkBackService = MyAccessibilityService.getInstance(); if (talkBackService != null && talkBackService.supportsTouchScreen()) { getContentResolver().unregisterContentObserver(mTouchExploreObserver); } if (mExploreByTouchDialog != null) { mExploreByTouchDialog.dismiss(); } if (mTreeDebugDialog != null) { mTreeDebugDialog.dismiss(); } }
private void updateTalkBackShortcutStatus() { final CheckBoxPreference preference = (CheckBoxPreference) findPreferenceByResId(R.string.pref_two_volume_long_press_key); if (preference == null) { return; } if (Build.VERSION.SDK_INT >= ProcessorVolumeStream.MIN_API_LEVEL) { preference.setEnabled(MyAccessibilityService.getInstance() != null || preference.isChecked()); } else { final PreferenceGroup category = (PreferenceGroup) findPreferenceByResId(R.string.pref_category_miscellaneous_key); if (category == null) { return; } category.removePreference(preference); } }
@Override public void onResume() { super.onResume(); MyAccessibilityService talkBackService = MyAccessibilityService.getInstance(); if (talkBackService != null && talkBackService.supportsTouchScreen()) { registerTouchSettingObserver(); } if (mExploreByTouchDialog != null) { mExploreByTouchDialog.show(); } if (mTreeDebugDialog != null) { mTreeDebugDialog.show(); } updateTalkBackShortcutStatus(); updateDimingPreferenceStatus(); }