Accessibility settings should update after gesture to enable accessibility.
1. We have added a global gesture to enable accessibility which is long press on power follower by a long press with two fingers. If this gesture is performed when accessibility settings are on the screen, accessibility and the screen-reader are enabled while the UI does not reflect that and the user may try to enable the already enabled screen-reader which will show two irrelevant warning dialogs - one for enabling the screen-reader and one for enabling explore by touch (assuming the screen-reader requests it). This change adds a simple content observer for the relevant accessibility settings which upon a change calls the functions to refresh the settings UI. bug:7309127 Change-Id: I45851d7789e24e9e0a5bc5aaac39db9a12b60e0c
This commit is contained in:
@@ -30,6 +30,7 @@ import android.content.SharedPreferences;
|
|||||||
import android.content.pm.ResolveInfo;
|
import android.content.pm.ResolveInfo;
|
||||||
import android.content.pm.ServiceInfo;
|
import android.content.pm.ServiceInfo;
|
||||||
import android.content.res.Configuration;
|
import android.content.res.Configuration;
|
||||||
|
import android.database.ContentObserver;
|
||||||
import android.net.Uri;
|
import android.net.Uri;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.os.Handler;
|
import android.os.Handler;
|
||||||
@@ -150,6 +151,9 @@ public class AccessibilitySettings extends SettingsPreferenceFragment implements
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
private final SettingsContentObserver mSettingsContentObserver =
|
||||||
|
new SettingsContentObserver(mHandler);
|
||||||
|
|
||||||
private final RotationPolicy.RotationPolicyListener mRotationPolicyListener =
|
private final RotationPolicy.RotationPolicyListener mRotationPolicyListener =
|
||||||
new RotationPolicy.RotationPolicyListener() {
|
new RotationPolicy.RotationPolicyListener() {
|
||||||
@Override
|
@Override
|
||||||
@@ -190,6 +194,7 @@ public class AccessibilitySettings extends SettingsPreferenceFragment implements
|
|||||||
offerInstallAccessibilitySerivceOnce();
|
offerInstallAccessibilitySerivceOnce();
|
||||||
|
|
||||||
mSettingsPackageMonitor.register(getActivity(), getActivity().getMainLooper(), false);
|
mSettingsPackageMonitor.register(getActivity(), getActivity().getMainLooper(), false);
|
||||||
|
mSettingsContentObserver.register();
|
||||||
RotationPolicy.registerRotationPolicyListener(getActivity(),
|
RotationPolicy.registerRotationPolicyListener(getActivity(),
|
||||||
mRotationPolicyListener);
|
mRotationPolicyListener);
|
||||||
}
|
}
|
||||||
@@ -199,6 +204,7 @@ public class AccessibilitySettings extends SettingsPreferenceFragment implements
|
|||||||
mSettingsPackageMonitor.unregister();
|
mSettingsPackageMonitor.unregister();
|
||||||
RotationPolicy.unregisterRotationPolicyListener(getActivity(),
|
RotationPolicy.unregisterRotationPolicyListener(getActivity(),
|
||||||
mRotationPolicyListener);
|
mRotationPolicyListener);
|
||||||
|
mSettingsContentObserver.unregister();
|
||||||
super.onPause();
|
super.onPause();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1009,4 +1015,28 @@ public class AccessibilitySettings extends SettingsPreferenceFragment implements
|
|||||||
mSummaryPreference.setSummary(summary);
|
mSummaryPreference.setSummary(summary);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private final class SettingsContentObserver extends ContentObserver {
|
||||||
|
|
||||||
|
public SettingsContentObserver(Handler handler) {
|
||||||
|
super(handler);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void register() {
|
||||||
|
getContentResolver().registerContentObserver(Settings.Secure.getUriFor(
|
||||||
|
Settings.Secure.ACCESSIBILITY_ENABLED), false, this);
|
||||||
|
getContentResolver().registerContentObserver(Settings.Secure.getUriFor(
|
||||||
|
Settings.Secure.ENABLED_ACCESSIBILITY_SERVICES), false, this);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void unregister() {
|
||||||
|
getContentResolver().unregisterContentObserver(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onChange(boolean selfChange, Uri uri) {
|
||||||
|
loadInstalledServices();
|
||||||
|
updateServicesPreferences();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user