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

Commit a2715112 authored by Brandon Dayauon's avatar Brandon Dayauon
Browse files

Set attach consumer after animation finished

Its possible after the animation that attached view's alpha can still be stuck at 0 and never change.
This only happens when the view isn't in range to animate and after onBind() is already called.

Also added flag guarding to the animation as it seems to be forgotten since the big CL change moving
everything to privateProfileManager.

bug: 333506236
Test locally: https://screenshot.googleplex.com/8Kk6rLaczMPwr49 and https://screenshot.googleplex.com/9wXHeNuiCVFEMp6
manually: before https://drive.google.com/file/d/15hSqaUVjwE-lLp6IIv_mqwYbn_ITzR7s/view?usp=sharing
after: https://drive.google.com/file/d/15m7Al5H3vldFgIaQfFyulm1h92_Mgd0H/view?usp=sharing
Flag: ACONFIG com.android.launcher3.Flags.private_space_animation trunkfood

Change-Id: Ifed45f065b536bca5e8878b1bb95d16caf136ed6
parent a9721fd3
Loading
Loading
Loading
Loading
+10 −1
Original line number Diff line number Diff line
@@ -198,6 +198,7 @@ public class PrivateProfileManager extends UserProfileManager {
     * when animation is not running.
     */
    public void reset() {
        getMainRecyclerView().setChildAttachedConsumer(null);
        int previousState = getCurrentState();
        boolean isEnabled = !mAllApps.getAppsStore()
                .hasModelFlag(FLAG_PRIVATE_PROFILE_QUIET_MODE_ENABLED);
@@ -589,6 +590,9 @@ public class PrivateProfileManager extends UserProfileManager {
     * here.
     */
    private void updatePrivateStateAnimator(boolean expand) {
        if (!Flags.enablePrivateSpace() || !Flags.privateSpaceAnimation()) {
            return;
        }
        if (mPSHeader == null) {
            mOnPSHeaderAdded = () -> updatePrivateStateAnimator(expand);
            setAnimationRunning(false);
@@ -615,12 +619,13 @@ public class PrivateProfileManager extends UserProfileManager {
        });
        animatorSet.addListener(forEndCallback(() -> {
            setAnimationRunning(false);
            getMainRecyclerView().setChildAttachedConsumer(child -> child.setAlpha(1));
            if (!expand) {
                // Call onAppsUpdated() because it may be canceled when this animation occurs.
                mAllApps.getPersonalAppList().onAppsUpdated();
                if (isPrivateSpaceHidden()) {
                    // TODO (b/325455879): Figure out if we can avoid this.
                    mAllApps.getActiveRecyclerView().getAdapter().notifyDataSetChanged();
                    getMainRecyclerView().getAdapter().notifyDataSetChanged();
                }
            }
        }));
@@ -724,6 +729,10 @@ public class PrivateProfileManager extends UserProfileManager {
        allAppsRecyclerView.addOnScrollListener(mOnIdleScrollListener);
    }

    AllAppsRecyclerView getMainRecyclerView() {
        return mAllApps.mAH.get(ActivityAllAppsContainerView.AdapterHolder.MAIN).mRecyclerView;
    }

    boolean getAnimate() {
        return mAnimate;
    }
+4 −0
Original line number Diff line number Diff line
@@ -29,6 +29,7 @@ import static org.junit.Assert.assertEquals;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.anyInt;
import static org.mockito.Mockito.doNothing;
import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.spy;
import static org.mockito.Mockito.when;

@@ -150,6 +151,7 @@ public class PrivateProfileManagerTest {
        PrivateProfileManager privateProfileManager = spy(mPrivateProfileManager);
        doNothing().when(privateProfileManager).resetPrivateSpaceDecorator(anyInt());
        doNothing().when(privateProfileManager).executeLock();
        doReturn(mAllAppsRecyclerView).when(privateProfileManager).getMainRecyclerView();
        when(mAllAppsStore.hasModelFlag(FLAG_PRIVATE_PROFILE_QUIET_MODE_ENABLED))
                .thenReturn(false, true);

@@ -169,6 +171,7 @@ public class PrivateProfileManagerTest {
    public void transitioningToUnlocked_resetCallsPostUnlock() throws Exception {
        PrivateProfileManager privateProfileManager = spy(mPrivateProfileManager);
        doNothing().when(privateProfileManager).resetPrivateSpaceDecorator(anyInt());
        doReturn(mAllAppsRecyclerView).when(privateProfileManager).getMainRecyclerView();
        when(mAllAppsStore.hasModelFlag(FLAG_PRIVATE_PROFILE_QUIET_MODE_ENABLED))
                .thenReturn(false);
        doNothing().when(privateProfileManager).expandPrivateSpace();
@@ -187,6 +190,7 @@ public class PrivateProfileManagerTest {
        PrivateProfileManager privateProfileManager = spy(mPrivateProfileManager);
        doNothing().when(privateProfileManager).resetPrivateSpaceDecorator(anyInt());
        doNothing().when(privateProfileManager).executeLock();
        doReturn(mAllAppsRecyclerView).when(privateProfileManager).getMainRecyclerView();
        when(mAllAppsStore.hasModelFlag(FLAG_PRIVATE_PROFILE_QUIET_MODE_ENABLED))
                .thenReturn(true);
        doNothing().when(privateProfileManager).expandPrivateSpace();