Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit a1af2cee authored by Brandon Dayauon's avatar Brandon Dayauon
Browse files

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
parent f15a9660
Loading
Loading
Loading
Loading
+28 −0
Original line number Diff line number Diff line
<!--
  ~ 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" xmlns:aapt="http://schemas.android.com/aapt"
    android:viewportWidth="32"
    android:viewportHeight="32"
    android:width="32dp"
    android:height="32dp">
    <path
        android:pathData="M16.0007 2.66602L5.33398 6.66602V14.786C5.33398 21.5194 9.88065 27.7993 16.0007 29.3327C22.1207 27.7993 26.6673 21.5194 26.6673 14.786V6.66602L16.0007 2.66602ZM20.0007 19.9993V22.666H17.334V23.9993H14.6673V17.1193C12.7473 16.546 11.334 14.786 11.334 12.666C11.334 10.0927 13.4273 7.99935 16.0007 7.99935C18.574 7.99935 20.6673 10.0927 20.6673 12.666C20.6673 14.7727 19.254 16.546 17.334 17.1193V19.9993H20.0007Z"
        android:fillType="evenOdd"
        android:fillColor="@android:color/white" />
    <path
        android:pathData="M16 14.666C17.1046 14.666 18 13.7706 18 12.666C18 11.5614 17.1046 10.666 16 10.666C14.8954 10.666 14 11.5614 14 12.666C14 13.7706 14.8954 14.666 16 14.666Z"
        android:fillColor="@android:color/white" />
</vector>
+1 −11
Original line number Diff line number Diff line
@@ -155,7 +155,7 @@ public abstract class FastScrollRecyclerView extends RecyclerView {
     * Maps the touch (from 0..1) to the adapter position that should be visible.
     * <p>Override in each subclass of this base class.
     */
    public abstract String scrollToPositionAtProgress(float touchFraction);
    public abstract CharSequence scrollToPositionAtProgress(float touchFraction);

    /**
     * Updates the bounds for the scrollbar.
@@ -193,14 +193,4 @@ public abstract class FastScrollRecyclerView extends RecyclerView {
        }
        scrollToPosition(0);
    }

    /**
     * Scrolls this recycler view to the bottom with easing and duration.
     */
    public void scrollToBottomWithMotion(int duration) {
        if (mScrollbar != null) {
            mScrollbar.reattachThumbToScroll();
        }
        smoothScrollBy(0, getAvailableScrollHeight(), Interpolators.EMPHASIZED, duration);
    }
}
+1 −1
Original line number Diff line number Diff line
@@ -180,7 +180,7 @@ public class AllAppsRecyclerView extends FastScrollRecyclerView {
     * Maps the touch (from 0..1) to the adapter position that should be visible.
     */
    @Override
    public String scrollToPositionAtProgress(float touchFraction) {
    public CharSequence scrollToPositionAtProgress(float touchFraction) {
        int rowCount = mApps.getNumAppRows();
        if (rowCount == 0) {
            return "";
+16 −5
Original line number Diff line number Diff line
@@ -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;
    }

    /**
+4 −3
Original line number Diff line number Diff line
@@ -30,6 +30,7 @@ import android.graphics.Paint;
import android.graphics.Point;
import android.graphics.Rect;
import android.graphics.RectF;
import android.text.TextUtils;
import android.util.AttributeSet;
import android.util.Log;
import android.util.Property;
@@ -121,7 +122,7 @@ public class RecyclerViewFastScroller extends View {
    // Fast scroller popup
    private TextView mPopupView;
    private boolean mPopupVisible;
    private String mPopupSectionName;
    private CharSequence mPopupSectionName;
    private Insets mSystemGestureInsets;

    protected FastScrollRecyclerView mRv;
@@ -307,13 +308,13 @@ public class RecyclerViewFastScroller extends View {
        // Update the fastscroller section name at this touch position
        int bottom = mRv.getScrollbarTrackHeight() - mThumbHeight;
        float boundedY = (float) Math.max(0, Math.min(bottom, y - mTouchOffsetY));
        String sectionName = mRv.scrollToPositionAtProgress(boundedY / bottom);
        CharSequence sectionName = mRv.scrollToPositionAtProgress(boundedY / bottom);
        if (!sectionName.equals(mPopupSectionName)) {
            mPopupSectionName = sectionName;
            mPopupView.setText(sectionName);
            performHapticFeedback(CLOCK_TICK);
        }
        animatePopupVisibility(!sectionName.isEmpty());
        animatePopupVisibility(!TextUtils.isEmpty(sectionName));
        mLastTouchY = boundedY;
        setThumbOffsetY((int) mLastTouchY);
    }
Loading