summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorDaisuke Miyakawa <dmiyakawa@google.com>2010-11-11 16:36:50 -0800
committerDaisuke Miyakawa <dmiyakawa@google.com>2010-11-11 16:58:04 -0800
commit40124c30a9d554597808992d77ccc867737cf242 (patch)
tree2ce124374addb13eb3ed56b5ec9b1524d3ff8430 /src
parent23b0f055d361d6d727332b0ab8b976e911178f7e (diff)
downloadpackages_apps_settings-40124c30a9d554597808992d77ccc867737cf242.zip
packages_apps_settings-40124c30a9d554597808992d77ccc867737cf242.tar.gz
packages_apps_settings-40124c30a9d554597808992d77ccc867737cf242.tar.bz2
Delay showSoftInput() call.
We need to wait onFocusView() call back for actually showing software keyboard. Bug: 3053354 Change-Id: Idd946e3b8a372ddbabb8b36600c77290f77a06e6
Diffstat (limited to 'src')
-rw-r--r--src/com/android/settings/wifi/WifiConfigUiForSetupWizardXL.java58
-rw-r--r--src/com/android/settings/wifi/WifiSettingsForSetupWizardXL.java3
2 files changed, 43 insertions, 18 deletions
diff --git a/src/com/android/settings/wifi/WifiConfigUiForSetupWizardXL.java b/src/com/android/settings/wifi/WifiConfigUiForSetupWizardXL.java
index 155b691..a29790f 100644
--- a/src/com/android/settings/wifi/WifiConfigUiForSetupWizardXL.java
+++ b/src/com/android/settings/wifi/WifiConfigUiForSetupWizardXL.java
@@ -20,9 +20,11 @@ import com.android.settings.R;
import android.app.Activity;
import android.content.Context;
+import android.os.Handler;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
+import android.view.View.OnFocusChangeListener;
import android.view.ViewGroup;
import android.view.inputmethod.InputMethodManager;
import android.widget.Button;
@@ -32,7 +34,7 @@ import android.widget.EditText;
* Shows simplified UI for configuring a wifi network. Used only in SetupWizard for XLarge
* screen.
*/
-public class WifiConfigUiForSetupWizardXL implements WifiConfigUiBase {
+public class WifiConfigUiForSetupWizardXL implements WifiConfigUiBase, OnFocusChangeListener {
private static final String TAG = "SetupWizard";
private Button mConnectButton;
@@ -44,6 +46,7 @@ public class WifiConfigUiForSetupWizardXL implements WifiConfigUiBase {
private WifiConfigController mController;
private AccessPoint mAccessPoint;
private boolean mEdit;
+ private Handler mHandler = new Handler();
private LayoutInflater mInflater;
@@ -66,25 +69,18 @@ public class WifiConfigUiForSetupWizardXL implements WifiConfigUiBase {
mView = mInflater.inflate(R.layout.wifi_config_ui_for_setup_wizard, parent, false);
mController = new WifiConfigController(this, mView, mAccessPoint, edit);
- trySetFocusAndLaunchSoftInput(R.id.password);
- }
- private void trySetFocusAndLaunchSoftInput(int id) {
- final View viewToBeFocused = mView.findViewById(id);
- if (viewToBeFocused != null && viewToBeFocused.getVisibility() == View.VISIBLE) {
+ // Set Focus to password View.
+ final View viewToBeFocused = mView.findViewById(R.id.password);
+ if (viewToBeFocused != null && viewToBeFocused.getVisibility() == View.VISIBLE &&
+ viewToBeFocused instanceof EditText) {
+ // After acquiring the focus, we show software keyboard.
+ viewToBeFocused.setOnFocusChangeListener(this);
final boolean requestFocusResult = viewToBeFocused.requestFocus();
- Log.i(TAG, String.format("Focus request to %x %s.", id,
+ Log.i(TAG, String.format("Focus request %s.",
(requestFocusResult ? "successful" : "failed")));
- if (requestFocusResult && viewToBeFocused instanceof EditText) {
- Log.i(TAG, String.format(
- "Focused View (%x) is EditText. Try to show software keyboard", id));
- final InputMethodManager inputMethodManager = (InputMethodManager)
- mActivity.getSystemService(Context.INPUT_METHOD_SERVICE);
- final boolean showSoftInputResult =
- inputMethodManager.showSoftInput(viewToBeFocused, 0);
- if (!showSoftInputResult) {
- Log.w(TAG, "Failed to show software keyboard ");
- }
+ if (!requestFocusResult) {
+ viewToBeFocused.setOnFocusChangeListener(null);
}
}
}
@@ -164,4 +160,32 @@ public class WifiConfigUiForSetupWizardXL implements WifiConfigUiBase {
public void setTitle(CharSequence title) {
Log.d(TAG, "Ignoring setTitle");
}
+
+ private static class FocusRunnable implements Runnable {
+ final InputMethodManager mInputMethodManager;
+ final View mViewToBeFocused;
+ public FocusRunnable(Context context, View viewToBeFocused) {
+ mInputMethodManager = (InputMethodManager)
+ context.getSystemService(Context.INPUT_METHOD_SERVICE);
+ mViewToBeFocused = viewToBeFocused;
+ }
+
+ @Override
+ public void run() {
+ mInputMethodManager.focusIn(mViewToBeFocused);
+ final boolean showSoftInputResult =
+ mInputMethodManager.showSoftInput(mViewToBeFocused, 0);
+ if (!showSoftInputResult) {
+ Log.w(TAG, "Failed to show software keyboard ");
+ }
+ }
+ }
+
+ @Override
+ public void onFocusChange(View view, boolean hasFocus) {
+ view.setOnFocusChangeListener(null);
+ if (hasFocus) {
+ mHandler.post(new FocusRunnable(mActivity, view));
+ }
+ }
} \ No newline at end of file
diff --git a/src/com/android/settings/wifi/WifiSettingsForSetupWizardXL.java b/src/com/android/settings/wifi/WifiSettingsForSetupWizardXL.java
index 635f301..f59816e 100644
--- a/src/com/android/settings/wifi/WifiSettingsForSetupWizardXL.java
+++ b/src/com/android/settings/wifi/WifiSettingsForSetupWizardXL.java
@@ -111,7 +111,7 @@ public class WifiSettingsForSetupWizardXL extends Activity implements OnClickLis
setContentView(R.layout.wifi_settings_for_setup_wizard_xl);
getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE);
-
+
mWifiManager = (WifiManager)getSystemService(Context.WIFI_SERVICE);
// There's no button here enabling wifi network, so we need to enable it without
// users' request.
@@ -188,6 +188,7 @@ public class WifiSettingsForSetupWizardXL extends Activity implements OnClickLis
}
private void hideSoftwareKeyboard() {
+ Log.i(TAG, "Hiding software keyboard.");
final View focusedView = getCurrentFocus();
if (focusedView != null) {
mInputMethodManager.hideSoftInputFromWindow(focusedView.getWindowToken(), 0);