diff options
author | 2025-02-28 22:21:28 +0000 | |
---|---|---|
committer | 2025-03-06 19:20:11 +0000 | |
commit | 5a118cb57dc9c43445442c51bcf74f13ddbc6daf (patch) | |
tree | 8a5890db468f78e4eb0c3bea04af39ab893ab3b0 | |
parent | aa39accd494851769e420072fe62cbad492e3b18 (diff) |
Move privateSpace app location to after the header
Updated bubbleTextView that defaults creationFlag to 0 thus applying the
badge on the icon when there shouldn't be a badge. Tested this by
installing the privateSpace.apk and seeing that I've successfully
removed the original install icon.
bug: 360313403
Test: manually - https://hsv.googleplex.com/4736879982280704
Flag: android.multiuser.enable_moving_content_into_private_space
Change-Id: I50a277457c9c3f78214b53e4391535a2c45dca55
-rw-r--r-- | src/com/android/launcher3/BubbleTextView.java | 2 | ||||
-rw-r--r-- | src/com/android/launcher3/allapps/AlphabeticalAppsList.java | 29 |
2 files changed, 29 insertions, 2 deletions
diff --git a/src/com/android/launcher3/BubbleTextView.java b/src/com/android/launcher3/BubbleTextView.java index bd42b2b855..c2a126b0d6 100644 --- a/src/com/android/launcher3/BubbleTextView.java +++ b/src/com/android/launcher3/BubbleTextView.java @@ -483,7 +483,7 @@ public class BubbleTextView extends TextView implements ItemInfoUpdateReceiver, } private void setNonPendingIcon(ItemInfoWithIcon info) { - int flags = shouldUseTheme() ? FLAG_THEMED : 0; + int flags = shouldUseTheme() ? FLAG_THEMED : info.bitmap.creationFlags; // Remove badge on icons smaller than 48dp. if (mHideBadge || mDisplay == DISPLAY_SEARCH_RESULT_SMALL) { flags |= FLAG_NO_BADGE; diff --git a/src/com/android/launcher3/allapps/AlphabeticalAppsList.java b/src/com/android/launcher3/allapps/AlphabeticalAppsList.java index 709b52a174..5f632fe25d 100644 --- a/src/com/android/launcher3/allapps/AlphabeticalAppsList.java +++ b/src/com/android/launcher3/allapps/AlphabeticalAppsList.java @@ -15,10 +15,14 @@ */ package com.android.launcher3.allapps; +import static android.multiuser.Flags.enableMovingContentIntoPrivateSpace; + import static com.android.launcher3.allapps.BaseAllAppsAdapter.VIEW_TYPE_BOTTOM_VIEW_TO_SCROLL_TO; +import static com.android.launcher3.allapps.BaseAllAppsAdapter.VIEW_TYPE_MASK_PRIVATE_SPACE_HEADER; import static com.android.launcher3.allapps.SectionDecorationInfo.ROUND_BOTTOM_LEFT; import static com.android.launcher3.allapps.SectionDecorationInfo.ROUND_BOTTOM_RIGHT; import static com.android.launcher3.allapps.SectionDecorationInfo.ROUND_NOTHING; +import static com.android.launcher3.icons.BitmapInfo.FLAG_NO_BADGE; import static com.android.launcher3.logging.StatsLogManager.LauncherEvent.LAUNCHER_PRIVATE_SPACE_PREINSTALLED_APPS_COUNT; import static com.android.launcher3.logging.StatsLogManager.LauncherEvent.LAUNCHER_PRIVATE_SPACE_USER_INSTALLED_APPS_COUNT; @@ -60,6 +64,7 @@ public class AlphabeticalAppsList<T extends Context & ActivityContext> implement AllAppsStore.OnUpdateListener { public static final String TAG = "AlphabeticalAppsList"; + private static final String PRIVATE_SPACE_PACKAGE = "com.android.privatespace"; private final WorkProfileManager mWorkProviderManager; @@ -382,7 +387,7 @@ public class AlphabeticalAppsList<T extends Context & ActivityContext> implement private int addPrivateSpaceApps(int position) { // Add Install Apps Button first. - if (Flags.privateSpaceAppInstallerButton()) { + if (Flags.privateSpaceAppInstallerButton() && !enableMovingContentIntoPrivateSpace()) { mPrivateProviderManager.addPrivateSpaceInstallAppButton(mAdapterItems); position++; } @@ -419,6 +424,28 @@ public class AlphabeticalAppsList<T extends Context & ActivityContext> implement // Add system apps. position = addAppsWithSections(split.get(false), position); + if (enableMovingContentIntoPrivateSpace()) { + // Look for the private space app via package and move it after header. + int headerIndex = -1; + int privateSpaceAppIndex = -1; + for (int i = 0; i < mAdapterItems.size(); i++) { + BaseAllAppsAdapter.AdapterItem currentItem = mAdapterItems.get(i); + if (currentItem.viewType == VIEW_TYPE_MASK_PRIVATE_SPACE_HEADER) { + headerIndex = i; + } + if (currentItem.itemInfo != null && Objects.equals( + currentItem.itemInfo.getTargetPackage(), PRIVATE_SPACE_PACKAGE)) { + currentItem.itemInfo.bitmap.creationFlags |= FLAG_NO_BADGE; + privateSpaceAppIndex = i; + } + } + if (headerIndex != -1 && privateSpaceAppIndex != -1) { + BaseAllAppsAdapter.AdapterItem movedItem = + mAdapterItems.remove(privateSpaceAppIndex); + // Move the icon after the header. + mAdapterItems.add(headerIndex + 1, movedItem); + } + } return position; } |