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!"); Log.d(TAG, "We have payloads, so ignoring!");
} else { } else {
holder.binding.titleTextView.setText(title); 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() { private fun themeDialog() {
viewThemeUtils.colorTextViewText(binding.pollQuestion) viewThemeUtils.colorPrimaryTextViewElement(binding.pollQuestion)
viewThemeUtils.colorTextViewText(binding.pollOptions) viewThemeUtils.colorPrimaryTextViewElement(binding.pollOptions)
viewThemeUtils.colorTextViewText(binding.pollSettings) viewThemeUtils.colorPrimaryTextViewElement(binding.pollSettings)
viewThemeUtils.colorEditText(binding.pollCreateQuestionTextEdit) viewThemeUtils.colorEditText(binding.pollCreateQuestionTextEdit)

View File

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

View File

@ -165,7 +165,7 @@ public class SortingOrderDialogFragment extends DialogFragment implements View.O
viewThemeUtils.colorMaterialButtonText((MaterialButton) view); viewThemeUtils.colorMaterialButtonText((MaterialButton) view);
} }
if (view instanceof TextView) { if (view instanceof TextView) {
viewThemeUtils.colorTextViewElement((TextView) view); viewThemeUtils.colorPrimaryTextViewElement((TextView) view);
((TextView) view).setTypeface(Typeface.DEFAULT_BOLD); ((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) { fun themeHorizontalSeekBar(seekBar: SeekBar) {
withElementColor(seekBar) { color -> withScheme(seekBar) { scheme ->
themeHorizontalSeekBar(seekBar, color) themeHorizontalSeekBar(seekBar, scheme.primary)
} }
} }
@ -179,23 +179,19 @@ class ViewThemeUtils @Inject constructor(private val theme: ServerTheme, private
} }
} }
fun colorTextViewElement(textView: TextView) { fun colorPrimaryTextViewElement(textView: TextView) {
withElementColor(textView) { color -> withScheme(textView) { scheme ->
textView.setTextColor(color) textView.setTextColor(scheme.primary)
} }
} }
fun colorTextViewText(textView: TextView) {
textView.setTextColor(theme.colorText)
}
/** /**
* Colors the background as element color and the foreground as text color. * Colors the background as element color and the foreground as text color.
*/ */
fun colorImageViewButton(imageView: ImageView) { fun colorImageViewButton(imageView: ImageView) {
withElementColor(imageView) { color -> withScheme(imageView) { scheme ->
imageView.imageTintList = ColorStateList.valueOf(theme.colorText) imageView.imageTintList = ColorStateList.valueOf(scheme.onPrimaryContainer)
imageView.backgroundTintList = ColorStateList.valueOf(color) imageView.backgroundTintList = ColorStateList.valueOf(scheme.primaryContainer)
} }
} }
@ -270,15 +266,15 @@ class ViewThemeUtils @Inject constructor(private val theme: ServerTheme, private
} }
fun colorCardViewBackground(card: MaterialCardView) { fun colorCardViewBackground(card: MaterialCardView) {
withElementColor(card) { color -> withScheme(card) { scheme ->
card.setCardBackgroundColor(color) card.setCardBackgroundColor(scheme.surfaceVariant)
} }
} }
// TODO split this util into classes depending on framework views vs library views // TODO split this util into classes depending on framework views vs library views
fun colorPreferenceCategory(category: MaterialPreferenceCategory) { fun colorPreferenceCategory(category: MaterialPreferenceCategory) {
withElementColor(category) { color -> withScheme(category) { scheme ->
category.setTitleColor(color) category.setTitleColor(scheme.primary)
} }
} }
@ -358,8 +354,8 @@ class ViewThemeUtils @Inject constructor(private val theme: ServerTheme, private
} }
fun colorProgressBar(progressIndicator: LinearProgressIndicator) { fun colorProgressBar(progressIndicator: LinearProgressIndicator) {
withElementColor(progressIndicator) { color -> withScheme(progressIndicator) { scheme ->
progressIndicator.setIndicatorColor(progressColor(progressIndicator.context, color)) progressIndicator.setIndicatorColor(scheme.primary)
} }
} }