Bug 1215950 - GeckoInputConnection: Run re-focus workaround on the UI thread. r=jchen
authorSebastian Kaspari <s.kaspari@gmail.com>
Fri, 23 Oct 2015 10:05:40 +0200
changeset 304319 6c5f530312e3dbe55851cacee41fb0f664e0ec20
parent 304318 688d6e1caacaf05a5d52dc2a5b01ed32f30f72b3
child 304320 712073c4f0b41cfa50f3d99332b44882cbeb0644
push id1001
push userraliiev@mozilla.com
push dateMon, 18 Jan 2016 19:06:03 +0000
treeherdermozilla-release@8b89261f3ac4 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjchen
bugs1215950
milestone44.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1215950 - GeckoInputConnection: Run re-focus workaround on the UI thread. r=jchen
mobile/android/base/GeckoInputConnection.java
--- a/mobile/android/base/GeckoInputConnection.java
+++ b/mobile/android/base/GeckoInputConnection.java
@@ -366,22 +366,33 @@ class GeckoInputConnection
 
     private static void showSoftInput() {
         final InputMethodManager imm = getInputMethodManager();
         if (imm != null) {
             final View v = getView();
 
             if (v.hasFocus() && !imm.isActive(v)) {
                 // Workaround: The view has focus but it is not the active view for the input method. (Bug 1211848)
+                refocusAndShowSoftInput(imm, v);
+            } else {
+                imm.showSoftInput(v, 0);
+            }
+        }
+    }
+
+    private static void refocusAndShowSoftInput(final InputMethodManager imm, final View v) {
+        ThreadUtils.postToUiThread(new Runnable() {
+            @Override
+            public void run() {
                 v.clearFocus();
                 v.requestFocus();
+
+                imm.showSoftInput(v, 0);
             }
-
-            imm.showSoftInput(v, 0);
-        }
+        });
     }
 
     private static void hideSoftInput() {
         final InputMethodManager imm = getInputMethodManager();
         if (imm != null) {
             final View v = getView();
             imm.hideSoftInputFromWindow(v.getWindowToken(), 0);
         }