ReviewOS

also looking at this

craft-native/craft

feat(android): the shared-item trio in Zig — ratchet 82 → 79

#161
Merged glennmichael123 wants to merge feat/android-shared-items into main
6 files +463 -3
packages/android/templates/CraftBridge.kt.templatemodified+12-0
Changes to packages/android/templates/CraftBridge.kt.template
@@ -3333,6 +3333,10 @@ class CraftBridge(
33333333
33343334 @JavascriptInterface
33353335 fun setSharedItem(key: String, value: String, group: String) {
3336 // Zig answers through the reply channel, so returning here is what
3337 // stops the promise being settled twice.
3338 if (CraftNative.setSharedItem(activity, key, value, group)) return
3339
33363340 try {
33373341 val prefsName = if (group.isNotEmpty()) "craft_shared_$group" else "craft_shared"
33383342 val prefs = activity.getSharedPreferences(prefsName, Context.MODE_PRIVATE)
@@ -3356,6 +3360,10 @@ class CraftBridge(
33563360
33573361 @JavascriptInterface
33583362 fun getSharedItem(key: String, group: String) {
3363 // Zig answers through the reply channel, so returning here is what
3364 // stops the promise being settled twice.
3365 if (CraftNative.getSharedItem(activity, key, group)) return
3366
33593367 try {
33603368 val prefsName = if (group.isNotEmpty()) "craft_shared_$group" else "craft_shared"
33613369 val prefs = activity.getSharedPreferences(prefsName, Context.MODE_PRIVATE)
@@ -3386,6 +3394,10 @@ class CraftBridge(
33863394
33873395 @JavascriptInterface
33883396 fun removeSharedItem(key: String, group: String) {
3397 // Zig answers through the reply channel, so returning here is what
3398 // stops the promise being settled twice.
3399 if (CraftNative.removeSharedItem(activity, key, group)) return
3400
33893401 try {
33903402 val prefsName = if (group.isNotEmpty()) "craft_shared_$group" else "craft_shared"
33913403 val prefs = activity.getSharedPreferences(prefsName, Context.MODE_PRIVATE)