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

Commit 3003e57d authored by Hyunyoung Song's avatar Hyunyoung Song Committed by Android (Google) Code Review
Browse files

Merge "Handle IME selection focus for ENABLE_DEVICE_SEARCH" into ub-launcher3-master

parents fe9b7e37 5dd045be
Loading
Loading
Loading
Loading
+5 −0
Original line number Original line Diff line number Diff line
@@ -310,4 +310,9 @@ public class AppsDividerView extends View implements StateListener<LauncherState
    public Class<AppsDividerView> getTypeClass() {
    public Class<AppsDividerView> getTypeClass() {
        return AppsDividerView.class;
        return AppsDividerView.class;
    }
    }

    @Override
    public View getFocusedChild() {
        return null;
    }
}
}
+7 −1
Original line number Original line Diff line number Diff line
@@ -169,6 +169,7 @@ public class PredictionRowView extends LinearLayout implements
                mDecorationHandler.extendBounds(getChildAt(i));
                mDecorationHandler.extendBounds(getChildAt(i));
            }
            }
            mDecorationHandler.onDraw(canvas);
            mDecorationHandler.onDraw(canvas);
            mDecorationHandler.onFocusDraw(canvas, getFocusedChild());
        }
        }
        mFocusHelper.draw(canvas);
        mFocusHelper.draw(canvas);
        super.dispatchDraw(canvas);
        super.dispatchDraw(canvas);
@@ -183,7 +184,7 @@ public class PredictionRowView extends LinearLayout implements


    @Override
    @Override
    public boolean shouldDraw() {
    public boolean shouldDraw() {
        return getVisibility() != GONE;
        return getVisibility() == VISIBLE;
    }
    }


    @Override
    @Override
@@ -364,4 +365,9 @@ public class PredictionRowView extends LinearLayout implements
    public Class<PredictionRowView> getTypeClass() {
    public Class<PredictionRowView> getTypeClass() {
        return PredictionRowView.class;
        return PredictionRowView.class;
    }
    }

    @Override
    public View getFocusedChild() {
        return getChildAt(0);
    }
}
}
+2 −1
Original line number Original line Diff line number Diff line
@@ -35,7 +35,8 @@


    <color name="icon_background">#E0E0E0</color> <!-- Gray 300 -->
    <color name="icon_background">#E0E0E0</color> <!-- Gray 300 -->


    <color name="all_apps_section_fill">#327d7d7d</color>
    <color name="all_apps_section_fill">#32c0c0c0</color>
    <color name="all_apps_section_focused_item">#40c0c0c0</color>


    <color name="gesture_tutorial_ripple_color">#A0C2F9</color> <!-- Light Blue -->
    <color name="gesture_tutorial_ripple_color">#A0C2F9</color> <!-- Light Blue -->
    <color name="gesture_tutorial_fake_task_view_color">#6DA1FF</color> <!-- Light Blue -->
    <color name="gesture_tutorial_fake_task_view_color">#6DA1FF</color> <!-- Light Blue -->
+18 −1
Original line number Original line Diff line number Diff line
@@ -527,6 +527,22 @@ public class AllAppsContainerView extends SpringRelativeLayout implements DragSo
        return mViewPager == null ? getActiveRecyclerView() : mViewPager;
        return mViewPager == null ? getActiveRecyclerView() : mViewPager;
    }
    }


    /**
     * Returns the ItemInfo of a view that is in focus, ready to be launched by an IME.
     */
    public ItemInfo getHighlightedItemInfo() {
        View view = getFloatingHeaderView().getFocusedChild();
        if (view != null && view.getTag() instanceof ItemInfo) {
            return ((ItemInfo) view.getTag());
        }
        if (getActiveRecyclerView().getApps().getFocusedChild() != null) {
            // TODO: when new pipelines are included, getSearchResults
            // should be supported at recycler view level and not apps list level.
            return getActiveRecyclerView().getApps().getFocusedChild().appInfo;
        }
        return null;
    }

    public RecyclerViewFastScroller getScrollBar() {
    public RecyclerViewFastScroller getScrollBar() {
        AllAppsRecyclerView rv = getActiveRecyclerView();
        AllAppsRecyclerView rv = getActiveRecyclerView();
        return rv == null ? null : rv.getScrollbar();
        return rv == null ? null : rv.getScrollbar();
@@ -658,7 +674,8 @@ public class AllAppsContainerView extends SpringRelativeLayout implements DragSo
            applyPadding();
            applyPadding();
            setupOverlay();
            setupOverlay();
            if (FeatureFlags.ENABLE_DEVICE_SEARCH.get()) {
            if (FeatureFlags.ENABLE_DEVICE_SEARCH.get()) {
                recyclerView.addItemDecoration(new AllAppsSectionDecorator(getApps()));
                recyclerView.addItemDecoration(new AllAppsSectionDecorator(
                        AllAppsContainerView.this));
            }
            }
        }
        }


+34 −11
Original line number Original line Diff line number Diff line
@@ -21,6 +21,7 @@ import android.graphics.Paint;
import android.graphics.RectF;
import android.graphics.RectF;
import android.view.View;
import android.view.View;


import androidx.annotation.Nullable;
import androidx.recyclerview.widget.RecyclerView;
import androidx.recyclerview.widget.RecyclerView;


import com.android.launcher3.R;
import com.android.launcher3.R;
@@ -34,19 +35,19 @@ import java.util.List;
 */
 */
