[WifiSettings] Add Wi-Fi dialog activity
Add a Wi-Fi dialog activity that can be started by setup wizard to connect to a Wi-Fi access point. Also refactored mEdit and mModify in WifiConfigController into an int-enum mMode, with modes view, connect and modify. This is how the new modes maps to the old flags: MODE_VIEW -- mEdit = false, mModify = * MODE_CONNECT -- mEdit = true, mModify = false MODE_MODIFY -- mEdit = true, mModify = true Bug: 23426311 Change-Id: I8e2221fd3c42577068e07686dab245dd5888e0ae
This commit is contained in:
@@ -2500,6 +2500,16 @@
|
|||||||
android:excludeFromRecents="true">
|
android:excludeFromRecents="true">
|
||||||
</activity>
|
</activity>
|
||||||
|
|
||||||
|
<activity android:name=".wifi.WifiDialogActivity"
|
||||||
|
android:theme="@style/Transparent"
|
||||||
|
android:excludeFromRecents="true"
|
||||||
|
android:exported="true">
|
||||||
|
<intent-filter>
|
||||||
|
<action android:name="com.android.settings.WIFI_DIALOG" />
|
||||||
|
<category android:name="android.intent.category.DEFAULT" />
|
||||||
|
</intent-filter>
|
||||||
|
</activity>
|
||||||
|
|
||||||
<activity android:name=".sim.SimDialogActivity"
|
<activity android:name=".sim.SimDialogActivity"
|
||||||
android:theme="@android:style/Theme.Material.Light.Dialog.NoActionBar"
|
android:theme="@android:style/Theme.Material.Light.Dialog.NoActionBar"
|
||||||
android:label="@string/sim_settings_title"
|
android:label="@string/sim_settings_title"
|
||||||
|
@@ -239,6 +239,7 @@
|
|||||||
</style>
|
</style>
|
||||||
|
|
||||||
<style name="Transparent">
|
<style name="Transparent">
|
||||||
|
<item name="android:alertDialogTheme">@style/Theme.AlertDialog</item>
|
||||||
<item name="android:windowBackground">@android:color/transparent</item>
|
<item name="android:windowBackground">@android:color/transparent</item>
|
||||||
<item name="android:windowNoTitle">true</item>
|
<item name="android:windowNoTitle">true</item>
|
||||||
<item name="android:windowIsFloating">true</item>
|
<item name="android:windowIsFloating">true</item>
|
||||||
|
@@ -146,7 +146,7 @@ public class SavedAccessPointsWifiSettings extends SettingsPreferenceFragment
|
|||||||
final boolean hideForgetButton = WifiSettings.isEditabilityLockedDown(getActivity(),
|
final boolean hideForgetButton = WifiSettings.isEditabilityLockedDown(getActivity(),
|
||||||
mDlgAccessPoint.getConfig());
|
mDlgAccessPoint.getConfig());
|
||||||
mDialog = new WifiDialog(getActivity(), this, mDlgAccessPoint,
|
mDialog = new WifiDialog(getActivity(), this, mDlgAccessPoint,
|
||||||
false /* not editting */, false, true /* hide the submit button */,
|
WifiConfigUiBase.MODE_VIEW, true /* hide the submit button */,
|
||||||
hideForgetButton);
|
hideForgetButton);
|
||||||
return mDialog;
|
return mDialog;
|
||||||
|
|
||||||
|
@@ -144,23 +144,20 @@ public class WifiConfigController implements TextWatcher,
|
|||||||
private StaticIpConfiguration mStaticIpConfiguration = null;
|
private StaticIpConfiguration mStaticIpConfiguration = null;
|
||||||
|
|
||||||
private String[] mLevels;
|
private String[] mLevels;
|
||||||
private boolean mEdit;
|
private int mMode;
|
||||||
private boolean mModify;
|
|
||||||
private TextView mSsidView;
|
private TextView mSsidView;
|
||||||
|
|
||||||
private Context mContext;
|
private Context mContext;
|
||||||
|
|
||||||
public WifiConfigController(
|
public WifiConfigController(WifiConfigUiBase parent, View view, AccessPoint accessPoint,
|
||||||
WifiConfigUiBase parent, View view, AccessPoint accessPoint, boolean edit,
|
int mode) {
|
||||||
boolean modify) {
|
|
||||||
mConfigUi = parent;
|
mConfigUi = parent;
|
||||||
|
|
||||||
mView = view;
|
mView = view;
|
||||||
mAccessPoint = accessPoint;
|
mAccessPoint = accessPoint;
|
||||||
mAccessPointSecurity = (accessPoint == null) ? AccessPoint.SECURITY_NONE :
|
mAccessPointSecurity = (accessPoint == null) ? AccessPoint.SECURITY_NONE :
|
||||||
accessPoint.getSecurity();
|
accessPoint.getSecurity();
|
||||||
mEdit = edit;
|
mMode = mode;
|
||||||
mModify = modify;
|
|
||||||
|
|
||||||
mTextViewChangedHandler = new Handler();
|
mTextViewChangedHandler = new Handler();
|
||||||
mContext = mConfigUi.getContext();
|
mContext = mConfigUi.getContext();
|
||||||
@@ -238,7 +235,7 @@ public class WifiConfigController implements TextWatcher,
|
|||||||
}
|
}
|
||||||
|
|
||||||
if ((!mAccessPoint.isSaved() && !mAccessPoint.isActive())
|
if ((!mAccessPoint.isSaved() && !mAccessPoint.isActive())
|
||||||
|| mEdit) {
|
|| mMode != WifiConfigUiBase.MODE_VIEW) {
|
||||||
showSecurityFields();
|
showSecurityFields();
|
||||||
showIpConfigFields();
|
showIpConfigFields();
|
||||||
showProxyFields();
|
showProxyFields();
|
||||||
@@ -251,8 +248,10 @@ public class WifiConfigController implements TextWatcher,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mModify) {
|
if (mMode == WifiConfigUiBase.MODE_MODIFY) {
|
||||||
mConfigUi.setSubmitButton(res.getString(R.string.wifi_save));
|
mConfigUi.setSubmitButton(res.getString(R.string.wifi_save));
|
||||||
|
} else if (mMode == WifiConfigUiBase.MODE_CONNECT) {
|
||||||
|
mConfigUi.setSubmitButton(res.getString(R.string.wifi_connect));
|
||||||
} else {
|
} else {
|
||||||
final DetailedState state = mAccessPoint.getDetailedState();
|
final DetailedState state = mAccessPoint.getDetailedState();
|
||||||
final String signalLevel = getSignalString();
|
final String signalLevel = getSignalString();
|
||||||
@@ -376,7 +375,7 @@ public class WifiConfigController implements TextWatcher,
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* package */ WifiConfiguration getConfig() {
|
/* package */ WifiConfiguration getConfig() {
|
||||||
if (!mEdit) {
|
if (mMode == WifiConfigUiBase.MODE_VIEW) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -966,12 +965,8 @@ public class WifiConfigController implements TextWatcher,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isEdit() {
|
public int getMode() {
|
||||||
return mEdit;
|
return mMode;
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isModify() {
|
|
||||||
return mModify;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -1066,4 +1061,8 @@ public class WifiConfigController implements TextWatcher,
|
|||||||
InputType.TYPE_TEXT_VARIATION_VISIBLE_PASSWORD :
|
InputType.TYPE_TEXT_VARIATION_VISIBLE_PASSWORD :
|
||||||
InputType.TYPE_TEXT_VARIATION_PASSWORD));
|
InputType.TYPE_TEXT_VARIATION_PASSWORD));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public AccessPoint getAccessPoint() {
|
||||||
|
return mAccessPoint;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@@ -24,10 +24,26 @@ import android.widget.Button;
|
|||||||
* Foundation interface glues between Activities and UIs like {@link WifiDialog}.
|
* Foundation interface glues between Activities and UIs like {@link WifiDialog}.
|
||||||
*/
|
*/
|
||||||
public interface WifiConfigUiBase {
|
public interface WifiConfigUiBase {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Viewing mode for a Wi-Fi access point. Data is displayed in non-editable mode.
|
||||||
|
*/
|
||||||
|
int MODE_VIEW = 0;
|
||||||
|
/**
|
||||||
|
* Connect mode. Data is displayed in editable mode, and a connect button will be shown.
|
||||||
|
*/
|
||||||
|
int MODE_CONNECT = 1;
|
||||||
|
/**
|
||||||
|
* Modify mode. All data is displayed in editable fields, and a "save" button is shown instead
|
||||||
|
* of "connect". Clients are expected to only save but not connect to the access point in this
|
||||||
|
* mode.
|
||||||
|
*/
|
||||||
|
int MODE_MODIFY = 2;
|
||||||
|
|
||||||
public Context getContext();
|
public Context getContext();
|
||||||
public WifiConfigController getController();
|
public WifiConfigController getController();
|
||||||
public LayoutInflater getLayoutInflater();
|
public LayoutInflater getLayoutInflater();
|
||||||
public boolean isEdit();
|
public int getMode();
|
||||||
|
|
||||||
public void dispatchSubmit();
|
public void dispatchSubmit();
|
||||||
|
|
||||||
|
@@ -24,6 +24,7 @@ import android.content.Context;
|
|||||||
import android.content.DialogInterface;
|
import android.content.DialogInterface;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
|
import android.view.WindowManager;
|
||||||
import android.widget.Button;
|
import android.widget.Button;
|
||||||
|
|
||||||
class WifiDialog extends AlertDialog implements WifiConfigUiBase, DialogInterface.OnClickListener {
|
class WifiDialog extends AlertDialog implements WifiConfigUiBase, DialogInterface.OnClickListener {
|
||||||
@@ -36,8 +37,7 @@ class WifiDialog extends AlertDialog implements WifiConfigUiBase, DialogInterfac
|
|||||||
private static final int BUTTON_SUBMIT = DialogInterface.BUTTON_POSITIVE;
|
private static final int BUTTON_SUBMIT = DialogInterface.BUTTON_POSITIVE;
|
||||||
private static final int BUTTON_FORGET = DialogInterface.BUTTON_NEUTRAL;
|
private static final int BUTTON_FORGET = DialogInterface.BUTTON_NEUTRAL;
|
||||||
|
|
||||||
private final boolean mEdit;
|
private final int mMode;
|
||||||
private final boolean mModify;
|
|
||||||
private final WifiDialogListener mListener;
|
private final WifiDialogListener mListener;
|
||||||
private final AccessPoint mAccessPoint;
|
private final AccessPoint mAccessPoint;
|
||||||
|
|
||||||
@@ -46,19 +46,17 @@ class WifiDialog extends AlertDialog implements WifiConfigUiBase, DialogInterfac
|
|||||||
private boolean mHideSubmitButton;
|
private boolean mHideSubmitButton;
|
||||||
private boolean mHideForgetButton;
|
private boolean mHideForgetButton;
|
||||||
|
|
||||||
public WifiDialog(Context context, WifiDialogListener listener,
|
public WifiDialog(Context context, WifiDialogListener listener, AccessPoint accessPoint,
|
||||||
AccessPoint accessPoint, boolean edit, boolean modify,
|
int mode, boolean hideSubmitButton, boolean hideForgetButton) {
|
||||||
boolean hideSubmitButton, boolean hideForgetButton) {
|
this(context, listener, accessPoint, mode);
|
||||||
this(context, listener, accessPoint, edit, modify);
|
|
||||||
mHideSubmitButton = hideSubmitButton;
|
mHideSubmitButton = hideSubmitButton;
|
||||||
mHideForgetButton = hideForgetButton;
|
mHideForgetButton = hideForgetButton;
|
||||||
}
|
}
|
||||||
|
|
||||||
public WifiDialog(Context context, WifiDialogListener listener,
|
public WifiDialog(Context context, WifiDialogListener listener, AccessPoint accessPoint,
|
||||||
AccessPoint accessPoint, boolean edit, boolean modify) {
|
int mode) {
|
||||||
super(context);
|
super(context);
|
||||||
mEdit = edit;
|
mMode = mode;
|
||||||
mModify = modify;
|
|
||||||
mListener = listener;
|
mListener = listener;
|
||||||
mAccessPoint = accessPoint;
|
mAccessPoint = accessPoint;
|
||||||
mHideSubmitButton = false;
|
mHideSubmitButton = false;
|
||||||
@@ -75,7 +73,7 @@ class WifiDialog extends AlertDialog implements WifiConfigUiBase, DialogInterfac
|
|||||||
mView = getLayoutInflater().inflate(R.layout.wifi_dialog, null);
|
mView = getLayoutInflater().inflate(R.layout.wifi_dialog, null);
|
||||||
setView(mView);
|
setView(mView);
|
||||||
setInverseBackgroundForced(true);
|
setInverseBackgroundForced(true);
|
||||||
mController = new WifiConfigController(this, mView, mAccessPoint, mEdit, mModify);
|
mController = new WifiConfigController(this, mView, mAccessPoint, mMode);
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
|
|
||||||
if (mHideSubmitButton) {
|
if (mHideSubmitButton) {
|
||||||
@@ -119,8 +117,8 @@ class WifiDialog extends AlertDialog implements WifiConfigUiBase, DialogInterfac
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isEdit() {
|
public int getMode() {
|
||||||
return mEdit;
|
return mMode;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
118
src/com/android/settings/wifi/WifiDialogActivity.java
Normal file
118
src/com/android/settings/wifi/WifiDialogActivity.java
Normal file
@@ -0,0 +1,118 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2015 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.DialogInterface;
|
||||||
|
import android.content.Intent;
|
||||||
|
import android.net.NetworkInfo;
|
||||||
|
import android.net.wifi.WifiConfiguration;
|
||||||
|
import android.net.wifi.WifiManager;
|
||||||
|
import android.os.Bundle;
|
||||||
|
import android.util.Log;
|
||||||
|
|
||||||
|
import com.android.settingslib.wifi.AccessPoint;
|
||||||
|
|
||||||
|
public class WifiDialogActivity extends Activity implements WifiDialog.WifiDialogListener,
|
||||||
|
DialogInterface.OnDismissListener {
|
||||||
|
|
||||||
|
private static final String TAG = "WifiDialogActivity";
|
||||||
|
|
||||||
|
private static final int RESULT_CONNECTED = RESULT_FIRST_USER;
|
||||||
|
private static final int RESULT_FORGET = RESULT_FIRST_USER + 1;
|
||||||
|
|
||||||
|
private static final String KEY_ACCESS_POINT_STATE = "access_point_state";
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
|
super.onCreate(savedInstanceState);
|
||||||
|
|
||||||
|
final Intent intent = getIntent();
|
||||||
|
final Bundle accessPointState = intent.getBundleExtra(KEY_ACCESS_POINT_STATE);
|
||||||
|
final AccessPoint accessPoint = new AccessPoint(this, accessPointState);
|
||||||
|
|
||||||
|
WifiDialog dialog = new WifiDialog(this, this, accessPoint, WifiConfigUiBase.MODE_CONNECT);
|
||||||
|
dialog.show();
|
||||||
|
dialog.setOnDismissListener(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onForget(WifiDialog dialog) {
|
||||||
|
final WifiManager wifiManager = getSystemService(WifiManager.class);
|
||||||
|
final AccessPoint accessPoint = dialog.getController().getAccessPoint();
|
||||||
|
if (accessPoint != null) {
|
||||||
|
if (!accessPoint.isSaved()) {
|
||||||
|
if (accessPoint.getNetworkInfo() != null &&
|
||||||
|
accessPoint.getNetworkInfo().getState() != NetworkInfo.State.DISCONNECTED) {
|
||||||
|
// Network is active but has no network ID - must be ephemeral.
|
||||||
|
wifiManager.disableEphemeralNetwork(
|
||||||
|
AccessPoint.convertToQuotedString(accessPoint.getSsidStr()));
|
||||||
|
} else {
|
||||||
|
// Should not happen, but a monkey seems to trigger it
|
||||||
|
Log.e(TAG, "Failed to forget invalid network " + accessPoint.getConfig());
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
wifiManager.forget(accessPoint.getConfig().networkId, null /* listener */);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Intent resultData = new Intent();
|
||||||
|
if (accessPoint != null) {
|
||||||
|
Bundle accessPointState = new Bundle();
|
||||||
|
accessPoint.saveWifiState(accessPointState);
|
||||||
|
resultData.putExtra(KEY_ACCESS_POINT_STATE, accessPointState);
|
||||||
|
}
|
||||||
|
setResult(RESULT_FORGET);
|
||||||
|
finish();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onSubmit(WifiDialog dialog) {
|
||||||
|
final WifiConfiguration config = dialog.getController().getConfig();
|
||||||
|
final AccessPoint accessPoint = dialog.getController().getAccessPoint();
|
||||||
|
final WifiManager wifiManager = getSystemService(WifiManager.class);
|
||||||
|
|
||||||
|
if (config == null) {
|
||||||
|
if (accessPoint != null && accessPoint.isSaved()) {
|
||||||
|
wifiManager.connect(accessPoint.getConfig(), null /* listener */);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
wifiManager.save(config, null /* listener */);
|
||||||
|
if (accessPoint != null) {
|
||||||
|
// accessPoint is null for "Add network"
|
||||||
|
NetworkInfo networkInfo = accessPoint.getNetworkInfo();
|
||||||
|
if (networkInfo == null || !networkInfo.isConnected()) {
|
||||||
|
wifiManager.connect(config, null /* listener */);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Intent resultData = new Intent();
|
||||||
|
if (accessPoint != null) {
|
||||||
|
Bundle accessPointState = new Bundle();
|
||||||
|
accessPoint.saveWifiState(accessPointState);
|
||||||
|
resultData.putExtra(KEY_ACCESS_POINT_STATE, accessPointState);
|
||||||
|
}
|
||||||
|
setResult(RESULT_CONNECTED, resultData);
|
||||||
|
finish();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onDismiss(DialogInterface dialogInterface) {
|
||||||
|
finish();
|
||||||
|
}
|
||||||
|
}
|
@@ -112,8 +112,7 @@ public class WifiSettings extends RestrictedSettingsFragment
|
|||||||
private static final int WRITE_NFC_DIALOG_ID = 6;
|
private static final int WRITE_NFC_DIALOG_ID = 6;
|
||||||
|
|
||||||
// Instance state keys
|
// Instance state keys
|
||||||
private static final String SAVE_DIALOG_EDIT_MODE = "edit_mode";
|
private static final String SAVE_DIALOG_MODE = "dialog_mode";
|
||||||
private static final String SAVE_DIALOG_MODIFY_MODE = "modify_mode";
|
|
||||||
private static final String SAVE_DIALOG_ACCESS_POINT_STATE = "wifi_ap_state";
|
private static final String SAVE_DIALOG_ACCESS_POINT_STATE = "wifi_ap_state";
|
||||||
private static final String SAVED_WIFI_NFC_DIALOG_STATE = "wifi_nfc_dlg_state";
|
private static final String SAVED_WIFI_NFC_DIALOG_STATE = "wifi_nfc_dlg_state";
|
||||||
|
|
||||||
@@ -145,8 +144,7 @@ public class WifiSettings extends RestrictedSettingsFragment
|
|||||||
private boolean mEnableNextOnConnection;
|
private boolean mEnableNextOnConnection;
|
||||||
|
|
||||||
// Save the dialog details
|
// Save the dialog details
|
||||||
private boolean mDlgModify;
|
private int mDialogMode;
|
||||||
private boolean mDlgEdit;
|
|
||||||
private AccessPoint mDlgAccessPoint;
|
private AccessPoint mDlgAccessPoint;
|
||||||
private Bundle mAccessPointSavedState;
|
private Bundle mAccessPointSavedState;
|
||||||
private Bundle mWifiNfcDialogSavedState;
|
private Bundle mWifiNfcDialogSavedState;
|
||||||
@@ -243,8 +241,7 @@ public class WifiSettings extends RestrictedSettingsFragment
|
|||||||
};
|
};
|
||||||
|
|
||||||
if (savedInstanceState != null) {
|
if (savedInstanceState != null) {
|
||||||
mDlgEdit = savedInstanceState.getBoolean(SAVE_DIALOG_EDIT_MODE);
|
mDialogMode = savedInstanceState.getInt(SAVE_DIALOG_MODE);
|
||||||
mDlgModify = savedInstanceState.getBoolean(SAVE_DIALOG_MODIFY_MODE);
|
|
||||||
if (savedInstanceState.containsKey(SAVE_DIALOG_ACCESS_POINT_STATE)) {
|
if (savedInstanceState.containsKey(SAVE_DIALOG_ACCESS_POINT_STATE)) {
|
||||||
mAccessPointSavedState =
|
mAccessPointSavedState =
|
||||||
savedInstanceState.getBundle(SAVE_DIALOG_ACCESS_POINT_STATE);
|
savedInstanceState.getBundle(SAVE_DIALOG_ACCESS_POINT_STATE);
|
||||||
@@ -375,8 +372,7 @@ public class WifiSettings extends RestrictedSettingsFragment
|
|||||||
|
|
||||||
// If the dialog is showing, save its state.
|
// If the dialog is showing, save its state.
|
||||||
if (mDialog != null && mDialog.isShowing()) {
|
if (mDialog != null && mDialog.isShowing()) {
|
||||||
outState.putBoolean(SAVE_DIALOG_EDIT_MODE, mDlgEdit);
|
outState.putInt(SAVE_DIALOG_MODE, mDialogMode);
|
||||||
outState.putBoolean(SAVE_DIALOG_MODIFY_MODE, mDlgModify);
|
|
||||||
if (mDlgAccessPoint != null) {
|
if (mDlgAccessPoint != null) {
|
||||||
mAccessPointSavedState = new Bundle();
|
mAccessPointSavedState = new Bundle();
|
||||||
mDlgAccessPoint.saveWifiState(mAccessPointSavedState);
|
mDlgAccessPoint.saveWifiState(mAccessPointSavedState);
|
||||||
@@ -504,8 +500,7 @@ public class WifiSettings extends RestrictedSettingsFragment
|
|||||||
mSelectedAccessPoint.generateOpenNetworkConfig();
|
mSelectedAccessPoint.generateOpenNetworkConfig();
|
||||||
connect(mSelectedAccessPoint.getConfig());
|
connect(mSelectedAccessPoint.getConfig());
|
||||||
} else {
|
} else {
|
||||||
mDlgModify = false;
|
showDialog(mSelectedAccessPoint, WifiConfigUiBase.MODE_CONNECT);
|
||||||
showDialog(mSelectedAccessPoint, true);
|
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -514,8 +509,7 @@ public class WifiSettings extends RestrictedSettingsFragment
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
case MENU_ID_MODIFY: {
|
case MENU_ID_MODIFY: {
|
||||||
mDlgModify = true;
|
showDialog(mSelectedAccessPoint, WifiConfigUiBase.MODE_MODIFY);
|
||||||
showDialog(mSelectedAccessPoint, true);
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
case MENU_ID_WRITE_NFC:
|
case MENU_ID_WRITE_NFC:
|
||||||
@@ -540,11 +534,9 @@ public class WifiSettings extends RestrictedSettingsFragment
|
|||||||
}
|
}
|
||||||
connect(mSelectedAccessPoint.getConfig());
|
connect(mSelectedAccessPoint.getConfig());
|
||||||
} else if (mSelectedAccessPoint.isSaved()){
|
} else if (mSelectedAccessPoint.isSaved()){
|
||||||
mDlgModify = false;
|
showDialog(mSelectedAccessPoint, WifiConfigUiBase.MODE_VIEW);
|
||||||
showDialog(mSelectedAccessPoint, false);
|
|
||||||
} else {
|
} else {
|
||||||
mDlgModify = false;
|
showDialog(mSelectedAccessPoint, WifiConfigUiBase.MODE_CONNECT);
|
||||||
showDialog(mSelectedAccessPoint, true);
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
return super.onPreferenceTreeClick(screen, preference);
|
return super.onPreferenceTreeClick(screen, preference);
|
||||||
@@ -552,7 +544,7 @@ public class WifiSettings extends RestrictedSettingsFragment
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void showDialog(AccessPoint accessPoint, boolean edit) {
|
private void showDialog(AccessPoint accessPoint, int dialogMode) {
|
||||||
if (accessPoint != null) {
|
if (accessPoint != null) {
|
||||||
WifiConfiguration config = accessPoint.getConfig();
|
WifiConfiguration config = accessPoint.getConfig();
|
||||||
if (isEditabilityLockedDown(getActivity(), config) && accessPoint.isActive()) {
|
if (isEditabilityLockedDown(getActivity(), config) && accessPoint.isActive()) {
|
||||||
@@ -587,7 +579,7 @@ public class WifiSettings extends RestrictedSettingsFragment
|
|||||||
|
|
||||||
// Save the access point and edit mode
|
// Save the access point and edit mode
|
||||||
mDlgAccessPoint = accessPoint;
|
mDlgAccessPoint = accessPoint;
|
||||||
mDlgEdit = edit;
|
mDialogMode = dialogMode;
|
||||||
|
|
||||||
showDialog(WIFI_DIALOG_ID);
|
showDialog(WIFI_DIALOG_ID);
|
||||||
}
|
}
|
||||||
@@ -610,8 +602,8 @@ public class WifiSettings extends RestrictedSettingsFragment
|
|||||||
mSelectedAccessPoint = ap;
|
mSelectedAccessPoint = ap;
|
||||||
final boolean hideForget = (ap == null || isEditabilityLockedDown(getActivity(),
|
final boolean hideForget = (ap == null || isEditabilityLockedDown(getActivity(),
|
||||||
ap.getConfig()));
|
ap.getConfig()));
|
||||||
mDialog = new WifiDialog(getActivity(), this, ap, mDlgEdit,
|
mDialog = new WifiDialog(getActivity(), this, ap, mDialogMode,
|
||||||
mDlgModify, /* no hide submit/connect */ false,
|
/* no hide submit/connect */ false,
|
||||||
/* hide forget if config locked down */ hideForget);
|
/* hide forget if config locked down */ hideForget);
|
||||||
return mDialog;
|
return mDialog;
|
||||||
case WPS_PBC_DIALOG_ID:
|
case WPS_PBC_DIALOG_ID:
|
||||||
@@ -830,7 +822,7 @@ public class WifiSettings extends RestrictedSettingsFragment
|
|||||||
&& mSelectedAccessPoint.isSaved()) {
|
&& mSelectedAccessPoint.isSaved()) {
|
||||||
connect(mSelectedAccessPoint.getConfig());
|
connect(mSelectedAccessPoint.getConfig());
|
||||||
}
|
}
|
||||||
} else if (configController.isModify()) {
|
} else if (configController.getMode() == WifiConfigUiBase.MODE_MODIFY) {
|
||||||
mWifiManager.save(config, mSaveListener);
|
mWifiManager.save(config, mSaveListener);
|
||||||
} else {
|
} else {
|
||||||
mWifiManager.save(config, mSaveListener);
|
mWifiManager.save(config, mSaveListener);
|
||||||
@@ -891,7 +883,7 @@ public class WifiSettings extends RestrictedSettingsFragment
|
|||||||
MetricsLogger.action(getActivity(), MetricsLogger.ACTION_WIFI_ADD_NETWORK);
|
MetricsLogger.action(getActivity(), MetricsLogger.ACTION_WIFI_ADD_NETWORK);
|
||||||
// No exact access point is selected.
|
// No exact access point is selected.
|
||||||
mSelectedAccessPoint = null;
|
mSelectedAccessPoint = null;
|
||||||
showDialog(null, true);
|
showDialog(null, WifiConfigUiBase.MODE_CONNECT);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* package */ int getAccessPointsCount() {
|
/* package */ int getAccessPointsCount() {
|
||||||
|
Reference in New Issue
Block a user