cleanup text theming methods, migrate image button theming

Signed-off-by: Andy Scherzinger <info@andy-scherzinger.de>
This commit is contained in:
Andy Scherzinger 2022-08-01 15:55:15 +02:00
parent ab14d9afff
commit 51cf6061c3
No known key found for this signature in database
GPG Key ID: 6CADC7E3523C308B
5 changed files with 20 additions and 24 deletions

View File

@ -74,7 +74,7 @@ public class GenericTextHeaderItem extends AbstractHeaderItem<GenericTextHeaderI
Log.d(TAG, "We have payloads, so ignoring!");
} else {
holder.binding.titleTextView.setText(title);
viewThemeUtils.colorTextViewElement(holder.binding.titleTextView);
viewThemeUtils.colorPrimaryTextViewElement(holder.binding.titleTextView);
}
}

View File

@ -99,9 +99,9 @@ class PollCreateDialogFragment : DialogFragment(), PollCreateOptionsItemListener
}
private fun themeDialog() {
viewThemeUtils.colorTextViewText(binding.pollQuestion)
viewThemeUtils.colorTextViewText(binding.pollOptions)
viewThemeUtils.colorTextViewText(binding.pollSettings)
viewThemeUtils.colorPrimaryTextViewElement(binding.pollQuestion)
viewThemeUtils.colorPrimaryTextViewElement(binding.pollOptions)
viewThemeUtils.colorPrimaryTextViewElement(binding.pollSettings)
viewThemeUtils.colorEditText(binding.pollCreateQuestionTextEdit)

View File

@ -416,7 +416,7 @@ class SetStatusDialogFragment :
}
}
viewThemeUtils.colorCardViewBackground(views.first)
viewThemeUtils.colorTextViewText(views.second)
viewThemeUtils.colorPrimaryTextViewElement(views.second)
}
private fun clearTopStatus() {

View File

@ -165,7 +165,7 @@ public class SortingOrderDialogFragment extends DialogFragment implements View.O
viewThemeUtils.colorMaterialButtonText((MaterialButton) view);
}
if (view instanceof TextView) {
viewThemeUtils.colorTextViewElement((TextView) view);
viewThemeUtils.colorPrimaryTextViewElement((TextView) view);
((TextView) view).setTypeface(Typeface.DEFAULT_BOLD);
}
}

View File

@ -162,8 +162,8 @@ class ViewThemeUtils @Inject constructor(private val theme: ServerTheme, private
}
fun themeHorizontalSeekBar(seekBar: SeekBar) {
withElementColor(seekBar) { color ->
themeHorizontalSeekBar(seekBar, color)
withScheme(seekBar) { scheme ->
themeHorizontalSeekBar(seekBar, scheme.primary)
}
}
@ -179,23 +179,19 @@ class ViewThemeUtils @Inject constructor(private val theme: ServerTheme, private
}
}
fun colorTextViewElement(textView: TextView) {
withElementColor(textView) { color ->
textView.setTextColor(color)
fun colorPrimaryTextViewElement(textView: TextView) {
withScheme(textView) { scheme ->
textView.setTextColor(scheme.primary)
}
}
fun colorTextViewText(textView: TextView) {
textView.setTextColor(theme.colorText)
}
/**
* Colors the background as element color and the foreground as text color.
*/
fun colorImageViewButton(imageView: ImageView) {
withElementColor(imageView) { color ->
imageView.imageTintList = ColorStateList.valueOf(theme.colorText)
imageView.backgroundTintList = ColorStateList.valueOf(color)
withScheme(imageView) { scheme ->
imageView.imageTintList = ColorStateList.valueOf(scheme.onPrimaryContainer)
imageView.backgroundTintList = ColorStateList.valueOf(scheme.primaryContainer)
}
}
@ -270,15 +266,15 @@ class ViewThemeUtils @Inject constructor(private val theme: ServerTheme, private
}
fun colorCardViewBackground(card: MaterialCardView) {
withElementColor(card) { color ->
card.setCardBackgroundColor(color)
withScheme(card) { scheme ->
card.setCardBackgroundColor(scheme.surfaceVariant)
}
}
// TODO split this util into classes depending on framework views vs library views
fun colorPreferenceCategory(category: MaterialPreferenceCategory) {
withElementColor(category) { color ->
category.setTitleColor(color)
withScheme(category) { scheme ->
category.setTitleColor(scheme.primary)
}
}
@ -358,8 +354,8 @@ class ViewThemeUtils @Inject constructor(private val theme: ServerTheme, private
}
fun colorProgressBar(progressIndicator: LinearProgressIndicator) {
withElementColor(progressIndicator) { color ->
progressIndicator.setIndicatorColor(progressColor(progressIndicator.context, color))
withScheme(progressIndicator) { scheme ->
progressIndicator.setIndicatorColor(scheme.primary)
}
}