Przeglądaj źródła

Can now open preview messages in the files app in message actions

Signed-off-by: rapterjet2004 <juliuslinus1@gmail.com>
Julius Linus 1 rok temu
rodzic
commit
fa5e0fb01d

+ 9 - 0
app/src/main/java/com/nextcloud/talk/chat/ChatActivity.kt

@@ -122,6 +122,7 @@ import com.nextcloud.talk.adapters.messages.OutcomingPreviewMessageViewHolder
 import com.nextcloud.talk.adapters.messages.OutcomingTextMessageViewHolder
 import com.nextcloud.talk.adapters.messages.OutcomingVoiceMessageViewHolder
 import com.nextcloud.talk.adapters.messages.PreviewMessageInterface
+import com.nextcloud.talk.adapters.messages.PreviewMessageViewHolder
 import com.nextcloud.talk.adapters.messages.SystemMessageViewHolder
 import com.nextcloud.talk.adapters.messages.TalkMessagesListAdapter
 import com.nextcloud.talk.adapters.messages.UnreadNoticeMessageViewHolder
@@ -173,6 +174,7 @@ import com.nextcloud.talk.utils.DateConstants
 import com.nextcloud.talk.utils.DateUtils
 import com.nextcloud.talk.utils.DisplayUtils
 import com.nextcloud.talk.utils.FileUtils
+import com.nextcloud.talk.utils.FileViewerUtils
 import com.nextcloud.talk.utils.ImageEmojiEditText
 import com.nextcloud.talk.utils.MagicCharPolicy
 import com.nextcloud.talk.utils.NotificationUtils
@@ -3455,6 +3457,13 @@ class ChatActivity :
         startActivity(intent)
     }
 
+    fun openInFilesApp(message: ChatMessage) {
+        val keyID = message.selectedIndividualHashMap!![PreviewMessageViewHolder.KEY_ID]
+        val link = message.selectedIndividualHashMap!!["link"]
+        val fileViewerUtils = FileViewerUtils(this, message.activeUser!!)
+        fileViewerUtils.openFileInFilesApp(link!!, keyID!!)
+    }
+
     private fun hasVisibleItems(message: ChatMessage): Boolean {
         return !message.isDeleted || // copy message
             message.replyable || // reply to

+ 14 - 0
app/src/main/java/com/nextcloud/talk/ui/dialog/MessageActionsDialog.kt

@@ -111,6 +111,9 @@ class MessageActionsDialog(
             message.previousMessageId > NO_PREVIOUS_MESSAGE_ID &&
                 ChatMessage.MessageType.SYSTEM_MESSAGE != message.getCalculateMessageType()
         )
+        initMenuItemOpenNcApp(
+            ChatMessage.MessageType.SINGLE_NC_ATTACHMENT_MESSAGE == message.getCalculateMessageType()
+        )
     }
 
     override fun onStart() {
@@ -314,6 +317,17 @@ class MessageActionsDialog(
         dialogMessageActionsBinding.menuTranslateMessage.visibility = getVisibility(visible)
     }
 
+    private fun initMenuItemOpenNcApp(visible: Boolean) {
+        if (visible) {
+            dialogMessageActionsBinding.menuOpenInNcApp.setOnClickListener {
+                chatActivity.openInFilesApp(message)
+                dismiss()
+            }
+        }
+
+        dialogMessageActionsBinding.menuOpenInNcApp.visibility = getVisibility(visible)
+    }
+
     private fun getVisibility(visible: Boolean): Int {
         return if (visible) {
             View.VISIBLE

+ 33 - 0
app/src/main/res/layout/dialog_message_actions.xml

@@ -320,6 +320,39 @@
 
         </LinearLayout>
 
+        <LinearLayout
+            android:id="@+id/menu_open_in_nc_app"
+            android:layout_width="match_parent"
+            android:layout_height="@dimen/bottom_sheet_item_height"
+            android:background="?android:attr/selectableItemBackground"
+            android:gravity="center_vertical"
+            android:orientation="horizontal"
+            tools:ignore="UseCompoundDrawables">
+
+            <ImageView
+                android:id="@+id/menu_icon_open_in_nc_app"
+                android:layout_width="wrap_content"
+                android:layout_height="wrap_content"
+                android:contentDescription="@null"
+                android:paddingStart="@dimen/standard_padding"
+                android:paddingEnd="@dimen/zero"
+                android:src="@drawable/ic_exit_to_app_black_24dp"
+                app:tint="@color/high_emphasis_menu_icon" />
+
+            <androidx.appcompat.widget.AppCompatTextView
+                android:id="@+id/menu_text_open_in_nc_app"
+                android:layout_width="match_parent"
+                android:layout_height="wrap_content"
+                android:layout_gravity="start|center_vertical"
+                android:paddingStart="@dimen/standard_double_padding"
+                android:paddingEnd="@dimen/standard_padding"
+                android:text="@string/open_in_files_app"
+                android:textAlignment="viewStart"
+                android:textColor="@color/high_emphasis_text"
+                android:textSize="@dimen/bottom_sheet_text_size" />
+
+        </LinearLayout>
+
         <LinearLayout
             android:id="@+id/menu_delete_message"
             android:layout_width="match_parent"