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

Commit 01a29794 authored by Shamali P's avatar Shamali P Committed by Shamali Patwa
Browse files

Fix issue that expanded widgets appear before next item moved down

Issue - http://screen/AYyCKCWZH4uYeBp

* Before - http:/screencast/cast/NTc1NzE0MTg1NDk3ODA0OHwyNjA4ZmU5OC02ZQ
* After - http://screencast/cast/NDcyNTkzNzcyMjYyMTk1MnwxNmU1MTRmNy1jMw

Additionally, also fixes problem that fade in for some expanded sections
didn't always happen.

Bug: 332457155
Flag: N/A
Test: Manual (see video)
Change-Id: Iad3a341d9b992c72b61492d57db4faa96a06ecfa
parent da82c82a
Loading
Loading
Loading
Loading
+27 −1
Original line number Diff line number Diff line
@@ -21,6 +21,7 @@ import static com.android.launcher3.LauncherPrefs.WIDGETS_EDUCATION_DIALOG_SEEN;
import static com.android.launcher3.allapps.ActivityAllAppsContainerView.AdapterHolder.SEARCH;
import static com.android.launcher3.logging.StatsLogManager.LauncherEvent.LAUNCHER_WIDGETSTRAY_SEARCHED;
import static com.android.launcher3.testing.shared.TestProtocol.NORMAL_STATE_ORDINAL;
import static com.android.launcher3.widget.picker.WidgetsListAdapter.VIEW_TYPE_WIDGETS_LIST;

import android.animation.Animator;
import android.content.Context;
@@ -1094,10 +1095,35 @@ public class WidgetsFullSheet extends BaseWidgetSheet
                default:
                    break;
            }
            mWidgetsListItemAnimator = new DefaultItemAnimator();
            mWidgetsListItemAnimator = new DefaultItemAnimator() {
                @Override
                public boolean animateChange(RecyclerView.ViewHolder oldHolder,
                        RecyclerView.ViewHolder newHolder, int fromLeft, int fromTop, int toLeft,
                        int toTop) {
                    // As we expand an item, the content / widgets list that appears (with add
                    // event) also gets change events as its previews load asynchronously. The
                    // super implementation of animateChange cancels the animations on it - breaking
                    // the "add animation". Instead, here, we skip "change" animation for content
                    // list - because we want it to either appear or disappear. And, the previews
                    // themselves have their own animation when loaded, so, we don't need change
                    // animations for them anyway. Below, we do-nothing.
                    if (oldHolder.getItemViewType() == VIEW_TYPE_WIDGETS_LIST) {
                        dispatchChangeStarting(oldHolder, true);
                        dispatchChangeFinished(oldHolder, true);
                        return true;
                    }
                    return super.animateChange(oldHolder, newHolder, fromLeft, fromTop, toLeft,
                            toTop);
                }
            };
            // Disable change animations because it disrupts the item focus upon adapter item
            // change.
            mWidgetsListItemAnimator.setSupportsChangeAnimations(false);
            // Make the moves a bit faster, so that the amount of time for which user sees the
            // bottom-sheet background before "add" animation starts is less making it smoother.
            mWidgetsListItemAnimator.setChangeDuration(90);
            mWidgetsListItemAnimator.setMoveDuration(90);
            mWidgetsListItemAnimator.setAddDuration(300);
        }

        private int getEmptySpaceHeight() {