ReviewOS

also looking at this

craft-native/craft

feat(android): the shortcut pair in Zig — ratchet 75 → 73

#171
Merged chris wants to merge feat/android-shortcuts into main
6 files +602 -3
packages/android/templates/CraftNative.kt.templatemodified+26-0
Changes to packages/android/templates/CraftNative.kt.template
@@ -120,6 +120,8 @@ object CraftNative {
120120 private external fun nativeAddContact(activity: Activity, contactJson: String): Boolean
121121 private external fun nativeUpdateWidget(activity: Activity, action: String, dataJson: String): Boolean
122122 private external fun nativeReloadWidgets(activity: Activity, action: String): Boolean
123 private external fun nativeSetShortcuts(activity: Activity, shortcutsJson: String): Boolean
124 private external fun nativeClearShortcuts(activity: Activity): Boolean
123125
124126 /**
125127 * `getDeviceInfo`, or null to use the Kotlin implementation.
@@ -511,4 +513,28 @@ object CraftNative {
511513 false
512514 }
513515 }
516
517 /**
518 * The launcher's long-press menu.
519 *
520 * Both handle the pre-25 case themselves, and asymmetrically, because the
521 * Kotlin does: setting rejects with a message and clearing resolves true.
522 */
523 fun setShortcuts(activity: Activity, shortcutsJson: String): Boolean {
524 if (!isAvailable) return false
525 return try {
526 nativeSetShortcuts(activity, shortcutsJson)
527 } catch (e: UnsatisfiedLinkError) {
528 false
529 }
530 }
531
532 fun clearShortcuts(activity: Activity): Boolean {
533 if (!isAvailable) return false
534 return try {
535 nativeClearShortcuts(activity)
536 } catch (e: UnsatisfiedLinkError) {
537 false
538 }
539 }
514540}