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

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

Merge "Move adding views logic to privateProfileManager" into main

parents 391e53d2 136f9d6f
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -33,7 +33,7 @@
        android:layout_centerVertical="true"
        android:gravity="center_vertical"
        android:layout_alignParentEnd="true"
        android:animateLayoutChanges="true">
        android:animateLayoutChanges="false">
        <ImageButton
            android:id="@+id/ps_settings_button"
            android:layout_width="@dimen/ps_header_image_height"
+11 −13
Original line number Diff line number Diff line
@@ -70,7 +70,6 @@ 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;
@@ -127,7 +126,6 @@ public class ActivityAllAppsContainerView<T extends Context & ActivityContext>
    public static final float PULL_MULTIPLIER = .02f;
    public static final float FLING_VELOCITY_MULTIPLIER = 1200f;
    protected static final String BUNDLE_KEY_CURRENT_PAGE = "launcher.allapps.current_page";
    private static final int SCROLL_TO_BOTTOM_DURATION = 500;
    private static final long DEFAULT_SEARCH_TRANSITION_DURATION_MS = 300;
    // Render the header protection at all times to debug clipping issues.
    private static final boolean DEBUG_HEADER_PROTECTION = false;
@@ -192,8 +190,6 @@ public class ActivityAllAppsContainerView<T extends Context & ActivityContext>
    private float mTotalHeaderProtectionHeight;
    @Nullable private AllAppsTransitionController mAllAppsTransitionController;

    private PrivateSpaceHeaderViewController mPrivateSpaceHeaderViewController;

    public ActivityAllAppsContainerView(Context context) {
        this(context, null);
    }
