Merge "Add icons for color inversion and daltonizer"
This commit is contained in:
committed by
Android (Google) Code Review
commit
ae1011ee5d
@@ -42,6 +42,7 @@ import android.view.KeyCharacterMap;
|
||||
import android.view.KeyEvent;
|
||||
import android.view.accessibility.AccessibilityManager;
|
||||
|
||||
import com.android.internal.accessibility.AccessibilityShortcutController;
|
||||
import com.android.internal.content.PackageMonitor;
|
||||
import com.android.internal.logging.nano.MetricsProto.MetricsEvent;
|
||||
import com.android.internal.view.RotationPolicy;
|
||||
@@ -57,6 +58,7 @@ import com.android.settingslib.RestrictedPreference;
|
||||
import com.android.settingslib.accessibility.AccessibilityUtils;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
@@ -172,13 +174,7 @@ public class AccessibilitySettings extends SettingsPreferenceFragment implements
|
||||
}
|
||||
};
|
||||
|
||||
private final SettingsContentObserver mSettingsContentObserver =
|
||||
new SettingsContentObserver(mHandler) {
|
||||
@Override
|
||||
public void onChange(boolean selfChange, Uri uri) {
|
||||
updateServicePreferences();
|
||||
}
|
||||
};
|
||||
private final SettingsContentObserver mSettingsContentObserver;
|
||||
|
||||
private final RotationPolicyListener mRotationPolicyListener = new RotationPolicyListener() {
|
||||
@Override
|
||||
@@ -224,6 +220,22 @@ public class AccessibilitySettings extends SettingsPreferenceFragment implements
|
||||
.getBoolean(com.android.internal.R.bool.config_setColorTransformAccelerated);
|
||||
}
|
||||
|
||||
public AccessibilitySettings() {
|
||||
// Observe changes to anything that the shortcut can toggle, so we can reflect updates
|
||||
final Collection<AccessibilityShortcutController.ToggleableFrameworkFeatureInfo> features =
|
||||
AccessibilityShortcutController.getFrameworkShortcutFeaturesMap().values();
|
||||
final List<String> shortcutFeatureKeys = new ArrayList<>(features.size());
|
||||
for (AccessibilityShortcutController.ToggleableFrameworkFeatureInfo feature : features) {
|
||||
shortcutFeatureKeys.add(feature.getSettingKey());
|
||||
}
|
||||
mSettingsContentObserver = new SettingsContentObserver(mHandler, shortcutFeatureKeys) {
|
||||
@Override
|
||||
public void onChange(boolean selfChange, Uri uri) {
|
||||
updateAllPreferences();
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMetricsCategory() {
|
||||
return MetricsEvent.ACCESSIBILITY;
|
||||
|
@@ -22,16 +22,28 @@ import android.net.Uri;
|
||||
import android.os.Handler;
|
||||
import android.provider.Settings;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
abstract class SettingsContentObserver extends ContentObserver {
|
||||
private final List<String> mKeysToObserve = new ArrayList<>(2);
|
||||
|
||||
public SettingsContentObserver(Handler handler) {
|
||||
super(handler);
|
||||
mKeysToObserve.add(Settings.Secure.ACCESSIBILITY_ENABLED);
|
||||
mKeysToObserve.add(Settings.Secure.ENABLED_ACCESSIBILITY_SERVICES);
|
||||
}
|
||||
|
||||
public SettingsContentObserver(Handler handler, List<String> keysToObserve) {
|
||||
this(handler);
|
||||
mKeysToObserve.addAll(keysToObserve);
|
||||
}
|
||||
|
||||
public void register(ContentResolver contentResolver) {
|
||||
contentResolver.registerContentObserver(Settings.Secure.getUriFor(
|
||||
Settings.Secure.ACCESSIBILITY_ENABLED), false, this);
|
||||
contentResolver.registerContentObserver(Settings.Secure.getUriFor(
|
||||
Settings.Secure.ENABLED_ACCESSIBILITY_SERVICES), false, this);
|
||||
for (int i = 0; i < mKeysToObserve.size(); i++) {
|
||||
contentResolver.registerContentObserver(
|
||||
Settings.Secure.getUriFor(mKeysToObserve.get(i)), false, this);
|
||||
}
|
||||
}
|
||||
|
||||
public void unregister(ContentResolver contentResolver) {
|
||||
|
@@ -16,6 +16,8 @@
|
||||
package com.android.settings.accessibility;
|
||||
|
||||
import static android.content.DialogInterface.BUTTON_POSITIVE;
|
||||
import static com.android.internal.accessibility.AccessibilityShortcutController.COLOR_INVERSION_COMPONENT_NAME;
|
||||
import static com.android.internal.accessibility.AccessibilityShortcutController.DALTONIZER_COMPONENT_NAME;
|
||||
|
||||
import android.accessibilityservice.AccessibilityServiceInfo;
|
||||
import android.app.Activity;
|
||||
@@ -85,9 +87,16 @@ public class ShortcutServicePickerFragment extends RadioButtonPickerFragment {
|
||||
Map<ComponentName, ToggleableFrameworkFeatureInfo> frameworkFeatureInfoMap =
|
||||
AccessibilityShortcutController.getFrameworkShortcutFeaturesMap();
|
||||
for (ComponentName componentName : frameworkFeatureInfoMap.keySet()) {
|
||||
// Lookup icon
|
||||
final int iconId;
|
||||
if (componentName.equals(COLOR_INVERSION_COMPONENT_NAME)) {
|
||||
iconId = R.drawable.ic_color_inversion;
|
||||
} else if (componentName.equals(DALTONIZER_COMPONENT_NAME)) {
|
||||
iconId = R.drawable.ic_daltonizer;
|
||||
} else {
|
||||
iconId = R.drawable.empty_icon;
|
||||
}
|
||||
candidates.add(new FrameworkCandidateInfo(frameworkFeatureInfoMap.get(componentName),
|
||||
R.drawable.empty_icon, componentName.flattenToString()));
|
||||
iconId, componentName.flattenToString()));
|
||||
}
|
||||
for (int i = 0; i < numInstalledServices; i++) {
|
||||
final AccessibilityServiceInfo installedServiceInfo = installedServices.get(i);
|
||||
|
Reference in New Issue
Block a user