Skip to content
Snippets Groups Projects
Commit 74a1b7c7 authored by Pierre Nicolas's avatar Pierre Nicolas :joy:
Browse files

conversation: fix symbol null

GitLab: #1507
Change-Id: I9e79ff80e35e01a84bdbb1bbcfc22ad36e4b5fe0
parent 05551ae4
No related branches found
No related tags found
No related merge requests found
......@@ -96,10 +96,11 @@ class ConversationActionsFragment : Fragment(), Colorable {
getText(R.string.conversation_preference_color)
) {
ColorChooserBottomSheet { color -> // Color chosen by the user (onclick method).
setConversationPreferences(
val rgbColor = String.format("#%06X", 0xFFFFFF and color)
mConversationFacade.setConversationPreferences(
path.accountId,
path.conversationUri,
color = color
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.
......@@ -113,10 +114,10 @@ class ConversationActionsFragment : Fragment(), Colorable {
symbolAction = ContactAction(0, getText(R.string.conversation_preference_emoji)) {
EmojiChooserBottomSheet { emoji -> // Emoji chosen by the user (onclick method).
if (emoji == null) return@EmojiChooserBottomSheet
setConversationPreferences(
mConversationFacade.setConversationPreferences(
path.accountId,
path.conversationUri,
emoji = emoji
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.
......@@ -291,25 +292,6 @@ class ConversationActionsFragment : Fragment(), Colorable {
adapter.notifyItemChanged(symbolActionPosition)
}
/**
* Set the conversation preferences.
* Always resend the color and emoji, even if they are not changed (to not reset).
*/
private fun setConversationPreferences(
accountId: String,
conversationUri: Uri,
color: Int? = colorAction?.iconTint,
emoji: String = symbolAction?.iconSymbol.toString(),
) {
mConversationFacade.setConversationPreferences(
accountId, conversationUri, mapOf(
Conversation.KEY_PREFERENCE_CONVERSATION_SYMBOL to emoji,
Conversation.KEY_PREFERENCE_CONVERSATION_COLOR to if (color != null)
String.format("#%06X", 0xFFFFFF and color) else ""
)
)
}
private fun copyAndShow(toCopy: String) {
val clipboard = requireActivity().getSystemService(AppCompatActivity.CLIPBOARD_SERVICE) as ClipboardManager
clipboard.setPrimaryClip(ClipData.newPlainText(getText(R.string.clip_contact_uri), toCopy))
......
......@@ -24,6 +24,7 @@ import io.reactivex.rxjava3.subjects.PublishSubject
import io.reactivex.rxjava3.subjects.SingleSubject
import io.reactivex.rxjava3.subjects.Subject
import net.jami.utils.Log
import net.jami.utils.StringUtils
import java.util.*
class Conversation : ConversationHistory {
......@@ -699,10 +700,9 @@ class Conversation : ConversationHistory {
// So we add FF in front of the color (full opacity).
color.onNext(colorValue.substring(1).toInt(16) or 0xFF000000.toInt())
} else color.onNext(0)
val symbolValue = preferences[KEY_PREFERENCE_CONVERSATION_SYMBOL]
if (symbolValue != null) {
symbol.onNext(symbolValue)
} else symbol.onNext("")
preferences[KEY_PREFERENCE_CONVERSATION_SYMBOL].let {
symbol.onNext(if (StringUtils.isOnlyEmoji(it)) it!! else "")
}
}
/** Tells if the conversation is a swarm:group with more than 2 participants (including user) */
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment