Bladeren bron

Merge pull request #2725 from nextcloud/issue-2470

Added A scroll down button + new icon + some styles for the button
Andy Scherzinger 2 jaren geleden
bovenliggende
commit
af40c98cdf

+ 9 - 0
app/src/main/java/com/nextcloud/talk/controllers/ChatController.kt

@@ -673,6 +673,8 @@ class ChatController(args: Bundle) :
             }
         }
 
+        binding?.scrollDownButton?.setOnClickListener { binding?.messagesListView?.smoothScrollToPosition(0) }
+
         binding?.let { viewThemeUtils.material.colorMaterialButtonPrimaryFilled(it.popupBubbleView) }
 
         binding?.messageInputView?.setPadding(0, 0, 0, 0)
@@ -682,6 +684,13 @@ class ChatController(args: Bundle) :
                 super.onScrollStateChanged(recyclerView, newState)
 
                 if (newState == AbsListView.OnScrollListener.SCROLL_STATE_IDLE) {
+
+                    if (layoutManager!!.findFirstCompletelyVisibleItemPosition() > 0) {
+                        binding?.scrollDownButton?.visibility = View.VISIBLE
+                    } else {
+                        binding?.scrollDownButton?.visibility = View.INVISIBLE
+                    }
+
                     if (newMessagesCount != 0 && layoutManager != null) {
                         if (layoutManager!!.findFirstCompletelyVisibleItemPosition() < newMessagesCount) {
                             newMessagesCount = 0

+ 21 - 0
app/src/main/res/drawable/ic_baseline_keyboard_double_arrow_down_24.xml

@@ -0,0 +1,21 @@
+<!--
+    @author Google LLC
+    Copyright (C) 2023 Google LLC
+    Licensed under the Apache License, Version 2.0 (the "License");
+    you may not use this file except in compliance with the License.
+    You may obtain a copy of the License at
+    http://www.apache.org/licenses/LICENSE-2.0
+    Unless required by applicable law or agreed to in writing, software
+    distributed under the License is distributed on an "AS IS" BASIS,
+    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+    See the License for the specific language governing permissions and
+    limitations under the License.
+-->
+<vector android:height="24dp" android:tint="#000"
+    android:viewportHeight="24" android:viewportWidth="24"
+    android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android">
+    <path android:fillColor="@android:color/black"
+        android:pathData="M18,6.41l-1.41,-1.41l-4.59,4.58l-4.59,-4.58l-1.41,1.41l6,6z"/>
+    <path android:fillColor="@android:color/black"
+        android:pathData="M18,13l-1.41,-1.41l-4.59,4.58l-4.59,-4.58l-1.41,1.41l6,6z"/>
+</vector>

+ 17 - 0
app/src/main/res/layout/controller_chat.xml

@@ -3,6 +3,8 @@
   ~
   ~ @author Mario Danic
   ~ @author Andy Scherzinger
+  ~ @author Julius Linus
+  ~ Copyright (C) 2023 Julius Linus <juliuslinus1@gmail.com>
   ~ Copyright (C) 2021 Andy Scherzinger <info@andy-scherzinger.de>
   ~ Copyright (C) 2017-2018 Mario Danic <mario@lovelyhq.com>
   ~
@@ -108,6 +110,21 @@
             app:cornerRadius="@dimen/button_corner_radius"
             app:icon="@drawable/ic_baseline_arrow_downward_24px" />
 
+        <ImageButton
+            android:id="@+id/scrollDownButton"
+            android:layout_width="44dp"
+            android:layout_height="44dp"
+            android:layout_alignParentEnd="true"
+            android:layout_alignParentBottom="true"
+            android:layout_marginEnd="6dp"
+            android:layout_marginBottom="16dp"
+            android:background="@drawable/shape_oval"
+            android:backgroundTint="@color/scroll_down_chat_button"
+            android:contentDescription="@string/scroll_to_bottom"
+            android:src="@drawable/ic_baseline_keyboard_double_arrow_down_24"
+            android:visibility="invisible"
+            app:tint="@color/scroll_down_chat_button_icon" />
+
     </RelativeLayout>
 
     <LinearLayout

+ 4 - 0
app/src/main/res/values-night/colors.xml

@@ -76,4 +76,8 @@
 
     <color name="dialog_background">#353535</color>
 
+    <!-- scroll down chat button  -->
+    <color name="scroll_down_chat_button">#141F25</color>
+    <color name="scroll_down_chat_button_icon">#99C3DA</color>
+
 </resources>

+ 4 - 0
app/src/main/res/values/colors.xml

@@ -102,6 +102,10 @@
     <color name="list_divider_background">#1F121212</color>
     <color name="grey_200">#EEEEEE</color>
 
+    <!-- scroll down chat button  -->
+    <color name="scroll_down_chat_button">#E5F0F5</color>
+    <color name="scroll_down_chat_button_icon">#002A41</color>
+
     <!-- this is just a helper for status icon background because getting the background color of a dialog is not
     possible?! don't use this to set the background of dialogs -->
     <color name="dialog_background">#FFFFFF</color>

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

@@ -630,5 +630,6 @@
 
     <string name="nc_not_allowed_to_activate_audio">You are not allowed to activate audio!</string>
     <string name="nc_not_allowed_to_activate_video">You are not allowed to activate video!</string>
+    <string name="scroll_to_bottom">Scroll to bottom</string>
 
 </resources>