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

Commit 14ec2174 authored by Brandon Dayauon's avatar Brandon Dayauon
Browse files

Fix views being visible after closing private space.

Its possible views are still being binded before the app list is refreshed.
So instead make the views gone in that case (by making sure private profile is disabled).

Fixes:
- install app icon still showing because it is not identified as a private space item
- Divider still containing a decorator when collapsing before app list is refreshed.

bug: 334868779
Test video manualy:
before:https://drive.google.com/file/d/1IWdGsTSq7-xRZKOJso-5p9g-j7RTEkas/view?usp=sharing
after:https://drive.google.com/file/d/1IVNTksryFi5o4uHzZtzNC0Yz7-rxrje3/view?usp=sharing
Flag: ACONFIG com.android.launcher3.Flags.private_space_animation trunkfood

Change-Id: If93e39753352741fb6f0728f717a67b7f9315d0b
parent a2715112
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) {
+2 −1
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;
@@ -746,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;
    }
}