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

Commit 474508b7 authored by Treehugger Robot's avatar Treehugger Robot Committed by Gerrit Code Review
Browse files

Merge "Update FloatingRotationButton in onMeasure" into main

parents 8c9b4586 538497c1
Loading
Loading
Loading
Loading
+8 −0
Original line number Diff line number Diff line
@@ -125,6 +125,7 @@ public class FloatingRotationButton implements RotationButton {
                taskbarMarginLeft, taskbarMarginBottom, floatingRotationButtonPositionLeft);

        final int diameter = res.getDimensionPixelSize(mButtonDiameterResource);
        mKeyButtonView.setDiameter(diameter);
        mContainerSize = diameter + Math.max(defaultMargin, Math.max(taskbarMarginLeft,
                taskbarMarginBottom));
    }
@@ -195,6 +196,7 @@ public class FloatingRotationButton implements RotationButton {
    public void updateIcon(int lightIconColor, int darkIconColor) {
        mAnimatedDrawable = (AnimatedVectorDrawable) mKeyButtonView.getContext()
                .getDrawable(mRotationButtonController.getIconResId());
        mAnimatedDrawable.setBounds(0, 0, mKeyButtonView.getWidth(), mKeyButtonView.getHeight());
        mKeyButtonView.setImageDrawable(mAnimatedDrawable);
        mKeyButtonView.setColors(lightIconColor, darkIconColor);
    }
@@ -248,8 +250,14 @@ public class FloatingRotationButton implements RotationButton {
            updateDimensionResources();

            if (mIsShowing) {
                updateIcon(mRotationButtonController.getLightIconColor(),
                        mRotationButtonController.getDarkIconColor());
                final LayoutParams layoutParams = adjustViewPositionAndCreateLayoutParams();
                mWindowManager.updateViewLayout(mKeyButtonContainer, layoutParams);
                if (mAnimatedDrawable != null) {
                    mAnimatedDrawable.reset();
                    mAnimatedDrawable.start();
                }
            }
        }

+16 −0
Original line number Diff line number Diff line
@@ -37,6 +37,7 @@ public class FloatingRotationButtonView extends ImageView {
    private static final float BACKGROUND_ALPHA = 0.92f;

    private KeyButtonRipple mRipple;
    private int mDiameter;
    private final Paint mOvalBgPaint = new Paint(Paint.ANTI_ALIAS_FLAG | Paint.FILTER_BITMAP_FLAG);

    private final Configuration mLastConfiguration;
@@ -93,10 +94,25 @@ public class FloatingRotationButtonView extends ImageView {
        mRipple.setDarkIntensity(darkIntensity);
    }

    /**
     * Sets the view's diameter.
     *
     * @param diameter the diameter value for the view
     */
    void setDiameter(int diameter) {
        mDiameter = diameter;
    }

    @Override
    public void draw(Canvas canvas) {
        int d = Math.min(getWidth(), getHeight());
        canvas.drawOval(0, 0, d, d, mOvalBgPaint);
        super.draw(canvas);
    }

    @Override
    protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
        super.onMeasure(widthMeasureSpec, heightMeasureSpec);
        setMeasuredDimension(mDiameter, mDiameter);
    }
}