[DO NOT MERGE] Update contextual cards display mechanism

1. Make Wi-Fi card default to collapse.
2. Support showing a default card when there's no displayable card.
3. Solve the problem of icon not showing for cached slices in card
renderer

Bug: 163288869
Fixes: 159092915
Test: manual, robotest
Change-Id: Ie8b61ad58410337334e29b7a794353b0c6a6ba8c
This commit is contained in:
Jason Chiu
2020-08-10 23:38:15 +08:00
parent 27f7aae886
commit b824187524
6 changed files with 57 additions and 10 deletions

View File

@@ -25,6 +25,7 @@ import android.net.NetworkInfo.State;
import android.net.Uri;
import android.net.wifi.WifiInfo;
import android.net.wifi.WifiManager;
import android.provider.Settings;
import android.text.TextUtils;
import androidx.annotation.VisibleForTesting;
@@ -44,6 +45,9 @@ import com.android.settingslib.wifi.AccessPoint;
*/
public class ContextualWifiSlice extends WifiSlice {
@VisibleForTesting
static final String CONTEXTUAL_WIFI_EXPANDABLE = "contextual_wifi_expandable";
@VisibleForTesting
static final int COLLAPSED_ROW_COUNT = 0;
@@ -63,13 +67,17 @@ public class ContextualWifiSlice extends WifiSlice {
@Override
public Slice getSlice() {
final long currentUiSession = FeatureFactory.getFactory(mContext)
.getSlicesFeatureProvider().getUiSessionToken();
if (currentUiSession != sActiveUiSession) {
sActiveUiSession = currentUiSession;
sApRowCollapsed = hasWorkingNetwork();
} else if (!mWifiManager.isWifiEnabled()) {
sApRowCollapsed = false;
if (isExpandable()) {
final long currentUiSession = FeatureFactory.getFactory(mContext)
.getSlicesFeatureProvider().getUiSessionToken();
if (currentUiSession != sActiveUiSession) {
sActiveUiSession = currentUiSession;
sApRowCollapsed = hasWorkingNetwork();
} else if (!mWifiManager.isWifiEnabled()) {
sApRowCollapsed = false;
}
} else {
sApRowCollapsed = true;
}
return super.getSlice();
}
@@ -87,12 +95,18 @@ public class ContextualWifiSlice extends WifiSlice {
protected ListBuilder.RowBuilder getHeaderRow(boolean isWifiEnabled, AccessPoint accessPoint) {
final ListBuilder.RowBuilder builder = super.getHeaderRow(isWifiEnabled, accessPoint);
builder.setTitleItem(getHeaderIcon(isWifiEnabled, accessPoint), ListBuilder.ICON_IMAGE);
if (sApRowCollapsed) {
if (sApRowCollapsed && isWifiEnabled) {
builder.setSubtitle(getSubtitle(accessPoint));
}
return builder;
}
private boolean isExpandable() {
// Return whether this slice can be expandable.
return Settings.Global.getInt(mContext.getContentResolver(), CONTEXTUAL_WIFI_EXPANDABLE, 0)
!= 0;
}
private IconCompat getHeaderIcon(boolean isWifiEnabled, AccessPoint accessPoint) {
final Drawable drawable;
final int tint;