diff options
Diffstat (limited to 'src')
13 files changed, 255 insertions, 110 deletions
diff --git a/src/com/android/settings/ButtonBarHandler.java b/src/com/android/settings/ButtonBarHandler.java new file mode 100644 index 0000000..d61da13 --- /dev/null +++ b/src/com/android/settings/ButtonBarHandler.java @@ -0,0 +1,27 @@ +/* + * 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. + */ +package com.android.settings; + +import android.widget.Button; + +/** + * Interface letting {@link SettingsPreferenceFragment} access to bottom bar inside + * {@link android.preference.PreferenceActivity}. + */ +public interface ButtonBarHandler { + public boolean hasNextButton(); + public Button getNextButton(); +}
\ No newline at end of file diff --git a/src/com/android/settings/ChooseLockPassword.java b/src/com/android/settings/ChooseLockPassword.java index 1bebebb..018dfd2 100644 --- a/src/com/android/settings/ChooseLockPassword.java +++ b/src/com/android/settings/ChooseLockPassword.java @@ -197,7 +197,7 @@ public class ChooseLockPassword extends PreferenceActivity { int currentType = mPasswordEntry.getInputType(); mPasswordEntry.setInputType(mIsAlphaMode ? currentType - : (currentType | InputType.TYPE_CLASS_NUMBER)); + : (InputType.TYPE_CLASS_NUMBER | InputType.TYPE_NUMBER_VARIATION_PASSWORD)); Intent intent = getActivity().getIntent(); final boolean confirmCredentials = intent.getBooleanExtra("confirm_credentials", true); diff --git a/src/com/android/settings/Settings.java b/src/com/android/settings/Settings.java index 613b082..11d8c57 100644 --- a/src/com/android/settings/Settings.java +++ b/src/com/android/settings/Settings.java @@ -34,7 +34,7 @@ import java.util.List; /** * Top-level settings activity to handle single pane and double pane UI layout. */ -public class Settings extends PreferenceActivity { +public class Settings extends PreferenceActivity implements ButtonBarHandler { private static final String META_DATA_KEY_HEADER_ID = "com.android.settings.TOP_LEVEL_HEADER_ID"; diff --git a/src/com/android/settings/SettingsPreferenceFragment.java b/src/com/android/settings/SettingsPreferenceFragment.java index 0db4f8b..47e31ee 100644 --- a/src/com/android/settings/SettingsPreferenceFragment.java +++ b/src/com/android/settings/SettingsPreferenceFragment.java @@ -158,11 +158,11 @@ public class SettingsPreferenceFragment extends PreferenceFragment } protected boolean hasNextButton() { - return ((Settings)getActivity()).hasNextButton(); + return ((ButtonBarHandler)getActivity()).hasNextButton(); } protected Button getNextButton() { - return ((Settings)getActivity()).getNextButton(); + return ((ButtonBarHandler)getActivity()).getNextButton(); } public void finish() { diff --git a/src/com/android/settings/accounts/AccountSyncSettings.java b/src/com/android/settings/accounts/AccountSyncSettings.java index 298f1b6..aef8b8a 100644 --- a/src/com/android/settings/accounts/AccountSyncSettings.java +++ b/src/com/android/settings/accounts/AccountSyncSettings.java @@ -55,6 +55,7 @@ import android.widget.TextView; import java.io.IOException; import java.util.ArrayList; +import java.util.Collections; import java.util.Date; import java.util.HashMap; import java.util.List; @@ -212,7 +213,6 @@ public class AccountSyncSettings extends AccountPreferenceBase { String title = getString(R.string.sync_item_title, providerLabel); item.setTitle(title); item.setKey(authority); - getPreferenceScreen().addPreference(item); mCheckBoxes.add(item); } @@ -472,6 +472,11 @@ public class AccountSyncSettings extends AccountPreferenceBase { } } } + + Collections.sort(mCheckBoxes); + for (int i = 0, n = mCheckBoxes.size(); i < n; i++) { + getPreferenceScreen().addPreference(mCheckBoxes.get(i)); + } } /** diff --git a/src/com/android/settings/applications/ApplicationsState.java b/src/com/android/settings/applications/ApplicationsState.java index 6e9f2a2..6de8c7f 100644 --- a/src/com/android/settings/applications/ApplicationsState.java +++ b/src/com/android/settings/applications/ApplicationsState.java @@ -71,6 +71,7 @@ public class ApplicationsState { long cacheSize; long codeSize; long dataSize; + long externalSize; } public static class AppEntry extends SizeInfo { @@ -626,9 +627,16 @@ public class ApplicationsState { // -------------------------------------------------------------- - private long getTotalSize(PackageStats ps) { + private long getTotalInternalSize(PackageStats ps) { if (ps != null) { - return ps.codeSize+ps.dataSize; + return ps.codeSize + ps.dataSize; + } + return SIZE_INVALID; + } + + private long getTotalExternalSize(PackageStats ps) { + if (ps != null) { + return ps.externalDataSize + ps.externalMediaSize + ps.externalCacheSize; } return SIZE_INVALID; } @@ -660,15 +668,18 @@ public class ApplicationsState { synchronized (entry) { entry.sizeStale = false; entry.sizeLoadStart = 0; - long newSize = getTotalSize(stats); + long externalSize = getTotalExternalSize(stats); + long newSize = externalSize + getTotalInternalSize(stats); if (entry.size != newSize || entry.cacheSize != stats.cacheSize || entry.codeSize != stats.codeSize || - entry.dataSize != stats.dataSize) { + entry.dataSize != stats.dataSize || + entry.externalSize != externalSize) { entry.size = newSize; entry.cacheSize = stats.cacheSize; entry.codeSize = stats.codeSize; entry.dataSize = stats.dataSize; + entry.externalSize = externalSize; entry.sizeStr = getSizeStr(entry.size); if (DEBUG) Log.i(TAG, "Set size of " + entry.label + " " + entry + ": " + entry.sizeStr); diff --git a/src/com/android/settings/applications/InstalledAppDetails.java b/src/com/android/settings/applications/InstalledAppDetails.java index de897eb..06d97fc 100644 --- a/src/com/android/settings/applications/InstalledAppDetails.java +++ b/src/com/android/settings/applications/InstalledAppDetails.java @@ -93,6 +93,7 @@ public class InstalledAppDetails extends Fragment private TextView mTotalSize; private TextView mAppSize; private TextView mDataSize; + private TextView mExternalSize; private ClearUserDataObserver mClearDataObserver; // Views related to cache info private TextView mCacheSize; @@ -107,6 +108,7 @@ public class InstalledAppDetails extends Fragment private boolean mHaveSizes = false; private long mLastCodeSize = -1; private long mLastDataSize = -1; + private long mLastExternalSize = -1; private long mLastCacheSize = -1; private long mLastTotalSize = -1; @@ -317,6 +319,7 @@ public class InstalledAppDetails extends Fragment mTotalSize = (TextView)view.findViewById(R.id.total_size_text); mAppSize = (TextView)view.findViewById(R.id.application_size_text); mDataSize = (TextView)view.findViewById(R.id.data_size_text); + mExternalSize = (TextView)view.findViewById(R.id.external_size_text); // Get Control button panel View btnPanel = view.findViewById(R.id.control_buttons_panel); @@ -504,6 +507,10 @@ public class InstalledAppDetails extends Fragment mLastDataSize = mAppEntry.dataSize; mDataSize.setText(getSizeStr(mAppEntry.dataSize)); } + if (mLastExternalSize != mAppEntry.externalSize) { + mLastExternalSize = mAppEntry.externalSize; + mExternalSize.setText(getSizeStr(mAppEntry.externalSize)); + } if (mLastCacheSize != mAppEntry.cacheSize) { mLastCacheSize = mAppEntry.cacheSize; mCacheSize.setText(getSizeStr(mAppEntry.cacheSize)); diff --git a/src/com/android/settings/vpn/VpnSettings.java b/src/com/android/settings/vpn/VpnSettings.java index 0587619..960d37e 100644 --- a/src/com/android/settings/vpn/VpnSettings.java +++ b/src/com/android/settings/vpn/VpnSettings.java @@ -190,30 +190,38 @@ public class VpnSettings extends SettingsPreferenceFragment // for long-press gesture on a profile preference registerForContextMenu(getListView()); - // listen to vpn connectivity event - mVpnManager.registerConnectivityReceiver(mConnectivityReceiver); retrieveVpnListFromStorage(); - checkVpnConnectionStatusInBackground(); restoreInstanceState(savedInstanceState); } @Override + public void onPause() { + // ignore vpn connectivity event + mVpnManager.unregisterConnectivityReceiver(mConnectivityReceiver); + super.onPause(); + } + + @Override public void onResume() { super.onResume(); if (DEBUG) Log.d(TAG, "onResume"); + + // listen to vpn connectivity event + mVpnManager.registerConnectivityReceiver(mConnectivityReceiver); + if ((mUnlockAction != null) && isKeyStoreUnlocked()) { Runnable action = mUnlockAction; mUnlockAction = null; getActivity().runOnUiThread(action); } + checkVpnConnectionStatusInBackground(); } @Override public void onDestroyView() { unregisterForContextMenu(getListView()); - mVpnManager.unregisterConnectivityReceiver(mConnectivityReceiver); if ((mShowingDialog != null) && mShowingDialog.isShowing()) { mShowingDialog.dismiss(); } diff --git a/src/com/android/settings/wifi/WifiConfigUiBase.java b/src/com/android/settings/wifi/WifiConfigUiBase.java index d930b58..11dcc00 100644 --- a/src/com/android/settings/wifi/WifiConfigUiBase.java +++ b/src/com/android/settings/wifi/WifiConfigUiBase.java @@ -22,7 +22,7 @@ import android.widget.Button; /** * Foundation interface glues between Activities and UIs like - * {@link WifiDialog} or {@link WifiConfigPreference}. + * {@link WifiDialog} or {@link WifiConfigUiForSetupWizardXL}. */ public interface WifiConfigUiBase { public Context getContext(); diff --git a/src/com/android/settings/wifi/WifiConfigUiForSetupWizardXL.java b/src/com/android/settings/wifi/WifiConfigUiForSetupWizardXL.java index bbd8f80..bffcc61 100644 --- a/src/com/android/settings/wifi/WifiConfigUiForSetupWizardXL.java +++ b/src/com/android/settings/wifi/WifiConfigUiForSetupWizardXL.java @@ -18,7 +18,6 @@ package com.android.settings.wifi; import com.android.settings.R; -import android.app.Activity; import android.content.Context; import android.os.Handler; import android.util.Log; @@ -38,16 +37,17 @@ public class WifiConfigUiForSetupWizardXL implements WifiConfigUiBase, OnFocusCh private static final String TAG = "SetupWizard"; private Button mConnectButton; - private Button mForgetButton; private Button mCancelButton; - private final Activity mActivity; + 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; /** @@ -58,10 +58,10 @@ public class WifiConfigUiForSetupWizardXL implements WifiConfigUiBase, OnFocusCh * @param edit */ public WifiConfigUiForSetupWizardXL( - Activity activity, ViewGroup parent, AccessPoint accessPoint, boolean edit) { + WifiSettingsForSetupWizardXL activity, ViewGroup parent, + AccessPoint accessPoint, boolean edit) { mActivity = activity; mConnectButton = (Button)activity.findViewById(R.id.wifi_setup_connect); - mForgetButton = (Button)activity.findViewById(R.id.wifi_setup_forget); mCancelButton = (Button)activity.findViewById(R.id.wifi_setup_cancel); mAccessPoint = accessPoint; mEdit = edit; @@ -70,12 +70,14 @@ public class WifiConfigUiForSetupWizardXL implements WifiConfigUiBase, OnFocusCh mView = mInflater.inflate(R.layout.wifi_config_ui_for_setup_wizard, parent, true); mController = new WifiConfigController(this, mView, mAccessPoint, edit); - // Assumes R.id.password is inside security_fields. - // TODO: confirm it is ok to assume R.id.password is the only EditText to be focused, and - // R.id.security_fields is the only parent for possible EditTexts. Possibly we need to - // check parentand detect visibility manually. + 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).getVisibility() == View.VISIBLE) { + // Add Network flow. + requestFocusAndShowKeyboard(R.id.ssid); } } @@ -90,13 +92,17 @@ public class WifiConfigUiForSetupWizardXL implements WifiConfigUiBase, OnFocusCh } 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); + if (viewToBeFocused.isFocused()) { + mInputMethodManager.showSoftInput(viewToBeFocused, 0); + } 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); + } } } } @@ -131,7 +137,7 @@ public class WifiConfigUiForSetupWizardXL implements WifiConfigUiBase, OnFocusCh @Override public Button getForgetButton() { - return mForgetButton; + return null; } @Override @@ -143,16 +149,11 @@ public class WifiConfigUiForSetupWizardXL implements WifiConfigUiBase, OnFocusCh public void setSubmitButton(CharSequence text) { mConnectButton.setVisibility(View.VISIBLE); mConnectButton.setText(text); - - // test - mForgetButton.setVisibility(View.GONE); } @Override public void setForgetButton(CharSequence text) { // In XL setup screen, we won't show Forget button for simplifying the UI. - // mForgetButton.setVisibility(View.VISIBLE); - // mForgetButton.setText(text); } @Override @@ -177,12 +178,9 @@ public class WifiConfigUiForSetupWizardXL implements WifiConfigUiBase, OnFocusCh Log.d(TAG, "Ignoring setTitle"); } - private static class FocusRunnable implements Runnable { - final InputMethodManager mInputMethodManager; + private class FocusRunnable implements Runnable { final View mViewToBeFocused; - public FocusRunnable(Context context, View viewToBeFocused) { - mInputMethodManager = (InputMethodManager) - context.getSystemService(Context.INPUT_METHOD_SERVICE); + public FocusRunnable(View viewToBeFocused) { mViewToBeFocused = viewToBeFocused; } @@ -191,7 +189,9 @@ public class WifiConfigUiForSetupWizardXL implements WifiConfigUiBase, OnFocusCh // mInputMethodManager.focusIn(mViewToBeFocused); final boolean showSoftInputResult = mInputMethodManager.showSoftInput(mViewToBeFocused, 0); - if (!showSoftInputResult) { + if (showSoftInputResult) { + mActivity.setPaddingVisibility(View.GONE); + } else { Log.w(TAG, "Failed to show software keyboard "); } } @@ -201,7 +201,7 @@ public class WifiConfigUiForSetupWizardXL implements WifiConfigUiBase, OnFocusCh public void onFocusChange(View view, boolean hasFocus) { view.setOnFocusChangeListener(null); if (hasFocus) { - mHandler.post(new FocusRunnable(mActivity, view)); + mHandler.post(new FocusRunnable(view)); } } }
\ No newline at end of file diff --git a/src/com/android/settings/wifi/WifiPickerActivity.java b/src/com/android/settings/wifi/WifiPickerActivity.java new file mode 100644 index 0000000..7b972fc --- /dev/null +++ b/src/com/android/settings/wifi/WifiPickerActivity.java @@ -0,0 +1,44 @@ +/* + * 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. + */ +package com.android.settings.wifi; + +import com.android.settings.ButtonBarHandler; + +import android.content.Intent; +import android.preference.PreferenceActivity; +import android.widget.Button; + +public class WifiPickerActivity extends PreferenceActivity implements ButtonBarHandler { + @Override + public Intent getIntent() { + Intent modIntent = new Intent(super.getIntent()); + modIntent.putExtra(EXTRA_SHOW_FRAGMENT, WifiSettings.class.getName()); + modIntent.putExtra(EXTRA_NO_HEADERS, true); + return modIntent; + } + + @Override + public boolean hasNextButton() { + // PreferenceActivity#hasNextButton() is protected, so we need to expose it here. + return super.hasNextButton(); + } + + @Override + public Button getNextButton() { + // PreferenceActivity#getNextButton() is protected, so we need to expose it here. + return super.getNextButton(); + } +}
\ No newline at end of file diff --git a/src/com/android/settings/wifi/WifiSettings.java b/src/com/android/settings/wifi/WifiSettings.java index ffe48a9..ccc40fb 100644 --- a/src/com/android/settings/wifi/WifiSettings.java +++ b/src/com/android/settings/wifi/WifiSettings.java @@ -567,7 +567,7 @@ public class WifiSettings extends SettingsPreferenceFragment public void onClick(DialogInterface dialogInterface, int button) { if (mInXlSetupWizard) { if (button == WifiDialog.BUTTON_FORGET && mSelectedAccessPoint != null) { - ((WifiSettingsForSetupWizardXL)getActivity()).onForgetButtonPressed(); + forget(); } else if (button == WifiDialog.BUTTON_SUBMIT) { ((WifiSettingsForSetupWizardXL)getActivity()).onConnectButtonPressed(); } diff --git a/src/com/android/settings/wifi/WifiSettingsForSetupWizardXL.java b/src/com/android/settings/wifi/WifiSettingsForSetupWizardXL.java index 7fccce0..cb33d3b 100644 --- a/src/com/android/settings/wifi/WifiSettingsForSetupWizardXL.java +++ b/src/com/android/settings/wifi/WifiSettingsForSetupWizardXL.java @@ -29,10 +29,10 @@ import android.os.Handler; import android.preference.PreferenceCategory; import android.text.TextUtils; import android.util.Log; -import android.view.View; +import android.view.ContextMenu; import android.view.ContextMenu.ContextMenuInfo; +import android.view.View; import android.view.View.OnClickListener; -import android.view.ContextMenu; import android.view.ViewGroup; import android.view.Window; import android.view.WindowManager; @@ -69,16 +69,31 @@ public class WifiSettingsForSetupWizardXL extends Activity implements OnClickLis private WifiManager mWifiManager; - private TextView mProgressText; + /** + * Used for resizing a padding above title. Hiden when software keyboard is shown. + */ + private View mTopPadding; + + /** + * Used for resizing a padding inside Config UI. Hiden when software keyboard is shown. + */ + private View mWifiConfigPadding; + + 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 WifiSettings mWifiSettings; - private TextView mStatusText; private Button mAddNetworkButton; private Button mRefreshButton; private Button mSkipOrNextButton; private Button mConnectButton; - private Button mForgetButton; private Button mBackButton; // true when a user already pressed "Connect" button and waiting for connection. @@ -130,14 +145,11 @@ public class WifiSettingsForSetupWizardXL extends Activity implements OnClickLis } public void setup() { - mProgressText = (TextView)findViewById(R.id.scanning_progress_text); + mTitleView = (TextView)findViewById(R.id.wifi_setup_title); mProgressBar = (ProgressBar)findViewById(R.id.scanning_progress_bar); mProgressBar.setMax(2); - mStatusText = (TextView)findViewById(R.id.wifi_setup_status); - mProgressText.setText(Summary.get(this, DetailedState.SCANNING)); mProgressBar.setIndeterminate(true); - mStatusText.setText(R.string.wifi_setup_status_scanning); mAddNetworkButton = (Button)findViewById(R.id.wifi_setup_add_network); mAddNetworkButton.setOnClickListener(this); @@ -147,11 +159,12 @@ public class WifiSettingsForSetupWizardXL extends Activity implements OnClickLis mSkipOrNextButton.setOnClickListener(this); mConnectButton = (Button)findViewById(R.id.wifi_setup_connect); mConnectButton.setOnClickListener(this); - mForgetButton = (Button)findViewById(R.id.wifi_setup_forget); - mForgetButton.setOnClickListener(this); mBackButton = (Button)findViewById(R.id.wifi_setup_cancel); mBackButton.setOnClickListener(this); + mTopPadding = findViewById(R.id.top_padding); + mWifiConfigPadding = findViewById(R.id.wifi_config_padding); + // At first, Wifi module doesn't return SCANNING state (it's too early), so we manually // show it. showScanningStatus(); @@ -159,12 +172,13 @@ public class WifiSettingsForSetupWizardXL extends Activity implements OnClickLis } private void restoreFirstButtonVisibilityState() { + showDefaultTitle(); mAddNetworkButton.setVisibility(View.VISIBLE); mRefreshButton.setVisibility(View.VISIBLE); mSkipOrNextButton.setVisibility(View.VISIBLE); mConnectButton.setVisibility(View.GONE); - mForgetButton.setVisibility(View.GONE); mBackButton.setVisibility(View.GONE); + setPaddingVisibility(View.VISIBLE, View.GONE); } @Override @@ -188,9 +202,6 @@ public class WifiSettingsForSetupWizardXL extends Activity implements OnClickLis } else if (view == mConnectButton) { if (DEBUG) Log.d(TAG, "Connect button pressed"); onConnectButtonPressed(); - } else if (view == mForgetButton) { - if (DEBUG) Log.d(TAG, "Forget button pressed"); - onForgetButtonPressed(); } else if (view == mBackButton) { if (DEBUG) Log.d(TAG, "Back button pressed"); onBackButtonPressed(); @@ -222,7 +233,6 @@ public class WifiSettingsForSetupWizardXL extends Activity implements OnClickLis // no visible network on the list. if (mWifiSettings.getAccessPointsCount() == 0) { mProgressBar.setIndeterminate(true); - mProgressText.setText(Summary.get(this, DetailedState.SCANNING)); } else { // Users already connected to a network, or see available networks. mProgressBar.setIndeterminate(false); @@ -234,15 +244,16 @@ public class WifiSettingsForSetupWizardXL extends Activity implements OnClickLis break; } case CONNECTED: { + hideSoftwareKeyboard(); + // If the device is already connected to a wifi without users' "Connect" request, // this can be false here. We want to treat it as "after connect action". mAfterConnectAction = true; mProgressBar.setIndeterminate(false); mProgressBar.setProgress(2); - mProgressText.setText(Summary.get(this, state)); - mStatusText.setText(R.string.wifi_setup_status_proceed_to_next); + showConnectedTitle(); mConnectButton.setVisibility(View.GONE); mAddNetworkButton.setVisibility(View.GONE); mRefreshButton.setVisibility(View.GONE); @@ -250,8 +261,6 @@ public class WifiSettingsForSetupWizardXL extends Activity implements OnClickLis mSkipOrNextButton.setVisibility(View.VISIBLE); mSkipOrNextButton.setEnabled(true); mHandler.removeCallbacks(mSkipButtonEnabler); - - mProgressText.setText(Summary.get(this, state)); break; } default: // DISCONNECTED, FAILED @@ -264,31 +273,52 @@ public class WifiSettingsForSetupWizardXL extends Activity implements OnClickLis mProgressBar.setIndeterminate(false); mProgressBar.setProgress(0); - mProgressText.setText(stateString); - mAddNetworkButton.setEnabled(true); mRefreshButton.setEnabled(true); } private void showConnectingStatus() { + // We save this title and show it when authentication failed. + mEditingTitle = mTitleView.getText(); + showConnectingTitle(); mProgressBar.setIndeterminate(false); mProgressBar.setProgress(1); - mStatusText.setText(R.string.wifi_setup_status_connecting); - mProgressText.setText(Summary.get(this, DetailedState.CONNECTING)); + setPaddingVisibility(View.VISIBLE); + } + + private void showDefaultTitle() { + mTitleView.setText(getString(R.string.wifi_setup_title)); + } + + private void showEditingTitle() { + if (TextUtils.isEmpty(mNetworkName) && mWifiConfig != null) { + mNetworkName = mWifiConfig.getController().getConfig().SSID; + } + mTitleView.setText(getString(R.string.wifi_setup_title_editing_network, mNetworkName)); + } + + private void showConnectingTitle() { + if (TextUtils.isEmpty(mNetworkName) && mWifiConfig != null) { + mNetworkName = mWifiConfig.getController().getConfig().SSID; + } + mTitleView.setText(getString(R.string.wifi_setup_title_connecting_network, mNetworkName)); + } + + private void showConnectedTitle() { + if (TextUtils.isEmpty(mNetworkName) && mWifiConfig != null) { + mNetworkName = mWifiConfig.getController().getConfig().SSID; + } + mTitleView.setText(getString(R.string.wifi_setup_title_connected_network, mNetworkName)); } private void showScanningStatus() { 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); } private void onAddNetworkButtonPressed() { - // onConfigUiShown() will be called. mWifiSettings.onAddNetworkPressed(); - } /** @@ -318,34 +348,41 @@ public class WifiSettingsForSetupWizardXL extends Activity implements OnClickLis mWifiConfig = new WifiConfigUiForSetupWizardXL(this, parent, selectedAccessPoint, edit); final View view = mWifiConfig.getView(); if (selectedAccessPoint != null) { - view.findViewById(R.id.wifi_general_info).setVisibility(View.VISIBLE); - ((TextView)view.findViewById(R.id.title)).setText(selectedAccessPoint.getTitle()); - ((TextView)view.findViewById(R.id.summary)).setText(selectedAccessPoint.getSummary()); + mNetworkName = selectedAccessPoint.getTitle().toString(); + mTitleView.setText(getString(R.string.wifi_setup_title_editing_network, mNetworkName)); } else { + mNetworkName = ""; + mTitleView.setText(R.string.wifi_setup_title_add_network); view.findViewById(R.id.wifi_general_info).setVisibility(View.GONE); } if (selectedAccessPoint != null && selectedAccessPoint.security == AccessPoint.SECURITY_NONE) { - mStatusText.setText(R.string.wifi_setup_status_unsecured_network); + // onConnectButtonPressed() will change visibility status. + mConnectButton.performClick(); } else if (selectedAccessPoint != null && selectedAccessPoint.security == AccessPoint.SECURITY_EAP) { - mStatusText.setText(R.string.wifi_setup_status_eap_not_supported); mConnectButton.setVisibility(View.GONE); + + showEditingTitle(); + mSkipOrNextButton.setVisibility(View.GONE); + mAddNetworkButton.setVisibility(View.GONE); + mRefreshButton.setVisibility(View.GONE); + mBackButton.setVisibility(View.VISIBLE); } else { - 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); + // 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); - mBackButton.setVisibility(View.VISIBLE); + showEditingTitle(); + 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 @@ -388,21 +425,6 @@ public class WifiSettingsForSetupWizardXL extends Activity implements OnClickLis mRefreshButton.setVisibility(View.GONE); } - // May be called when user press "forget" button in WifiDialog - /* package */ void onForgetButtonPressed() { - mWifiSettings.forget(); - - refreshAccessPoints(false); - restoreFirstButtonVisibilityState(); - mAddNetworkButton.setEnabled(true); - mRefreshButton.setEnabled(true); - mSkipOrNextButton.setEnabled(true); - - mProgressBar.setIndeterminate(false); - mProgressBar.setProgress(0); - mProgressText.setText(getString(R.string.wifi_setup_not_connected)); - } - private void onBackButtonPressed() { if (mAfterConnectAction) { if (DEBUG) Log.d(TAG, "Back button pressed after connect action."); @@ -421,7 +443,6 @@ public class WifiSettingsForSetupWizardXL extends Activity implements OnClickLis } else { // During user's Wifi configuration. mWifiSettings.resumeWifiScan(); - mStatusText.setText(R.string.wifi_setup_status_select_network); restoreFirstButtonVisibilityState(); mAddNetworkButton.setEnabled(true); @@ -470,7 +491,8 @@ public class WifiSettingsForSetupWizardXL extends Activity implements OnClickLis } /** - * Called when {@link WifiSettings} received {@link WifiManager#SUPPLICANT_CHANGED_ACTION}. + * 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); @@ -485,11 +507,17 @@ public class WifiSettingsForSetupWizardXL extends Activity implements OnClickLis */ 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); + if (!TextUtils.isEmpty(mEditingTitle)) { + mTitleView.setText(mEditingTitle); + } else { + Log.w(TAG, "Title during editing/adding a network was empty."); + showEditingTitle(); + } + // Restore View status which was tweaked on connection. final View wpsFieldView = findViewById(R.id.wps_fields); if (wpsFieldView != null) { @@ -502,21 +530,36 @@ public class WifiSettingsForSetupWizardXL extends Activity implements OnClickLis 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); + setPaddingVisibility(View.GONE); } + mWifiConfig.requestFocusAndShowKeyboard(R.id.password); } } } final View typeView = findViewById(R.id.type); if (typeView != null) { typeView.setVisibility(mPreviousTypeVisibility); + if (mPreviousTypeVisibility == View.VISIBLE && mWifiConfig != null) { + final View ssidView = findViewById(R.id.ssid); + if (ssidView != null) { + if (ssidView.isFocused()) { + setPaddingVisibility(View.GONE); + } + mWifiConfig.requestFocusAndShowKeyboard(R.id.ssid); + } + } } } + public void setPaddingVisibility(int visibility) { + setPaddingVisibility(visibility, visibility); + } + + private void setPaddingVisibility(int topPaddingVisibility, int configVisibility) { + mTopPadding.setVisibility(topPaddingVisibility); + mWifiConfigPadding.setVisibility(configVisibility); + } + /** * Called when WifiManager is requested to save a network. This method sholud include * WifiManager#saveNetwork() call. |