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

Commit c96132ff authored by Jean-Baptiste Queru's avatar Jean-Baptiste Queru
Browse files

Revert "Clean up layout direction APIs for Drawable"

This reverts commit c1da6518.
parent 78068825
Loading
Loading
Loading
Loading
+8 −5
Original line number Diff line number Diff line
@@ -9251,12 +9251,12 @@ package android.graphics.drawable {
    method public android.graphics.drawable.Drawable getCurrent();
    method public int getIntrinsicHeight();
    method public int getIntrinsicWidth();
    method public int getLayoutDirection();
    method public final int getLevel();
    method public int getMinimumHeight();
    method public int getMinimumWidth();
    method public abstract int getOpacity();
    method public boolean getPadding(android.graphics.Rect);
    method public int getResolvedLayoutDirectionSelf();
    method public int[] getState();
    method public android.graphics.Region getTransparentRegion();
    method public void inflate(android.content.res.Resources, org.xmlpull.v1.XmlPullParser, android.util.AttributeSet) throws java.io.IOException, org.xmlpull.v1.XmlPullParserException;
@@ -9279,7 +9279,6 @@ package android.graphics.drawable {
    method public void setColorFilter(int, android.graphics.PorterDuff.Mode);
    method public void setDither(boolean);
    method public void setFilterBitmap(boolean);
    method public void setLayoutDirection(int);
    method public final boolean setLevel(int);
    method public boolean setState(int[]);
    method public boolean setVisible(boolean, boolean);
@@ -9292,6 +9291,10 @@ package android.graphics.drawable {
    method public abstract void unscheduleDrawable(android.graphics.drawable.Drawable, java.lang.Runnable);
  }
  public static abstract interface Drawable.Callback2 implements android.graphics.drawable.Drawable.Callback {
    method public abstract int getResolvedLayoutDirection(android.graphics.drawable.Drawable);
  }
  public static abstract class Drawable.ConstantState {
    ctor public Drawable.ConstantState();
    method public abstract int getChangingConfigurations();
@@ -23902,7 +23905,7 @@ package android.view {
    method public void recycle();
  }
  public class View implements android.view.accessibility.AccessibilityEventSource android.graphics.drawable.Drawable.Callback android.view.KeyEvent.Callback {
  public class View implements android.view.accessibility.AccessibilityEventSource android.graphics.drawable.Drawable.Callback android.graphics.drawable.Drawable.Callback2 android.view.KeyEvent.Callback {
    ctor public View(android.content.Context);
    ctor public View(android.content.Context, android.util.AttributeSet);
    ctor public View(android.content.Context, android.util.AttributeSet, int);
@@ -24047,6 +24050,7 @@ package android.view {
    method public float getPivotX();
    method public float getPivotY();
    method public int getResolvedLayoutDirection();
    method public int getResolvedLayoutDirection(android.graphics.drawable.Drawable);
    method public int getResolvedTextAlignment();
    method public int getResolvedTextDirection();
    method public android.content.res.Resources getResources();
@@ -24178,7 +24182,6 @@ package android.view {
    method protected void onOverScrolled(int, int, boolean, boolean);
    method public void onPaddingChanged(int);
    method public void onPopulateAccessibilityEvent(android.view.accessibility.AccessibilityEvent);
    method public void onResolveDrawables(int);
    method public void onResolvedLayoutDirectionChanged();
    method public void onResolvedLayoutDirectionReset();
    method public void onResolvedTextAlignmentChanged();
@@ -24230,7 +24233,6 @@ package android.view {
    method public void resetResolvedLayoutDirection();
    method public void resetResolvedTextAlignment();
    method public void resetResolvedTextDirection();
    method public void resolveDrawables();
    method public void resolveLayoutDirection();
    method public void resolvePadding();
    method public static int resolveSize(int, int);
@@ -28723,6 +28725,7 @@ package android.widget {
    method public boolean onTextContextMenuItem(int);
    method public void removeTextChangedListener(android.text.TextWatcher);
    method protected void resetResolvedDrawables();
    method protected void resolveDrawables();
    method public void setAllCaps(boolean);
    method public final void setAutoLinkMask(int);
    method public void setCompoundDrawablePadding(int);
+8 −35
Original line number Diff line number Diff line
@@ -660,7 +660,7 @@ import java.util.concurrent.CopyOnWriteArrayList;
 *
 * @see android.view.ViewGroup
 */
public class View implements Drawable.Callback, KeyEvent.Callback,
public class View implements Drawable.Callback, Drawable.Callback2, KeyEvent.Callback,
        AccessibilityEventSource {
    private static final boolean DBG = false;
@@ -3838,15 +3838,6 @@ public class View implements Drawable.Callback, KeyEvent.Callback,
            scrollabilityCache.scrollBar.setAlwaysDrawVerticalTrack(true);
        }
        // Apply layout direction to the new Drawables if needed
        final int layoutDirection = getResolvedLayoutDirection();
        if (track != null) {
            track.setLayoutDirection(layoutDirection);
        }
        if (thumb != null) {
            thumb.setLayoutDirection(layoutDirection);
        }
        // Re-apply user/background padding so that scrollbar(s) get added
        resolvePadding();
    }
@@ -13875,29 +13866,12 @@ public class View implements Drawable.Callback, KeyEvent.Callback,
    }
    /**
     * Resolve the Drawables depending on the layout direction. This is implicitly supposing
     * that the View directionality can and will be resolved before its Drawables.
    * Return the layout direction of a given Drawable.
    *
     * Will call {@link View#onResolveDrawables} when resolution is done.
     */
    public void resolveDrawables() {
        if (mBackground != null) {
            mBackground.setLayoutDirection(getResolvedLayoutDirection());
        }
        onResolveDrawables(getResolvedLayoutDirection());
    }
    /**
     * Called when layout direction has been resolved.
     *
     * The default implementation does nothing.
     *
     * @param layoutDirection The resolved layout direction.
     *
     * @see {@link #LAYOUT_DIRECTION_LTR}
     * @see {@link #LAYOUT_DIRECTION_RTL}
    * @param who the Drawable to query
    */
    public void onResolveDrawables(int layoutDirection) {
    public int getResolvedLayoutDirection(Drawable who) {
        return (who == mBackground) ? getResolvedLayoutDirection() : LAYOUT_DIRECTION_DEFAULT;
    }
    /**
@@ -14166,9 +14140,8 @@ public class View implements Drawable.Callback, KeyEvent.Callback,
                padding = new Rect();
                sThreadLocal.set(padding);
            }
            background.setLayoutDirection(getResolvedLayoutDirection());
            if (background.getPadding(padding)) {
                switch (background.getLayoutDirection()) {
                switch (background.getResolvedLayoutDirectionSelf()) {
                    case LAYOUT_DIRECTION_RTL:
                        setPadding(padding.right, padding.top, padding.left, padding.bottom);
                        break;
+6 −1
Original line number Diff line number Diff line
@@ -193,6 +193,12 @@ public class ImageView extends View {
        }
    }

    @Override
    public int getResolvedLayoutDirection(Drawable dr) {
        return (dr == mDrawable) ?
                getResolvedLayoutDirection() : super.getResolvedLayoutDirection(dr);
    }

    @Override
    public boolean hasOverlappingRendering() {
        return (getBackground() != null);
@@ -666,7 +672,6 @@ public class ImageView extends View {
                d.setState(getDrawableState());
            }
            d.setLevel(mLevel);
            d.setLayoutDirection(getLayoutDirection());
            mDrawableWidth = d.getIntrinsicWidth();
            mDrawableHeight = d.getIntrinsicHeight();
            applyColorMod();
+6 −4
Original line number Diff line number Diff line
@@ -478,9 +478,6 @@ public class ProgressBar extends View {
            d.setCallback(this);
        }
        mIndeterminateDrawable = d;
        if (mIndeterminateDrawable != null) {
            mIndeterminateDrawable.setLayoutDirection(getLayoutDirection());
        }
        if (mIndeterminate) {
            mCurrentDrawable = d;
            postInvalidate();
@@ -520,7 +517,6 @@ public class ProgressBar extends View {

        if (d != null) {
            d.setCallback(this);
            d.setLayoutDirection(getLayoutDirection());

            // Make sure the ProgressBar is always tall enough
            int drawableHeight = d.getMinimumHeight();
@@ -979,6 +975,12 @@ public class ProgressBar extends View {
        }
    }

    @Override
    public int getResolvedLayoutDirection(Drawable who) {
        return (who == mProgressDrawable || who == mIndeterminateDrawable) ?
            getResolvedLayoutDirection() : super.getResolvedLayoutDirection(who);
    }

    @Override
    protected void onSizeChanged(int w, int h, int oldw, int oldh) {
        updateDrawableBounds(w, h);
+22 −19
Original line number Diff line number Diff line
@@ -4578,6 +4578,20 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener
        }
    }

    @Override
    public int getResolvedLayoutDirection(Drawable who) {
        if (who == null) return View.LAYOUT_DIRECTION_LTR;
        if (mDrawables != null) {
            final Drawables drawables = mDrawables;
            if (who == drawables.mDrawableLeft || who == drawables.mDrawableRight ||
                who == drawables.mDrawableTop || who == drawables.mDrawableBottom ||
                who == drawables.mDrawableStart || who == drawables.mDrawableEnd) {
                return getResolvedLayoutDirection();
            }
        }
        return super.getResolvedLayoutDirection(who);
    }

    @Override
    public boolean hasOverlappingRendering() {
        return (getBackground() != null || mText instanceof Spannable || hasSelection());
@@ -8189,8 +8203,13 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener
        }
    }

    @Override
    public void onResolveDrawables(int layoutDirection) {
    /**
     * Subclasses will need to override this method to implement their own way of resolving
     * drawables depending on the layout direction.
     *
     * A call to the super method will be required from the subclasses implementation.
     */
    protected void resolveDrawables() {
        // No need to resolve twice
        if (mResolvedDrawables) {
            return;
@@ -8206,7 +8225,7 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener
        }

        Drawables dr = mDrawables;
        switch(layoutDirection) {
        switch(getResolvedLayoutDirection()) {
            case LAYOUT_DIRECTION_RTL:
                if (dr.mDrawableStart != null) {
                    dr.mDrawableRight = dr.mDrawableStart;
@@ -8238,25 +8257,9 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener
                }
                break;
        }
        updateDrawablesLayoutDirection(dr, layoutDirection);
        mResolvedDrawables = true;
    }

    private void updateDrawablesLayoutDirection(Drawables dr, int layoutDirection) {
        if (dr.mDrawableLeft != null) {
            dr.mDrawableLeft.setLayoutDirection(layoutDirection);
        }
        if (dr.mDrawableRight != null) {
            dr.mDrawableRight.setLayoutDirection(layoutDirection);
        }
        if (dr.mDrawableTop != null) {
            dr.mDrawableTop.setLayoutDirection(layoutDirection);
        }
        if (dr.mDrawableBottom != null) {
            dr.mDrawableBottom.setLayoutDirection(layoutDirection);
        }
    }

    protected void resetResolvedDrawables() {
        mResolvedDrawables = false;
    }
Loading