Removing AdaptiveIconDrawable Checks

As part of the internal cleanup for adaptive icons, we are removing if checks for AdaptiveIconDrawable that are no longer necessary. Also refactoring to follow a more functional programming pattern for easier future refactors.

Bug: 318867282
Flag: EXEMPT BUGFIX
Test: AllAppsSearchImageTest
Change-Id: Id13040bc4fd2ca7e85583d727b228ee390eadc91
This commit is contained in:
Andrew Cole committed 2024-05-20 11:01:51 -07:00
1 parent bc549958d9
commit cdfa5e6b33
2 files changed
+8 -15

No files matched your search

@@ -17,6 +17,7 @@
package com.android.launcher3.icons;
import android.content.Context;
import android.graphics.drawable.AdaptiveIconDrawable;
import android.graphics.drawable.Drawable;
import android.os.UserHandle;
@@ -101,7 +102,7 @@ public class LauncherIcons extends BaseIconFactory implements AutoCloseable {
}
@Override
protected Drawable getMonochromeDrawable(Drawable base) {
protected Drawable getMonochromeDrawable(AdaptiveIconDrawable base) {
Drawable mono = super.getMonochromeDrawable(base);
if (mono != null || !Flags.forceMonochromeAppIcons()) {
return mono;
@@ -100,20 +100,12 @@ public class MonochromeIconFactory extends Drawable {
* Creates a monochrome version of the provided drawable
*/
@WorkerThread
public Drawable wrap(Drawable icon) {
if (icon instanceof AdaptiveIconDrawable) {
AdaptiveIconDrawable aid = (AdaptiveIconDrawable) icon;
mFlatCanvas.drawColor(Color.BLACK);
drawDrawable(aid.getBackground());
drawDrawable(aid.getForeground());
generateMono();
return new ClippedMonoDrawable(this);
} else {
mFlatCanvas.drawColor(Color.WHITE);
drawDrawable(icon);
generateMono();
return this;
}
public Drawable wrap(AdaptiveIconDrawable icon) {
mFlatCanvas.drawColor(Color.BLACK);
drawDrawable(icon.getBackground());
drawDrawable(icon.getForeground());
generateMono();
return new ClippedMonoDrawable(this);
}
@WorkerThread