summaryrefslogtreecommitdiff
path: root/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/utils/ColorUtils.java
diff options
context:
space:
mode:
authorTobrun <tobrun@mapbox.com>2016-04-26 09:52:14 +0200
committerTobrun <tobrun@mapbox.com>2016-04-26 12:28:36 +0200
commitb39d289920ad805f4dc64b6fe452399046f2baf3 (patch)
tree69558bdd2fe9634487a31a15ca1be3602f20522e /platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/utils/ColorUtils.java
parent3602fdc040de9dfd700e9130d8db68e045f133db (diff)
downloadqtlocation-mapboxgl-b39d289920ad805f4dc64b6fe452399046f2baf3.tar.gz
[android] #3231 - add support for tinting attribution icon through xml - MapboxMapOptions, AttributionDialog will use the same color values
Diffstat (limited to 'platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/utils/ColorUtils.java')
-rw-r--r--platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/utils/ColorUtils.java27
1 files changed, 8 insertions, 19 deletions
diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/utils/ColorUtils.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/utils/ColorUtils.java
index 972011b7f9..a0de07c5f1 100644
--- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/utils/ColorUtils.java
+++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/utils/ColorUtils.java
@@ -59,43 +59,32 @@ public class ColorUtils {
/**
* Returns a color state list associated with a theme based on a {@link Context}
*
- * @param context The context used to style the color attributes.
+ * @param color The color used for tinting.
* @return A ColorStateList object containing the primary color of a theme
*/
@NonNull
- public static ColorStateList getSelector(@NonNull Context context) {
+ public static ColorStateList getSelector(@ColorInt int color) {
return new ColorStateList(
new int[][]{
new int[]{android.R.attr.state_pressed},
new int[]{}
},
new int[]{
- getPrimaryColor(context),
- getPrimaryColor(context)
+ color,
+ color
}
);
}
/**
- * Set a primary color tint list to the {@link Drawable} of an {@link ImageView}.
+ * Set a color tint list to the {@link Drawable} of an {@link ImageView}.
*
* @param imageView The view to set the default tint list.
+ * @param tintColor The color to tint.
*/
- public static void setTintList(@NonNull ImageView imageView) {
+ public static void setTintList(@NonNull ImageView imageView, @ColorInt int tintColor) {
Drawable originalDrawable = imageView.getDrawable();
Drawable wrappedDrawable = DrawableCompat.wrap(originalDrawable);
- DrawableCompat.setTintList(wrappedDrawable, getSelector(imageView.getContext()));
+ DrawableCompat.setTintList(wrappedDrawable, getSelector(tintColor));
}
-
- /**
- * Set a primary color tint to a {@link Drawable}.
- *
- * @param context The context used to style the color attributes.
- * @param drawable The drawable to tint.
- */
- public static void setTint(@NonNull Context context, @NonNull Drawable drawable) {
- Drawable wrappedDrawable = DrawableCompat.wrap(drawable);
- DrawableCompat.setTint(wrappedDrawable, ColorUtils.getPrimaryColor(context));
- }
-
} \ No newline at end of file