summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Ashley Rose <ashleyrose@google.com> 2018-09-05 16:04:01 -0400
committer Ashley Rose <ashleyrose@google.com> 2018-09-05 19:30:53 -0400
commitaa554ae636ffc07bf83f11b010c217c585197b96 (patch)
treea84282016f20d63841fba9702be1393412eddac2
parent7ea11f2b14dbb02c5a4828960fafccd29eabc28e (diff)
Add isColorType to TypedValue
There's a lot of places that used TypedValue.TYPE_FIRST_COLOR_INT and TypedValue.TYPE_LAST_COLOR_INT, and I'd like to propose that it's enough of an implementation detail that it should have a dedicated public method to query it. Fixes: 114126626 Test: CTS tests to be added Change-Id: I4d2a927cc3d2e999985d7e1c9b647d513fff53fc
-rwxr-xr-xapi/current.txt1
-rw-r--r--core/java/android/util/TypedValue.java10
2 files changed, 11 insertions, 0 deletions
diff --git a/api/current.txt b/api/current.txt
index f750e33a9610..65af433509da 100755
--- a/api/current.txt
+++ b/api/current.txt
@@ -45984,6 +45984,7 @@ package android.util {
method public float getDimension(android.util.DisplayMetrics);
method public final float getFloat();
method public float getFraction(float, float);
+ method public boolean isColorType();
method public void setTo(android.util.TypedValue);
field public static final int COMPLEX_MANTISSA_MASK = 16777215; // 0xffffff
field public static final int COMPLEX_MANTISSA_SHIFT = 8; // 0x8
diff --git a/core/java/android/util/TypedValue.java b/core/java/android/util/TypedValue.java
index 2c9bb660b149..964017396bbd 100644
--- a/core/java/android/util/TypedValue.java
+++ b/core/java/android/util/TypedValue.java
@@ -232,6 +232,16 @@ public class TypedValue {
};
/**
+ * Determine if a value is a color by comparing {@link type} to {@link #TYPE_FIRST_COLOR_INT}
+ * and {@link #TYPE_LAST_COLOR_INT}.
+ *
+ * @return true if this value is a color
+ */
+ public boolean isColorType() {
+ return (type >= TYPE_FIRST_COLOR_INT && type <= TYPE_LAST_COLOR_INT);
+ }
+
+ /**
* Retrieve the base value from a complex data integer. This uses the
* {@link #COMPLEX_MANTISSA_MASK} and {@link #COMPLEX_RADIX_MASK} fields of
* the data to compute a floating point representation of the number they