summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMaurice Lam <yukl@google.com>2014-06-20 14:28:30 -0700
committerMaurice Lam <yukl@google.com>2014-06-20 15:27:25 -0700
commit9f59de930ae14566673d4d57597b836556820b29 (patch)
tree74e97b668c775b7073c3f37238fb5ebd526b0871
parentc24ffca0f43ec73c112613750960438fcd846fb2 (diff)
downloadpackages_apps_Settings-9f59de930ae14566673d4d57597b836556820b29.zip
packages_apps_Settings-9f59de930ae14566673d4d57597b836556820b29.tar.gz
packages_apps_Settings-9f59de930ae14566673d4d57597b836556820b29.tar.bz2
[WifiSetup] Restore enableNext behavior
Partial revert of ag/475394 which moved enable-next-on-connect behavior to setup wizard specific code. But account creation was using it outside of setup wizard context. Change-Id: I575976207a3ba2b5dac7e5467036e6ec7f519d9d
-rw-r--r--src/com/android/settings/wifi/WifiSettings.java43
-rw-r--r--src/com/android/settings/wifi/WifiSettingsForSetupWizard.java42
2 files changed, 41 insertions, 44 deletions
diff --git a/src/com/android/settings/wifi/WifiSettings.java b/src/com/android/settings/wifi/WifiSettings.java
index ec77937..c832252 100644
--- a/src/com/android/settings/wifi/WifiSettings.java
+++ b/src/com/android/settings/wifi/WifiSettings.java
@@ -39,6 +39,7 @@ import android.content.pm.PackageManager;
import android.content.res.Resources;
import android.content.res.TypedArray;
import android.location.LocationManager;
+import android.net.ConnectivityManager;
import android.net.NetworkInfo;
import android.net.NetworkInfo.DetailedState;
import android.net.wifi.ScanResult;
@@ -96,8 +97,6 @@ public class WifiSettings extends RestrictedSettingsFragment
private static final int WIFI_DIALOG_ID = 1;
/* package */ static final int WPS_PBC_DIALOG_ID = 2;
private static final int WPS_PIN_DIALOG_ID = 3;
- /* package */ static final int WIFI_SKIPPED_DIALOG_ID = 4;
- /* package */ static final int WIFI_AND_MOBILE_SKIPPED_DIALOG_ID = 5;
private static final int WRITE_NFC_DIALOG_ID = 6;
// Combo scans can take 5-6s to complete - set to 10s.
@@ -131,6 +130,13 @@ public class WifiSettings extends RestrictedSettingsFragment
private TextView mEmptyView;
+ // this boolean extra specifies whether to disable the Next button when not connected. Used by
+ // account creation outside of setup wizard.
+ private static final String EXTRA_ENABLE_NEXT_ON_CONNECT = "wifi_enable_next_on_connect";
+
+ // should Next button only be enabled when we have a connection?
+ private boolean mEnableNextOnConnection;
+
// Save the dialog details
private boolean mDlgEdit;
private AccessPoint mDlgAccessPoint;
@@ -222,6 +228,23 @@ public class WifiSettings extends RestrictedSettingsFragment
mAccessPointSavedState = savedInstanceState.getBundle(SAVE_DIALOG_ACCESS_POINT_STATE);
}
+ // if we're supposed to enable/disable the Next button based on our current connection
+ // state, start it off in the right state
+ Intent intent = getActivity().getIntent();
+ mEnableNextOnConnection = intent.getBooleanExtra(EXTRA_ENABLE_NEXT_ON_CONNECT, false);
+
+ if (mEnableNextOnConnection) {
+ if (hasNextButton()) {
+ final ConnectivityManager connectivity = (ConnectivityManager)
+ getActivity().getSystemService(Context.CONNECTIVITY_SERVICE);
+ if (connectivity != null) {
+ NetworkInfo info = connectivity.getNetworkInfo(
+ ConnectivityManager.TYPE_WIFI);
+ changeNextButtonState(info.isConnected());
+ }
+ }
+ }
+
addPreferencesFromResource(R.xml.wifi_settings);
mEmptyView = (TextView) getView().findViewById(android.R.id.empty);
@@ -675,6 +698,7 @@ public class WifiSettings extends RestrictedSettingsFragment
NetworkInfo info = (NetworkInfo) intent.getParcelableExtra(
WifiManager.EXTRA_NETWORK_INFO);
mConnected.set(info.isConnected());
+ changeNextButtonState(info.isConnected());
updateAccessPoints();
updateConnectionState(info.getDetailedState());
} else if (WifiManager.RSSI_CHANGED_ACTION.equals(action)) {
@@ -770,6 +794,18 @@ public class WifiSettings extends RestrictedSettingsFragment
}
}
+ /**
+ * Renames/replaces "Next" button when appropriate. "Next" button usually exists in
+ * Wifi setup screens, not in usual wifi settings screen.
+ *
+ * @param enabled true when the device is connected to a wifi network.
+ */
+ private void changeNextButtonState(boolean enabled) {
+ if (mEnableNextOnConnection && hasNextButton()) {
+ getNextButton().setEnabled(enabled);
+ }
+ }
+
@Override
public void onClick(DialogInterface dialogInterface, int button) {
if (button == WifiDialog.BUTTON_FORGET && mSelectedAccessPoint != null) {
@@ -822,6 +858,9 @@ public class WifiSettings extends RestrictedSettingsFragment
mScanner.resume();
}
updateAccessPoints();
+
+ // We need to rename/replace "Next" button in wifi setup context.
+ changeNextButtonState(false);
}
/**
diff --git a/src/com/android/settings/wifi/WifiSettingsForSetupWizard.java b/src/com/android/settings/wifi/WifiSettingsForSetupWizard.java
index 325e1eb..7ef6480 100644
--- a/src/com/android/settings/wifi/WifiSettingsForSetupWizard.java
+++ b/src/com/android/settings/wifi/WifiSettingsForSetupWizard.java
@@ -54,18 +54,12 @@ public class WifiSettingsForSetupWizard extends WifiSettings {
/* Used in Wifi Setup context */
- // this boolean extra specifies whether to disable the Next button when not connected
- private static final String EXTRA_ENABLE_NEXT_ON_CONNECT = "wifi_enable_next_on_connect";
-
// this boolean extra specifies whether to auto finish when connection is established
private static final String EXTRA_AUTO_FINISH_ON_CONNECT = "wifi_auto_finish_on_connect";
// show a text regarding data charges when wifi connection is required during setup wizard
protected static final String EXTRA_SHOW_WIFI_REQUIRED_INFO = "wifi_show_wifi_required_info";
- // should Next button only be enabled when we have a connection?
- private boolean mEnableNextOnConnection;
-
// should activity finish once we have a connection?
private boolean mAutoFinishOnConnection;
@@ -83,7 +77,6 @@ public class WifiSettingsForSetupWizard extends WifiSettings {
public void onReceive(Context context, Intent intent) {
NetworkInfo info = (NetworkInfo) intent.getParcelableExtra(
WifiManager.EXTRA_NETWORK_INFO);
- changeNextButtonState(info.isConnected());
if (mAutoFinishOnConnection && info.isConnected()) {
Log.d(TAG, "mReceiver.onReceive context=" + context + " intent=" + intent);
WifiSetupActivity activity = (WifiSetupActivity) getActivity();
@@ -177,22 +170,6 @@ public class WifiSettingsForSetupWizard extends WifiSettings {
}
}
}
-
- // if we're supposed to enable/disable the Next button based on our current connection
- // state, start it off in the right state
- mEnableNextOnConnection = intent.getBooleanExtra(EXTRA_ENABLE_NEXT_ON_CONNECT, false);
-
- if (mEnableNextOnConnection) {
- if (hasNextButton()) {
- final ConnectivityManager connectivity = (ConnectivityManager)
- activity.getSystemService(Context.CONNECTIVITY_SERVICE);
- if (connectivity != null) {
- NetworkInfo info = connectivity.getNetworkInfo(
- ConnectivityManager.TYPE_WIFI);
- changeNextButtonState(info.isConnected());
- }
- }
- }
}
@Override
@@ -233,23 +210,4 @@ public class WifiSettingsForSetupWizard extends WifiSettings {
ta.recycle();
}
- @Override
- /* package */ void forget() {
- super.forget();
-
- // We need to rename/replace "Next" button in wifi setup context.
- changeNextButtonState(false);
- }
-
- /**
- * Renames/replaces "Next" button when appropriate. "Next" button usually exists in
- * Wifi setup screens, not in usual wifi settings screen.
- *
- * @param enabled true when the device is connected to a wifi network.
- */
- private void changeNextButtonState(boolean enabled) {
- if (mEnableNextOnConnection && hasNextButton()) {
- getNextButton().setEnabled(enabled);
- }
- }
}