It will automatically generate the tint color also. 70 | * 71 | * @param accentColor The accent color to be set. 72 | * 73 | * @return The {@link T} object to allow for chaining of calls to set methods. 74 | * 75 | * @see #setAccentColor(int, boolean) 76 | * @see #setTintAccentColor(int) 77 | */ 78 | @NonNull T setAccentColor(@ColorInt int accentColor); 79 | 80 | /** 81 | * Returns the dark accent color used by this theme. 82 | * 83 | * @param resolve {@code true} to resolve the auto color. 84 | * @param inverse {@code true} to resolve the inverse color. 85 | * 86 | * @return The dark accent color used by this theme. 87 | */ 88 | @ColorInt int getAccentColorDark(boolean resolve, boolean inverse); 89 | 90 | /** 91 | * Returns the dark accent color used by this theme. 92 | * 93 | * @param resolve {@code true} to resolve the auto color. 94 | * 95 | * @return The dark accent color used by this theme. 96 | */ 97 | @ColorInt int getAccentColorDark(boolean resolve); 98 | 99 | /** 100 | * Returns the dark accent color used by this theme. 101 | * 102 | * @return The dark accent color used by this theme. 103 | */ 104 | @ColorInt int getAccentColorDark(); 105 | 106 | /** 107 | * Set the dark accent color used by this theme. 108 | * 109 | * @param accentColorDark The dark accent color to be set. 110 | * @param generateTint {@code true} to automatically generate the tint color also. 111 | * 112 | * @return The {@link T} object to allow for chaining of calls to set methods. 113 | * 114 | * @see #setTintAccentColorDark(int) 115 | */ 116 | @NonNull T setAccentColorDark(@ColorInt int accentColorDark, boolean generateTint); 117 | 118 | /** 119 | * Set the dark accent color used by this theme. 120 | *
It will automatically generate the tint color also.
121 | *
122 | * @param accentColorDark The dark accent color to be set.
123 | *
124 | * @return The {@link T} object to allow for chaining of calls to set methods.
125 | *
126 | * @see #setAccentColorDark(int, boolean)
127 | * @see #setTintAccentColorDark(int)
128 | */
129 | @NonNull T setAccentColorDark(@ColorInt int accentColorDark);
130 |
131 | /**
132 | * Returns the accent tint color used by this theme.
133 | *
134 | * @param resolve {@code true} to resolve the auto color.
135 | * @param inverse {@code true} to resolve the inverse color.
136 | *
137 | * @return The accent tint color used by this theme.
138 | */
139 | @ColorInt int getTintAccentColor(boolean resolve, boolean inverse);
140 |
141 | /**
142 | * Returns the accent tint color used by this theme.
143 | *
144 | * @param resolve {@code true} to resolve the auto color.
145 | *
146 | * @return The accent tint color used by this theme.
147 | */
148 | @ColorInt int getTintAccentColor(boolean resolve);
149 |
150 | /**
151 | * Returns the accent tint color used by this theme.
152 | *
153 | * @return The accent tint color used by this theme.
154 | */
155 | @ColorInt int getTintAccentColor();
156 |
157 | /**
158 | * Set the accent tint color used by this theme.
159 | *
160 | * @param tintAccentColor The accent tint color to be set.
161 | *
162 | * @return The {@link T} object to allow for chaining of calls to set methods.
163 | */
164 | @NonNull T setTintAccentColor(@ColorInt int tintAccentColor);
165 |
166 | /**
167 | * Returns the dark accent tint color used by this theme.
168 | *
169 | * @param resolve {@code true} to resolve the auto color.
170 | * @param inverse {@code true} to resolve the inverse color.
171 | *
172 | * @return The dark accent tint color used by this theme.
173 | */
174 | @ColorInt int getTintAccentColorDark(boolean resolve, boolean inverse);
175 |
176 | /**
177 | * Returns the dark accent tint color used by this theme.
178 | *
179 | * @param resolve {@code true} to resolve the auto color.
180 | *
181 | * @return The dark accent tint color used by this theme.
182 | */
183 | @ColorInt int getTintAccentColorDark(boolean resolve);
184 |
185 | /**
186 | * Returns the dark accent tint color used by this theme.
187 | *
188 | * @return The dark accent tint color used by this theme.
189 | */
190 | @ColorInt int getTintAccentColorDark();
191 |
192 | /**
193 | * Set the dark accent tint color used by this theme.
194 | *
195 | * @param tintAccentColorDark The dark accent tint color to be set.
196 | *
197 | * @return The {@link T} object to allow for chaining of calls to set methods.
198 | */
199 | @NonNull T setTintAccentColorDark(@ColorInt int tintAccentColorDark);
200 | }
201 |
--------------------------------------------------------------------------------
/dynamic-theme/src/main/java/com/pranavpandey/android/dynamic/theme/base/AutoTheme.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2019-2022 Pranav Pandey
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package com.pranavpandey.android.dynamic.theme.base;
18 |
19 | import androidx.annotation.NonNull;
20 |
21 | /**
22 | * A {@link BaseTheme} to implement the auto theme.
23 | *
24 | * @param It will automatically generate the tint color also.
70 | *
71 | * @param backgroundColor The background color to be set.
72 | *
73 | * @return The {@link T} object to allow for chaining of calls to set methods.
74 | *
75 | * @see #setBackgroundColor(int, boolean)
76 | * @see #setTintBackgroundColor(int)
77 | */
78 | @NonNull T setBackgroundColor(@ColorInt int backgroundColor);
79 |
80 | /**
81 | * Returns the background tint color used by this theme.
82 | *
83 | * @param resolve {@code true} to resolve the auto color.
84 | * @param inverse {@code true} to resolve the inverse color.
85 | *
86 | * @return The background tint color used by this theme.
87 | */
88 | @ColorInt int getTintBackgroundColor(boolean resolve, boolean inverse);
89 |
90 | /**
91 | * Returns the background tint color used by this theme.
92 | *
93 | * @param resolve {@code true} to resolve the auto color.
94 | *
95 | * @return The background tint color used by this theme.
96 | */
97 | @ColorInt int getTintBackgroundColor(boolean resolve);
98 |
99 | /**
100 | * Returns the background tint color used by this theme.
101 | *
102 | * @return The background tint color used by this theme.
103 | */
104 | @ColorInt int getTintBackgroundColor();
105 |
106 | /**
107 | * Set the background tint color used by this theme.
108 | *
109 | * @param tintBackgroundColor The background tint color to be set.
110 | *
111 | * @return The {@link T} object to allow for chaining of calls to set methods.
112 | */
113 | @NonNull T setTintBackgroundColor(@ColorInt int tintBackgroundColor);
114 |
115 | /**
116 | * Returns {@code true} if this theme is dark.
117 | *
118 | * @return {@code true} if this theme is dark.
119 | */
120 | boolean isDarkTheme();
121 |
122 | /**
123 | * Checks whether this theme is applied in the inverse mode.
124 | *
125 | * @return {@code true} if this theme is applied in the inverse mode.
126 | */
127 | boolean isInverseTheme();
128 |
129 | /**
130 | * Returns whether to show the dividers for this theme.
131 | *
132 | * @return {@code true} to show the dividers for this theme.
133 | */
134 | boolean isShowDividers();
135 | }
136 |
--------------------------------------------------------------------------------
/dynamic-theme/src/main/java/com/pranavpandey/android/dynamic/theme/base/BaseTheme.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2019-2022 Pranav Pandey
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package com.pranavpandey.android.dynamic.theme.base;
18 |
19 | import androidx.annotation.NonNull;
20 |
21 | /**
22 | * An interface to implement the base theme.
23 | *
24 | * @param It will automatically generate the tint color also.
70 | *
71 | * @param errorColor The error color to be set.
72 | *
73 | * @return The {@link T} object to allow for chaining of calls to set methods.
74 | *
75 | * @see #setErrorColor(int, boolean)
76 | * @see #setTintErrorColor(int)
77 | */
78 | @NonNull T setErrorColor(@ColorInt int errorColor);
79 |
80 | /**
81 | * Returns the error tint color used by this theme.
82 | *
83 | * @param resolve {@code true} to resolve the auto color.
84 | * @param inverse {@code true} to resolve the inverse color.
85 | *
86 | * @return The error tint color used by this theme.
87 | */
88 | @ColorInt int getTintErrorColor(boolean resolve, boolean inverse);
89 |
90 | /**
91 | * Returns the error tint color used by this theme.
92 | *
93 | * @param resolve {@code true} to resolve the auto color.
94 | *
95 | * @return The error tint color used by this theme.
96 | */
97 | @ColorInt int getTintErrorColor(boolean resolve);
98 |
99 | /**
100 | * Returns the error tint color used by this theme.
101 | *
102 | * @return The error tint color used by this theme.
103 | */
104 | @ColorInt int getTintErrorColor();
105 |
106 | /**
107 | * Set the error tint color used by this theme.
108 | *
109 | * @param tintErrorColor The error tint color to be set.
110 | *
111 | * @return The {@link T} object to allow for chaining of calls to set methods.
112 | */
113 | @NonNull T setTintErrorColor(@ColorInt int tintErrorColor);
114 | }
115 |
--------------------------------------------------------------------------------
/dynamic-theme/src/main/java/com/pranavpandey/android/dynamic/theme/base/FallbackTheme.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2019-2022 Pranav Pandey
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package com.pranavpandey.android.dynamic.theme.base;
18 |
19 | import androidx.annotation.NonNull;
20 |
21 | /**
22 | * A {@link BaseTheme} to implement the fallback theme.
23 | *
24 | * @param It will automatically generate the tint color also.
70 | *
71 | * @param primaryColor The primary color to be set.
72 | *
73 | * @return The {@link T} object to allow for chaining of calls to set methods.
74 | *
75 | * @see #setPrimaryColor(int, boolean)
76 | * @see #setTintPrimaryColor(int)
77 | */
78 | @NonNull T setPrimaryColor(@ColorInt int primaryColor);
79 |
80 | /**
81 | * Returns the dark primary color used by this theme.
82 | *
83 | * @param resolve {@code true} to resolve the auto color.
84 | * @param inverse {@code true} to resolve the inverse color.
85 | *
86 | * @return The dark primary color used by this theme.
87 | */
88 | @ColorInt int getPrimaryColorDark(boolean resolve, boolean inverse);
89 |
90 | /**
91 | * Returns the dark primary color used by this theme.
92 | *
93 | * @param resolve {@code true} to resolve the auto color.
94 | *
95 | * @return The dark primary color used by this theme.
96 | */
97 | @ColorInt int getPrimaryColorDark(boolean resolve);
98 |
99 | /**
100 | * Returns the dark primary color used by this theme.
101 | *
102 | * @return The dark primary color used by this theme.
103 | */
104 | @ColorInt int getPrimaryColorDark();
105 |
106 | /**
107 | * Set the dark primary color used by this theme.
108 | *
109 | * @param primaryColorDark The dark primary color to be set.
110 | * @param generateTint {@code true} to automatically generate the tint color also.
111 | *
112 | * @return The {@link T} object to allow for chaining of calls to set methods.
113 | *
114 | * @see #setTintPrimaryColorDark(int)
115 | */
116 | @NonNull T setPrimaryColorDark(@ColorInt int primaryColorDark, boolean generateTint);
117 |
118 | /**
119 | * Set the dark primary color used by this theme.
120 | * It will automatically generate the tint color also.
121 | *
122 | * @param primaryColorDark The dark primary color to be set.
123 | *
124 | * @return The {@link T} object to allow for chaining of calls to set methods.
125 | *
126 | * @see #setPrimaryColorDark(int, boolean)
127 | * @see #setTintPrimaryColorDark(int)
128 | */
129 | @NonNull T setPrimaryColorDark(@ColorInt int primaryColorDark);
130 |
131 | /**
132 | * Returns the primary tint color used by this theme.
133 | *
134 | * @param resolve {@code true} to resolve the auto color.
135 | * @param inverse {@code true} to resolve the inverse color.
136 | *
137 | * @return The primary tint color used by this theme.
138 | */
139 | @ColorInt int getTintPrimaryColor(boolean resolve, boolean inverse);
140 |
141 | /**
142 | * Returns the primary tint color used by this theme.
143 | *
144 | * @param resolve {@code true} to resolve the auto color.
145 | *
146 | * @return The primary tint color used by this theme.
147 | */
148 | @ColorInt int getTintPrimaryColor(boolean resolve);
149 |
150 | /**
151 | * Returns the primary tint color used by this theme.
152 | *
153 | * @return The primary tint color used by this theme.
154 | */
155 | @ColorInt int getTintPrimaryColor();
156 |
157 | /**
158 | * Set the primary tint color used by this theme.
159 | *
160 | * @param tintPrimaryColor The primary tint color to be set.
161 | *
162 | * @return The {@link T} object to allow for chaining of calls to set methods.
163 | */
164 | @NonNull T setTintPrimaryColor(@ColorInt int tintPrimaryColor);
165 |
166 | /**
167 | * Returns the dark primary tint color used by this theme.
168 | *
169 | * @param resolve {@code true} to resolve the auto color.
170 | * @param inverse {@code true} to resolve the inverse color.
171 | *
172 | * @return The dark primary tint color used by this theme.
173 | */
174 | @ColorInt int getTintPrimaryColorDark(boolean resolve, boolean inverse);
175 |
176 | /**
177 | * Returns the dark primary tint color used by this theme.
178 | *
179 | * @param resolve {@code true} to resolve the auto color.
180 | *
181 | * @return The dark primary tint color used by this theme.
182 | */
183 | @ColorInt int getTintPrimaryColorDark(boolean resolve);
184 |
185 | /**
186 | * Returns the dark primary tint color used by this theme.
187 | *
188 | * @return The dark primary tint color used by this theme.
189 | */
190 | @ColorInt int getTintPrimaryColorDark();
191 |
192 | /**
193 | * Set the dark primary tint color used by this theme.
194 | *
195 | * @param tintPrimaryColorDark The dark primary tint color to be set.
196 | *
197 | * @return The {@link T} object to allow for chaining of calls to set methods.
198 | */
199 | @NonNull T setTintPrimaryColorDark(@ColorInt int tintPrimaryColorDark);
200 | }
201 |
--------------------------------------------------------------------------------
/dynamic-theme/src/main/java/com/pranavpandey/android/dynamic/theme/base/ResourceTheme.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2019-2022 Pranav Pandey
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package com.pranavpandey.android.dynamic.theme.base;
18 |
19 | import androidx.annotation.NonNull;
20 | import androidx.annotation.StyleRes;
21 |
22 | /**
23 | * A {@link BaseTheme} to implement the resource theme.
24 | *
25 | * @param It will automatically generate the tint color also.
70 | *
71 | * @param surfaceColor The surface color to be set.
72 | *
73 | * @return The {@link T} object to allow for chaining of calls to set methods.
74 | *
75 | * @see #setSurfaceColor(int, boolean)
76 | * @see #setTintSurfaceColor(int)
77 | */
78 | @NonNull T setSurfaceColor(@ColorInt int surfaceColor);
79 |
80 | /**
81 | * Returns the surface tint color used by this theme.
82 | *
83 | * @param resolve {@code true} to resolve the auto color.
84 | * @param inverse {@code true} to resolve the inverse color.
85 | *
86 | * @return The surface tint color used by this theme.
87 | */
88 | @ColorInt int getTintSurfaceColor(boolean resolve, boolean inverse);
89 |
90 | /**
91 | * Returns the surface tint color used by this theme.
92 | *
93 | * @param resolve {@code true} to resolve the auto color.
94 | *
95 | * @return The surface tint color used by this theme.
96 | */
97 | @ColorInt int getTintSurfaceColor(boolean resolve);
98 |
99 | /**
100 | * Returns the surface tint color used by this theme.
101 | *
102 | * @return The surface tint color used by this theme.
103 | */
104 | @ColorInt int getTintSurfaceColor();
105 |
106 | /**
107 | * Set the surface tint color used by this theme.
108 | *
109 | * @param tintSurfaceColor The surface tint color to be set.
110 | *
111 | * @return The {@link T} object to allow for chaining of calls to set methods.
112 | */
113 | @NonNull T setTintSurfaceColor(@ColorInt int tintSurfaceColor);
114 |
115 | /**
116 | * Checks whether the background should be used as the surface.
117 | *
118 | * @return {@code true} if the background should be used as surface.
119 | */
120 | boolean isBackgroundSurface();
121 | }
122 |
--------------------------------------------------------------------------------
/dynamic-theme/src/main/java/com/pranavpandey/android/dynamic/theme/base/TextTheme.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2019-2022 Pranav Pandey
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package com.pranavpandey.android.dynamic.theme.base;
18 |
19 | import androidx.annotation.ColorInt;
20 | import androidx.annotation.NonNull;
21 |
22 | /**
23 | * A {@link BaseTheme} to implement the text theme.
24 | *
25 | * @param It will automatically generate the inverse color also.
70 | *
71 | * @param textPrimaryColor The primary text color to be set.
72 | *
73 | * @return The {@link T} object to allow for chaining of calls to set methods.
74 | *
75 | * @see #setTextPrimaryColor(int, boolean)
76 | * @see #setTextPrimaryColorInverse(int)
77 | */
78 | @NonNull T setTextPrimaryColor(@ColorInt int textPrimaryColor);
79 |
80 | /**
81 | * Returns the secondary text color used by this theme.
82 | *
83 | * @param resolve {@code true} to resolve the auto color.
84 | * @param inverse {@code true} to resolve the inverse color.
85 | *
86 | * @return The secondary text color used by this theme.
87 | */
88 | @ColorInt int getTextSecondaryColor(boolean resolve, boolean inverse);
89 |
90 | /**
91 | * Returns the secondary text color used by this theme.
92 | *
93 | * @param resolve {@code true} to resolve the auto color.
94 | *
95 | * @return The secondary text color used by this theme.
96 | */
97 | @ColorInt int getTextSecondaryColor(boolean resolve);
98 |
99 | /**
100 | * Returns the secondary text color used by this theme.
101 | *
102 | * @return The secondary text color used by this theme.
103 | */
104 | @ColorInt int getTextSecondaryColor();
105 |
106 | /**
107 | * Set the secondary text color used by this theme.
108 | *
109 | * @param textSecondaryColor The secondary text color to be set.
110 | * @param generateInverse {@code true} to automatically generate the inverse color also.
111 | *
112 | * @return The {@link T} object to allow for chaining of calls to set methods.
113 | *
114 | * @see #setTextSecondaryColorInverse(int)
115 | */
116 | @NonNull T setTextSecondaryColor(@ColorInt int textSecondaryColor, boolean generateInverse);
117 |
118 | /**
119 | * Set the secondary text color used by this theme.
120 | * It will automatically generate the inverse color also.
121 | *
122 | * @param textSecondaryColor The secondary text color to be set.
123 | *
124 | * @return The {@link T} object to allow for chaining of calls to set methods.
125 | *
126 | * @see #setTextSecondaryColor(int, boolean)
127 | * @see #setTextSecondaryColorInverse(int)
128 | */
129 | @NonNull T setTextSecondaryColor(@ColorInt int textSecondaryColor);
130 |
131 | /**
132 | * Returns the inverse color for the primary text color.
133 | *
134 | * @param resolve {@code true} to resolve the auto color.
135 | * @param inverse {@code true} to resolve the inverse color.
136 | *
137 | * @return The inverse color for the primary text color.
138 | */
139 | @ColorInt int getTextPrimaryColorInverse(boolean resolve, boolean inverse);
140 |
141 | /**
142 | * Returns the inverse color for the primary text color.
143 | *
144 | * @param resolve {@code true} to resolve the auto color.
145 | *
146 | * @return The inverse color for the primary text color.
147 | */
148 | @ColorInt int getTextPrimaryColorInverse(boolean resolve);
149 |
150 | /**
151 | * Returns the inverse color for the primary text color.
152 | *
153 | * @return The inverse color for the primary text color.
154 | */
155 | @ColorInt int getTextPrimaryColorInverse();
156 |
157 | /**
158 | * Set the primary text inverse color used by this theme.
159 | *
160 | * @param textPrimaryColorInverse The primary text inverse color to be set.
161 | *
162 | * @return The {@link T} object to allow for chaining of calls to set methods.
163 | */
164 | @NonNull T setTextPrimaryColorInverse(int textPrimaryColorInverse);
165 |
166 | /**
167 | * Returns the inverse color for the secondary text color.
168 | *
169 | * @param resolve {@code true} to resolve the auto color.
170 | * @param inverse {@code true} to resolve the inverse color.
171 | *
172 | * @return The inverse color for the secondary text color.
173 | */
174 | @ColorInt int getTextSecondaryColorInverse(boolean resolve, boolean inverse);
175 |
176 | /**
177 | * Returns the inverse color for the secondary text color.
178 | *
179 | * @param resolve {@code true} to resolve the auto color.
180 | *
181 | * @return The inverse color for the secondary text color.
182 | */
183 | @ColorInt int getTextSecondaryColorInverse(boolean resolve);
184 |
185 | /**
186 | * Returns the inverse color for the secondary text color.
187 | *
188 | * @return The inverse color for the secondary text color.
189 | */
190 | @ColorInt int getTextSecondaryColorInverse();
191 |
192 | /**
193 | * Set the secondary text inverse color used by this theme.
194 | *
195 | * @param textSecondaryColorInverse The secondary text inverse color to be set.
196 | *
197 | * @return The {@link T} object to allow for chaining of calls to set methods.
198 | */
199 | @NonNull T setTextSecondaryColorInverse(int textSecondaryColorInverse);
200 |
201 | /**
202 | * Returns the highlight color for this theme.
203 | *
204 | * @param contrastWithColor The contrast with color to be used.
205 | *
206 | * @return The highlight color for this theme.
207 | */
208 | @ColorInt int getHighlightColor(@ColorInt int contrastWithColor);
209 |
210 | /**
211 | * Returns the highlight color for this theme.
212 | *
213 | * @return The highlight color for this theme.
214 | */
215 | @ColorInt int getHighlightColor();
216 |
217 | /**
218 | * Returns the font scaling factor used by this theme.
219 | *
220 | * @param resolve {@code true} to resolve the auto font scale.
221 | *
222 | * @return The font scaling factor (in percent) used by this theme.
223 | */
224 | int getFontScale(boolean resolve);
225 |
226 | /**
227 | * Returns the font scaling factor used by this theme.
228 | *
229 | * @return The font scaling factor (in percent) used by this theme.
230 | */
231 | int getFontScale();
232 |
233 | /**
234 | * Returns the relative font scale after dividing it by 100.
235 | *
236 | * @return The relative font scale after dividing it by 100.
237 | */
238 | float getFontScaleRelative();
239 |
240 | /**
241 | * Set the font scaling factor used by this theme.
242 | *
243 | * @param fontScale The font scaling factor (in percent) to be set.
244 | *
245 | * @return The {@link T} object to allow for chaining of calls to set methods.
246 | */
247 | @NonNull T setFontScale(int fontScale);
248 |
249 | /**
250 | * Checks whether the custom font scale is set.
251 | *
252 | * @return {@code true} if the custom font scale is set.
253 | */
254 | boolean isFontScale();
255 | }
256 |
--------------------------------------------------------------------------------
/dynamic-theme/src/main/java/com/pranavpandey/android/dynamic/theme/base/TranslucentTheme.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2019-2022 Pranav Pandey
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package com.pranavpandey.android.dynamic.theme.base;
18 |
19 | import androidx.annotation.NonNull;
20 |
21 | /**
22 | * A {@link BaseTheme} to implement the translucent theme.
23 | *
24 | * @param Extend this broadcast receiver and declare it in the project's manifest to
33 | * receive the theme data.
34 | */
35 | public abstract class DynamicThemeReceiver extends BroadcastReceiver {
36 |
37 | @Override
38 | public void onReceive(final @NonNull Context context, @Nullable Intent intent) {
39 | if (intent == null) {
40 | return;
41 | }
42 |
43 | if (Theme.Intent.ACTION.equals(intent.getAction())) {
44 | if (intent.hasExtra(Theme.Intent.EXTRA_THEME)
45 | || intent.hasExtra(Theme.Intent.EXTRA_DATA)) {
46 | onReceiveTheme(intent.getStringExtra(Theme.Intent.EXTRA_THEME),
47 | intent.getStringExtra(Theme.Intent.EXTRA_VALUE),
48 | intent.getStringExtra(Theme.Intent.EXTRA_DATA));
49 | }
50 | } else if (Theme.Intent.ACTION_APP_WIDGET.equals(intent.getAction())
51 | || intent.hasExtra(AppWidgetManager.EXTRA_APPWIDGET_ID)) {
52 | int appWidgetId = intent.getIntExtra(AppWidgetManager.EXTRA_APPWIDGET_ID,
53 | AppWidgetManager.INVALID_APPWIDGET_ID);
54 |
55 | if (appWidgetId != AppWidgetManager.INVALID_APPWIDGET_ID) {
56 | onAppWidget(appWidgetId, intent.getStringExtra(Theme.Intent.EXTRA_PREFS),
57 | intent.getStringExtra(Theme.Intent.EXTRA_THEME));
58 | }
59 | }
60 | }
61 |
62 | /**
63 | * This method will be called when a theme data is received by this receiver.
64 | *
65 | * @param theme The theme received by the receiver.
66 | * @param value The theme value received by the receiver.
67 | * @param data The theme data received by the receiver.
68 | */
69 | protected abstract void onReceiveTheme(@Nullable @Theme.ToString String theme,
70 | @Nullable @Theme.ToString String value, @Nullable String data);
71 |
72 | /**
73 | * This method will be called when an app widget is added via pinning.
74 | *
75 | * @param appWidgetId The generated app widget id.
76 | * @param prefs The received shared preferences name.
77 | * @param theme The received widget theme or settings.
78 | */
79 | protected void onAppWidget(int appWidgetId,
80 | @Nullable String prefs, @Nullable String theme) { }
81 | }
82 |
--------------------------------------------------------------------------------
/dynamic-theme/src/main/java/com/pranavpandey/android/dynamic/theme/strategy/ExcludeStrategy.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2019-2022 Pranav Pandey
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package com.pranavpandey.android.dynamic.theme.strategy;
18 |
19 | import com.google.gson.ExclusionStrategy;
20 | import com.google.gson.FieldAttributes;
21 | import com.pranavpandey.android.dynamic.theme.annotation.Exclude;
22 |
23 | /**
24 | * A {@link com.google.gson.Gson} exclusion strategy to exclude the field from the JSON string.
25 | */
26 | public class ExcludeStrategy implements ExclusionStrategy {
27 |
28 | @Override
29 | public boolean shouldSkipField(FieldAttributes f) {
30 | return f.getAnnotation(Exclude.class) != null;
31 | }
32 |
33 | @Override
34 | public boolean shouldSkipClass(Class> clazz) {
35 | return false;
36 | }
37 | }
38 |
--------------------------------------------------------------------------------
/dynamic-theme/src/main/res/drawable-anydpi-v23/adt_ic_palette.xml:
--------------------------------------------------------------------------------
1 |
2 |
17 |
18 |