Include Add Network button for Setup Wizard
To allow first-time users to set up on networks with hidden SSID, include this button on the action bar. Temporarily using placeholder text until artwork is available. Bug: 6446220 Change-Id: I437ad3f37b42b93f7a0c6838cbb0c5090073e32d
This commit is contained in:
@@ -137,8 +137,9 @@ public class WifiSettings extends SettingsPreferenceFragment
|
|||||||
// this boolean extra specifies whether to auto finish when connection is established
|
// 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_AUTO_FINISH_ON_CONNECT = "wifi_auto_finish_on_connect";
|
||||||
|
|
||||||
private static final String EXTRA_WIFI_SHOW_ACTION_BAR = "wifi_show_action_bar";
|
// this boolean extra is set if we are being invoked by the Setup Wizard
|
||||||
private static final String EXTRA_WIFI_SHOW_MENUS = "wifi_show_menus";
|
private static final String EXTRA_IS_FIRST_RUN = "firstRun";
|
||||||
|
|
||||||
private static final String EXTRA_WIFI_DISABLE_BACK = "wifi_disable_back";
|
private static final String EXTRA_WIFI_DISABLE_BACK = "wifi_disable_back";
|
||||||
|
|
||||||
// should Next button only be enabled when we have a connection?
|
// should Next button only be enabled when we have a connection?
|
||||||
@@ -152,8 +153,8 @@ public class WifiSettings extends SettingsPreferenceFragment
|
|||||||
private AccessPoint mDlgAccessPoint;
|
private AccessPoint mDlgAccessPoint;
|
||||||
private Bundle mAccessPointSavedState;
|
private Bundle mAccessPointSavedState;
|
||||||
|
|
||||||
// Menus are not shown by Setup Wizard
|
// the action bar uses a different set of controls for Setup Wizard
|
||||||
private boolean mShowMenu;
|
private boolean mSetupWizardMode;
|
||||||
|
|
||||||
/* End of "used in Wifi Setup context" */
|
/* End of "used in Wifi Setup context" */
|
||||||
|
|
||||||
@@ -178,6 +179,14 @@ public class WifiSettings extends SettingsPreferenceFragment
|
|||||||
mScanner = new Scanner();
|
mScanner = new Scanner();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onCreate(Bundle icicle) {
|
||||||
|
// Set this flag early, as it's needed by getHelpResource(), which is called by super
|
||||||
|
mSetupWizardMode = getActivity().getIntent().getBooleanExtra(EXTRA_IS_FIRST_RUN, false);
|
||||||
|
|
||||||
|
super.onCreate(icicle);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onActivityCreated(Bundle savedInstanceState) {
|
public void onActivityCreated(Bundle savedInstanceState) {
|
||||||
// We don't call super.onActivityCreated() here, since it assumes we already set up
|
// We don't call super.onActivityCreated() here, since it assumes we already set up
|
||||||
@@ -268,9 +277,8 @@ public class WifiSettings extends SettingsPreferenceFragment
|
|||||||
getView().setSystemUiVisibility(View.STATUS_BAR_DISABLE_BACK);
|
getView().setSystemUiVisibility(View.STATUS_BAR_DISABLE_BACK);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Action bar is hidden for Setup Wizard
|
// On/off switch is hidden for Setup Wizard
|
||||||
final boolean showActionBar = intent.getBooleanExtra(EXTRA_WIFI_SHOW_ACTION_BAR, true);
|
if (!mSetupWizardMode) {
|
||||||
if (showActionBar) {
|
|
||||||
Switch actionBarSwitch = new Switch(activity);
|
Switch actionBarSwitch = new Switch(activity);
|
||||||
|
|
||||||
if (activity instanceof PreferenceActivity) {
|
if (activity instanceof PreferenceActivity) {
|
||||||
@@ -294,13 +302,9 @@ public class WifiSettings extends SettingsPreferenceFragment
|
|||||||
mEmptyView = (TextView) getView().findViewById(android.R.id.empty);
|
mEmptyView = (TextView) getView().findViewById(android.R.id.empty);
|
||||||
getListView().setEmptyView(mEmptyView);
|
getListView().setEmptyView(mEmptyView);
|
||||||
|
|
||||||
// Menu is hidden for Setup Wizard
|
if (!mSetupWizardMode) {
|
||||||
mShowMenu = intent.getBooleanExtra(EXTRA_WIFI_SHOW_MENUS, true);
|
|
||||||
if (mShowMenu) {
|
|
||||||
registerForContextMenu(getListView());
|
registerForContextMenu(getListView());
|
||||||
}
|
}
|
||||||
// FIXME: When WPS image button is implemented, use mShowMenu instead of always showing
|
|
||||||
// the options menu
|
|
||||||
setHasOptionsMenu(true);
|
setHasOptionsMenu(true);
|
||||||
|
|
||||||
// After confirming PreferenceScreen is available, we call super.
|
// After confirming PreferenceScreen is available, we call super.
|
||||||
@@ -337,7 +341,15 @@ public class WifiSettings extends SettingsPreferenceFragment
|
|||||||
@Override
|
@Override
|
||||||
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
|
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
|
||||||
final boolean wifiIsEnabled = mWifiManager.isWifiEnabled();
|
final boolean wifiIsEnabled = mWifiManager.isWifiEnabled();
|
||||||
if (mShowMenu) {
|
if (mSetupWizardMode) {
|
||||||
|
// FIXME: add setIcon() when graphics are available
|
||||||
|
menu.add(Menu.NONE, MENU_ID_WPS_PBC, 0, R.string.wifi_menu_wps_pbc)
|
||||||
|
.setEnabled(wifiIsEnabled)
|
||||||
|
.setShowAsAction(MenuItem.SHOW_AS_ACTION_ALWAYS);
|
||||||
|
menu.add(Menu.NONE, MENU_ID_ADD_NETWORK, 0, R.string.wifi_add_network)
|
||||||
|
.setEnabled(wifiIsEnabled)
|
||||||
|
.setShowAsAction(MenuItem.SHOW_AS_ACTION_ALWAYS);
|
||||||
|
} else {
|
||||||
menu.add(Menu.NONE, MENU_ID_WPS_PBC, 0, R.string.wifi_menu_wps_pbc)
|
menu.add(Menu.NONE, MENU_ID_WPS_PBC, 0, R.string.wifi_menu_wps_pbc)
|
||||||
.setEnabled(wifiIsEnabled)
|
.setEnabled(wifiIsEnabled)
|
||||||
.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM);
|
.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM);
|
||||||
@@ -359,11 +371,6 @@ public class WifiSettings extends SettingsPreferenceFragment
|
|||||||
menu.add(Menu.NONE, MENU_ID_ADVANCED, 0, R.string.wifi_menu_advanced)
|
menu.add(Menu.NONE, MENU_ID_ADVANCED, 0, R.string.wifi_menu_advanced)
|
||||||
//.setIcon(android.R.drawable.ic_menu_manage)
|
//.setIcon(android.R.drawable.ic_menu_manage)
|
||||||
.setShowAsAction(MenuItem.SHOW_AS_ACTION_NEVER);
|
.setShowAsAction(MenuItem.SHOW_AS_ACTION_NEVER);
|
||||||
} else {
|
|
||||||
// FIXME: Interim support for WPS, until ImageButton is available
|
|
||||||
menu.add(Menu.NONE, MENU_ID_WPS_PBC, 0, R.string.wifi_menu_wps_pbc)
|
|
||||||
.setEnabled(wifiIsEnabled)
|
|
||||||
.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM);
|
|
||||||
}
|
}
|
||||||
super.onCreateOptionsMenu(menu, inflater);
|
super.onCreateOptionsMenu(menu, inflater);
|
||||||
}
|
}
|
||||||
@@ -889,10 +896,9 @@ public class WifiSettings extends SettingsPreferenceFragment
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected int getHelpResource() {
|
protected int getHelpResource() {
|
||||||
// Setup Wizard has different help content
|
if (mSetupWizardMode) {
|
||||||
if (mShowMenu) {
|
|
||||||
return R.string.help_url_wifi;
|
|
||||||
}
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
return R.string.help_url_wifi;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user