-
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.
simplify kotlin native module update
- Loading branch information
1 parent
04d4b80
commit 0bb8a1f
Showing
3 changed files
with
39 additions
and
53 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
51 changes: 0 additions & 51 deletions
51
android/src/main/java/expo/modules/xmtpreactnativesdk/wrappers/PermissionPolicySet.kt
This file was deleted.
Oops, something went wrong.
37 changes: 37 additions & 0 deletions
37
android/src/main/java/expo/modules/xmtpreactnativesdk/wrappers/PermissionPolicySetWrapper.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,37 @@ | ||
package expo.modules.xmtpreactnativesdk.wrappers | ||
|
||
import com.google.gson.GsonBuilder | ||
import uniffi.xmtpv3.org.xmtp.android.library.libxmtp.PermissionOption | ||
import uniffi.xmtpv3.org.xmtp.android.library.libxmtp.PermissionPolicySet | ||
|
||
class PermissionPolicySetWrapper { | ||
|
||
companion object { | ||
fun fromPermissionOption(permissionOption: PermissionOption): String { | ||
return when (permissionOption) { | ||
PermissionOption.Allow -> "allow" | ||
PermissionOption.Deny -> "deny" | ||
PermissionOption.Admin -> "admin" | ||
PermissionOption.SuperAdmin -> "superAdmin" | ||
PermissionOption.Unknown -> "unknown" | ||
} | ||
} | ||
fun encodeToObj(policySet: PermissionPolicySet): Map<String, Any> { | ||
return mapOf( | ||
"addMemberPolicy" to fromPermissionOption(policySet.addMemberPolicy), | ||
"removeMemberPolicy" to fromPermissionOption(policySet.removeMemberPolicy), | ||
"addAdminPolicy" to fromPermissionOption(policySet.addAdminPolicy), | ||
"removeAdminPolicy" to fromPermissionOption(policySet.removeAdminPolicy), | ||
"updateGroupNamePolicy" to fromPermissionOption(policySet.updateGroupNamePolicy), | ||
"updateGroupDescriptionPolicy" to fromPermissionOption(policySet.updateGroupDescriptionPolicy), | ||
"updateGroupImagePolicy" to fromPermissionOption(policySet.updateGroupImagePolicy), | ||
) | ||
} | ||
|
||
fun encodeToJsonString(policySet: PermissionPolicySet): String { | ||
val gson = GsonBuilder().create() | ||
val obj = encodeToObj(policySet) | ||
return gson.toJson(obj) | ||
} | ||
} | ||
} |