Create 'See All Networks' Preference to hide additional networks.
Bug: 34719725 Test: manual inspection, tests to be added in b/35322551 Change-Id: I1a5a08ca4c53db71b4c0c3d4c2942da65faa67d2
This commit is contained in:
@@ -140,6 +140,10 @@ public class WifiSettings extends RestrictedSettingsFragment
|
||||
// should Next button only be enabled when we have a connection?
|
||||
private boolean mEnableNextOnConnection;
|
||||
|
||||
// should see all networks instead of collapsing networks and showing mSeeAllNetworksPreference.
|
||||
private boolean mSeeAllNetworks;
|
||||
private static final int NETWORKS_TO_INITIALLY_SHOW = 5;
|
||||
|
||||
// Save the dialog details
|
||||
private int mDialogMode;
|
||||
private AccessPoint mDlgAccessPoint;
|
||||
@@ -157,6 +161,7 @@ public class WifiSettings extends RestrictedSettingsFragment
|
||||
private PreferenceCategory mAccessPointsPreferenceCategory;
|
||||
private PreferenceCategory mAdditionalSettingsPreferenceCategory;
|
||||
private Preference mAddPreference;
|
||||
private Preference mSeeAllNetworksPreference;
|
||||
private Preference mConfigureWifiSettingsPreference;
|
||||
private Preference mSavedNetworksPreference;
|
||||
private LinkablePreference mStatusMessagePreference;
|
||||
@@ -200,6 +205,10 @@ public class WifiSettings extends RestrictedSettingsFragment
|
||||
mAddPreference = new Preference(prefContext);
|
||||
mAddPreference.setIcon(R.drawable.ic_menu_add_inset);
|
||||
mAddPreference.setTitle(R.string.wifi_add_network);
|
||||
mSeeAllNetworksPreference = new Preference(prefContext);
|
||||
mSeeAllNetworksPreference.setIcon(R.drawable.ic_arrow_down_24dp);
|
||||
mSeeAllNetworksPreference.setTitle(R.string.wifi_see_all_networks_button_title);
|
||||
mSeeAllNetworks = false;
|
||||
mStatusMessagePreference = new LinkablePreference(prefContext);
|
||||
|
||||
mUserBadgeCache = new AccessPointPreference.UserBadgeCache(getPackageManager());
|
||||
@@ -524,6 +533,9 @@ public class WifiSettings extends RestrictedSettingsFragment
|
||||
}
|
||||
} else if (preference == mAddPreference) {
|
||||
onAddNetworkPressed();
|
||||
} else if (preference == mSeeAllNetworksPreference) {
|
||||
mSeeAllNetworks = true;
|
||||
onAccessPointsChanged();
|
||||
} else {
|
||||
return super.onPreferenceTreeClick(preference);
|
||||
}
|
||||
@@ -635,8 +647,12 @@ public class WifiSettings extends RestrictedSettingsFragment
|
||||
cacheRemoveAllPrefs(mAccessPointsPreferenceCategory);
|
||||
|
||||
int index = configureConnectedAccessPointPreferenceCategory(accessPoints) ? 1 : 0;
|
||||
boolean fewerNetworksThanLimit =
|
||||
accessPoints.size() <= index + NETWORKS_TO_INITIALLY_SHOW;
|
||||
int numAccessPointsToShow = mSeeAllNetworks || fewerNetworksThanLimit
|
||||
? accessPoints.size() : index + NETWORKS_TO_INITIALLY_SHOW;
|
||||
|
||||
for (; index < accessPoints.size(); index++) {
|
||||
for (; index < numAccessPointsToShow; index++) {
|
||||
AccessPoint accessPoint = accessPoints.get(index);
|
||||
// Ignore access points that are out of range.
|
||||
if (accessPoint.getLevel() != -1) {
|
||||
@@ -682,15 +698,19 @@ public class WifiSettings extends RestrictedSettingsFragment
|
||||
pref.setOrder(index++);
|
||||
pref.setKey(PREF_KEY_EMPTY_WIFI_LIST);
|
||||
mAccessPointsPreferenceCategory.addPreference(pref);
|
||||
mAddPreference.setOrder(index++);
|
||||
mAccessPointsPreferenceCategory.addPreference(mAddPreference);
|
||||
setConfigureWifiSettingsVisibility();
|
||||
} else {
|
||||
mAddPreference.setOrder(index++);
|
||||
mAccessPointsPreferenceCategory.addPreference(mAddPreference);
|
||||
setConfigureWifiSettingsVisibility();
|
||||
setProgressBarVisible(false);
|
||||
}
|
||||
if (mSeeAllNetworks || fewerNetworksThanLimit) {
|
||||
mAccessPointsPreferenceCategory.removePreference(mSeeAllNetworksPreference);
|
||||
mAddPreference.setOrder(index);
|
||||
mAccessPointsPreferenceCategory.addPreference(mAddPreference);
|
||||
} else {
|
||||
mAccessPointsPreferenceCategory.removePreference(mAddPreference);
|
||||
mSeeAllNetworksPreference.setOrder(index);
|
||||
mAccessPointsPreferenceCategory.addPreference(mSeeAllNetworksPreference);
|
||||
}
|
||||
setConfigureWifiSettingsVisibility();
|
||||
if (mScanMenuItem != null) {
|
||||
mScanMenuItem.setEnabled(true);
|
||||
}
|
||||
|
Reference in New Issue
Block a user