diff --git a/AndroidManifest.xml b/AndroidManifest.xml
index d7d67b04726..b7554bc1716 100644
--- a/AndroidManifest.xml
+++ b/AndroidManifest.xml
@@ -208,13 +208,6 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/src/com/android/settings/wifi/WifiConfigController.java b/src/com/android/settings/wifi/WifiConfigController.java
index a5d076575d6..e244b7fb132 100644
--- a/src/com/android/settings/wifi/WifiConfigController.java
+++ b/src/com/android/settings/wifi/WifiConfigController.java
@@ -99,9 +99,6 @@ public class WifiConfigController implements TextWatcher,
/* Full list of phase2 methods */
private final ArrayAdapter PHASE2_FULL_ADAPTER;
- // True when this instance is used in SetupWizard XL context.
- private final boolean mInXlSetupWizard;
-
private final Handler mTextViewChangedHandler;
// e.g. AccessPoint.SECURITY_NONE
@@ -148,7 +145,6 @@ public class WifiConfigController implements TextWatcher,
public WifiConfigController(
WifiConfigUiBase parent, View view, AccessPoint accessPoint, boolean edit) {
mConfigUi = parent;
- mInXlSetupWizard = (parent instanceof WifiConfigUiForSetupWizardXL);
mView = view;
mAccessPoint = accessPoint;
@@ -184,18 +180,7 @@ public class WifiConfigController implements TextWatcher,
mSsidView.addTextChangedListener(this);
mSecuritySpinner = ((Spinner) mView.findViewById(R.id.security));
mSecuritySpinner.setOnItemSelectedListener(this);
- if (mInXlSetupWizard) {
- mView.findViewById(R.id.type_ssid).setVisibility(View.VISIBLE);
- mView.findViewById(R.id.type_security).setVisibility(View.VISIBLE);
- // We want custom layout. The content must be same as the other cases.
-
- ArrayAdapter adapter = new ArrayAdapter(mContext,
- R.layout.wifi_setup_custom_list_item_1, android.R.id.text1,
- res.getStringArray(R.array.wifi_security_no_eap));
- mSecuritySpinner.setAdapter(adapter);
- } else {
- mView.findViewById(R.id.type).setVisibility(View.VISIBLE);
- }
+ mView.findViewById(R.id.type).setVisibility(View.VISIBLE);
showIpConfigFields();
showProxyFields();
@@ -605,13 +590,6 @@ public class WifiConfigController implements TextWatcher,
}
private void showSecurityFields() {
- if (mInXlSetupWizard) {
- // Note: XL SetupWizard won't hide "EAP" settings here.
- if (!((WifiSettingsForSetupWizardXL)mConfigUi.getContext()).initSecurityFields(mView,
- mAccessPointSecurity)) {
- return;
- }
- }
if (mAccessPointSecurity == AccessPoint.SECURITY_NONE) {
mView.findViewById(R.id.security_fields).setVisibility(View.GONE);
return;
diff --git a/src/com/android/settings/wifi/WifiConfigUiBase.java b/src/com/android/settings/wifi/WifiConfigUiBase.java
index 11dcc0041c7..a0f67ab3cad 100644
--- a/src/com/android/settings/wifi/WifiConfigUiBase.java
+++ b/src/com/android/settings/wifi/WifiConfigUiBase.java
@@ -21,8 +21,7 @@ import android.view.LayoutInflater;
import android.widget.Button;
/**
- * Foundation interface glues between Activities and UIs like
- * {@link WifiDialog} or {@link WifiConfigUiForSetupWizardXL}.
+ * Foundation interface glues between Activities and UIs like {@link WifiDialog}.
*/
public interface WifiConfigUiBase {
public Context getContext();
diff --git a/src/com/android/settings/wifi/WifiConfigUiForSetupWizardXL.java b/src/com/android/settings/wifi/WifiConfigUiForSetupWizardXL.java
deleted file mode 100644
index 62bb5e170e2..00000000000
--- a/src/com/android/settings/wifi/WifiConfigUiForSetupWizardXL.java
+++ /dev/null
@@ -1,211 +0,0 @@
-/*
- * Copyright (C) 2010 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.
- */
-
-package com.android.settings.wifi;
-
-import com.android.settings.R;
-import com.android.settingslib.wifi.AccessPoint;
-
-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;
-import android.widget.EditText;
-
-/**
- * Shows simplified UI for configuring a wifi network. Used only in SetupWizard for XLarge
- * screen.
- */
-public class WifiConfigUiForSetupWizardXL implements WifiConfigUiBase, OnFocusChangeListener {
- private static final String TAG = "SetupWizard";
-
- private Button mConnectButton;
- private Button mCancelButton;
-
- private final WifiSettingsForSetupWizardXL mActivity;
- private View mView;
- private WifiConfigController mController;
- private AccessPoint mAccessPoint;
- private boolean mEdit;
- private Handler mHandler = new Handler();
-
- private final InputMethodManager mInputMethodManager;
-
- private LayoutInflater mInflater;
-
- /**
- * @param activity Activity which creates this object.
- * @param parent Parent ViewGroup (typically some layout) holding a view object created by
- * this object
- * @param accessPoint target AccessPoint to be configured.
- * @param edit
- */
- public WifiConfigUiForSetupWizardXL(
- WifiSettingsForSetupWizardXL activity, ViewGroup parent,
- AccessPoint accessPoint, boolean edit) {
- mActivity = activity;
- mConnectButton = (Button)activity.findViewById(R.id.wifi_setup_connect);
- mCancelButton = (Button)activity.findViewById(R.id.wifi_setup_cancel);
- mAccessPoint = accessPoint;
- mEdit = edit;
- mInflater = (LayoutInflater)activity.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
-
- mView = mInflater.inflate(R.layout.wifi_config_ui_for_setup_wizard, parent, true);
- mController = new WifiConfigController(this, mView, mAccessPoint, edit);
-
- mInputMethodManager = (InputMethodManager)
- activity.getSystemService(Context.INPUT_METHOD_SERVICE);
-
- if (mView.findViewById(R.id.security_fields).getVisibility() == View.VISIBLE) {
- requestFocusAndShowKeyboard(R.id.password);
- } else if (mView.findViewById(R.id.type_ssid).getVisibility() == View.VISIBLE) {
- // Add Network flow.
- requestFocusAndShowKeyboard(R.id.ssid);
- }
- }
-
- /**
- * @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 {
- if (viewToBeFocused.isFocused()) {
- Log.i(TAG, "Already focused");
- if (!mInputMethodManager.showSoftInput(viewToBeFocused, 0)) {
- Log.w(TAG, "Failed to show SoftInput");
- }
- } 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);
- }
- }
- }
- }
-
- public View getView() {
- return mView;
- }
-
- public AccessPoint getAccessPoint() {
- return mAccessPoint;
- }
-
- @Override
- public WifiConfigController getController() {
- return mController;
- }
-
- @Override
- public boolean isEdit() {
- return mEdit;
- }
-
- @Override
- public LayoutInflater getLayoutInflater() {
- return mInflater;
- }
-
- @Override
- public Button getSubmitButton() {
- return mConnectButton;
- }
-
- @Override
- public Button getForgetButton() {
- return null;
- }
-
- @Override
- public Button getCancelButton() {
- return mCancelButton;
- }
-
- @Override
- public void setSubmitButton(CharSequence text) {
- mConnectButton.setVisibility(View.VISIBLE);
- mConnectButton.setText(text);
- }
-
- @Override
- public void setForgetButton(CharSequence text) {
- // In XL setup screen, we won't show Forget button for simplifying the UI.
- }
-
- @Override
- public void setCancelButton(CharSequence text) {
- mCancelButton.setVisibility(View.VISIBLE);
- // We don't want "cancel" label given from caller.
- // mCancelButton.setText(text);
- }
-
- @Override
- public Context getContext() {
- return mActivity;
- }
-
- @Override
- public void setTitle(int id) {
- Log.d(TAG, "Ignoring setTitle");
- }
-
- @Override
- public void setTitle(CharSequence title) {
- Log.d(TAG, "Ignoring setTitle");
- }
-
- private class FocusRunnable implements Runnable {
- final View mViewToBeFocused;
- public FocusRunnable(View viewToBeFocused) {
- mViewToBeFocused = viewToBeFocused;
- }
-
- @Override
- public void run() {
- // mInputMethodManager.focusIn(mViewToBeFocused);
- final boolean showSoftInputResult =
- mInputMethodManager.showSoftInput(mViewToBeFocused, 0);
- if (showSoftInputResult) {
- mActivity.setPaddingVisibility(View.GONE);
- } else {
- 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(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
deleted file mode 100644
index a3018a3d4d7..00000000000
--- a/src/com/android/settings/wifi/WifiSettingsForSetupWizardXL.java
+++ /dev/null
@@ -1,770 +0,0 @@
-/*
- * Copyright (C) 2010 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.
- */
-
-package com.android.settings.wifi;
-
-import android.app.Activity;
-import android.content.Context;
-import android.content.Intent;
-import android.content.pm.ActivityInfo;
-import android.net.NetworkInfo.DetailedState;
-import android.net.wifi.WifiConfiguration;
-import android.net.wifi.WifiManager;
-import android.os.Bundle;
-import android.preference.PreferenceScreen;
-import android.text.TextUtils;
-import android.util.Log;
-import android.view.View;
-import android.view.View.OnClickListener;
-import android.view.ViewGroup;
-import android.view.Window;
-import android.view.inputmethod.InputMethodManager;
-import android.widget.Button;
-import android.widget.ProgressBar;
-import android.widget.TextView;
-
-import com.android.settings.R;
-import com.android.settingslib.wifi.AccessPoint;
-
-import java.util.Collection;
-import java.util.EnumMap;
-import java.util.List;
-
-/**
- * WifiSetings Activity specific for SetupWizard with X-Large screen size.
- */
-public class WifiSettingsForSetupWizardXL extends Activity implements OnClickListener {
- private static final String TAG = "SetupWizard";
- private static final boolean DEBUG = true;
-
- // lock orientation into landscape or portrait
- private static final String EXTRA_PREFS_LANDSCAPE_LOCK = "extra_prefs_landscape_lock";
- private static final String EXTRA_PREFS_PORTRAIT_LOCK = "extra_prefs_portrait_lock";
-
- private static final EnumMap sNetworkStateMap =
- new EnumMap(DetailedState.class);
-
- static {
- sNetworkStateMap.put(DetailedState.IDLE, DetailedState.DISCONNECTED);
- sNetworkStateMap.put(DetailedState.SCANNING, DetailedState.SCANNING);
- sNetworkStateMap.put(DetailedState.CONNECTING, DetailedState.CONNECTING);
- sNetworkStateMap.put(DetailedState.AUTHENTICATING, DetailedState.CONNECTING);
- sNetworkStateMap.put(DetailedState.OBTAINING_IPADDR, DetailedState.CONNECTING);
- sNetworkStateMap.put(DetailedState.CONNECTED, DetailedState.CONNECTED);
- sNetworkStateMap.put(DetailedState.SUSPENDED, DetailedState.SUSPENDED); // ?
- sNetworkStateMap.put(DetailedState.DISCONNECTING, DetailedState.DISCONNECTED);
- sNetworkStateMap.put(DetailedState.DISCONNECTED, DetailedState.DISCONNECTED);
- sNetworkStateMap.put(DetailedState.FAILED, DetailedState.FAILED);
- }
-
- private WifiSettings mWifiSettings;
- private WifiManager mWifiManager;
-
- /** Used for resizing a padding above title. Hiden when software keyboard is shown. */
- private View mTopPadding;
-
- /** Used for resizing a padding of main content. Hiden when software keyboard is shown. */
- private View mContentPadding;
-
- private TextView mTitleView;
- /**
- * The name of a network currently connecting, or trying to connect.
- * This may be empty ("") at first, and updated when configuration is changed.
- */
- private CharSequence mNetworkName = "";
- private CharSequence mEditingTitle;
-
- private ProgressBar mProgressBar;
- private View mTopDividerNoProgress;
- /**
- * Used for resizing a padding between WifiSettings preference and bottom bar when
- * ProgressBar is visible as a top divider.
- */
- private View mBottomPadding;
-
- private Button mAddNetworkButton;
- private Button mRefreshButton;
- private Button mSkipOrNextButton;
- private Button mBackButton;
-
- private Button mConnectButton;
-
- /**
- * View enclosing {@link WifiSettings}.
- */
- private View mWifiSettingsFragmentLayout;
- private View mConnectingStatusLayout;
- private TextView mConnectingStatusView;
-
- /*
- * States of current screen, which should be saved and restored when Activity is relaunched
- * with orientation change, etc.
- */
- private static final int SCREEN_STATE_DISCONNECTED = 0;
- private static final int SCREEN_STATE_EDITING = 1;
- private static final int SCREEN_STATE_CONNECTING = 2;
- private static final int SCREEN_STATE_CONNECTED = 3;
-
- /** Current screen state. */
- private int mScreenState = SCREEN_STATE_DISCONNECTED;
-
- private WifiConfigUiForSetupWizardXL mWifiConfig;
-
- private InputMethodManager mInputMethodManager;
-
- /**
- * Previous network connection state reported by main Wifi module.
- *
- * Note that we don't use original {@link DetailedState} object but simplified one translated
- * using sNetworkStateMap.
- */
- private DetailedState mPreviousNetworkState = DetailedState.DISCONNECTED;
-
- @Override
- public void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- requestWindowFeature(Window.FEATURE_NO_TITLE);
- setContentView(R.layout.wifi_settings_for_setup_wizard_xl);
-
- mWifiManager = (WifiManager)getSystemService(Context.WIFI_SERVICE);
- // There's no button here enabling wifi network, so we need to enable it without
- // users' request.
- mWifiManager.setWifiEnabled(true);
-
- mWifiSettings =
- (WifiSettings)getFragmentManager().findFragmentById(R.id.wifi_setup_fragment);
- mInputMethodManager = (InputMethodManager)getSystemService(Context.INPUT_METHOD_SERVICE);
-
- initViews();
-
- // At first, Wifi module doesn't return SCANNING state (it's too early), so we manually
- // show it.
- showScanningState();
- }
-
- private void initViews() {
- Intent intent = getIntent();
-
- if (intent.getBooleanExtra("firstRun", false)) {
- final View layoutRoot = findViewById(R.id.layout_root);
- layoutRoot.setSystemUiVisibility(View.STATUS_BAR_DISABLE_BACK);
- }
- if (intent.getBooleanExtra(EXTRA_PREFS_LANDSCAPE_LOCK, false)) {
- setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_SENSOR_LANDSCAPE);
- }
- if (intent.getBooleanExtra(EXTRA_PREFS_PORTRAIT_LOCK, false)) {
- setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_SENSOR_PORTRAIT);
- }
-
- mTitleView = (TextView)findViewById(R.id.wifi_setup_title);
- mProgressBar = (ProgressBar)findViewById(R.id.scanning_progress_bar);
- mProgressBar.setMax(2);
- mTopDividerNoProgress = findViewById(R.id.top_divider_no_progress);
- mBottomPadding = findViewById(R.id.bottom_padding);
-
- mProgressBar.setVisibility(View.VISIBLE);
- mProgressBar.setIndeterminate(true);
- mTopDividerNoProgress.setVisibility(View.GONE);
-
- mAddNetworkButton = (Button)findViewById(R.id.wifi_setup_add_network);
- mAddNetworkButton.setOnClickListener(this);
- mRefreshButton = (Button)findViewById(R.id.wifi_setup_refresh_list);
- mRefreshButton.setOnClickListener(this);
- mSkipOrNextButton = (Button)findViewById(R.id.wifi_setup_skip_or_next);
- mSkipOrNextButton.setOnClickListener(this);
- mConnectButton = (Button)findViewById(R.id.wifi_setup_connect);
- mConnectButton.setOnClickListener(this);
- mBackButton = (Button)findViewById(R.id.wifi_setup_cancel);
- mBackButton.setOnClickListener(this);
-
- mTopPadding = findViewById(R.id.top_padding);
- mContentPadding = findViewById(R.id.content_padding);
-
- mWifiSettingsFragmentLayout = findViewById(R.id.wifi_settings_fragment_layout);
- mConnectingStatusLayout = findViewById(R.id.connecting_status_layout);
- mConnectingStatusView = (TextView) findViewById(R.id.connecting_status);
- }
-
- private void restoreFirstVisibilityState() {
- showDefaultTitle();
- mAddNetworkButton.setVisibility(View.VISIBLE);
- mRefreshButton.setVisibility(View.VISIBLE);
- mSkipOrNextButton.setVisibility(View.VISIBLE);
- mConnectButton.setVisibility(View.GONE);
- mBackButton.setVisibility(View.GONE);
- setPaddingVisibility(View.VISIBLE);
- }
-
- @Override
- public void onClick(View view) {
- hideSoftwareKeyboard();
- if (view == mAddNetworkButton) {
- if (DEBUG) Log.d(TAG, "AddNetwork button pressed");
- onAddNetworkButtonPressed();
- } else if (view == mRefreshButton) {
- if (DEBUG) Log.d(TAG, "Refresh button pressed");
- refreshAccessPoints(true);
- } else if (view == mSkipOrNextButton) {
- if (DEBUG) Log.d(TAG, "Skip/Next button pressed");
- if (TextUtils.equals(getString(R.string.wifi_setup_skip), ((Button)view).getText())) {
- // We don't want to let Wifi enabled when a user press skip without choosing
- // any access point.
- mWifiManager.setWifiEnabled(false);
- // Notify "skip"
- setResult(RESULT_FIRST_USER);
- } else {
- setResult(RESULT_OK);
- }
- finish();
- } else if (view == mConnectButton) {
- if (DEBUG) Log.d(TAG, "Connect button pressed");
- onConnectButtonPressed();
- } else if (view == mBackButton) {
- if (DEBUG) Log.d(TAG, "Back button pressed");
- onBackButtonPressed();
- }
- }
-
- private void hideSoftwareKeyboard() {
- if (DEBUG) Log.i(TAG, "Hiding software keyboard.");
- final View focusedView = getCurrentFocus();
- if (focusedView != null) {
- mInputMethodManager.hideSoftInputFromWindow(focusedView.getWindowToken(), 0);
- }
- }
-
- // Called from WifiSettings
- /* package */ void updateConnectionState(DetailedState originalState) {
- final DetailedState state = sNetworkStateMap.get(originalState);
-
- if (originalState == DetailedState.FAILED) {
- // We clean up the current connectivity status and let users select another network
- // if they want.
- refreshAccessPoints(true);
- }
-
- switch (state) {
- case SCANNING: {
- if (mScreenState == SCREEN_STATE_DISCONNECTED) {
- if (mWifiSettings.getAccessPointsCount() == 0) {
- showScanningState();
- } else {
- showDisconnectedProgressBar();
- mWifiSettingsFragmentLayout.setVisibility(View.VISIBLE);
- mBottomPadding.setVisibility(View.GONE);
- }
- } else {
- showDisconnectedProgressBar();
- }
- break;
- }
- case CONNECTING: {
- if (mScreenState == SCREEN_STATE_CONNECTING) {
- showConnectingState();
- }
- break;
- }
- case CONNECTED: {
- showConnectedState();
- break;
- }
- default: // DISCONNECTED, FAILED
- if (mScreenState != SCREEN_STATE_CONNECTED &&
- mWifiSettings.getAccessPointsCount() > 0) {
- showDisconnectedState(AccessPoint.getSummary(this, state, false /* isEphemeral */));
- }
- break;
- }
- mPreviousNetworkState = state;
- }
-
- private void showDisconnectedState(String stateString) {
- showDisconnectedProgressBar();
- if (mScreenState == SCREEN_STATE_DISCONNECTED &&
- mWifiSettings.getAccessPointsCount() > 0) {
- mWifiSettingsFragmentLayout.setVisibility(View.VISIBLE);
- mBottomPadding.setVisibility(View.GONE);
- }
- mAddNetworkButton.setEnabled(true);
- mRefreshButton.setEnabled(true);
- }
-
- private void showConnectingState() {
- mScreenState = SCREEN_STATE_CONNECTING;
-
- mBackButton.setVisibility(View.VISIBLE);
- // We save this title and show it when authentication failed.
- mEditingTitle = mTitleView.getText();
- showConnectingTitle();
- showConnectingProgressBar();
-
- setPaddingVisibility(View.VISIBLE);
- }
-
- private void showConnectedState() {
- // Once we show "connected" screen, we won't change it even when the device becomes
- // disconnected afterwards. We keep the state unless a user explicitly cancel it
- // (by pressing "back" button).
- mScreenState = SCREEN_STATE_CONNECTED;
-
- hideSoftwareKeyboard();
- setPaddingVisibility(View.VISIBLE);
-
- showConnectedTitle();
- showConnectedProgressBar();
-
- mWifiSettingsFragmentLayout.setVisibility(View.GONE);
- mConnectingStatusLayout.setVisibility(View.VISIBLE);
-
- mConnectingStatusView.setText(R.string.wifi_setup_description_connected);
- mConnectButton.setVisibility(View.GONE);
- mAddNetworkButton.setVisibility(View.GONE);
- mRefreshButton.setVisibility(View.GONE);
- mBackButton.setVisibility(View.VISIBLE);
- mBackButton.setText(R.string.wifi_setup_back);
- mSkipOrNextButton.setVisibility(View.VISIBLE);
- mSkipOrNextButton.setEnabled(true);
- }
-
- private void showDefaultTitle() {
- mTitleView.setText(getString(R.string.wifi_setup_title));
- }
-
- private void showAddNetworkTitle() {
- mNetworkName = "";
- mTitleView.setText(R.string.wifi_setup_title_add_network);
- }
-
- private void showEditingTitle() {
- if (TextUtils.isEmpty(mNetworkName) && mWifiConfig != null) {
- if (mWifiConfig.getController() != null &&
- mWifiConfig.getController().getConfig() != null) {
- mNetworkName = mWifiConfig.getController().getConfig().SSID;
- } else {
- Log.w(TAG, "Unexpected null found (WifiController or WifiConfig is null). " +
- "Ignore them.");
- }
- }
- mTitleView.setText(getString(R.string.wifi_setup_title_editing_network, mNetworkName));
- }
-
- private void showConnectingTitle() {
- if (TextUtils.isEmpty(mNetworkName) && mWifiConfig != null) {
- if (mWifiConfig.getController() != null &&
- mWifiConfig.getController().getConfig() != null) {
- mNetworkName = mWifiConfig.getController().getConfig().SSID;
- } else {
- Log.w(TAG, "Unexpected null found (WifiController or WifiConfig is null). " +
- "Ignore them.");
- }
- }
- mTitleView.setText(getString(R.string.wifi_setup_title_connecting_network, mNetworkName));
- }
-
- private void showConnectedTitle() {
- if (TextUtils.isEmpty(mNetworkName) && mWifiConfig != null) {
- if (mWifiConfig.getController() != null &&
- mWifiConfig.getController().getConfig() != null) {
- mNetworkName = mWifiConfig.getController().getConfig().SSID;
- } else {
- Log.w(TAG, "Unexpected null found (WifiController or WifiConfig is null). " +
- "Ignore them.");
- }
- }
- mTitleView.setText(getString(R.string.wifi_setup_title_connected_network, mNetworkName));
- }
-
- /**
- * Shows top divider with ProgressBar without defining the state of the ProgressBar.
- *
- * @see #showScanningProgressBar()
- * @see #showConnectedProgressBar()
- * @see #showConnectingProgressBar()
- */
- private void showTopDividerWithProgressBar() {
- mProgressBar.setVisibility(View.VISIBLE);
- mTopDividerNoProgress.setVisibility(View.GONE);
- mBottomPadding.setVisibility(View.GONE);
- }
-
- private void showScanningState() {
- setPaddingVisibility(View.VISIBLE);
- mWifiSettingsFragmentLayout.setVisibility(View.GONE);
- showScanningProgressBar();
- }
-
- private void onAddNetworkButtonPressed() {
- mWifiSettings.onAddNetworkPressed();
- }
-
- /**
- * Called when the screen enters wifi configuration UI. UI widget for configuring network
- * (a.k.a. ConfigPreference) should be taken care of by caller side.
- * This method should handle buttons' visibility/enabled.
- * @param selectedAccessPoint AccessPoint object being selected. null when a user pressed
- * "Add network" button, meaning there's no selected access point.
- */
- /* package */ void showConfigUi(AccessPoint selectedAccessPoint, boolean edit) {
- mScreenState = SCREEN_STATE_EDITING;
-
- if (selectedAccessPoint != null &&
- (selectedAccessPoint.getSecurity() == AccessPoint.SECURITY_WEP ||
- selectedAccessPoint.getSecurity() == 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 Wifi networks during users' configuring a network.
- mWifiSettings.pauseWifiScan();
-
- mWifiSettingsFragmentLayout.setVisibility(View.GONE);
- mConnectingStatusLayout.setVisibility(View.GONE);
- final ViewGroup parent = (ViewGroup)findViewById(R.id.wifi_config_ui);
- parent.setVisibility(View.VISIBLE);
- parent.removeAllViews();
- mWifiConfig = new WifiConfigUiForSetupWizardXL(this, parent, selectedAccessPoint, edit);
-
- if (selectedAccessPoint == null) { // "Add network" flow
- showAddNetworkTitle();
- mConnectButton.setVisibility(View.VISIBLE);
-
- showDisconnectedProgressBar();
- showEditingButtonState();
- } else if (selectedAccessPoint.getSecurity() == AccessPoint.SECURITY_NONE) {
- mNetworkName = selectedAccessPoint.getSsid().toString();
-
- // onConnectButtonPressed() will change visibility status.
- mConnectButton.performClick();
- } else {
- mNetworkName = selectedAccessPoint.getSsid().toString();
- showEditingTitle();
- showDisconnectedProgressBar();
- showEditingButtonState();
- if (selectedAccessPoint.getSecurity() == AccessPoint.SECURITY_EAP) {
- onEapNetworkSelected();
- } else {
- 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);
- mBackButton.setText(R.string.wifi_setup_cancel);
- }
- }
- }
-
- /**
- * Called before security fields are correctly set by {@link WifiConfigController}.
- *
- * @param view security field view
- * @param accessPointSecurity type of security. e.g. AccessPoint.SECURITY_NONE
- * @return true when it is ok for the caller to init security fields. false when
- * all security fields are managed by this method, and thus the caller shouldn't touch them.
- */
- /* package */ boolean initSecurityFields(View view, int accessPointSecurity) {
- // Reset all states tweaked below.
- view.findViewById(R.id.eap_not_supported).setVisibility(View.GONE);
- view.findViewById(R.id.eap_not_supported_for_add_network).setVisibility(View.GONE);
- view.findViewById(R.id.ssid_text).setVisibility(View.VISIBLE);
- view.findViewById(R.id.ssid_layout).setVisibility(View.VISIBLE);
-
- if (accessPointSecurity == AccessPoint.SECURITY_EAP) {
- setPaddingVisibility(View.VISIBLE);
- hideSoftwareKeyboard();
-
- // In SetupWizard for XLarge screen, we don't have enough space for showing
- // configurations needed for EAP. We instead disable the whole feature there and let
- // users configure those networks after the setup.
- if (view.findViewById(R.id.type_ssid).getVisibility() == View.VISIBLE) {
- view.findViewById(R.id.eap_not_supported_for_add_network)
- .setVisibility(View.VISIBLE);
- } else {
- view.findViewById(R.id.eap_not_supported).setVisibility(View.VISIBLE);
- }
- view.findViewById(R.id.security_fields).setVisibility(View.GONE);
- view.findViewById(R.id.ssid_text).setVisibility(View.GONE);
- view.findViewById(R.id.ssid_layout).setVisibility(View.GONE);
- onEapNetworkSelected();
-
- // This method did init security fields by itself. The caller must not do it.
- return false;
- }
-
- mConnectButton.setVisibility(View.VISIBLE);
- setPaddingVisibility(View.GONE);
-
- // In "add network" flow, we'll see multiple initSecurityFields() calls with different
- // accessPointSecurity variable. We want to show software keyboard conditionally everytime
- // when this method is called.
- if (mWifiConfig != null) {
- if (accessPointSecurity == AccessPoint.SECURITY_PSK ||
- accessPointSecurity == AccessPoint.SECURITY_WEP) {
- mWifiConfig.requestFocusAndShowKeyboard(R.id.password);
- } else {
- mWifiConfig.requestFocusAndShowKeyboard(R.id.ssid);
- }
- }
-
- // Let the caller init security fields.
- return true;
- }
-
- private void onEapNetworkSelected() {
- mConnectButton.setVisibility(View.GONE);
- mBackButton.setText(R.string.wifi_setup_back);
- }
-
- private void showEditingButtonState() {
- mSkipOrNextButton.setVisibility(View.GONE);
- mAddNetworkButton.setVisibility(View.GONE);
- mRefreshButton.setVisibility(View.GONE);
- mBackButton.setVisibility(View.VISIBLE);
- }
-
- // May be called when user press "connect" button in WifiDialog
- /* package */ void onConnectButtonPressed() {
- mScreenState = SCREEN_STATE_CONNECTING;
-
- mWifiSettings.submit(mWifiConfig.getController());
-
- // updateConnectionState() isn't called soon by the main Wifi module after the user's
- // "connect" request, and the user still sees "not connected" message for a while, which
- // looks strange for users though legitimate from the view of the module.
- //
- // We instead manually show "connecting" message before the system gets actual
- // "connecting" message from Wifi module.
- showConnectingState();
-
- // Might be better to delay showing this button.
- mBackButton.setVisibility(View.VISIBLE);
- mBackButton.setText(R.string.wifi_setup_back);
-
- final ViewGroup parent = (ViewGroup)findViewById(R.id.wifi_config_ui);
- parent.setVisibility(View.GONE);
- mConnectingStatusLayout.setVisibility(View.VISIBLE);
- mConnectingStatusView.setText(R.string.wifi_setup_description_connecting);
-
- mSkipOrNextButton.setVisibility(View.VISIBLE);
- mSkipOrNextButton.setEnabled(false);
- mConnectButton.setVisibility(View.GONE);
- mAddNetworkButton.setVisibility(View.GONE);
- mRefreshButton.setVisibility(View.GONE);
- }
-
- private void onBackButtonPressed() {
-
- if (mScreenState == SCREEN_STATE_CONNECTING || mScreenState == SCREEN_STATE_CONNECTED) {
- if (DEBUG) Log.d(TAG, "Back button pressed after connect action.");
- mScreenState = SCREEN_STATE_DISCONNECTED;
-
- // When a user press "Back" button after pressing "Connect" button, we want to cancel
- // the "Connect" request and refresh the whole Wifi status.
- restoreFirstVisibilityState();
-
- mSkipOrNextButton.setEnabled(true);
- changeNextButtonState(false); // Skip
-
- // Wifi list becomes empty for a moment. We show "scanning" effect to a user so that
- // he/she won't be astonished there. This stops once the scan finishes.
- showScanningState();
-
- // Remembered networks may be re-used during SetupWizard, which confuse users.
- // We force the module to forget them to reduce UX complexity
- final List configs = mWifiManager.getConfiguredNetworks();
- for (WifiConfiguration config : configs) {
- if (DEBUG) {
- Log.d(TAG, String.format("forgeting Wi-Fi network \"%s\" (id: %d)",
- config.SSID, config.networkId));
- }
- mWifiManager.forget(config.networkId, new WifiManager.ActionListener() {
- public void onSuccess() {
- }
- public void onFailure(int reason) {
- //TODO: Add failure UI
- }
- });
- }
-
- mWifiSettingsFragmentLayout.setVisibility(View.GONE);
- refreshAccessPoints(true);
- } else { // During user's Wifi configuration.
- mScreenState = SCREEN_STATE_DISCONNECTED;
- mWifiSettings.resumeWifiScan();
-
- restoreFirstVisibilityState();
-
- mAddNetworkButton.setEnabled(true);
- mRefreshButton.setEnabled(true);
- mSkipOrNextButton.setEnabled(true);
- showDisconnectedProgressBar();
- mWifiSettingsFragmentLayout.setVisibility(View.VISIBLE);
- mBottomPadding.setVisibility(View.GONE);
- }
-
- setPaddingVisibility(View.VISIBLE);
- mConnectingStatusLayout.setVisibility(View.GONE);
- final ViewGroup parent = (ViewGroup)findViewById(R.id.wifi_config_ui);
- parent.removeAllViews();
- parent.setVisibility(View.GONE);
- mWifiConfig = null;
- }
-
- /**
- * @param connected true when the device is connected to a specific network.
- */
- /* package */ void changeNextButtonState(boolean connected) {
- if (connected) {
- mSkipOrNextButton.setText(R.string.wifi_setup_next);
- } else {
- mSkipOrNextButton.setText(R.string.wifi_setup_skip);
- }
- }
-
- /**
- * Called when the list of AccessPoints are modified and this Activity needs to refresh
- * the list.
- * @param preferenceScreen
- */
- /* package */ void onAccessPointsUpdated(
- PreferenceScreen preferenceScreen, Collection accessPoints) {
- // If we already show some of access points but the bar still shows "scanning" state, it
- // should be stopped.
- if (mProgressBar.isIndeterminate() && accessPoints.size() > 0) {
- showDisconnectedProgressBar();
- if (mScreenState == SCREEN_STATE_DISCONNECTED) {
- mWifiSettingsFragmentLayout.setVisibility(View.VISIBLE);
- mBottomPadding.setVisibility(View.GONE);
- }
- mAddNetworkButton.setEnabled(true);
- mRefreshButton.setEnabled(true);
- }
-
- for (AccessPoint accessPoint : accessPoints) {
- AccessPointPreference preference = (AccessPointPreference) accessPoint.getTag();
- if (preference == null) continue;
- preference.setLayoutResource(R.layout.custom_preference);
- preferenceScreen.addPreference(preference);
- }
- }
-
- private void refreshAccessPoints(boolean disconnectNetwork) {
- showScanningState();
-
- if (disconnectNetwork) {
- mWifiManager.disconnect();
- }
-
- mWifiSettings.refreshAccessPoints();
- }
-
- /**
- * Called when {@link WifiSettings} received
- * {@link WifiManager#SUPPLICANT_STATE_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() {
- mScreenState = SCREEN_STATE_EDITING;
-
- mSkipOrNextButton.setVisibility(View.GONE);
- mConnectButton.setVisibility(View.VISIBLE);
- mConnectButton.setEnabled(true);
-
- if (!TextUtils.isEmpty(mEditingTitle)) {
- mTitleView.setText(mEditingTitle);
- } else {
- Log.w(TAG, "Title during editing/adding a network was empty.");
- showEditingTitle();
- }
-
- final ViewGroup parent = (ViewGroup)findViewById(R.id.wifi_config_ui);
- parent.setVisibility(View.VISIBLE);
- mConnectingStatusLayout.setVisibility(View.GONE);
-
- showDisconnectedProgressBar();
- setPaddingVisibility(View.GONE);
- }
-
- // Used by WifiConfigUiForSetupWizardXL
- /* package */ void setPaddingVisibility(int visibility) {
- mTopPadding.setVisibility(visibility);
- mContentPadding.setVisibility(visibility);
- }
-
- private void showDisconnectedProgressBar() {
- // The device may report DISCONNECTED during connecting to a network, at which we don't
- // want to lose bottom padding of top divider implicitly added by ProgressBar.
- if (mScreenState == SCREEN_STATE_DISCONNECTED) {
- mProgressBar.setVisibility(View.GONE);
- mProgressBar.setIndeterminate(false);
- mTopDividerNoProgress.setVisibility(View.VISIBLE);
- } else {
- mProgressBar.setVisibility(View.VISIBLE);
- mProgressBar.setIndeterminate(false);
- mProgressBar.setProgress(0);
- mTopDividerNoProgress.setVisibility(View.GONE);
- }
- }
-
- /**
- * Shows top divider with ProgressBar, whose state is intermediate.
- */
- private void showScanningProgressBar() {
- showTopDividerWithProgressBar();
- mProgressBar.setIndeterminate(true);
- }
-
- /**
- * Shows top divider with ProgressBar, showing "connecting" state.
- */
- private void showConnectingProgressBar() {
- showTopDividerWithProgressBar();
- mProgressBar.setIndeterminate(false);
- mProgressBar.setProgress(1);
- }
-
- private void showConnectedProgressBar() {
- showTopDividerWithProgressBar();
- mProgressBar.setIndeterminate(false);
- mProgressBar.setProgress(2);
- }
-
- /**
- * Called when WifiManager is requested to save a network.
- */
- /* package */ void onSaveNetwork(WifiConfiguration config) {
- // We want to both save and connect a network. connectNetwork() does both.
- mWifiManager.connect(config, new WifiManager.ActionListener() {
- public void onSuccess() {
- }
- public void onFailure(int reason) {
- //TODO: Add failure UI
- }
- });
- }
-}