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

Commit b9ed7c15 authored by Helen Cheuk's avatar Helen Cheuk Committed by Android (Google) Code Review
Browse files

Merge "Disable launcher focus outline animation" into main

parents e91b4b52 ce0f8595
Loading
Loading
Loading
Loading
+4 −1
Original line number Diff line number Diff line
@@ -485,7 +485,10 @@ public abstract class PagedView<T extends View & PageIndicator> extends ViewGrou
        super.onVisibilityAggregated(isVisible);
    }

    protected boolean isPageInTransition() {
    /**
     * Returns true if the page is in the middle of transition to another page
     */
    public boolean isPageInTransition() {
        return mIsPageInTransition;
    }

+2 −1
Original line number Diff line number Diff line
@@ -246,7 +246,8 @@ public abstract class ItemFocusIndicatorHelper<T> implements AnimatorUpdateListe

    protected void setCurrentItem(T item) {
        mCurrentItem = item;
        mShift = 0;
        // Set it to end value directly to skip the animation for outline
        mShift = Flags.enableFocusOutline() ? 1 : 0;
        mTargetItem = null;
    }

+23 −0
Original line number Diff line number Diff line
@@ -19,6 +19,7 @@ package com.android.launcher3.keyboard;
import android.graphics.Rect;
import android.view.View;

import com.android.launcher3.Flags;
import com.android.launcher3.PagedView;

/**
@@ -34,6 +35,28 @@ public class ViewGroupFocusHelper extends FocusIndicatorHelper {
        mContainer = container;
    }

    @Override
    protected boolean shouldDraw(View item) {
        if (Flags.enableFocusOutline()) {
            // Not draw outline in page transition because the outline just remains fully
            // persistent during the transition and does not look smooth
            return super.shouldDraw(item) && !isInPageTransition(item);
        } else {
            return super.shouldDraw(item);
        }
    }

    private boolean isInPageTransition(View view) {
        if (view == null || !(view.getParent() instanceof View)) {
            return false;
        }
        boolean isInTransition = false;
        if (view instanceof PagedView) {
            isInTransition = ((PagedView<?>) view).isPageInTransition();
        }
        return isInTransition || isInPageTransition((View) view.getParent());
    }

    @Override
    public void viewToRect(View v, Rect outRect) {
        // Using FocusedRect here allows views to provide their custom rect for drawing outline,