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

Commit cebc6bab authored by Alan Viverette's avatar Alan Viverette
Browse files

Support hotspots in View drawables

BUG: 15285217
Change-Id: Iad44454fe16ac27ed20b9c17ae2df69649339eed
parent ec464ed7
Loading
Loading
Loading
Loading
+24 −16
Original line number Diff line number Diff line
@@ -90,6 +90,7 @@ import static java.lang.Math.max;
import com.android.internal.R;
import com.android.internal.util.Predicate;
import com.android.internal.view.menu.MenuBuilder;
import com.google.android.collect.Lists;
import com.google.android.collect.Maps;
@@ -4794,14 +4795,10 @@ public class View implements Drawable.Callback, KeyEvent.Callback,
     * @param v previous or the next focus holder, or null if none
     */
    private void manageFocusHotspot(boolean focused, View v) {
        if (mBackground == null) {
            return;
        }
        final Rect r = new Rect();
        if (!focused && v != null) {
            v.getBoundsOnScreen(r);
            final int[] location = new int[2];
            final int[] location = mAttachInfo.mTmpLocation;
            getLocationOnScreen(location);
            r.offset(-location[0], -location[1]);
        } else {
@@ -4810,8 +4807,21 @@ public class View implements Drawable.Callback, KeyEvent.Callback,
        final float x = r.exactCenterX();
        final float y = r.exactCenterY();
        setDrawableHotspot(x, y);
    }
    /**
     * Sets the hotspot position for this View's drawables.
     *
     * @param x hotspot x coordinate
     * @param y hotspot y coordinate
     * @hide
     */
    protected void setDrawableHotspot(float x, float y) {
        if (mBackground != null) {
            mBackground.setHotspot(x, y);
        }
    }
    /**
     * Request that a rectangle of this view be visible on the screen,
@@ -6767,7 +6777,7 @@ public class View implements Drawable.Callback, KeyEvent.Callback,
     */
    private void setPressed(boolean pressed, float x, float y) {
        if (pressed) {
            setHotspot(x, y);
            setDrawableHotspot(x, y);
        }
        setPressed(pressed);
@@ -9106,8 +9116,7 @@ public class View implements Drawable.Callback, KeyEvent.Callback,
                        postDelayed(mPendingCheckForTap, ViewConfiguration.getTapTimeout());
                    } else {
                        // Not inside a scrolling container, so show the feedback right away
                        setHotspot(x, y);
                        setPressed(true);
                        setPressed(true, x, y);
                        checkForLongClick(0);
                    }
                    break;
@@ -9119,7 +9128,7 @@ public class View implements Drawable.Callback, KeyEvent.Callback,
                    break;
                case MotionEvent.ACTION_MOVE:
                    setHotspot(x, y);
                    setDrawableHotspot(x, y);
                    // Be lenient about moving outside of buttons
                    if (!pointInView(x, y, mTouchSlop)) {
@@ -9141,12 +9150,6 @@ public class View implements Drawable.Callback, KeyEvent.Callback,
        return false;
    }
    private void setHotspot(float x, float y) {
        if (mBackground != null) {
            mBackground.setHotspot(x, y);
        }
    }
    /**
     * @hide
     */
@@ -19761,6 +19764,11 @@ public class View implements Drawable.Callback, KeyEvent.Callback,
         */
        final int[] mInvalidateChildLocation = new int[2];
        /**
         * Global to the view hierarchy used as a temporary for dealng with
         * computing absolute on-screen location.
         */
        final int[] mTmpLocation = new int[2];
        /**
         * Global to the view hierarchy used as a temporary for dealing with
+16 −0
Original line number Diff line number Diff line
@@ -255,6 +255,22 @@ public abstract class AbsSeekBar extends ProgressBar {
        }
    }

    /** @hide */
    @Override
    protected void setDrawableHotspot(float x, float y) {
        super.setDrawableHotspot(x, y);

        final Drawable progressDrawable = getProgressDrawable();
        if (progressDrawable != null) {
            progressDrawable.setHotspot(x, y);
        }

        final Drawable thumb = mThumb;
        if (thumb != null) {
            thumb.setHotspot(x, y);
        }
    }

    @Override
    public void invalidateDrawable(Drawable dr) {
        super.invalidateDrawable(dr);
+10 −0
Original line number Diff line number Diff line
@@ -307,6 +307,16 @@ public class CheckedTextView extends TextView implements Checkable {
        }
    }

    /** @hide */
    @Override
    protected void setDrawableHotspot(float x, float y) {
        super.setDrawableHotspot(x, y);

        if (mCheckMarkDrawable != null) {
            mCheckMarkDrawable.setHotspot(x, y);
        }
    }

    @Override
    public void onInitializeAccessibilityEvent(AccessibilityEvent event) {
        super.onInitializeAccessibilityEvent(event);
+10 −0
Original line number Diff line number Diff line
@@ -320,6 +320,16 @@ public abstract class CompoundButton extends Button implements Checkable {
        }
    }

    /** @hide */
    @Override
    protected void setDrawableHotspot(float x, float y) {
        super.setDrawableHotspot(x, y);

        if (mButtonDrawable != null) {
            mButtonDrawable.setHotspot(x, y);
        }
    }

    @Override
    protected boolean verifyDrawable(Drawable who) {
        return super.verifyDrawable(who) || who == mButtonDrawable;
+10 −0
Original line number Diff line number Diff line
@@ -205,6 +205,16 @@ public class FrameLayout extends ViewGroup {
        }
    }

    /** @hide */
    @Override
    protected void setDrawableHotspot(float x, float y) {
        super.setDrawableHotspot(x, y);

        if (mForeground != null) {
            mForeground.setHotspot(x, y);
        }
    }

    /**
     * Returns a set of layout parameters with a width of
     * {@link android.view.ViewGroup.LayoutParams#MATCH_PARENT},
Loading