-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
first pass at all the pieces needed for threading
- Loading branch information
1 parent
1a1e055
commit fcb9921
Showing
8 changed files
with
2,559 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
package org.xmtp.android.library | ||
|
||
import org.xmtp.android.library.libxmtp.Message | ||
import uniffi.xmtp_dh.FfiGroup | ||
import uniffi.xmtp_dh.FfiListMessagesOptions | ||
|
||
class Group(val client: Client, val libXMTPGroup: FfiGroup) { | ||
val id: List<UByte> | ||
get() = libXMTPGroup.id() | ||
|
||
suspend fun send(text: String) { | ||
libXMTPGroup.send(contentBytes = text.toByteArray(Charsets.UTF_8).toUByteArray().toList()) | ||
} | ||
|
||
suspend fun messages(): List<Message> { | ||
return libXMTPGroup.findMessages( | ||
opts = FfiListMessagesOptions( | ||
sentBeforeNs = null, | ||
sentAfterNs = null, | ||
limit = null | ||
) | ||
).map { | ||
Message(client, it) | ||
} | ||
} | ||
} |
5 changes: 5 additions & 0 deletions
5
library/src/main/java/org/xmtp/android/library/libxmtp/InboxOwner.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
package uniffi.xmtp_dh.org.xmtp.android.library.libxmtp | ||
|
||
import uniffi.xmtp_dh.FfiInboxOwner | ||
|
||
interface InboxOwner : FfiInboxOwner {} |
16 changes: 16 additions & 0 deletions
16
library/src/main/java/org/xmtp/android/library/libxmtp/Message.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
package org.xmtp.android.library.libxmtp | ||
|
||
import org.xmtp.android.library.Client | ||
import uniffi.xmtp_dh.FfiMessage | ||
|
||
data class Message(val client: Client, val libXMTPMessage: FfiMessage) { | ||
val id: ByteArray | ||
get() = libXMTPMessage.id | ||
|
||
val senderAddress: String | ||
get() = libXMTPMessage.addrFrom | ||
|
||
fun text(): String { | ||
return libXMTPMessage.content.decodeToString() | ||
} | ||
} |
10 changes: 10 additions & 0 deletions
10
library/src/main/java/org/xmtp/android/library/libxmtp/XMTPLogger.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
package uniffi.xmtp_dh.org.xmtp.android.library.libxmtp | ||
|
||
import android.util.Log | ||
import uniffi.xmtp_dh.FfiLogger | ||
|
||
class XMTPLogger : FfiLogger { | ||
override fun log(level: UInt, levelLabel: String, message: String) { | ||
Log.i("$level $levelLabel", message) | ||
} | ||
} |
Oops, something went wrong.