@@ -261,10 +257,6 @@ public class ActivityAllAppsContainerView<T extends Context & ActivityContext>
     */
    protected void initContent() {
        mMainAdapterProvider = mSearchUiDelegate.createMainAdapterProvider();
        if (Flags.enablePrivateSpace()) {
            mPrivateSpaceHeaderViewController =
                    new PrivateSpaceHeaderViewController(this, mPrivateProfileManager);
        }

        mAH.set(AdapterHolder.MAIN, new AdapterHolder(AdapterHolder.MAIN,
                new AlphabeticalAppsList<>(mActivityContext,
@@ -398,7 +390,7 @@ public class ActivityAllAppsContainerView<T extends Context & ActivityContext>
        mAllAppsTransitionController = allAppsTransitionController;
    }

    private void animateToSearchState(boolean goingToSearch, long durationMs) {
    void animateToSearchState(boolean goingToSearch, long durationMs) {
        if (!mSearchTransitionController.isRunning() && goingToSearch == isSearching()) {
            return;
        }
@@ -499,9 +491,9 @@ public class ActivityAllAppsContainerView<T extends Context & ActivityContext>
    }

    /**
     * Exits search and returns to A-Z apps list. Scroll to the bottom.
     * Exits search and returns to A-Z apps list. Scroll to the private space header.
     */
    public void resetAndScrollToBottom() {
    public void resetAndScrollToPrivateSpaceHeader() {
        if (mTouchHandler != null) {
            mTouchHandler.endFastScrolling();
        }
@@ -518,7 +510,13 @@ public class ActivityAllAppsContainerView<T extends Context & ActivityContext>
            // Switch to the main tab
            switchToTab(ActivityAllAppsContainerView.AdapterHolder.MAIN);
            // Scroll to bottom
            getActiveRecyclerView().scrollToBottomWithMotion(SCROLL_TO_BOTTOM_DURATION);
            if (mPrivateProfileManager != null) {
                mPrivateProfileManager.scrollForViewToBeVisibleInContainer(
                        getActiveAppsRecyclerView(),
                        getPersonalAppList().getAdapterItems(),
                        mPrivateProfileManager.getPsHeaderHeight(),
                        mActivityContext.getDeviceProfile().allAppsCellHeightPx);
            }
        });
    }

@@ -906,7 +904,7 @@ public class ActivityAllAppsContainerView<T extends Context & ActivityContext>

    protected BaseAllAppsAdapter<T> createAdapter(AlphabeticalAppsList<T> appsList) {
        return new AllAppsGridAdapter<>(mActivityContext, getLayoutInflater(), appsList,
                mMainAdapterProvider, mPrivateSpaceHeaderViewController);
                mMainAdapterProvider);
    }

    // TODO(b/216683257): Remove when Taskbar All Apps supports search.
+2 −3
Original line number Diff line number Diff line
@@ -73,9 +73,8 @@ public class AllAppsGridAdapter<T extends Context & ActivityContext> extends


    public AllAppsGridAdapter(T activityContext, LayoutInflater inflater,
            AlphabeticalAppsList apps, SearchAdapterProvider<?> adapterProvider,
            PrivateSpaceHeaderViewController privateSpaceHeaderViewController) {
        super(activityContext, inflater, apps, adapterProvider, privateSpaceHeaderViewController);
            AlphabeticalAppsList apps, SearchAdapterProvider<?> adapterProvider) {
        super(activityContext, inflater, apps, adapterProvider);
        mGridLayoutMgr = new AppsGridLayoutManager(mActivityContext);
        mGridLayoutMgr.setSpanSizeLookup(new GridSpanSizer());
        setAppsPerRow(activityContext.getDeviceProfile().numShownAllAppsColumns);
+8 −1
Original line number Diff line number Diff line
@@ -206,7 +206,10 @@ public class AlphabeticalAppsList<T extends Context & ActivityContext> implement
     */
    @Override
    public void onAppsUpdated() {
        if (mAllAppsStore == null) {
        // Don't update apps when the private profile animations are running, otherwise the motion
        // is canceled.
        if (mAllAppsStore == null || (mPrivateProviderManager != null &&
                mPrivateProviderManager.getAnimationRunning())) {
            return;
        }
        // Sort the list of apps
@@ -444,6 +447,10 @@ public class AlphabeticalAppsList<T extends Context & ActivityContext> implement
        return roundRegion;
    }

    public PrivateProfileManager getPrivateProfileManager() {
        return mPrivateProviderManager;
    }

    private static class MyDiffCallback extends DiffUtil.Callback {

        private final List<AdapterItem> mOldList;
+2 −13
Original line number Diff line number Diff line
@@ -169,16 +169,9 @@ public abstract class BaseAllAppsAdapter<T extends Context & ActivityContext> ex
    protected final OnClickListener mOnIconClickListener;
    protected final OnLongClickListener mOnIconLongClickListener;
    protected OnFocusChangeListener mIconFocusListener;
    private final PrivateSpaceHeaderViewController mPrivateSpaceHeaderViewController;

    public BaseAllAppsAdapter(T activityContext, LayoutInflater inflater,
            AlphabeticalAppsList<T> apps, SearchAdapterProvider<?> adapterProvider) {
        this(activityContext, inflater, apps, adapterProvider, null);
    }

    public BaseAllAppsAdapter(T activityContext, LayoutInflater inflater,
            AlphabeticalAppsList<T> apps, SearchAdapterProvider<?> adapterProvider,
            PrivateSpaceHeaderViewController privateSpaceHeaderViewController) {
        mActivityContext = activityContext;
        mApps = apps;
        mLayoutInflater = inflater;
@@ -187,7 +180,6 @@ public abstract class BaseAllAppsAdapter<T extends Context & ActivityContext> ex
        mOnIconLongClickListener = mActivityContext.getAllAppsItemLongClickListener();

        mAdapterProvider = adapterProvider;
        mPrivateSpaceHeaderViewController = privateSpaceHeaderViewController;
    }

    /** Checks if the passed viewType represents all apps divider. */
@@ -283,13 +275,10 @@ public abstract class BaseAllAppsAdapter<T extends Context & ActivityContext> ex
            case VIEW_TYPE_PRIVATE_SPACE_HEADER:
                RelativeLayout psHeaderLayout = holder.itemView.findViewById(
                        R.id.ps_header_layout);
                assert mPrivateSpaceHeaderViewController != null;
                assert psHeaderLayout != null;
                mPrivateSpaceHeaderViewController.addPrivateSpaceHeaderViewElements(psHeaderLayout);
                mApps.getPrivateProfileManager().addPrivateSpaceHeaderViewElements(psHeaderLayout);
                AdapterItem adapterItem = mApps.getAdapterItems().get(position);
                int roundRegions = ROUND_TOP_LEFT | ROUND_TOP_RIGHT;
                if (mPrivateSpaceHeaderViewController.getPrivateProfileManager().getCurrentState()
                        == STATE_DISABLED) {
                if (mApps.getPrivateProfileManager().getCurrentState() == STATE_DISABLED) {
                    roundRegions |= (ROUND_BOTTOM_LEFT | ROUND_BOTTOM_RIGHT);
                }
                adapterItem.decorationInfo =
Loading