-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Add theming logic for share link icons #6400
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -688,15 +688,9 @@ public static String colorToHexString(int color) { | |
| public static void colorFloatingActionButton(FloatingActionButton button, @DrawableRes int drawable, | ||
| Context context) { | ||
| int primaryColor = ThemeUtils.primaryColor(null, true, false, context); | ||
| colorFloatingActionButton(button, context, primaryColor); | ||
|
|
||
| if (Color.BLACK == primaryColor) { | ||
| button.setImageDrawable(ThemeUtils.tintDrawable(drawable, Color.WHITE)); | ||
| } else if (Color.WHITE == primaryColor) { | ||
| button.setImageDrawable(ThemeUtils.tintDrawable(drawable, Color.BLACK)); | ||
| } else { | ||
| button.setImageDrawable(ThemeUtils.tintDrawable(drawable, ThemeUtils.fontColor(context, false))); | ||
| } | ||
| colorFloatingActionButton(button, context, primaryColor); | ||
| button.setImageDrawable(ThemeUtils.tintDrawable(drawable, getColorForPrimary(primaryColor, context))); | ||
| } | ||
|
|
||
| public static void colorFloatingActionButton(FloatingActionButton button, Context context) { | ||
|
|
@@ -712,6 +706,29 @@ public static void colorFloatingActionButton(FloatingActionButton button, int ba | |
| button.setRippleColor(rippleColor); | ||
| } | ||
|
|
||
| public static void colorIconImageViewWithBackground(ImageView imageView, Context context) { | ||
| int primaryColor = ThemeUtils.primaryColor(null, true, false, context); | ||
|
|
||
| imageView.getBackground().setColorFilter(primaryColor, PorterDuff.Mode.SRC_IN); | ||
| imageView.getDrawable().mutate().setColorFilter(getColorForPrimary(primaryColor, context), | ||
| PorterDuff.Mode.SRC_IN); | ||
| } | ||
|
|
||
| /** | ||
| * returns a primary color matching color for texts/icons on top of a primary-colored element (like buttons). | ||
| * | ||
| * @param primaryColor the primary color | ||
| */ | ||
| private static int getColorForPrimary(int primaryColor, Context context) { | ||
| if (Color.BLACK == primaryColor) { | ||
| return Color.WHITE; | ||
| } else if (Color.WHITE == primaryColor) { | ||
| return Color.BLACK; | ||
| } else { | ||
| return ThemeUtils.fontColor(context, false); | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Isn't this also a good idea to have this computed on server? font-color-light and font-color dark?
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Don't know, but @nickvergessen might be able to shed some light on the font-color calculations. I'd hope that with a fallback-ing background color working for dark/light the text-color of a button doesn't have any contrast issues anymore. So we would rather have to discuss if primary button texts would have to be white/black or if we just use white in both theme variants. So also pinging @jancborchardt about this. ATM we don't have text-color variant from the server (also with element-color reference)
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fine for me to have this in next PR 👍 |
||
| } | ||
| } | ||
|
|
||
| private static OCCapability getCapability(Context context) { | ||
| return getCapability(null, context); | ||
| } | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this obeying dark mode?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not at this very moment, we just do this based on the primary color for edge cases and else use the server's text-color value. See also my other comment.