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

Commit 19091a7f authored by Samuel Tan's avatar Samuel Tan Committed by android-build-merger
Browse files

Merge branch 'master' of...

Merge branch 'master' of /usr/local/google/game/mirror/googleplex-android_googlesource_com/platform/frameworks/base
parents 33d5888d 0cc6b5a4
Loading
Loading
Loading
Loading
+6 −0
Original line number Diff line number Diff line
@@ -260,6 +260,12 @@ public class StateSet {
            case R.attr.state_enabled:
                sb.append("E ");
                break;
            case R.attr.state_checked:
                sb.append("C ");
                break;
            case R.attr.state_activated:
                sb.append("A ");
                break;
            }
        }

+38 −10
Original line number Diff line number Diff line
@@ -394,7 +394,17 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener
            mOverride = false;
        }

        public void resolveWithLayoutDirection(int layoutDirection) {
        /**
         * Updates the list of displayed drawables to account for the current
         * layout direction.
         *
         * @param layoutDirection the current layout direction
         * @return {@code true} if the displayed drawables changed
         */
        public boolean resolveWithLayoutDirection(int layoutDirection) {
            final Drawable previousLeft = mShowing[Drawables.LEFT];
            final Drawable previousRight = mShowing[Drawables.RIGHT];

            // First reset "left" and "right" drawables to their initial values
            mShowing[Drawables.LEFT] = mDrawableLeftInitial;
            mShowing[Drawables.RIGHT] = mDrawableRightInitial;
@@ -442,16 +452,11 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener
                        break;
                }
            }

            applyErrorDrawableIfNeeded(layoutDirection);
            updateDrawablesLayoutDirection(layoutDirection);
        }

        private void updateDrawablesLayoutDirection(int layoutDirection) {
            for (Drawable dr : mShowing) {
                if (dr != null) {
                    dr.setLayoutDirection(layoutDirection);
                }
            }
            return mShowing[Drawables.LEFT] != previousLeft
                    || mShowing[Drawables.RIGHT] != previousRight;
        }

        public void setErrorDrawable(Drawable dr, TextView tv) {
@@ -9846,7 +9851,30 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener

        // Resolve drawables
        if (mDrawables != null) {
            mDrawables.resolveWithLayoutDirection(layoutDirection);
            if (mDrawables.resolveWithLayoutDirection(layoutDirection)) {
                prepareDrawableForDisplay(mDrawables.mShowing[Drawables.LEFT]);
                prepareDrawableForDisplay(mDrawables.mShowing[Drawables.RIGHT]);
                applyCompoundDrawableTint();
            }
        }
    }

    /**
     * Prepares a drawable for display by propagating layout direction and
     * drawable state.
     *
     * @param dr the drawable to prepare
     */
    private void prepareDrawableForDisplay(@Nullable Drawable dr) {
        if (dr == null) {
            return;
        }

        dr.setLayoutDirection(getLayoutDirection());

        if (dr.isStateful()) {
            dr.setState(getDrawableState());
            dr.jumpToCurrentState();
        }
    }