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

Commit 4420eae3 authored by Chris Craik's avatar Chris Craik Committed by Android (Google) Code Review
Browse files

Merge "Check api level before throwing in drawable setters"

parents 11dce732 b7244809
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -297,7 +297,7 @@ public class TextureView extends View {

    @Override
    public void setForeground(Drawable foreground) {
        if (foreground != null) {
        if (foreground != null && !sTextureViewIgnoresDrawableSetters) {
            throw new UnsupportedOperationException(
                    "TextureView doesn't support displaying a foreground drawable");
        }
@@ -305,7 +305,7 @@ public class TextureView extends View {

    @Override
    public void setBackgroundDrawable(Drawable background) {
        if (background != null) {
        if (background != null && !sTextureViewIgnoresDrawableSetters) {
            throw new UnsupportedOperationException(
                    "TextureView doesn't support displaying a background drawable");
        }
+10 −0
Original line number Diff line number Diff line
@@ -811,6 +811,12 @@ public class View implements Drawable.Callback, KeyEvent.Callback,
     */
    private static boolean sLayoutParamsAlwaysChanged = false;
    /**
     * Allow setForeground/setBackground to be called (and ignored) on a textureview,
     * without throwing
     */
    static boolean sTextureViewIgnoresDrawableSetters = false;
    /**
     * This view does not want keystrokes. Use with TAKES_FOCUS_MASK when
     * calling setFlags.
@@ -3984,6 +3990,10 @@ public class View implements Drawable.Callback, KeyEvent.Callback,
            // work. Partial layout breaks this assumption.
            sLayoutParamsAlwaysChanged = targetSdkVersion <= M;
            // Prior to N, TextureView would silently ignore calls to setBackground/setForeground.
            // On N+, we throw, but that breaks compatibility with apps that use these methods.
            sTextureViewIgnoresDrawableSetters = targetSdkVersion <= M;
            sCompatibilityDone = true;
        }
    }