also looking at this
feat(android): the shortcut pair in Zig — ratchet 75 → 73
#171
6 files
+602
-3
| @@ -120,6 +120,8 @@ object CraftNative { | ||
| 120 | 120 | private external fun nativeAddContact(activity: Activity, contactJson: String): Boolean |
| 121 | 121 | private external fun nativeUpdateWidget(activity: Activity, action: String, dataJson: String): Boolean |
| 122 | 122 | 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 | |
| 123 | 125 | |
| 124 | 126 | /** |
| 125 | 127 | * `getDeviceInfo`, or null to use the Kotlin implementation. |
| @@ -511,4 +513,28 @@ object CraftNative { | ||
| 511 | 513 | false |
| 512 | 514 | } |
| 513 | 515 | } |
| 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 | } | |
| 514 | 540 | } |