Merge "Show Hotspot network icon (Wi-Fi Slice)" into udc-qpr-dev am: f5023f3805
am: e456621260
Original change: https://googleplex-android-review.googlesource.com/c/platform/packages/apps/Settings/+/24533568 Change-Id: Ie548f74405de03e73686abbd13f3fc4bb308209c Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
@@ -20,6 +20,7 @@ import static android.app.slice.Slice.EXTRA_TOGGLE_STATE;
|
||||
import static android.provider.SettingsSlicesContract.KEY_WIFI;
|
||||
|
||||
import static com.android.settings.slices.CustomSliceRegistry.WIFI_SLICE_URI;
|
||||
import static com.android.settingslib.wifi.WifiUtils.getHotspotIconResource;
|
||||
|
||||
import android.annotation.ColorInt;
|
||||
import android.app.PendingIntent;
|
||||
@@ -264,13 +265,19 @@ public class WifiSlice implements CustomSliceable {
|
||||
android.R.attr.colorControlNormal));
|
||||
}
|
||||
|
||||
final Drawable drawable = mContext.getDrawable(
|
||||
WifiUtils.getInternetIconResource(wifiSliceItem.getLevel(),
|
||||
wifiSliceItem.shouldShowXLevelIcon()));
|
||||
Drawable drawable = mContext.getDrawable(getWifiIconResId(wifiSliceItem));
|
||||
drawable.setTint(tint);
|
||||
return Utils.createIconWithDrawable(drawable);
|
||||
}
|
||||
|
||||
@VisibleForTesting
|
||||
int getWifiIconResId(WifiSliceItem wifiSliceItem) {
|
||||
return (wifiSliceItem.isInstantHotspotNetwork())
|
||||
? getHotspotIconResource(wifiSliceItem.getInstantHotspotDeviceType())
|
||||
: WifiUtils.getInternetIconResource(wifiSliceItem.getLevel(),
|
||||
wifiSliceItem.shouldShowXLevelIcon());
|
||||
}
|
||||
|
||||
protected IconCompat getEndIcon(WifiSliceItem wifiSliceItem) {
|
||||
if (wifiSliceItem.getConnectedState() != WifiEntry.CONNECTED_STATE_DISCONNECTED) {
|
||||
return IconCompat.createWithResource(mContext, R.drawable.ic_settings_24dp);
|
||||
|
@@ -20,6 +20,7 @@ import android.content.Context;
|
||||
import android.text.TextUtils;
|
||||
|
||||
import com.android.settingslib.R;
|
||||
import com.android.wifitrackerlib.HotspotNetworkEntry;
|
||||
import com.android.wifitrackerlib.WifiEntry;
|
||||
|
||||
/**
|
||||
@@ -39,6 +40,9 @@ public class WifiSliceItem {
|
||||
private final boolean mHasInternetAccess;
|
||||
private final String mSummary;
|
||||
|
||||
private boolean mIsInstantHotspotNetwork;
|
||||
private int mInstantHotspotDeviceType;
|
||||
|
||||
// These values must be kept within [WifiEntry.WIFI_LEVEL_MIN, WifiEntry.WIFI_LEVEL_MAX]
|
||||
private static final int[] WIFI_CONNECTION_STRENGTH = {
|
||||
R.string.accessibility_no_wifi,
|
||||
@@ -59,6 +63,10 @@ public class WifiSliceItem {
|
||||
mShouldEditBeforeConnect = wifiEntry.shouldEditBeforeConnect();
|
||||
mHasInternetAccess = wifiEntry.hasInternetAccess();
|
||||
mSummary = wifiEntry.getSummary(false /* concise */);
|
||||
mIsInstantHotspotNetwork = wifiEntry instanceof HotspotNetworkEntry;
|
||||
if (mIsInstantHotspotNetwork) {
|
||||
mInstantHotspotDeviceType = ((HotspotNetworkEntry) wifiEntry).getDeviceType();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -83,6 +91,12 @@ public class WifiSliceItem {
|
||||
if (!TextUtils.equals(getSummary(), otherItem.getSummary())) {
|
||||
return false;
|
||||
}
|
||||
if (isInstantHotspotNetwork() != otherItem.isInstantHotspotNetwork()) {
|
||||
return false;
|
||||
}
|
||||
if (getInstantHotspotDeviceType() != otherItem.getInstantHotspotDeviceType()) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -136,6 +150,20 @@ public class WifiSliceItem {
|
||||
return mSummary;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if this is a Instant Hotspot network.
|
||||
*/
|
||||
public boolean isInstantHotspotNetwork() {
|
||||
return mIsInstantHotspotNetwork;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns DeviceType of Instant Hotspot network.
|
||||
*/
|
||||
public int getInstantHotspotDeviceType() {
|
||||
return mInstantHotspotDeviceType;
|
||||
}
|
||||
|
||||
/**
|
||||
* This method has similar code as WifiEntryPreference#buildContentDescription().
|
||||
* TODO(b/154191825): Adds WifiEntry#getContentDescription() to replace the duplicate code.
|
||||
|
Reference in New Issue
Block a user