Browse Source

TextInputLayout now supports Material 3

Signed-off-by: Andy Scherzinger <info@andy-scherzinger.de>
Andy Scherzinger 2 years ago
parent
commit
6075191bc5
1 changed files with 9 additions and 8 deletions
  1. 9 8
      app/src/main/java/com/nextcloud/talk/ui/theme/ViewThemeUtils.kt

+ 9 - 8
app/src/main/java/com/nextcloud/talk/ui/theme/ViewThemeUtils.kt

@@ -350,8 +350,7 @@ class ViewThemeUtils @Inject constructor(private val theme: ServerTheme, private
     }
     }
 
 
     fun colorEditText(editText: EditText) {
     fun colorEditText(editText: EditText) {
-        withElementColor(editText) { color ->
-            editText.setTextColor(color)
+        withScheme(editText) { scheme ->
             // TODO check API-level compatibility
             // TODO check API-level compatibility
             // editText.background.setColorFilter(color, PorterDuff.Mode.SRC_ATOP)
             // editText.background.setColorFilter(color, PorterDuff.Mode.SRC_ATOP)
             editText.backgroundTintList = ColorStateList(
             editText.backgroundTintList = ColorStateList(
@@ -360,16 +359,18 @@ class ViewThemeUtils @Inject constructor(private val theme: ServerTheme, private
                     intArrayOf(android.R.attr.state_focused)
                     intArrayOf(android.R.attr.state_focused)
                 ),
                 ),
                 intArrayOf(
                 intArrayOf(
-                    Color.GRAY,
-                    color
+                    scheme.outline,
+                    scheme.primary
                 )
                 )
             )
             )
+            editText.setHintTextColor(scheme.onSurfaceVariant)
+            editText.setTextColor(scheme.onSurface)
         }
         }
     }
     }
 
 
     fun colorTextInputLayout(textInputLayout: TextInputLayout) {
     fun colorTextInputLayout(textInputLayout: TextInputLayout) {
-        withElementColor(textInputLayout) { color ->
-            val errorColor = Color.GRAY
+        withScheme(textInputLayout) { scheme ->
+            val errorColor = scheme.onSurfaceVariant
 
 
             val errorColorStateList = ColorStateList(
             val errorColorStateList = ColorStateList(
                 arrayOf(
                 arrayOf(
@@ -387,8 +388,8 @@ class ViewThemeUtils @Inject constructor(private val theme: ServerTheme, private
                     intArrayOf(android.R.attr.state_focused)
                     intArrayOf(android.R.attr.state_focused)
                 ),
                 ),
                 intArrayOf(
                 intArrayOf(
-                    Color.GRAY,
-                    color
+                    scheme.outline,
+                    scheme.primary
                 )
                 )
             )
             )