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

Commit 7b1858cb authored by Himanshu Gupta's avatar Himanshu Gupta Committed by Android (Google) Code Review
Browse files

Merge "Adding suport for Private Space QsTile fulfillment." into main

parents d0791af2 ce495f13
Loading
Loading
Loading
Loading
+6 −1
Original line number Diff line number Diff line
@@ -260,7 +260,7 @@ public class ActivityAllAppsContainerView<T extends Context & ActivityContext>
        mMainAdapterProvider = mSearchUiDelegate.createMainAdapterProvider();
        if (Flags.enablePrivateSpace()) {
            mPrivateSpaceHeaderViewController =
                    new PrivateSpaceHeaderViewController(mPrivateProfileManager);
                    new PrivateSpaceHeaderViewController(this, mPrivateProfileManager);
        }

        mAH.set(AdapterHolder.MAIN, new AdapterHolder(AdapterHolder.MAIN,
@@ -980,6 +980,11 @@ public class ActivityAllAppsContainerView<T extends Context & ActivityContext>
        return mWorkManager;
    }

    /** Returns whether Private Profile has been setup. */
    public boolean hasPrivateProfile() {
        return mHasPrivateApps;
    }

    @Override
    public void onDeviceProfileChanged(DeviceProfile dp) {
        for (AdapterHolder holder : mAH) {
+0 −4
Original line number Diff line number Diff line
@@ -325,10 +325,6 @@ public class AlphabeticalAppsList<T extends Context & ActivityContext> implement
                    mPrivateProviderManager.addPrivateSpaceInstallAppButton(mAdapterItems);
                    position++;
                    addAppsWithSections(mPrivateApps, position);
                    if (mActivityContext.getAppsView() != null) {
                        mActivityContext.getAppsView().getActiveRecyclerView()
                                .scrollToBottomWithMotion();
                    }
                    break;
            }
        }
+28 −11
Original line number Diff line number Diff line
@@ -21,6 +21,7 @@ import static com.android.launcher3.allapps.BaseAllAppsAdapter.VIEW_TYPE_ICON;
import static com.android.launcher3.allapps.BaseAllAppsAdapter.VIEW_TYPE_PRIVATE_SPACE_HEADER;
import static com.android.launcher3.allapps.SectionDecorationInfo.ROUND_NOTHING;
import static com.android.launcher3.model.BgDataModel.Callbacks.FLAG_PRIVATE_PROFILE_QUIET_MODE_ENABLED;
import static com.android.launcher3.util.Executors.MAIN_EXECUTOR;
import static com.android.launcher3.util.Executors.UI_HELPER_EXECUTOR;
import static com.android.launcher3.util.SettingsCache.PRIVATE_SPACE_HIDE_WHEN_LOCKED_URI;

@@ -34,7 +35,6 @@ import android.os.UserManager;
import androidx.annotation.VisibleForTesting;

import com.android.launcher3.BuildConfig;
import com.android.launcher3.Flags;
import com.android.launcher3.R;
import com.android.launcher3.icons.BitmapInfo;
import com.android.launcher3.icons.LauncherIcons;
@@ -59,11 +59,11 @@ public class PrivateProfileManager extends UserProfileManager {
    private static final String SAFETY_CENTER_INTENT = Intent.ACTION_SAFETY_CENTER;
    private static final String PS_SETTINGS_FRAGMENT_KEY = ":settings:fragment_args_key";
    private static final String PS_SETTINGS_FRAGMENT_VALUE = "AndroidPrivateSpace_personal";
    private static final int ANIMATION_DURATION = 2000;
    private final ActivityAllAppsContainerView<?> mAllApps;
    private final Predicate<UserHandle> mPrivateProfileMatcher;
    private PrivateAppsSectionDecorator mPrivateAppsSectionDecorator;
    private boolean mPrivateSpaceSettingsAvailable;
    private Runnable mUnlockRunnable;

    public PrivateProfileManager(UserManager userManager,
            ActivityAllAppsContainerView<?> allApps,
@@ -115,9 +115,17 @@ public class PrivateProfileManager extends UserProfileManager {
        mAllApps.mAH.get(MAIN).mAdapter.notifyItemInserted(adapterItems.size() - 1);
    }

    /** Disables quiet mode for Private Space User Profile. */
    public void unlockPrivateProfile() {
    /**
     * Disables quiet mode for Private Space User Profile.
     * The runnable passed will be executed in the {@link #reset()} method,
     * when Launcher receives update about profile availability.
     * The runnable passed is only executed once, and reset after execution.
     * In case the method is called again, before the previously set runnable was executed,
     * the runnable will be updated.
     */
    public void unlockPrivateProfile(Runnable runnable) {
        enableQuietMode(false);
        mUnlockRunnable = runnable;
    }

    /** Enables quiet mode for Private Space User Profile. */
@@ -133,11 +141,15 @@ public class PrivateProfileManager extends UserProfileManager {

    /** Resets the current state of Private Profile, w.r.t. to Launcher. */
    public void reset() {
        int previousState = getCurrentState();
        boolean isEnabled = !mAllApps.getAppsStore()
                .hasModelFlag(FLAG_PRIVATE_PROFILE_QUIET_MODE_ENABLED);
        int updatedState = isEnabled ? STATE_ENABLED : STATE_DISABLED;
        setCurrentState(updatedState);
        resetPrivateSpaceDecorator(updatedState);
        if (transitioningFromLockedToUnlocked(previousState, updatedState)) {
            applyUnlockRunnable();
        }
    }

    /** Opens the Private Space Settings Entry Point. */
@@ -182,13 +194,6 @@ public class PrivateProfileManager extends UserProfileManager {
            }
            // Add Private Space Decorator to the Recycler view.
            mainAdapterHolder.mRecyclerView.addItemDecoration(mPrivateAppsSectionDecorator);
            if (Flags.privateSpaceAnimation() && mAllApps.getActiveRecyclerView()
                    == mainAdapterHolder.mRecyclerView) {
                RecyclerViewAnimationController recyclerViewAnimationController =
                        new RecyclerViewAnimationController(mAllApps);
                recyclerViewAnimationController.animateToState(true /* expand */,
                        ANIMATION_DURATION, () -> {});
            }
        } else {
            // Remove Private Space Decorator from the Recycler view.
            if (mPrivateAppsSectionDecorator != null) {
@@ -202,6 +207,18 @@ public class PrivateProfileManager extends UserProfileManager {
        setQuietMode(enable);
    }

    void applyUnlockRunnable() {
        if (mUnlockRunnable != null) {
            // reset the runnable to prevent re-execution.
            MAIN_EXECUTOR.post(mUnlockRunnable);
            mUnlockRunnable = null;
        }
    }

    private boolean transitioningFromLockedToUnlocked(int previousState, int updatedState) {
        return previousState == STATE_DISABLED && updatedState == STATE_ENABLED;
    }

    @Override
    public Predicate<UserHandle> getUserMatcher() {
        return mPrivateProfileMatcher;
+24 −2
Original line number Diff line number Diff line
@@ -16,6 +16,7 @@

package com.android.launcher3.allapps;

import static com.android.launcher3.allapps.ActivityAllAppsContainerView.AdapterHolder.MAIN;
import static com.android.launcher3.allapps.PrivateProfileManager.STATE_DISABLED;
import static com.android.launcher3.allapps.PrivateProfileManager.STATE_ENABLED;
import static com.android.launcher3.allapps.PrivateProfileManager.STATE_TRANSITION;
@@ -28,6 +29,7 @@ import android.widget.ImageButton;
import android.widget.ImageView;
import android.widget.RelativeLayout;

import com.android.launcher3.Flags;
import com.android.launcher3.R;
import com.android.launcher3.allapps.UserProfileManager.UserProfileState;

@@ -36,9 +38,13 @@ import com.android.launcher3.allapps.UserProfileManager.UserProfileState;
 * {@link UserProfileState}
 */
public class PrivateSpaceHeaderViewController {
    private static final int ANIMATION_DURATION = 2000;
    private final ActivityAllAppsContainerView mAllApps;
    private final PrivateProfileManager mPrivateProfileManager;

    public PrivateSpaceHeaderViewController(PrivateProfileManager privateProfileManager) {
    public PrivateSpaceHeaderViewController(ActivityAllAppsContainerView allApps,
            PrivateProfileManager privateProfileManager) {
        this.mAllApps = allApps;
        this.mPrivateProfileManager = privateProfileManager;
    }

@@ -77,7 +83,8 @@ public class PrivateSpaceHeaderViewController {
                quietModeButton.setOnClickListener(
                        view -> {
                            mPrivateProfileManager.logEvents(LAUNCHER_PRIVATE_SPACE_UNLOCK_TAP);
                            mPrivateProfileManager.unlockPrivateProfile();
                            mPrivateProfileManager.unlockPrivateProfile((this::
                                    onPrivateProfileUnlocked));
                        });
            }
            default -> quietModeButton.setVisibility(View.GONE);
@@ -106,6 +113,21 @@ public class PrivateSpaceHeaderViewController {
        }
    }

    private void onPrivateProfileUnlocked() {
        // If we are on main adapter view, we apply the PS Container expansion animation and
        // then scroll down to load the entire container, making animation visible.
        ActivityAllAppsContainerView<?>.AdapterHolder mainAdapterHolder =
                (ActivityAllAppsContainerView<?>.AdapterHolder) mAllApps.mAH.get(MAIN);
        if (Flags.enablePrivateSpace() && Flags.privateSpaceAnimation()
                && mAllApps.getActiveRecyclerView() == mainAdapterHolder.mRecyclerView) {
            RecyclerViewAnimationController recyclerViewAnimationController =
                    new RecyclerViewAnimationController(mAllApps);
            recyclerViewAnimationController.animateToState(true /* expand */,
                    ANIMATION_DURATION, () -> {});
            mAllApps.getActiveRecyclerView().scrollToBottomWithMotion();
        }
    }

    PrivateProfileManager getPrivateProfileManager() {
        return mPrivateProfileManager;
    }
+0 −2
Original line number Diff line number Diff line
@@ -22,7 +22,6 @@ import android.os.UserHandle;
import android.os.UserManager;

import androidx.annotation.IntDef;
import androidx.annotation.VisibleForTesting;

import com.android.launcher3.Utilities;
import com.android.launcher3.logging.StatsLogManager;
@@ -89,7 +88,6 @@ public abstract class UserProfileManager {
    }

    /** Returns current state for the profile type. */
    @VisibleForTesting(otherwise = VisibleForTesting.PROTECTED)
    public int getCurrentState() {
        return mCurrentState;
    }
Loading