mirror of
https://github.com/nextcloud/talk-android
synced 2025-06-23 13:40:43 +01:00
improve color state calculation for all button types with primary color style
Signed-off-by: Andy Scherzinger <info@andy-scherzinger.de>
This commit is contained in:
parent
51cf6061c3
commit
822970f8e8
@ -99,7 +99,7 @@ class PollResultsFragment : Fragment(), PollResultItemClickListener {
|
|||||||
|
|
||||||
private fun themeDialog() {
|
private fun themeDialog() {
|
||||||
viewThemeUtils.colorMaterialButtonPrimaryFilled(binding.editVoteButton)
|
viewThemeUtils.colorMaterialButtonPrimaryFilled(binding.editVoteButton)
|
||||||
viewThemeUtils.colorMaterialButtonText(binding.pollResultsEndPollButton)
|
viewThemeUtils.colorMaterialButtonPrimaryBorderless(binding.pollResultsEndPollButton)
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun initAdapter() {
|
private fun initAdapter() {
|
||||||
|
@ -128,7 +128,7 @@ class PollVoteFragment : Fragment() {
|
|||||||
private fun themeDialog() {
|
private fun themeDialog() {
|
||||||
viewThemeUtils.colorMaterialButtonPrimaryFilled(binding.pollVoteSubmitButton)
|
viewThemeUtils.colorMaterialButtonPrimaryFilled(binding.pollVoteSubmitButton)
|
||||||
viewThemeUtils.colorMaterialButtonText(binding.pollVoteEndPollButton)
|
viewThemeUtils.colorMaterialButtonText(binding.pollVoteEndPollButton)
|
||||||
viewThemeUtils.colorMaterialButtonText(binding.pollVoteEditDismiss)
|
viewThemeUtils.colorMaterialButtonPrimaryOutlined(binding.pollVoteEditDismiss)
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun updateDismissEditButton(showDismissEditButton: Boolean) {
|
private fun updateDismissEditButton(showDismissEditButton: Boolean) {
|
||||||
|
@ -120,7 +120,7 @@ public class SortingOrderDialogFragment extends DialogFragment implements View.O
|
|||||||
* find all relevant UI elements and set their values.
|
* find all relevant UI elements and set their values.
|
||||||
*/
|
*/
|
||||||
private void setupDialogElements() {
|
private void setupDialogElements() {
|
||||||
viewThemeUtils.colorMaterialButtonText(binding.cancel);
|
viewThemeUtils.colorMaterialButtonPrimaryBorderless(binding.cancel);
|
||||||
|
|
||||||
taggedViews = new View[12];
|
taggedViews = new View[12];
|
||||||
taggedViews[0] = binding.sortByNameAscending;
|
taggedViews[0] = binding.sortByNameAscending;
|
||||||
|
@ -199,8 +199,8 @@ class ViewThemeUtils @Inject constructor(private val theme: ServerTheme, private
|
|||||||
* Tints the image with element color
|
* Tints the image with element color
|
||||||
*/
|
*/
|
||||||
fun colorImageView(imageView: ImageView) {
|
fun colorImageView(imageView: ImageView) {
|
||||||
withElementColor(imageView) { color ->
|
withScheme(imageView) { scheme ->
|
||||||
imageView.imageTintList = ColorStateList.valueOf(color)
|
imageView.imageTintList = ColorStateList.valueOf(scheme.primary)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -212,14 +212,14 @@ class ViewThemeUtils @Inject constructor(private val theme: ServerTheme, private
|
|||||||
}
|
}
|
||||||
|
|
||||||
fun colorMaterialButtonText(button: MaterialButton) {
|
fun colorMaterialButtonText(button: MaterialButton) {
|
||||||
withElementColor(button) { color ->
|
withScheme(button) { scheme ->
|
||||||
val disabledColor = ContextCompat.getColor(button.context, R.color.disabled_text)
|
val disabledColor = ContextCompat.getColor(button.context, R.color.disabled_text)
|
||||||
val colorStateList = ColorStateList(
|
val colorStateList = ColorStateList(
|
||||||
arrayOf(
|
arrayOf(
|
||||||
intArrayOf(android.R.attr.state_enabled),
|
intArrayOf(android.R.attr.state_enabled),
|
||||||
intArrayOf(-android.R.attr.state_enabled)
|
intArrayOf(-android.R.attr.state_enabled)
|
||||||
),
|
),
|
||||||
intArrayOf(color, disabledColor)
|
intArrayOf(scheme.primary, disabledColor)
|
||||||
)
|
)
|
||||||
button.setTextColor(colorStateList)
|
button.setTextColor(colorStateList)
|
||||||
button.iconTint = colorStateList
|
button.iconTint = colorStateList
|
||||||
@ -236,7 +236,7 @@ class ViewThemeUtils @Inject constructor(private val theme: ServerTheme, private
|
|||||||
),
|
),
|
||||||
intArrayOf(
|
intArrayOf(
|
||||||
scheme.primary,
|
scheme.primary,
|
||||||
calculateDisabledColor(scheme.primary, SURFACE_OPACITY_BUTTON_DISABLED)
|
calculateDisabledColor(scheme.onSurface, SURFACE_OPACITY_BUTTON_DISABLED)
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -248,7 +248,36 @@ class ViewThemeUtils @Inject constructor(private val theme: ServerTheme, private
|
|||||||
),
|
),
|
||||||
intArrayOf(
|
intArrayOf(
|
||||||
scheme.onPrimary,
|
scheme.onPrimary,
|
||||||
calculateDisabledColor(scheme.onPrimary, ON_SURFACE_OPACITY_BUTTON_DISABLED)
|
calculateDisabledColor(scheme.onSurface, ON_SURFACE_OPACITY_BUTTON_DISABLED)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
button.iconTint = ColorStateList(
|
||||||
|
arrayOf(
|
||||||
|
intArrayOf(android.R.attr.state_enabled),
|
||||||
|
intArrayOf(-android.R.attr.state_enabled)
|
||||||
|
),
|
||||||
|
intArrayOf(
|
||||||
|
scheme.onPrimary,
|
||||||
|
calculateDisabledColor(scheme.onSurface, ON_SURFACE_OPACITY_BUTTON_DISABLED)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fun colorMaterialButtonPrimaryOutlined(button: MaterialButton) {
|
||||||
|
withScheme(button) { scheme ->
|
||||||
|
button.strokeColor = ColorStateList.valueOf(scheme.outline)
|
||||||
|
button.setTextColor(
|
||||||
|
ColorStateList(
|
||||||
|
arrayOf(
|
||||||
|
intArrayOf(android.R.attr.state_enabled),
|
||||||
|
intArrayOf(-android.R.attr.state_enabled)
|
||||||
|
),
|
||||||
|
intArrayOf(
|
||||||
|
scheme.primary,
|
||||||
|
calculateDisabledColor(scheme.onSurface, ON_SURFACE_OPACITY_BUTTON_DISABLED)
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
@ -258,8 +287,35 @@ class ViewThemeUtils @Inject constructor(private val theme: ServerTheme, private
|
|||||||
intArrayOf(-android.R.attr.state_enabled)
|
intArrayOf(-android.R.attr.state_enabled)
|
||||||
),
|
),
|
||||||
intArrayOf(
|
intArrayOf(
|
||||||
scheme.onPrimary,
|
scheme.primary,
|
||||||
calculateDisabledColor(scheme.onPrimary, ON_SURFACE_OPACITY_BUTTON_DISABLED)
|
calculateDisabledColor(scheme.onSurface, ON_SURFACE_OPACITY_BUTTON_DISABLED)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fun colorMaterialButtonPrimaryBorderless(button: MaterialButton) {
|
||||||
|
withScheme(button) { scheme ->
|
||||||
|
button.setTextColor(
|
||||||
|
ColorStateList(
|
||||||
|
arrayOf(
|
||||||
|
intArrayOf(android.R.attr.state_enabled),
|
||||||
|
intArrayOf(-android.R.attr.state_enabled)
|
||||||
|
),
|
||||||
|
intArrayOf(
|
||||||
|
scheme.primary,
|
||||||
|
calculateDisabledColor(scheme.onSurface, ON_SURFACE_OPACITY_BUTTON_DISABLED)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
button.iconTint = ColorStateList(
|
||||||
|
arrayOf(
|
||||||
|
intArrayOf(android.R.attr.state_enabled),
|
||||||
|
intArrayOf(-android.R.attr.state_enabled)
|
||||||
|
),
|
||||||
|
intArrayOf(
|
||||||
|
scheme.primary,
|
||||||
|
calculateDisabledColor(scheme.onSurface, ON_SURFACE_OPACITY_BUTTON_DISABLED)
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
@ -288,7 +344,7 @@ class ViewThemeUtils @Inject constructor(private val theme: ServerTheme, private
|
|||||||
}
|
}
|
||||||
|
|
||||||
fun colorSwitchCompat(switchCompat: SwitchCompat) {
|
fun colorSwitchCompat(switchCompat: SwitchCompat) {
|
||||||
withElementColor(switchCompat) { color ->
|
withScheme(switchCompat) { scheme ->
|
||||||
|
|
||||||
val context = switchCompat.context
|
val context = switchCompat.context
|
||||||
|
|
||||||
@ -303,11 +359,16 @@ class ViewThemeUtils @Inject constructor(private val theme: ServerTheme, private
|
|||||||
context.theme
|
context.theme
|
||||||
)
|
)
|
||||||
|
|
||||||
val trackColor =
|
val trackColor = Color.argb(
|
||||||
Color.argb(SWITCHCOMPAT_TRACK_ALPHA, Color.red(color), Color.green(color), Color.blue(color))
|
SWITCHCOMPAT_TRACK_ALPHA,
|
||||||
|
Color.red(scheme.primary),
|
||||||
|
Color.green(scheme.primary),
|
||||||
|
Color.blue
|
||||||
|
(scheme.primary)
|
||||||
|
)
|
||||||
switchCompat.thumbTintList = ColorStateList(
|
switchCompat.thumbTintList = ColorStateList(
|
||||||
arrayOf(intArrayOf(android.R.attr.state_checked), intArrayOf()),
|
arrayOf(intArrayOf(android.R.attr.state_checked), intArrayOf()),
|
||||||
intArrayOf(color, thumbUncheckedColor)
|
intArrayOf(scheme.primary, thumbUncheckedColor)
|
||||||
)
|
)
|
||||||
|
|
||||||
switchCompat.trackTintList = ColorStateList(
|
switchCompat.trackTintList = ColorStateList(
|
||||||
@ -318,37 +379,37 @@ class ViewThemeUtils @Inject constructor(private val theme: ServerTheme, private
|
|||||||
}
|
}
|
||||||
|
|
||||||
fun colorDrawable(context: Context, drawable: Drawable) {
|
fun colorDrawable(context: Context, drawable: Drawable) {
|
||||||
val color = getElementColor(context)
|
val scheme = getScheme(context)
|
||||||
drawable.setTint(color)
|
drawable.setTint(scheme.primary)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun themeCheckbox(checkbox: CheckBox) {
|
fun themeCheckbox(checkbox: CheckBox) {
|
||||||
withElementColor(checkbox) { color ->
|
withScheme(checkbox) { scheme ->
|
||||||
checkbox.buttonTintList = ColorStateList(
|
checkbox.buttonTintList = ColorStateList(
|
||||||
arrayOf(
|
arrayOf(
|
||||||
intArrayOf(-android.R.attr.state_checked),
|
intArrayOf(-android.R.attr.state_checked),
|
||||||
intArrayOf(android.R.attr.state_checked)
|
intArrayOf(android.R.attr.state_checked)
|
||||||
),
|
),
|
||||||
intArrayOf(Color.GRAY, color)
|
intArrayOf(Color.GRAY, scheme.primary)
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun themeRadioButton(radioButton: RadioButton) {
|
fun themeRadioButton(radioButton: RadioButton) {
|
||||||
withElementColor(radioButton) { color ->
|
withScheme(radioButton) { scheme ->
|
||||||
radioButton.buttonTintList = ColorStateList(
|
radioButton.buttonTintList = ColorStateList(
|
||||||
arrayOf(
|
arrayOf(
|
||||||
intArrayOf(-android.R.attr.state_checked),
|
intArrayOf(-android.R.attr.state_checked),
|
||||||
intArrayOf(android.R.attr.state_checked)
|
intArrayOf(android.R.attr.state_checked)
|
||||||
),
|
),
|
||||||
intArrayOf(Color.GRAY, color)
|
intArrayOf(Color.GRAY, scheme.primary)
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun themeSwipeRefreshLayout(swipeRefreshLayout: SwipeRefreshLayout) {
|
fun themeSwipeRefreshLayout(swipeRefreshLayout: SwipeRefreshLayout) {
|
||||||
withElementColor(swipeRefreshLayout) { color ->
|
withScheme(swipeRefreshLayout) { scheme ->
|
||||||
swipeRefreshLayout.setColorSchemeColors(color)
|
swipeRefreshLayout.setColorSchemeColors(scheme.primary)
|
||||||
swipeRefreshLayout.setProgressBackgroundColorSchemeResource(R.color.refresh_spinner_background)
|
swipeRefreshLayout.setProgressBackgroundColorSchemeResource(R.color.refresh_spinner_background)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -420,8 +481,8 @@ class ViewThemeUtils @Inject constructor(private val theme: ServerTheme, private
|
|||||||
}
|
}
|
||||||
|
|
||||||
fun colorTabLayout(tabLayout: TabLayout) {
|
fun colorTabLayout(tabLayout: TabLayout) {
|
||||||
withElementColor(tabLayout) { color ->
|
withScheme(tabLayout) { scheme ->
|
||||||
tabLayout.setSelectedTabIndicatorColor(color)
|
tabLayout.setSelectedTabIndicatorColor(scheme.primary)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -438,18 +499,18 @@ class ViewThemeUtils @Inject constructor(private val theme: ServerTheme, private
|
|||||||
}
|
}
|
||||||
|
|
||||||
fun colorChipBackground(chip: Chip) {
|
fun colorChipBackground(chip: Chip) {
|
||||||
withElementColor(chip) { color ->
|
withScheme(chip) { scheme ->
|
||||||
chip.chipBackgroundColor = ColorStateList.valueOf(color)
|
chip.chipBackgroundColor = ColorStateList.valueOf(scheme.primary)
|
||||||
chip.setTextColor(theme.colorText)
|
chip.setTextColor(theme.colorText)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun colorChipOutlined(chip: Chip, strokeWidth: Float) {
|
fun colorChipOutlined(chip: Chip, strokeWidth: Float) {
|
||||||
withElementColor(chip) { color ->
|
withScheme(chip) { scheme ->
|
||||||
chip.chipBackgroundColor = ColorStateList.valueOf(Color.TRANSPARENT)
|
chip.chipBackgroundColor = ColorStateList.valueOf(Color.TRANSPARENT)
|
||||||
chip.chipStrokeWidth = strokeWidth
|
chip.chipStrokeWidth = strokeWidth
|
||||||
chip.chipStrokeColor = ColorStateList.valueOf(color)
|
chip.chipStrokeColor = ColorStateList.valueOf(scheme.primary)
|
||||||
chip.setTextColor(color)
|
chip.setTextColor(scheme.primary)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user