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) { diff --git a/app/src/main/java/it/niedermann/owncloud/notes/edit/category/CategoryDialogFragment.java b/app/src/main/java/it/niedermann/owncloud/notes/edit/category/CategoryDialogFragment.java index 530a5549..16e0686b 100644 --- a/app/src/main/java/it/niedermann/owncloud/notes/edit/category/CategoryDialogFragment.java +++ b/app/src/main/java/it/niedermann/owncloud/notes/edit/category/CategoryDialogFragment.java @@ -49,7 +49,7 @@ public class CategoryDialogFragment extends BrandedDialogFragment { @Override public void applyBrand(int mainColor, int textColor) { - BrandingUtil.applyBrandToEditText(mainColor, textColor, binding.search); + BrandingUtil.applyBrandToEditTextInputLayout(mainColor, binding.inputWrapper); } /** diff --git a/app/src/main/java/it/niedermann/owncloud/notes/edit/title/EditTitleDialogFragment.java b/app/src/main/java/it/niedermann/owncloud/notes/edit/title/EditTitleDialogFragment.java index 4d2a770a..b4221d98 100644 --- a/app/src/main/java/it/niedermann/owncloud/notes/edit/title/EditTitleDialogFragment.java +++ b/app/src/main/java/it/niedermann/owncloud/notes/edit/title/EditTitleDialogFragment.java @@ -1,5 +1,7 @@ package it.niedermann.owncloud.notes.edit.title; +import static it.niedermann.owncloud.notes.branding.BrandingUtil.applyBrandToEditTextInputLayout; + import android.app.Dialog; import android.content.Context; import android.os.Bundle; @@ -15,9 +17,10 @@ import androidx.fragment.app.DialogFragment; import com.google.android.material.dialog.MaterialAlertDialogBuilder; import it.niedermann.owncloud.notes.R; +import it.niedermann.owncloud.notes.branding.BrandedDialogFragment; import it.niedermann.owncloud.notes.databinding.DialogEditTitleBinding; -public class EditTitleDialogFragment extends DialogFragment { +public class EditTitleDialogFragment extends BrandedDialogFragment { private static final String TAG = EditTitleDialogFragment.class.getSimpleName(); static final String PARAM_OLD_TITLE = "old_title"; @@ -83,6 +86,11 @@ public class EditTitleDialogFragment extends DialogFragment { return fragment; } + @Override + public void applyBrand(int mainColor, int textColor) { + applyBrandToEditTextInputLayout(mainColor, binding.inputWrapper); + } + /** * Interface that must be implemented by the calling Activity. */ diff --git a/app/src/main/java/it/niedermann/owncloud/notes/shared/util/NotesColorUtil.java b/app/src/main/java/it/niedermann/owncloud/notes/shared/util/NotesColorUtil.java index 035aab9a..70c5316e 100644 --- a/app/src/main/java/it/niedermann/owncloud/notes/shared/util/NotesColorUtil.java +++ b/app/src/main/java/it/niedermann/owncloud/notes/shared/util/NotesColorUtil.java @@ -28,6 +28,17 @@ public final class NotesColorUtil { return ret; } + public static boolean contrastRatioIsSufficientBigAreas(@ColorInt int colorOne, @ColorInt int colorTwo) { + final var key = new ColorPair(colorOne, colorTwo); + var ret = CONTRAST_RATIO_SUFFICIENT_CACHE.get(key); + if (ret == null) { + ret = ColorUtil.INSTANCE.getContrastRatio(colorOne, colorTwo) > 1.47d; + CONTRAST_RATIO_SUFFICIENT_CACHE.put(key, ret); + return ret; + } + return ret; + } + private static class ColorPair extends Pair { private ColorPair(@Nullable Integer first, @Nullable Integer second) { diff --git a/app/src/main/res/color/text_input_layout_color.xml b/app/src/main/res/color/text_input_layout_color.xml new file mode 100644 index 00000000..fcd5fa09 --- /dev/null +++ b/app/src/main/res/color/text_input_layout_color.xml @@ -0,0 +1,7 @@ + + + + + + + diff --git a/app/src/main/res/layout/dialog_account_switcher.xml b/app/src/main/res/layout/dialog_account_switcher.xml index 8e8634b2..965f1df8 100644 --- a/app/src/main/res/layout/dialog_account_switcher.xml +++ b/app/src/main/res/layout/dialog_account_switcher.xml @@ -6,7 +6,6 @@ android:layout_height="wrap_content" android:orientation="vertical"> - - - - - + android:labelFor="@id/search"> + + + + + + + + android:padding="@dimen/spacer_2x"> #ffffff #121212 + #d40000 #0082C9 @@ -21,7 +22,8 @@ #999999 #ffffff - #757575 + #757575 + @color/grey600 @color/bg_normal @color/defaultBrand diff --git a/app/src/main/res/values/styles.xml b/app/src/main/res/values/styles.xml index 6a09ce60..2e06afb0 100644 --- a/app/src/main/res/values/styles.xml +++ b/app/src/main/res/values/styles.xml @@ -40,6 +40,11 @@ ?attr/colorAccent + +