Disable launcher focus outline animation

Bug: 335424188
Test: Manual
Flag: ACONFIG com.android.launcher3.enable_focus_outline Teamfood
Change-Id: I31c63607c914da956d7c6139cc5089fe419f40e1
This commit is contained in:
helencheuk
2024-04-24 11:37:30 +01:00
parent 2fb15b12d5
commit ce0f8595b7
3 changed files with 29 additions and 2 deletions
+4 -1
View File
@@ -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;
}
@@ -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;
}
@@ -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,