浏览代码

migrate profile fields to input layouts for Material3

Signed-off-by: Andy Scherzinger <info@andy-scherzinger.de>
Andy Scherzinger 2 年之前
父节点
当前提交
b34765ccf4

+ 14 - 26
app/src/main/java/com/nextcloud/talk/controllers/ProfileController.kt

@@ -24,10 +24,8 @@ package com.nextcloud.talk.controllers
 import android.app.Activity
 import android.content.Intent
 import android.content.pm.PackageManager
-import android.content.res.ColorStateList
 import android.graphics.Bitmap
 import android.graphics.BitmapFactory
-import android.graphics.Color
 import android.net.Uri
 import android.os.Bundle
 import android.text.Editable
@@ -43,7 +41,6 @@ import android.view.ViewGroup
 import android.widget.Toast
 import androidx.annotation.ColorInt
 import androidx.annotation.DrawableRes
-import androidx.core.content.ContextCompat
 import androidx.core.graphics.drawable.DrawableCompat
 import androidx.core.view.ViewCompat
 import androidx.recyclerview.widget.RecyclerView
@@ -764,22 +761,14 @@ class ProfileController : NewBaseController(R.layout.controller_profile) {
             DrawableCompat.setTint(holder.binding.icon.drawable, mTintColor)
             if (!TextUtils.isEmpty(item.text) || controller.edit) {
                 holder.binding.userInfoDetailContainer.visibility = View.VISIBLE
-                if (controller.activity != null) {
-                    holder.binding.userInfoEditText.setTextColor(
-                        ContextCompat.getColor(
-                            controller.activity!!,
-                            R.color.conversation_item_header
-                        )
-                    )
-                }
+                controller.viewThemeUtils.colorTextInputLayout(holder.binding.userInfoInputLayout)
                 if (controller.edit &&
                     controller.editableFields.contains(item.field.toString().lowercase())
                 ) {
-                    holder.binding.userInfoEditText.isEnabled = true
-                    holder.binding.userInfoEditText.isFocusableInTouchMode = true
-                    holder.binding.userInfoEditText.isEnabled = true
-                    holder.binding.userInfoEditText.isCursorVisible = true
-                    holder.binding.userInfoEditText.backgroundTintList = ColorStateList.valueOf(mTintColor)
+                    holder.binding.userInfoEditTextEdit.isEnabled = true
+                    holder.binding.userInfoEditTextEdit.isFocusableInTouchMode = true
+                    holder.binding.userInfoEditTextEdit.isEnabled = true
+                    holder.binding.userInfoEditTextEdit.isCursorVisible = true
                     holder.binding.scope.setOnClickListener {
                         ScopeDialog(
                             controller.activity!!,
@@ -790,11 +779,10 @@ class ProfileController : NewBaseController(R.layout.controller_profile) {
                     }
                     holder.binding.scope.alpha = HIGH_EMPHASIS_ALPHA
                 } else {
-                    holder.binding.userInfoEditText.isEnabled = false
-                    holder.binding.userInfoEditText.isFocusableInTouchMode = false
-                    holder.binding.userInfoEditText.isEnabled = false
-                    holder.binding.userInfoEditText.isCursorVisible = false
-                    holder.binding.userInfoEditText.backgroundTintList = ColorStateList.valueOf(Color.TRANSPARENT)
+                    holder.binding.userInfoEditTextEdit.isEnabled = false
+                    holder.binding.userInfoEditTextEdit.isFocusableInTouchMode = false
+                    holder.binding.userInfoEditTextEdit.isEnabled = false
+                    holder.binding.userInfoEditTextEdit.isCursorVisible = false
                     holder.binding.scope.setOnClickListener(null)
                     holder.binding.scope.alpha = MEDIUM_EMPHASIS_ALPHA
                 }
@@ -807,19 +795,19 @@ class ProfileController : NewBaseController(R.layout.controller_profile) {
             holder: ViewHolder,
             item: UserInfoDetailsItem
         ) {
-            holder.binding.userInfoEditText.setText(item.text)
-            holder.binding.userInfoEditText.hint = item.hint
-            holder.binding.userInfoEditText.addTextChangedListener(object : TextWatcher {
+            holder.binding.userInfoEditTextEdit.setText(item.text)
+            holder.binding.userInfoInputLayout.hint = item.hint
+            holder.binding.userInfoEditTextEdit.addTextChangedListener(object : TextWatcher {
                 override fun beforeTextChanged(s: CharSequence, start: Int, count: Int, after: Int) {
                     // unused atm
                 }
 
                 override fun onTextChanged(s: CharSequence, start: Int, before: Int, count: Int) {
                     if (controller.edit) {
-                        displayList!![holder.adapterPosition].text = holder.binding.userInfoEditText.text.toString()
+                        displayList!![holder.adapterPosition].text = holder.binding.userInfoEditTextEdit.text.toString()
                     } else {
                         filteredDisplayList[holder.adapterPosition].text =
-                            holder.binding.userInfoEditText.text.toString()
+                            holder.binding.userInfoEditTextEdit.text.toString()
                     }
                 }
 

+ 2 - 1
app/src/main/res/layout/controller_profile.xml

@@ -29,7 +29,8 @@
     <RelativeLayout
         android:id="@+id/avatarContainer"
         android:layout_width="match_parent"
-        android:layout_height="wrap_content">
+        android:layout_height="wrap_content"
+        android:paddingBottom="@dimen/standard_padding">
 
         <com.facebook.drawee.view.SimpleDraweeView
             android:id="@+id/avatar_image"

+ 33 - 21
app/src/main/res/layout/user_info_details_table_item.xml

@@ -1,7 +1,7 @@
 <?xml version="1.0" encoding="utf-8"?><!--
   Nextcloud Android client application
 
-  Copyright (C) 2018-2021 Andy Scherzinger
+  Copyright (C) 2018-2022 Andy Scherzinger
   Copyright (C) 2018 Nextcloud
 
   This program is free software; you can redistribute it and/or
@@ -22,8 +22,10 @@
     xmlns:tools="http://schemas.android.com/tools"
     android:id="@+id/user_info_detail_container"
     android:layout_width="match_parent"
-    android:layout_height="@dimen/iconized_single_line_item_layout_height"
-    android:orientation="horizontal">
+    android:layout_height="wrap_content"
+    android:minHeight="@dimen/min_size_clickable_area"
+    android:orientation="horizontal"
+    android:paddingBottom="@dimen/standard_padding">
 
     <ImageView
         android:id="@+id/icon"
@@ -36,34 +38,44 @@
         app:layout_constraintTop_toTopOf="parent"
         tools:src="@drawable/ic_phone" />
 
-    <EditText
-        android:id="@+id/user_info_edit_text"
+    <com.google.android.material.textfield.TextInputLayout
+        android:id="@+id/user_info_input_layout"
+        style="@style/Widget.MaterialComponents.TextInputLayout.OutlinedBox"
         android:layout_width="0dp"
-        android:layout_height="48dp"
-        android:layout_marginStart="@dimen/standard_double_margin"
-        android:layout_marginEnd="@dimen/standard_margin"
-        android:autofillHints="none"
-        android:ellipsize="end"
-        android:inputType="text"
-        android:maxLines="1"
-        android:textSize="@dimen/two_line_primary_text_size"
+        android:layout_height="wrap_content"
+        android:layout_marginStart="@dimen/standard_margin"
+        android:minHeight="@dimen/min_size_clickable_area"
+        app:boxStrokeColor="@color/colorPrimary"
+        app:errorTextAppearance="@style/ErrorAppearance"
+        app:hintTextColor="@color/colorPrimary"
         app:layout_constraintBottom_toBottomOf="parent"
         app:layout_constraintEnd_toStartOf="@id/scope"
         app:layout_constraintStart_toEndOf="@id/icon"
-        app:layout_constraintTop_toTopOf="parent"
-        tools:ignore="LabelFor"
-        tools:text="+49 123 456 789 12" />
+        app:layout_constraintTop_toTopOf="parent">
+
+        <com.nextcloud.talk.utils.EmojiTextInputEditText
+            android:id="@+id/user_info_edit_text_edit"
+            android:layout_width="match_parent"
+            android:layout_height="wrap_content"
+            android:imeOptions="actionNext"
+            android:inputType="text"
+            android:singleLine="true"
+            android:textAlignment="viewStart"
+            tools:text="+49 123 456 789 12" />
+
+    </com.google.android.material.textfield.TextInputLayout>
 
     <ImageView
         android:id="@+id/scope"
-        android:layout_width="48dp"
-        android:layout_height="48dp"
-        android:padding="12dp"
-        android:layout_marginEnd="4dp"
+        android:layout_width="@dimen/min_size_clickable_area"
+        android:layout_height="@dimen/min_size_clickable_area"
+        android:layout_marginStart="@dimen/standard_quarter_margin"
+        android:layout_marginEnd="@dimen/standard_quarter_margin"
         android:contentDescription="@string/scope_toggle"
+        android:padding="@dimen/scope_padding"
         app:layout_constraintBottom_toBottomOf="parent"
         app:layout_constraintEnd_toEndOf="parent"
-        app:layout_constraintStart_toEndOf="@id/user_info_edit_text"
+        app:layout_constraintStart_toEndOf="@id/user_info_input_layout"
         app:layout_constraintTop_toTopOf="parent"
         tools:src="@drawable/ic_link" />
 

+ 1 - 0
app/src/main/res/values/dimens.xml

@@ -72,6 +72,7 @@
     <dimen name="activity_row_layout_height">48dp</dimen>
     <dimen name="reaction_bottom_sheet_layout_size">40dp</dimen>
     <dimen name="standard_eighth_margin">2dp</dimen>
+    <dimen name="scope_padding">12dp</dimen>
 
     <dimen name="default_checkbox_dialog_start_margin">18dp</dimen>