Change-Id: Ie5d78c1ddb61241db8259a200a3df1950d767cce
if (!accessibilityServices.isEmpty()) {
if (serviceState == 1) {
mToggleCheckBox.setChecked(true);
if (!accessibilityServices.isEmpty()) {
if (serviceState == 1) {
mToggleCheckBox.setChecked(true);
+ } else {
+ setAccessibilityServicePreferencesState(false);
}
mToggleCheckBox.setEnabled(true);
} else {
}
mToggleCheckBox.setEnabled(true);
} else {
persistEnabledAccessibilityServices();
}
persistEnabledAccessibilityServices();
}
+ /**
+ * Sets the state of the preferences for enabling/disabling
+ * AccessibilityServices.
+ *
+ * @param isEnabled If to enable or disable the preferences.
+ */
+ private void setAccessibilityServicePreferencesState(boolean isEnabled) {
+ if (mAccessibilityServicesCategory == null) {
+ return;
+ }
+
+ int count = mAccessibilityServicesCategory.getPreferenceCount();
+ for (int i = 0; i < count; i++) {
+ Preference pref = mAccessibilityServicesCategory.getPreference(i);
+ pref.setEnabled(isEnabled);
+ }
+ }
+
@Override
public boolean onPreferenceTreeClick(PreferenceScreen preferenceScreen, Preference preference) {
final String key = preference.getKey();
@Override
public boolean onPreferenceTreeClick(PreferenceScreen preferenceScreen, Preference preference) {
final String key = preference.getKey();
if (preference.isChecked()) {
Settings.Secure.putInt(getContentResolver(),
Settings.Secure.ACCESSIBILITY_ENABLED, 1);
if (preference.isChecked()) {
Settings.Secure.putInt(getContentResolver(),
Settings.Secure.ACCESSIBILITY_ENABLED, 1);
+ setAccessibilityServicePreferencesState(true);
} else {
final CheckBoxPreference checkBoxPreference = preference;
AlertDialog dialog = (new AlertDialog.Builder(this))
} else {
final CheckBoxPreference checkBoxPreference = preference;
AlertDialog dialog = (new AlertDialog.Builder(this))
public void onClick(DialogInterface dialog, int which) {
Settings.Secure.putInt(getContentResolver(),
Settings.Secure.ACCESSIBILITY_ENABLED, 0);
public void onClick(DialogInterface dialog, int which) {
Settings.Secure.putInt(getContentResolver(),
Settings.Secure.ACCESSIBILITY_ENABLED, 0);
+ setAccessibilityServicePreferencesState(false);
}
})
.setNegativeButton(android.R.string.cancel,
}
})
.setNegativeButton(android.R.string.cancel,