瀏覽代碼

cleanup text theming methods, migrate image button theming

Signed-off-by: Andy Scherzinger <info@andy-scherzinger.de>
Andy Scherzinger 2 年之前
父節點
當前提交
51cf6061c3

+ 1 - 1
app/src/main/java/com/nextcloud/talk/adapters/items/GenericTextHeaderItem.java

@@ -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);
         }
     }
 

+ 3 - 3
app/src/main/java/com/nextcloud/talk/polls/ui/PollCreateDialogFragment.kt

@@ -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)
 

+ 1 - 1
app/src/main/java/com/nextcloud/talk/ui/dialog/SetStatusDialogFragment.kt

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

+ 1 - 1
app/src/main/java/com/nextcloud/talk/ui/dialog/SortingOrderDialogFragment.java

@@ -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);
             }
         }

+ 14 - 18
app/src/main/java/com/nextcloud/talk/ui/theme/ViewThemeUtils.kt

@@ -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)
         }
     }