Loading src/com/android/settings/wifi/WifiSettings.java +41 −2 Original line number Diff line number Diff line Loading @@ -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; Loading Loading @@ -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. Loading Loading @@ -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; Loading Loading @@ -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); Loading Loading @@ -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)) { Loading Loading @@ -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) { Loading Loading @@ -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); } /** Loading src/com/android/settings/wifi/WifiSettingsForSetupWizard.java +0 −42 Original line number Diff line number Diff line Loading @@ -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; Loading @@ -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(); Loading Loading @@ -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 Loading Loading @@ -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); } } } Loading
src/com/android/settings/wifi/WifiSettings.java +41 −2 Original line number Diff line number Diff line Loading @@ -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; Loading Loading @@ -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. Loading Loading @@ -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; Loading Loading @@ -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); Loading Loading @@ -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)) { Loading Loading @@ -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) { Loading Loading @@ -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); } /** Loading
src/com/android/settings/wifi/WifiSettingsForSetupWizard.java +0 −42 Original line number Diff line number Diff line Loading @@ -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; Loading @@ -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(); Loading Loading @@ -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 Loading Loading @@ -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); } } }