From 665b7af683b03ff9b5714b78f554f1b0fd9b73d0 Mon Sep 17 00:00:00 2001 From: Brian Nicholson Date: Tue, 1 May 2012 18:15:42 -0700 Subject: [PATCH] Bug 750734 - Ensure view is focused when showing virtual keyboard. r=cpeterson a=android-only --- mobile/android/base/GeckoInputConnection.java | 20 ++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/mobile/android/base/GeckoInputConnection.java b/mobile/android/base/GeckoInputConnection.java index 484ec901157..3e04a925e45 100644 --- a/mobile/android/base/GeckoInputConnection.java +++ b/mobile/android/base/GeckoInputConnection.java @@ -1029,10 +1029,10 @@ public class GeckoInputConnection instance = null; } - View v = GeckoApp.mAppContext.getLayerController().getView(); + final View v = GeckoApp.mAppContext.getLayerController().getView(); if (DEBUG) Log.d(LOGTAG, "IME: v=" + v); - InputMethodManager imm = getInputMethodManager(); + final InputMethodManager imm = getInputMethodManager(); if (imm == null) return; @@ -1042,10 +1042,20 @@ public class GeckoInputConnection if (!mEnable) return; - if (mIMEState != IME_STATE_DISABLED) - imm.showSoftInput(v, 0); - else + if (mIMEState != IME_STATE_DISABLED) { + if (!v.isFocused()) { + GeckoApp.mAppContext.mMainHandler.post(new Runnable() { + public void run() { + v.requestFocus(); + imm.showSoftInput(v, 0); + } + }); + } else { + imm.showSoftInput(v, 0); + } + } else { imm.hideSoftInputFromWindow(v.getWindowToken(), 0); + } } }