Merge "Update of accessibility settings"
This commit is contained in:
committed by
Android (Google) Code Review
commit
76631f3a90
@@ -15,6 +15,7 @@
|
||||
-->
|
||||
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:id="@+id/message_container"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical" >
|
||||
|
@@ -2718,38 +2718,49 @@ found in the list of installed applications.</string>
|
||||
<!-- Summary for the allowed state of script injection. [CHAR LIMIT=15] -->
|
||||
<string name="accessibility_script_injection_allowed">Allowed</string>
|
||||
<!-- Summary for the disallowed state of script injection. [CHAR LIMIT=15] -->
|
||||
<string name="accessibility_script_injection_disallowed">Disallowed</string>
|
||||
<string name="accessibility_script_injection_disallowed">Not allowed</string>
|
||||
|
||||
<!-- Title for the dialog button to allow script injection. [CHAR LIMIT=15] -->
|
||||
<string name="accessibility_script_injection_button_allow">Allow</string>
|
||||
<!-- Title for the dialog button to disallow script injection. [CHAR LIMIT=15] -->
|
||||
<string name="accessibility_script_injection_button_disallow">Don\'t Allow</string>
|
||||
|
||||
<!-- Warning message about security implications of enabling an accessibility service,
|
||||
<!-- Title for a warning message about security implications of enabling an accessibility service,
|
||||
displayed as a dialog message when the user selects to enable an accessibility service (tablet). [CHAR LIMIT=NONE] -->
|
||||
<string name="accessibility_service_security_warning">
|
||||
<string name="accessibility_service_security_warning_title">Use
|
||||
<xliff:g id="service" example="TalkBack">%1$s</xliff:g>?</string>
|
||||
<!-- Summary for a warning message about security implications of enabling an accessibility service,
|
||||
displayed as a dialog message when the user selects to enable an accessibility service (tablet). [CHAR LIMIT=NONE] -->
|
||||
<string name="accessibility_service_security_warning_summary">
|
||||
<xliff:g id="accessibility_service_name">%1$s</xliff:g> can
|
||||
collect all of the text you type, except passwords. This includes personal data such as credit card
|
||||
numbers. It can also collect data about your interactions with the device.</string>
|
||||
<!-- Title for a warning about disabling accessibility displayed as a dialog message when the user
|
||||
selects to disable accessibility. This avoids accidental disabling. [CHAR LIMIT=30] -->
|
||||
<string name="accessibility_disable_warning_title">Turn accessibility off?</string>
|
||||
<!-- Summary for a warning about disabling accessibility displayed as a dialog message when the user
|
||||
selects to disable accessibility. This avoids accidental disabling. [CHAR LIMIT=NONE] -->
|
||||
<string name="accessibility_disable_warning_summary">Touching OK will stop spoken
|
||||
descriptions and all other accessibility features you\'ve been using.</string>
|
||||
|
||||
<!-- Title for a warning about disabling an accessibility service displayed as a dialog message when the user
|
||||
selects to disable that service. This avoids accidental disabling. [CHAR LIMIT=NONE] -->
|
||||
<string name="accessibility_service_disable_warning_title">Stop
|
||||
<xliff:g id="service" example="TalkBack">%1$s</xliff:g>?</string>
|
||||
<!-- Summary for a warning about disabling accessibility service displayed as a dialog message when the user
|
||||
selects to disable that service. This avoids accidental disabling. [CHAR LIMIT=NONE] -->
|
||||
<string name="accessibility_service_disable_warning_summary">Touching OK will
|
||||
stop <xliff:g id="service" example="TalkBack">%1$s</xliff:g>.</string>
|
||||
|
||||
<!-- Title for the prompt that lets users know that they have no accessibility related apps
|
||||
installed and that they can install TalkBack from Market. [CHAR LIMIT=50] -->
|
||||
<string name="accessibility_service_no_apps_title">No accessibility applications
|
||||
</string>
|
||||
<string name="accessibility_service_no_apps_title">No accessibility applications</string>
|
||||
<!-- Message for the prompt that lets users know that they have no accessibility related apps
|
||||
installed and that they can install TalkBack from Market. [CHAR LIMIT=NONE] -->
|
||||
<string name="accessibility_service_no_apps_message">You don\'t have accessibility
|
||||
applications installed. Do you want to download a screen reader from the Android Market?</string>
|
||||
|
||||
<!-- Title for a warning about downloading accessibility scripts displayed as a dialog message
|
||||
when the user selects to enable script downloading. [CHAR LIMIT=40] -->
|
||||
<string name="accessibility_script_injection_security_warning_title">Install accessibility scripts?</string>
|
||||
<!-- Warning message about security implications of downloading accessibility scripts,
|
||||
displayed as a dialog message when the user selects to enable script downloading. [CHAR LIMIT=NONE] -->
|
||||
<string name="accessibility_script_injection_security_warning">Do you want applications to install
|
||||
<string name="accessibility_script_injection_security_warning_summary">Do you want applications to install
|
||||
scripts from Google that will make their content more accessible?</string>
|
||||
|
||||
<!-- Warning message that the interaction model changes on enabling touch exploration. [CHAR LIMIT=NONE] -->
|
||||
<string name="accessibility_touch_exploration_warning">This feature changes the
|
||||
way your device responds to touch. Turn on?</string>
|
||||
@@ -2757,6 +2768,7 @@ found in the list of installed applications.</string>
|
||||
<string name="accessibility_service_default_description">This accessibility service has no
|
||||
description.\n\nAccessibility services provide various types of feedback when you interact
|
||||
with the device. </string>
|
||||
|
||||
<!-- Accessibility settings: button for lauching settings for an accessibility service -->
|
||||
<string name="settings_button">Settings</string>
|
||||
|
||||
|
@@ -30,13 +30,17 @@
|
||||
<CheckBoxPreference
|
||||
android:key="toggle_large_text_preference"
|
||||
android:title="@string/accessibility_toggle_large_text_title"
|
||||
android:persistent="true"/>
|
||||
android:persistent="false"/>
|
||||
|
||||
<CheckBoxPreference
|
||||
android:key="toggle_power_button_ends_call_preference"
|
||||
android:title="@string/accessibility_power_button_ends_call_title"
|
||||
android:persistent="true">
|
||||
</CheckBoxPreference>
|
||||
android:persistent="false"/>
|
||||
|
||||
<CheckBoxPreference
|
||||
android:key="toggle_auto_rotate_screen_preference"
|
||||
android:title="@string/accelerometer_title"
|
||||
android:persistent="false"/>
|
||||
|
||||
<PreferenceScreen
|
||||
android:key="toggle_touch_exploration_preference"
|
||||
@@ -44,7 +48,8 @@
|
||||
android:fragment="com.android.settings.AccessibilitySettings$ToggleTouchExplorationFragment" >
|
||||
<extra android:name="title" android:value="@string/accessibility_touch_exploration_title" />
|
||||
<extra android:name="summary" android:value="@string/accessibility_touch_exploration_summary" />
|
||||
<extra android:name="warning_message" android:value="@string/accessibility_touch_exploration_warning" />
|
||||
<extra android:name="enable_warning_title" android:value="@android:string/dialog_alert_title" />
|
||||
<extra android:name="enable_warning_message" android:value="@string/accessibility_touch_exploration_warning" />
|
||||
<extra android:name="settings_title" android:value="@string/accessibility_menu_item_tutorial" />
|
||||
<extra android:name="settings_component_name" android:value="com.android.settings/com.android.settings.AccessibilityTutorialActivity" />
|
||||
</PreferenceScreen>
|
||||
@@ -53,17 +58,17 @@
|
||||
android:title="@string/accessibility_long_press_timeout_title"
|
||||
android:entries="@array/long_press_timeout_selector_titles"
|
||||
android:entryValues="@array/long_press_timeout_selector_values"
|
||||
android:persistent="true" />
|
||||
android:persistent="false"/>
|
||||
|
||||
<com.android.settings.AccessibilityEnableScriptInjectionPreference
|
||||
android:key="toggle_script_injection_preference"
|
||||
android:title="@string/accessibility_script_injection_title"
|
||||
android:dialogTitle="@android:string/dialog_alert_title"
|
||||
android:dialogTitle="@string/accessibility_script_injection_security_warning_title"
|
||||
android:dialogIcon="@android:drawable/ic_dialog_alert"
|
||||
android:dialogMessage="@string/accessibility_script_injection_security_warning"
|
||||
android:dialogMessage="@string/accessibility_script_injection_security_warning_summary"
|
||||
android:positiveButtonText="@string/accessibility_script_injection_button_allow"
|
||||
android:negativeButtonText="@string/accessibility_script_injection_button_disallow"
|
||||
android:persistent="true" />
|
||||
android:persistent="false"/>
|
||||
|
||||
</PreferenceCategory>
|
||||
|
||||
|
@@ -53,6 +53,7 @@ import android.view.MenuItem;
|
||||
import android.view.View;
|
||||
import android.view.accessibility.AccessibilityEvent;
|
||||
import android.view.accessibility.AccessibilityManager;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.Switch;
|
||||
import android.widget.TextView;
|
||||
|
||||
@@ -99,6 +100,8 @@ public class AccessibilitySettings extends SettingsPreferenceFragment implements
|
||||
private static final String TOGGLE_LARGE_TEXT_PREFERENCE = "toggle_large_text_preference";
|
||||
private static final String TOGGLE_POWER_BUTTON_ENDS_CALL_PREFERENCE =
|
||||
"toggle_power_button_ends_call_preference";
|
||||
private static final String TOGGLE_AUTO_ROTATE_SCREEN_PREFERENCE =
|
||||
"toggle_auto_rotate_screen_preference";
|
||||
private static final String TOGGLE_TOUCH_EXPLORATION_PREFERENCE =
|
||||
"toggle_touch_exploration_preference";
|
||||
private static final String SELECT_LONG_PRESS_TIMEOUT_PREFERENCE =
|
||||
@@ -111,13 +114,15 @@ public class AccessibilitySettings extends SettingsPreferenceFragment implements
|
||||
private static final String EXTRA_CHECKED = "checked";
|
||||
private static final String EXTRA_TITLE = "title";
|
||||
private static final String EXTRA_SUMMARY = "summary";
|
||||
private static final String EXTRA_WARNING_MESSAGE = "warning_message";
|
||||
private static final String EXTRA_ENABLE_WARNING_TITLE = "enable_warning_title";
|
||||
private static final String EXTRA_ENABLE_WARNING_MESSAGE = "enable_warning_message";
|
||||
private static final String EXTRA_DISABLE_WARNING_TITLE = "disable_warning_title";
|
||||
private static final String EXTRA_DISABLE_WARNING_MESSAGE = "disable_warning_message";
|
||||
private static final String EXTRA_SETTINGS_TITLE = "settings_title";
|
||||
private static final String EXTRA_SETTINGS_COMPONENT_NAME = "settings_component_name";
|
||||
|
||||
// Dialog IDs.
|
||||
private static final int DIALOG_ID_DISABLE_ACCESSIBILITY = 1;
|
||||
private static final int DIALOG_ID_NO_ACCESSIBILITY_SERVICES = 2;
|
||||
private static final int DIALOG_ID_NO_ACCESSIBILITY_SERVICES = 1;
|
||||
|
||||
// Auxiliary members.
|
||||
private final SimpleStringSplitter mStringColonSplitter =
|
||||
@@ -134,18 +139,17 @@ public class AccessibilitySettings extends SettingsPreferenceFragment implements
|
||||
@Override
|
||||
public void dispatchMessage(Message msg) {
|
||||
super.dispatchMessage(msg);
|
||||
updateServicesPreferences(mToggleAccessibilitySwitch.isChecked());
|
||||
updateServicesPreferences();
|
||||
}
|
||||
};
|
||||
|
||||
// Preference controls.
|
||||
private ToggleSwitch mToggleAccessibilitySwitch;
|
||||
|
||||
private PreferenceCategory mServicesCategory;
|
||||
private PreferenceCategory mSystemsCategory;
|
||||
|
||||
private CheckBoxPreference mToggleLargeTextPreference;
|
||||
private CheckBoxPreference mTogglePowerButtonEndsCallPreference;
|
||||
private CheckBoxPreference mToggleAutoRotateScreenPreference;
|
||||
private Preference mToggleTouchExplorationPreference;
|
||||
private ListPreference mSelectLongPressTimeoutPreference;
|
||||
private AccessibilityEnableScriptInjectionPreference mToggleScriptInjectionPreference;
|
||||
@@ -162,9 +166,8 @@ public class AccessibilitySettings extends SettingsPreferenceFragment implements
|
||||
@Override
|
||||
public void onResume() {
|
||||
super.onResume();
|
||||
final boolean accessibilityEnabled = mToggleAccessibilitySwitch.isChecked();
|
||||
updateAllPreferences(accessibilityEnabled);
|
||||
if (accessibilityEnabled) {
|
||||
updateAllPreferences();
|
||||
if (mServicesCategory.getPreference(0) == mNoServicesMessagePreference) {
|
||||
offerInstallAccessibilitySerivceOnce();
|
||||
}
|
||||
mSettingsPackageMonitor.register(getActivity(), false);
|
||||
@@ -176,18 +179,6 @@ public class AccessibilitySettings extends SettingsPreferenceFragment implements
|
||||
super.onPause();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onViewCreated(View view, Bundle savedInstanceState) {
|
||||
addToggleAccessibilitySwitch();
|
||||
super.onViewCreated(view, savedInstanceState);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDestroyView() {
|
||||
removeToggleAccessibilitySwitch();
|
||||
super.onDestroyView();
|
||||
}
|
||||
|
||||
public boolean onPreferenceChange(Preference preference, Object newValue) {
|
||||
if (preference == mSelectLongPressTimeoutPreference) {
|
||||
String stringValue = (String) newValue;
|
||||
@@ -202,13 +193,15 @@ public class AccessibilitySettings extends SettingsPreferenceFragment implements
|
||||
|
||||
@Override
|
||||
public boolean onPreferenceTreeClick(PreferenceScreen preferenceScreen, Preference preference) {
|
||||
final String key = preference.getKey();
|
||||
if (mToggleLargeTextPreference == preference) {
|
||||
handleToggleLargeTextPreferenceClick();
|
||||
return true;
|
||||
} else if (mTogglePowerButtonEndsCallPreference == preference) {
|
||||
handleTogglePowerButtonEndsCallPreferenceClick();
|
||||
return true;
|
||||
} else if (mToggleAutoRotateScreenPreference == preference) {
|
||||
handleToggleAutoRotateScreenPreferenceClick();
|
||||
return true;
|
||||
}
|
||||
return super.onPreferenceTreeClick(preferenceScreen, preference);
|
||||
}
|
||||
@@ -230,88 +223,34 @@ public class AccessibilitySettings extends SettingsPreferenceFragment implements
|
||||
: Settings.Secure.INCALL_POWER_BUTTON_BEHAVIOR_SCREEN_OFF));
|
||||
}
|
||||
|
||||
private void addToggleAccessibilitySwitch() {
|
||||
mToggleAccessibilitySwitch = createAndAddActionBarToggleSwitch(getActivity());
|
||||
final boolean checked = (Settings.Secure.getInt(getContentResolver(),
|
||||
Settings.Secure.ACCESSIBILITY_ENABLED, 0) == 1);
|
||||
mToggleAccessibilitySwitch.setChecked(checked);
|
||||
mToggleAccessibilitySwitch.setOnBeforeCheckedChangeListener(
|
||||
new OnBeforeCheckedChangeListener() {
|
||||
@Override
|
||||
public boolean onBeforeCheckedChanged(ToggleSwitch toggleSwitch, boolean checked) {
|
||||
if (!checked) {
|
||||
toggleSwitch.setCheckedInternal(true);
|
||||
showDialog(DIALOG_ID_DISABLE_ACCESSIBILITY);
|
||||
return true;
|
||||
}
|
||||
Settings.Secure.putInt(getContentResolver(),
|
||||
Settings.Secure.ACCESSIBILITY_ENABLED, 1);
|
||||
updateAllPreferences(true);
|
||||
offerInstallAccessibilitySerivceOnce();
|
||||
return false;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void removeToggleAccessibilitySwitch() {
|
||||
mToggleAccessibilitySwitch.setOnBeforeCheckedChangeListener(null);
|
||||
getActivity().getActionBar().setCustomView(null);
|
||||
private void handleToggleAutoRotateScreenPreferenceClick() {
|
||||
Settings.System.putInt(getContentResolver(),
|
||||
Settings.System.ACCELEROMETER_ROTATION,
|
||||
(mToggleAutoRotateScreenPreference.isChecked() ? 1 : 0));
|
||||
}
|
||||
|
||||
private void initializeAllPreferences() {
|
||||
// The basic logic here is if accessibility is not enabled all accessibility
|
||||
// settings will have no effect but still their selected state should be kept
|
||||
// unchanged, so the user can see what settings will be enabled when turning
|
||||
// on accessibility.
|
||||
|
||||
final boolean accessibilityEnabled = (Settings.Secure.getInt(getContentResolver(),
|
||||
Settings.Secure.ACCESSIBILITY_ENABLED, 0) == 1);
|
||||
|
||||
mServicesCategory = (PreferenceCategory) findPreference(SERVICES_CATEGORY);
|
||||
mSystemsCategory = (PreferenceCategory) findPreference(SYSTEM_CATEGORY);
|
||||
|
||||
// Large text.
|
||||
mToggleLargeTextPreference =
|
||||
(CheckBoxPreference) findPreference(TOGGLE_LARGE_TEXT_PREFERENCE);
|
||||
if (accessibilityEnabled) {
|
||||
try {
|
||||
mCurConfig.updateFrom(ActivityManagerNative.getDefault().getConfiguration());
|
||||
} catch (RemoteException re) {
|
||||
/* ignore */
|
||||
}
|
||||
mToggleLargeTextPreference.setChecked(mCurConfig.fontScale == LARGE_FONT_SCALE);
|
||||
}
|
||||
|
||||
// Power button ends calls.
|
||||
mTogglePowerButtonEndsCallPreference =
|
||||
(CheckBoxPreference) findPreference(TOGGLE_POWER_BUTTON_ENDS_CALL_PREFERENCE);
|
||||
if (KeyCharacterMap.deviceHasKey(KeyEvent.KEYCODE_POWER)
|
||||
&& Utils.isVoiceCapable(getActivity())) {
|
||||
if (accessibilityEnabled) {
|
||||
final int incallPowerBehavior = Settings.Secure.getInt(getContentResolver(),
|
||||
Settings.Secure.INCALL_POWER_BUTTON_BEHAVIOR,
|
||||
Settings.Secure.INCALL_POWER_BUTTON_BEHAVIOR_DEFAULT);
|
||||
final boolean powerButtonEndsCall =
|
||||
(incallPowerBehavior == Settings.Secure.INCALL_POWER_BUTTON_BEHAVIOR_HANGUP);
|
||||
mTogglePowerButtonEndsCallPreference.setChecked(powerButtonEndsCall);
|
||||
}
|
||||
} else {
|
||||
if (!KeyCharacterMap.deviceHasKey(KeyEvent.KEYCODE_POWER)
|
||||
|| !Utils.isVoiceCapable(getActivity())) {
|
||||
mSystemsCategory.removePreference(mTogglePowerButtonEndsCallPreference);
|
||||
}
|
||||
|
||||
// Auto-rotate screen
|
||||
mToggleAutoRotateScreenPreference =
|
||||
(CheckBoxPreference) findPreference(TOGGLE_AUTO_ROTATE_SCREEN_PREFERENCE);
|
||||
|
||||
// Touch exploration enabled.
|
||||
mToggleTouchExplorationPreference = findPreference(TOGGLE_TOUCH_EXPLORATION_PREFERENCE);
|
||||
final boolean touchExplorationEnabled = (Settings.Secure.getInt(getContentResolver(),
|
||||
Settings.Secure.TOUCH_EXPLORATION_ENABLED, 0) == 1);
|
||||
if (touchExplorationEnabled) {
|
||||
mToggleTouchExplorationPreference.setSummary(
|
||||
getString(R.string.accessibility_service_state_on));
|
||||
mToggleTouchExplorationPreference.getExtras().putBoolean(EXTRA_CHECKED, true);
|
||||
} else {
|
||||
mToggleTouchExplorationPreference.setSummary(
|
||||
getString(R.string.accessibility_service_state_off));
|
||||
mToggleTouchExplorationPreference.getExtras().putBoolean(EXTRA_CHECKED, false);
|
||||
}
|
||||
|
||||
// Long press timeout.
|
||||
mSelectLongPressTimeoutPreference =
|
||||
@@ -328,34 +267,18 @@ public class AccessibilitySettings extends SettingsPreferenceFragment implements
|
||||
mLongPressTimeoutValuetoTitleMap.put(timeoutValues[i], timeoutTitles[i]);
|
||||
}
|
||||
}
|
||||
if (accessibilityEnabled) {
|
||||
final int longPressTimeout = Settings.Secure.getInt(getContentResolver(),
|
||||
Settings.Secure.LONG_PRESS_TIMEOUT, mLongPressTimeoutDefault);
|
||||
String value = String.valueOf(longPressTimeout);
|
||||
mSelectLongPressTimeoutPreference.setValue(value);
|
||||
mSelectLongPressTimeoutPreference.setSummary(
|
||||
mLongPressTimeoutValuetoTitleMap.get(value));
|
||||
} else {
|
||||
Settings.Secure.putInt(getContentResolver(), Settings.Secure.LONG_PRESS_TIMEOUT,
|
||||
mLongPressTimeoutDefault);
|
||||
}
|
||||
|
||||
// Script injection.
|
||||
mToggleScriptInjectionPreference = (AccessibilityEnableScriptInjectionPreference)
|
||||
findPreference(TOGGLE_SCRIPT_INJECTION_PREFERENCE);
|
||||
if (accessibilityEnabled) {
|
||||
final boolean scriptInjectionAllowed = (Settings.Secure.getInt(getContentResolver(),
|
||||
Settings.Secure.ACCESSIBILITY_SCRIPT_INJECTION, 0) == 1);
|
||||
mToggleScriptInjectionPreference.setInjectionAllowed(scriptInjectionAllowed);
|
||||
}
|
||||
}
|
||||
|
||||
private void updateAllPreferences(boolean accessibilityEnabled) {
|
||||
updateServicesPreferences(accessibilityEnabled);
|
||||
updateSystemPreferences(accessibilityEnabled);
|
||||
private void updateAllPreferences() {
|
||||
updateServicesPreferences();
|
||||
updateSystemPreferences();
|
||||
}
|
||||
|
||||
private void updateServicesPreferences(boolean accessibilityEnabled) {
|
||||
private void updateServicesPreferences() {
|
||||
// Since services category is auto generated we have to do a pass
|
||||
// to generate it since services can come and go and then based on
|
||||
// the global accessibility state to decided whether it is enabled.
|
||||
@@ -381,7 +304,6 @@ public class AccessibilitySettings extends SettingsPreferenceFragment implements
|
||||
|
||||
for (int i = 0, count = installedServices.size(); i < count; ++i) {
|
||||
AccessibilityServiceInfo info = installedServices.get(i);
|
||||
String key = info.getId();
|
||||
|
||||
PreferenceScreen preference = getPreferenceManager().createPreferenceScreen(
|
||||
getActivity());
|
||||
@@ -416,9 +338,19 @@ public class AccessibilitySettings extends SettingsPreferenceFragment implements
|
||||
}
|
||||
extras.putString(EXTRA_SUMMARY, description);
|
||||
|
||||
extras.putString(EXTRA_WARNING_MESSAGE, getString(
|
||||
R.string.accessibility_service_security_warning,
|
||||
info.getResolveInfo().loadLabel(getPackageManager())));
|
||||
CharSequence applicationLabel = info.getResolveInfo().loadLabel(getPackageManager());
|
||||
|
||||
extras.putString(EXTRA_ENABLE_WARNING_TITLE, getString(
|
||||
R.string.accessibility_service_security_warning_title, applicationLabel));
|
||||
extras.putString(EXTRA_ENABLE_WARNING_MESSAGE, getString(
|
||||
R.string.accessibility_service_security_warning_summary, applicationLabel));
|
||||
|
||||
extras.putString(EXTRA_DISABLE_WARNING_TITLE, getString(
|
||||
R.string.accessibility_service_disable_warning_title,
|
||||
applicationLabel));
|
||||
extras.putString(EXTRA_DISABLE_WARNING_MESSAGE, getString(
|
||||
R.string.accessibility_service_disable_warning_summary,
|
||||
applicationLabel));
|
||||
|
||||
String settingsClassName = info.getSettingsActivityName();
|
||||
if (!TextUtils.isEmpty(settingsClassName)) {
|
||||
@@ -432,48 +364,59 @@ public class AccessibilitySettings extends SettingsPreferenceFragment implements
|
||||
mServicesCategory.addPreference(preference);
|
||||
}
|
||||
|
||||
// Update enabled state.
|
||||
mServicesCategory.setEnabled(accessibilityEnabled);
|
||||
if (mServicesCategory.getPreferenceCount() == 0) {
|
||||
if (mNoServicesMessagePreference == null) {
|
||||
mNoServicesMessagePreference = new Preference(getActivity()) {
|
||||
@Override
|
||||
protected void onBindView(View view) {
|
||||
super.onBindView(view);
|
||||
|
||||
LinearLayout containerView =
|
||||
(LinearLayout) view.findViewById(R.id.message_container);
|
||||
containerView.setGravity(Gravity.CENTER);
|
||||
|
||||
TextView summaryView = (TextView) view.findViewById(R.id.summary);
|
||||
String title = getString(R.string.accessibility_service_no_apps_title);
|
||||
summaryView.setText(title);
|
||||
}
|
||||
};
|
||||
mNoServicesMessagePreference.setPersistent(false);
|
||||
mNoServicesMessagePreference.setLayoutResource(
|
||||
R.layout.text_description_preference);
|
||||
mNoServicesMessagePreference.setSelectable(false);
|
||||
}
|
||||
mServicesCategory.addPreference(mNoServicesMessagePreference);
|
||||
}
|
||||
}
|
||||
|
||||
private void updateSystemPreferences(boolean accessibilityEnabled) {
|
||||
// The basic logic here is if accessibility is not enabled all accessibility
|
||||
// settings will have no effect but still their selected state should be kept
|
||||
// unchanged, so the user can see what settings will be enabled when turning
|
||||
// on accessibility.
|
||||
private Preference mNoServicesMessagePreference;
|
||||
|
||||
private void updateSystemPreferences() {
|
||||
// Large text.
|
||||
mToggleLargeTextPreference.setEnabled(accessibilityEnabled);
|
||||
if (accessibilityEnabled) {
|
||||
mCurConfig.fontScale =
|
||||
mToggleLargeTextPreference.isChecked() ? LARGE_FONT_SCALE : 1;
|
||||
} else {
|
||||
mCurConfig.fontScale = 1;
|
||||
}
|
||||
try {
|
||||
ActivityManagerNative.getDefault().updatePersistentConfiguration(mCurConfig);
|
||||
mCurConfig.updateFrom(ActivityManagerNative.getDefault().getConfiguration());
|
||||
} catch (RemoteException re) {
|
||||
/* ignore */
|
||||
}
|
||||
mToggleLargeTextPreference.setChecked(mCurConfig.fontScale == LARGE_FONT_SCALE);
|
||||
|
||||
// Power button ends calls.
|
||||
if (mTogglePowerButtonEndsCallPreference != null) {
|
||||
mTogglePowerButtonEndsCallPreference.setEnabled(accessibilityEnabled);
|
||||
final int powerButtonEndsCall;
|
||||
if (accessibilityEnabled) {
|
||||
powerButtonEndsCall = mTogglePowerButtonEndsCallPreference.isChecked()
|
||||
? Settings.Secure.INCALL_POWER_BUTTON_BEHAVIOR_HANGUP
|
||||
: Settings.Secure.INCALL_POWER_BUTTON_BEHAVIOR_SCREEN_OFF;
|
||||
} else {
|
||||
powerButtonEndsCall = Settings.Secure.INCALL_POWER_BUTTON_BEHAVIOR_SCREEN_OFF;
|
||||
}
|
||||
Settings.Secure.putInt(getContentResolver(),
|
||||
if (KeyCharacterMap.deviceHasKey(KeyEvent.KEYCODE_POWER)
|
||||
&& Utils.isVoiceCapable(getActivity())) {
|
||||
final int incallPowerBehavior = Settings.Secure.getInt(getContentResolver(),
|
||||
Settings.Secure.INCALL_POWER_BUTTON_BEHAVIOR,
|
||||
powerButtonEndsCall);
|
||||
Settings.Secure.INCALL_POWER_BUTTON_BEHAVIOR_DEFAULT);
|
||||
final boolean powerButtonEndsCall =
|
||||
(incallPowerBehavior == Settings.Secure.INCALL_POWER_BUTTON_BEHAVIOR_HANGUP);
|
||||
mTogglePowerButtonEndsCallPreference.setChecked(powerButtonEndsCall);
|
||||
}
|
||||
|
||||
// Auto-rotate screen
|
||||
final boolean autoRotationEnabled = Settings.System.getInt(getContentResolver(),
|
||||
Settings.System.ACCELEROMETER_ROTATION, 0) != 0;
|
||||
mToggleAutoRotateScreenPreference.setChecked(autoRotationEnabled);
|
||||
|
||||
// Touch exploration enabled.
|
||||
mToggleTouchExplorationPreference.setEnabled(accessibilityEnabled);
|
||||
final boolean touchExplorationEnabled = (Settings.Secure.getInt(getContentResolver(),
|
||||
Settings.Secure.TOUCH_EXPLORATION_ENABLED, 0) == 1);
|
||||
if (touchExplorationEnabled) {
|
||||
@@ -487,29 +430,16 @@ public class AccessibilitySettings extends SettingsPreferenceFragment implements
|
||||
}
|
||||
|
||||
// Long press timeout.
|
||||
mSelectLongPressTimeoutPreference.setEnabled(accessibilityEnabled);
|
||||
final int longPressTimeout;
|
||||
if (accessibilityEnabled) {
|
||||
String value = mSelectLongPressTimeoutPreference.getValue();
|
||||
longPressTimeout = (value != null) ? Integer.parseInt(value) : mLongPressTimeoutDefault;
|
||||
} else {
|
||||
longPressTimeout = mLongPressTimeoutDefault;
|
||||
}
|
||||
Settings.Secure.putInt(getContentResolver(), Settings.Secure.LONG_PRESS_TIMEOUT,
|
||||
longPressTimeout);
|
||||
String value = mSelectLongPressTimeoutPreference.getValue();
|
||||
final int longPressTimeout = Settings.Secure.getInt(getContentResolver(),
|
||||
Settings.Secure.LONG_PRESS_TIMEOUT, mLongPressTimeoutDefault);
|
||||
String value = String.valueOf(longPressTimeout);
|
||||
mSelectLongPressTimeoutPreference.setValue(value);
|
||||
mSelectLongPressTimeoutPreference.setSummary(mLongPressTimeoutValuetoTitleMap.get(value));
|
||||
|
||||
// Script injection.
|
||||
mToggleScriptInjectionPreference.setEnabled(accessibilityEnabled);
|
||||
final boolean scriptInjectionAllowed;
|
||||
if (accessibilityEnabled) {
|
||||
scriptInjectionAllowed = mToggleScriptInjectionPreference.isInjectionAllowed();
|
||||
} else {
|
||||
scriptInjectionAllowed = false;
|
||||
}
|
||||
Settings.Secure.putInt(getContentResolver(), Settings.Secure.ACCESSIBILITY_SCRIPT_INJECTION,
|
||||
scriptInjectionAllowed ? 1 : 0);
|
||||
final boolean scriptInjectionAllowed = (Settings.Secure.getInt(getContentResolver(),
|
||||
Settings.Secure.ACCESSIBILITY_SCRIPT_INJECTION, 0) == 1);
|
||||
mToggleScriptInjectionPreference.setInjectionAllowed(scriptInjectionAllowed);
|
||||
}
|
||||
|
||||
private void offerInstallAccessibilitySerivceOnce() {
|
||||
@@ -531,31 +461,6 @@ public class AccessibilitySettings extends SettingsPreferenceFragment implements
|
||||
@Override
|
||||
public Dialog onCreateDialog(int dialogId) {
|
||||
switch (dialogId) {
|
||||
case DIALOG_ID_DISABLE_ACCESSIBILITY:
|
||||
return (new AlertDialog.Builder(getActivity()))
|
||||
.setTitle(R.string.accessibility_disable_warning_title)
|
||||
.setIcon(android.R.drawable.ic_dialog_alert)
|
||||
.setMessage(getResources().
|
||||
getString(R.string.accessibility_disable_warning_summary))
|
||||
.setCancelable(true)
|
||||
.setPositiveButton(android.R.string.ok,
|
||||
new DialogInterface.OnClickListener() {
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
Settings.Secure.putInt(getContentResolver(),
|
||||
Settings.Secure.ACCESSIBILITY_ENABLED, 0);
|
||||
mToggleAccessibilitySwitch.setCheckedInternal(
|
||||
false);
|
||||
updateAllPreferences(false);
|
||||
}
|
||||
})
|
||||
.setNegativeButton(android.R.string.cancel,
|
||||
new DialogInterface.OnClickListener() {
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
mToggleAccessibilitySwitch.setCheckedInternal(
|
||||
true);
|
||||
}
|
||||
})
|
||||
.create();
|
||||
case DIALOG_ID_NO_ACCESSIBILITY_SERVICES:
|
||||
return new AlertDialog.Builder(getActivity())
|
||||
.setTitle(R.string.accessibility_service_no_apps_title)
|
||||
@@ -670,6 +575,10 @@ public class AccessibilitySettings extends SettingsPreferenceFragment implements
|
||||
enabledServices += preferenceKey;
|
||||
Settings.Secure.putString(getContentResolver(),
|
||||
Settings.Secure.ENABLED_ACCESSIBILITY_SERVICES, enabledServices);
|
||||
// Enabling the first service enables accessibility.
|
||||
Settings.Secure.putInt(getContentResolver(),
|
||||
Settings.Secure.ACCESSIBILITY_ENABLED, 1);
|
||||
|
||||
} else if (length > 0) {
|
||||
enabledServices += ENABLED_ACCESSIBILITY_SERVICES_SEPARATOR + preferenceKey;
|
||||
Settings.Secure.putString(getContentResolver(),
|
||||
@@ -681,6 +590,9 @@ public class AccessibilitySettings extends SettingsPreferenceFragment implements
|
||||
enabledServices = enabledServices.replace(preferenceKey, "");
|
||||
Settings.Secure.putString(getContentResolver(),
|
||||
Settings.Secure.ENABLED_ACCESSIBILITY_SERVICES, enabledServices);
|
||||
// Disabling the last service disables accessibility).
|
||||
Settings.Secure.putInt(getContentResolver(),
|
||||
Settings.Secure.ACCESSIBILITY_ENABLED, 0);
|
||||
} else if (index > 0) {
|
||||
enabledServices = enabledServices.replace(
|
||||
ENABLED_ACCESSIBILITY_SERVICES_SEPARATOR + preferenceKey, "");
|
||||
@@ -713,18 +625,24 @@ public class AccessibilitySettings extends SettingsPreferenceFragment implements
|
||||
private abstract static class TogglePreferenceFragment extends SettingsPreferenceFragment
|
||||
implements DialogInterface.OnClickListener {
|
||||
|
||||
private static final int DIALOG_ID_WARNING = 1;
|
||||
private static final int DIALOG_ID_ENABLE_WARNING = 1;
|
||||
private static final int DIALOG_ID_DISABLE_WARNING = 2;
|
||||
|
||||
private String mPreferenceKey;
|
||||
|
||||
private ToggleSwitch mToggleSwitch;
|
||||
|
||||
private CharSequence mWarningMessage;
|
||||
private CharSequence mEnableWarningTitle;
|
||||
private CharSequence mEnableWarningMessage;
|
||||
private CharSequence mDisableWarningTitle;
|
||||
private CharSequence mDisableWarningMessage;
|
||||
private Preference mSummaryPreference;
|
||||
|
||||
private CharSequence mSettingsTitle;
|
||||
private Intent mSettingsIntent;
|
||||
|
||||
private int mShownDialogId;
|
||||
|
||||
// TODO: Showing sub-sub fragment does not handle the activity title
|
||||
// so we do it but this is wrong. Do a real fix when there is time.
|
||||
private CharSequence mOldActivityTitle;
|
||||
@@ -789,37 +707,51 @@ public class AccessibilitySettings extends SettingsPreferenceFragment implements
|
||||
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
|
||||
super.onCreateOptionsMenu(menu, inflater);
|
||||
MenuItem menuItem = menu.add(mSettingsTitle);
|
||||
menuItem.setShowAsAction(MenuItem.SHOW_AS_ACTION_NEVER);
|
||||
menuItem.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM);
|
||||
menuItem.setIntent(mSettingsIntent);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Dialog onCreateDialog(int dialogId) {
|
||||
CharSequence title = null;
|
||||
CharSequence message = null;
|
||||
switch (dialogId) {
|
||||
case DIALOG_ID_WARNING:
|
||||
case DIALOG_ID_ENABLE_WARNING:
|
||||
mShownDialogId = DIALOG_ID_ENABLE_WARNING;
|
||||
title = mEnableWarningTitle;
|
||||
message = mEnableWarningMessage;
|
||||
break;
|
||||
case DIALOG_ID_DISABLE_WARNING:
|
||||
mShownDialogId = DIALOG_ID_DISABLE_WARNING;
|
||||
title = mDisableWarningTitle;
|
||||
message = mDisableWarningMessage;
|
||||
break;
|
||||
default:
|
||||
throw new IllegalArgumentException();
|
||||
}
|
||||
return new AlertDialog.Builder(getActivity())
|
||||
.setTitle(android.R.string.dialog_alert_title)
|
||||
.setTitle(title)
|
||||
.setIcon(android.R.drawable.ic_dialog_alert)
|
||||
.setMessage(mWarningMessage)
|
||||
.setMessage(message)
|
||||
.setCancelable(true)
|
||||
.setPositiveButton(android.R.string.ok, this)
|
||||
.setNegativeButton(android.R.string.cancel, this)
|
||||
.create();
|
||||
default:
|
||||
throw new IllegalArgumentException();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
final boolean checked;
|
||||
switch (which) {
|
||||
case DialogInterface.BUTTON_POSITIVE:
|
||||
// OK, we got the user consent so set checked.
|
||||
mToggleSwitch.setCheckedInternal(true);
|
||||
onPreferenceToggled(mPreferenceKey, true);
|
||||
checked = (mShownDialogId == DIALOG_ID_ENABLE_WARNING);
|
||||
mToggleSwitch.setCheckedInternal(checked);
|
||||
onPreferenceToggled(mPreferenceKey, checked);
|
||||
break;
|
||||
case DialogInterface.BUTTON_NEGATIVE:
|
||||
onPreferenceToggled(mPreferenceKey, false);
|
||||
checked = (mShownDialogId == DIALOG_ID_DISABLE_WARNING);
|
||||
mToggleSwitch.setCheckedInternal(checked);
|
||||
onPreferenceToggled(mPreferenceKey, checked);
|
||||
break;
|
||||
default:
|
||||
throw new IllegalArgumentException();
|
||||
@@ -832,13 +764,18 @@ public class AccessibilitySettings extends SettingsPreferenceFragment implements
|
||||
@Override
|
||||
public boolean onBeforeCheckedChanged(ToggleSwitch toggleSwitch, boolean checked) {
|
||||
if (checked) {
|
||||
if (!TextUtils.isEmpty(mWarningMessage)) {
|
||||
if (!TextUtils.isEmpty(mEnableWarningMessage)) {
|
||||
toggleSwitch.setCheckedInternal(false);
|
||||
showDialog(DIALOG_ID_WARNING);
|
||||
showDialog(DIALOG_ID_ENABLE_WARNING);
|
||||
return true;
|
||||
}
|
||||
onPreferenceToggled(mPreferenceKey, true);
|
||||
} else {
|
||||
if (!TextUtils.isEmpty(mDisableWarningMessage)) {
|
||||
toggleSwitch.setCheckedInternal(true);
|
||||
showDialog(DIALOG_ID_DISABLE_WARNING);
|
||||
return true;
|
||||
}
|
||||
onPreferenceToggled(mPreferenceKey, false);
|
||||
}
|
||||
return false;
|
||||
@@ -861,7 +798,7 @@ public class AccessibilitySettings extends SettingsPreferenceFragment implements
|
||||
if (!activity.onIsMultiPane() || activity.onIsHidingHeaders()) {
|
||||
mOldActivityTitle = getActivity().getTitle();
|
||||
String title = arguments.getString(EXTRA_TITLE);
|
||||
getActivity().getActionBar().setTitle(arguments.getCharSequence(EXTRA_TITLE));
|
||||
getActivity().getActionBar().setTitle(title);
|
||||
}
|
||||
|
||||
// Summary.
|
||||
@@ -881,9 +818,21 @@ public class AccessibilitySettings extends SettingsPreferenceFragment implements
|
||||
}
|
||||
}
|
||||
|
||||
// Waring message.
|
||||
mWarningMessage = arguments.getCharSequence(
|
||||
AccessibilitySettings.EXTRA_WARNING_MESSAGE);
|
||||
// Enable warning title.
|
||||
mEnableWarningTitle = arguments.getCharSequence(
|
||||
AccessibilitySettings.EXTRA_ENABLE_WARNING_TITLE);
|
||||
|
||||
// Enable warning message.
|
||||
mEnableWarningMessage = arguments.getCharSequence(
|
||||
AccessibilitySettings.EXTRA_ENABLE_WARNING_MESSAGE);
|
||||
|
||||
// Disable warning title.
|
||||
mDisableWarningTitle = arguments.getString(
|
||||
AccessibilitySettings.EXTRA_DISABLE_WARNING_TITLE);
|
||||
|
||||
// Disable warning message.
|
||||
mDisableWarningMessage = arguments.getString(
|
||||
AccessibilitySettings.EXTRA_DISABLE_WARNING_MESSAGE);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user