diff --git a/src/com/android/launcher3/allapps/BaseAllAppsAdapter.java b/src/com/android/launcher3/allapps/BaseAllAppsAdapter.java index 3ba1eedc5c..a21d7be587 100644 --- a/src/com/android/launcher3/allapps/BaseAllAppsAdapter.java +++ b/src/com/android/launcher3/allapps/BaseAllAppsAdapter.java @@ -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,15 +266,25 @@ public abstract class BaseAllAppsAdapter ex icon.applyFromApplicationInfo(adapterItem.itemInfo); icon.setOnFocusChangeListener(mIconFocusListener); PrivateProfileManager privateProfileManager = mApps.getPrivateProfileManager(); - // Set the alpha of the private space icon to 0 upon expanding the header so the - // alpha can animate -> 1. - if (icon.getAlpha() == 0 || icon.getAlpha() == 1) { - icon.setAlpha(privateProfileManager != null - && privateProfileManager.isPrivateSpaceItem(adapterItem) - && privateProfileManager.getAnimationScrolling() - && privateProfileManager.getAnimate() - && privateProfileManager.getCurrentState() == STATE_ENABLED - ? 0 : 1); + 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(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; } @@ -298,7 +311,8 @@ public abstract class BaseAllAppsAdapter 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: diff --git a/src/com/android/launcher3/allapps/PrivateAppsSectionDecorator.java b/src/com/android/launcher3/allapps/PrivateAppsSectionDecorator.java index 18175b6add..339e443642 100644 --- a/src/com/android/launcher3/allapps/PrivateAppsSectionDecorator.java +++ b/src/com/android/launcher3/allapps/PrivateAppsSectionDecorator.java @@ -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) { diff --git a/src/com/android/launcher3/allapps/PrivateProfileManager.java b/src/com/android/launcher3/allapps/PrivateProfileManager.java index 7b1ed6421c..90ed3eb5cc 100644 --- a/src/com/android/launcher3/allapps/PrivateProfileManager.java +++ b/src/com/android/launcher3/allapps/PrivateProfileManager.java @@ -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; } }