Skip to content

Commit be9ccaa

Browse files
author
Jorge Antonio Diaz-Benito Soriano
committed
Color the navigation button icons
1 parent d3f6d76 commit be9ccaa

15 files changed

+59
-29
lines changed

presentation/src/main/java/com/jorge/boats/xkcd/navigation/NavigationLinearLayout.java

+16-1
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,13 @@
66
import android.content.Context;
77
import android.content.res.Configuration;
88
import android.content.res.Resources;
9+
import android.graphics.PorterDuff;
10+
import android.support.annotation.ColorInt;
911
import android.support.annotation.IntDef;
1012
import android.support.annotation.NonNull;
1113
import android.support.annotation.Nullable;
14+
import android.support.design.widget.FloatingActionButton;
15+
import android.support.v4.content.ContextCompat;
1216
import android.util.AttributeSet;
1317
import android.util.DisplayMetrics;
1418
import android.view.LayoutInflater;
@@ -20,6 +24,7 @@
2024

2125
import com.jorge.boats.xkcd.R;
2226
import com.jorge.boats.xkcd.presenter.StripePresenter;
27+
import com.jorge.boats.xkcd.util.ThemeUtil;
2328

2429
import butterknife.Bind;
2530
import butterknife.ButterKnife;
@@ -28,7 +33,7 @@
2833
public class NavigationLinearLayout extends LinearLayout {
2934

3035
@Bind({ R.id.fab_index_zero, R.id.fab_index_one, R.id.fab_index_two })
31-
View[] mButtons;
36+
FloatingActionButton[] mButtons;
3237

3338
private boolean isExpanded = false;
3439

@@ -48,6 +53,16 @@ private void init(final @NonNull Context context) {
4853
}
4954

5055
ButterKnife.bind(this);
56+
tintButtonIcons();
57+
}
58+
59+
private void tintButtonIcons() {
60+
final @ColorInt int colorAccent = ContextCompat.getColor(getContext(),
61+
ThemeUtil.getAppColor(getContext()));
62+
63+
for (final FloatingActionButton button : mButtons) {
64+
button.getDrawable().setColorFilter(colorAccent, PorterDuff.Mode.SRC_IN);
65+
}
5166
}
5267

5368
public boolean isExpanded() {

presentation/src/main/java/com/jorge/boats/xkcd/util/ThemeUtil.java

+36-15
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package com.jorge.boats.xkcd.util;
22

33
import android.content.Context;
4+
import android.support.annotation.ColorRes;
45
import android.support.annotation.NonNull;
56
import android.support.annotation.StyleRes;
67

@@ -50,21 +51,21 @@ public static int getSettingsTheme(final @NonNull Context context) {
5051
.theme_4_name), theme5Name = context.getString(R.string.theme_5_name);
5152

5253
if ((themeName = P.themeName.get()).contentEquals(theme0Name)) {
53-
return R.style.SettingsStandard;
54-
} else if (themeName.contentEquals(theme1Name)) {
55-
return R.style.SettingsNegative;
56-
} else if (themeName.contentEquals(theme2Name)) {
57-
return R.style.SettingsWeb;
58-
} else if (themeName.contentEquals(theme3Name)) {
59-
return R.style.SettingsWarm;
60-
} else if (themeName.contentEquals(theme4Name)) {
61-
return R.style.SettingsMaterialLight;
62-
} else if (themeName.contentEquals(theme5Name)) {
63-
return R.style.SettingsMaterialDark;
64-
} else {
65-
throw new IllegalStateException(
66-
String.format(Locale.ENGLISH, "Unrecognized theme name %s", themeName));
67-
}
54+
return R.style.SettingsStandard;
55+
} else if (themeName.contentEquals(theme1Name)) {
56+
return R.style.SettingsNegative;
57+
} else if (themeName.contentEquals(theme2Name)) {
58+
return R.style.SettingsWeb;
59+
} else if (themeName.contentEquals(theme3Name)) {
60+
return R.style.SettingsWarm;
61+
} else if (themeName.contentEquals(theme4Name)) {
62+
return R.style.SettingsMaterialLight;
63+
} else if (themeName.contentEquals(theme5Name)) {
64+
return R.style.SettingsMaterialDark;
65+
} else {
66+
throw new IllegalStateException(
67+
String.format(Locale.ENGLISH, "Unrecognized theme name %s", themeName));
68+
}
6869
}
6970

