Instead of popup to show letters, show private space icon on fast scrolling

Use spannableString to show the icon instead of regular letters for the private space icons.

bug:304752744
Test manual: https://drive.google.com/file/d/1LFy4-bu69Kuo8eV4erjJOsbkiQJs09kC/view?usp=sharing
Flag: None

Change-Id: I149d7aba6b0a4fdafacd2684e56827c7e1b9d724
This commit is contained in:
Brandon Dayauon committed 2024-04-17 12:37:38 -07:00
1 parent f15a96608a
commit a1af2cee1c
6 files changed
+51 -21

No files matched your search

@@ -22,6 +22,10 @@ import static com.android.launcher3.logging.StatsLogManager.LauncherEvent.LAUNCH
import static com.android.launcher3.logging.StatsLogManager.LauncherEvent.LAUNCHER_PRIVATE_SPACE_USER_INSTALLED_APPS_COUNT;
import android.content.Context;
import android.graphics.drawable.Drawable;
import android.text.Spannable;
import android.text.SpannableString;
import android.text.style.ImageSpan;
import androidx.annotation.Nullable;
import androidx.annotation.VisibleForTesting;
@@ -65,11 +69,11 @@ public class AlphabeticalAppsList<T extends Context & ActivityContext> implement
*/
public static class FastScrollSectionInfo {
// The section name
public final String sectionName;
public final CharSequence sectionName;
// The item position
public final int position;
public FastScrollSectionInfo(String sectionName, int position) {
public FastScrollSectionInfo(CharSequence sectionName, int position) {
this.sectionName = sectionName;
this.position = position;
}
@@ -93,6 +97,7 @@ public class AlphabeticalAppsList<T extends Context & ActivityContext> implement
// The of ordered component names as a result of a search query
private final ArrayList<AdapterItem> mSearchResults = new ArrayList<>();
private final SpannableString mPrivateProfileAppScrollerBadge;
private BaseAllAppsAdapter<T> mAdapter;
private AppInfoComparator mAppNameComparator;
private int mNumAppsPerRowAllApps;
@@ -110,6 +115,10 @@ public class AlphabeticalAppsList<T extends Context & ActivityContext> implement
if (mAllAppsStore != null) {
mAllAppsStore.addUpdateListener(this);
}
mPrivateProfileAppScrollerBadge = new SpannableString(" ");
mPrivateProfileAppScrollerBadge.setSpan(new ImageSpan(context,
R.drawable.ic_private_profile_app_scroller_badge, ImageSpan.ALIGN_CENTER),
0, 1, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
}
/** Set the number of apps per row when device profile changes. */
@@ -383,6 +392,7 @@ public class AlphabeticalAppsList<T extends Context & ActivityContext> implement
private int addAppsWithSections(List<AppInfo> appList, int startPosition) {
String lastSectionName = null;
boolean hasPrivateApps = false;
int position = startPosition;
if (mPrivateProviderManager != null) {
hasPrivateApps = appList.stream().
allMatch(mPrivateProviderManager.getItemInfoMatcher());
@@ -403,11 +413,12 @@ public class AlphabeticalAppsList<T extends Context & ActivityContext> implement
// Create a new section if the section names do not match
if (!sectionName.equals(lastSectionName)) {
lastSectionName = sectionName;
mFastScrollerSections.add(new FastScrollSectionInfo(sectionName, startPosition));
mFastScrollerSections.add(new FastScrollSectionInfo(hasPrivateApps ?
mPrivateProfileAppScrollerBadge : sectionName, position));
}
startPosition++;
position++;
}
return startPosition;
return position;
}
/**