From cc3c480db73918bff51b0dc46e34f01392e8e9f8 Mon Sep 17 00:00:00 2001 From: Musenkishi Date: Thu, 11 Jun 2015 10:46:51 +0200 Subject: [PATCH] Remove ColorUtils --- .../java/com/musenkishi/atelier/Atelier.java | 4 +- .../com/musenkishi/atelier/ColorUtils.java | 67 ------------------- 2 files changed, 2 insertions(+), 69 deletions(-) delete mode 100644 lib/src/main/java/com/musenkishi/atelier/ColorUtils.java diff --git a/lib/src/main/java/com/musenkishi/atelier/Atelier.java b/lib/src/main/java/com/musenkishi/atelier/Atelier.java index 704db71..35d2057 100644 --- a/lib/src/main/java/com/musenkishi/atelier/Atelier.java +++ b/lib/src/main/java/com/musenkishi/atelier/Atelier.java @@ -216,7 +216,7 @@ private static void applyColorToView(final FloatingActionButton floatingActionBu .setColorFilter(color, PorterDuff.Mode.MULTIPLY); } } else { - ColorStateList colorStateList = ColorUtils.generateColorStateList(color); + ColorStateList colorStateList = ColorStateList.valueOf(color); floatingActionButton.setBackgroundTintList(colorStateList); } } else { @@ -265,7 +265,7 @@ public void onAnimationUpdate(ValueAnimator valueAnimator) { @Override public void onAnimationUpdate(ValueAnimator animator) { int color = (Integer) animator.getAnimatedValue(); - floatingActionButton.setBackgroundTintList(ColorUtils.generateColorStateList(color)); + floatingActionButton.setBackgroundTintList(ColorStateList.valueOf(color)); } }); colorAnimation.setDuration(300); diff --git a/lib/src/main/java/com/musenkishi/atelier/ColorUtils.java b/lib/src/main/java/com/musenkishi/atelier/ColorUtils.java deleted file mode 100644 index b205ba2..0000000 --- a/lib/src/main/java/com/musenkishi/atelier/ColorUtils.java +++ /dev/null @@ -1,67 +0,0 @@ -/* - * Copyright (C) 2015 Freddie (Musenkishi) Lust-Hed - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.musenkishi.atelier; - -import android.content.res.ColorStateList; -import android.graphics.Color; - -/** - * General class containing helpful functions regarding colors. - *

Created by Freddie (Musenkishi) Lust-Hed on 08/06/15.

- */ -public class ColorUtils { - - /** - * Will generate a {@link ColorStateList} based on the color provided. - * The generated {@link ColorStateList} will contain 3 different colors based on the provided; - * a regular, a greyed out (disabled state), and a darkened (pressed state). - * @param color The color you want the ColorStateList based on - * @return a ColorStateList based on provided color - */ - public static ColorStateList generateColorStateList(int color) { - int[][] states = new int[][] { - new int[] { android.R.attr.state_enabled}, // enabled - new int[] {-android.R.attr.state_enabled}, // disabled - new int[] {-android.R.attr.state_checked}, // unchecked - new int[] { android.R.attr.state_pressed} // pressed - }; - - int[] colors = new int[] { - color, - greyOutColor(color), - color, - darkenColor(color) - }; - - return new ColorStateList(states, colors); - } - - private static int darkenColor(int color) { - float[] hsv = new float[3]; - Color.colorToHSV(color, hsv); - hsv[2] *= 0.6f; - return Color.HSVToColor(hsv); - } - - private static int greyOutColor(int color) { - float[] hsv = new float[3]; - Color.colorToHSV(color, hsv); - hsv[1] *= 0.6f; - return Color.HSVToColor(hsv); - } - -}