Bug 1042257 - Part 2: Listen when the user enables/disables accessibility. r=mfinkle

This commit is contained in:
Frédéric Wang 2014-08-20 17:37:32 -07:00
Родитель 0b8faee779
Коммит 304b1ca8d3
3 изменённых файлов: 20 добавлений и 2 удалений

Просмотреть файл

@ -251,6 +251,19 @@ public class GeckoAccessibility {
}
}
public static void setAccessibilityStateChangeListener(final Context context) {
// The state change listener is only supported on API14+
if (Versions.feature14Plus) {
AccessibilityManager accessibilityManager =
(AccessibilityManager) context.getSystemService(Context.ACCESSIBILITY_SERVICE);
accessibilityManager.addAccessibilityStateChangeListener(new AccessibilityManager.AccessibilityStateChangeListener() {
public void onAccessibilityStateChanged(boolean enabled) {
updateAccessibilitySettings(context);
}
});
}
}
public static void onLayerViewFocusChanged(LayerView layerview, boolean gainFocus) {
if (sEnabled)
GeckoAppShell.sendEventToGecko(GeckoEvent.createBroadcastEvent("Accessibility:Focus",

Просмотреть файл

@ -1911,8 +1911,12 @@ public abstract class GeckoApp
refreshChrome();
}
// User may have enabled/disabled accessibility.
GeckoAccessibility.updateAccessibilitySettings(this);
if (!Versions.feature14Plus) {
// Update accessibility settings in case it has been changed by the
// user. On API14+, this is handled in LayerView by registering an
// accessibility state change listener.
GeckoAccessibility.updateAccessibilitySettings(this);
}
if (mAppStateListeners != null) {
for (GeckoAppShell.AppStateListener listener: mAppStateListeners) {

Просмотреть файл

@ -138,6 +138,7 @@ public class LayerView extends FrameLayout implements Tabs.OnTabsChangedListener
setFocusableInTouchMode(true);
GeckoAccessibility.setDelegate(this);
GeckoAccessibility.setAccessibilityStateChangeListener(getContext());
}
private static Point getEventRadius(MotionEvent event) {