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

Commit 8cd89cdd authored by Evan Rosky's avatar Evan Rosky
Browse files

Don't clear focus during transition animations

If a view is suppressing layout, it is probably part of a
transition animation. In this case, we don't want to defocus
a focused view which may eventually have a size.

Bug: 78302781
Test: issue in bug is resolved. Transition CTS tests still pass
Change-Id: I983f41bcd68056d2150d4db29c781b63a2c321c2
parent f3015eb0
Loading
Loading
Loading
Loading
+32 −32
Original line number Original line Diff line number Diff line
@@ -311,6 +311,38 @@ public class ChangeBounds extends Transition {
                ++numChanges;
                ++numChanges;
            }
            }
            if (numChanges > 0) {
            if (numChanges > 0) {
                if (view.getParent() instanceof ViewGroup) {
                    final ViewGroup parent = (ViewGroup) view.getParent();
                    parent.suppressLayout(true);
                    TransitionListener transitionListener = new TransitionListenerAdapter() {
                        boolean mCanceled = false;

                        @Override
                        public void onTransitionCancel(Transition transition) {
                            parent.suppressLayout(false);
                            mCanceled = true;
                        }

                        @Override
                        public void onTransitionEnd(Transition transition) {
                            if (!mCanceled) {
                                parent.suppressLayout(false);
                            }
                            transition.removeListener(this);
                        }

                        @Override
                        public void onTransitionPause(Transition transition) {
                            parent.suppressLayout(false);
                        }

                        @Override
                        public void onTransitionResume(Transition transition) {
                            parent.suppressLayout(true);
                        }
                    };
                    addListener(transitionListener);
                }
                Animator anim;
                Animator anim;
                if (!mResizeClip) {
                if (!mResizeClip) {
                    view.setLeftTopRightBottom(startLeft, startTop, startRight, startBottom);
                    view.setLeftTopRightBottom(startLeft, startTop, startRight, startBottom);
@@ -398,38 +430,6 @@ public class ChangeBounds extends Transition {
                    anim = TransitionUtils.mergeAnimators(positionAnimator,
                    anim = TransitionUtils.mergeAnimators(positionAnimator,
                            clipAnimator);
                            clipAnimator);
                }
                }
                if (view.getParent() instanceof ViewGroup) {
                    final ViewGroup parent = (ViewGroup) view.getParent();
                    parent.suppressLayout(true);
                    TransitionListener transitionListener = new TransitionListenerAdapter() {
                        boolean mCanceled = false;

                        @Override
                        public void onTransitionCancel(Transition transition) {
                            parent.suppressLayout(false);
                            mCanceled = true;
                        }

                        @Override
                        public void onTransitionEnd(Transition transition) {
                            if (!mCanceled) {
                                parent.suppressLayout(false);
                            }
                            transition.removeListener(this);
                        }

                        @Override
                        public void onTransitionPause(Transition transition) {
                            parent.suppressLayout(false);
                        }

                        @Override
                        public void onTransitionResume(Transition transition) {
                            parent.suppressLayout(true);
                        }
                    };
                    addListener(transitionListener);
                }
                return anim;
                return anim;
            }
            }
        } else {
        } else {
+3 −1
Original line number Original line Diff line number Diff line
@@ -20850,7 +20850,9 @@ public class View implements Drawable.Callback, KeyEvent.Callback,
        }
        }
        // If this isn't laid out yet, focus assignment will be handled during the "deferment/
        // If this isn't laid out yet, focus assignment will be handled during the "deferment/
        // backtracking" of requestFocus during layout, so don't touch focus here.
        // backtracking" of requestFocus during layout, so don't touch focus here.
        if (!sCanFocusZeroSized && isLayoutValid()) {
        if (!sCanFocusZeroSized && isLayoutValid()
                // Don't touch focus if animating
                && !(mParent instanceof ViewGroup && ((ViewGroup) mParent).isLayoutSuppressed())) {
            if (newWidth <= 0 || newHeight <= 0) {
            if (newWidth <= 0 || newHeight <= 0) {
                if (hasFocus()) {
                if (hasFocus()) {
                    clearFocus();
                    clearFocus();