diff options
author | Andrew Flynn <flynn@google.com> | 2012-05-06 14:59:11 -0700 |
---|---|---|
committer | Andrew Flynn <flynn@google.com> | 2012-05-08 15:50:45 -0700 |
commit | 0575736cdc13bd08e42a954c7699d3937679b561 (patch) | |
tree | 77feb409e77233e77c151ac7c28369255e5d6487 | |
parent | 98d262df0d0b6eb76b9ddbfb75cc5076a08301db (diff) | |
download | packages_apps_settings-0575736cdc13bd08e42a954c7699d3937679b561.zip packages_apps_settings-0575736cdc13bd08e42a954c7699d3937679b561.tar.gz packages_apps_settings-0575736cdc13bd08e42a954c7699d3937679b561.tar.bz2 |
Allow WiFi picker to exit after a valid connection is made
Choice is passed in via boolean extra and has two effects:
* A valid network connection exits the picker.
* The next button (if there is one) is hidden.
This functionality will be used for SetupWizard initially.
Bug: 6428046
Change-Id: Ieeed3a9f1013cccd76bd4762131747a57a38ce9c
-rw-r--r-- | src/com/android/settings/wifi/WifiSettings.java | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/src/com/android/settings/wifi/WifiSettings.java b/src/com/android/settings/wifi/WifiSettings.java index 97f464f..5037ad3 100644 --- a/src/com/android/settings/wifi/WifiSettings.java +++ b/src/com/android/settings/wifi/WifiSettings.java @@ -133,6 +133,10 @@ public class WifiSettings extends SettingsPreferenceFragment // 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"; + private static final String EXTRA_WIFI_SHOW_ACTION_BAR = "wifi_show_action_bar"; private static final String EXTRA_WIFI_SHOW_MENUS = "wifi_show_menus"; private static final String EXTRA_WIFI_DISABLE_BACK = "wifi_disable_back"; @@ -140,6 +144,9 @@ public class WifiSettings extends SettingsPreferenceFragment // 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; + // Save the dialog details private boolean mDlgEdit; private AccessPoint mDlgAccessPoint; @@ -220,6 +227,24 @@ public class WifiSettings extends SettingsPreferenceFragment final Activity activity = getActivity(); final Intent intent = activity.getIntent(); + // first if we're supposed to finish once we have a connection + mAutoFinishOnConnection = intent.getBooleanExtra(EXTRA_AUTO_FINISH_ON_CONNECT, false); + + if (mAutoFinishOnConnection) { + // Hide the next button + if (hasNextButton()) { + getNextButton().setVisibility(View.GONE); + } + + final ConnectivityManager connectivity = (ConnectivityManager) + getActivity().getSystemService(Context.CONNECTIVITY_SERVICE); + if (connectivity != null + && connectivity.getNetworkInfo(ConnectivityManager.TYPE_WIFI).isConnected()) { + activity.finish(); + return; + } + } + // 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); @@ -656,6 +681,10 @@ public class WifiSettings extends SettingsPreferenceFragment changeNextButtonState(info.isConnected()); updateAccessPoints(); updateConnectionState(info.getDetailedState()); + if (mAutoFinishOnConnection && info.isConnected()) { + getActivity().finish(); + return; + } } else if (WifiManager.RSSI_CHANGED_ACTION.equals(action)) { updateConnectionState(null); } |