-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #231 from xmtp/cv/group-spike
Create LibXMTP Client - android
- Loading branch information
Showing
11 changed files
with
2,488 additions
and
1,971 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
28 changes: 28 additions & 0 deletions
28
android/src/main/java/expo/modules/xmtpreactnativesdk/wrappers/GroupWrapper.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,28 @@ | ||
package expo.modules.xmtpreactnativesdk.wrappers | ||
|
||
import android.util.Base64 | ||
import android.util.Base64.NO_WRAP | ||
import com.google.gson.GsonBuilder | ||
import org.xmtp.android.library.Client | ||
import org.xmtp.android.library.Group | ||
|
||
class GroupWrapper { | ||
|
||
companion object { | ||
private fun encodeToObj(client: Client, group: Group, idString: String): Map<String, Any> { | ||
return mapOf( | ||
"clientAddress" to client.address, | ||
"id" to idString, | ||
"createdAt" to group.createdAt.time, | ||
"peerAddresses" to group.memberAddresses(), | ||
|
||
) | ||
} | ||
|
||
fun encode(client: Client, group: Group): String { | ||
val gson = GsonBuilder().create() | ||
val obj = encodeToObj(client, group, Base64.encodeToString(group.id, NO_WRAP)) | ||
return gson.toJson(obj) | ||
} | ||
} | ||
} |
Oops, something went wrong.