react-native-audio-browser 0.2.0-next.4 → 0.2.0-next.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (58) hide show
  1. package/android/src/main/java/com/audiobrowser/model/PlayerUpdateOptions.kt +11 -11
  2. package/android/src/main/java/com/audiobrowser/player/CapabilityControls.kt +111 -58
  3. package/android/src/main/java/com/audiobrowser/player/MediaSessionCallback.kt +9 -5
  4. package/android/src/main/java/com/audiobrowser/player/MediaSessionCommandManager.kt +218 -252
  5. package/android/src/main/java/com/audiobrowser/player/Player.kt +19 -8
  6. package/android/src/test/java/com/audiobrowser/player/CapabilityControlsTest.kt +100 -56
  7. package/android/src/test/java/com/audiobrowser/player/MediaSessionSlotMappingTest.kt +45 -0
  8. package/lib/commonjs/features/player/options.js +45 -15
  9. package/lib/commonjs/features/player/options.js.map +1 -1
  10. package/lib/commonjs/features/player/setup.js +13 -6
  11. package/lib/commonjs/features/player/setup.js.map +1 -1
  12. package/lib/module/features/player/options.js +45 -15
  13. package/lib/module/features/player/options.js.map +1 -1
  14. package/lib/module/features/player/setup.js +13 -6
  15. package/lib/module/features/player/setup.js.map +1 -1
  16. package/lib/typescript/src/features/player/options.d.ts +86 -36
  17. package/lib/typescript/src/features/player/options.d.ts.map +1 -1
  18. package/lib/typescript/src/features/player/setup.d.ts +10 -3
  19. package/lib/typescript/src/features/player/setup.d.ts.map +1 -1
  20. package/nitrogen/generated/android/AudioBrowser+autolinking.cmake +1 -1
  21. package/nitrogen/generated/android/c++/JAndroidOptions.hpp +10 -10
  22. package/nitrogen/generated/android/c++/JFunc_void_Options.hpp +5 -5
  23. package/nitrogen/generated/android/c++/JHybridAudioBrowserSpec.cpp +9 -9
  24. package/nitrogen/generated/android/c++/JNativeSetupPlayerOptions.hpp +5 -5
  25. package/nitrogen/generated/android/c++/JNativeUpdateOptions.hpp +5 -5
  26. package/nitrogen/generated/android/c++/JNitroAndroidUpdateOptions.hpp +10 -10
  27. package/nitrogen/generated/android/c++/JOptions.hpp +5 -5
  28. package/nitrogen/generated/android/c++/{JNotificationButton.hpp → JRemoteButton.hpp} +19 -19
  29. package/nitrogen/generated/android/c++/JRemoteButtonLayout.hpp +86 -0
  30. package/nitrogen/generated/android/c++/JVariant_NullType_RemoteButtonLayout.cpp +26 -0
  31. package/nitrogen/generated/android/c++/JVariant_NullType_RemoteButtonLayout.hpp +75 -0
  32. package/nitrogen/generated/android/kotlin/com/margelo/nitro/audiobrowser/AndroidOptions.kt +3 -3
  33. package/nitrogen/generated/android/kotlin/com/margelo/nitro/audiobrowser/NitroAndroidUpdateOptions.kt +3 -3
  34. package/nitrogen/generated/android/kotlin/com/margelo/nitro/audiobrowser/{NotificationButton.kt → RemoteButton.kt} +3 -3
  35. package/nitrogen/generated/android/kotlin/com/margelo/nitro/audiobrowser/RemoteButtonLayout.kt +44 -0
  36. package/nitrogen/generated/android/kotlin/com/margelo/nitro/audiobrowser/{Variant_NullType_NotificationButtonLayout.kt → Variant_NullType_RemoteButtonLayout.kt} +9 -9
  37. package/nitrogen/generated/ios/AudioBrowser-Swift-Cxx-Bridge.hpp +36 -51
  38. package/nitrogen/generated/ios/AudioBrowser-Swift-Cxx-Umbrella.hpp +6 -6
  39. package/nitrogen/generated/ios/c++/HybridAudioBrowserSpecSwift.hpp +6 -6
  40. package/nitrogen/generated/ios/swift/AndroidOptions.swift +12 -12
  41. package/nitrogen/generated/ios/swift/NitroAndroidUpdateOptions.swift +12 -12
  42. package/nitrogen/generated/ios/swift/{NotificationButton.swift → RemoteButton.swift} +6 -6
  43. package/nitrogen/generated/ios/swift/RemoteButtonLayout.swift +57 -0
  44. package/nitrogen/generated/ios/swift/{Variant_NullType_NotificationButtonLayout.swift → Variant_NullType_RemoteButtonLayout.swift} +3 -3
  45. package/nitrogen/generated/shared/c++/AndroidOptions.hpp +8 -8
  46. package/nitrogen/generated/shared/c++/NitroAndroidUpdateOptions.hpp +8 -8
  47. package/nitrogen/generated/shared/c++/{NotificationButton.hpp → RemoteButton.hpp} +19 -19
  48. package/nitrogen/generated/shared/c++/RemoteButtonLayout.hpp +94 -0
  49. package/package.json +1 -1
  50. package/src/features/player/options.ts +97 -37
  51. package/src/features/player/setup.test.ts +12 -4
  52. package/src/features/player/setup.ts +14 -7
  53. package/nitrogen/generated/android/c++/JNotificationButtonLayout.hpp +0 -94
  54. package/nitrogen/generated/android/c++/JVariant_NullType_NotificationButtonLayout.cpp +0 -26
  55. package/nitrogen/generated/android/c++/JVariant_NullType_NotificationButtonLayout.hpp +0 -75
  56. package/nitrogen/generated/android/kotlin/com/margelo/nitro/audiobrowser/NotificationButtonLayout.kt +0 -50
  57. package/nitrogen/generated/ios/swift/NotificationButtonLayout.swift +0 -92
  58. package/nitrogen/generated/shared/c++/NotificationButtonLayout.hpp +0 -102
