Adding suport for Private Space QsTile fulfillment.

Adding logic to unlock private space and
scroll to the container after unlock event
is received by Launcher.

This change also moves pieces of Private Space
Animation to different classes, in order to make
it more robust.

Bug: 289024009
Test: atest PrivateProfileManagerTest
Flag: ACONFIG com.google.android.apps.nexuslauncher.inject_private_space_tile TEAMFOOD
Change-Id: Ica2fbc00ff3516ed5aca7fbbfc0bd2aa036a4cee
This commit is contained in:
Himanshu Gupta
2023-12-11 16:19:55 +00:00
parent c52860263a
commit ce495f13e3
7 changed files with 87 additions and 22 deletions

View File

@@ -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;
}