Merge "Temporarily disable shapes flag for tests that it breaks." into main
diff --git a/quickstep/src/com/android/launcher3/taskbar/TaskbarUIController.java b/quickstep/src/com/android/launcher3/taskbar/TaskbarUIController.java
index e5d642d..89bcb41 100644
--- a/quickstep/src/com/android/launcher3/taskbar/TaskbarUIController.java
+++ b/quickstep/src/com/android/launcher3/taskbar/TaskbarUIController.java
@@ -283,7 +283,7 @@
foundTask,
taskContainer.getIconView().getDrawable(),
taskContainer.getSnapshotView(),
- taskContainer.getSplitAnimationThumbnail(),
+ taskContainer.getThumbnail(),
null /* intent */,
null /* user */,
info);
diff --git a/quickstep/src/com/android/quickstep/TaskShortcutFactory.java b/quickstep/src/com/android/quickstep/TaskShortcutFactory.java
index 7990aae..a69d472 100644
--- a/quickstep/src/com/android/quickstep/TaskShortcutFactory.java
+++ b/quickstep/src/com/android/quickstep/TaskShortcutFactory.java
@@ -236,15 +236,14 @@
position[0] + width, position[1] + height);
// Take the thumbnail of the task without a scrim and apply it back after
- // TODO(b/348643341) add ability to get override the scrim for this Bitmap retrieval
- float alpha = 0f;
- if (!enableRefactorTaskThumbnail()) {
- alpha = mTaskContainer.getThumbnailViewDeprecated().getDimAlpha();
+ Bitmap thumbnail;
+ if (enableRefactorTaskThumbnail()) {
+ thumbnail = mTaskContainer.getThumbnail();
+ } else {
+ float alpha = mTaskContainer.getThumbnailViewDeprecated().getDimAlpha();
mTaskContainer.getThumbnailViewDeprecated().setDimAlpha(0);
- }
- Bitmap thumbnail = RecentsTransition.drawViewIntoHardwareBitmap(
- taskBounds.width(), taskBounds.height(), snapShotView, 1f, Color.BLACK);
- if (!enableRefactorTaskThumbnail()) {
+ thumbnail = RecentsTransition.drawViewIntoHardwareBitmap(
+ taskBounds.width(), taskBounds.height(), snapShotView, 1f, Color.BLACK);
mTaskContainer.getThumbnailViewDeprecated().setDimAlpha(alpha);
}
diff --git a/quickstep/src/com/android/quickstep/util/SplitAnimationController.kt b/quickstep/src/com/android/quickstep/util/SplitAnimationController.kt
index 88d14b7..a1963c9 100644
--- a/quickstep/src/com/android/quickstep/util/SplitAnimationController.kt
+++ b/quickstep/src/com/android/quickstep/util/SplitAnimationController.kt
@@ -127,7 +127,7 @@
val drawable = getDrawable(container.iconView, splitSelectSource)
return SplitAnimInitProps(
container.snapshotView,
- container.splitAnimationThumbnail,
+ container.thumbnail,
drawable,
fadeWithThumbnail = true,
isStagedTask = true,
@@ -147,7 +147,7 @@
val drawable = getDrawable(it.iconView, splitSelectSource)
return SplitAnimInitProps(
it.snapshotView,
- it.splitAnimationThumbnail,
+ it.thumbnail,
drawable,
fadeWithThumbnail = true,
isStagedTask = true,
diff --git a/quickstep/src/com/android/quickstep/views/TaskContainer.kt b/quickstep/src/com/android/quickstep/views/TaskContainer.kt
index bbe1af4..ef85aa1 100644
--- a/quickstep/src/com/android/quickstep/views/TaskContainer.kt
+++ b/quickstep/src/com/android/quickstep/views/TaskContainer.kt
@@ -75,7 +75,9 @@
}
internal var thumbnailData: ThumbnailData? = null
- val splitAnimationThumbnail: Bitmap?
+
+ val thumbnail: Bitmap?
+ /** If possible don't use this. It should be replaced as part of b/331753115. */
get() =
if (enableRefactorTaskThumbnail()) thumbnailData?.thumbnail
else thumbnailViewDeprecated.thumbnail
diff --git a/quickstep/src/com/android/quickstep/views/TaskView.kt b/quickstep/src/com/android/quickstep/views/TaskView.kt
index 56a35bd..39c15b1 100644
--- a/quickstep/src/com/android/quickstep/views/TaskView.kt
+++ b/quickstep/src/com/android/quickstep/views/TaskView.kt
@@ -1397,7 +1397,7 @@
container.task,
container.iconView.drawable,
container.snapshotView,
- container.splitAnimationThumbnail,
+ container.thumbnail,
/* intent */ null,
/* user */ null,
container.itemInfo,
diff --git a/quickstep/tests/multivalentTests/src/com/android/quickstep/util/SplitAnimationControllerTest.kt b/quickstep/tests/multivalentTests/src/com/android/quickstep/util/SplitAnimationControllerTest.kt
index 5051251..9d000a4 100644
--- a/quickstep/tests/multivalentTests/src/com/android/quickstep/util/SplitAnimationControllerTest.kt
+++ b/quickstep/tests/multivalentTests/src/com/android/quickstep/util/SplitAnimationControllerTest.kt
@@ -89,7 +89,7 @@
@Before
fun setup() {
whenever(mockTaskContainer.snapshotView).thenReturn(mockSnapshotView)
- whenever(mockTaskContainer.splitAnimationThumbnail).thenReturn(mockBitmap)
+ whenever(mockTaskContainer.thumbnail).thenReturn(mockBitmap)
whenever(mockTaskContainer.iconView).thenReturn(mockIconView)
whenever(mockTaskContainer.task).thenReturn(mockTask)
whenever(mockIconView.drawable).thenReturn(mockTaskViewDrawable)
@@ -117,7 +117,7 @@
assertEquals(
"Did not fallback to use splitSource icon drawable",
mockSplitSourceDrawable,
- splitAnimInitProps.iconDrawable
+ splitAnimInitProps.iconDrawable,
)
}
@@ -133,7 +133,7 @@
assertEquals(
"Did not use taskView icon drawable",
mockTaskViewDrawable,
- splitAnimInitProps.iconDrawable
+ splitAnimInitProps.iconDrawable,
)
}
@@ -152,7 +152,7 @@
assertEquals(
"Did not use taskView icon drawable",
mockTaskViewDrawable,
- splitAnimInitProps.iconDrawable
+ splitAnimInitProps.iconDrawable,
)
}
@@ -168,7 +168,7 @@
assertEquals(
"Did not use splitSource icon drawable",
mockSplitSourceDrawable,
- splitAnimInitProps.iconDrawable
+ splitAnimInitProps.iconDrawable,
)
}
@@ -190,13 +190,13 @@
val splitAnimInitProps: SplitAnimationController.Companion.SplitAnimInitProps =
splitAnimationController.getFirstAnimInitViews(
{ mockGroupedTaskView },
- { splitSelectSource }
+ { splitSelectSource },
)
assertEquals(
"Did not use splitSource icon drawable",
mockSplitSourceDrawable,
- splitAnimInitProps.iconDrawable
+ splitAnimInitProps.iconDrawable,
)
}
@@ -214,7 +214,7 @@
any(),
any(),
any(),
- any()
+ any(),
)
spySplitAnimationController.playSplitLaunchAnimation(
@@ -230,7 +230,7 @@
null /* info */,
null /* t */,
{} /* finishCallback */,
- 1f /* cornerRadius */
+ 1f, /* cornerRadius */
)
verify(spySplitAnimationController)
@@ -243,7 +243,7 @@
any(),
any(),
any(),
- any()
+ any(),
)
}
@@ -267,7 +267,7 @@
transitionInfo,
transaction,
{} /* finishCallback */,
- 1f /* cornerRadius */
+ 1f, /* cornerRadius */
)
verify(spySplitAnimationController)
@@ -296,7 +296,7 @@
transitionInfo,
transaction,
{} /* finishCallback */,
- 1f /* cornerRadius */
+ 1f, /* cornerRadius */
)
verify(spySplitAnimationController)
@@ -325,7 +325,7 @@
transitionInfo,
transaction,
{} /* finishCallback */,
- 1f /* cornerRadius */
+ 1f, /* cornerRadius */
)
verify(spySplitAnimationController)
@@ -353,7 +353,7 @@
transitionInfo,
transaction,
{} /* finishCallback */,
- 1f /* cornerRadius */
+ 1f, /* cornerRadius */
)
verify(spySplitAnimationController)
@@ -381,7 +381,7 @@
transitionInfo,
transaction,
{} /* finishCallback */,
- 1f /* cornerRadius */
+ 1f, /* cornerRadius */
)
verify(spySplitAnimationController)
@@ -408,7 +408,7 @@
transitionInfo,
transaction,
{} /* finishCallback */,
- 1f /* cornerRadius */
+ 1f, /* cornerRadius */
)
verify(spySplitAnimationController)
diff --git a/src/com/android/launcher3/dagger/LauncherBaseAppComponent.java b/src/com/android/launcher3/dagger/LauncherBaseAppComponent.java
index 87b5459..35ae68f 100644
--- a/src/com/android/launcher3/dagger/LauncherBaseAppComponent.java
+++ b/src/com/android/launcher3/dagger/LauncherBaseAppComponent.java
@@ -22,6 +22,7 @@
import com.android.launcher3.LauncherPrefs;
import com.android.launcher3.graphics.IconShape;
import com.android.launcher3.graphics.ThemeManager;
+import com.android.launcher3.icons.LauncherIcons.IconPool;
import com.android.launcher3.model.ItemInstallQueue;
import com.android.launcher3.pm.InstallSessionHelper;
import com.android.launcher3.pm.UserCache;
@@ -74,6 +75,7 @@
WallpaperColorHints getWallpaperColorHints();
LockedUserState getLockedUserState();
InvariantDeviceProfile getIDP();
+ IconPool getIconPool();
/** Builder for LauncherBaseAppComponent. */
interface Builder {
diff --git a/src/com/android/launcher3/graphics/ThemeManager.kt b/src/com/android/launcher3/graphics/ThemeManager.kt
index 1636da8..e767290 100644
--- a/src/com/android/launcher3/graphics/ThemeManager.kt
+++ b/src/com/android/launcher3/graphics/ThemeManager.kt
@@ -106,6 +106,7 @@
iconMask = iconMask,
folderShapeMask = shapeModel?.folderPathString ?: iconMask,
themeController = createThemeController(),
+ iconScale = shapeModel?.iconScale ?: 1f,
)
}
@@ -118,6 +119,7 @@
val folderShapeMask: String,
val themeController: IconThemeController?,
val themeCode: String = themeController?.themeID ?: "no-theme",
+ val iconScale: Float = 1f,
) {
fun toUniqueId() = "${iconMask.hashCode()},$themeCode"
}
diff --git a/src/com/android/launcher3/icons/LauncherIcons.kt b/src/com/android/launcher3/icons/LauncherIcons.kt
index 518f29d..d173fd6 100644
--- a/src/com/android/launcher3/icons/LauncherIcons.kt
+++ b/src/com/android/launcher3/icons/LauncherIcons.kt
@@ -24,29 +24,38 @@
import android.os.UserHandle
import com.android.launcher3.Flags
import com.android.launcher3.InvariantDeviceProfile
-import com.android.launcher3.LauncherPrefs
+import com.android.launcher3.dagger.ApplicationContext
+import com.android.launcher3.dagger.LauncherAppSingleton
+import com.android.launcher3.dagger.LauncherComponentProvider.appComponent
import com.android.launcher3.graphics.IconShape
import com.android.launcher3.graphics.ThemeManager
import com.android.launcher3.pm.UserCache
-import com.android.launcher3.util.MainThreadInitializedObject
-import com.android.launcher3.util.SafeCloseable
import com.android.launcher3.util.UserIconInfo
+import dagger.assisted.Assisted
+import dagger.assisted.AssistedFactory
+import dagger.assisted.AssistedInject
import java.util.concurrent.ConcurrentLinkedQueue
+import javax.inject.Inject
/**
* Wrapper class to provide access to [BaseIconFactory] and also to provide pool of this class that
* are threadsafe.
*/
class LauncherIcons
-protected constructor(
- context: Context,
- fillResIconDpi: Int,
- iconBitmapSize: Int,
- private val pool: ConcurrentLinkedQueue<LauncherIcons>,
-) : BaseIconFactory(context, fillResIconDpi, iconBitmapSize), AutoCloseable {
+@AssistedInject
+internal constructor(
+ @ApplicationContext context: Context,
+ idp: InvariantDeviceProfile,
+ themeManager: ThemeManager,
+ private var userCache: UserCache,
+ private var iconShape: IconShape,
+ @Assisted private val pool: ConcurrentLinkedQueue<LauncherIcons>,
+) : BaseIconFactory(context, idp.fillResIconDpi, idp.iconBitmapSize), AutoCloseable {
+
+ private val iconScale = themeManager.iconState.iconScale
init {
- mThemeController = ThemeManager.INSTANCE[context].themeController
+ mThemeController = themeManager.themeController
}
/** Recycles a LauncherIcons that may be in-use. */
@@ -56,12 +65,12 @@
}
override fun getUserInfo(user: UserHandle): UserIconInfo {
- return UserCache.INSTANCE[mContext].getUserInfo(user)
+ return userCache.getUserInfo(user)
}
public override fun getShapePath(drawable: AdaptiveIconDrawable, iconBounds: Rect): Path {
if (!Flags.enableLauncherIconShapes()) return drawable.iconMask
- return IconShape.INSTANCE[mContext].shape.getPath(iconBounds)
+ return iconShape.shape.getPath(iconBounds)
}
override fun drawAdaptiveIcon(
@@ -73,14 +82,6 @@
super.drawAdaptiveIcon(canvas, drawable, overridePath)
return
}
- val shapeKey = LauncherPrefs.get(mContext).get(ThemeManager.PREF_ICON_SHAPE)
- val iconScale =
- when (shapeKey) {
- "seven_sided_cookie" -> SEVEN_SIDED_COOKIE_SCALE
- "four_sided_cookie" -> FOUR_SIDED_COOKIE_SCALE
- "sunny" -> VERY_SUNNY_SCALE
- else -> DEFAULT_ICON_SCALE
- }
canvas.clipPath(overridePath)
canvas.drawColor(Color.BLACK)
canvas.save()
@@ -98,42 +99,31 @@
recycle()
}
- private class Pool(private val context: Context) : SafeCloseable {
+ @AssistedFactory
+ internal interface LauncherIconsFactory {
+ fun create(pool: ConcurrentLinkedQueue<LauncherIcons>): LauncherIcons
+ }
+
+ @LauncherAppSingleton
+ class IconPool @Inject internal constructor(private val factory: LauncherIconsFactory) {
private var pool = ConcurrentLinkedQueue<LauncherIcons>()
- fun obtain(): LauncherIcons {
- val pool = pool
- return pool.poll()
- ?: InvariantDeviceProfile.INSTANCE[context].let {
- LauncherIcons(context, it.fillResIconDpi, it.iconBitmapSize, pool)
- }
- }
+ fun obtain(): LauncherIcons = pool.let { it.poll() ?: factory.create(it) }
- override fun close() {
+ fun clear() {
pool = ConcurrentLinkedQueue()
}
}
companion object {
- private const val SEVEN_SIDED_COOKIE_SCALE = 72f / 80f
- private const val FOUR_SIDED_COOKIE_SCALE = 72f / 83.4f
- private const val VERY_SUNNY_SCALE = 72f / 92f
- private const val DEFAULT_ICON_SCALE = 1f
-
- private val POOL = MainThreadInitializedObject { Pool(it) }
/**
- * Return a new Message instance from the global pool. Allows us to avoid allocating new
- * objects in many cases.
+ * Return a new LauncherIcons instance from the global pool. Allows us to avoid allocating
+ * new objects in many cases.
*/
@JvmStatic
- fun obtain(context: Context): LauncherIcons {
- return POOL[context].obtain()
- }
+ fun obtain(context: Context): LauncherIcons = context.appComponent.iconPool.obtain()
- @JvmStatic
- fun clearPool(context: Context) {
- POOL[context].close()
- }
+ @JvmStatic fun clearPool(context: Context) = context.appComponent.iconPool.clear()
}
}
diff --git a/src/com/android/launcher3/shapes/IconShapeModel.kt b/src/com/android/launcher3/shapes/IconShapeModel.kt
index dd6c432..fc49adc 100644
--- a/src/com/android/launcher3/shapes/IconShapeModel.kt
+++ b/src/com/android/launcher3/shapes/IconShapeModel.kt
@@ -21,4 +21,5 @@
val title: String,
val pathString: String,
val folderPathString: String = pathString,
+ val iconScale: Float = 1f,
)
diff --git a/src/com/android/launcher3/shapes/ShapesProvider.kt b/src/com/android/launcher3/shapes/ShapesProvider.kt
index 7e1f640..463c816 100644
--- a/src/com/android/launcher3/shapes/ShapesProvider.kt
+++ b/src/com/android/launcher3/shapes/ShapesProvider.kt
@@ -174,6 +174,7 @@
pathString =
"M39.888,4.517C46.338 7.319 53.662 7.319 60.112 4.517L63.605 3C84.733 -6.176 106.176 15.268 97 36.395L95.483 39.888C92.681 46.338 92.681 53.662 95.483 60.112L97 63.605C106.176 84.732 84.733 106.176 63.605 97L60.112 95.483C53.662 92.681 46.338 92.681 39.888 95.483L36.395 97C15.267 106.176 -6.176 84.732 3 63.605L4.517 60.112C7.319 53.662 7.319 46.338 4.517 39.888L3 36.395C -6.176 15.268 15.267 -6.176 36.395 3Z",
folderPathString = folderShapes["complexClover"]!!,
+ iconScale = 72f / 83.4f,
),
"seven_sided_cookie" to
IconShapeModel(
@@ -182,6 +183,7 @@
pathString =
"M35.209 4.878C36.326 3.895 36.884 3.404 37.397 3.006 44.82 -2.742 55.18 -2.742 62.603 3.006 63.116 3.404 63.674 3.895 64.791 4.878 65.164 5.207 65.351 5.371 65.539 5.529 68.167 7.734 71.303 9.248 74.663 9.932 74.902 9.981 75.147 10.025 75.637 10.113 77.1 10.375 77.831 10.506 78.461 10.66 87.573 12.893 94.032 21.011 94.176 30.412 94.186 31.062 94.151 31.805 94.08 33.293 94.057 33.791 94.045 34.04 94.039 34.285 93.958 37.72 94.732 41.121 96.293 44.18 96.404 44.399 96.522 44.618 96.759 45.056 97.467 46.366 97.821 47.021 98.093 47.611 102.032 56.143 99.727 66.266 92.484 72.24 91.983 72.653 91.381 73.089 90.177 73.961 89.774 74.254 89.572 74.4 89.377 74.548 86.647 76.626 84.477 79.353 83.063 82.483 82.962 82.707 82.865 82.936 82.671 83.395 82.091 84.766 81.8 85.451 81.51 86.033 77.31 94.44 67.977 98.945 58.801 96.994 58.166 96.859 57.451 96.659 56.019 96.259 55.54 96.125 55.3 96.058 55.063 95.998 51.74 95.154 48.26 95.154 44.937 95.998 44.699 96.058 44.46 96.125 43.981 96.259 42.549 96.659 41.834 96.859 41.199 96.994 32.023 98.945 22.69 94.44 18.49 86.033 18.2 85.451 17.909 84.766 17.329 83.395 17.135 82.936 17.038 82.707 16.937 82.483 15.523 79.353 13.353 76.626 10.623 74.548 10.428 74.4 10.226 74.254 9.823 73.961 8.619 73.089 8.017 72.653 7.516 72.24 .273 66.266 -2.032 56.143 1.907 47.611 2.179 47.021 2.533 46.366 3.241 45.056 3.478 44.618 3.596 44.399 3.707 44.18 5.268 41.121 6.042 37.72 5.961 34.285 5.955 34.04 5.943 33.791 5.92 33.293 5.849 31.805 5.814 31.062 5.824 30.412 5.968 21.011 12.427 12.893 21.539 10.66 22.169 10.506 22.9 10.375 24.363 10.113 24.853 10.025 25.098 9.981 25.337 9.932 28.697 9.248 31.833 7.734 34.461 5.529 34.649 5.371 34.836 5.207 35.209 4.878Z",
folderPathString = folderShapes["clover"]!!,
+ iconScale = 72f / 80f,
),
"arch" to
IconShapeModel(
@@ -198,6 +200,7 @@
pathString =
"M42.846 4.873C46.084 -.531 53.916 -.531 57.154 4.873L60.796 10.951C62.685 14.103 66.414 15.647 69.978 14.754L76.851 13.032C82.962 11.5 88.5 17.038 86.968 23.149L85.246 30.022C84.353 33.586 85.897 37.315 89.049 39.204L95.127 42.846C100.531 46.084 100.531 53.916 95.127 57.154L89.049 60.796C85.897 62.685 84.353 66.414 85.246 69.978L86.968 76.851C88.5 82.962 82.962 88.5 76.851 86.968L69.978 85.246C66.414 84.353 62.685 85.898 60.796 89.049L57.154 95.127C53.916 100.531 46.084 100.531 42.846 95.127L39.204 89.049C37.315 85.898 33.586 84.353 30.022 85.246L23.149 86.968C17.038 88.5 11.5 82.962 13.032 76.851L14.754 69.978C15.647 66.414 14.103 62.685 10.951 60.796L4.873 57.154C -.531 53.916 -.531 46.084 4.873 42.846L10.951 39.204C14.103 37.315 15.647 33.586 14.754 30.022L13.032 23.149C11.5 17.038 17.038 11.5 23.149 13.032L30.022 14.754C33.586 15.647 37.315 14.103 39.204 10.951L42.846 4.873Z",
folderPathString = folderShapes["clover"]!!,
+ iconScale = 72f / 92f,
),
)
} else {