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

Commit c07e3b3c authored by Hyunyoung Song's avatar Hyunyoung Song
Browse files

Remove AA+ decorator logic from aosp code

Bug: 179495850
Test: manual

Change-Id: I7e029e4970f45a0f7c410533f85335a95e4e448c
parent fe158fab
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -329,6 +329,6 @@ public abstract class BaseDraggingActivity extends BaseActivity
     * views
     */
    public SearchAdapterProvider createSearchAdapterProvider(AllAppsContainerView allapps) {
        return new DefaultSearchAdapterProvider(this);
        return new DefaultSearchAdapterProvider(this, allapps);
    }
}
+1 −2
Original line number Diff line number Diff line
@@ -699,8 +699,7 @@ public class AllAppsContainerView extends SpringRelativeLayout implements DragSo
            applyPadding();
            setupOverlay();
            if (FeatureFlags.ENABLE_DEVICE_SEARCH.get()) {
                recyclerView.addItemDecoration(new AllAppsSectionDecorator(
                        AllAppsContainerView.this));
                recyclerView.addItemDecoration(mSearchAdapterProvider.getDecorator());
            }
        }

+1 −2
Original line number Diff line number Diff line
@@ -42,7 +42,6 @@ import com.android.launcher3.BaseDraggingActivity;
import com.android.launcher3.BubbleTextView;
import com.android.launcher3.R;
import com.android.launcher3.allapps.search.SearchAdapterProvider;
import com.android.launcher3.allapps.search.SectionDecorationInfo;
import com.android.launcher3.model.data.AppInfo;
import com.android.launcher3.util.PackageManagerHelper;

@@ -108,7 +107,7 @@ public class AllAppsGridAdapter extends
        // The index of this app not including sections
        public int appIndex = -1;
        // Search section associated to result
        public SectionDecorationInfo sectionDecorationInfo = null;
        public DecorationInfo decorationInfo = null;

        /**
         * Factory method for AppIcon AdapterItem
+0 −150
Original line number Diff line number Diff line
/*
 * Copyright (C) 2020 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.
 */
package com.android.launcher3.allapps;

import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Paint;
import android.graphics.Path;
import android.graphics.RectF;
import android.view.View;

import androidx.annotation.Nullable;
import androidx.core.graphics.ColorUtils;
import androidx.recyclerview.widget.RecyclerView;

import com.android.launcher3.R;
import com.android.launcher3.allapps.search.SearchAdapterProvider;
import com.android.launcher3.allapps.search.SectionDecorationInfo;
import com.android.launcher3.util.Themes;

import java.util.List;

/**
 * ItemDecoration class that groups items in {@link AllAppsRecyclerView}
 */
public class AllAppsSectionDecorator extends RecyclerView.ItemDecoration {

    private final AllAppsContainerView mAppsView;

    AllAppsSectionDecorator(AllAppsContainerView appsContainerView) {
        mAppsView = appsContainerView;
    }

    @Override
    public void onDraw(Canvas c, RecyclerView parent, RecyclerView.State state) {
        List<AllAppsGridAdapter.AdapterItem> adapterItems = mAppsView.getApps().getAdapterItems();
        SearchAdapterProvider adapterProvider = mAppsView.getSearchAdapterProvider();
        for (int i = 0; i < parent.getChildCount(); i++) {
            View view = parent.getChildAt(i);
            int position = parent.getChildAdapterPosition(view);
            AllAppsGridAdapter.AdapterItem adapterItem = adapterItems.get(position);
            if (adapterItem.sectionDecorationInfo != null) {
                SectionDecorationInfo sectionInfo = adapterItem.sectionDecorationInfo;
                SectionDecorationHandler decorationHandler = sectionInfo.getDecorationHandler();
                if (decorationHandler != null) {
                    if (view.equals(adapterProvider.getHighlightedItem())) {
                        decorationHandler.onFocusDraw(c, view);
                    } else {
                        decorationHandler.onGroupDraw(c, view);
                    }
                }
            }
        }
    }

    /**
     * Handles grouping and drawing of items in the same all apps sections.
     */
    public static class SectionDecorationHandler {
        protected RectF mBounds = new RectF();
        private final boolean mIsFullWidth;
        private final float mRadius;

