Move adding views logic to privateProfileManager

- Have the animation happen according to the state of private space.
- Have the transition happen only once by setting the current transition to null at the end of transition and by ensuring
where the transitions are allowed.
- Removing controller class.

- The onClick controls the enablement of the profile. On reset (when getting the transition) is what controls the animation
during expand.

tldr- In the collapse case:  execute() is called -> animation happens  -> addPsHeader
tldr- Expand case: post() is called -> addPsHeader -> animation happens.

Collapse:
onClick() -> AACV.onAppsUpdated() that resets & apply/RUNS runnable because EXECUTE
-> AAList.onAppsUpdated() (which is called at the same time animating happens which we should cancel and do at end callback)
-> AAList.onAppsUpdated() gets called again

Expand:
onCLick() -> AACV.onAppsUpdated() that resets & apply runnable
-> AAList.onAppsUpdated() (no animation running)
-> AAList.onAppsUpdated() (no animation running)
-> addPrivateSpaceHeader
-> then unlockAction() runnable because its posted at this point

bug: 326206132
bug: 330444548
bug: 299294792
Test: manually locally and presubmit: https://screenshot.googleplex.com/9wavvwKQ8hY6oUw & https://screenshot.googleplex.com/BiqmidLFjPwS28j
video: https://drive.google.com/file/d/1XGhmTncdUFtJj188_l7alGyyNz_fhXNw/view?usp=sharing

Scrolling fix before: https://drive.google.com/file/d/1XykDm4UELoCvcwZdj8ZlJ6TszptB8W0W/view?usp=sharing
scrolling fix after when not a lot of apps: https://drive.google.com/file/d/1Y4VY1eX7WE8ShSLXRrT56ieBdAuJo_zn/view?usp=sharing
scrolling fix after with a lot of apps: https://drive.google.com/file/d/1Y58c-Z9xnU1GILp0Ih-oLORXYkMB-jWn/view?usp=sharing
Flag: ACONFIG com.android.launcher3.Flags.private_space_animation

Change-Id: I8d03ae60e2c9fe0ec145c4b0a2e9604b9e6e9017
This commit is contained in:
Brandon Dayauon
2024-03-06 15:29:31 -08:00
parent 75216f9108
commit 136f9d6f8a
9 changed files with 567 additions and 463 deletions

View File

@@ -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.