From c215913374b81eb7ab3ad3aef2b850a2ab82d270 Mon Sep 17 00:00:00 2001
From: Lanius-collaris <heptadecagon@yandex.com>
Date: Wed, 12 Jun 2024 10:02:17 +0800
Subject: [PATCH] conv actions: disable color chooser and emoji chooser for
 trust requests

GitLab: #1370
Change-Id: I2906fb9381c6167b4c4206e36939ddb6124591d8
---
 .../fragments/ConversationActionsFragment.kt  | 70 ++++++++++---------
 1 file changed, 36 insertions(+), 34 deletions(-)

diff --git a/jami-android/app/src/main/java/cx/ring/fragments/ConversationActionsFragment.kt b/jami-android/app/src/main/java/cx/ring/fragments/ConversationActionsFragment.kt
index 51070062c..50e134a11 100644
--- a/jami-android/app/src/main/java/cx/ring/fragments/ConversationActionsFragment.kt
+++ b/jami-android/app/src/main/java/cx/ring/fragments/ConversationActionsFragment.kt
@@ -90,41 +90,43 @@ class ConversationActionsFragment : Fragment(), Colorable {
             colorActionPosition = 0
             symbolActionPosition = 1
 
-            // Setup an action to allow the user to select a color for the conversation.
-            colorAction = ContactAction(
-                R.drawable.item_color_background, 0,
-                getText(R.string.conversation_preference_color)
-            ) {
-                ColorChooserBottomSheet { color -> // Color chosen by the user (onclick method).
-                    val rgbColor = String.format("#%06X", 0xFFFFFF and color)
-                    mConversationFacade.setConversationPreferences(
-                        path.accountId,
-                        path.conversationUri,
-                        mapOf(Conversation.KEY_PREFERENCE_CONVERSATION_COLOR to rgbColor)
-                    )
-                    // Need to manually update the color of the conversation as will not get the
-                    // update signal from daemon.
-                    if (!path.conversationUri.isSwarm) conversation.setColor(color)
-                }.show(parentFragmentManager, "colorChooser")
-            }
-            // Add the action to the list of actions.
-            adapter.actions.add(colorAction!!)
-
-            // Setup an action to allow the user to select an Emoji for the conversation.
-            symbolAction = ContactAction(0, getText(R.string.conversation_preference_emoji)) {
-                EmojiChooserBottomSheet { emoji -> // Emoji chosen by the user (onclick method).
-                    if (emoji == null) return@EmojiChooserBottomSheet
-                    mConversationFacade.setConversationPreferences(
-                        path.accountId,
-                        path.conversationUri,
-                        mapOf(Conversation.KEY_PREFERENCE_CONVERSATION_SYMBOL to emoji)
-                    )
-                    // Need to manually update the symbol of the conversation as will not get the
-                    // update signal from daemon.
-                    if(!path.conversationUri.isSwarm) conversation.setSymbol(emoji.toString())
-                }.show(parentFragmentManager, "colorChooser")
+            if (conversation.mode.blockingFirst().isSwarm) {
+                // Setup an action to allow the user to select a color for the conversation.
+                colorAction = ContactAction(
+                    R.drawable.item_color_background, 0,
+                    getText(R.string.conversation_preference_color)
+                ) {
+                    ColorChooserBottomSheet { color -> // Color chosen by the user (onclick method).
+                        val rgbColor = String.format("#%06X", 0xFFFFFF and color)
+                        mConversationFacade.setConversationPreferences(
+                            path.accountId,
+                            path.conversationUri,
+                            mapOf(Conversation.KEY_PREFERENCE_CONVERSATION_COLOR to rgbColor)
+                        )
+                        // Need to manually update the color of the conversation as will not get the
+                        // update signal from daemon.
+                        if (!path.conversationUri.isSwarm) conversation.setColor(color)
+                    }.show(parentFragmentManager, "colorChooser")
+                }
+                // Add the action to the list of actions.
+                adapter.actions.add(colorAction!!)
+
+                // Setup an action to allow the user to select an Emoji for the conversation.
+                symbolAction = ContactAction(0, getText(R.string.conversation_preference_emoji)) {
+                    EmojiChooserBottomSheet { emoji -> // Emoji chosen by the user (onclick method).
+                        if (emoji == null) return@EmojiChooserBottomSheet
+                        mConversationFacade.setConversationPreferences(
+                            path.accountId,
+                            path.conversationUri,
+                            mapOf(Conversation.KEY_PREFERENCE_CONVERSATION_SYMBOL to emoji)
+                        )
+                        // Need to manually update the symbol of the conversation as will not get the
+                        // update signal from daemon.
+                        if(!path.conversationUri.isSwarm) conversation.setSymbol(emoji.toString())
+                    }.show(parentFragmentManager, "colorChooser")
+                }
+                adapter.actions.add(symbolAction!!)
             }
-            adapter.actions.add(symbolAction!!)
 
             // Update color on RX color signal.
             mDisposableBag.add(conversation.getColor()
-- 
GitLab