Using roundIconRes for loading appInfo icon if launcher's icon is round
Bug: 392145015 Flag: EXEMPT not-supported during overlay change Test: Verified manually on device Change-Id: I7aa571e12318c28f8ff373c19a84d4856c57d6c5
This commit is contained in:
@@ -192,4 +192,6 @@ open class SystemApiWrapper @Inject constructor(@ApplicationContext context: Con
|
||||
|
||||
override fun getApplicationInfoHash(appInfo: ApplicationInfo): String =
|
||||
(appInfo.sourceDir?.hashCode() ?: 0).toString() + " " + appInfo.longVersionCode
|
||||
|
||||
override fun getRoundIconRes(appInfo: ApplicationInfo) = appInfo.roundIconRes
|
||||
}
|
||||
|
||||
@@ -126,7 +126,6 @@ constructor(
|
||||
): ValueAnimator where T : View, T : ClipPathView
|
||||
}
|
||||
|
||||
@VisibleForTesting
|
||||
class Circle : RoundedSquare(1f) {
|
||||
|
||||
override fun drawShape(
|
||||
|
||||
@@ -19,14 +19,18 @@ import android.content.Context;
|
||||
import android.content.pm.ApplicationInfo;
|
||||
import android.content.res.Resources;
|
||||
import android.content.res.XmlResourceParser;
|
||||
import android.graphics.drawable.AdaptiveIconDrawable;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.text.TextUtils;
|
||||
import android.util.ArrayMap;
|
||||
import android.util.Log;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
import com.android.launcher3.R;
|
||||
import com.android.launcher3.config.FeatureFlags;
|
||||
import com.android.launcher3.graphics.IconShape;
|
||||
import com.android.launcher3.graphics.ThemeManager;
|
||||
import com.android.launcher3.util.ApiWrapper;
|
||||
|
||||
@@ -49,9 +53,14 @@ public class LauncherIconProvider extends IconProvider {
|
||||
|
||||
private Map<String, ThemeData> mThemedIconMap;
|
||||
|
||||
private final ApiWrapper mApiWrapper;
|
||||
private final IconShape mIconShape;
|
||||
|
||||
public LauncherIconProvider(Context context) {
|
||||
super(context);
|
||||
setIconThemeSupported(ThemeManager.INSTANCE.get(context).isMonoThemeEnabled());
|
||||
mApiWrapper = ApiWrapper.INSTANCE.get(context);
|
||||
mIconShape = IconShape.INSTANCE.get(context);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -75,7 +84,25 @@ public class LauncherIconProvider extends IconProvider {
|
||||
|
||||
@Override
|
||||
protected String getApplicationInfoHash(@NonNull ApplicationInfo appInfo) {
|
||||
return ApiWrapper.INSTANCE.get(mContext).getApplicationInfoHash(appInfo);
|
||||
return mApiWrapper.getApplicationInfoHash(appInfo);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
protected Drawable loadAppInfoIcon(ApplicationInfo info, Resources resources, int density) {
|
||||
// Tries to load the round icon res, if the app defines it as an adaptive icon
|
||||
if (mIconShape.getShape() instanceof IconShape.Circle) {
|
||||
int roundIconRes = mApiWrapper.getRoundIconRes(info);
|
||||
if (roundIconRes != 0 && roundIconRes != info.icon) {
|
||||
try {
|
||||
Drawable d = resources.getDrawableForDensity(roundIconRes, density);
|
||||
if (d instanceof AdaptiveIconDrawable) {
|
||||
return d;
|
||||
}
|
||||
} catch (Resources.NotFoundException exc) { }
|
||||
}
|
||||
}
|
||||
return super.loadAppInfoIcon(info, resources, density);
|
||||
}
|
||||
|
||||
private Map<String, ThemeData> getThemedIconMap() {
|
||||
|
||||
@@ -171,6 +171,13 @@ public class ApiWrapper {
|
||||
return appInfo.sourceDir;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the round icon resource Id if defined by the app
|
||||
*/
|
||||
public int getRoundIconRes(@NonNull ApplicationInfo appInfo) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
private static class NoopDrawable extends ColorDrawable {
|
||||
@Override
|
||||
public int getIntrinsicHeight() {
|
||||
|
||||
Reference in New Issue
Block a user