Loading core/java/android/view/View.java +3 −0 Original line number Diff line number Diff line Loading @@ -75,6 +75,7 @@ import android.graphics.RenderNode; import android.graphics.Shader; import android.graphics.drawable.ColorDrawable; import android.graphics.drawable.Drawable; import android.graphics.drawable.GradientDrawable; import android.hardware.display.DisplayManagerGlobal; import android.net.Uri; import android.os.Build; Loading Loading @@ -5229,6 +5230,8 @@ public class View implements Drawable.Callback, KeyEvent.Callback, sBrokenWindowBackground = targetSdkVersion < Build.VERSION_CODES.Q; GradientDrawable.sWrapNegativeAngleMeasurements = targetSdkVersion >= Build.VERSION_CODES.Q; sCompatibilityDone = true; } } graphics/java/android/graphics/drawable/GradientDrawable.java +53 −27 Original line number Diff line number Diff line Loading @@ -97,6 +97,14 @@ import java.lang.annotation.RetentionPolicy; * @attr ref android.R.styleable#GradientDrawablePadding_bottom */ public class GradientDrawable extends Drawable { /** * Flag to determine if we should wrap negative gradient angle measurements * for API levels that support it * @hide */ public static boolean sWrapNegativeAngleMeasurements = true; /** * Shape is a rectangle, possibly with rounded corners */ Loading Loading @@ -151,6 +159,9 @@ public class GradientDrawable extends Drawable { /** Radius is a fraction of the bounds size. */ private static final int RADIUS_TYPE_FRACTION_PARENT = 2; /** Default orientation for GradientDrawable **/ private static final Orientation DEFAULT_ORIENTATION = Orientation.TOP_BOTTOM; /** @hide */ @IntDef({RADIUS_TYPE_PIXELS, RADIUS_TYPE_FRACTION, RADIUS_TYPE_FRACTION_PARENT}) @Retention(RetentionPolicy.SOURCE) Loading Loading @@ -207,7 +218,7 @@ public class GradientDrawable extends Drawable { } public GradientDrawable() { this(new GradientState(Orientation.TOP_BOTTOM, null), null); this(new GradientState(DEFAULT_ORIENTATION, null), null); } /** Loading Loading @@ -1757,8 +1768,20 @@ public class GradientDrawable extends Drawable { } int angle = (int) a.getFloat(R.styleable.GradientDrawableGradient_angle, st.mAngle); // GradientDrawable historically has not parsed negative angle measurements and always // stays on the default orientation for API levels older than Q. // Only configure the orientation if the angle is greater than zero. // Otherwise fallback on Orientation.TOP_BOTTOM // In Android Q and later, actually wrap the negative angle measurement to the correct // value if (sWrapNegativeAngleMeasurements) { st.mAngle = ((angle % 360) + 360) % 360; // offset negative angle measures } else { st.mAngle = angle % 360; } if (st.mAngle >= 0) { switch (st.mAngle) { case 0: st.mOrientation = Orientation.LEFT_RIGHT; Loading @@ -1785,6 +1808,9 @@ public class GradientDrawable extends Drawable { st.mOrientation = Orientation.TL_BR; break; } } else { st.mOrientation = DEFAULT_ORIENTATION; } final TypedValue tv = a.peekValue(R.styleable.GradientDrawableGradient_gradientRadius); if (tv != null) { Loading Loading
core/java/android/view/View.java +3 −0 Original line number Diff line number Diff line Loading @@ -75,6 +75,7 @@ import android.graphics.RenderNode; import android.graphics.Shader; import android.graphics.drawable.ColorDrawable; import android.graphics.drawable.Drawable; import android.graphics.drawable.GradientDrawable; import android.hardware.display.DisplayManagerGlobal; import android.net.Uri; import android.os.Build; Loading Loading @@ -5229,6 +5230,8 @@ public class View implements Drawable.Callback, KeyEvent.Callback, sBrokenWindowBackground = targetSdkVersion < Build.VERSION_CODES.Q; GradientDrawable.sWrapNegativeAngleMeasurements = targetSdkVersion >= Build.VERSION_CODES.Q; sCompatibilityDone = true; } }
graphics/java/android/graphics/drawable/GradientDrawable.java +53 −27 Original line number Diff line number Diff line Loading @@ -97,6 +97,14 @@ import java.lang.annotation.RetentionPolicy; * @attr ref android.R.styleable#GradientDrawablePadding_bottom */ public class GradientDrawable extends Drawable { /** * Flag to determine if we should wrap negative gradient angle measurements * for API levels that support it * @hide */ public static boolean sWrapNegativeAngleMeasurements = true; /** * Shape is a rectangle, possibly with rounded corners */ Loading Loading @@ -151,6 +159,9 @@ public class GradientDrawable extends Drawable { /** Radius is a fraction of the bounds size. */ private static final int RADIUS_TYPE_FRACTION_PARENT = 2; /** Default orientation for GradientDrawable **/ private static final Orientation DEFAULT_ORIENTATION = Orientation.TOP_BOTTOM; /** @hide */ @IntDef({RADIUS_TYPE_PIXELS, RADIUS_TYPE_FRACTION, RADIUS_TYPE_FRACTION_PARENT}) @Retention(RetentionPolicy.SOURCE) Loading Loading @@ -207,7 +218,7 @@ public class GradientDrawable extends Drawable { } public GradientDrawable() { this(new GradientState(Orientation.TOP_BOTTOM, null), null); this(new GradientState(DEFAULT_ORIENTATION, null), null); } /** Loading Loading @@ -1757,8 +1768,20 @@ public class GradientDrawable extends Drawable { } int angle = (int) a.getFloat(R.styleable.GradientDrawableGradient_angle, st.mAngle); // GradientDrawable historically has not parsed negative angle measurements and always // stays on the default orientation for API levels older than Q. // Only configure the orientation if the angle is greater than zero. // Otherwise fallback on Orientation.TOP_BOTTOM // In Android Q and later, actually wrap the negative angle measurement to the correct // value if (sWrapNegativeAngleMeasurements) { st.mAngle = ((angle % 360) + 360) % 360; // offset negative angle measures } else { st.mAngle = angle % 360; } if (st.mAngle >= 0) { switch (st.mAngle) { case 0: st.mOrientation = Orientation.LEFT_RIGHT; Loading @@ -1785,6 +1808,9 @@ public class GradientDrawable extends Drawable { st.mOrientation = Orientation.TL_BR; break; } } else { st.mOrientation = DEFAULT_ORIENTATION; } final TypedValue tv = a.peekValue(R.styleable.GradientDrawableGradient_gradientRadius); if (tv != null) { Loading