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

Commit 1c9d20b5 authored by Alan Viverette's avatar Alan Viverette
Browse files

Preserve TextView mDrawables if it has metadata (ex. tint or padding)

Bug: 26939206
Change-Id: Iccc8b3d50e93e50685d050ca6ea191708a0e6171
parent b52567d6
Loading
Loading
Loading
Loading
+10 −3
Original line number Diff line number Diff line
@@ -115,7 +115,6 @@ import android.view.ContextMenu;
import android.view.DragEvent;
import android.view.Gravity;
import android.view.HapticFeedbackConstants;
import android.view.InputDevice;
import android.view.KeyCharacterMap;
import android.view.KeyEvent;
import android.view.MotionEvent;
@@ -394,6 +393,14 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener
            mOverride = false;
        }

        /**
         * @return {@code true} if this object contains metadata that needs to
         *         be retained, {@code false} otherwise
         */
        public boolean hasMetadata() {
            return mDrawablePadding != 0 || mHasTintMode || mHasTint;
        }

        /**
         * Updates the list of displayed drawables to account for the current
         * layout direction.
@@ -2174,7 +2181,7 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener
        if (!drawables) {
            // Clearing drawables...  can we free the data structure?
            if (dr != null) {
                if (dr.mDrawablePadding == 0) {
                if (!dr.hasMetadata()) {
                    mDrawables = null;
                } else {
                    // We need to retain the last set padding, so just clear
@@ -2377,7 +2384,7 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener
        if (!drawables) {
            // Clearing drawables...  can we free the data structure?
            if (dr != null) {
                if (dr.mDrawablePadding == 0) {
                if (!dr.hasMetadata()) {
                    mDrawables = null;
                } else {
                    // We need to retain the last set padding, so just clear