Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/stefan-niedermann/nextcloud-notes.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
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.java14
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) {