Implement new design of Wi-Fi card
- always show Wi-Fi card - collapse the card in the new UI session when connecting to a stable network - hide toggle, show a level icon and subtext in the new collapsed mode - show loading row when the AP list is not full Test: robotest Fixes: 147473096 Change-Id: I893064ef04d40d8e7cb8e62c1e72a2cb5e97f6ac
This commit is contained in:
@@ -95,7 +95,7 @@ public class WifiSlice implements CustomSliceable {
|
||||
mContext.getTheme().applyStyle(R.style.Theme_Settings_Home, true /* force */);
|
||||
|
||||
final boolean isWifiEnabled = isWifiEnabled();
|
||||
ListBuilder listBuilder = getHeaderRow(isWifiEnabled);
|
||||
ListBuilder listBuilder = getListBuilder(isWifiEnabled, null /* accessPoint */);
|
||||
if (!isWifiEnabled) {
|
||||
WifiScanWorker.clearClickedWifi();
|
||||
return listBuilder.build();
|
||||
@@ -107,17 +107,12 @@ public class WifiSlice implements CustomSliceable {
|
||||
final boolean isFirstApActive = apCount > 0 && apList.get(0).isActive();
|
||||
handleNetworkCallback(worker, isFirstApActive);
|
||||
|
||||
// Need a loading text when results are not ready or out of date.
|
||||
boolean needLoadingRow = true;
|
||||
// Skip checking the existence of the first access point if it's active
|
||||
int index = isFirstApActive ? 1 : 0;
|
||||
// This loop checks the existence of reachable APs to determine the validity of the current
|
||||
// AP list.
|
||||
for (; index < apCount; index++) {
|
||||
if (apList.get(index).isReachable()) {
|
||||
needLoadingRow = false;
|
||||
break;
|
||||
if (!isToggleNeeded()) {
|
||||
if (isFirstApActive) {
|
||||
// refresh header subtext
|
||||
listBuilder = getListBuilder(true /* isWifiEnabled */, apList.get(0));
|
||||
}
|
||||
return listBuilder.build();
|
||||
}
|
||||
|
||||
// Add AP rows
|
||||
@@ -125,9 +120,8 @@ public class WifiSlice implements CustomSliceable {
|
||||
for (int i = 0; i < DEFAULT_EXPANDED_ROW_COUNT; i++) {
|
||||
if (i < apCount) {
|
||||
listBuilder.addRow(getAccessPointRow(apList.get(i)));
|
||||
} else if (needLoadingRow) {
|
||||
} else if (i == apCount) {
|
||||
listBuilder.addRow(getLoadingRow(placeholder));
|
||||
needLoadingRow = false;
|
||||
} else {
|
||||
listBuilder.addRow(new ListBuilder.RowBuilder()
|
||||
.setTitle(placeholder)
|
||||
@@ -148,24 +142,34 @@ public class WifiSlice implements CustomSliceable {
|
||||
}
|
||||
}
|
||||
|
||||
private ListBuilder getHeaderRow(boolean isWifiEnabled) {
|
||||
protected boolean isToggleNeeded() {
|
||||
return true;
|
||||
}
|
||||
|
||||
protected ListBuilder.RowBuilder getHeaderRow(AccessPoint accessPoint) {
|
||||
final IconCompat icon = IconCompat.createWithResource(mContext,
|
||||
R.drawable.ic_settings_wireless);
|
||||
final String title = mContext.getString(R.string.wifi_settings);
|
||||
final PendingIntent toggleAction = getBroadcastIntent(mContext);
|
||||
final PendingIntent primaryAction = getPrimaryAction();
|
||||
final SliceAction primarySliceAction = SliceAction.createDeeplink(primaryAction, icon,
|
||||
ListBuilder.ICON_IMAGE, title);
|
||||
final SliceAction toggleSliceAction = SliceAction.createToggle(toggleAction,
|
||||
null /* actionTitle */, isWifiEnabled);
|
||||
|
||||
return new ListBuilder(mContext, getUri(), ListBuilder.INFINITY)
|
||||
return new ListBuilder.RowBuilder()
|
||||
.setTitle(title)
|
||||
.setPrimaryAction(primarySliceAction);
|
||||
}
|
||||
|
||||
private ListBuilder getListBuilder(boolean isWifiEnabled, AccessPoint accessPoint) {
|
||||
final ListBuilder builder = new ListBuilder(mContext, getUri(), ListBuilder.INFINITY)
|
||||
.setAccentColor(COLOR_NOT_TINTED)
|
||||
.setKeywords(getKeywords())
|
||||
.addRow(new ListBuilder.RowBuilder()
|
||||
.setTitle(title)
|
||||
.addEndItem(toggleSliceAction)
|
||||
.setPrimaryAction(primarySliceAction));
|
||||
.addRow(getHeaderRow(accessPoint));
|
||||
if (isToggleNeeded()) {
|
||||
final PendingIntent toggleAction = getBroadcastIntent(mContext);
|
||||
builder.addAction(SliceAction.createToggle(toggleAction, null /* actionTitle */,
|
||||
isWifiEnabled));
|
||||
}
|
||||
return builder;
|
||||
}
|
||||
|
||||
private ListBuilder.RowBuilder getAccessPointRow(AccessPoint accessPoint) {
|
||||
@@ -200,7 +204,7 @@ public class WifiSlice implements CustomSliceable {
|
||||
return TextUtils.isEmpty(summary) ? mContext.getText(R.string.disconnected) : summary;
|
||||
}
|
||||
|
||||
private IconCompat getAccessPointLevelIcon(AccessPoint accessPoint) {
|
||||
protected IconCompat getAccessPointLevelIcon(AccessPoint accessPoint) {
|
||||
final Drawable d = mContext.getDrawable(
|
||||
com.android.settingslib.Utils.getWifiIconResource(accessPoint.getLevel()));
|
||||
|
||||
@@ -250,24 +254,16 @@ public class WifiSlice implements CustomSliceable {
|
||||
accessPoint.saveWifiState(extras);
|
||||
|
||||
if (accessPoint.isActive()) {
|
||||
Intent intent;
|
||||
final SubSettingLauncher launcher = new SubSettingLauncher(mContext)
|
||||
.setTitleRes(R.string.pref_title_network_details)
|
||||
.setArguments(extras)
|
||||
.setSourceMetricsCategory(SettingsEnums.WIFI);
|
||||
if (FeatureFlagUtils.isEnabled(mContext, FeatureFlagUtils.SETTINGS_WIFITRACKER2)) {
|
||||
intent = new SubSettingLauncher(mContext)
|
||||
.setTitleRes(R.string.pref_title_network_details)
|
||||
.setDestination(WifiNetworkDetailsFragment2.class.getName())
|
||||
.setArguments(extras)
|
||||
.setSourceMetricsCategory(SettingsEnums.WIFI)
|
||||
.toIntent();
|
||||
return getActivityAction(requestCode, intent, icon, title);
|
||||
launcher.setDestination(WifiNetworkDetailsFragment2.class.getName());
|
||||
} else {
|
||||
intent = new SubSettingLauncher(mContext)
|
||||
.setTitleRes(R.string.pref_title_network_details)
|
||||
.setDestination(WifiNetworkDetailsFragment.class.getName())
|
||||
.setArguments(extras)
|
||||
.setSourceMetricsCategory(SettingsEnums.WIFI)
|
||||
.toIntent();
|
||||
return getActivityAction(requestCode, intent, icon, title);
|
||||
launcher.setDestination(WifiNetworkDetailsFragment.class.getName());
|
||||
}
|
||||
return getActivityAction(requestCode, launcher.toIntent(), icon, title);
|
||||
} else if (WifiUtils.getConnectingType(accessPoint) != WifiUtils.CONNECT_TYPE_OTHERS) {
|
||||
final Intent intent = new Intent(mContext, ConnectToWifiHandler.class)
|
||||
.putExtra(WifiDialogActivity.KEY_ACCESS_POINT_STATE, extras);
|
||||
@@ -307,7 +303,7 @@ public class WifiSlice implements CustomSliceable {
|
||||
.setSubtitle(title);
|
||||
}
|
||||
|
||||
private boolean isCaptivePortal() {
|
||||
protected boolean isCaptivePortal() {
|
||||
final NetworkCapabilities nc = mConnectivityManager.getNetworkCapabilities(
|
||||
mWifiManager.getCurrentNetwork());
|
||||
return WifiUtils.canSignIntoNetwork(nc);
|
||||
|
Reference in New Issue
Block a user