diff options
author | Sunny Goyal <sunnygoyal@google.com> | 2019-01-23 16:42:43 -0800 |
---|---|---|
committer | Sunny Goyal <sunnygoyal@google.com> | 2019-01-23 16:43:26 -0800 |
commit | 90e3fbca6215b0bf2996786db5c9398a9691f3bf (patch) | |
tree | b82c25bce305b409fe708f4b94ac202a8f4c3b7e | |
parent | 95ee747f7613b6626d593cef8fed845fbd00f1be (diff) | |
download | android_packages_apps_Trebuchet-90e3fbca6215b0bf2996786db5c9398a9691f3bf.tar.gz android_packages_apps_Trebuchet-90e3fbca6215b0bf2996786db5c9398a9691f3bf.tar.bz2 android_packages_apps_Trebuchet-90e3fbca6215b0bf2996786db5c9398a9691f3bf.zip |
Updating folder shape when icon shape changes
> Removing unnecessary threading logic and the code was running on main thread anyway
Bug: 118757840
Change-Id: I7a012db5a0dbe2c23bd6ff2cd39679a803731ee8
3 files changed, 13 insertions, 27 deletions
diff --git a/iconloaderlib/src/com/android/launcher3/icons/ShadowGenerator.java b/iconloaderlib/src/com/android/launcher3/icons/ShadowGenerator.java index 455c58c91..5df804390 100644 --- a/iconloaderlib/src/com/android/launcher3/icons/ShadowGenerator.java +++ b/iconloaderlib/src/com/android/launcher3/icons/ShadowGenerator.java @@ -122,7 +122,11 @@ public class ShadowGenerator { } public Bitmap createPill(int width, int height) { - radius = height / 2f; + return createPill(width, height, height / 2f); + } + + public Bitmap createPill(int width, int height, float r) { + radius = r; int centerX = Math.round(width / 2f + shadowBlur); int centerY = Math.round(radius + shadowBlur + keyShadowDistance); diff --git a/src/com/android/launcher3/InvariantDeviceProfile.java b/src/com/android/launcher3/InvariantDeviceProfile.java index dafd5bb91..6582df2b7 100644 --- a/src/com/android/launcher3/InvariantDeviceProfile.java +++ b/src/com/android/launcher3/InvariantDeviceProfile.java @@ -36,6 +36,7 @@ import android.util.Xml; import android.view.Display; import android.view.WindowManager; +import com.android.launcher3.folder.FolderShape; import com.android.launcher3.util.ConfigMonitor; import com.android.launcher3.util.IntArray; import com.android.launcher3.util.MainThreadInitializedObject; @@ -285,6 +286,10 @@ public class InvariantDeviceProfile { !iconShapePath.equals(oldProfile.iconShapePath)) { changeFlags |= CHANGE_FLAG_ICON_PARAMS; } + if (!iconShapePath.equals(oldProfile.iconShapePath)) { + FolderShape.init(context); + } + apply(context, changeFlags); } diff --git a/src/com/android/launcher3/folder/FolderShape.java b/src/com/android/launcher3/folder/FolderShape.java index 4b06ddac8..61db6ffad 100644 --- a/src/com/android/launcher3/folder/FolderShape.java +++ b/src/com/android/launcher3/folder/FolderShape.java @@ -15,8 +15,6 @@ */ package com.android.launcher3.folder; -import static com.android.launcher3.Workspace.MAP_NO_RECURSE; - import android.animation.Animator; import android.animation.AnimatorListenerAdapter; import android.animation.FloatArrayEvaluator; @@ -43,9 +41,6 @@ import android.util.TypedValue; import android.util.Xml; import android.view.ViewOutlineProvider; -import com.android.launcher3.Launcher; -import com.android.launcher3.LauncherAppState; -import com.android.launcher3.MainThreadExecutor; import com.android.launcher3.R; import com.android.launcher3.Utilities; import com.android.launcher3.anim.RoundedRectRevealOutlineProvider; @@ -358,7 +353,7 @@ public abstract class FolderShape { if (!Utilities.ATLEAST_OREO) { return; } - new MainThreadExecutor().execute(() -> pickShapeInBackground(context)); + pickBestShape(context); } private static FolderShape getShapeDefinition(String type, float radius) { @@ -410,7 +405,7 @@ public abstract class FolderShape { } @TargetApi(Build.VERSION_CODES.O) - protected static void pickShapeInBackground(Context context) { + protected static void pickBestShape(Context context) { // Pick any large size int size = 200; @@ -447,25 +442,7 @@ public abstract class FolderShape { } if (closestShape != null) { - FolderShape shape = closestShape; - new MainThreadExecutor().execute(() -> updateFolderShape(shape)); - } - } - - private static void updateFolderShape(FolderShape shape) { - sInstance = shape; - LauncherAppState app = LauncherAppState.getInstanceNoCreate(); - if (app == null) { - return; - } - Launcher launcher = (Launcher) app.getModel().getCallback(); - if (launcher != null) { - launcher.getWorkspace().mapOverItems(MAP_NO_RECURSE, (i, v) -> { - if (v instanceof FolderIcon) { - v.invalidate(); - } - return false; - }); + sInstance = closestShape; } } } |