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

Commit 136f9d6f authored by Brandon Dayauon's avatar Brandon Dayauon
Browse files

Move adding views logic to privateProfileManager

- Have the animation happen according to the state of private space.
- Have the transition happen only once by setting the current transition to null at the end of transition and by ensuring
where the transitions are allowed.
- Removing controller class.

- The onClick controls the enablement of the profile. On reset (when getting the transition) is what controls the animation
during expand.

tldr- In the collapse case:  execute() is called -> animation happens  -> addPsHeader
tldr- Expand case: post() is called -> addPsHeader -> animation happens.

Collapse:
onClick() -> AACV.onAppsUpdated() that resets & apply/RUNS runnable because EXECUTE
-> AAList.onAppsUpdated() (which is called at the same time animating happens which we should cancel and do at end callback)
-> AAList.onAppsUpdated() gets called again

Expand:
onCLick() -> AACV.onAppsUpdated() that resets & apply runnable
-> AAList.onAppsUpdated() (no animation running)
-> AAList.onAppsUpdated() (no animation running)
-> addPrivateSpaceHeader
-> then unlockAction() runnable because its posted at this point

bug: 326206132
bug: 330444548
bug: 299294792
Test: manually locally and presubmit: https://screenshot.googleplex.com/9wavvwKQ8hY6oUw & https://screenshot.googleplex.com/BiqmidLFjPwS28j
video: https://drive.google.com/file/d/1XGhmTncdUFtJj188_l7alGyyNz_fhXNw/view?usp=sharing

Scrolling fix before: https://drive.google.com/file/d/1XykDm4UELoCvcwZdj8ZlJ6TszptB8W0W/view?usp=sharing
scrolling fix after when not a lot of apps: https://drive.google.com/file/d/1Y4VY1eX7WE8ShSLXRrT56ieBdAuJo_zn/view?usp=sharing
scrolling fix after with a lot of apps: https://drive.google.com/file/d/1Y58c-Z9xnU1GILp0Ih-oLORXYkMB-jWn/view?usp=sharing
Flag: ACONFIG com.android.launcher3.Flags.private_space_animation

Change-Id: I8d03ae60e2c9fe0ec145c4b0a2e9604b9e6e9017
parent 75216f91
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -33,7 +33,7 @@
        android:layout_centerVertical="true"
        android:gravity="center_vertical"
        android:layout_alignParentEnd="true"
        android:animateLayoutChanges="true">
        android:animateLayoutChanges="false">
        <ImageButton
            android:id="@+id/ps_settings_button"
            android:layout_width="@dimen/ps_header_image_height"
+11 −13
Original line number Diff line number Diff line
@@ -70,7 +70,6 @@ import com.android.launcher3.DeviceProfile;
import com.android.launcher3.DeviceProfile.OnDeviceProfileChangeListener;
import com.android.launcher3.DragSource;
import com.android.launcher3.DropTarget.DragObject;
import com.android.launcher3.Flags;
import com.android.launcher3.Insettable;
import com.android.launcher3.InsettableFrameLayout;
import com.android.launcher3.R;
@@ -127,7 +126,6 @@ public class ActivityAllAppsContainerView<T extends Context & ActivityContext>
    public static final float PULL_MULTIPLIER = .02f;
    public static final float FLING_VELOCITY_MULTIPLIER = 1200f;
    protected static final String BUNDLE_KEY_CURRENT_PAGE = "launcher.allapps.current_page";
    private static final int SCROLL_TO_BOTTOM_DURATION = 500;
    private static final long DEFAULT_SEARCH_TRANSITION_DURATION_MS = 300;
    // Render the header protection at all times to debug clipping issues.
    private static final boolean DEBUG_HEADER_PROTECTION = false;
@@ -192,8 +190,6 @@ public class ActivityAllAppsContainerView<T extends Context & ActivityContext>
    private float mTotalHeaderProtectionHeight;
    @Nullable private AllAppsTransitionController mAllAppsTransitionController;

    private PrivateSpaceHeaderViewController mPrivateSpaceHeaderViewController;

    public ActivityAllAppsContainerView(Context context) {
        this(context, null);
    }
