Allow BaseState.getTransitionDuration to read DeviceProfile

- Changed handheld duration to AllApps to 600

Bug: 227745955
Test: manual
Change-Id: I6f6642440dda3e39947231c2d38e8b60d152e08f
This commit is contained in:
Alex Chau
2022-05-05 13:34:09 +01:00
parent 21ea6828d8
commit a717d1621d
5 changed files with 19 additions and 8 deletions

View File

@@ -62,7 +62,7 @@ public class TaskbarAllAppsSlideInView extends AbstractSlideInView<TaskbarAllApp
PropertyValuesHolder.ofFloat(TRANSLATION_SHIFT, TRANSLATION_SHIFT_OPENED));
mOpenCloseAnimator.setInterpolator(AGGRESSIVE_EASE);
mOpenCloseAnimator.setDuration(
ALL_APPS.getTransitionDuration(mContext, true /* isToState */)).start();
ALL_APPS.getTransitionDuration(mActivityContext, true /* isToState */)).start();
} else {
mTranslationShift = TRANSLATION_SHIFT_OPENED;
}
@@ -81,7 +81,8 @@ public class TaskbarAllAppsSlideInView extends AbstractSlideInView<TaskbarAllApp
@Override
protected void handleClose(boolean animate) {
Optional.ofNullable(mOnCloseBeginListener).ifPresent(OnCloseListener::onSlideInViewClosed);
handleClose(animate, ALL_APPS.getTransitionDuration(mContext, false /* isToState */));
handleClose(animate,
ALL_APPS.getTransitionDuration(mActivityContext, false /* isToState */));
}
@Override

View File

@@ -20,6 +20,7 @@ import static com.android.launcher3.logging.StatsLogManager.LAUNCHER_STATE_ALLAP
import android.content.Context;
import com.android.launcher3.DeviceProfile.DeviceProfileListenable;
import com.android.launcher3.Launcher;
import com.android.launcher3.LauncherState;
import com.android.launcher3.R;
@@ -38,8 +39,11 @@ public class AllAppsState extends LauncherState {
}
@Override
public int getTransitionDuration(Context context, boolean isToState) {
return isToState ? 500 : 300;
public <DEVICE_PROFILE_CONTEXT extends Context & DeviceProfileListenable>
int getTransitionDuration(DEVICE_PROFILE_CONTEXT context, boolean isToState) {
return !context.getDeviceProfile().isTablet && isToState
? 600
: isToState ? 500 : 300;
}
@Override

View File

@@ -4051,7 +4051,7 @@ public abstract class RecentsView<ACTIVITY_TYPE extends StatefulActivity<STATE_T
// TODO(194414938) starting bounds seem slightly off, investigate
Rect firstTaskStartingBounds = new Rect();
Rect firstTaskEndingBounds = mTempRect;
int duration = mActivity.getStateManager().getState().getTransitionDuration(getContext(),
int duration = mActivity.getStateManager().getState().getTransitionDuration(mActivity,
false /* isToState */);
PendingAnimation pendingAnimation = new PendingAnimation(duration);

View File

@@ -18,6 +18,7 @@ package com.android.launcher3.statemanager;
import android.content.Context;
import com.android.launcher3.DeviceProfile;
import com.android.launcher3.DeviceProfile.DeviceProfileListenable;
/**
* Interface representing a state of a StatefulActivity
@@ -36,7 +37,8 @@ public interface BaseState<T extends BaseState> {
/**
* @return How long the animation to this state should take (or from this state to NORMAL).
*/
int getTransitionDuration(Context context, boolean isToState);
<DEVICE_PROFILE_CONTEXT extends Context & DeviceProfileListenable>
int getTransitionDuration(DEVICE_PROFILE_CONTEXT context, boolean isToState);
/**
* Returns the state to go back to from this state

View File

@@ -20,6 +20,7 @@ import static com.android.launcher3.logging.StatsLogManager.LAUNCHER_STATE_ALLAP
import android.content.Context;
import com.android.launcher3.DeviceProfile.DeviceProfileListenable;
import com.android.launcher3.Launcher;
import com.android.launcher3.LauncherState;
import com.android.launcher3.R;
@@ -39,8 +40,11 @@ public class AllAppsState extends LauncherState {
}
@Override
public int getTransitionDuration(Context context, boolean isToState) {
return isToState ? 500 : 300;
public <DEVICE_PROFILE_CONTEXT extends Context & DeviceProfileListenable>
int getTransitionDuration(DEVICE_PROFILE_CONTEXT context, boolean isToState) {
return !context.getDeviceProfile().isTablet && isToState
? 600
: isToState ? 500 : 300;
}
@Override