Bug 764057 - Update a11y settings according to Android settings when resuming. r=blassey

This commit is contained in:
Eitan Isaacson 2012-06-13 12:22:52 -07:00
parent 398e168f1b
commit 9e7fd64275

View File

@ -1170,22 +1170,7 @@ abstract public class GeckoApp
}
});
} else if (event.equals("Accessibility:Ready")) {
mMainHandler.post(new Runnable() {
public void run() {
JSONObject ret = new JSONObject();
AccessibilityManager accessibilityManager =
(AccessibilityManager) mAppContext.getSystemService(Context.ACCESSIBILITY_SERVICE);
try {
ret.put("enabled", accessibilityManager.isEnabled());
// XXX: A placeholder for future explore by touch support.
ret.put("exploreByTouch", false);
} catch (Exception ex) {
Log.e(LOGTAG, "Error building JSON arguments for Accessibility:Ready:", ex);
}
GeckoAppShell.sendEventToGecko(GeckoEvent.createBroadcastEvent("Accessibility:Settings",
ret.toString()));
}
});
updateAccessibilitySettings();
} else if (event.equals("Shortcut:Remove")) {
final String url = message.getString("url");
final String title = message.getString("title");
@ -1497,6 +1482,28 @@ abstract public class GeckoApp
});
}
public void updateAccessibilitySettings () {
mMainHandler.post(new Runnable() {
public void run() {
JSONObject ret = new JSONObject();
AccessibilityManager accessibilityManager =
(AccessibilityManager) mAppContext.getSystemService(Context.ACCESSIBILITY_SERVICE);
try {
ret.put("enabled", accessibilityManager.isEnabled());
if (Build.VERSION.SDK_INT >= 14) { // Build.VERSION_CODES.ICE_CREAM_SANDWICH
ret.put("exploreByTouch", accessibilityManager.isTouchExplorationEnabled());
} else {
ret.put("exploreByTouch", false);
}
} catch (Exception ex) {
Log.e(LOGTAG, "Error building JSON arguments for Accessibility:Settings:", ex);
}
GeckoAppShell.sendEventToGecko(GeckoEvent.createBroadcastEvent("Accessibility:Settings",
ret.toString()));
}
});
}
public Surface createSurface() {
Tabs tabs = Tabs.getInstance();
Tab tab = tabs.getSelectedTab();
@ -2086,6 +2093,9 @@ abstract public class GeckoApp
mOrientation = newOrientation;
refreshChrome();
}
// User may have enabled/disabled accessibility.
updateAccessibilitySettings();
}
@Override