update folder anim for new folder specs and spring animation
- Refactors FolderAnimationManager into several classes including new FolderSpringBuilderAnimationManager - Changes Folder animations to use animators resembling SpringAnimation - Split up calculations from creating AnimatorSet Bug: 387543793 Test: tested opening closing folders of different sizes Flag: com.android.launcher3.enable_launcher_icon_shapes Flag: com.android.launcher3.enable_expressive_folder_expansion Change-Id: Idf1f21374f987389979ad45544ade1506b26fc0c
This commit is contained in:
@@ -37,6 +37,8 @@ import android.view.View;
|
||||
import android.view.animation.AnimationUtils;
|
||||
import android.view.animation.Interpolator;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
|
||||
import com.android.launcher3.BubbleTextView;
|
||||
import com.android.launcher3.CellLayout;
|
||||
import com.android.launcher3.DeviceProfile;
|
||||
@@ -60,7 +62,7 @@ import java.util.List;
|
||||
* ie. When the user taps on the FolderIcon, we immediately hide the FolderIcon and show the Folder
|
||||
* in its place before starting the animation.
|
||||
*/
|
||||
public class FolderAnimationManager {
|
||||
public class FolderAnimationManager implements FolderAnimationCreator {
|
||||
|
||||
private static final float EXTRA_FOLDER_REVEAL_RADIUS_PERCENTAGE = 0.125F;
|
||||
private static final int FOLDER_NAME_ALPHA_DURATION = 32;
|
||||
@@ -75,7 +77,7 @@ public class FolderAnimationManager {
|
||||
|
||||
private Context mContext;
|
||||
|
||||
private final boolean mIsOpening;
|
||||
private boolean mIsOpening;
|
||||
|
||||
private final int mDuration;
|
||||
private final int mDelay;
|
||||
@@ -92,7 +94,7 @@ public class FolderAnimationManager {
|
||||
|
||||
private DeviceProfile mDeviceProfile;
|
||||
|
||||
public FolderAnimationManager(Folder folder, boolean isOpening) {
|
||||
public FolderAnimationManager(Folder folder) {
|
||||
mFolder = folder;
|
||||
mContent = folder.mContent;
|
||||
mFolderBackground = (GradientDrawable) mFolder.getBackground();
|
||||
@@ -104,7 +106,7 @@ public class FolderAnimationManager {
|
||||
mDeviceProfile = folder.mActivityContext.getDeviceProfile();
|
||||
mPreviewVerifier = createFolderGridOrganizer(mDeviceProfile);
|
||||
|
||||
mIsOpening = isOpening;
|
||||
mIsOpening = true;
|
||||
|
||||
Resources res = mContent.getResources();
|
||||
mDuration = res.getInteger(R.integer.config_materialFolderExpandDuration);
|
||||
@@ -130,7 +132,10 @@ public class FolderAnimationManager {
|
||||
/**
|
||||
* Prepares the Folder for animating between open / closed states.
|
||||
*/
|
||||
public AnimatorSet getAnimator() {
|
||||
@NonNull
|
||||
@Override
|
||||
public AnimatorSet createAnimatorSet(boolean isOpening) {
|
||||
mIsOpening = isOpening;
|
||||
final BaseDragLayer.LayoutParams lp =
|
||||
(BaseDragLayer.LayoutParams) mFolder.getLayoutParams();
|
||||
mFolderIcon.getPreviewItemManager().recomputePreviewDrawingParams();
|
||||
@@ -145,7 +150,7 @@ public class FolderAnimationManager {
|
||||
float initialSize = (scaledRadius * 2) * scaleRelativeToDragLayer;
|
||||
|
||||
// Match size/scale of icons in the preview
|
||||
float previewScale = rule.scaleForItem(itemsInPreview.size());
|
||||
float previewScale = rule.scaleForItem(itemsInPreview.size(), 0);
|
||||
float previewSize = rule.getIconSize() * previewScale;
|
||||
float baseIconSize = getBubbleTextView(itemsInPreview.get(0)).getIconSize();
|
||||
float initialScale = previewSize / baseIconSize * scaleRelativeToDragLayer;
|
||||
@@ -385,7 +390,7 @@ public class FolderAnimationManager {
|
||||
cwc.setupLp(v);
|
||||
|
||||
// Match scale of icons in the preview of the items on the first page.
|
||||
float previewScale = rule.scaleForItem(numItemsInFirstPagePreview);
|
||||
float previewScale = rule.scaleForItem(numItemsInFirstPagePreview, 0);
|
||||
float previewSize = rule.getIconSize() * previewScale;
|
||||
float baseIconSize = getBubbleTextView(v).getIconSize();
|
||||
float iconScale = previewSize / baseIconSize;
|
||||
|
||||
Reference in New Issue
Block a user