Bug 1404111 - WIP - Refocus GeckoView when it gains focus to make sure the InputMethodManager is up-to-date draft
authorJan Henning <jh+bugzilla@buttercookie.de>
Sun, 08 Oct 2017 22:40:02 +0200
changeset 676880 369e6ca398f62771fffcc950523d5ecb577907e2
parent 676879 47b1e21f65d867cf3340515e5f94cc9f27fa011c
child 676881 d552dc178bea8d8ee1f93d20d1001a8190c7487c
push id83657
push usermozilla@buttercookie.de
push dateMon, 09 Oct 2017 20:10:45 +0000
bugs1404111
milestone58.0a1
Bug 1404111 - WIP - Refocus GeckoView when it gains focus to make sure the InputMethodManager is up-to-date MozReview-Commit-ID: BtAXXOBpYwr
mobile/android/base/java/org/mozilla/gecko/BrowserApp.java
--- a/mobile/android/base/java/org/mozilla/gecko/BrowserApp.java
+++ b/mobile/android/base/java/org/mozilla/gecko/BrowserApp.java
@@ -245,16 +245,18 @@ public class BrowserApp extends GeckoApp
     private View doorhangerOverlay;
     // We can't name the TabStrip class because it's not included on API 9.
     private TabStripInterface mTabStrip;
     private AnimatedProgressBar mProgressView;
     private FirstrunAnimationContainer mFirstrunAnimationContainer;
     private HomeScreen mHomeScreen;
     private TabsPanel mTabsPanel;
 
+    private boolean mRefocussingGeckoView;
+
     private boolean showSplashScreen = false;
     private SplashScreen splashScreen;
     /**
      * Container for the home screen implementation. This will be populated with any valid
      * home screen implementation (currently that is just the HomePager, but that will be extended
      * to permit further experimental replacement panels such as the activity-stream panel).
      */
     private ViewGroup mHomeScreenContainer;
@@ -645,16 +647,35 @@ public class BrowserApp extends GeckoApp
         final GeckoApplication app = (GeckoApplication) getApplication();
         app.prepareLightweightTheme();
 
         super.onCreate(savedInstanceState);
 
         initSwitchboard(this, intent, isInAutomation);
         initTelemetryUploader(isInAutomation);
 
+        mLayerView.setOnFocusChangeListener(new View.OnFocusChangeListener() {
+            @Override
+            public void onFocusChange(View v, boolean hasFocus) {
+                if (mRefocussingGeckoView) {
+                    if (hasFocus) {
+                        mRefocussingGeckoView = false;
+                    }
+                } else if (hasFocus) {
+                    mRefocussingGeckoView = true;
+                    ThreadUtils.postToUiThread(new Runnable() {
+                        @Override
+                        public void run() {
+                            mLayerView.clearFocus();
+                        }
+                    });
+                }
+            }
+        });
+
         mBrowserChrome = (ViewGroup) findViewById(R.id.browser_chrome);
         mActionBarFlipper = (ViewFlipper) findViewById(R.id.browser_actionbar);
         mActionBar = (ActionModeCompatView) findViewById(R.id.actionbar);
 
         mVideoPlayer = (VideoPlayer) findViewById(R.id.video_player);
         mVideoPlayer.setFullScreenListener(new VideoPlayer.FullScreenListener() {
             @Override
             public void onFullScreenChanged(boolean fullScreen) {