summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndroid Build Coastguard Worker <android-build-coastguard-worker@google.com>2024-01-11 01:39:50 +0000
committerAndroid Build Coastguard Worker <android-build-coastguard-worker@google.com>2024-01-11 01:39:50 +0000
commitdc58c6d14f927ba19aefd6aad97ac2511ed0a155 (patch)
tree43210f40de63fb9292ba28b1f1f2a72e9679727e
parent47cb9a214697d75fa961ad6da8f508b225ee2e4f (diff)
parent192cafaebae78a942ba0644450643e2daa7ac69e (diff)
downloadsystemui-android14-qpr2-s2-release.tar.gz
Change-Id: I696044f50d728d3d183d472f1440c21a1ab6b07a
-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.java135
-rw-r--r--iconloaderlib/src/com/android/launcher3/util/UserIconInfo.java12
12 files changed, 209 insertions, 172 deletions
diff --git a/iconloaderlib/res/drawable/ic_clone_app_badge.xml b/iconloaderlib/res/drawable/ic_clone_app_badge.xml
index f81a960..9f0876d 100644
--- a/iconloaderlib/res/drawable/ic_clone_app_badge.xml
+++ b/iconloaderlib/res/drawable/ic_clone_app_badge.xml
@@ -17,16 +17,27 @@
android:width="@dimen/profile_badge_size"
android:height="@dimen/profile_badge_size"
android:viewportWidth="24"
- android:viewportHeight="24"
- android:tint="#ff3C4043">
+ 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" />
<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="#FFFFFFFF"/>
- <path
+ android:fillColor="#ff3C4043"/>
+ <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="#FFFFFFFF"
+ android:fillColor="#ff3C4043"
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
new file mode 100644
index 0000000..3a59e3d
--- /dev/null
+++ b/iconloaderlib/res/drawable/ic_clone_app_badge_themed.xml
@@ -0,0 +1,43 @@
+<?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 0e36b30..e6b5701 100644
--- a/iconloaderlib/res/drawable/ic_instant_app_badge.xml
+++ b/iconloaderlib/res/drawable/ic_instant_app_badge.xml
@@ -17,11 +17,14 @@
android:width="@dimen/profile_badge_size"
android:height="@dimen/profile_badge_size"
android:viewportWidth="18"
- android:viewportHeight="18"
- android:tint="@android:color/black">
+ android:viewportHeight="18">
<path
- android:fillColor="#FFFFFFFF"
+ 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: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
new file mode 100644
index 0000000..6e19339
--- /dev/null
+++ b/iconloaderlib/res/drawable/ic_instant_app_badge_themed.xml
@@ -0,0 +1,30 @@
+<?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 1f2967e..26e8ccc 100644
--- a/iconloaderlib/res/drawable/ic_private_profile_app_badge.xml
+++ b/iconloaderlib/res/drawable/ic_private_profile_app_badge.xml
@@ -17,10 +17,16 @@
android:width="@dimen/profile_badge_size"
android:height="@dimen/profile_badge_size"
android:viewportWidth="24"
- android:viewportHeight="24"
- android:tint="#001A41">
+ android:viewportHeight="24">
<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="#FFFFFFFF"/>
+ 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>
</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
new file mode 100644
index 0000000..636498e
--- /dev/null
+++ b/iconloaderlib/res/drawable/ic_private_profile_app_badge_themed.xml
@@ -0,0 +1,32 @@
+<!--
+ ~ 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 b4d99dd..1599489 100644
--- a/iconloaderlib/res/drawable/ic_work_app_badge.xml
+++ b/iconloaderlib/res/drawable/ic_work_app_badge.xml
@@ -17,12 +17,23 @@
android:width="@dimen/profile_badge_size"
android:height="@dimen/profile_badge_size"
android:viewportWidth="24"
- android:viewportHeight="24"
- android:tint="#1A73E8">
+ 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" />
<group android:scaleX=".6" android:scaleY=".6" android:pivotX="12" android:pivotY="12">
<path
- android:fillColor="#FFFFFFFF"
+ android:fillColor="#1A73E8"
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
new file mode 100644
index 0000000..6866d2f
--- /dev/null
+++ b/iconloaderlib/res/drawable/ic_work_app_badge_themed.xml
@@ -0,0 +1,39 @@
+<?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 7c112da..f20caa2 100644
--- a/iconloaderlib/src/com/android/launcher3/icons/BaseIconFactory.java
+++ b/iconloaderlib/src/com/android/launcher3/icons/BaseIconFactory.java
@@ -264,7 +264,9 @@ public class BaseIconFactory implements AutoCloseable {
info = getUserInfo(options.mUserHandle);
}
if (info != null) {
- op = info.applyBitmapInfoFlags(op);
+ op = op.setFlag(FLAG_WORK, info.isWork());
+ op = op.setFlag(FLAG_CLONE, info.isCloned());
+ op = op.setFlag(FLAG_PRIVATE, info.isPrivate());
}
}
return op;
diff --git a/iconloaderlib/src/com/android/launcher3/icons/BitmapInfo.java b/iconloaderlib/src/com/android/launcher3/icons/BitmapInfo.java
index 86db5b8..f527686 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 {
- 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;
+ 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;
@IntDef(flag = true, value = {
FLAG_WORK,
FLAG_INSTANT,
@@ -170,14 +170,21 @@ public class BitmapInfo {
if (badgeInfo != null) {
return badgeInfo.newIcon(context, isThemed ? FLAG_THEMED : 0);
} else if ((flags & FLAG_INSTANT) != 0) {
- return new UserBadgeDrawable(context, R.drawable.ic_instant_app_badge, isThemed);
+ return context.getDrawable(isThemed
+ ? R.drawable.ic_instant_app_badge_themed
+ : R.drawable.ic_instant_app_badge);
} else if ((flags & FLAG_WORK) != 0) {
- return new UserBadgeDrawable(context, R.drawable.ic_work_app_badge, isThemed);
+ return context.getDrawable(isThemed
+ ? R.drawable.ic_work_app_badge_themed
+ : R.drawable.ic_work_app_badge);
} else if ((flags & FLAG_CLONE) != 0) {
- return new UserBadgeDrawable(context, R.drawable.ic_clone_app_badge, isThemed);
+ return context.getDrawable(isThemed
+ ? R.drawable.ic_clone_app_badge_themed
+ : R.drawable.ic_clone_app_badge);
} else if ((flags & FLAG_PRIVATE) != 0) {
- return new UserBadgeDrawable(
- context, R.drawable.ic_private_profile_app_badge, isThemed);
+ return context.getDrawable(isThemed
+ ? R.drawable.ic_private_profile_app_badge_themed
+ : R.drawable.ic_private_profile_app_badge);
}
return null;
}
diff --git a/iconloaderlib/src/com/android/launcher3/icons/UserBadgeDrawable.java b/iconloaderlib/src/com/android/launcher3/icons/UserBadgeDrawable.java
deleted file mode 100644
index 96d8cc4..0000000
--- a/iconloaderlib/src/com/android/launcher3/icons/UserBadgeDrawable.java
+++ /dev/null
@@ -1,135 +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.
- */
-
-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 = true;
-
- 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();
- int saveCount = canvas.save();
- canvas.translate(b.left, b.top);
- canvas.scale(b.width() / VIEWPORT_SIZE, b.height() / VIEWPORT_SIZE);
-
- 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 f1d753d..2f37122 100644
--- a/iconloaderlib/src/com/android/launcher3/util/UserIconInfo.java
+++ b/iconloaderlib/src/com/android/launcher3/util/UserIconInfo.java
@@ -16,14 +16,9 @@
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}
@@ -71,11 +66,4 @@ 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());
- }
}