@@ -261,10 +257,6 @@ public class ActivityAllAppsContainerView<T extends Context & ActivityContext>
     */
    protected void initContent() {
        mMainAdapterProvider = mSearchUiDelegate.createMainAdapterProvider();
        if (Flags.enablePrivateSpace()) {
            mPrivateSpaceHeaderViewController =
                    new PrivateSpaceHeaderViewController(this, mPrivateProfileManager);
        }

        mAH.set(AdapterHolder.MAIN, new AdapterHolder(AdapterHolder.MAIN,
                new AlphabeticalAppsList<>(mActivityContext,
@@ -398,7 +390,7 @@ public class ActivityAllAppsContainerView<T extends Context & ActivityContext>
        mAllAppsTransitionController = allAppsTransitionController;
    }

    private void animateToSearchState(boolean goingToSearch, long durationMs) {
    void animateToSearchState(boolean goingToSearch, long durationMs) {
        if (!mSearchTransitionController.isRunning() && goingToSearch == isSearching()) {
            return;
        }
@@ -499,9 +491,9 @@ public class ActivityAllAppsContainerView<T extends Context & ActivityContext>
    }

    /**
     * Exits search and returns to A-Z apps list. Scroll to the bottom.
     * Exits search and returns to A-Z apps list. Scroll to the private space header.
     */
    public void resetAndScrollToBottom() {
    public void resetAndScrollToPrivateSpaceHeader() {
        if (mTouchHandler != null) {
            mTouchHandler.endFastScrolling();
        }
@@ -518,7 +510,13 @@ public class ActivityAllAppsContainerView<T extends Context & ActivityContext>
            // Switch to the main tab
            switchToTab(ActivityAllAppsContainerView.AdapterHolder.MAIN);
            // Scroll to bottom
            getActiveRecyclerView().scrollToBottomWithMotion(SCROLL_TO_BOTTOM_DURATION);
            if (mPrivateProfileManager != null) {
                mPrivateProfileManager.scrollForViewToBeVisibleInContainer(
                        getActiveAppsRecyclerView(),
                        getPersonalAppList().getAdapterItems(),
                        mPrivateProfileManager.getPsHeaderHeight(),
                        mActivityContext.getDeviceProfile().allAppsCellHeightPx);
            }
        });
    }

@@ -906,7 +904,7 @@ public class ActivityAllAppsContainerView<T extends Context & ActivityContext>

    protected BaseAllAppsAdapter<T> createAdapter(AlphabeticalAppsList<T> appsList) {
        return new AllAppsGridAdapter<>(mActivityContext, getLayoutInflater(), appsList,
                mMainAdapterProvider, mPrivateSpaceHeaderViewController);
                mMainAdapterProvider);
    }

    // TODO(b/216683257): Remove when Taskbar All Apps supports search.
+2 −3
Original line number Diff line number Diff line
@@ -73,9 +73,8 @@ public class AllAppsGridAdapter<T extends Context & ActivityContext> extends


    public AllAppsGridAdapter(T activityContext, LayoutInflater inflater,
            AlphabeticalAppsList apps, SearchAdapterProvider<?> adapterProvider,
            PrivateSpaceHeaderViewController privateSpaceHeaderViewController) {
        super(activityContext, inflater, apps, adapterProvider, privateSpaceHeaderViewController);
            AlphabeticalAppsList apps, SearchAdapterProvider<?> adapterProvider) {
        super(activityContext, inflater, apps, adapterProvider);
        mGridLayoutMgr = new AppsGridLayoutManager(mActivityContext);
        mGridLayoutMgr.setSpanSizeLookup(new GridSpanSizer());
        setAppsPerRow(activityContext.getDeviceProfile().numShownAllAppsColumns);
+8 −1
Original line number Diff line number Diff line
@@ -206,7 +206,10 @@ public class AlphabeticalAppsList<T extends Context & ActivityContext> implement
     */
    @Override
    public void onAppsUpdated() {
        if (mAllAppsStore == null) {
        // Don't update apps when the private profile animations are running, otherwise the motion
        // is canceled.
        if (mAllAppsStore == null || (mPrivateProviderManager != null &&
                mPrivateProviderManager.getAnimationRunning())) {
            return;
        }
        // Sort the list of apps
@@ -444,6 +447,10 @@ public class AlphabeticalAppsList<T extends Context & ActivityContext> implement
        return roundRegion;
    }

    public PrivateProfileManager getPrivateProfileManager() {
        return mPrivateProviderManager;
    }

    private static class MyDiffCallback extends DiffUtil.Callback {

        private final List<AdapterItem> mOldList;
+2 −13
Original line number Diff line number Diff line
@@ -169,16 +169,9 @@ public abstract class BaseAllAppsAdapter<T extends Context & ActivityContext> ex
    protected final OnClickListener mOnIconClickListener;
    protected final OnLongClickListener mOnIconLongClickListener;
    protected OnFocusChangeListener mIconFocusListener;
    private final PrivateSpaceHeaderViewController mPrivateSpaceHeaderViewController;

    public BaseAllAppsAdapter(T activityContext, LayoutInflater inflater,
            AlphabeticalAppsList<T> apps, SearchAdapterProvider<?> adapterProvider) {
        this(activityContext, inflater, apps, adapterProvider, null);
    }

    public BaseAllAppsAdapter(T activityContext, LayoutInflater inflater,
            AlphabeticalAppsList<T> apps, SearchAdapterProvider<?> adapterProvider,
            PrivateSpaceHeaderViewController privateSpaceHeaderViewController) {
        mActivityContext = activityContext;
        mApps = apps;
        mLayoutInflater = inflater;
@@ -187,7 +180,6 @@ public abstract class BaseAllAppsAdapter<T extends Context & ActivityContext> ex
        mOnIconLongClickListener = mActivityContext.getAllAppsItemLongClickListener();

        mAdapterProvider = adapterProvider;
        mPrivateSpaceHeaderViewController = privateSpaceHeaderViewController;
    }

    /** Checks if the passed viewType represents all apps divider. */
@@ -283,13 +275,10 @@ public abstract class BaseAllAppsAdapter<T extends Context & ActivityContext> ex
            case VIEW_TYPE_PRIVATE_SPACE_HEADER:
                RelativeLayout psHeaderLayout = holder.itemView.findViewById(
                        R.id.ps_header_layout);
                assert mPrivateSpaceHeaderViewController != null;
                assert psHeaderLayout != null;
                mPrivateSpaceHeaderViewController.addPrivateSpaceHeaderViewElements(psHeaderLayout);
                mApps.getPrivateProfileManager().addPrivateSpaceHeaderViewElements(psHeaderLayout);
                AdapterItem adapterItem = mApps.getAdapterItems().get(position);
                int roundRegions = ROUND_TOP_LEFT | ROUND_TOP_RIGHT;
                if (mPrivateSpaceHeaderViewController.getPrivateProfileManager().getCurrentState()
                        == STATE_DISABLED) {
                if (mApps.getPrivateProfileManager().getCurrentState() == STATE_DISABLED) {
                    roundRegions |= (ROUND_BOTTOM_LEFT | ROUND_BOTTOM_RIGHT);
                }
                adapterItem.decorationInfo =
Loading