Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit d8b9264a authored by Jonathan Miranda's avatar Jonathan Miranda Committed by Android (Google) Code Review
Browse files

Merge "Fix sizing of FloatingIconView so that it matches the workspace." into ub-launcher3-master

parents f86a7766 6f455b58
Loading
Loading
Loading
Loading
+2 −1
Original line number Original line Diff line number Diff line
@@ -480,7 +480,8 @@ public class BubbleTextView extends TextView implements ItemInfoUpdateReceiver,
     */
     */
    public ObjectAnimator createTextAlphaAnimator(boolean fadeIn) {
    public ObjectAnimator createTextAlphaAnimator(boolean fadeIn) {
        float toAlpha = shouldTextBeVisible() && fadeIn ? 1 : 0;
        float toAlpha = shouldTextBeVisible() && fadeIn ? 1 : 0;
        return ObjectAnimator.ofFloat(this, TEXT_ALPHA_PROPERTY, toAlpha);
        float fromAlpha = toAlpha == 1 ? 0 : 1f;
        return ObjectAnimator.ofFloat(this, TEXT_ALPHA_PROPERTY, fromAlpha, toAlpha);
    }
    }


    @Override
    @Override
+1 −2
Original line number Original line Diff line number Diff line
@@ -618,8 +618,7 @@ public class Folder extends AbstractFloatingView implements ClipPathView, DragSo
            mFolderIcon.setBackgroundVisible(true);
            mFolderIcon.setBackgroundVisible(true);
            mFolderIcon.mFolderName.setTextVisibility(true);
            mFolderIcon.mFolderName.setTextVisibility(true);
            if (wasAnimated) {
            if (wasAnimated) {
                mFolderIcon.mBackground.fadeInBackgroundShadow();
                mFolderIcon.animateBgShadowAndStroke();
                mFolderIcon.mBackground.animateBackgroundStroke();
                mFolderIcon.onFolderClose(mContent.getCurrentPage());
                mFolderIcon.onFolderClose(mContent.getCurrentPage());
                if (mFolderIcon.hasDot()) {
                if (mFolderIcon.hasDot()) {
                    mFolderIcon.animateDotScale(0f, 1f);
                    mFolderIcon.animateDotScale(0f, 1f);
+9 −0
Original line number Original line Diff line number Diff line
@@ -189,6 +189,15 @@ public class FolderIcon extends FrameLayout implements FolderListener {
        return icon;
        return icon;
    }
    }


    public void animateBgShadowAndStroke() {
        mBackground.fadeInBackgroundShadow();
        mBackground.animateBackgroundStroke();
    }

    public BubbleTextView getFolderName() {
        return mFolderName;
    }

    public void getPreviewBounds(Rect outBounds) {
    public void getPreviewBounds(Rect outBounds) {
        mBackground.getBounds(outBounds);
        mBackground.getBounds(outBounds);
    }
    }
+64 −14
Original line number Original line Diff line number Diff line
@@ -19,6 +19,8 @@ import static com.android.launcher3.config.FeatureFlags.ADAPTIVE_ICON_WINDOW_ANI


import android.animation.Animator;
import android.animation.Animator;
import android.animation.AnimatorListenerAdapter;
import android.animation.AnimatorListenerAdapter;
import android.animation.AnimatorSet;
import android.animation.ObjectAnimator;
import android.animation.ValueAnimator;
import android.animation.ValueAnimator;
import android.content.Context;
import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Canvas;
@@ -47,6 +49,7 @@ import com.android.launcher3.R;
import com.android.launcher3.Utilities;
import com.android.launcher3.Utilities;
import com.android.launcher3.anim.Interpolators;
import com.android.launcher3.anim.Interpolators;
import com.android.launcher3.dragndrop.DragLayer;
import com.android.launcher3.dragndrop.DragLayer;
import com.android.launcher3.dragndrop.FolderAdaptiveIcon;
import com.android.launcher3.folder.FolderIcon;
import com.android.launcher3.folder.FolderIcon;
import com.android.launcher3.folder.FolderShape;
import com.android.launcher3.folder.FolderShape;
import com.android.launcher3.graphics.ShiftedBitmapDrawable;
import com.android.launcher3.graphics.ShiftedBitmapDrawable;
@@ -157,11 +160,13 @@ public class FloatingIconView extends View implements Animator.AnimatorListener,


    @Override
    @Override
    public void onAnimationEnd(Animator animator) {
    public void onAnimationEnd(Animator animator) {
        if (mEndRunnable != null) {
            mEndRunnable.run();
        } else {
            // End runnable also ends the reveal animator, so we manually handle it here.
            if (mRevealAnimator != null) {
            if (mRevealAnimator != null) {
                mRevealAnimator.end();
                mRevealAnimator.end();
            }
            }
        if (mEndRunnable != null) {
            mEndRunnable.run();
        }
        }
    }
    }


@@ -221,6 +226,7 @@ public class FloatingIconView extends View implements Animator.AnimatorListener,
        new Handler(Looper.getMainLooper()).post(() -> {
        new Handler(Looper.getMainLooper()).post(() -> {
            if (isAdaptiveIcon) {
            if (isAdaptiveIcon) {
                mIsAdaptiveIcon = true;
                mIsAdaptiveIcon = true;
                boolean isFolderIcon = finalDrawable instanceof FolderAdaptiveIcon;


                AdaptiveIconDrawable adaptiveIcon = (AdaptiveIconDrawable) finalDrawable;
                AdaptiveIconDrawable adaptiveIcon = (AdaptiveIconDrawable) finalDrawable;
                Drawable background = adaptiveIcon.getBackground();
                Drawable background = adaptiveIcon.getBackground();
@@ -234,20 +240,27 @@ public class FloatingIconView extends View implements Animator.AnimatorListener,
                }
                }
                mForeground = foreground;
                mForeground = foreground;


                mFinalDrawableBounds.set(iconOffset, iconOffset, lp.width -
                        iconOffset, mOriginalHeight - iconOffset);
                if (mForeground instanceof ShiftedBitmapDrawable && v instanceof FolderIcon) {
                if (mForeground instanceof ShiftedBitmapDrawable && v instanceof FolderIcon) {
                    ShiftedBitmapDrawable sbd = (ShiftedBitmapDrawable) mForeground;
                    ShiftedBitmapDrawable sbd = (ShiftedBitmapDrawable) mForeground;
                    ((FolderIcon) v).getPreviewBounds(sTmpRect);
                    ((FolderIcon) v).getPreviewBounds(sTmpRect);
                    sbd.setShiftX(sbd.getShiftX() - sTmpRect.left);
                    sbd.setShiftX(sbd.getShiftX() - sTmpRect.left);
                    sbd.setShiftY(sbd.getShiftY() - sTmpRect.top);
                    sbd.setShiftY(sbd.getShiftY() - sTmpRect.top);
                }
                }

                int blurMargin = mBlurSizeOutline / 2;
                mFinalDrawableBounds.set(0, 0, lp.width, mOriginalHeight);
                if (!isFolderIcon) {
                    mFinalDrawableBounds.inset(iconOffset - blurMargin, iconOffset - blurMargin);
                }
                mForeground.setBounds(mFinalDrawableBounds);
                mForeground.setBounds(mFinalDrawableBounds);
                mBackground.setBounds(mFinalDrawableBounds);
                mBackground.setBounds(mFinalDrawableBounds);


                int blurMargin = mBlurSizeOutline / 2;
                if (isFolderIcon) {
                mStartRevealRect.set(blurMargin, blurMargin , lp.width - blurMargin,
                    mStartRevealRect.set(0, 0, lp.width, mOriginalHeight);
                        mOriginalHeight - blurMargin);
                } else {
                    mStartRevealRect.set(mBlurSizeOutline, mBlurSizeOutline,
                            lp.width - mBlurSizeOutline, mOriginalHeight - mBlurSizeOutline);
                }


                if (aspectRatio > 0) {
                if (aspectRatio > 0) {
                    lp.height = (int) Math.max(lp.height, lp.width * aspectRatio);
                    lp.height = (int) Math.max(lp.height, lp.width * aspectRatio);
@@ -380,12 +393,49 @@ public class FloatingIconView extends View implements Animator.AnimatorListener,
                originalView.setVisibility(INVISIBLE);
                originalView.setVisibility(INVISIBLE);
            }
            }
        };
        };
        view.mEndRunnable = () -> {
            ((ViewGroup) dragLayer.getParent()).getOverlay().remove(view);
        if (hideOriginal) {
        if (hideOriginal) {
            view.mEndRunnable = () -> {
                AnimatorSet fade = new AnimatorSet();
                fade.setDuration(200);
                fade.addListener(new AnimatorListenerAdapter() {
                    @Override
                    public void onAnimationStart(Animator animation) {
                        originalView.setVisibility(VISIBLE);
                        originalView.setVisibility(VISIBLE);

                        if (originalView instanceof FolderIcon) {
                            FolderIcon folderIcon = (FolderIcon) originalView;
                            folderIcon.setBackgroundVisible(false);
                            folderIcon.getFolderName().setTextVisibility(false);
                        }
                    }
                    }

                    @Override
                    public void onAnimationEnd(Animator animation) {
                        ((ViewGroup) dragLayer.getParent()).getOverlay().remove(view);

                        if (view.mRevealAnimator != null) {
                            view.mRevealAnimator.end();
                        }
                    }
                });

                if (originalView instanceof FolderIcon) {
                    FolderIcon folderIcon = (FolderIcon) originalView;
                    fade.play(folderIcon.getFolderName().createTextAlphaAnimator(true));
                    fade.addListener(new AnimatorListenerAdapter() {
                        @Override
                        public void onAnimationEnd(Animator animation) {
                            folderIcon.setBackgroundVisible(true);
                            folderIcon.animateBgShadowAndStroke();
                            folderIcon.animateDotScale(0, 1f);
                        }
                    });
                } else {
                    fade.play(ObjectAnimator.ofFloat(originalView, ALPHA, 0f, 1f));
                }
                fade.start();
            };
            };
        }
        return view;
        return view;
    }
    }
}
}