Merge changes from topic "fastScrollerPrivateSpaceDrawableToLetters" into main

* changes:
  Add spannedDrawable for the divider in the letter fastScroller.
  Only have private space drawable section for beginning of private space section and keep letters for everything else.
This commit is contained in:
Brandon Dayauon
2024-10-11 22:33:53 +00:00
committed by Android (Google) Code Review
5 changed files with 90 additions and 9 deletions
@@ -0,0 +1,26 @@
<!--
~ Copyright (C) 2024 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="20dp"
android:height="20dp"
android:viewportWidth="20"
android:viewportHeight="20">
<group>
<path
android:pathData="M5,9L15,9A1,1 0,0 1,16 10L16,10A1,1 0,0 1,15 11L5,11A1,1 0,0 1,4 10L4,10A1,1 0,0 1,5 9z"
android:fillColor="?attr/materialColorOnSurface"/>
</group>
</vector>
@@ -0,0 +1,28 @@
<!--
~ Copyright (C) 2024 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="12dp"
android:height="15dp"
android:viewportWidth="12"
android:viewportHeight="15">
<path
android:pathData="M5.952,0.911L0.645,2.902V6.942C0.645,10.292 2.907,13.417 5.952,14.18C8.997,13.417 11.26,10.292 11.26,6.942V2.902L5.952,0.911ZM7.943,9.536V10.863H6.616V11.526H5.289V8.103C4.333,7.818 3.63,6.942 3.63,5.887C3.63,4.607 4.672,3.565 5.952,3.565C7.233,3.565 8.274,4.607 8.274,5.887C8.274,6.935 7.571,7.818 6.616,8.103V9.536H7.943Z"
android:fillColor="#3C4043"
android:fillType="evenOdd"/>
<path
android:pathData="M5.952,6.882C6.502,6.882 6.947,6.436 6.947,5.887C6.947,5.337 6.502,4.892 5.952,4.892C5.403,4.892 4.957,5.337 4.957,5.887C4.957,6.436 5.403,6.882 5.952,6.882Z"
android:fillColor="#3C4043"/>
</vector>
@@ -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);
}
@@ -106,6 +106,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 final SpannableString mPrivateProfileDividerBadge;
private BaseAllAppsAdapter<T> mAdapter;
private AppInfoComparator mAppNameComparator;
private int mNumAppsPerRowAllApps;
@@ -124,9 +125,14 @@ public class AlphabeticalAppsList<T extends Context & ActivityContext> 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);
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. */
@@ -404,6 +410,11 @@ public class AlphabeticalAppsList<T extends Context & ActivityContext> 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);
@@ -437,8 +448,11 @@ public class AlphabeticalAppsList<T extends Context & ActivityContext> 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++;
}
@@ -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.
*