diff options
author | Stefan Niedermann <info@niedermann.it> | 2020-07-06 16:18:14 +0300 |
---|---|---|
committer | Stefan Niedermann <info@niedermann.it> | 2020-07-06 16:18:14 +0300 |
commit | 04a3ce1690bf5e6ac065658830a6a47e3ccb15f3 (patch) | |
tree | 65eeac100719109d5f37bea2885bebb26339e693 /app/src/main/java/it/niedermann/nextcloud/deck/ui/filter/FilterDialogFragment.java | |
parent | 4830657f4b2d32f494645c40cb293ce0afbfe7b7 (diff) |
Enhanced branding for filter tabs
Diffstat (limited to 'app/src/main/java/it/niedermann/nextcloud/deck/ui/filter/FilterDialogFragment.java')
-rw-r--r-- | app/src/main/java/it/niedermann/nextcloud/deck/ui/filter/FilterDialogFragment.java | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/app/src/main/java/it/niedermann/nextcloud/deck/ui/filter/FilterDialogFragment.java b/app/src/main/java/it/niedermann/nextcloud/deck/ui/filter/FilterDialogFragment.java index aa6f59d04..b6a0c17a4 100644 --- a/app/src/main/java/it/niedermann/nextcloud/deck/ui/filter/FilterDialogFragment.java +++ b/app/src/main/java/it/niedermann/nextcloud/deck/ui/filter/FilterDialogFragment.java @@ -8,6 +8,7 @@ import android.os.Bundle; import androidx.annotation.ColorInt; import androidx.annotation.NonNull; import androidx.appcompat.app.AlertDialog; +import androidx.core.content.ContextCompat; import androidx.fragment.app.DialogFragment; import androidx.fragment.app.Fragment; import androidx.fragment.app.FragmentManager; @@ -27,6 +28,7 @@ import it.niedermann.nextcloud.deck.ui.branding.BrandedAlertDialogBuilder; import it.niedermann.nextcloud.deck.ui.branding.BrandedDialogFragment; import static it.niedermann.nextcloud.deck.ui.branding.BrandingUtil.getSecondaryForegroundColorDependingOnTheme; +import static it.niedermann.nextcloud.deck.util.ColorUtil.getContrastRatio; public class FilterDialogFragment extends BrandedDialogFragment { @@ -103,9 +105,10 @@ public class FilterDialogFragment extends BrandedDialogFragment { @Override public void applyBrand(int mainColor) { - @ColorInt int finalMainColor = getSecondaryForegroundColorDependingOnTheme(requireContext(), mainColor); - binding.tabLayout.setSelectedTabIndicatorColor(finalMainColor); - indicator.setColorFilter(finalMainColor, PorterDuff.Mode.SRC_ATOP); + @ColorInt final int finalMainColor = getSecondaryForegroundColorDependingOnTheme(binding.tabLayout.getContext(), mainColor); + final boolean contrastRatioIsSufficient = getContrastRatio(mainColor, ContextCompat.getColor(binding.tabLayout.getContext(), R.color.primary)) > 1.7d; + binding.tabLayout.setSelectedTabIndicatorColor(contrastRatioIsSufficient ? mainColor : finalMainColor); + indicator.setColorFilter(contrastRatioIsSufficient ? mainColor : finalMainColor, PorterDuff.Mode.SRC_ATOP); } private static class TabsPagerAdapter extends FragmentStateAdapter { |