From 209c1a90ba5cdacce95468532b2bac8175e34c30 Mon Sep 17 00:00:00 2001 From: Andy Scherzinger Date: Fri, 29 Jul 2022 00:40:00 +0200 Subject: [PATCH] reuse color state list definitions Signed-off-by: Andy Scherzinger --- .../nextcloud/talk/ui/theme/ViewThemeUtils.kt | 77 ++++++------------- 1 file changed, 23 insertions(+), 54 deletions(-) diff --git a/app/src/main/java/com/nextcloud/talk/ui/theme/ViewThemeUtils.kt b/app/src/main/java/com/nextcloud/talk/ui/theme/ViewThemeUtils.kt index 572fb1259..b41c4eb15 100644 --- a/app/src/main/java/com/nextcloud/talk/ui/theme/ViewThemeUtils.kt +++ b/app/src/main/java/com/nextcloud/talk/ui/theme/ViewThemeUtils.kt @@ -288,64 +288,33 @@ class ViewThemeUtils @Inject constructor(private val theme: ServerTheme) { fun colorTextInputLayout(textInputLayout: TextInputLayout) { withElementColor(textInputLayout) { color -> val errorColor = Color.GRAY - textInputLayout.setBoxStrokeColorStateList( - ColorStateList( - arrayOf( - intArrayOf(-android.R.attr.state_focused), - intArrayOf(android.R.attr.state_focused) - ), - intArrayOf( - Color.GRAY, - color - ) + + val errorColorStateList = ColorStateList( + arrayOf( + intArrayOf(-android.R.attr.state_focused), + intArrayOf(android.R.attr.state_focused) + ), + intArrayOf( + errorColor, + errorColor ) ) - textInputLayout.setErrorIconTintList( - ColorStateList( - arrayOf( - intArrayOf(-android.R.attr.state_focused), - intArrayOf(android.R.attr.state_focused) - ), - intArrayOf( - errorColor, - errorColor - ) + val coloredColorStateList = ColorStateList( + arrayOf( + intArrayOf(-android.R.attr.state_focused), + intArrayOf(android.R.attr.state_focused) + ), + intArrayOf( + Color.GRAY, + color ) ) - textInputLayout.setErrorTextColor( - ColorStateList( - arrayOf( - intArrayOf(-android.R.attr.state_focused), - intArrayOf(android.R.attr.state_focused) - ), - intArrayOf( - errorColor, - errorColor - ) - ) - ) - textInputLayout.boxStrokeErrorColor = - ColorStateList( - arrayOf( - intArrayOf(-android.R.attr.state_focused), - intArrayOf(android.R.attr.state_focused) - ), - intArrayOf( - errorColor, - errorColor - ) - ) - textInputLayout.defaultHintTextColor = - ColorStateList( - arrayOf( - intArrayOf(-android.R.attr.state_focused), - intArrayOf(android.R.attr.state_focused) - ), - intArrayOf( - Color.GRAY, - color - ) - ) + + textInputLayout.setBoxStrokeColorStateList(coloredColorStateList) + textInputLayout.setErrorIconTintList(errorColorStateList) + textInputLayout.setErrorTextColor(errorColorStateList) + textInputLayout.boxStrokeErrorColor = errorColorStateList + textInputLayout.defaultHintTextColor = coloredColorStateList } }