        protected final int mFocusColor; // main focused item color
        protected final int mFillcolor; // grouping color

        private final Paint mPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
        private final boolean mIsTopRound;
        private final boolean mIsBottomRound;
        private float[] mCorners;
        private float mFillSpacing;

        public SectionDecorationHandler(Context context, boolean isFullWidth, int fillAlpha,
                boolean isTopRound, boolean isBottomRound) {

            mIsFullWidth = isFullWidth;
            int endScrim = Themes.getColorBackground(context);
            mFillcolor = ColorUtils.setAlphaComponent(endScrim, fillAlpha);
            mFocusColor = endScrim;

            mIsTopRound = isTopRound;
            mIsBottomRound = isBottomRound;

            mRadius = context.getResources().getDimensionPixelSize(
                    R.dimen.search_decoration_corner_radius);
            mFillSpacing = context.getResources().getDimensionPixelSize(
                    R.dimen.search_decoration_padding);
            mCorners = new float[]{
                    mIsTopRound ? mRadius : 0, mIsTopRound ? mRadius : 0, // Top left radius in px
                    mIsTopRound ? mRadius : 0, mIsTopRound ? mRadius : 0, // Top right radius in px
                    mIsBottomRound ? mRadius : 0, mIsBottomRound ? mRadius : 0, // Bottom right
                    mIsBottomRound ? mRadius : 0, mIsBottomRound ? mRadius : 0  // Bottom left
            };

        }

        /**
         * Draw bounds onto canvas.
         */
        public void onGroupDraw(Canvas canvas, View view) {
            if (view == null) return;
            mPaint.setColor(mFillcolor);
            mBounds.set(view.getLeft(), view.getTop(), view.getRight(), view.getBottom());
            onDraw(canvas);
        }

        /**
         * Draw the bound of the view to the canvas.
         */
        public void onFocusDraw(Canvas canvas, @Nullable View view) {
            if (view == null) {
                return;
            }
            mPaint.setColor(mFocusColor);
            mBounds.set(view.getLeft(), view.getTop(), view.getRight(), view.getBottom());
            onDraw(canvas);
        }


        private void onDraw(Canvas canvas) {
            final Path path = new Path();
            RectF finalBounds = new RectF(mBounds.left + mFillSpacing,
                    mBounds.top + mFillSpacing,
                    mBounds.right - mFillSpacing,
                    mBounds.bottom - mFillSpacing);
            path.addRoundRect(finalBounds, mCorners, Path.Direction.CW);
            canvas.drawPath(path, mPaint);
        }

        /**
         * Reset view bounds to empty.
         */
        public void reset() {
            mBounds.setEmpty();
        }
    }
}
+1 −9
Original line number Diff line number Diff line
@@ -20,7 +20,6 @@ import android.content.Context;

import com.android.launcher3.BaseDraggingActivity;
import com.android.launcher3.allapps.AllAppsGridAdapter.AdapterItem;
import com.android.launcher3.allapps.search.SectionDecorationInfo;
import com.android.launcher3.config.FeatureFlags;
import com.android.launcher3.model.data.AppInfo;
import com.android.launcher3.util.ItemInfoMatcher;
@@ -288,11 +287,6 @@ public class AlphabeticalAppsList implements AllAppsStore.OnUpdateListener {
        mFastScrollerSections.clear();
        mAdapterItems.clear();

        SectionDecorationInfo appSection = new SectionDecorationInfo();
        appSection.setDecorationHandler(
                new AllAppsSectionDecorator.SectionDecorationHandler(mLauncher, true,
                        0, false, false));

        // Recreate the filtered and sectioned apps (for convenience for the grid layout) from the
        // ordered set of sections

@@ -313,9 +307,7 @@ public class AlphabeticalAppsList implements AllAppsStore.OnUpdateListener {
                if (lastFastScrollerSectionInfo.fastScrollToItem == null) {
                    lastFastScrollerSectionInfo.fastScrollToItem = appItem;
                }
                if (FeatureFlags.ENABLE_DEVICE_SEARCH.get()) {
                    appItem.sectionDecorationInfo = appSection;
                }

                mAdapterItems.add(appItem);
            }
        } else {
Loading