diff options
-rw-r--r-- | res/layout-xlarge/date_time_settings_setupwizard.xml | 2 | ||||
-rw-r--r-- | res/values-xlarge/bools.xml | 21 | ||||
-rw-r--r-- | res/values/bools.xml | 2 | ||||
-rw-r--r-- | res/values/strings.xml | 22 | ||||
-rw-r--r-- | res/xml/dock_settings.xml | 3 | ||||
-rw-r--r-- | res/xml/language_settings.xml | 3 | ||||
-rw-r--r-- | src/com/android/settings/Settings.java | 12 | ||||
-rw-r--r-- | src/com/android/settings/SettingsPreferenceFragment.java | 101 | ||||
-rw-r--r-- | src/com/android/settings/SoundSettings.java | 5 | ||||
-rw-r--r-- | src/com/android/settings/wifi/WifiConfigUiForSetupWizardXL.java | 37 | ||||
-rw-r--r-- | src/com/android/settings/wifi/WifiSettings.java | 25 | ||||
-rw-r--r-- | src/com/android/settings/wifi/WifiSettingsForSetupWizardXL.java | 109 |
12 files changed, 195 insertions, 147 deletions
diff --git a/res/layout-xlarge/date_time_settings_setupwizard.xml b/res/layout-xlarge/date_time_settings_setupwizard.xml index 73aba01..328a014 100644 --- a/res/layout-xlarge/date_time_settings_setupwizard.xml +++ b/res/layout-xlarge/date_time_settings_setupwizard.xml @@ -43,6 +43,8 @@ android:layout_width="match_parent" android:layout_height="3dip" android:layout_below="@id/title" + android:layout_marginTop="6dip" + android:layout_marginBottom="7dip" android:background="@color/divider_color" /> <!-- timezone --> diff --git a/res/values-xlarge/bools.xml b/res/values-xlarge/bools.xml new file mode 100644 index 0000000..bde07d7 --- /dev/null +++ b/res/values-xlarge/bools.xml @@ -0,0 +1,21 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- Copyright (C) 2011 The Android Open Source Project + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +--> + +<resources> + <!-- Whether there is a silent mode checkbox --> + <bool name="has_silent_mode">false</bool> +</resources> + diff --git a/res/values/bools.xml b/res/values/bools.xml index 61cc79e..f4a95f3 100644 --- a/res/values/bools.xml +++ b/res/values/bools.xml @@ -20,4 +20,6 @@ <bool name="has_intrusive_led">false</bool> <!-- Whether or not the dock settings are to be displayed for this device when docked --> <bool name="has_dock_settings">false</bool> + <!-- Whether there is a silent mode checkbox --> + <bool name="has_silent_mode">true</bool> </resources> diff --git a/res/values/strings.xml b/res/values/strings.xml index 86f4e85..1a6dcd6 100644 --- a/res/values/strings.xml +++ b/res/values/strings.xml @@ -2261,27 +2261,27 @@ found in the list of installed applications.</string> <string name="input_methods_settings_title">Text input</string> <!-- Setting name for Input Method chooser --> <string name="input_method">Input method</string> - <!-- Title for selecting the current input method --> + <!-- Title for selecting the current input method [CHAR LIMIT=35] --> <string name="current_input_method">Current input method</string> - <!-- Title for setting the visibility of input method selector--> + <!-- Title for setting the visibility of input method selector [CHAR LIMIT=35] --> <string name="input_method_selector">Input method selector</string> - <!-- An option to always show input method selector automatically when needed --> + <!-- An option to always show input method selector automatically when needed [CHAR LIMIT=25] --> <string name="input_method_selector_show_automatically_title">Automatic</string> - <!-- An option to always show input method selector --> + <!-- An option to always show input method selector [CHAR LIMIT=25] --> <string name="input_method_selector_always_show_title">Always show</string> - <!-- An option to always hide input method selector --> + <!-- An option to always hide input method selector [CHAR LIMIT=25] --> <string name="input_method_selector_always_hide_title">Always hide</string> - <!-- Title for configuring input method settings --> + <!-- Title for configuring input method settings [CHAR LIMIT=35] --> <string name="configure_input_method">Configure input methods</string> - <!-- Title for settings of each IME --> + <!-- Title for settings of each IME [CHAR LIMIT=25] --> <string name="input_method_settings">Settings</string> - <!-- Title for settings of active input methods in each IME --> + <!-- Title for settings of active input methods in each IME [CHAR LIMIT=35] --> <string name="active_input_method_subtypes">Active input methods</string> - <!-- Title for settings whether or not the framework will select input methods in an IME based on the current system locale. --> + <!-- Title for settings whether or not the framework will select input methods in an IME based on the current system locale. [CHAR LIMIT=35] --> <string name="use_system_language_to_select_input_method_subtypes">Use system language</string> - <!-- Input Methods Settings localized format string for generating the appropriate "Foo settings" menu label for the Input Method named "Foo" --> + <!-- Input Methods Settings localized format string for generating the appropriate "Foo settings" menu label for the Input Method named "Foo" [CHAR LIMIT=35] --> <string name="input_methods_settings_label_format"><xliff:g id="ime_name">%1$s</xliff:g> settings</string> - <!-- Title for the settings of selecting active input methods of an IME --> + <!-- Title for the settings of selecting active input methods of an IME [CHAR LIMIT=35] --> <string name="input_methods_and_subtype_enabler_title">Select active input methods</string> <!-- Summary for on-screen keyboard settings --> <string name="onscreen_keyboard_settings_summary">Onscreen keyboard settings</string> diff --git a/res/xml/dock_settings.xml b/res/xml/dock_settings.xml index d3d6e43..177da9f 100644 --- a/res/xml/dock_settings.xml +++ b/res/xml/dock_settings.xml @@ -23,8 +23,7 @@ <PreferenceScreen android:key="dock_audio" android:title="@string/dock_audio_settings_title" - android:summary="@string/dock_settings_summary" - android:widgetLayout="@*android:layout/preference_dialog" /> + android:summary="@string/dock_settings_summary" /> <CheckBoxPreference android:key="dock_sounds" diff --git a/res/xml/language_settings.xml b/res/xml/language_settings.xml index 9230496..b7934e6 100644 --- a/res/xml/language_settings.xml +++ b/res/xml/language_settings.xml @@ -58,8 +58,7 @@ <PreferenceCategory android:key="keyboard_settings_category" android:title="@string/keyboard_settings_category"> <PreferenceScreen android:key="current_input_method" - android:title="@string/current_input_method" - android:widgetLayout="@*android:layout/preference_dialog" /> + android:title="@string/current_input_method" /> <ListPreference android:key="input_method_selector" android:title="@string/input_method_selector" diff --git a/src/com/android/settings/Settings.java b/src/com/android/settings/Settings.java index 280f295..22fc4bf 100644 --- a/src/com/android/settings/Settings.java +++ b/src/com/android/settings/Settings.java @@ -23,10 +23,10 @@ import android.content.pm.PackageManager; import android.content.pm.PackageManager.NameNotFoundException; import android.os.Bundle; import android.preference.PreferenceActivity; -import android.preference.PreferenceActivity.Header; import android.util.Log; import android.view.View; import android.view.View.OnClickListener; +import android.widget.Button; import java.util.HashMap; import java.util.List; @@ -290,6 +290,16 @@ public class Settings extends PreferenceActivity { } } + @Override + public boolean hasNextButton() { + return super.hasNextButton(); + } + + @Override + public Button getNextButton() { + return super.getNextButton(); + } + /* * Settings subclasses for launching independently. */ diff --git a/src/com/android/settings/SettingsPreferenceFragment.java b/src/com/android/settings/SettingsPreferenceFragment.java index 6f0c91f..0db4f8b 100644 --- a/src/com/android/settings/SettingsPreferenceFragment.java +++ b/src/com/android/settings/SettingsPreferenceFragment.java @@ -40,20 +40,11 @@ public class SettingsPreferenceFragment extends PreferenceFragment private static final String TAG = "SettingsPreferenceFragment"; - // Originally from PreferenceActivity. - private static final String EXTRA_PREFS_SHOW_BUTTON_BAR = "extra_prefs_show_button_bar"; - private static final String EXTRA_PREFS_SHOW_SKIP = "extra_prefs_show_skip"; - private static final String EXTRA_PREFS_SET_NEXT_TEXT = "extra_prefs_set_next_text"; - private static final String EXTRA_PREFS_SET_BACK_TEXT = "extra_prefs_set_back_text"; - private SettingsDialogFragment mDialogFragment; - private Button mNextButton; - @Override public void onActivityCreated(Bundle savedInstanceState) { super.onActivityCreated(savedInstanceState); - setupButtonBar(); } /* @@ -167,11 +158,11 @@ public class SettingsPreferenceFragment extends PreferenceFragment } protected boolean hasNextButton() { - return mNextButton != null; + return ((Settings)getActivity()).hasNextButton(); } protected Button getNextButton() { - return mNextButton; + return ((Settings)getActivity()).getNextButton(); } public void finish() { @@ -193,92 +184,4 @@ public class SettingsPreferenceFragment extends PreferenceFragment } } - /** - * Sets up Button Bar possibly required in the Fragment. Probably available only in - * phones. - * - * Previously {@link PreferenceActivity} had the capability as hidden functionality. - */ - private void setupButtonBar() { - // Originally from PreferenceActivity, which has had button bar inside its layout. - final Activity activity = getActivity(); - final Intent intent = activity.getIntent(); - final View buttonBar = activity.findViewById(com.android.internal.R.id.button_bar); - if (!intent.getBooleanExtra(EXTRA_PREFS_SHOW_BUTTON_BAR, false) || buttonBar == null) { - return; - } - - buttonBar.setVisibility(View.VISIBLE); - View tmpView = activity.findViewById(com.android.internal.R.id.back_button); - if (tmpView != null) { - // TODO: Assume this is pressed only in single pane, finishing current Activity. - try { - final Button backButton = (Button)tmpView; - backButton.setOnClickListener(new OnClickListener() { - public void onClick(View v) { - activity.setResult(Activity.RESULT_CANCELED); - activity.finish(); - } - }); - if (intent.hasExtra(EXTRA_PREFS_SET_BACK_TEXT)) { - String buttonText = intent.getStringExtra(EXTRA_PREFS_SET_BACK_TEXT); - if (TextUtils.isEmpty(buttonText)) { - backButton.setVisibility(View.GONE); - } - else { - backButton.setText(buttonText); - } - } - } catch (ClassCastException e) { - Log.w(TAG, "The view originally for back_button is used not as Button. " + - "Ignored."); - } - } - - tmpView = activity.findViewById(com.android.internal.R.id.skip_button); - if (tmpView != null) { - try { - final Button skipButton = (Button)tmpView; - skipButton.setOnClickListener(new OnClickListener() { - public void onClick(View v) { - activity.setResult(Activity.RESULT_OK); - activity.finish(); - } - }); - if (intent.getBooleanExtra(EXTRA_PREFS_SHOW_SKIP, false)) { - skipButton.setVisibility(View.VISIBLE); - } - } catch (ClassCastException e) { - Log.w(TAG, "The view originally for skip_button is used not as Button. " + - "Ignored."); - } - } - - tmpView = activity.findViewById(com.android.internal.R.id.next_button); - if (tmpView != null) { - try { - mNextButton = (Button)tmpView; - mNextButton.setOnClickListener(new OnClickListener() { - public void onClick(View v) { - activity.setResult(Activity.RESULT_OK); - activity.finish(); - } - }); - // set our various button parameters - if (intent.hasExtra(EXTRA_PREFS_SET_NEXT_TEXT)) { - String buttonText = intent.getStringExtra(EXTRA_PREFS_SET_NEXT_TEXT); - if (TextUtils.isEmpty(buttonText)) { - mNextButton.setVisibility(View.GONE); - } - else { - mNextButton.setText(buttonText); - } - } - } catch (ClassCastException e) { - Log.w(TAG, "The view originally for next_button is used not as Button. " + - "Ignored."); - mNextButton = null; - } - } - } } diff --git a/src/com/android/settings/SoundSettings.java b/src/com/android/settings/SoundSettings.java index cc38c23..23c7096 100644 --- a/src/com/android/settings/SoundSettings.java +++ b/src/com/android/settings/SoundSettings.java @@ -43,6 +43,7 @@ public class SoundSettings extends SettingsPreferenceFragment implements private static final String KEY_SILENT = "silent"; private static final String KEY_VIBRATE = "vibrate"; + private static final String KEY_RING_VOLUME = "ring_volume"; private static final String KEY_DTMF_TONE = "dtmf_tone"; private static final String KEY_SOUND_EFFECTS = "sound_effects"; private static final String KEY_HAPTIC_FEEDBACK = "haptic_feedback"; @@ -110,6 +111,10 @@ public class SoundSettings extends SettingsPreferenceFragment implements } mSilent = (CheckBoxPreference) findPreference(KEY_SILENT); + if (!getResources().getBoolean(R.bool.has_silent_mode)) { + getPreferenceScreen().removePreference(mSilent); + findPreference(KEY_RING_VOLUME).setDependency(null); + } mVibrate = (ListPreference) findPreference(KEY_VIBRATE); mVibrate.setOnPreferenceChangeListener(this); diff --git a/src/com/android/settings/wifi/WifiConfigUiForSetupWizardXL.java b/src/com/android/settings/wifi/WifiConfigUiForSetupWizardXL.java index 4de7ef5..bbd8f80 100644 --- a/src/com/android/settings/wifi/WifiConfigUiForSetupWizardXL.java +++ b/src/com/android/settings/wifi/WifiConfigUiForSetupWizardXL.java @@ -75,21 +75,28 @@ public class WifiConfigUiForSetupWizardXL implements WifiConfigUiBase, OnFocusCh // R.id.security_fields is the only parent for possible EditTexts. Possibly we need to // check parentand detect visibility manually. if (mView.findViewById(R.id.security_fields).getVisibility() == View.VISIBLE) { - // Set Focus to password View. - final View viewToBeFocused = mView.findViewById(R.id.password); - if (viewToBeFocused == null) { - Log.w(TAG, "password field to be focused not found."); - } else if (!(viewToBeFocused instanceof EditText)) { - Log.w(TAG, "password field is not EditText"); - } else { - // After acquiring the focus, we show software keyboard. - viewToBeFocused.setOnFocusChangeListener(this); - final boolean requestFocusResult = viewToBeFocused.requestFocus(); - Log.i(TAG, String.format("Focus request %s.", - (requestFocusResult ? "successful" : "failed"))); - if (!requestFocusResult) { - viewToBeFocused.setOnFocusChangeListener(null); - } + requestFocusAndShowKeyboard(R.id.password); + } + } + + /** + * @param editViewId must be EditView + */ + public void requestFocusAndShowKeyboard(int editViewId) { + // Set Focus to password View. + final View viewToBeFocused = mView.findViewById(editViewId); + if (viewToBeFocused == null) { + Log.w(TAG, "password field to be focused not found."); + } else if (!(viewToBeFocused instanceof EditText)) { + Log.w(TAG, "password field is not EditText"); + } else { + // After acquiring the focus, we show software keyboard. + viewToBeFocused.setOnFocusChangeListener(this); + final boolean requestFocusResult = viewToBeFocused.requestFocus(); + Log.i(TAG, String.format("Focus request %s.", + (requestFocusResult ? "successful" : "failed"))); + if (!requestFocusResult) { + viewToBeFocused.setOnFocusChangeListener(null); } } } diff --git a/src/com/android/settings/wifi/WifiSettings.java b/src/com/android/settings/wifi/WifiSettings.java index b81be6d..857e153 100644 --- a/src/com/android/settings/wifi/WifiSettings.java +++ b/src/com/android/settings/wifi/WifiSettings.java @@ -35,28 +35,29 @@ import android.net.NetworkInfo.DetailedState; import android.net.wifi.ScanResult; import android.net.wifi.SupplicantState; import android.net.wifi.WifiConfiguration; -import android.net.wifi.WifiConfiguration.KeyMgmt; import android.net.wifi.WifiInfo; import android.net.wifi.WifiManager; +import android.net.wifi.WifiConfiguration.KeyMgmt; import android.os.Bundle; import android.os.Handler; import android.os.Message; import android.preference.CheckBoxPreference; import android.preference.Preference; +import android.preference.PreferenceActivity; import android.preference.PreferenceScreen; import android.provider.Settings.Secure; import android.security.Credentials; import android.security.KeyStore; import android.view.ContextMenu; -import android.view.ContextMenu.ContextMenuInfo; import android.view.LayoutInflater; import android.view.Menu; import android.view.MenuInflater; import android.view.MenuItem; import android.view.View; import android.view.ViewGroup; -import android.widget.AdapterView.AdapterContextMenuInfo; +import android.view.ContextMenu.ContextMenuInfo; import android.widget.Toast; +import android.widget.AdapterView.AdapterContextMenuInfo; import java.util.ArrayList; import java.util.Collection; @@ -171,7 +172,7 @@ public class WifiSettings extends SettingsPreferenceFragment // Avoid re-adding on returning from an overlapping activity/fragment. if (getPreferenceScreen() == null || getPreferenceScreen().getPreferenceCount() < 2) { if (mEnableNextOnConnection) { - if (mEnableNextOnConnection && hasNextButton()) { + if (hasNextButton()) { final ConnectivityManager connectivity = (ConnectivityManager) getActivity().getSystemService(Context.CONNECTIVITY_SERVICE); if (connectivity != null) { @@ -445,6 +446,10 @@ public class WifiSettings extends SettingsPreferenceFragment updateConnectionState(WifiInfo.getDetailedStateOf((SupplicantState) intent.getParcelableExtra(WifiManager.EXTRA_NEW_STATE))); } + + if (mInXlSetupWizard) { + ((WifiSettingsForSetupWizardXL)getActivity()).onSupplicantStateChanged(intent); + } } else if (WifiManager.NETWORK_STATE_CHANGED_ACTION.equals(action)) { NetworkInfo info = (NetworkInfo) intent.getParcelableExtra( WifiManager.EXTRA_NETWORK_INFO); @@ -588,11 +593,11 @@ public class WifiSettings extends SettingsPreferenceFragment } } else if (config.networkId != INVALID_NETWORK_ID) { if (mSelectedAccessPoint != null) { - mWifiManager.saveNetwork(config); + saveNetwork(config); } } else { if (configController.isEdit() || requireKeyStore(config)) { - mWifiManager.saveNetwork(config); + saveNetwork(config); } else { mWifiManager.connectNetwork(config); } @@ -606,6 +611,14 @@ public class WifiSettings extends SettingsPreferenceFragment updateAccessPoints(); } + private void saveNetwork(WifiConfiguration config) { + if (mInXlSetupWizard) { + ((WifiSettingsForSetupWizardXL)getActivity()).onSaveNetwork(config); + } else { + mWifiManager.saveNetwork(config); + } + } + /* package */ void forget() { mWifiManager.forgetNetwork(mSelectedAccessPoint.networkId); diff --git a/src/com/android/settings/wifi/WifiSettingsForSetupWizardXL.java b/src/com/android/settings/wifi/WifiSettingsForSetupWizardXL.java index d55cbe4..f420f34 100644 --- a/src/com/android/settings/wifi/WifiSettingsForSetupWizardXL.java +++ b/src/com/android/settings/wifi/WifiSettingsForSetupWizardXL.java @@ -20,7 +20,9 @@ import com.android.settings.R; import android.app.Activity; import android.content.Context; +import android.content.Intent; import android.net.NetworkInfo.DetailedState; +import android.net.wifi.WifiConfiguration; import android.net.wifi.WifiManager; import android.os.Bundle; import android.os.Handler; @@ -87,6 +89,10 @@ public class WifiSettingsForSetupWizardXL extends Activity implements OnClickLis private final Handler mHandler = new Handler(); + private int mPreviousWpsFieldsVisibility = View.GONE; + private int mPreviousSecurityFieldsVisibility = View.GONE; + private int mPreviousTypeVisibility = View.GONE; + // At first, we set "Skip" button disabled so that users won't press it soon after the screen // migration. The button is enabled after the wifi module returns some result // (a list of available network, etc.) One possible problem is that the notification from the @@ -233,9 +239,9 @@ public class WifiSettingsForSetupWizardXL extends Activity implements OnClickLis mProgressBar.setIndeterminate(false); mProgressBar.setProgress(2); mProgressText.setText(Summary.get(this, state)); - mStatusText.setVisibility(View.VISIBLE); mStatusText.setText(R.string.wifi_setup_status_proceed_to_next); + mConnectButton.setVisibility(View.GONE); mAddNetworkButton.setVisibility(View.GONE); mRefreshButton.setVisibility(View.GONE); mBackButton.setVisibility(View.VISIBLE); @@ -260,13 +266,11 @@ public class WifiSettingsForSetupWizardXL extends Activity implements OnClickLis mAddNetworkButton.setEnabled(true); mRefreshButton.setEnabled(true); - mSkipOrNextButton.setEnabled(true); } private void showConnectingStatus() { mProgressBar.setIndeterminate(false); mProgressBar.setProgress(1); - mStatusText.setVisibility(View.VISIBLE); mStatusText.setText(R.string.wifi_setup_status_connecting); mProgressText.setText(Summary.get(this, DetailedState.CONNECTING)); } @@ -276,7 +280,6 @@ public class WifiSettingsForSetupWizardXL extends Activity implements OnClickLis ((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.setVisibility(View.VISIBLE); mStatusText.setText(R.string.wifi_setup_status_scanning); } @@ -294,6 +297,15 @@ public class WifiSettingsForSetupWizardXL extends Activity implements OnClickLis * "Add network" button, meaning there's no selected access point. */ /* package */ void showConfigUi(AccessPoint selectedAccessPoint, boolean edit) { + if (selectedAccessPoint != null && + (selectedAccessPoint.security == AccessPoint.SECURITY_WEP || + selectedAccessPoint.security == AccessPoint.SECURITY_PSK)) { + // We forcibly set edit as true so that users can modify every field if they want, + // while config UI doesn't allow them to edit some of them when edit is false + // (e.g. password field is hiden when edit==false). + edit = true; + } + // We don't want to keep scanning Wi-Fi networks during users' configuring one network. mWifiSettings.pauseWifiScan(); @@ -310,7 +322,6 @@ public class WifiSettingsForSetupWizardXL extends Activity implements OnClickLis } else { view.findViewById(R.id.wifi_general_info).setVisibility(View.GONE); } - // parent.addView(view); if (selectedAccessPoint != null && selectedAccessPoint.security == AccessPoint.SECURITY_NONE) { @@ -320,10 +331,15 @@ public class WifiSettingsForSetupWizardXL extends Activity implements OnClickLis mStatusText.setText(R.string.wifi_setup_status_eap_not_supported); mConnectButton.setVisibility(View.GONE); } else { - // mStatusText.setText(R.string.wifi_setup_status_edit_network); - mStatusText.setVisibility(View.GONE); + mStatusText.setText(R.string.wifi_setup_status_edit_network); mConnectButton.setVisibility(View.VISIBLE); } + + // WifiConfigController shows Connect button as "Save" when edit==true and a user + // tried to connect the network. + // In SetupWizard, we just show the button as "Connect" instead. + mConnectButton.setText(R.string.wifi_connect); + mAddNetworkButton.setVisibility(View.GONE); mRefreshButton.setVisibility(View.GONE); mSkipOrNextButton.setVisibility(View.GONE); @@ -345,10 +361,24 @@ public class WifiSettingsForSetupWizardXL extends Activity implements OnClickLis // Might be better to delay showing this button. mBackButton.setVisibility(View.VISIBLE); - findViewById(R.id.wps_fields).setVisibility(View.GONE); - findViewById(R.id.security_fields).setVisibility(View.GONE); - findViewById(R.id.type).setVisibility(View.GONE); + // We need to restore visibility status when the device failed to connect the network. + final View wpsFieldView = findViewById(R.id.wps_fields); + if (wpsFieldView != null) { + mPreviousWpsFieldsVisibility = wpsFieldView.getVisibility(); + wpsFieldView.setVisibility(View.GONE); + } + final View securityFieldsView = findViewById(R.id.security_fields); + if (securityFieldsView != null) { + mPreviousSecurityFieldsVisibility = securityFieldsView.getVisibility(); + securityFieldsView.setVisibility(View.GONE); + } + final View typeView = findViewById(R.id.type); + if (typeView != null) { + mPreviousTypeVisibility = typeView.getVisibility(); + typeView.setVisibility(View.GONE); + } + mHandler.removeCallbacks(mSkipButtonEnabler); mSkipOrNextButton.setVisibility(View.VISIBLE); mSkipOrNextButton.setEnabled(false); mConnectButton.setVisibility(View.GONE); @@ -389,7 +419,6 @@ public class WifiSettingsForSetupWizardXL extends Activity implements OnClickLis } else { // During user's Wifi configuration. mWifiSettings.resumeWifiScan(); - mStatusText.setVisibility(View.VISIBLE); mStatusText.setText(R.string.wifi_setup_status_select_network); restoreFirstButtonVisibilityState(); @@ -437,4 +466,62 @@ public class WifiSettingsForSetupWizardXL extends Activity implements OnClickLis mWifiSettings.refreshAccessPoints(); } + + /** + * Called when {@link WifiSettings} received {@link WifiManager#SUPPLICANT_CHANGED_ACTION}. + */ + /* package */ void onSupplicantStateChanged(Intent intent) { + final int errorCode = intent.getIntExtra(WifiManager.EXTRA_SUPPLICANT_ERROR, -1); + if (errorCode == WifiManager.ERROR_AUTHENTICATING) { + Log.i(TAG, "Received authentication error event."); + onAuthenticationFailure(); + } + } + + /** + * Called once when Authentication failed. + */ + private void onAuthenticationFailure() { + mAfterConnectAction = false; + mStatusText.setText(R.string.wifi_setup_status_edit_network); + mSkipOrNextButton.setVisibility(View.GONE); + mConnectButton.setVisibility(View.VISIBLE); + mConnectButton.setEnabled(true); + + // Restore View status which was tweaked on connection. + final View wpsFieldView = findViewById(R.id.wps_fields); + if (wpsFieldView != null) { + wpsFieldView.setVisibility(mPreviousWpsFieldsVisibility); + } + final View securityFieldsView = findViewById(R.id.security_fields); + if (securityFieldsView != null) { + securityFieldsView.setVisibility(mPreviousSecurityFieldsVisibility); + if (mPreviousSecurityFieldsVisibility == View.VISIBLE && mWifiConfig != null) { + final View passwordView = findViewById(R.id.password); + if (passwordView != null) { + if (passwordView.isFocused()) { + final InputMethodManager inputMethodManager = (InputMethodManager) + getSystemService(Context.INPUT_METHOD_SERVICE); + inputMethodManager.showSoftInput(passwordView, 0); + } else { + mWifiConfig.requestFocusAndShowKeyboard(R.id.password); + } + } + } + } + final View typeView = findViewById(R.id.type); + if (typeView != null) { + typeView.setVisibility(mPreviousTypeVisibility); + } + } + + /** + * Called when WifiManager is requested to save a network. This method sholud include + * WifiManager#saveNetwork() call. + * + * Currently this method calls {@link WifiManager#connectNetwork(int)}. + */ + /* package */ void onSaveNetwork(WifiConfiguration config) { + mWifiManager.connectNetwork(config); + } } |