Merge "Show Instant Tether network icon" into udc-qpr-dev am: 8cdbeab57c am: 988568f64b

Original change: https://googleplex-android-review.googlesource.com/c/platform/packages/apps/Settings/+/24122143

Change-Id: Ib363d47fc121b1f1c1c0f63f5f5d0906ae783607
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
Weng Su
2023-07-20 16:08:02 +00:00
committed by Automerger Merge Worker
2 changed files with 58 additions and 15 deletions

View File

@@ -15,6 +15,8 @@
*/
package com.android.settings.wifi;
import static com.android.settingslib.wifi.WifiUtils.getHotspotIconResource;
import android.annotation.Nullable;
import android.content.Context;
import android.content.res.Resources;
@@ -37,6 +39,7 @@ import com.android.settingslib.RestrictedPreference;
import com.android.settingslib.Utils;
import com.android.settingslib.wifi.WifiUtils;
import com.android.wifitrackerlib.BaseWifiTracker;
import com.android.wifitrackerlib.HotspotNetworkEntry;
import com.android.wifitrackerlib.WifiEntry;
/**
@@ -145,13 +148,17 @@ public class WifiEntryPreference extends RestrictedPreference implements
*/
public void refresh() {
setTitle(mWifiEntry.getTitle());
final int level = mWifiEntry.getLevel();
final boolean showX = mWifiEntry.shouldShowXLevelIcon();
if (level != mLevel || showX != mShowX) {
mLevel = level;
mShowX = showX;
updateIcon(mShowX, mLevel);
notifyChanged();
if (mWifiEntry instanceof HotspotNetworkEntry) {
updateHotspotIcon(((HotspotNetworkEntry) mWifiEntry).getDeviceType());
} else {
int level = mWifiEntry.getLevel();
boolean showX = mWifiEntry.shouldShowXLevelIcon();
if (level != mLevel || showX != mShowX) {
mLevel = level;
mShowX = showX;
updateIcon(mShowX, mLevel);
}
}
setSummary(mWifiEntry.getSummary(false /* concise */));
@@ -201,14 +208,7 @@ public class WifiEntryPreference extends RestrictedPreference implements
return accent ? android.R.attr.colorAccent : android.R.attr.colorControlNormal;
}
@VisibleForTesting
void updateIcon(boolean showX, int level) {
if (level == -1) {
setIcon(null);
return;
}
final Drawable drawable = mIconInjector.getIcon(showX, level);
private void setIconWithTint(Drawable drawable) {
if (drawable != null) {
// Must use Drawable#setTintList() instead of Drawable#setTint() to show the grey
// icon when the preference is disabled.
@@ -219,6 +219,20 @@ public class WifiEntryPreference extends RestrictedPreference implements
}
}
@VisibleForTesting
void updateIcon(boolean showX, int level) {
if (level == -1) {
setIcon(null);
return;
}
setIconWithTint(mIconInjector.getIcon(showX, level));
}
@VisibleForTesting
void updateHotspotIcon(int deviceType) {
setIconWithTint(getContext().getDrawable(getHotspotIconResource(deviceType)));
}
@Nullable
private StateListDrawable getFrictionStateListDrawable() {
TypedArray frictionSld;