Skip to content

Commit

Permalink
Modified Theme class;
Browse files Browse the repository at this point in the history
Modified new toARGB method so it now only converts hexadecimal into int
by receiving only ARGB hexadecimal int color;
Renamed initToColor methods to update the changes made in new toARGB.
  • Loading branch information
rafaisen committed Jun 19, 2019
1 parent 4716a32 commit 85ab487
Showing 1 changed file with 14 additions and 26 deletions.
40 changes: 14 additions & 26 deletions droidar/src/main/java/gui/simpleUI/Theme.java
Original file line number Diff line number Diff line change
Expand Up @@ -190,28 +190,16 @@ public static int toARGB(int alpha, int red, int green, int blue) {
* for more info:
* https://developer.android.com/reference/android/graphics/Color.html#parseColor(java.lang.String)
*
* @param color hexadecimal String color value - #RRGGBB/#AARRGGBB
* @return the calculated rgb/argb value
* @param color hexadecimal String color value - 0xAARRGGBB
* @return the calculated argb value
*/
public static int toARGB(String color) {
int result;
if (color.length() == 7) {
result = toARGB(
DEFAULT_ALPHA,
Integer.valueOf(color.substring(1, 3), 16),
Integer.valueOf(color.substring(3, 5), 16),
Integer.valueOf(color.substring(5, 7), 16)
);
} else {
result = toARGB(
Integer.valueOf(color.substring(1, 3), 16),
Integer.valueOf(color.substring(3, 5), 16),
Integer.valueOf(color.substring(5, 7), 16),
Integer.valueOf(color.substring(7, 9), 16)
);

}
return result;
public static int toARGB(int color) {
return android.graphics.Color.argb(
(color >> 24) & 0xff,
(color >> 16) & 0xff,
(color >> 8) & 0xff,
(color) & 0xff
);
}

private static int[] initGradientGray() {
Expand All @@ -232,17 +220,17 @@ private static int[] initGradientGray2() {
return c;
}

public static Theme.ThemeColors initToColor(String boxColor1, String boxColor2,
String shadowColor, String textColor) {
public static Theme.ThemeColors initToHexColor(int boxColor1, int boxColor2,
int shadowColor, int textColor) {
int boxColor1Value = toARGB(boxColor1);
int boxColor2Value = toARGB(boxColor2);
int shadowColorValue = toARGB(shadowColor);
int textColorValue = toARGB(textColor);
return initToColor(boxColor1Value, boxColor2Value, shadowColorValue, textColorValue);
return initARGBToColor(boxColor1Value, boxColor2Value, shadowColorValue, textColorValue);
}

public static Theme.ThemeColors initToColor(int boxColor1, int boxColor2,
int shadowColor, int textColor) {
public static Theme.ThemeColors initARGBToColor(int boxColor1, int boxColor2,
int shadowColor, int textColor) {
Theme.ThemeColors c = new ThemeColors();
int[] colorArray = new int[2];
colorArray[0] = boxColor1;
Expand Down

0 comments on commit 85ab487

Please sign in to comment.