7071
public static boolean isAppThemeLight(final @NonNull Context context) {
@@ -79,4 +80,24 @@ public static boolean isAppThemeLight(final @NonNull Context context) {
7980
public static boolean isSettingsThemeDark(final @NonNull Context context) {
8081
return !isAppThemeLight(context);
8182
}
83+
84+
@ColorRes
85+
public static int getAppColor(@NonNull final Context context) {
86+
switch(getAppTheme(context)) {
87+
case R.style.AppStandard:
88+
return R.color.standard_primary_light;
89+
case R.style.AppWeb:
90+
return R.color.web_primary_light;
91+
case R.style.AppWarm:
92+
return R.color.warm_primary_light;
93+
case R.style.AppNegative:
94+
return R.color.negative_primary_light;
95+
case R.style.AppMaterialLight:
96+
return R.color.material_light_primary_light;
97+
case R.style.AppMaterialDark:
98+
return R.color.material_dark_primary_light;
99+
default:
100+
throw new IllegalStateException("Theme not recognized.");
101+
}
102+
}
82103
}

presentation/src/main/res/layout/widget_navigation_layout.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -78,4 +78,4 @@
7878
app:borderWidth="0dp"
7979
app:fabSize="normal"/>
8080
</RelativeLayout>
81-
</merge>
81+
</merge>

presentation/src/main/res/values/colors-material-dark.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<resources>
33
<color name="material_dark_primary">#000000</color>
4-
<color name="material_dark_primary_light">#E3F2FD</color>
4+
<color name="material_dark_primary_light">#FFFFFF</color>
55
<color name="material_dark_accent">#000000</color>
66
<color name="material_dark_primary_text">#FFFFFF</color>
77
<color name="material_dark_secondary_text">#727272</color>

presentation/src/main/res/values/colors-material-light.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<resources>
33
<color name="material_light_primary">#64B5F6</color>
4-
<color name="material_light_primary_light">#E3F2FD</color>
4+
<color name="material_light_primary_light">#FFFFFF</color>
55
<color name="material_light_accent">#2196F3</color>
66
<color name="material_light_primary_text">#FFFFFF</color>
77
<color name="material_light_secondary_text">#727272</color>

presentation/src/main/res/values/colors-negative.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<resources>
33
<color name="negative_primary">#743CB5</color>
4-
<color name="negative_primary_light">#231237</color>
4+
<color name="negative_primary_light">#000000</color>
55
<color name="negative_accent">#B350AF</color>
66
<color name="negative_primary_text">#000000</color>
77
<color name="negative_secondary_text">#8D8D8D</color>

presentation/src/main/res/values/colors-standard.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<resources>
33
<color name="standard_primary">#8BC34A</color>
4-
<color name="standard_primary_light">#DCEDC8</color>
4+
<color name="standard_primary_light">#FFFFFF</color>
55
<color name="standard_accent">#4CAF50</color>
66
<color name="standard_primary_text">#FFFFFF</color>
77
<color name="standard_secondary_text">#727272</color>

presentation/src/main/res/values/colors-warm.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<resources>
33
<color name="warm_primary">#FF3C10</color>
4-
<color name="warm_primary_light">#FA9A37</color>
4+
<color name="warm_primary_light">#000000</color>
55
<color name="warm_accent">#FFDD00</color>
66
<color name="warm_primary_text">#000000</color>
77
<color name="warm_secondary_text">#8D8D8D</color>

presentation/src/main/res/values/colors-web.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<resources>
33
<color name="web_primary">#D1D1D1</color>
4-
<color name="web_primary_light">#050505</color>
4+
<color name="web_primary_light">#FFFFFF</color>
55
<color name="web_accent">#1131CF</color>
66
<color name="web_primary_text">#FFFFFF</color>
77
<color name="web_secondary_text">#656565</color>

presentation/src/main/res/values/theme-material-dark.xml

-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
<style name="AppMaterialDark" parent="Theme.AppCompat.Light.NoActionBar">
55
<item name="colorPrimary">@color/material_dark_primary</item>
66
<item name="colorAccent">@color/material_dark_accent</item>
7-
<item name="color">@color/material_dark_primary_light</item>
87
<item name="colorControlNormal">@color/material_dark_primary_text</item>
98
<item name="android:textColorPrimary">@color/material_dark_primary_text</item>
109
<item name="android:textColorSecondary">@color/material_dark_secondary_text</item>

presentation/src/main/res/values/theme-material-light.xml

-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
<style name="AppMaterialLight" parent="Theme.AppCompat.Light.NoActionBar">
55
<item name="colorPrimary">@color/material_light_primary</item>
66
<item name="colorAccent">@color/material_light_accent</item>
7-
<item name="color">@color/material_light_primary_light</item>
87
<item name="colorControlNormal">@color/material_light_primary_text</item>
98
<item name="android:textColorPrimary">@color/material_light_primary_text</item>
109
<item name="android:textColorSecondary">@color/material_light_secondary_text</item>

presentation/src/main/res/values/theme-negative.xml

-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
<style name="AppNegative" parent="Theme.AppCompat.Light.NoActionBar">
55
<item name="colorPrimary">@color/negative_primary</item>
66
<item name="colorAccent">@color/negative_accent</item>
7-
<item name="color">@color/negative_primary_light</item>
87
<item name="colorControlNormal">@color/negative_primary_text</item>
98
<item name="android:textColorPrimary">@color/negative_primary_text</item>
109
<item name="android:textColorSecondary">@color/negative_secondary_text</item>

presentation/src/main/res/values/theme-standard.xml

-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
<style name="AppStandard" parent="Theme.AppCompat.Light.NoActionBar">
55
<item name="colorPrimary">@color/standard_primary</item>
66
<item name="colorAccent">@color/standard_accent</item>
7-
<item name="color">@color/standard_primary_light</item>
87
<item name="colorControlNormal">@color/standard_primary_text</item>
98
<item name="android:textColorPrimary">@color/standard_primary_text</item>
109
<item name="android:textColorSecondary">@color/standard_secondary_text</item>

presentation/src/main/res/values/theme-warm.xml

-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
<style name="AppWarm" parent="Theme.AppCompat.Light.NoActionBar">
55
<item name="colorPrimary">@color/warm_primary</item>
66
<item name="colorAccent">@color/warm_accent</item>
7-
<item name="color">@color/warm_primary_light</item>
87
<item name="colorControlNormal">@color/warm_primary_text</item>
98
<item name="android:textColorPrimary">@color/warm_primary_text</item>
109
<item name="android:textColorSecondary">@color/warm_secondary_text</item>

presentation/src/main/res/values/theme-web.xml

-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
<style name="AppWeb" parent="Theme.AppCompat.Light.NoActionBar">
55
<item name="colorPrimary">@color/web_primary</item>
66
<item name="colorAccent">@color/web_accent</item>
7-
<item name="color">@color/web_primary_light</item>
87
<item name="colorControlNormal">@color/web_primary_text</item>
98
<item name="android:textColorPrimary">@color/web_primary_text</item>
109
<item name="android:textColorSecondary">@color/web_secondary_text</item>

0 commit comments

Comments
 (0)