mirror of
https://github.com/LawnchairLauncher/lawnchair.git
synced 2026-03-01 08:16:49 +00:00
Enabling Private Space Container in Launcher.
This CL adds the following: 1. Adds filtering and addition of Private Profile apps in main user all apps recycler view 2. Enables decoration of Private Profile apps 3. Enables hiding Private Space container based upon a settings entry. Flag: ACONFIG com.android.launcher3.Flags.enable_private_space DEVELOPMENT Bug: 289223923 Test: Ran Launcher3 tests Change-Id: I33dc55a3a39e75d3fc336ca6a488b282e2dd322c
This commit is contained in:
@@ -16,6 +16,7 @@
|
||||
package com.android.launcher3.allapps;
|
||||
|
||||
import static com.android.launcher3.Flags.enableExpandingPauseWorkButton;
|
||||
import static com.android.launcher3.allapps.ActivityAllAppsContainerView.AdapterHolder.MAIN;
|
||||
import static com.android.launcher3.allapps.ActivityAllAppsContainerView.AdapterHolder.SEARCH;
|
||||
import static com.android.launcher3.allapps.BaseAllAppsAdapter.VIEW_TYPE_WORK_DISABLED_CARD;
|
||||
import static com.android.launcher3.allapps.BaseAllAppsAdapter.VIEW_TYPE_WORK_EDU_CARD;
|
||||
@@ -69,6 +70,7 @@ 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;
|
||||
@@ -95,6 +97,7 @@ import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.function.Predicate;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
/**
|
||||
* All apps container view with search support for use in a dragging activity.
|
||||
@@ -133,6 +136,7 @@ public class ActivityAllAppsContainerView<T extends Context & ActivityContext>
|
||||
protected final Predicate<ItemInfo> mPersonalMatcher = ItemInfoMatcher.ofUser(
|
||||
Process.myUserHandle());
|
||||
protected WorkProfileManager mWorkManager;
|
||||
protected final PrivateProfileManager mPrivateProfileManager;
|
||||
protected final Point mFastScrollerOffset = new Point();
|
||||
protected final int mScrimColor;
|
||||
protected final float mHeaderThreshold;
|
||||
@@ -175,6 +179,7 @@ public class ActivityAllAppsContainerView<T extends Context & ActivityContext>
|
||||
protected SearchAdapterProvider<?> mMainAdapterProvider;
|
||||
private View mBottomSheetHandleArea;
|
||||
private boolean mHasWorkApps;
|
||||
private boolean mHasPrivateApps;
|
||||
private float[] mBottomSheetCornerRadii;
|
||||
private ScrimView mScrimView;
|
||||
private int mHeaderColor;
|
||||
@@ -184,6 +189,8 @@ public class ActivityAllAppsContainerView<T extends Context & ActivityContext>
|
||||
private int mTabsProtectionAlpha;
|
||||
@Nullable private AllAppsTransitionController mAllAppsTransitionController;
|
||||
|
||||
private PrivateSpaceHeaderViewController mPrivateSpaceHeaderViewController;
|
||||
|
||||
public ActivityAllAppsContainerView(Context context) {
|
||||
this(context, null);
|
||||
}
|
||||
@@ -207,6 +214,11 @@ public class ActivityAllAppsContainerView<T extends Context & ActivityContext>
|
||||
this,
|
||||
mActivityContext.getStatsLogManager(),
|
||||
UserCache.INSTANCE.get(mActivityContext));
|
||||
mPrivateProfileManager = new PrivateProfileManager(
|
||||
mActivityContext.getSystemService(UserManager.class),
|
||||
this,
|
||||
mActivityContext.getStatsLogManager(),
|
||||
UserCache.INSTANCE.get(mActivityContext));
|
||||
mAH = Arrays.asList(null, null, null);
|
||||
mNavBarScrimPaint = new Paint();
|
||||
mNavBarScrimPaint.setColor(Themes.getNavBarScrimColor(mActivityContext));
|
||||
@@ -246,13 +258,20 @@ public class ActivityAllAppsContainerView<T extends Context & ActivityContext>
|
||||
*/
|
||||
protected void initContent() {
|
||||
mMainAdapterProvider = mSearchUiDelegate.createMainAdapterProvider();
|
||||
if (Flags.enablePrivateSpace()) {
|
||||
mPrivateSpaceHeaderViewController =
|
||||
new PrivateSpaceHeaderViewController(mPrivateProfileManager);
|
||||
}
|
||||
|
||||
mAH.set(AdapterHolder.MAIN, new AdapterHolder(AdapterHolder.MAIN,
|
||||
new AlphabeticalAppsList<>(mActivityContext, mAllAppsStore, null)));
|
||||
new AlphabeticalAppsList<>(mActivityContext,
|
||||
mAllAppsStore,
|
||||
null,
|
||||
mPrivateProfileManager)));
|
||||
mAH.set(AdapterHolder.WORK, new AdapterHolder(AdapterHolder.WORK,
|
||||
new AlphabeticalAppsList<>(mActivityContext, mAllAppsStore, mWorkManager)));
|
||||
new AlphabeticalAppsList<>(mActivityContext, mAllAppsStore, mWorkManager, null)));
|
||||
mAH.set(SEARCH, new AdapterHolder(SEARCH,
|
||||
new AlphabeticalAppsList<>(mActivityContext, null, null)));
|
||||
new AlphabeticalAppsList<>(mActivityContext, null, null, null)));
|
||||
|
||||
getLayoutInflater().inflate(R.layout.all_apps_content, this);
|
||||
mHeader = findViewById(R.id.all_apps_header);
|
||||
@@ -592,7 +611,7 @@ public class ActivityAllAppsContainerView<T extends Context & ActivityContext>
|
||||
} else {
|
||||
mainRecyclerView = findViewById(R.id.apps_list_view);
|
||||
workRecyclerView = null;
|
||||
mAH.get(AdapterHolder.MAIN).setup(mainRecyclerView, null);
|
||||
mAH.get(AdapterHolder.MAIN).setup(mainRecyclerView, mPersonalMatcher);
|
||||
mAH.get(AdapterHolder.WORK).mRecyclerView = null;
|
||||
}
|
||||
setUpCustomRecyclerViewPool(
|
||||
@@ -860,7 +879,7 @@ public class ActivityAllAppsContainerView<T extends Context & ActivityContext>
|
||||
|
||||
protected BaseAllAppsAdapter<T> createAdapter(AlphabeticalAppsList<T> appsList) {
|
||||
return new AllAppsGridAdapter<>(mActivityContext, getLayoutInflater(), appsList,
|
||||
mMainAdapterProvider);
|
||||
mMainAdapterProvider, mPrivateSpaceHeaderViewController);
|
||||
}
|
||||
|
||||
// TODO(b/216683257): Remove when Taskbar All Apps supports search.
|
||||
@@ -973,13 +992,19 @@ public class ActivityAllAppsContainerView<T extends Context & ActivityContext>
|
||||
|
||||
@VisibleForTesting
|
||||
public void onAppsUpdated() {
|
||||
mHasWorkApps = mWorkManager.hasWorkApps();
|
||||
mHasWorkApps = Stream.of(mAllAppsStore.getApps())
|
||||
.anyMatch(mWorkManager.getItemInfoMatcher());
|
||||
mHasPrivateApps = Stream.of(mAllAppsStore.getApps())
|
||||
.anyMatch(mPrivateProfileManager.getItemInfoMatcher());
|
||||
if (!isSearching()) {
|
||||
rebindAdapters();
|
||||
}
|
||||
if (mHasWorkApps) {
|
||||
mWorkManager.reset();
|
||||
}
|
||||
if (mHasPrivateApps) {
|
||||
mPrivateProfileManager.reset();
|
||||
}
|
||||
|
||||
mActivityContext.getStatsLogManager().logger()
|
||||
.withCardinality(mAllAppsStore.getApps().length)
|
||||
@@ -1245,6 +1270,10 @@ public class ActivityAllAppsContainerView<T extends Context & ActivityContext>
|
||||
return mAH.get(SEARCH).mAppsList;
|
||||
}
|
||||
|
||||
public AlphabeticalAppsList<T> getPersonalAppList() {
|
||||
return mAH.get(MAIN).mAppsList;
|
||||
}
|
||||
|
||||
public FloatingHeaderView getFloatingHeaderView() {
|
||||
return mHeader;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user