summaryrefslogtreecommitdiffstats
path: root/src/com/android/launcher3
diff options
context:
space:
mode:
authorHyunyoung Song <hyunyoungs@google.com>2019-06-03 22:34:02 +0000
committerAndroid (Google) Code Review <android-gerrit@google.com>2019-06-03 22:34:02 +0000
commited45267bf998bbd9c299da3757c0ee570c8b8932 (patch)
tree465bb4d44ce6add6e36a1583f40ced77e1a7a18f /src/com/android/launcher3
parentacdde3d750611476264a838d0a536d99404a692b (diff)
parentf69426c4845f35206ad370889cb489d2f4af0135 (diff)
downloadandroid_packages_apps_Trebuchet-ed45267bf998bbd9c299da3757c0ee570c8b8932.tar.gz
android_packages_apps_Trebuchet-ed45267bf998bbd9c299da3757c0ee570c8b8932.tar.bz2
android_packages_apps_Trebuchet-ed45267bf998bbd9c299da3757c0ee570c8b8932.zip
Merge "Add shape detection logic only for circle icons" into ub-launcher3-qt-dev
Diffstat (limited to 'src/com/android/launcher3')
-rw-r--r--src/com/android/launcher3/dragndrop/DragView.java2
-rw-r--r--src/com/android/launcher3/graphics/IconShape.java9
-rw-r--r--src/com/android/launcher3/icons/LauncherIcons.java15
-rw-r--r--src/com/android/launcher3/views/FloatingIconView.java3
4 files changed, 23 insertions, 6 deletions
diff --git a/src/com/android/launcher3/dragndrop/DragView.java b/src/com/android/launcher3/dragndrop/DragView.java
index d1bd2db13..09c5e5b2b 100644
--- a/src/com/android/launcher3/dragndrop/DragView.java
+++ b/src/com/android/launcher3/dragndrop/DragView.java
@@ -243,7 +243,7 @@ public class DragView extends View implements LauncherStateManager.StateListener
nDr = new AdaptiveIconDrawable(new ColorDrawable(Color.BLACK), null);
}
Utilities.scaleRectAboutCenter(bounds,
- li.getNormalizer().getScale(nDr, null));
+ li.getNormalizer().getScale(nDr, null, null, null));
}
AdaptiveIconDrawable adaptiveIcon = (AdaptiveIconDrawable) dr;
diff --git a/src/com/android/launcher3/graphics/IconShape.java b/src/com/android/launcher3/graphics/IconShape.java
index 88e4452e1..4369385ae 100644
--- a/src/com/android/launcher3/graphics/IconShape.java
+++ b/src/com/android/launcher3/graphics/IconShape.java
@@ -91,6 +91,10 @@ public abstract class IconShape {
private SparseArray<TypedValue> mAttrs;
+ public boolean enableShapeDetection(){
+ return false;
+ };
+
public abstract void drawShape(Canvas canvas, float offsetX, float offsetY, float radius,
Paint paint);
@@ -194,6 +198,11 @@ public abstract class IconShape {
protected float getStartRadius(Rect startRect) {
return startRect.width() / 2f;
}
+
+ @Override
+ public boolean enableShapeDetection() {
+ return true;
+ }
}
public static class RoundedSquare extends SimpleRectShape {
diff --git a/src/com/android/launcher3/icons/LauncherIcons.java b/src/com/android/launcher3/icons/LauncherIcons.java
index 5c4af1fe6..3b74307db 100644
--- a/src/com/android/launcher3/icons/LauncherIcons.java
+++ b/src/com/android/launcher3/icons/LauncherIcons.java
@@ -30,6 +30,7 @@ import com.android.launcher3.InvariantDeviceProfile;
import com.android.launcher3.ItemInfoWithIcon;
import com.android.launcher3.LauncherAppState;
import com.android.launcher3.R;
+import com.android.launcher3.graphics.IconShape;
import com.android.launcher3.model.PackageItemInfo;
import com.android.launcher3.shortcuts.DeepShortcutManager;
import com.android.launcher3.util.Themes;
@@ -50,11 +51,15 @@ public class LauncherIcons extends BaseIconFactory implements AutoCloseable {
private static LauncherIcons sPool;
private static int sPoolId = 0;
+ public static LauncherIcons obtain(Context context) {
+ return obtain(context, IconShape.getShape().enableShapeDetection());
+ }
+
/**
* Return a new Message instance from the global pool. Allows us to
* avoid allocating new objects in many cases.
*/
- public static LauncherIcons obtain(Context context) {
+ public static LauncherIcons obtain(Context context, boolean shapeDetection) {
int poolId;
synchronized (sPoolSync) {
if (sPool != null) {
@@ -67,7 +72,8 @@ public class LauncherIcons extends BaseIconFactory implements AutoCloseable {
}
InvariantDeviceProfile idp = LauncherAppState.getIDP(context);
- return new LauncherIcons(context, idp.fillResIconDpi, idp.iconBitmapSize, poolId);
+ return new LauncherIcons(context, idp.fillResIconDpi, idp.iconBitmapSize, poolId,
+ shapeDetection);
}
public static void clearPool() {
@@ -81,8 +87,9 @@ public class LauncherIcons extends BaseIconFactory implements AutoCloseable {
private LauncherIcons next;
- private LauncherIcons(Context context, int fillResIconDpi, int iconBitmapSize, int poolId) {
- super(context, fillResIconDpi, iconBitmapSize);
+ private LauncherIcons(Context context, int fillResIconDpi, int iconBitmapSize, int poolId,
+ boolean shapeDetection) {
+ super(context, fillResIconDpi, iconBitmapSize, shapeDetection);
mPoolId = poolId;
}
diff --git a/src/com/android/launcher3/views/FloatingIconView.java b/src/com/android/launcher3/views/FloatingIconView.java
index e4591b618..95c96817a 100644
--- a/src/com/android/launcher3/views/FloatingIconView.java
+++ b/src/com/android/launcher3/views/FloatingIconView.java
@@ -529,7 +529,8 @@ public class FloatingIconView extends View implements
bounds.inset(mBlurSizeOutline / 2, mBlurSizeOutline / 2);
try (LauncherIcons li = LauncherIcons.obtain(mLauncher)) {
- Utilities.scaleRectAboutCenter(bounds, li.getNormalizer().getScale(drawable, null));
+ Utilities.scaleRectAboutCenter(bounds, li.getNormalizer().getScale(drawable, null,
+ null, null));
}
bounds.inset(