summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndroid Build Coastguard Worker <android-build-coastguard-worker@google.com>2023-11-29 00:19:00 +0000
committerAndroid Build Coastguard Worker <android-build-coastguard-worker@google.com>2023-11-29 00:19:00 +0000
commit04db8c85603f20faece6a107a435a60b165fba39 (patch)
tree85c4c22b3ac7dd4a0744bb1fbb19df89382bf2c7
parent0160bc81da19f8dbb87cdb9a2b88299fc2794483 (diff)
parent0259d5ed34b4b43402a9737cfa03c3507e4d7f29 (diff)
downloadsystemui-04db8c85603f20faece6a107a435a60b165fba39.tar.gz
Snap for 11151698 from 0259d5ed34b4b43402a9737cfa03c3507e4d7f29 to 24Q1-release
Change-Id: Ic9d2d4595c0e68042b9074c248718f27fe92025e
-rw-r--r--iconloaderlib/res/drawable/ic_clone_app_badge.xml21
-rw-r--r--iconloaderlib/res/drawable/ic_clone_app_badge_themed.xml43
-rw-r--r--iconloaderlib/res/drawable/ic_instant_app_badge.xml9
-rw-r--r--iconloaderlib/res/drawable/ic_instant_app_badge_themed.xml30
-rw-r--r--iconloaderlib/res/drawable/ic_private_profile_app_badge.xml14
-rw-r--r--iconloaderlib/res/drawable/ic_private_profile_app_badge_themed.xml32
-rw-r--r--iconloaderlib/res/drawable/ic_work_app_badge.xml17
-rw-r--r--iconloaderlib/res/drawable/ic_work_app_badge_themed.xml39
-rw-r--r--iconloaderlib/src/com/android/launcher3/icons/BaseIconFactory.java4
-rw-r--r--iconloaderlib/src/com/android/launcher3/icons/BitmapInfo.java25
-rw-r--r--iconloaderlib/src/com/android/launcher3/icons/UserBadgeDrawable.java136
-rw-r--r--iconloaderlib/src/com/android/launcher3/util/UserIconInfo.java12
12 files changed, 173 insertions, 209 deletions
diff --git a/iconloaderlib/res/drawable/ic_clone_app_badge.xml b/iconloaderlib/res/drawable/ic_clone_app_badge.xml
index 9f0876d..f81a960 100644
--- a/iconloaderlib/res/drawable/ic_clone_app_badge.xml
+++ b/iconloaderlib/res/drawable/ic_clone_app_badge.xml
@@ -17,27 +17,16 @@
android:width="@dimen/profile_badge_size"
android:height="@dimen/profile_badge_size"
android:viewportWidth="24"
- android:viewportHeight="24">
-
- <path
- android:fillColor="#11000000"
- android:pathData="M.5,12.25
- A11.5,11.5 0 1,1 23.5,12.25
- A11.5,11.5 0 1,1 .5,12.25" />
-
- <path
- android:fillColor="@android:color/white"
- android:pathData="M1,12
- A11,11 0 1,1 23,12
- A11,11 0 1,1 1,12" />
+ android:viewportHeight="24"
+ android:tint="#ff3C4043">
<group android:scaleX=".6" android:scaleY=".6" android:pivotX="12" android:pivotY="12">
<path
android:pathData="M22,9.5C22,13.642 18.642,17 14.5,17C10.358,17 7,13.642 7,9.5C7,5.358 10.358,2 14.5,2C18.642,2 22,5.358 22,9.5Z"
- android:fillColor="#ff3C4043"/>
- <path
+ android:fillColor="#FFFFFFFF"/>
+ <path
android:pathData="M9.5,20.333C12.722,20.333 15.333,17.722 15.333,14.5C15.333,11.278 12.722,8.667 9.5,8.667C6.278,8.667 3.667,11.278 3.667,14.5C3.667,17.722 6.278,20.333 9.5,20.333ZM9.5,22C13.642,22 17,18.642 17,14.5C17,10.358 13.642,7 9.5,7C5.358,7 2,10.358 2,14.5C2,18.642 5.358,22 9.5,22Z"
- android:fillColor="#ff3C4043"
+ android:fillColor="#FFFFFFFF"
android:fillType="evenOdd"/>
</group>
</vector>
diff --git a/iconloaderlib/res/drawable/ic_clone_app_badge_themed.xml b/iconloaderlib/res/drawable/ic_clone_app_badge_themed.xml
deleted file mode 100644
index 3a59e3d..0000000
--- a/iconloaderlib/res/drawable/ic_clone_app_badge_themed.xml
+++ /dev/null
@@ -1,43 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!-- Copyright (C) 2023 The Android Open Source Project
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
--->
-<vector xmlns:android="http://schemas.android.com/apk/res/android"
- android:width="@dimen/profile_badge_size"
- android:height="@dimen/profile_badge_size"
- android:viewportWidth="24"
- android:viewportHeight="24">
-
- <path
- android:fillColor="#11000000"
- android:pathData="M.5,12.25
- A11.5,11.5 0 1,1 23.5,12.25
- A11.5,11.5 0 1,1 .5,12.25" />
-
- <path
- android:fillColor="@color/themed_icon_background_color"
- android:pathData="M1,12
- A11,11 0 1,1 23,12
- A11,11 0 1,1 1,12" />
-
- <group android:scaleX=".6" android:scaleY=".6" android:pivotX="12" android:pivotY="12">
- <path
- android:pathData="M22,9.5C22,13.642 18.642,17 14.5,17C10.358,17 7,13.642 7,9.5C7,5.358 10.358,2 14.5,2C18.642,2 22,5.358 22,9.5Z"
- android:fillColor="@color/themed_badge_icon_color"/>
- <path
- android:pathData="M9.5,20.333C12.722,20.333 15.333,17.722 15.333,14.5C15.333,11.278 12.722,8.667 9.5,8.667C6.278,8.667 3.667,11.278 3.667,14.5C3.667,17.722 6.278,20.333 9.5,20.333ZM9.5,22C13.642,22 17,18.642 17,14.5C17,10.358 13.642,7 9.5,7C5.358,7 2,10.358 2,14.5C2,18.642 5.358,22 9.5,22Z"
- android:fillColor="@color/themed_badge_icon_color"
- android:fillType="evenOdd"/>
- </group>
-</vector>
diff --git a/iconloaderlib/res/drawable/ic_instant_app_badge.xml b/iconloaderlib/res/drawable/ic_instant_app_badge.xml
index e6b5701..0e36b30 100644
--- a/iconloaderlib/res/drawable/ic_instant_app_badge.xml
+++ b/iconloaderlib/res/drawable/ic_instant_app_badge.xml
@@ -17,14 +17,11 @@
android:width="@dimen/profile_badge_size"
android:height="@dimen/profile_badge_size"
android:viewportWidth="18"
- android:viewportHeight="18">
+ android:viewportHeight="18"
+ android:tint="@android:color/black">
<path
- android:fillColor="@android:color/white"
- android:strokeWidth="1"
- android:pathData="M 9 0 C 13.9705627485 0 18 4.02943725152 18 9 C 18 13.9705627485 13.9705627485 18 9 18 C 4.02943725152 18 0 13.9705627485 0 9 C 0 4.02943725152 4.02943725152 0 9 0 Z" />
- <path
- android:fillColor="@android:color/black"
+ android:fillColor="#FFFFFFFF"
android:strokeWidth="1"
android:pathData="M 6 10.4123279 L 8.63934949 10.4123279 L 8.63934949 15.6 L 12.5577168 7.84517705 L 9.94547194 7.84517705 L 9.94547194 2 Z" />
</vector>
diff --git a/iconloaderlib/res/drawable/ic_instant_app_badge_themed.xml b/iconloaderlib/res/drawable/ic_instant_app_badge_themed.xml
deleted file mode 100644
index 6e19339..0000000
--- a/iconloaderlib/res/drawable/ic_instant_app_badge_themed.xml
+++ /dev/null
@@ -1,30 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!-- Copyright (C) 2017 The Android Open Source Project
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
--->
-<vector xmlns:android="http://schemas.android.com/apk/res/android"
- android:width="@dimen/profile_badge_size"
- android:height="@dimen/profile_badge_size"
- android:viewportWidth="18"
- android:viewportHeight="18">
-
- <path
- android:fillColor="@color/themed_badge_icon_background_color"
- android:strokeWidth="1"
- android:pathData="M 9 0 C 13.9705627485 0 18 4.02943725152 18 9 C 18 13.9705627485 13.9705627485 18 9 18 C 4.02943725152 18 0 13.9705627485 0 9 C 0 4.02943725152 4.02943725152 0 9 0 Z" />
- <path
- android:fillColor="@color/themed_badge_icon_color"
- android:strokeWidth="1"
- android:pathData="M 6 10.4123279 L 8.63934949 10.4123279 L 8.63934949 15.6 L 12.5577168 7.84517705 L 9.94547194 7.84517705 L 9.94547194 2 Z" />
-</vector>
diff --git a/iconloaderlib/res/drawable/ic_private_profile_app_badge.xml b/iconloaderlib/res/drawable/ic_private_profile_app_badge.xml
index 26e8ccc..1f2967e 100644
--- a/iconloaderlib/res/drawable/ic_private_profile_app_badge.xml
+++ b/iconloaderlib/res/drawable/ic_private_profile_app_badge.xml
@@ -17,16 +17,10 @@
android:width="@dimen/profile_badge_size"
android:height="@dimen/profile_badge_size"
android:viewportWidth="24"
- android:viewportHeight="24">
+ android:viewportHeight="24"
+ android:tint="#001A41">
<path
- android:pathData="M12,0L12,0A12,12 0,0 1,24 12L24,12A12,12 0,0 1,12 24L12,24A12,12 0,0 1,0 12L0,12A12,12 0,0 1,12 0z"
- android:fillColor="#ffffff"/>
- <group>
- <clip-path
- android:pathData="M5,5h14v14h-14z"/>
- <path
- android:pathData="M11.033,14H12.967L12.6,11.85C12.789,11.75 12.933,11.606 13.033,11.417C13.144,11.228 13.2,11.022 13.2,10.8C13.2,10.467 13.083,10.183 12.85,9.95C12.617,9.717 12.333,9.6 12,9.6C11.667,9.6 11.383,9.717 11.15,9.95C10.917,10.183 10.8,10.467 10.8,10.8C10.8,11.022 10.85,11.228 10.95,11.417C11.061,11.606 11.211,11.75 11.4,11.85L11.033,14ZM12,18.4C10.5,18.033 9.256,17.183 8.267,15.85C7.289,14.517 6.8,13.039 6.8,11.417V7.6L12,5.6L17.2,7.6V11.417C17.2,13.039 16.706,14.517 15.717,15.85C14.739,17.183 13.5,18.033 12,18.4ZM12,17.15C13.156,16.794 14.111,16.078 14.867,15C15.622,13.922 16,12.728 16,11.417V8.417L12,6.883L8,8.417V11.417C8,12.728 8.378,13.922 9.133,15C9.889,16.078 10.844,16.794 12,17.15Z"
- android:fillColor="#001A41"/>
- </group>
+ android:pathData="M11.033,14H12.967L12.6,11.85C12.789,11.75 12.933,11.606 13.033,11.417C13.144,11.228 13.2,11.022 13.2,10.8C13.2,10.467 13.083,10.183 12.85,9.95C12.617,9.717 12.333,9.6 12,9.6C11.667,9.6 11.383,9.717 11.15,9.95C10.917,10.183 10.8,10.467 10.8,10.8C10.8,11.022 10.85,11.228 10.95,11.417C11.061,11.606 11.211,11.75 11.4,11.85L11.033,14ZM12,18.4C10.5,18.033 9.256,17.183 8.267,15.85C7.289,14.517 6.8,13.039 6.8,11.417V7.6L12,5.6L17.2,7.6V11.417C17.2,13.039 16.706,14.517 15.717,15.85C14.739,17.183 13.5,18.033 12,18.4ZM12,17.15C13.156,16.794 14.111,16.078 14.867,15C15.622,13.922 16,12.728 16,11.417V8.417L12,6.883L8,8.417V11.417C8,12.728 8.378,13.922 9.133,15C9.889,16.078 10.844,16.794 12,17.15Z"
+ android:fillColor="#FFFFFFFF"/>
</vector>
diff --git a/iconloaderlib/res/drawable/ic_private_profile_app_badge_themed.xml b/iconloaderlib/res/drawable/ic_private_profile_app_badge_themed.xml
deleted file mode 100644
index 636498e..0000000
--- a/iconloaderlib/res/drawable/ic_private_profile_app_badge_themed.xml
+++ /dev/null
@@ -1,32 +0,0 @@
-<!--
- ~ Copyright (C) 2023 The Android Open Source Project
- ~
- ~ Licensed under the Apache License, Version 2.0 (the "License");
- ~ you may not use this file except in compliance with the License.
- ~ You may obtain a copy of the License at
- ~
- ~ http://www.apache.org/licenses/LICENSE-2.0
- ~
- ~ Unless required by applicable law or agreed to in writing, software
- ~ distributed under the License is distributed on an "AS IS" BASIS,
- ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- ~ See the License for the specific language governing permissions and
- ~ limitations under the License.
- -->
-<vector xmlns:android="http://schemas.android.com/apk/res/android"
- android:width="24dp"
- android:height="24dp"
- android:viewportWidth="24"
- android:viewportHeight="24">
- <path
- android:pathData="M12,0L12,0A12,12 0,0 1,24 12L24,12A12,12 0,0 1,12 24L12,24A12,12 0,0 1,0 12L0,12A12,12 0,0 1,12 0z"
- android:fillColor="@color/themed_badge_icon_background_color"/>
- <group>
- <clip-path
- android:pathData="M5,5h14v14h-14z"/>
- <path
- android:pathData="M11.033,14H12.967L12.6,11.85C12.789,11.75 12.933,11.606 13.033,11.417C13.144,11.228 13.2,11.022 13.2,10.8C13.2,10.467 13.083,10.183 12.85,9.95C12.617,9.717 12.333,9.6 12,9.6C11.667,9.6 11.383,9.717 11.15,9.95C10.917,10.183 10.8,10.467 10.8,10.8C10.8,11.022 10.85,11.228 10.95,11.417C11.061,11.606 11.211,11.75 11.4,11.85L11.033,14ZM12,18.4C10.5,18.033 9.256,17.183 8.267,15.85C7.289,14.517 6.8,13.039 6.8,11.417V7.6L12,5.6L17.2,7.6V11.417C17.2,13.039 16.706,14.517 15.717,15.85C14.739,17.183 13.5,18.033 12,18.4ZM12,17.15C13.156,16.794 14.111,16.078 14.867,15C15.622,13.922 16,12.728 16,11.417V8.417L12,6.883L8,8.417V11.417C8,12.728 8.378,13.922 9.133,15C9.889,16.078 10.844,16.794 12,17.15Z"
- android:fillColor="@color/themed_badge_icon_color"/>
- </group>
-</vector>
-
diff --git a/iconloaderlib/res/drawable/ic_work_app_badge.xml b/iconloaderlib/res/drawable/ic_work_app_badge.xml
index 1599489..b4d99dd 100644
--- a/iconloaderlib/res/drawable/ic_work_app_badge.xml
+++ b/iconloaderlib/res/drawable/ic_work_app_badge.xml
@@ -17,23 +17,12 @@
android:width="@dimen/profile_badge_size"
android:height="@dimen/profile_badge_size"
android:viewportWidth="24"
- android:viewportHeight="24">
-
- <path
- android:fillColor="#11000000"
- android:pathData="M.5,12.25
- A11.5,11.5 0 1,1 23.5,12.25
- A11.5,11.5 0 1,1 .5,12.25" />
-
- <path
- android:fillColor="@android:color/white"
- android:pathData="M1,12
- A11,11 0 1,1 23,12
- A11,11 0 1,1 1,12" />
+ android:viewportHeight="24"
+ android:tint="#1A73E8">
<group android:scaleX=".6" android:scaleY=".6" android:pivotX="12" android:pivotY="12">
<path
- android:fillColor="#1A73E8"
+ android:fillColor="#FFFFFFFF"
android:pathData="M20,6h-4L16,4c0,-1.11 -0.89,-2 -2,-2h-4c-1.11,0 -2,0.89 -2,2v2L4,6c-1.11,0 -1.99,0.89 -1.99,2L2,19c0,1.11 0.89,2 2,2h16c1.11,0 2,-0.89 2,-2L22,8c0,-1.11 -0.89,-2 -2,-2zM14,6h-4L10,4h4v2z" />
</group>
</vector>
diff --git a/iconloaderlib/res/drawable/ic_work_app_badge_themed.xml b/iconloaderlib/res/drawable/ic_work_app_badge_themed.xml
deleted file mode 100644
index 6866d2f..0000000
--- a/iconloaderlib/res/drawable/ic_work_app_badge_themed.xml
+++ /dev/null
@@ -1,39 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!-- Copyright (C) 2023 The Android Open Source Project
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
--->
-<vector xmlns:android="http://schemas.android.com/apk/res/android"
- android:width="@dimen/profile_badge_size"
- android:height="@dimen/profile_badge_size"
- android:viewportWidth="24"
- android:viewportHeight="24">
-
- <path
- android:fillColor="#11000000"
- android:pathData="M.5,12.25
- A11.5,11.5 0 1,1 23.5,12.25
- A11.5,11.5 0 1,1 .5,12.25" />
-
- <path
- android:fillColor="@color/themed_badge_icon_background_color"
- android:pathData="M1,12
- A11,11 0 1,1 23,12
- A11,11 0 1,1 1,12" />
-
- <group android:scaleX=".6" android:scaleY=".6" android:pivotX="12" android:pivotY="12">
- <path
- android:fillColor="@color/themed_badge_icon_color"
- android:pathData="M20,6h-4L16,4c0,-1.11 -0.89,-2 -2,-2h-4c-1.11,0 -2,0.89 -2,2v2L4,6c-1.11,0 -1.99,0.89 -1.99,2L2,19c0,1.11 0.89,2 2,2h16c1.11,0 2,-0.89 2,-2L22,8c0,-1.11 -0.89,-2 -2,-2zM14,6h-4L10,4h4v2z" />
- </group>
-</vector>
diff --git a/iconloaderlib/src/com/android/launcher3/icons/BaseIconFactory.java b/iconloaderlib/src/com/android/launcher3/icons/BaseIconFactory.java
index f20caa2..7c112da 100644
--- a/iconloaderlib/src/com/android/launcher3/icons/BaseIconFactory.java
+++ b/iconloaderlib/src/com/android/launcher3/icons/BaseIconFactory.java
@@ -264,9 +264,7 @@ public class BaseIconFactory implements AutoCloseable {
info = getUserInfo(options.mUserHandle);
}
if (info != null) {
- op = op.setFlag(FLAG_WORK, info.isWork());
- op = op.setFlag(FLAG_CLONE, info.isCloned());
- op = op.setFlag(FLAG_PRIVATE, info.isPrivate());
+ op = info.applyBitmapInfoFlags(op);
}
}
return op;
diff --git a/iconloaderlib/src/com/android/launcher3/icons/BitmapInfo.java b/iconloaderlib/src/com/android/launcher3/icons/BitmapInfo.java
index f527686..86db5b8 100644
--- a/iconloaderlib/src/com/android/launcher3/icons/BitmapInfo.java
+++ b/iconloaderlib/src/com/android/launcher3/icons/BitmapInfo.java
@@ -29,10 +29,10 @@ import com.android.launcher3.util.FlagOp;
public class BitmapInfo {
- static final int FLAG_WORK = 1 << 0;
- static final int FLAG_INSTANT = 1 << 1;
- static final int FLAG_CLONE = 1 << 2;
- static final int FLAG_PRIVATE = 1 << 3;
+ public static final int FLAG_WORK = 1 << 0;
+ public static final int FLAG_INSTANT = 1 << 1;
+ public static final int FLAG_CLONE = 1 << 2;
+ public static final int FLAG_PRIVATE = 1 << 3;
@IntDef(flag = true, value = {
FLAG_WORK,
FLAG_INSTANT,
@@ -170,21 +170,14 @@ public class BitmapInfo {
if (badgeInfo != null) {
return badgeInfo.newIcon(context, isThemed ? FLAG_THEMED : 0);
} else if ((flags & FLAG_INSTANT) != 0) {
- return context.getDrawable(isThemed
- ? R.drawable.ic_instant_app_badge_themed
- : R.drawable.ic_instant_app_badge);
+ return new UserBadgeDrawable(context, R.drawable.ic_instant_app_badge, isThemed);
} else if ((flags & FLAG_WORK) != 0) {
- return context.getDrawable(isThemed
- ? R.drawable.ic_work_app_badge_themed
- : R.drawable.ic_work_app_badge);
+ return new UserBadgeDrawable(context, R.drawable.ic_work_app_badge, isThemed);
} else if ((flags & FLAG_CLONE) != 0) {
- return context.getDrawable(isThemed
- ? R.drawable.ic_clone_app_badge_themed
- : R.drawable.ic_clone_app_badge);
+ return new UserBadgeDrawable(context, R.drawable.ic_clone_app_badge, isThemed);
} else if ((flags & FLAG_PRIVATE) != 0) {
- return context.getDrawable(isThemed
- ? R.drawable.ic_private_profile_app_badge_themed
- : R.drawable.ic_private_profile_app_badge);
+ return new UserBadgeDrawable(
+ context, R.drawable.ic_private_profile_app_badge, isThemed);
}
return null;
}
diff --git a/iconloaderlib/src/com/android/launcher3/icons/UserBadgeDrawable.java b/iconloaderlib/src/com/android/launcher3/icons/UserBadgeDrawable.java
new file mode 100644
index 0000000..fd3cf01
--- /dev/null
+++ b/iconloaderlib/src/com/android/launcher3/icons/UserBadgeDrawable.java
@@ -0,0 +1,136 @@
+/*
+ * Copyright (C) 2023 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.launcher3.icons;
+
+import android.content.Context;
+import android.content.res.Resources;
+import android.content.res.Resources.Theme;
+import android.graphics.Canvas;
+import android.graphics.Color;
+import android.graphics.Paint;
+import android.graphics.Rect;
+import android.graphics.drawable.Drawable;
+import android.graphics.drawable.DrawableWrapper;
+
+import androidx.annotation.NonNull;
+
+/**
+ * A drawable used for drawing user badge. It draws a circle around the actual badge,
+ * and has support for theming.
+ */
+public class UserBadgeDrawable extends DrawableWrapper {
+
+ private static final float VIEWPORT_SIZE = 24;
+ private static final float CENTER = VIEWPORT_SIZE / 2;
+
+ private static final float BG_RADIUS = 11;
+ private static final float SHADOW_RADIUS = 11.5f;
+ private static final float SHADOW_OFFSET_Y = 0.25f;
+
+ private static final int SHADOW_COLOR = 0x11000000;
+
+ private final Paint mPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
+
+ private final int mBgColor;
+ private boolean mShouldDrawBackground = false;
+
+ public UserBadgeDrawable(Context context, int badgeRes, boolean isThemed) {
+ super(context.getDrawable(badgeRes));
+
+ if (isThemed) {
+ mutate();
+ setTint(context.getColor(R.color.themed_badge_icon_color));
+ mBgColor = context.getColor(R.color.themed_badge_icon_background_color);
+ } else {
+ mBgColor = Color.WHITE;
+ }
+ }
+
+ private UserBadgeDrawable(Drawable base, int bgColor, boolean shouldDrawBackground) {
+ super(base);
+ mBgColor = bgColor;
+ mShouldDrawBackground = shouldDrawBackground;
+ }
+
+ @Override
+ public void draw(@NonNull Canvas canvas) {
+ if (mShouldDrawBackground) {
+ Rect b = getBounds();
+ if (!b.isEmpty()) {
+ int saveCount = canvas.save();
+ canvas.scale(VIEWPORT_SIZE / b.width(), VIEWPORT_SIZE / b.height());
+
+ mPaint.setColor(SHADOW_COLOR);
+ canvas.drawCircle(CENTER, CENTER + SHADOW_OFFSET_Y, SHADOW_RADIUS, mPaint);
+
+ mPaint.setColor(mBgColor);
+ canvas.drawCircle(CENTER, CENTER, BG_RADIUS, mPaint);
+
+ canvas.restoreToCount(saveCount);
+ }
+ }
+ super.draw(canvas);
+ }
+
+ public void setShouldDrawBackground(boolean shouldDrawBackground) {
+ mutate();
+ mShouldDrawBackground = shouldDrawBackground;
+ }
+
+ @Override
+ public ConstantState getConstantState() {
+ return new MyConstantState(
+ getDrawable().getConstantState(), mBgColor, mShouldDrawBackground);
+ }
+
+ private static class MyConstantState extends ConstantState {
+
+ private final ConstantState mBase;
+ private final int mBgColor;
+ private final boolean mShouldDrawBackground;
+
+ public MyConstantState(ConstantState base, int bgColor, boolean shouldDrawBackground) {
+ mBase = base;
+ mBgColor = bgColor;
+ mShouldDrawBackground = shouldDrawBackground;
+ }
+
+ @Override
+ public int getChangingConfigurations() {
+ return mBase.getChangingConfigurations();
+ }
+
+ @Override
+ @NonNull
+ public Drawable newDrawable() {
+ return new UserBadgeDrawable(mBase.newDrawable(), mBgColor, mShouldDrawBackground);
+ }
+
+ @Override
+ @NonNull
+ public Drawable newDrawable(Resources res) {
+ return new UserBadgeDrawable(mBase.newDrawable(res), mBgColor, mShouldDrawBackground);
+ }
+
+ @Override
+ @NonNull
+ public Drawable newDrawable(Resources res, Theme theme) {
+ return new UserBadgeDrawable(mBase.newDrawable(res, theme),
+ mBgColor, mShouldDrawBackground);
+ }
+ }
+}
diff --git a/iconloaderlib/src/com/android/launcher3/util/UserIconInfo.java b/iconloaderlib/src/com/android/launcher3/util/UserIconInfo.java
index 2f37122..f1d753d 100644
--- a/iconloaderlib/src/com/android/launcher3/util/UserIconInfo.java
+++ b/iconloaderlib/src/com/android/launcher3/util/UserIconInfo.java
@@ -16,9 +16,14 @@
package com.android.launcher3.util;
+import static com.android.launcher3.icons.BitmapInfo.FLAG_CLONE;
+import static com.android.launcher3.icons.BitmapInfo.FLAG_PRIVATE;
+import static com.android.launcher3.icons.BitmapInfo.FLAG_WORK;
+
import android.os.UserHandle;
import androidx.annotation.IntDef;
+import androidx.annotation.NonNull;
/**
* Data class which stores various properties of a {@link android.os.UserHandle}
@@ -66,4 +71,11 @@ public class UserIconInfo {
public boolean isPrivate() {
return type == TYPE_PRIVATE;
}
+
+ @NonNull
+ public FlagOp applyBitmapInfoFlags(@NonNull FlagOp op) {
+ return op.setFlag(FLAG_WORK, isWork())
+ .setFlag(FLAG_CLONE, isCloned())
+ .setFlag(FLAG_PRIVATE, isPrivate());
+ }
}