@@ -70,7 +70,8 @@ export interface PlayerCapabilities {
70
70
  *
71
71
  * Turns on the favorite/like heart across all surfaces:
72
72
  * - iOS: Control Center + CarPlay now-playing.
73
- * - Android: notification button slot + Android Auto now-playing, and an
73
+ * - Android: a place in the {@link RemoteButtonLayout} — the notification,
74
+ * Android Auto and the Android 13+ system media controls — and an
74
75
  * (empty or filled) heart on playable browse rows.
75
76
  *
76
77
  * `match` controls how the ids from `setFavorites` are
@@ -117,10 +118,11 @@ export interface PlayerCapabilities {
117
118
  }
118
119
 
119
120
  /**
120
- * Buttons that can be assigned to Android notification button slots.
121
- * These represent the interactive buttons users can tap in the notification.
121
+ * Buttons that can be placed in the Android button layout — the interactive
122
+ * controls a listener taps in the notification, on the Android Auto Now Playing
123
+ * screen, and in the Android 13+ system media controls.
122
124
  */
123
- export type NotificationButton =
125
+ export type RemoteButton =
124
126
  | 'skip-to-previous'
125
127
  | 'skip-to-next'
126
128
  | 'jump-backward'
@@ -128,43 +130,71 @@ export type NotificationButton =
128
130
  | 'favorite'
129
131
 
130
132
  /**
131
- * Configuration for notification button layout on Android.
132
- * Allows explicit control over which buttons appear in which slots.
133
+ * Where each button sits on Android.
133
134
  *
134
- * Slot behavior:
135
- * - **Omit a slot**: Derive from capabilities (smart default)
136
- * - **Set to null**: Explicitly empty slot
137
- * - **Set to button**: Show that button in that slot
135
+ * Android offers exactly three positions, and play/pause always occupies the
136
+ * centre — you cannot move it, and you cannot put two buttons on the same side
137
+ * of it:
138
+ *
139
+ * ```
140
+ * back │ ▶ play/pause │ forward overflow ⋯
141
+ * ```
142
+ *
143
+ * - **`back`** — the single position left of play/pause
144
+ * - **`forward`** — the single position right of play/pause
145
+ * - **`overflow`** — everything else, in priority order
146
+ *
147
+ * **A layout describes the whole arrangement.** All three fields are required —
148
+ * there is no per-field merge with the capability defaults, so what you write is
149
+ * exactly what renders. Use `undefined` for an empty position and `[]` for no
150
+ * overflow. To go back to the derived defaults, omit `remoteButtonLayout`
151
+ * entirely (or set it to `null`); that is the only switch.
152
+ *
153
+ * **Overflow order is priority, not coordinates.** Each surface renders as many
154
+ * buttons as it has room for, taking them from the front — a phone
155
+ * notification, the Android 13+ system media controls, and a car head unit all
156
+ * have different budgets. A head unit with a spare slot may promote the first
157
+ * overflow entry onto the main row, and a long list gets truncated by whichever
158
+ * surface is showing it. Put what matters most first.
159
+ *
160
+ * Placement never changes what a control *can* do: a button left out entirely
161
+ * still responds to a Bluetooth remote or headset, as long as its
162
+ * {@link PlayerCapabilities} entry is enabled.
138
163
  *
139
164
  * @example
140
165
  * ```typescript
141
- * // Podcast-style: jump buttons as primary
142
- * notificationButtons: {
166
+ * // Podcast-style: jump either side of play/pause
167
+ * remoteButtonLayout: {
143
168
  * back: 'jump-backward',
144
169
  * forward: 'jump-forward',
145
- * overflow: ['favorite']
170
+ * overflow: ['skip-to-previous', 'skip-to-next', 'favorite']
146
171
  * }
147
172
  *
148
- * // Music-style: skip as primary, jump as secondary
149
- * notificationButtons: {
173
+ * // Music-style: skip either side of play/pause
174
+ * remoteButtonLayout: {
150
175
  * back: 'skip-to-previous',
151
176
  * forward: 'skip-to-next',
152
- * backSecondary: 'jump-backward',
153
- * forwardSecondary: 'jump-forward'
177
+ * overflow: ['favorite']
178
+ * }
179
+ *
180
+ * // Live radio: forward only, nothing to the left
181
+ * remoteButtonLayout: {
182
+ * back: undefined,
183
+ * forward: 'skip-to-next',
184
+ * overflow: []
154
185
  * }
155
186
  * ```
156
187
  */
157
- export type NotificationButtonLayout = {
158
- /** Primary back position (SLOT_BACK) - typically previous track or jump backward */
159
- back?: NotificationButton | null
160
- /** Primary forward position (SLOT_FORWARD) - typically next track or jump forward */
161
- forward?: NotificationButton | null
162
- /** Secondary back position (SLOT_BACK_SECONDARY) */
163
- backSecondary?: NotificationButton | null
164
- /** Secondary forward position (SLOT_FORWARD_SECONDARY) */
165
- forwardSecondary?: NotificationButton | null
166
- /** Additional buttons in overflow area (SLOT_OVERFLOW) */
167
- overflow?: NotificationButton[]
188
+ export type RemoteButtonLayout = {
189
+ /** The single position left of play/pause. `undefined` leaves it empty. */
190
+ back: RemoteButton | undefined
191
+ /** The single position right of play/pause. `undefined` leaves it empty. */
192
+ forward: RemoteButton | undefined
193
+ /**
194
+ * Everything else, most important first — surfaces promote and truncate from
195
+ * the front. `[]` for none.
196
+ */
197
+ overflow: RemoteButton[]
168
198
  }
169
199
 
170
200
  /**
@@ -204,12 +234,22 @@ export interface Options {
204
234
 
205
235
  /**
206
236
  * Jump forward interval in seconds when using jump forward controls.
237
+ *
238
+ * On Android, an interval of exactly 5, 10, 15 or 30 seconds gets an icon
239
+ * showing that number; any other interval gets an icon without one. Other
240
+ * values are perfectly valid — the interval also sets the seek distance.
241
+ *
207
242
  * @default 15
208
243
  */
209
244
  forwardJumpInterval: number
210
245
 
211
246
  /**
212
247
  * Jump backward interval in seconds when using jump backward controls.
248
+ *
249
+ * On Android, an interval of exactly 5, 10, 15 or 30 seconds gets an icon
250
+ * showing that number; any other interval gets an icon without one. Other
251
+ * values are perfectly valid — the interval also sets the seek distance.
252
+ *
213
253
  * @default 15
214
254
  */
215
255
  backwardJumpInterval: number
@@ -273,14 +313,14 @@ export interface AndroidOptions {
273
313
  skipSilence: boolean
274
314
 
275
315
  /**
276
- * Slot-based button layout for Android notifications.
277
- * Provides explicit control over which buttons appear in which positions.
316
+ * Ordered button layout, applied to the notification, Android Auto, and the
317
+ * Android 13+ system media controls. See {@link RemoteButtonLayout}.
278
318
  *
279
- * When not specified, button layout is derived from capabilities.
319
+ * When not specified, the layout is derived from capabilities.
280
320
  *
281
321
  * @platform android
282
322
  */
283
- notificationButtons: NotificationButtonLayout | null
323
+ remoteButtonLayout: RemoteButtonLayout | null
284
324
  }
285
325
 
286
326
  export interface AndroidUpdateOptions {
@@ -300,14 +340,14 @@ export interface AndroidUpdateOptions {
300
340
  skipSilence?: boolean
301
341
 
302
342
  /**
303
- * Slot-based button layout for Android notifications.
304
- * Provides explicit control over which buttons appear in which positions.
343
+ * Ordered button layout, applied to the notification, Android Auto, and the
344
+ * Android 13+ system media controls. See {@link RemoteButtonLayout}.
305
345
  *
306
- * When not specified, button layout is derived from capabilities.
346
+ * When not specified, the layout is derived from capabilities.
307
347
  *
308
348
  * @platform android
309
349
  */
310
- notificationButtons?: NotificationButtonLayout | null
350
+ remoteButtonLayout?: RemoteButtonLayout | null
311
351
  }
312
352
 
313
353
  /**
@@ -317,7 +357,7 @@ export interface AndroidUpdateOptions {
317
357
  export interface NitroAndroidUpdateOptions {
318
358
  appKilledPlaybackBehavior?: AppKilledPlaybackBehavior
319
359
  skipSilence?: boolean
320
- notificationButtons?: NotificationButtonLayout | null
360
+ remoteButtonLayout?: RemoteButtonLayout | null
321
361
  }
322
362
 
323
363
  /**
@@ -394,12 +434,22 @@ export interface UpdateOptions {
394
434
 
395
435
  /**
396
436
  * Jump forward interval in seconds when using jump forward controls.
437
+ *
438
+ * On Android, an interval of exactly 5, 10, 15 or 30 seconds gets an icon
439
+ * showing that number; any other interval gets an icon without one. Other
440
+ * values are perfectly valid — the interval also sets the seek distance.
441
+ *
397
442
  * @default 15
398
443
  */
399
444
  forwardJumpInterval?: number
400
445
 
401
446
  /**
402
447
  * Jump backward interval in seconds when using jump backward controls.
448
+ *
449
+ * On Android, an interval of exactly 5, 10, 15 or 30 seconds gets an icon
450
+ * showing that number; any other interval gets an icon without one. Other
451
+ * values are perfectly valid — the interval also sets the seek distance.
452
+ *
403
453
  * @default 15
404
454
  */
405
455
  backwardJumpInterval?: number
@@ -442,12 +492,22 @@ export interface NativeUpdateOptions {
442
492
 
443
493
  /**
444
494
  * Jump forward interval in seconds when using jump forward controls.
495
+ *
496
+ * On Android, an interval of exactly 5, 10, 15 or 30 seconds gets an icon
497
+ * showing that number; any other interval gets an icon without one. Other
498
+ * values are perfectly valid — the interval also sets the seek distance.
499
+ *
445
500
  * @default 15
446
501
  */
447
502
  forwardJumpInterval?: number
448
503
 
449
504
  /**
450
505
  * Jump backward interval in seconds when using jump backward controls.
506
+ *
507
+ * On Android, an interval of exactly 5, 10, 15 or 30 seconds gets an icon
508
+ * showing that number; any other interval gets an icon without one. Other
509
+ * values are perfectly valid — the interval also sets the seek distance.
510
+ *
451
511
  * @default 15
452
512
  */
453
513
  backwardJumpInterval?: number
@@ -52,7 +52,11 @@ describe('setupPlayer wire regrouping', () => {
52
52
  minBuffer: 50_000,
53
53
  wakeMode: 'network',
54
54
  skipSilence: true,
55
- notificationButtons: { overflow: ['favorite'] }
55
+ remoteButtonLayout: {
56
+ back: 'jump-backward',
57
+ forward: 'jump-forward',
58
+ overflow: ['favorite']
59
+ }
56
60
  }
57
61
  })
58
62
 
@@ -61,7 +65,11 @@ describe('setupPlayer wire regrouping', () => {
61
65
  expect(sent.options).toEqual({
62
66
  android: {
63
67
  skipSilence: true,
64
- notificationButtons: { overflow: ['favorite'] }
68
+ remoteButtonLayout: {
69
+ back: 'jump-backward',
70
+ forward: 'jump-forward',
71
+ overflow: ['favorite']
72
+ }
65
73
  }
66
74
  })
67
75
  })
@@ -85,12 +93,12 @@ describe('setupPlayer wire regrouping', () => {
85
93
  it('forwards meaningful nulls (progress disabled, empty button layout)', async () => {
86
94
  await setupPlayer({
87
95
  progressUpdateEventInterval: null,
88
- android: { notificationButtons: null }
96
+ android: { remoteButtonLayout: null }
89
97
  })
90
98
 
91
99
  expect(payload().options).toEqual({
92
100
  progressUpdateEventInterval: null,
93
- android: { notificationButtons: null }
101
+ android: { remoteButtonLayout: null }
94
102
  })
95
103
  })
96
104
 
@@ -326,7 +326,7 @@ export type AndroidPlayerWakeMode = 'none' | 'local' | 'network'
326
326
 
327
327
  /**
328
328
  * Android setup options: the engine-construction fields plus the Android runtime options
329
- * ({@link AndroidUpdateOptions} — `notificationButtons`, `skipSilence`, …), all expressible at
329
+ * ({@link AndroidUpdateOptions} — `remoteButtonLayout`, `skipSilence`, …), all expressible at
330
330
  * launch. The consumer never has to know which is which; `setupPlayer` routes each field to
331
331
  * where it's applied.
332
332
  */
@@ -496,7 +496,7 @@ export interface NativeSetupPlayerOptions extends Pick<
496
496
 
497
497
  /**
498
498
  * Player options to apply atomically with setup. They're stored before the player is
499
- * constructed, so e.g. Android's media session derives its notification buttons from
499
+ * constructed, so e.g. Android's media session derives its remote button layout from
500
500
  * `capabilities` the moment the service connects — no window with default controls.
501
501
  * Normalized from the flat fields on {@link SetupPlayerOptions}.
502
502
  */
@@ -658,7 +658,7 @@ function wrapNowPlayingFormatter(
658
658
 
659
659
  /**
660
660
  * The object's entries whose values aren't `undefined`. `null` stays: it's meaningful on some
661
- * fields (`progressUpdateEventInterval: null` disables progress events, `notificationButtons:
661
+ * fields (`progressUpdateEventInterval: null` disables progress events, `remoteButtonLayout:
662
662
  * null` empties the layout), so only `undefined` means "not provided".
663
663
  */
664
664
  function definedFields<T extends object>(obj: T): Partial<T> {
@@ -682,7 +682,7 @@ function nonEmpty<K extends string, T extends object>(
682
682
  /**
683
683
  * Initializes the player with the specified options — the full launch description in one
684
684
  * declarative, atomic call. Runtime options (`capabilities`, jump intervals,
685
- * `notificationButtons`, …) and the initial `playWhenReady` / `repeatMode` are applied
685
+ * `remoteButtonLayout`, …) and the initial `playWhenReady` / `repeatMode` are applied
686
686
  * natively as part of setup itself, so there is no setup-then-command ordering for consumers
687
687
  * to know about, and no window where the player exists without its options.
688
688
  *
@@ -699,7 +699,14 @@ function nonEmpty<K extends string, T extends object>(
699
699
  * playWhenReady: true,
700
700
  * repeatMode: 'queue',
701
701
  * capabilities: { favorite: true },
702
- * android: { audioContentType: 'music', notificationButtons: { overflow: ['favorite'] } },
702
+ * android: {
703
+ * audioContentType: 'music',
704
+ * remoteButtonLayout: {
705
+ * back: 'jump-backward',
706
+ * forward: 'jump-forward',
707
+ * overflow: ['favorite']
708
+ * }
709
+ * },
703
710
  * ios: { category: 'playback' }
704
711
  * })
705
712
  * ```
@@ -724,7 +731,7 @@ export async function setupPlayer(
724
731
  const {
725
732
  appKilledPlaybackBehavior,
726
733
  skipSilence,
727
- notificationButtons,
734
+ remoteButtonLayout,
728
735
  ...androidSetup
729
736
  } = android
730
737
  const {
@@ -750,7 +757,7 @@ export async function setupPlayer(
750
757
  definedFields({
751
758
  appKilledPlaybackBehavior,
752
759
  skipSilence,
753
- notificationButtons
760
+ remoteButtonLayout
754
761
  })
755
762
  ),
756
763
  ...nonEmpty('ios', iosUpdate)
@@ -1,94 +0,0 @@
1
- ///
2
- /// JNotificationButtonLayout.hpp
3
- /// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
4
- /// https://github.com/mrousavy/nitro
5
- /// Copyright © Marc Rousavy @ Margelo
6
- ///
7
-
8
- #pragma once
9
-
10
- #include <fbjni/fbjni.h>
11
- #include "NotificationButtonLayout.hpp"
12
-
13
- #include "JNotificationButton.hpp"
14
- #include "NotificationButton.hpp"
15
- #include <optional>
16
- #include <vector>
17
-
18
- namespace margelo::nitro::audiobrowser {
19
-
20
- using namespace facebook;
21
-
22
- /**
23
- * The C++ JNI bridge between the C++ struct "NotificationButtonLayout" and the the Kotlin data class "NotificationButtonLayout".
24
- */
25
- struct JNotificationButtonLayout final: public jni::JavaClass<JNotificationButtonLayout> {
26
- public:
27
- static auto constexpr kJavaDescriptor = "Lcom/margelo/nitro/audiobrowser/NotificationButtonLayout;";
28
-
29
- public:
30
- /**
31
- * Convert this Java/Kotlin-based struct to the C++ struct NotificationButtonLayout by copying all values to C++.
32
- */
33
- [[maybe_unused]]
34
- [[nodiscard]]
35
- NotificationButtonLayout toCpp() const {
36
- static const auto clazz = javaClassStatic();
37
- static const auto fieldBack = clazz->getField<JNotificationButton>("back");
38
- jni::local_ref<JNotificationButton> back = this->getFieldValue(fieldBack);
39
- static const auto fieldForward = clazz->getField<JNotificationButton>("forward");
40
- jni::local_ref<JNotificationButton> forward = this->getFieldValue(fieldForward);
41
- static const auto fieldBackSecondary = clazz->getField<JNotificationButton>("backSecondary");
42
- jni::local_ref<JNotificationButton> backSecondary = this->getFieldValue(fieldBackSecondary);
43
- static const auto fieldForwardSecondary = clazz->getField<JNotificationButton>("forwardSecondary");
44
- jni::local_ref<JNotificationButton> forwardSecondary = this->getFieldValue(fieldForwardSecondary);
45
- static const auto fieldOverflow = clazz->getField<jni::JArrayClass<JNotificationButton>>("overflow");
46
- jni::local_ref<jni::JArrayClass<JNotificationButton>> overflow = this->getFieldValue(fieldOverflow);
47
- return NotificationButtonLayout(
48
- back != nullptr ? std::make_optional(back->toCpp()) : std::nullopt,
49
- forward != nullptr ? std::make_optional(forward->toCpp()) : std::nullopt,
50
- backSecondary != nullptr ? std::make_optional(backSecondary->toCpp()) : std::nullopt,
51
- forwardSecondary != nullptr ? std::make_optional(forwardSecondary->toCpp()) : std::nullopt,
52
- overflow != nullptr ? std::make_optional([&]() {
53
- size_t __size = overflow->size();
54
- std::vector<NotificationButton> __vector;
55
- __vector.reserve(__size);
56
- for (size_t __i = 0; __i < __size; __i++) {
57
- auto __element = overflow->getElement(__i);
58
- __vector.push_back(__element->toCpp());
59
- }
60
- return __vector;
61
- }()) : std::nullopt
62
- );
63
- }
64
-
65
- public:
66
- /**
67
- * Create a Java/Kotlin-based struct by copying all values from the given C++ struct to Java.
68
- */
69
- [[maybe_unused]]
70
- static jni::local_ref<JNotificationButtonLayout::javaobject> fromCpp(const NotificationButtonLayout& value) {
71
- using JSignature = JNotificationButtonLayout(jni::alias_ref<JNotificationButton>, jni::alias_ref<JNotificationButton>, jni::alias_ref<JNotificationButton>, jni::alias_ref<JNotificationButton>, jni::alias_ref<jni::JArrayClass<JNotificationButton>>);
72
- static const auto clazz = javaClassStatic();
73
- static const auto create = clazz->getStaticMethod<JSignature>("fromCpp");
74
- return create(
75
- clazz,
76
- value.back.has_value() ? JNotificationButton::fromCpp(value.back.value()) : nullptr,
77
- value.forward.has_value() ? JNotificationButton::fromCpp(value.forward.value()) : nullptr,
78
- value.backSecondary.has_value() ? JNotificationButton::fromCpp(value.backSecondary.value()) : nullptr,
79
- value.forwardSecondary.has_value() ? JNotificationButton::fromCpp(value.forwardSecondary.value()) : nullptr,
80
- value.overflow.has_value() ? [&]() {
81
- size_t __size = value.overflow.value().size();
82
- jni::local_ref<jni::JArrayClass<JNotificationButton>> __array = jni::JArrayClass<JNotificationButton>::newArray(__size);
83
- for (size_t __i = 0; __i < __size; __i++) {
84
- const auto& __element = value.overflow.value()[__i];
85
- auto __elementJni = JNotificationButton::fromCpp(__element);
86
- __array->setElement(__i, *__elementJni);
87
- }
88
- return __array;
89
- }() : nullptr
90
- );
91
- }
92
- };
93
-
94
- } // namespace margelo::nitro::audiobrowser
@@ -1,26 +0,0 @@
1
- ///
2
- /// JVariant_NullType_NotificationButtonLayout.cpp
3
- /// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
4
- /// https://github.com/mrousavy/nitro
5
- /// Copyright © Marc Rousavy @ Margelo
6
- ///
7
-
8
- #include "JVariant_NullType_NotificationButtonLayout.hpp"
9
-
10
- namespace margelo::nitro::audiobrowser {
11
- /**
12
- * Converts JVariant_NullType_NotificationButtonLayout to std::variant<nitro::NullType, NotificationButtonLayout>
13
- */
14
- std::variant<nitro::NullType, NotificationButtonLayout> JVariant_NullType_NotificationButtonLayout::toCpp() const {
15
- if (isInstanceOf(JVariant_NullType_NotificationButtonLayout_impl::First::javaClassStatic())) {
16
- // It's a `nitro::NullType`
17
- auto jniValue = static_cast<const JVariant_NullType_NotificationButtonLayout_impl::First*>(this)->getValue();
18
- return nitro::null;
19
- } else if (isInstanceOf(JVariant_NullType_NotificationButtonLayout_impl::Second::javaClassStatic())) {
20
- // It's a `NotificationButtonLayout`
21
- auto jniValue = static_cast<const JVariant_NullType_NotificationButtonLayout_impl::Second*>(this)->getValue();
22
- return jniValue->toCpp();
23
- }
24
- throw std::invalid_argument("Variant is unknown Kotlin instance!");
25
- }
26
- } // namespace margelo::nitro::audiobrowser
@@ -1,75 +0,0 @@
1
- ///
2
- /// JVariant_NullType_NotificationButtonLayout.hpp
3
- /// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
4
- /// https://github.com/mrousavy/nitro
5
- /// Copyright © Marc Rousavy @ Margelo
6
- ///
7
-
8
- #pragma once
9
-
10
- #include <fbjni/fbjni.h>
11
- #include <variant>
12
-
13
- #include <NitroModules/Null.hpp>
14
- #include "NotificationButtonLayout.hpp"
15
- #include <variant>
16
- #include <NitroModules/JNull.hpp>
17
- #include "JNotificationButtonLayout.hpp"
18
- #include "NotificationButton.hpp"
19
- #include <optional>
20
- #include "JNotificationButton.hpp"
21
- #include <vector>
22
-
23
- namespace margelo::nitro::audiobrowser {
24
-
25
- using namespace facebook;
26
-
27
- /**
28
- * The C++ JNI bridge between the C++ std::variant and the Java class "Variant_NullType_NotificationButtonLayout".
29
- */
30
- class JVariant_NullType_NotificationButtonLayout: public jni::JavaClass<JVariant_NullType_NotificationButtonLayout> {
31
- public:
32
- static auto constexpr kJavaDescriptor = "Lcom/margelo/nitro/audiobrowser/Variant_NullType_NotificationButtonLayout;";
33
-
34
- static jni::local_ref<JVariant_NullType_NotificationButtonLayout> create_0(jni::alias_ref<JNull> value) {
35
- static const auto method = javaClassStatic()->getStaticMethod<JVariant_NullType_NotificationButtonLayout(jni::alias_ref<JNull>)>("create");
36
- return method(javaClassStatic(), value);
37
- }
38
- static jni::local_ref<JVariant_NullType_NotificationButtonLayout> create_1(jni::alias_ref<JNotificationButtonLayout> value) {
39
- static const auto method = javaClassStatic()->getStaticMethod<JVariant_NullType_NotificationButtonLayout(jni::alias_ref<JNotificationButtonLayout>)>("create");
40
- return method(javaClassStatic(), value);
41
- }
42
-
43
- static jni::local_ref<JVariant_NullType_NotificationButtonLayout> fromCpp(const std::variant<nitro::NullType, NotificationButtonLayout>& variant) {
44
- switch (variant.index()) {
45
- case 0: return create_0(JNull::null());
46
- case 1: return create_1(JNotificationButtonLayout::fromCpp(std::get<1>(variant)));
47
- default: throw std::invalid_argument("Variant holds unknown index! (" + std::to_string(variant.index()) + ")");
48
- }
49
- }
50
-
51
- [[nodiscard]] std::variant<nitro::NullType, NotificationButtonLayout> toCpp() const;
52
- };
53
-
54
- namespace JVariant_NullType_NotificationButtonLayout_impl {
55
- class First final: public jni::JavaClass<First, JVariant_NullType_NotificationButtonLayout> {
56
- public:
57
- static auto constexpr kJavaDescriptor = "Lcom/margelo/nitro/audiobrowser/Variant_NullType_NotificationButtonLayout$First;";
58
-
59
- [[nodiscard]] jni::local_ref<JNull> getValue() const {
60
- static const auto field = javaClassStatic()->getField<JNull>("value");
61
- return getFieldValue(field);
62
- }
63
- };
64
-
65
- class Second final: public jni::JavaClass<Second, JVariant_NullType_NotificationButtonLayout> {
66
- public:
67
- static auto constexpr kJavaDescriptor = "Lcom/margelo/nitro/audiobrowser/Variant_NullType_NotificationButtonLayout$Second;";
68
-
69
- [[nodiscard]] jni::local_ref<JNotificationButtonLayout> getValue() const {
70
- static const auto field = javaClassStatic()->getField<JNotificationButtonLayout>("value");
71
- return getFieldValue(field);
72
- }
73
- };
74
- } // namespace JVariant_NullType_NotificationButtonLayout_impl
75
- } // namespace margelo::nitro::audiobrowser
@@ -1,50 +0,0 @@
1
- ///
2
- /// NotificationButtonLayout.kt
3
- /// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
4
- /// https://github.com/mrousavy/nitro
5
- /// Copyright © Marc Rousavy @ Margelo
6
- ///
7
-
8
- package com.margelo.nitro.audiobrowser
9
-
10
- import androidx.annotation.Keep
11
- import com.facebook.proguard.annotations.DoNotStrip
12
-
13
-
14
- /**
15
- * Represents the JavaScript object/struct "NotificationButtonLayout".
16
- */
17
- @DoNotStrip
18
- @Keep
19
- data class NotificationButtonLayout(
20
- @DoNotStrip
21
- @Keep
22
- val back: NotificationButton?,
23
- @DoNotStrip
24
- @Keep
25
- val forward: NotificationButton?,
26
- @DoNotStrip
27
- @Keep
28
- val backSecondary: NotificationButton?,
29
- @DoNotStrip
30
- @Keep
31
- val forwardSecondary: NotificationButton?,
32
- @DoNotStrip
33
- @Keep
34
- val overflow: Array<NotificationButton>?
35
- ) {
36
- /* primary constructor */
37
-
38
- companion object {
39
- /**
40
- * Constructor called from C++
41
- */
42
- @DoNotStrip
43
- @Keep
44
- @Suppress("unused")
45
- @JvmStatic
46
- private fun fromCpp(back: NotificationButton?, forward: NotificationButton?, backSecondary: NotificationButton?, forwardSecondary: NotificationButton?, overflow: Array<NotificationButton>?): NotificationButtonLayout {
47
- return NotificationButtonLayout(back, forward, backSecondary, forwardSecondary, overflow)
48
- }
49
- }
50
- }