Skip to content

Commit 2791440

Browse files
committed
add dates to example and a test around removing members
1 parent be8c3bc commit 2791440

File tree

3 files changed

+43
-7
lines changed

3 files changed

+43
-7
lines changed

example/src/main/java/org/xmtp/android/example/message/MessageViewHolder.kt

+5-1
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,9 @@ import org.xmtp.android.example.R
1111
import org.xmtp.android.example.conversation.ConversationDetailViewModel
1212
import org.xmtp.android.example.databinding.ListItemMessageBinding
1313
import org.xmtp.android.example.extension.margins
14-
import org.xmtp.proto.mls.message.contents.TranscriptMessages
1514
import uniffi.xmtpv3.org.xmtp.android.library.codecs.GroupMembershipChanges
15+
import java.text.SimpleDateFormat
16+
import java.util.Locale
1617

1718
class MessageViewHolder(
1819
private val binding: ListItemMessageBinding,
@@ -45,6 +46,9 @@ class MessageViewHolder(
4546
binding.messageContainer.layoutParams = params
4647
if (item.message.content<Any>() is String) {
4748
binding.messageBody.text = item.message.body
49+
val sdf = SimpleDateFormat("yyyy-MM-dd HH:mm:ss", Locale.getDefault())
50+
binding.messageDate.text = sdf.format(item.message.sent)
51+
4852
} else if (item.message.content<Any>() is GroupMembershipChanges) {
4953
val changes = item.message.content() as? GroupMembershipChanges
5054
binding.messageBody.text =

example/src/main/res/layout/list_item_message.xml

+18-6
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,25 @@
1515
app:cardCornerRadius="8dp"
1616
app:layout_constraintTop_toTopOf="parent"
1717
tools:ignore="MissingConstraints">
18-
19-
<TextView
20-
android:id="@+id/messageBody"
18+
<LinearLayout
2119
android:layout_width="wrap_content"
22-
android:layout_height="wrap_content"
23-
android:textSize="16sp"
24-
android:layout_margin="8dp" />
20+
android:layout_height="wrap_content">
21+
<TextView
22+
android:id="@+id/messageBody"
23+
android:layout_width="wrap_content"
24+
android:layout_height="wrap_content"
25+
android:textSize="16sp"
26+
android:layout_margin="8dp" />
27+
<TextView
28+
android:id="@+id/messageDate"
29+
android:layout_width="wrap_content"
30+
android:layout_height="wrap_content"
31+
android:textSize="16sp"
32+
android:layout_margin="8dp"
33+
/>
34+
</LinearLayout>
35+
36+
2537

2638
</androidx.cardview.widget.CardView>
2739

library/src/androidTest/java/org/xmtp/android/library/GroupTest.kt

+20
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,26 @@ class GroupTest {
112112
)
113113
}
114114

115+
@Test
116+
fun testCanRemoveGroupMembersWhenNotCreator() {
117+
boClient.conversations.newGroup(
118+
listOf(
119+
alix.walletAddress,
120+
caro.walletAddress
121+
)
122+
)
123+
runBlocking { alixClient.conversations.syncGroups() }
124+
val group = alixClient.conversations.listGroups().first()
125+
group.removeMembers(listOf(caro.walletAddress))
126+
assertEquals(
127+
group.memberAddresses().sorted(),
128+
listOf(
129+
alix.walletAddress.lowercase(),
130+
bo.walletAddress.lowercase()
131+
).sorted()
132+
)
133+
}
134+
115135
@Test
116136
fun testIsActiveReturnsCorrectly() {
117137
val group = boClient.conversations.newGroup(

0 commit comments

Comments
 (0)