Bug 1258450 - Route setAccessibilityEnabled through GeckoInterface. r=snorp,jchen
☠☠ backed out by 353d5e668129 ☠ ☠
authorNick Alexander <nalexander@mozilla.com>
Sun, 20 Mar 2016 20:00:07 -0700
changeset 290844 7a434b18855a9439a98480a2261509ab5596f315
parent 290843 0476a0d0575b4b07c404eb15bc5a943ae04d0289
child 290845 462e9e4314eff25e00e65e75359274ec09807eee
push id19656
push usergwagner@mozilla.com
push dateMon, 04 Apr 2016 13:43:23 +0000
treeherderb2g-inbound@e99061fde28a [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssnorp, jchen
bugs1258450
milestone48.0a1
Bug 1258450 - Route setAccessibilityEnabled through GeckoInterface. r=snorp,jchen MozReview-Commit-ID: 9DXQ8mxtg2Q
mobile/android/base/java/org/mozilla/gecko/BaseGeckoInterface.java
mobile/android/base/java/org/mozilla/gecko/BrowserApp.java
mobile/android/base/java/org/mozilla/gecko/GeckoAccessibility.java
mobile/android/base/java/org/mozilla/gecko/GeckoAppShell.java
--- 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;
     }