diff options
author | Stefan Niedermann <info@niedermann.it> | 2022-11-04 13:46:54 +0300 |
---|---|---|
committer | Stefan Niedermann <info@niedermann.it> | 2022-11-12 11:02:24 +0300 |
commit | 35a378b845ba8d9f6cd3b752701fcb06a35e1633 (patch) | |
tree | 1aaaeb817a63a86ae1791fb1d3c6ee5f5aa67ec4 /app/src/main/java/it/niedermann/owncloud/notes/branding/BrandingUtil.java | |
parent | 20bb9481300d02baf9e7f286717e2ce6b3140d90 (diff) |
Material 3: Navbar highlighting, TextInputLayouts in dialogs, Buttons
Signed-off-by: Stefan Niedermann <info@niedermann.it>
Diffstat (limited to 'app/src/main/java/it/niedermann/owncloud/notes/branding/BrandingUtil.java')
-rw-r--r-- | app/src/main/java/it/niedermann/owncloud/notes/branding/BrandingUtil.java | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/app/src/main/java/it/niedermann/owncloud/notes/branding/BrandingUtil.java b/app/src/main/java/it/niedermann/owncloud/notes/branding/BrandingUtil.java index 44b34eb7..2de58640 100644 --- a/app/src/main/java/it/niedermann/owncloud/notes/branding/BrandingUtil.java +++ b/app/src/main/java/it/niedermann/owncloud/notes/branding/BrandingUtil.java @@ -28,6 +28,9 @@ import it.niedermann.owncloud.notes.NotesApplication; import it.niedermann.owncloud.notes.R; import static it.niedermann.owncloud.notes.shared.util.NotesColorUtil.contrastRatioIsSufficient; +import static it.niedermann.owncloud.notes.shared.util.NotesColorUtil.contrastRatioIsSufficientBigAreas; + +import com.google.android.material.textfield.TextInputLayout; public class BrandingUtil { @@ -146,6 +149,17 @@ public class BrandingUtil { )); } + public static void applyBrandToEditTextInputLayout(@ColorInt int color, @NonNull TextInputLayout til) { + final int colorPrimary = ContextCompat.getColor(til.getContext(), R.color.primary); + final int colorAccent = ContextCompat.getColor(til.getContext(), R.color.accent); + final var colorDanger = ColorStateList.valueOf(ContextCompat.getColor(til.getContext(), R.color.danger)); + til.setBoxStrokeColor(contrastRatioIsSufficientBigAreas(color, colorPrimary) ? color : colorAccent); + til.setHintTextColor(ColorStateList.valueOf(contrastRatioIsSufficient(color, colorPrimary) ? color : colorAccent)); + til.setErrorTextColor(colorDanger); + til.setBoxStrokeErrorColor(colorDanger); + til.setErrorIconTintList(colorDanger); + } + public static void tintMenuIcon(@NonNull MenuItem menuItem, @ColorInt int color) { var drawable = menuItem.getIcon(); if (drawable != null) { |