From 9d60a18c5c58338f1f7d2c869bd0653a4c9bb302 Mon Sep 17 00:00:00 2001 From: Brandon Dayauon Date: Mon, 23 Sep 2024 14:23:18 -0700 Subject: [PATCH 1/2] Only have private space drawable section for beginning of private space section and keep letters for everything else. spec: https://www.figma.com/design/uMzPkNMZpb7EyfHDo8usIa/V-%E2%80%A2-Toast-Butter?node-id=2746-180205&node-type=frame&m=dev As of recent request: Only using the bubble background for everything and have private space go back to using letters. Will include divider in followup. bug:358673724 Test photo: https://drive.google.com/file/d/1dC3fgfWiumhyLm4vI-VfnXIYQyjPyrnk/view?usp=sharing Flag: com.android.launcher3.letter_fast_scroller Change-Id: I30487581eec4bd3e1921de4e3d899cfe2e2a703f --- ...rofile_letter_list_fast_scroller_badge.xml | 28 +++++++++++++++++++ .../allapps/AllAppsRecyclerView.java | 7 +---- .../allapps/AlphabeticalAppsList.java | 10 +++++-- .../launcher3/allapps/LetterListTextView.java | 18 ++++++++++++ 4 files changed, 54 insertions(+), 9 deletions(-) create mode 100644 res/drawable/ic_private_profile_letter_list_fast_scroller_badge.xml diff --git a/res/drawable/ic_private_profile_letter_list_fast_scroller_badge.xml b/res/drawable/ic_private_profile_letter_list_fast_scroller_badge.xml new file mode 100644 index 0000000000..8d125988c1 --- /dev/null +++ b/res/drawable/ic_private_profile_letter_list_fast_scroller_badge.xml @@ -0,0 +1,28 @@ + + + + + diff --git a/src/com/android/launcher3/allapps/AllAppsRecyclerView.java b/src/com/android/launcher3/allapps/AllAppsRecyclerView.java index 4e1e95011b..e705d94d23 100644 --- a/src/com/android/launcher3/allapps/AllAppsRecyclerView.java +++ b/src/com/android/launcher3/allapps/AllAppsRecyclerView.java @@ -346,17 +346,12 @@ public class AllAppsRecyclerView extends FastScrollRecyclerView { (LetterListTextView) LayoutInflater.from(context).inflate( R.layout.fast_scroller_letter_list_text_view, mLetterList, false); int viewId = View.generateViewId(); - textView.setId(viewId); + textView.apply(sectionInfo /* FastScrollSectionInfo */, viewId /* viewId */); sectionInfo.setId(viewId); - textView.setText(sectionInfo.sectionName); if (i == fastScrollSections.size() - 1) { // The last section info is just a duplicate so that user can scroll to the bottom. textView.setVisibility(INVISIBLE); } - ConstraintLayout.LayoutParams lp = new ConstraintLayout.LayoutParams( - MATCH_CONSTRAINT, WRAP_CONTENT); - lp.dimensionRatio = "v,1:1"; - textView.setLayoutParams(lp); textViews.add(textView); mLetterList.addView(textView); } diff --git a/src/com/android/launcher3/allapps/AlphabeticalAppsList.java b/src/com/android/launcher3/allapps/AlphabeticalAppsList.java index 8e44d65d50..dd45a97d76 100644 --- a/src/com/android/launcher3/allapps/AlphabeticalAppsList.java +++ b/src/com/android/launcher3/allapps/AlphabeticalAppsList.java @@ -124,7 +124,8 @@ public class AlphabeticalAppsList implement mAllAppsStore.addUpdateListener(this); } mPrivateProfileAppScrollerBadge = new SpannableString(" "); - mPrivateProfileAppScrollerBadge.setSpan(new ImageSpan(context, + mPrivateProfileAppScrollerBadge.setSpan(new ImageSpan(context, Flags.letterFastScroller() + ? R.drawable.ic_private_profile_letter_list_fast_scroller_badge : R.drawable.ic_private_profile_app_scroller_badge, ImageSpan.ALIGN_CENTER), 0, 1, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE); } @@ -437,8 +438,11 @@ public class AlphabeticalAppsList implement Log.d(TAG, "addAppsWithSections: adding sectionName: " + sectionName + " with appInfoTitle: " + info.title); lastSectionName = sectionName; - mFastScrollerSections.add(new FastScrollSectionInfo(hasPrivateApps ? - mPrivateProfileAppScrollerBadge : sectionName, position)); + boolean usePrivateAppScrollerBadge = !Flags.letterFastScroller() && hasPrivateApps; + FastScrollSectionInfo sectionInfo = new FastScrollSectionInfo( + usePrivateAppScrollerBadge ? + mPrivateProfileAppScrollerBadge : sectionName, position); + mFastScrollerSections.add(sectionInfo); } position++; } diff --git a/src/com/android/launcher3/allapps/LetterListTextView.java b/src/com/android/launcher3/allapps/LetterListTextView.java index 9326d79f18..433a7f2e7d 100644 --- a/src/com/android/launcher3/allapps/LetterListTextView.java +++ b/src/com/android/launcher3/allapps/LetterListTextView.java @@ -16,6 +16,9 @@ package com.android.launcher3.allapps; +import static androidx.constraintlayout.widget.ConstraintSet.MATCH_CONSTRAINT; +import static androidx.constraintlayout.widget.ConstraintSet.WRAP_CONTENT; + import android.content.Context; import android.graphics.PorterDuff; import android.graphics.PorterDuffColorFilter; @@ -23,6 +26,7 @@ import android.graphics.drawable.Drawable; import android.util.AttributeSet; import android.widget.TextView; +import androidx.constraintlayout.widget.ConstraintLayout; import androidx.core.graphics.ColorUtils; import com.android.launcher3.R; @@ -70,6 +74,20 @@ public class LetterListTextView extends TextView { setVisibility(VISIBLE); } + /** + * Applies a viewId to the letter list text view and sets the background and text based on the + * sectionInfo. + */ + public void apply(AlphabeticalAppsList.FastScrollSectionInfo fastScrollSectionInfo, + int viewId) { + setId(viewId); + setText(fastScrollSectionInfo.sectionName); + ConstraintLayout.LayoutParams lp = new ConstraintLayout.LayoutParams( + MATCH_CONSTRAINT, WRAP_CONTENT); + lp.dimensionRatio = "v,1:1"; + setLayoutParams(lp); + } + /** * Animates the letter list text view based on the current finger position. * From c9ac51c521b43edf4f64e2a47fb2e52444e2add9 Mon Sep 17 00:00:00 2001 From: Brandon Dayauon Date: Tue, 24 Sep 2024 14:52:35 -0700 Subject: [PATCH 2/2] Add spannedDrawable for the divider in the letter fastScroller. Divider exported from: https://www.figma.com/design/uMzPkNMZpb7EyfHDo8usIa/V-%E2%80%A2-Toast-Butter?node-id=2751-194737&node-type=frame&m=dev bug:358673724 Test photo: https://drive.google.com/file/d/1I_Mu7mjxboP3puAJuiA9X9V3ogFR0oin/view?usp=sharing Flag: com.android.launcher3.letter_fast_scroller Change-Id: Ica5f05befbd63dc93b9c50bbbd6821cd931d148b --- .../ic_private_profile_divider_badge.xml | 26 +++++++++++++++++++ .../allapps/AlphabeticalAppsList.java | 10 +++++++ 2 files changed, 36 insertions(+) create mode 100644 res/drawable/ic_private_profile_divider_badge.xml diff --git a/res/drawable/ic_private_profile_divider_badge.xml b/res/drawable/ic_private_profile_divider_badge.xml new file mode 100644 index 0000000000..07c740d912 --- /dev/null +++ b/res/drawable/ic_private_profile_divider_badge.xml @@ -0,0 +1,26 @@ + + + + + + diff --git a/src/com/android/launcher3/allapps/AlphabeticalAppsList.java b/src/com/android/launcher3/allapps/AlphabeticalAppsList.java index dd45a97d76..709b52a174 100644 --- a/src/com/android/launcher3/allapps/AlphabeticalAppsList.java +++ b/src/com/android/launcher3/allapps/AlphabeticalAppsList.java @@ -106,6 +106,7 @@ public class AlphabeticalAppsList implement // The of ordered component names as a result of a search query private final ArrayList mSearchResults = new ArrayList<>(); private final SpannableString mPrivateProfileAppScrollerBadge; + private final SpannableString mPrivateProfileDividerBadge; private BaseAllAppsAdapter mAdapter; private AppInfoComparator mAppNameComparator; private int mNumAppsPerRowAllApps; @@ -128,6 +129,10 @@ public class AlphabeticalAppsList implement ? R.drawable.ic_private_profile_letter_list_fast_scroller_badge : R.drawable.ic_private_profile_app_scroller_badge, ImageSpan.ALIGN_CENTER), 0, 1, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE); + mPrivateProfileDividerBadge = new SpannableString(" "); + mPrivateProfileDividerBadge.setSpan(new ImageSpan(context, + R.drawable.ic_private_profile_divider_badge, ImageSpan.ALIGN_CENTER), + 0, 1, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE); } /** Set the number of apps per row when device profile changes. */ @@ -405,6 +410,11 @@ public class AlphabeticalAppsList implement // Add system apps separator. if (Flags.privateSpaceSysAppsSeparation()) { position = mPrivateProviderManager.addSystemAppsDivider(mAdapterItems); + if (Flags.letterFastScroller()) { + FastScrollSectionInfo sectionInfo = + new FastScrollSectionInfo(mPrivateProfileDividerBadge, position); + mFastScrollerSections.add(sectionInfo); + } } // Add system apps. position = addAppsWithSections(split.get(false), position);