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

Commit 8935b22c authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Fix the remove button icon not centered when the home screen is in...

Merge "Fix the remove button icon not centered when the home screen is in landscape." into sc-v2-dev
parents 4941b847 63d1a181
Loading
Loading
Loading
Loading
+15 −2
Original line number Diff line number Diff line
@@ -108,8 +108,8 @@ public abstract class ButtonDropTarget extends TextView
        // We do not set the drawable in the xml as that inflates two drawables corresponding to
        // drawableLeft and drawableStart.
        mDrawable = getContext().getDrawable(resId).mutate();
        mDrawable.setBounds(0, 0, mDrawableSize, mDrawableSize);
        mDrawable.setTintList(getTextColors());
        centerIcon();
        setCompoundDrawablesRelative(mDrawable, null, null, null);
    }

@@ -289,6 +289,12 @@ public abstract class ButtonDropTarget extends TextView
        return to;
    }

    private void centerIcon() {
        int x = mTextVisible ? 0
                : (getWidth() - getPaddingLeft() - getPaddingRight()) / 2 - mDrawableSize / 2;
        mDrawable.setBounds(x, 0, x + mDrawableSize, mDrawableSize);
    }

    @Override
    public void onClick(View v) {
        mLauncher.getAccessibilityDelegate().handleAccessibleDrop(this, null, null);
@@ -299,12 +305,19 @@ public abstract class ButtonDropTarget extends TextView
        if (mTextVisible != isVisible || !TextUtils.equals(newText, getText())) {
            mTextVisible = isVisible;
            setText(newText);
            centerIcon();
            setCompoundDrawablesRelative(mDrawable, null, null, null);
            int drawablePadding = mTextVisible ? mDrawablePadding : 0;
            setCompoundDrawablePadding(drawablePadding);
        }
    }

    @Override
    protected void onSizeChanged(int w, int h, int oldw, int oldh) {
        super.onSizeChanged(w, h, oldw, oldh);
        centerIcon();
    }

    public void setToolTipLocation(int location) {
        mToolTipLocation = location;
        hideTooltip();