Skip to content

Commit

Permalink
add dates to example and a test around removing members
Browse files Browse the repository at this point in the history
  • Loading branch information
nplasterer committed Feb 14, 2024
1 parent be8c3bc commit 2791440
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,9 @@ import org.xmtp.android.example.R
import org.xmtp.android.example.conversation.ConversationDetailViewModel
import org.xmtp.android.example.databinding.ListItemMessageBinding
import org.xmtp.android.example.extension.margins
import org.xmtp.proto.mls.message.contents.TranscriptMessages
import uniffi.xmtpv3.org.xmtp.android.library.codecs.GroupMembershipChanges
import java.text.SimpleDateFormat
import java.util.Locale

class MessageViewHolder(
private val binding: ListItemMessageBinding,
Expand Down Expand Up @@ -45,6 +46,9 @@ class MessageViewHolder(
binding.messageContainer.layoutParams = params
if (item.message.content<Any>() is String) {
binding.messageBody.text = item.message.body
val sdf = SimpleDateFormat("yyyy-MM-dd HH:mm:ss", Locale.getDefault())
binding.messageDate.text = sdf.format(item.message.sent)

} else if (item.message.content<Any>() is GroupMembershipChanges) {
val changes = item.message.content() as? GroupMembershipChanges
binding.messageBody.text =
Expand Down
24 changes: 18 additions & 6 deletions example/src/main/res/layout/list_item_message.xml
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,25 @@
app:cardCornerRadius="8dp"
app:layout_constraintTop_toTopOf="parent"
tools:ignore="MissingConstraints">

<TextView
android:id="@+id/messageBody"
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="16sp"
android:layout_margin="8dp" />
android:layout_height="wrap_content">
<TextView
android:id="@+id/messageBody"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="16sp"
android:layout_margin="8dp" />
<TextView
android:id="@+id/messageDate"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="16sp"
android:layout_margin="8dp"
/>
</LinearLayout>



</androidx.cardview.widget.CardView>

Expand Down
20 changes: 20 additions & 0 deletions library/src/androidTest/java/org/xmtp/android/library/GroupTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,26 @@ class GroupTest {
)
}

@Test
fun testCanRemoveGroupMembersWhenNotCreator() {
boClient.conversations.newGroup(
listOf(
alix.walletAddress,
caro.walletAddress
)
)
runBlocking { alixClient.conversations.syncGroups() }
val group = alixClient.conversations.listGroups().first()
group.removeMembers(listOf(caro.walletAddress))
assertEquals(
group.memberAddresses().sorted(),
listOf(
alix.walletAddress.lowercase(),
bo.walletAddress.lowercase()
).sorted()
)
}

@Test
fun testIsActiveReturnsCorrectly() {
val group = boClient.conversations.newGroup(
Expand Down

0 comments on commit 2791440

Please sign in to comment.