Update private space animation timings

The entire animation is 800ms where there are differences between lock/unlock.
Unlock 1.0:
   app Opacity: time = 400 -> 800ms Linear
   text opacity: time = 500 -> 800ms Linear
   settingsAndLockGroup "size": time = 400 -> 800ms Standard
   settingsGear: time = 400 -> 800ms Linear
Lock 2.0:
   app Opacity: time = 0 -> 400ms Linear
   text opacity: time = 0 -> 50ms Linear
   settingsAndLockGroup "size": time = 0 -> 400ms Standard
   settingsGear: time = 0 -> 400 Linear

bug:299294792
Test manually video:
after: https://drive.google.com/file/d/1_Y5I7vQhDHPX8DLM_rSM3mV9DrVN0v-q/view?usp=sharing
after 10x: https://drive.google.com/file/d/1_WLz2ijLs19qE1vYA9zdXF9YZB_CqMns/view?usp=sharing

Flag: aconfig com.android.launcher3.enable_private_space nextfood
Change-Id: I8a578e70bb834f403075824785fa9b4d8825858c
This commit is contained in:
Brandon Dayauon
2024-05-01 11:29:28 -07:00
parent 5a8e719b4c
commit ecc04b9f39
2 changed files with 31 additions and 8 deletions

View File

@@ -89,7 +89,15 @@ import java.util.function.Predicate;
*/
public class PrivateProfileManager extends UserProfileManager {
private static final int EXPAND_COLLAPSE_DURATION = 800;
private static final int SETTINGS_OPACITY_DURATION = 160;
private static final int SETTINGS_OPACITY_DURATION = 400;
private static final int TEXT_UNLOCK_OPACITY_DURATION = 300;
private static final int TEXT_LOCK_OPACITY_DURATION = 50;
private static final int APP_OPACITY_DURATION = 400;
private static final int APP_OPACITY_DELAY = 400;
private static final int SETTINGS_AND_LOCK_GROUP_TRANSITION_DELAY = 400;
private static final int SETTINGS_OPACITY_DELAY = 400;
private static final int LOCK_TEXT_OPACITY_DELAY = 500;
private static final int NO_DELAY = 0;
private final ActivityAllAppsContainerView<?> mAllApps;
private final Predicate<UserHandle> mPrivateProfileMatcher;
private final int mPsHeaderHeight;
@@ -445,7 +453,6 @@ public class PrivateProfileManager extends UserProfileManager {
if (getCurrentState() == STATE_ENABLED
&& isPrivateSpaceSettingsAvailable()) {
settingsButton.setVisibility(VISIBLE);
settingsButton.setAlpha(1f);
settingsButton.setOnClickListener(
view -> {
logEvents(LAUNCHER_PRIVATE_SPACE_SETTINGS_TAP);
@@ -590,7 +597,9 @@ public class PrivateProfileManager extends UserProfileManager {
List<BaseAllAppsAdapter.AdapterItem> allAppsAdapterItems =
mAllApps.getActiveRecyclerView().getApps().getAdapterItems();
ValueAnimator alphaAnim = ObjectAnimator.ofFloat(from, to);
alphaAnim.setDuration(EXPAND_COLLAPSE_DURATION);
alphaAnim.setDuration(APP_OPACITY_DURATION)
.setStartDelay(isExpanding ? APP_OPACITY_DELAY : NO_DELAY);
alphaAnim.setInterpolator(Interpolators.LINEAR);
alphaAnim.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
@Override
public void onAnimationUpdate(ValueAnimator valueAnimator) {
@@ -627,20 +636,25 @@ public class PrivateProfileManager extends UserProfileManager {
}
ViewGroup settingsAndLockGroup = mPSHeader.findViewById(R.id.settingsAndLockGroup);
ViewGroup lockButton = mPSHeader.findViewById(R.id.ps_lock_unlock_button);
TextView lockText = lockButton.findViewById(R.id.lock_text);
if (settingsAndLockGroup.getLayoutTransition() == null) {
// Set a new transition if the current ViewGroup does not already contain one as each
// transition should only happen once when applied.
enableLayoutTransition(settingsAndLockGroup);
}
settingsAndLockGroup.getLayoutTransition().setStartDelay(
LayoutTransition.CHANGING,
expand ? SETTINGS_AND_LOCK_GROUP_TRANSITION_DELAY : NO_DELAY);
PropertySetter headerSetter = new AnimatedPropertySetter();
ImageButton settingsButton = mPSHeader.findViewById(R.id.ps_settings_button);
updateSettingsGearAlpha(settingsButton, expand, headerSetter);
updateLockTextAlpha(lockText, expand, headerSetter);
AnimatorSet animatorSet = headerSetter.buildAnim();
animatorSet.addListener(new AnimatorListenerAdapter() {
@Override
public void onAnimationStart(Animator animation) {
// Animate the collapsing of the text at the same time while updating lock button.
lockButton.findViewById(R.id.lock_text).setVisibility(expand ? VISIBLE : GONE);
lockText.setVisibility(expand ? VISIBLE : GONE);
setAnimationRunning(true);
}
});
@@ -696,6 +710,8 @@ public class PrivateProfileManager extends UserProfileManager {
LayoutTransition settingsAndLockTransition = new LayoutTransition();
settingsAndLockTransition.enableTransitionType(LayoutTransition.CHANGING);
settingsAndLockTransition.setDuration(EXPAND_COLLAPSE_DURATION);
settingsAndLockTransition.setInterpolator(LayoutTransition.CHANGING,
Interpolators.STANDARD);
settingsAndLockTransition.addTransitionListener(new LayoutTransition.TransitionListener() {
@Override
public void startTransition(LayoutTransition transition, ViewGroup viewGroup,
@@ -716,7 +732,15 @@ public class PrivateProfileManager extends UserProfileManager {
PropertySetter setter) {
float toAlpha = expand ? 1 : 0;
setter.setFloat(settingsButton, VIEW_ALPHA, toAlpha, Interpolators.LINEAR)
.setDuration(SETTINGS_OPACITY_DURATION).setStartDelay(0);
.setDuration(SETTINGS_OPACITY_DURATION).setStartDelay(expand ?
SETTINGS_OPACITY_DELAY : NO_DELAY);
}
private void updateLockTextAlpha(TextView textView, boolean expand, PropertySetter setter) {
float toAlpha = expand ? 1 : 0;
setter.setFloat(textView, VIEW_ALPHA, toAlpha, Interpolators.LINEAR)
.setDuration(expand ? TEXT_UNLOCK_OPACITY_DURATION : TEXT_LOCK_OPACITY_DURATION)
.setStartDelay(expand ? LOCK_TEXT_OPACITY_DELAY : NO_DELAY);
}
void expandPrivateSpace() {