Optimize system bar switching animations

- Fix a bug where the wrong time was used when the activity was in
overview, but overview wasn't actually visible.
- Fixing this looks pretty bad. Introduce a pre-delay since our
animations decelarate heavily at the end.
- Consolidate logic between swipe-up and swipe-down. Take a middle
value that is most in line with the other animations.

Test: Open/close apps from home and recents with and without
swiping.
Fixes: 109906294

Change-Id: I9cd5568c60fe7281d0f71a75981a3003770e659e
This commit is contained in:
Jorim Jaggi
2018-06-11 15:21:41 +02:00
parent 2b03b713f7
commit fca9eec464
4 changed files with 22 additions and 7 deletions

View File

@@ -92,8 +92,16 @@ public class LauncherAppTransitionManagerImpl extends LauncherAppTransitionManag
implements OnDeviceProfileChangeListener {
private static final String TAG = "LauncherTransition";
/** Duration of status bar animations. */
public static final int STATUS_BAR_TRANSITION_DURATION = 120;
/**
* Since our animations decelerate heavily when finishing, we want to start status bar animations
* x ms before the ending.
*/
public static final int STATUS_BAR_TRANSITION_PRE_DELAY = 96;
private static final String CONTROL_REMOTE_APP_TRANSITION_PERMISSION =
"android.permission.CONTROL_REMOTE_APP_TRANSITION_ANIMATIONS";
@@ -210,9 +218,14 @@ public class LauncherAppTransitionManagerImpl extends LauncherAppTransitionManag
}
};
int duration = findTaskViewToLaunch(launcher, v, null) != null
? RECENTS_LAUNCH_DURATION : APP_LAUNCH_DURATION;
int statusBarTransitionDelay = duration - STATUS_BAR_TRANSITION_DURATION;
boolean fromRecents = mLauncher.getStateManager().getState().overviewUi
&& findTaskViewToLaunch(launcher, v, null) != null;
int duration = fromRecents
? RECENTS_LAUNCH_DURATION
: APP_LAUNCH_DURATION;
int statusBarTransitionDelay = duration - STATUS_BAR_TRANSITION_DURATION
- STATUS_BAR_TRANSITION_PRE_DELAY;
return ActivityOptionsCompat.makeRemoteAnimation(new RemoteAnimationAdapterCompat(
runner, duration, statusBarTransitionDelay));
}