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

Commit 31e713ee authored by Brandon Dayauon's avatar Brandon Dayauon Committed by Android (Google) Code Review
Browse files

Merge changes If93e3975,Ifed45f06 into main

* changes:
  Fix views being visible after closing private space.
  Set attach consumer after animation finished
parents 347cc489 14ec2174
Loading
Loading
Loading
Loading
+24 −10
Original line number Diff line number Diff line
@@ -15,6 +15,8 @@
 */
package com.android.launcher3.allapps;

import static android.view.View.GONE;

import static com.android.launcher3.allapps.SectionDecorationInfo.ROUND_BOTTOM_LEFT;
import static com.android.launcher3.allapps.SectionDecorationInfo.ROUND_BOTTOM_RIGHT;
import static com.android.launcher3.allapps.SectionDecorationInfo.ROUND_NOTHING;
@@ -42,6 +44,7 @@ import com.android.launcher3.LauncherPrefs;
import com.android.launcher3.R;
import com.android.launcher3.allapps.search.SearchAdapterProvider;
import com.android.launcher3.model.data.AppInfo;
import com.android.launcher3.model.data.ItemInfo;
import com.android.launcher3.views.ActivityContext;

/**
@@ -263,16 +266,26 @@ public abstract class BaseAllAppsAdapter<T extends Context & ActivityContext> ex
                icon.applyFromApplicationInfo(adapterItem.itemInfo);
                icon.setOnFocusChangeListener(mIconFocusListener);
                PrivateProfileManager privateProfileManager = mApps.getPrivateProfileManager();
                if (privateProfileManager != null) {
                    // Set the alpha of the private space icon to 0 upon expanding the header so the
                    // alpha can animate -> 1.
                    boolean isPrivateSpaceItem =
                            privateProfileManager.isPrivateSpaceItem(adapterItem);
                    if (icon.getAlpha() == 0 || icon.getAlpha() == 1) {
                    icon.setAlpha(privateProfileManager != null
                            && privateProfileManager.isPrivateSpaceItem(adapterItem)
                        icon.setAlpha(isPrivateSpaceItem
                                && privateProfileManager.getAnimationScrolling()
                                && privateProfileManager.getAnimate()
                                && privateProfileManager.getCurrentState() == STATE_ENABLED
                                ? 0 : 1);
                    }
                    // Views can still be bounded before the app list is updated hence showing icons
                    // after collapsing.
                    if (privateProfileManager.getCurrentState() == STATE_DISABLED
                            && isPrivateSpaceItem) {
                        adapterItem.decorationInfo = null;
                        icon.setVisibility(GONE);
                    }
                }
                break;
            }
            case VIEW_TYPE_EMPTY_SEARCH: {
@@ -298,7 +311,8 @@ public abstract class BaseAllAppsAdapter<T extends Context & ActivityContext> ex
                break;
            case VIEW_TYPE_PRIVATE_SPACE_SYS_APPS_DIVIDER:
                adapterItem = mApps.getAdapterItems().get(position);
                adapterItem.decorationInfo = new SectionDecorationInfo(mActivityContext,
                adapterItem.decorationInfo = mApps.getPrivateProfileManager().getCurrentState()
                        == STATE_DISABLED ? null : new SectionDecorationInfo(mActivityContext,
                        ROUND_NOTHING, true /* decorateTogether */);
                break;
            case VIEW_TYPE_ALL_APPS_DIVIDER:
+3 −0
Original line number Diff line number Diff line
@@ -43,6 +43,9 @@ public class PrivateAppsSectionDecorator extends RecyclerView.ItemDecoration {
        for (int i = 0; i < parent.getChildCount(); i++) {
            View view = parent.getChildAt(i);
            int position = parent.getChildAdapterPosition(view);
            if (position < 0 || position >= mAppsList.getAdapterItems().size()) {
                continue;
            }
            BaseAllAppsAdapter.AdapterItem adapterItem = mAppsList.getAdapterItems().get(position);
            SectionDecorationInfo info = adapterItem.decorationInfo;
            if (info == null) {
+12 −2
Original line number Diff line number Diff line
@@ -159,6 +159,7 @@ public class PrivateProfileManager extends UserProfileManager {
        itemInfo.contentDescription = context.getResources().getString(
                com.android.launcher3.R.string.ps_add_button_content_description);
        itemInfo.runtimeStatusFlags |= FLAG_NOT_PINNABLE;
        itemInfo.user = getProfileUser();

        BaseAllAppsAdapter.AdapterItem item = new BaseAllAppsAdapter.AdapterItem(VIEW_TYPE_ICON);
        item.itemInfo = itemInfo;
@@ -198,6 +199,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 +591,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 +620,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 +730,10 @@ public class PrivateProfileManager extends UserProfileManager {
        allAppsRecyclerView.addOnScrollListener(mOnIdleScrollListener);
    }

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

    boolean getAnimate() {
        return mAnimate;
    }
@@ -737,6 +747,6 @@ public class PrivateProfileManager extends UserProfileManager {
    }

    boolean isPrivateSpaceItem(BaseAllAppsAdapter.AdapterItem item) {
        return item.decorationInfo != null;
        return getItemInfoMatcher().test(item.itemInfo) || item.decorationInfo != null;
    }
}
+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();