Skip to content
Snippets Groups Projects
Commit 07af4fcf authored by Pierre Nicolas's avatar Pierre Nicolas :joy: Committed by Adrien Béraud
Browse files

request: display correct conversation mode

For private swarm
- Display single avatar for "private swarm"
- Display "private swarm" instead of "group swarm"

GitLab: #1195
Change-Id: Id10f044f157f6aa1faff41699bf51a34b5e5b5ab
parent 1a9fd4bc
No related branches found
No related tags found
No related merge requests found
......@@ -138,12 +138,20 @@ class ConversationActionsFragment : Fragment(), Colorable {
// Setup card with
// - conversation type (such as "Private swarm")
// - conversation id (such as swarm:1234)"
// The real conversation mode is hidden in TrustRequest when it's a request.
val conversationMode =
if (conversation.mode.blockingFirst() == Conversation.Mode.Request)
conversation.request!!.mode
else conversation.mode.blockingFirst()
@StringRes val infoString =
if (conversation.isSwarm)
if (conversation.mode.blockingFirst() == Conversation.Mode.OneToOne)
if (conversation.isSwarm) {
if (conversationMode == Conversation.Mode.OneToOne)
R.string.conversation_type_private
else
else {
R.string.conversation_type_group
}
}
else R.string.conversation_type_contact
conversationType.setText(infoString)
val conversationUri = conversation.uri.toString()
......@@ -153,7 +161,7 @@ class ConversationActionsFragment : Fragment(), Colorable {
// Setup other actions depending on context
val callUri: Uri?
if (conversation.mode.blockingFirst() == Conversation.Mode.OneToOne) {
if (conversationMode == Conversation.Mode.OneToOne) {
callUri = conversation.contact!!.uri
if (!conversation.contact!!.isBanned) {
// Setup block contact action
......
......@@ -597,7 +597,9 @@ class NotificationServiceImpl(
.setIcon(if (myPic == null) null else IconCompat.createWithBitmap(myPic))
.build()
val history = NotificationCompat.MessagingStyle(userPerson)
history.isGroupConversation = cvm.isGroup()
// Even if it's a group conversation, if there is only two people in it,
// we don't want to display notification as a group (not necessary to surcharge).
history.isGroupConversation = cvm.isSwarm && cvm.contacts.size > 2
history.conversationTitle = conversationProfile.second
val persons = HashMap<String, Person>()
for (contact in cvm.contacts) {
......
......@@ -270,9 +270,8 @@ class AvatarDrawable : Drawable {
return this
}
fun withViewModel(vm: ConversationItemViewModel): Builder {
val isSwarm = vm.uri.isSwarm && vm.mode != Conversation.Mode.OneToOne
return if (isSwarm)
fun withViewModel(vm: ConversationItemViewModel): Builder =
if (vm.isGroup())
withId(vm.uri.rawRingId)
.withContacts(vm.conversationProfile, vm.contacts)
.setGroup()
......@@ -280,7 +279,6 @@ class AvatarDrawable : Drawable {
.withPresence(vm.showPresence)
.withOnlineState(vm.isOnline)
.withCheck(vm.isChecked)
}
fun build(context: Context): AvatarDrawable =
AvatarDrawable(context, photos, name, id, circleCrop, isGroup).also {
......
......@@ -121,7 +121,7 @@ class ConversationPresenter @Inject constructor(
} else if (c.mode == Conversation.Mode.Request) {
view.switchToIncomingTrustRequestView(c.uriTitle/*ConversationItemViewModel.getUriTitle(conversation.uri, contacts)*/)
} else if (c.isSwarm || account.isContact(c.uri)) {
if (!c.isGroup() && c.getContact()?.contact?.isBanned == true) {
if ((c.mode == Conversation.Mode.OneToOne) && c.getContact()?.contact?.isBanned == true) {
view.switchToBannedView()
} else
view.switchToConversationView()
......
......@@ -674,6 +674,8 @@ class Account(
conversation.setProfile(p)
}
conversation.request = request
//Log.w(TAG, "pendingRequestAdded $key")
pending[key] = conversation
if (!conversation.isSwarm) {
......
......@@ -68,6 +68,8 @@ class Conversation : ConversationHistory {
private var mDirty = false
private var mLoadingSubject: SingleSubject<Conversation>? = null
var request:TrustRequest? = null
val mode: Observable<Mode>
get() = mMode
val isSwarm: Boolean
......
......@@ -37,6 +37,7 @@ class ConversationItemViewModel(
var selected: Observable<Boolean>? = conversation.getVisible()
private set
val lastEvent: Interaction? = conversation.lastEvent
val request: TrustRequest? = conversation.request
enum class Title {
None, Conversations, PublicDirectory
......@@ -67,7 +68,14 @@ class ConversationItemViewModel(
return if (contacts.isNotEmpty()) contacts[0] else null
}
fun isGroup(): Boolean = isSwarm && contacts.size > 2
fun isGroup(): Boolean =
// SwarmGroup is a conversation were there are multiple participants (not a 1:1
// conversation). To know this, we need to check the conversation mode.
// However, conversation mode can also be a request. In this case, we need to check the
// request mode to know if it is a 1:1 conversation or not (request attribute).
if (mode == Conversation.Mode.Request)
request?.mode != Conversation.Mode.OneToOne
else mode != Conversation.Mode.OneToOne
override fun equals(other: Any?): Boolean {
if (other !is ConversationItemViewModel) return false
......
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