Browse Source

Optimize themeing/layout for filtering

Signed-off-by: Andy Scherzinger <info@andy-scherzinger.de>
Andy Scherzinger 2 years ago
parent
commit
0246b584fb

+ 1 - 1
app/build.gradle

@@ -303,7 +303,7 @@ dependencies {
 
 
      implementation 'androidx.activity:activity-ktx:1.7.2'
      implementation 'androidx.activity:activity-ktx:1.7.2'
 
 
-    implementation 'com.github.nextcloud.android-common:ui:0.10.0'
+    implementation 'com.github.nextcloud.android-common:ui:0.11.0'
 
 
     implementation 'com.github.nextcloud-deps:android-talk-webrtc:110.5481.0'
     implementation 'com.github.nextcloud-deps:android-talk-webrtc:110.5481.0'
 }
 }

+ 4 - 2
app/src/main/java/com/nextcloud/talk/ui/dialog/FilterConversationFragment.kt

@@ -77,6 +77,8 @@ class FilterConversationFragment(
     }
     }
 
 
     private fun setUpColors() {
     private fun setUpColors() {
+        viewThemeUtils.material.colorMaterialButtonPrimaryBorderless(binding.buttonClose)
+
         binding.run {
         binding.run {
             listOf(
             listOf(
                 binding.root
                 binding.root
@@ -88,7 +90,7 @@ class FilterConversationFragment(
                 unreadFilterChip,
                 unreadFilterChip,
                 mentionedFilterChip
                 mentionedFilterChip
             )
             )
-        }.forEach(viewThemeUtils.material::colorChipBackground)
+        }.forEach(viewThemeUtils.talk::themeChipFilter)
 
 
         setUpChips()
         setUpChips()
     }
     }
@@ -106,7 +108,7 @@ class FilterConversationFragment(
             processSubmit()
             processSubmit()
         }
         }
 
 
-        binding.closeButton.setOnClickListener {
+        binding.buttonClose.setOnClickListener {
             dismiss()
             dismiss()
         }
         }
     }
     }

+ 36 - 0
app/src/main/java/com/nextcloud/talk/ui/theme/TalkSpecificViewThemeUtils.kt

@@ -24,6 +24,7 @@ package com.nextcloud.talk.ui.theme
 import android.annotation.TargetApi
 import android.annotation.TargetApi
 import android.content.Context
 import android.content.Context
 import android.content.res.ColorStateList
 import android.content.res.ColorStateList
+import android.graphics.Color
 import android.graphics.drawable.Drawable
 import android.graphics.drawable.Drawable
 import android.graphics.drawable.LayerDrawable
 import android.graphics.drawable.LayerDrawable
 import android.os.Build
 import android.os.Build
@@ -42,9 +43,11 @@ import androidx.core.graphics.drawable.DrawableCompat
 import androidx.core.view.ViewCompat
 import androidx.core.view.ViewCompat
 import androidx.core.view.children
 import androidx.core.view.children
 import com.google.android.material.card.MaterialCardView
 import com.google.android.material.card.MaterialCardView
+import com.google.android.material.chip.Chip
 import com.nextcloud.android.common.ui.theme.MaterialSchemes
 import com.nextcloud.android.common.ui.theme.MaterialSchemes
 import com.nextcloud.android.common.ui.theme.ViewThemeUtilsBase
 import com.nextcloud.android.common.ui.theme.ViewThemeUtilsBase
 import com.nextcloud.android.common.ui.theme.utils.AndroidXViewThemeUtils
 import com.nextcloud.android.common.ui.theme.utils.AndroidXViewThemeUtils
+import com.nextcloud.android.common.ui.util.buildColorStateList
 import com.nextcloud.talk.R
 import com.nextcloud.talk.R
 import com.nextcloud.talk.utils.DisplayUtils
 import com.nextcloud.talk.utils.DisplayUtils
 import com.nextcloud.talk.utils.DrawableUtils
 import com.nextcloud.talk.utils.DrawableUtils
@@ -87,6 +90,39 @@ class TalkSpecificViewThemeUtils @Inject constructor(
         ViewCompat.setBackground(bubble, bubbleDrawable)
         ViewCompat.setBackground(bubble, bubbleDrawable)
     }
     }
 
 
+    fun themeChipFilter(chip: Chip) {
+        withScheme(chip.context) { scheme ->
+            val backgroundColors = buildColorStateList(
+                android.R.attr.state_checked to scheme.secondaryContainer,
+                -android.R.attr.state_checked to scheme.surface,
+                android.R.attr.state_focused to scheme.secondaryContainer,
+                android.R.attr.state_hovered to scheme.secondaryContainer,
+                android.R.attr.state_pressed to scheme.secondaryContainer
+            )
+
+            val iconColors = buildColorStateList(
+                android.R.attr.state_checked to scheme.onSecondaryContainer,
+                -android.R.attr.state_checked to scheme.onSurfaceVariant,
+                android.R.attr.state_focused to scheme.onSecondaryContainer,
+                android.R.attr.state_hovered to scheme.onSecondaryContainer,
+                android.R.attr.state_pressed to scheme.onSecondaryContainer
+            )
+
+            val textColors = buildColorStateList(
+                android.R.attr.state_checked to scheme.onSecondaryContainer,
+                -android.R.attr.state_checked to scheme.onSurfaceVariant,
+                android.R.attr.state_hovered to scheme.onSecondaryContainer,
+                android.R.attr.state_focused to scheme.onSecondaryContainer,
+                android.R.attr.state_pressed to scheme.onSecondaryContainer
+            )
+
+            chip.chipBackgroundColor = backgroundColors
+            //chip.chipStrokeColor = chipOutlineFilterColorList(scheme)
+            chip.setTextColor(textColors)
+            chip.checkedIconTint = iconColors
+        }
+    }
+
     fun themeOutgoingMessageBubble(bubble: View, grouped: Boolean, deleted: Boolean) {
     fun themeOutgoingMessageBubble(bubble: View, grouped: Boolean, deleted: Boolean) {
         withScheme(bubble) { scheme ->
         withScheme(bubble) { scheme ->
             val bgBubbleColor = if (deleted) {
             val bgBubbleColor = if (deleted) {

+ 9 - 4
app/src/main/res/drawable/ic_baseline_filter_list_24.xml

@@ -14,8 +14,13 @@
     See the License for the specific language governing permissions and
     See the License for the specific language governing permissions and
     limitations under the License.
     limitations under the License.
 -->
 -->
-<vector android:height="24dp" android:tint="#000000"
-    android:viewportHeight="24" android:viewportWidth="24"
-    android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android">
-    <path android:fillColor="@android:color/white" android:pathData="M10,18h4v-2h-4v2zM3,6v2h18L21,6L3,6zM6,13h12v-2L6,11v2z"/>
+<vector xmlns:android="http://schemas.android.com/apk/res/android"
+    android:width="24dp"
+    android:height="24dp"
+    android:tint="#000000"
+    android:viewportWidth="24"
+    android:viewportHeight="24">
+    <path
+        android:fillColor="@android:color/white"
+        android:pathData="M10,18h4v-2h-4v2zM3,6v2h18L21,6L3,6zM6,13h12v-2L6,11v2z" />
 </vector>
 </vector>

+ 3 - 2
app/src/main/res/layout/controller_conversations_rv.xml

@@ -89,8 +89,9 @@
 
 
                 <ImageView
                 <ImageView
                     android:id="@+id/filter_conversations_button"
                     android:id="@+id/filter_conversations_button"
-                    android:layout_width="36dp"
-                    android:layout_height="36dp"
+                    android:layout_width="48dp"
+                    android:layout_height="48dp"
+                    android:padding="12dp"
                     android:contentDescription="@string/nc_filter"
                     android:contentDescription="@string/nc_filter"
                     android:src="@drawable/ic_baseline_filter_list_24"
                     android:src="@drawable/ic_baseline_filter_list_24"
                     app:layout_constraintBaseline_toTopOf="parent"
                     app:layout_constraintBaseline_toTopOf="parent"

+ 35 - 22
app/src/main/res/layout/dialog_filter_conversation.xml

@@ -19,6 +19,7 @@
   ~ along with this program.  If not, see <http://www.gnu.org/licenses/>.
   ~ along with this program.  If not, see <http://www.gnu.org/licenses/>.
   -->
   -->
 <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
 <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+    xmlns:app="http://schemas.android.com/apk/res-auto"
     xmlns:tools="http://schemas.android.com/tools"
     xmlns:tools="http://schemas.android.com/tools"
     android:layout_width="match_parent"
     android:layout_width="match_parent"
     android:layout_height="match_parent"
     android:layout_height="match_parent"
@@ -26,29 +27,12 @@
     tools:background="@color/white"
     tools:background="@color/white"
     tools:visibility="visible">
     tools:visibility="visible">
 
 
-    <LinearLayout
+    <com.google.android.material.textview.MaterialTextView
         android:layout_width="match_parent"
         android:layout_width="match_parent"
         android:layout_height="wrap_content"
         android:layout_height="wrap_content"
-        android:orientation="horizontal">
-
-        <com.google.android.material.textview.MaterialTextView
-            android:layout_width="wrap_content"
-            android:layout_height="wrap_content"
-            android:layout_weight="1"
-            android:layout_gravity="center"
-            android:layout_margin="@dimen/standard_margin"
-            android:text="@string/nc_filter"
-            android:textSize="@dimen/md_title_textsize" />
-
-        <ImageView
-            android:id="@+id/close_button"
-            android:layout_width="36dp"
-            android:layout_height="36dp"
-            android:src="@drawable/ic_close_search"
-            android:layout_margin="@dimen/standard_margin"
-            />
-
-    </LinearLayout>
+        android:layout_margin="@dimen/standard_margin"
+        android:text="@string/nc_filter"
+        android:textSize="@dimen/md_title_textsize" />
 
 
     <com.google.android.material.divider.MaterialDivider
     <com.google.android.material.divider.MaterialDivider
         android:layout_width="match_parent"
         android:layout_width="match_parent"
@@ -57,7 +41,11 @@
     <com.google.android.material.chip.ChipGroup
     <com.google.android.material.chip.ChipGroup
         android:layout_width="match_parent"
         android:layout_width="match_parent"
         android:layout_height="wrap_content"
         android:layout_height="wrap_content"
-        android:layout_margin="@dimen/standard_margin">
+        android:layout_marginStart="@dimen/standard_margin"
+        android:layout_marginTop="@dimen/standard_half_margin"
+        android:layout_marginEnd="@dimen/standard_margin"
+        android:layout_marginBottom="@dimen/standard_half_margin"
+        app:chipSpacingHorizontal="@dimen/standard_margin">
 
 
         <com.google.android.material.chip.Chip
         <com.google.android.material.chip.Chip
             android:id="@+id/unread_filter_chip"
             android:id="@+id/unread_filter_chip"
@@ -74,4 +62,29 @@
             android:text="@string/mentioned" />
             android:text="@string/mentioned" />
 
 
     </com.google.android.material.chip.ChipGroup>
     </com.google.android.material.chip.ChipGroup>
+
+    <com.google.android.material.divider.MaterialDivider
+        android:layout_width="match_parent"
+        android:layout_height="wrap_content" />
+
+    <LinearLayout
+        android:layout_width="match_parent"
+        android:layout_height="wrap_content"
+        android:layout_marginTop="@dimen/standard_half_margin"
+        android:gravity="end"
+        android:orientation="horizontal"
+        android:paddingStart="@dimen/dialog_padding"
+        android:paddingEnd="@dimen/dialog_padding"
+        android:paddingBottom="@dimen/dialog_padding_top_bottom">
+
+        <com.google.android.material.button.MaterialButton
+            android:id="@+id/button_close"
+            style="@style/Button.Borderless"
+            android:layout_width="wrap_content"
+            android:layout_height="wrap_content"
+            android:minHeight="@dimen/min_size_clickable_area"
+            android:text="@string/close" />
+
+    </LinearLayout>
+
 </LinearLayout>
 </LinearLayout>