Skip to content

Commit

Permalink
Utils hidden
Browse files Browse the repository at this point in the history
  • Loading branch information
marcoscgdev committed Dec 3, 2017
1 parent 922fc42 commit 6f8e8a8
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions dialogsheet/src/main/java/com/marcoscg/dialogsheet/Utils.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,27 +22,27 @@
public class Utils {

@ColorInt
public static int darkenColor(@ColorInt int color) {
static int darkenColor(@ColorInt int color) {
float[] hsv = new float[3];
Color.colorToHSV(color, hsv);
hsv[2] *= 0.85f;
return Color.HSVToColor(hsv);
}

public static boolean isColorLight(@ColorInt int color) {
static boolean isColorLight(@ColorInt int color) {
if (color == Color.BLACK) return false;
else if (color == Color.WHITE || color == Color.TRANSPARENT) return true;
final double darkness = 1 - (0.299 * Color.red(color) + 0.587 * Color.green(color) + 0.114 * Color.blue(color)) / 255;
return darkness < 0.4;
}

public static int buttonTextColor(@ColorInt int color) {
static int buttonTextColor(@ColorInt int color) {
if (isColorLight(color))
return Color.BLACK;
else return Color.WHITE;
}

public static int getThemeAccentColor(Context context) {
static int getThemeAccentColor(Context context) {
int colorAttr;
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
colorAttr = android.R.attr.colorAccent;
Expand All @@ -54,7 +54,7 @@ public static int getThemeAccentColor(Context context) {
return outValue.data;
}

public static void setButton(Context context, @ColorInt int color, Button button, boolean colored) {
static void setButton(Context context, @ColorInt int color, Button button, boolean colored) {
if (!colored)
color = Color.parseColor("#ffffff");

Expand All @@ -74,8 +74,7 @@ public static void setButton(Context context, @ColorInt int color, Button button
button.setBackgroundDrawable(button1bg);
}

public static int dpToPx(int dp)
{
private static int dpToPx(int dp) {
return (int) (dp * Resources.getSystem().getDisplayMetrics().density);
}
}

0 comments on commit 6f8e8a8

Please sign in to comment.