public class AllAppsSectionDecorator extends RecyclerView.ItemDecoration {
public class AllAppsSectionDecorator extends RecyclerView.ItemDecoration {


    private final AlphabeticalAppsList mApps;
    private final AllAppsContainerView mAppsView;


    AllAppsSectionDecorator(AlphabeticalAppsList appsList) {
    AllAppsSectionDecorator(AllAppsContainerView appsContainerView) {
        mApps = appsList;
        mAppsView = appsContainerView;
    }
    }


    @Override
    @Override
    public void onDraw(Canvas c, RecyclerView parent, RecyclerView.State state) {
    public void onDraw(Canvas c, RecyclerView parent, RecyclerView.State state) {
        // Iterate through views in recylerview and draw bounds around views in the same section.
        // Iterate through views in recylerview and draw bounds around views in the same section.
        // Since views in the same section will follow each other, we can skip to a last view in
        // Since views in the same section will follow each other, we can skip to a last view in
        // a section to get the bounds of the section without having to iterate on evert item.
        // a section to get the bounds of the section without having to iterate on every item.
        int itemCount = parent.getChildCount();
        int itemCount = parent.getChildCount();
        List<AlphabeticalAppsList.AdapterItem> adapterItems = mApps.getAdapterItems();
        List<AlphabeticalAppsList.AdapterItem> adapterItems = mAppsView.getApps().getAdapterItems();
        SectionDecorationHandler lastDecorationHandler = null;
        SectionDecorationHandler lastDecorationHandler = null;
        int i = 0;
        int i = 0;
        while (i < itemCount) {
        while (i < itemCount) {
@@ -69,7 +70,6 @@ public class AllAppsSectionDecorator extends RecyclerView.ItemDecoration {
                    i = endIndex;
                    i = endIndex;
                    continue;
                    continue;
                }
                }

            }
            }
            i++;
            i++;
        }
        }
@@ -78,13 +78,21 @@ public class AllAppsSectionDecorator extends RecyclerView.ItemDecoration {
        }
        }
    }
    }


    private void drawDecoration(Canvas c, SectionDecorationHandler decorationHandler, View parent) {
    private void drawDecoration(Canvas c, SectionDecorationHandler decorationHandler,
            RecyclerView parent) {
        if (decorationHandler == null) return;
        if (decorationHandler == null) return;
        if (decorationHandler.mIsFullWidth) {
        if (decorationHandler.mIsFullWidth) {
            decorationHandler.mBounds.left = parent.getPaddingLeft();
            decorationHandler.mBounds.left = parent.getPaddingLeft();
            decorationHandler.mBounds.right = parent.getWidth() - parent.getPaddingRight();
            decorationHandler.mBounds.right = parent.getWidth() - parent.getPaddingRight();
        }
        }
        decorationHandler.onDraw(c);
        decorationHandler.onDraw(c);
        if (mAppsView.getFloatingHeaderView().getFocusedChild() == null
                && mAppsView.getApps().getFocusedChild() != null) {
            int index = mAppsView.getApps().getFocusedChildIndex();
            if (index >= 0 && index < parent.getChildCount()) {
                decorationHandler.onFocusDraw(c, parent.getChildAt(index));
            }
        }
        decorationHandler.reset();
        decorationHandler.reset();
    }
    }


@@ -95,18 +103,21 @@ public class AllAppsSectionDecorator extends RecyclerView.ItemDecoration {
        protected RectF mBounds = new RectF();
        protected RectF mBounds = new RectF();
        private final boolean mIsFullWidth;
        private final boolean mIsFullWidth;
        private final float mRadius;
        private final float mRadius;

        private final int mFocusColor;
        private final int mFillcolor;
        private final int mFillcolor;
        Paint mPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
        private final Paint mPaint = new Paint(Paint.ANTI_ALIAS_FLAG);




        public SectionDecorationHandler(Context context, boolean isFullWidth) {
        public SectionDecorationHandler(Context context, boolean isFullWidth) {
            mIsFullWidth = isFullWidth;
            mIsFullWidth = isFullWidth;
            mFillcolor = context.getColor(R.color.all_apps_section_fill);
            mFillcolor = context.getColor(R.color.all_apps_section_fill);
            mFocusColor = context.getColor(R.color.all_apps_section_focused_item);
            mRadius = Themes.getDialogCornerRadius(context);
            mRadius = Themes.getDialogCornerRadius(context);
        }
        }


        /**
        /**
         * Extends current bounds to include view
         * Extends current bounds to include the view.
         */
         */
        public void extendBounds(View view) {
        public void extendBounds(View view) {
            if (mBounds.isEmpty()) {
            if (mBounds.isEmpty()) {
@@ -122,7 +133,7 @@ public class AllAppsSectionDecorator extends RecyclerView.ItemDecoration {
        }
        }


        /**
        /**
         * Draw bounds onto canvas
         * Draw bounds onto canvas.
         */
         */
        public void onDraw(Canvas canvas) {
        public void onDraw(Canvas canvas) {
            mPaint.setColor(mFillcolor);
            mPaint.setColor(mFillcolor);
@@ -130,7 +141,19 @@ public class AllAppsSectionDecorator extends RecyclerView.ItemDecoration {
        }
        }


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

        /**
         * Reset view bounds to empty.
         */
         */
        public void reset() {
        public void reset() {
            mBounds.setEmpty();
            mBounds.setEmpty();
Loading