diff options
author | Daisuke Miyakawa <dmiyakawa@google.com> | 2010-11-04 12:45:34 -0700 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2010-11-04 12:45:34 -0700 |
commit | 4a1333d9daa016dbc84005683f4359ba023373a2 (patch) | |
tree | 7027859a02a84bf7637b19477b7b86e9853c2bcd /src/com | |
parent | 96938b29bbce9a70627e24d5e84069ecea200ceb (diff) | |
parent | 8b3b876c096acb93ec8736851e47e2ba3ce276e5 (diff) | |
download | packages_apps_settings-4a1333d9daa016dbc84005683f4359ba023373a2.zip packages_apps_settings-4a1333d9daa016dbc84005683f4359ba023373a2.tar.gz packages_apps_settings-4a1333d9daa016dbc84005683f4359ba023373a2.tar.bz2 |
Merge "Fix UI for WifiSettings for XL screen"
Diffstat (limited to 'src/com')
3 files changed, 71 insertions, 16 deletions
diff --git a/src/com/android/settings/wifi/WifiConfigPreference.java b/src/com/android/settings/wifi/WifiConfigPreference.java index c495481..0e7af51 100644 --- a/src/com/android/settings/wifi/WifiConfigPreference.java +++ b/src/com/android/settings/wifi/WifiConfigPreference.java @@ -21,16 +21,21 @@ import com.android.settings.R; import android.content.Context; import android.content.DialogInterface; import android.preference.Preference; +import android.util.Log; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; +import android.view.inputmethod.InputMethodManager; import android.widget.Button; +import android.widget.EditText; /** * Preference letting users modify a setting for Wifi network. This work as an alternative UI * for {@link WifiDialog} without shouwing popup Dialog. */ public class WifiConfigPreference extends Preference implements WifiConfigUiBase { + private static final String TAG = "WifiConfigPreference"; + private WifiSettings mWifiSettings; private View mView; private final DialogInterface.OnClickListener mListener; @@ -38,6 +43,9 @@ public class WifiConfigPreference extends Preference implements WifiConfigUiBase private AccessPoint mAccessPoint; private boolean mEdit; + // Stores an View id to be focused. Used when view isn't available while setFocus() is called. + private int mFocusId = -1; + private LayoutInflater mInflater; public WifiConfigPreference(WifiSettings wifiSettings, @@ -57,12 +65,16 @@ public class WifiConfigPreference extends Preference implements WifiConfigUiBase @Override protected View onCreateView(ViewGroup parent) { // Called every time the list is created. - if (mView != null) { - // TODO: we need to re-forcus something. - return mView; + if (mView == null) { + mView = mInflater.inflate(getLayoutResource(), parent, false); + mController = new WifiConfigController(this, mView, mAccessPoint, mEdit, mListener); } - mView = mInflater.inflate(getLayoutResource(), parent, false); - mController = new WifiConfigController(this, mView, mAccessPoint, mEdit, mListener); + + if (mFocusId >= 0) { + trySetFocusAndLaunchSoftInput(mFocusId); + mFocusId = -1; + } + return mView; } @@ -71,6 +83,31 @@ public class WifiConfigPreference extends Preference implements WifiConfigUiBase return mController; } + public void setFocus(int id) { + if (mView != null) { + trySetFocusAndLaunchSoftInput(id); + mFocusId = -1; + } else { + mFocusId = id; + } + } + + private void trySetFocusAndLaunchSoftInput(int id) { + final View viewToBeFocused = mView.findViewById(id); + if (viewToBeFocused != null && viewToBeFocused.getVisibility() == View.VISIBLE) { + viewToBeFocused.requestFocus(); + // TODO: doesn't work. + if (viewToBeFocused instanceof EditText) { + Log.d(TAG, "Focused View is EditText. We try showing the software keyboard"); + // viewToBeFocused.performClick(); + final InputMethodManager inputMethodManager = + (InputMethodManager) + getContext().getSystemService(Context.INPUT_METHOD_SERVICE); + inputMethodManager.showSoftInput(viewToBeFocused, 0); + } + } + } + public View findViewById(int id) { return mView.findViewById(id); } diff --git a/src/com/android/settings/wifi/WifiSettings.java b/src/com/android/settings/wifi/WifiSettings.java index efafd59..bc1f09d 100644 --- a/src/com/android/settings/wifi/WifiSettings.java +++ b/src/com/android/settings/wifi/WifiSettings.java @@ -47,7 +47,6 @@ import android.preference.PreferenceScreen; import android.provider.Settings.Secure; import android.security.Credentials; import android.security.KeyStore; -import android.util.Log; import android.view.ContextMenu; import android.view.ContextMenu.ContextMenuInfo; import android.view.Menu; @@ -639,6 +638,10 @@ public class WifiSettings extends SettingsPreferenceFragment forget(); } else if (button == WifiDialog.BUTTON_SUBMIT) { submit(); + final Activity activity = getActivity(); + if (activity instanceof WifiSettingsForSetupWizardXL) { + ((WifiSettingsForSetupWizardXL)activity).onConnectButtonPressed(); + } } } @@ -740,6 +743,11 @@ public class WifiSettings extends SettingsPreferenceFragment /* package */ void onAddNetworkPressed() { mSelectedAccessPoint = null; showConfigUi(null, true); + + // Set focus to the EditText the user needs to configure. + if (mConfigPreference != null) { + mConfigPreference.setFocus(R.id.ssid); + } } /* package */ int getAccessPointsCount() { diff --git a/src/com/android/settings/wifi/WifiSettingsForSetupWizardXL.java b/src/com/android/settings/wifi/WifiSettingsForSetupWizardXL.java index fde5d90..1d11986 100644 --- a/src/com/android/settings/wifi/WifiSettingsForSetupWizardXL.java +++ b/src/com/android/settings/wifi/WifiSettingsForSetupWizardXL.java @@ -23,6 +23,7 @@ import android.content.Context; import android.net.NetworkInfo.DetailedState; import android.os.Bundle; import android.text.TextUtils; +import android.util.Log; import android.view.View; import android.view.View.OnClickListener; import android.view.Window; @@ -129,14 +130,7 @@ public class WifiSettingsForSetupWizardXL extends Activity implements OnClickLis break; case R.id.wifi_setup_connect: mWifiSettings.submit(); - - // updateConnectionState() isn't called soon after the user's "connect" action, - // and the user still sees "not connected" message for a while, which looks strange. - // We instead manually show "connecting" message before the system gets actual - // "connecting" message from Wi-Fi module. - showConnectingStatus(); - mShowingConnectingMessageManually = true; - mIgnoringWifiNotificationCount = 2; + onConnectButtonPressed(); break; case R.id.wifi_setup_forget: mWifiSettings.forget(); @@ -186,7 +180,10 @@ public class WifiSettingsForSetupWizardXL extends Activity implements OnClickLis mProgressBar.setProgress(2); mProgressText.setText(Summary.get(this, state)); mStatusText.setText(R.string.wifi_setup_status_proceed_to_next); - enableButtons(); + // We don't want "Add network" button here. User can press it after pressing + // "Refresh" button. + ((Button)findViewById(R.id.wifi_setup_refresh_list)).setEnabled(true); + ((Button)findViewById(R.id.wifi_setup_skip_or_next)).setEnabled(true); if (mIgnoringWifiNotificationCount > 0) { // The network is already available before doing anything. We avoid skip this @@ -219,7 +216,6 @@ public class WifiSettingsForSetupWizardXL extends Activity implements OnClickLis mShowingConnectingMessageManually = false; mProgressBar.setIndeterminate(false); mProgressBar.setProgress(0); - mStatusText.setText(R.string.wifi_setup_status_select_network); mProgressText.setText(getString(R.string.wifi_setup_not_connected)); enableButtons(); } @@ -254,7 +250,21 @@ public class WifiSettingsForSetupWizardXL extends Activity implements OnClickLis public void onRefreshAccessPoints() { mIgnoringWifiNotificationCount = 5; mProgressBar.setIndeterminate(true); + ((Button)findViewById(R.id.wifi_setup_add_network)).setEnabled(false); + ((Button)findViewById(R.id.wifi_setup_refresh_list)).setEnabled(false); mProgressText.setText(Summary.get(this, DetailedState.SCANNING)); mStatusText.setText(R.string.wifi_setup_status_scanning); } + + /* package */ void onConnectButtonPressed() { + // updateConnectionState() isn't called soon after the user's "connect" action, + // and the user still sees "not connected" message for a while, which looks strange. + // We instead manually show "connecting" message before the system gets actual + // "connecting" message from Wi-Fi module. + showConnectingStatus(); + ((Button)findViewById(R.id.wifi_setup_add_network)).setEnabled(false); + ((Button)findViewById(R.id.wifi_setup_refresh_list)).setEnabled(false); + mShowingConnectingMessageManually = true; + mIgnoringWifiNotificationCount = 2; + } } |