Bug 1258450 - Route setAccessibilityEnabled through GeckoInterface. r=snorp,jchen
MozReview-Commit-ID: 9DXQ8mxtg2Q
--- a/mobile/android/base/java/org/mozilla/gecko/BaseGeckoInterface.java
+++ b/mobile/android/base/java/org/mozilla/gecko/BaseGeckoInterface.java
@@ -151,9 +151,14 @@ public class BaseGeckoInterface implemen
public void markUriVisited(final String uri) {
// By default, no URIs are marked as visited.
}
@Override
public void setUriTitle(final String uri, final String title) {
// By default, no titles are associated with URIs.
}
+
+ @Override
+ public void setAccessibilityEnabled(boolean enabled) {
+ // By default, take no action when accessibility is toggled on or off.
+ }
}
--- a/mobile/android/base/java/org/mozilla/gecko/BrowserApp.java
+++ b/mobile/android/base/java/org/mozilla/gecko/BrowserApp.java
@@ -1369,16 +1369,17 @@ public class BrowserApp extends GeckoApp
return true;
}
return false;
}
@Override
public void setAccessibilityEnabled(boolean enabled) {
+ super.setAccessibilityEnabled(enabled);
mDynamicToolbar.setAccessibilityEnabled(enabled);
}
@Override
public void onDestroy() {
if (!HardwareUtils.isSupportedSystem()) {
// This build does not support the Android version of the device; Exit early.
super.onDestroy();
--- a/mobile/android/base/java/org/mozilla/gecko/GeckoAccessibility.java
+++ b/mobile/android/base/java/org/mozilla/gecko/GeckoAccessibility.java
@@ -86,25 +86,21 @@ public class GeckoAccessibility {
}
GeckoAppShell.notifyObservers("Accessibility:Settings", ret.toString());
return null;
}
@Override
public void onPostExecute(Void args) {
- boolean isGeckoApp = false;
- try {
- isGeckoApp = context instanceof GeckoApp;
- } catch (NoClassDefFoundError ex) {}
- if (isGeckoApp) {
- // Disable the dynamic toolbar when enabling accessibility.
- // These features tend not to interact well.
- ((GeckoApp) context).setAccessibilityEnabled(sEnabled);
+ final GeckoAppShell.GeckoInterface geckoInterface = GeckoAppShell.getGeckoInterface();
+ if (geckoInterface == null) {
+ return;
}
+ geckoInterface.setAccessibilityEnabled(sEnabled);
}
}.execute();
}
private static void populateEventFromJSON (AccessibilityEvent event, JSONObject message) {
final JSONArray textArray = message.optJSONArray("text");
if (textArray != null) {
for (int i = 0; i < textArray.length(); i++)
--- a/mobile/android/base/java/org/mozilla/gecko/GeckoAppShell.java
+++ b/mobile/android/base/java/org/mozilla/gecko/GeckoAppShell.java
@@ -2123,16 +2123,18 @@ public class GeckoAppShell
* Set the title of the given URI, as determined by Gecko.
* <p/>
* This method is always invoked on the Gecko thread.
*
* @param uri given.
* @param title to associate with the given URI.
*/
public void setUriTitle(final String uri, final String title);
+
+ public void setAccessibilityEnabled(boolean enabled);
};
private static GeckoInterface sGeckoInterface;
public static GeckoInterface getGeckoInterface() {
return sGeckoInterface;
}