react-native-audio-browser 0.2.0-next.3 → 0.2.0-next.5

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 +84 -35
  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 +95 -36
  51. package/src/features/player/setup.test.ts +12 -4
  52. package/src/features/player/setup.ts +13 -6
  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
@@ -117,10 +117,11 @@ export interface PlayerCapabilities {
117
117
  }
118
118
 
119
119
  /**
120
- * Buttons that can be assigned to Android notification button slots.
121
- * These represent the interactive buttons users can tap in the notification.
120
+ * Buttons that can be placed in the Android button layout — the interactive
121
+ * controls a listener taps in the notification, on the Android Auto Now Playing
122
+ * screen, and in the Android 13+ system media controls.
122
123
  */
123
- export type NotificationButton =
124
+ export type RemoteButton =
124
125
  | 'skip-to-previous'
125
126
  | 'skip-to-next'
126
127
  | 'jump-backward'
@@ -128,43 +129,71 @@ export type NotificationButton =
128
129
  | 'favorite'
129
130
 
130
131
  /**
131
- * Configuration for notification button layout on Android.
132
- * Allows explicit control over which buttons appear in which slots.
132
+ * Where each button sits on Android.
133
133
  *
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
134
+ * Android offers exactly three positions, and play/pause always occupies the
135
+ * centre — you cannot move it, and you cannot put two buttons on the same side
136
+ * of it:
137
+ *
138
+ * ```
139
+ * back │ ▶ play/pause │ forward overflow ⋯
140
+ * ```
141
+ *
142
+ * - **`back`** — the single position left of play/pause
143
+ * - **`forward`** — the single position right of play/pause
144
+ * - **`overflow`** — everything else, in priority order
145
+ *
146
+ * **A layout describes the whole arrangement.** All three fields are required —
147
+ * there is no per-field merge with the capability defaults, so what you write is
148
+ * exactly what renders. Use `undefined` for an empty position and `[]` for no
149
+ * overflow. To go back to the derived defaults, omit `remoteButtonLayout`
150
+ * entirely (or set it to `null`); that is the only switch.
151
+ *
152
+ * **Overflow order is priority, not coordinates.** Each surface renders as many
153
+ * buttons as it has room for, taking them from the front — a phone
154
+ * notification, the Android 13+ system media controls, and a car head unit all
155
+ * have different budgets. A head unit with a spare slot may promote the first
156
+ * overflow entry onto the main row, and a long list gets truncated by whichever
157
+ * surface is showing it. Put what matters most first.
158
+ *
159
+ * Placement never changes what a control *can* do: a button left out entirely
160
+ * still responds to a Bluetooth remote or headset, as long as its
161
+ * {@link PlayerCapabilities} entry is enabled.
138
162
  *
139
163
  * @example
140
164
  * ```typescript
141
- * // Podcast-style: jump buttons as primary
142
- * notificationButtons: {
165
+ * // Podcast-style: jump either side of play/pause
166
+ * remoteButtonLayout: {
143
167
  * back: 'jump-backward',
144
168
  * forward: 'jump-forward',
145
- * overflow: ['favorite']
169
+ * overflow: ['skip-to-previous', 'skip-to-next', 'favorite']
146
170
  * }
147
171
  *
148
- * // Music-style: skip as primary, jump as secondary
149
- * notificationButtons: {
172
+ * // Music-style: skip either side of play/pause
173
+ * remoteButtonLayout: {
150
174
  * back: 'skip-to-previous',
151
175
  * forward: 'skip-to-next',
152
- * backSecondary: 'jump-backward',
153
- * forwardSecondary: 'jump-forward'
176
+ * overflow: ['favorite']
177
+ * }
178
+ *
179
+ * // Live radio: forward only, nothing to the left
180
+ * remoteButtonLayout: {
181
+ * back: undefined,
182
+ * forward: 'skip-to-next',
183
+ * overflow: []
154
184
  * }
155
185
  * ```
156
186
  */
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[]
187
+ export type RemoteButtonLayout = {
188
+ /** The single position left of play/pause. `undefined` leaves it empty. */
189
+ back: RemoteButton | undefined
190
+ /** The single position right of play/pause. `undefined` leaves it empty. */
191
+ forward: RemoteButton | undefined
192
+ /**
193
+ * Everything else, most important first — surfaces promote and truncate from
194
+ * the front. `[]` for none.
195
+ */
196
+ overflow: RemoteButton[]
168
197
  }
169
198
 
170
199
  /**
@@ -204,12 +233,22 @@ export interface Options {
204
233
 
205
234
  /**
206
235
  * Jump forward interval in seconds when using jump forward controls.
236
+ *
237
+ * On Android, an interval of exactly 5, 10, 15 or 30 seconds gets an icon
238
+ * showing that number; any other interval gets an icon without one. Other
239
+ * values are perfectly valid — the interval also sets the seek distance.
240
+ *
207
241
  * @default 15
208
242
  */
209
243
  forwardJumpInterval: number
210
244
 
211
245
  /**
212
246
  * Jump backward interval in seconds when using jump backward controls.
247
+ *
248
+ * On Android, an interval of exactly 5, 10, 15 or 30 seconds gets an icon
249
+ * showing that number; any other interval gets an icon without one. Other
250
+ * values are perfectly valid — the interval also sets the seek distance.
251
+ *
213
252
  * @default 15
214
253
  */
215
254
  backwardJumpInterval: number
@@ -273,14 +312,14 @@ export interface AndroidOptions {
273
312
  skipSilence: boolean
274
313
 
275
314
  /**
276
- * Slot-based button layout for Android notifications.
277
- * Provides explicit control over which buttons appear in which positions.
315
+ * Ordered button layout, applied to the notification, Android Auto, and the
316
+ * Android 13+ system media controls. See {@link RemoteButtonLayout}.
278
317
  *
279
- * When not specified, button layout is derived from capabilities.
318
+ * When not specified, the layout is derived from capabilities.
280
319
  *
281
320
  * @platform android
282
321
  */
283
- notificationButtons: NotificationButtonLayout | null
322
+ remoteButtonLayout: RemoteButtonLayout | null
284
323
  }
285
324
 
286
325
  export interface AndroidUpdateOptions {
@@ -300,14 +339,14 @@ export interface AndroidUpdateOptions {
300
339
  skipSilence?: boolean
301
340
 
302
341
  /**
303
- * Slot-based button layout for Android notifications.
304
- * Provides explicit control over which buttons appear in which positions.
342
+ * Ordered button layout, applied to the notification, Android Auto, and the
343
+ * Android 13+ system media controls. See {@link RemoteButtonLayout}.
305
344
  *
306
- * When not specified, button layout is derived from capabilities.
345
+ * When not specified, the layout is derived from capabilities.
307
346
  *
308
347
  * @platform android
309
348
  */
310
- notificationButtons?: NotificationButtonLayout | null
349
+ remoteButtonLayout?: RemoteButtonLayout | null
311
350
  }
312
351
 
313
352
  /**
@@ -317,7 +356,7 @@ export interface AndroidUpdateOptions {
317
356
  export interface NitroAndroidUpdateOptions {
318
357
  appKilledPlaybackBehavior?: AppKilledPlaybackBehavior
319
358
  skipSilence?: boolean
320
- notificationButtons?: NotificationButtonLayout | null
359
+ remoteButtonLayout?: RemoteButtonLayout | null
321
360
  }
322
361
 
323
362
  /**
@@ -394,12 +433,22 @@ export interface UpdateOptions {
394
433
 
395
434
  /**
396
435
  * Jump forward interval in seconds when using jump forward controls.
436
+ *
437
+ * On Android, an interval of exactly 5, 10, 15 or 30 seconds gets an icon
438
+ * showing that number; any other interval gets an icon without one. Other
439
+ * values are perfectly valid — the interval also sets the seek distance.
440
+ *
397
441
  * @default 15
398
442
  */
399
443
  forwardJumpInterval?: number
400
444
 
401
445
  /**
402
446
  * Jump backward interval in seconds when using jump backward controls.
447
+ *
448
+ * On Android, an interval of exactly 5, 10, 15 or 30 seconds gets an icon
449
+ * showing that number; any other interval gets an icon without one. Other
450
+ * values are perfectly valid — the interval also sets the seek distance.
451
+ *
403
452
  * @default 15
404
453
  */
405
454
  backwardJumpInterval?: number
@@ -442,12 +491,22 @@ export interface NativeUpdateOptions {
442
491
 
443
492
  /**
444
493
  * Jump forward interval in seconds when using jump forward controls.
494
+ *
495
+ * On Android, an interval of exactly 5, 10, 15 or 30 seconds gets an icon
496
+ * showing that number; any other interval gets an icon without one. Other
497
+ * values are perfectly valid — the interval also sets the seek distance.
498
+ *
445
499
  * @default 15
446
500
  */
447
501
  forwardJumpInterval?: number
448
502
 
449
503
  /**
450
504
  * Jump backward interval in seconds when using jump backward controls.
505
+ *
506
+ * On Android, an interval of exactly 5, 10, 15 or 30 seconds gets an icon
507
+ * showing that number; any other interval gets an icon without one. Other
508
+ * values are perfectly valid — the interval also sets the seek distance.
509
+ *
451
510
  * @default 15
452
511
  */
453
512
  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
  */
@@ -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
- }
@@ -1,92 +0,0 @@
1
- ///
2
- /// NotificationButtonLayout.swift
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
- import NitroModules
9
-
10
- /**
11
- * Represents an instance of `NotificationButtonLayout`, backed by a C++ struct.
12
- */
13
- public typealias NotificationButtonLayout = margelo.nitro.audiobrowser.NotificationButtonLayout
14
-
15
- public extension NotificationButtonLayout {
16
- private typealias bridge = margelo.nitro.audiobrowser.bridge.swift
17
-
18
- /**
19
- * Create a new instance of `NotificationButtonLayout`.
20
- */
21
- init(back: NotificationButton?, forward: NotificationButton?, backSecondary: NotificationButton?, forwardSecondary: NotificationButton?, overflow: [NotificationButton]?) {
22
- self.init({ () -> bridge.std__optional_NotificationButton_ in
23
- if let __unwrappedValue = back {
24
- return bridge.create_std__optional_NotificationButton_(__unwrappedValue)
25
- } else {
26
- return .init()
27
- }
28
- }(), { () -> bridge.std__optional_NotificationButton_ in
29
- if let __unwrappedValue = forward {
30
- return bridge.create_std__optional_NotificationButton_(__unwrappedValue)
31
- } else {
32
- return .init()
33
- }
34
- }(), { () -> bridge.std__optional_NotificationButton_ in
35
- if let __unwrappedValue = backSecondary {
36
- return bridge.create_std__optional_NotificationButton_(__unwrappedValue)
37
- } else {
38
- return .init()
39
- }
40
- }(), { () -> bridge.std__optional_NotificationButton_ in
41
- if let __unwrappedValue = forwardSecondary {
42
- return bridge.create_std__optional_NotificationButton_(__unwrappedValue)
43
- } else {
44
- return .init()
45
- }
46
- }(), { () -> bridge.std__optional_std__vector_NotificationButton__ in
47
- if let __unwrappedValue = overflow {
48
- return bridge.create_std__optional_std__vector_NotificationButton__({ () -> bridge.std__vector_NotificationButton_ in
49
- var __vector = bridge.create_std__vector_NotificationButton_(__unwrappedValue.count)
50
- for __item in __unwrappedValue {
51
- __vector.push_back(__item)
52
- }
53
- return __vector
54
- }())
55
- } else {
56
- return .init()
57
- }
58
- }())
59
- }
60
-
61
- @inline(__always)
62
- var back: NotificationButton? {
63
- return self.__back.value
64
- }
65
-
66
- @inline(__always)
67
- var forward: NotificationButton? {
68
- return self.__forward.value
69
- }
70
-
71
- @inline(__always)
72
- var backSecondary: NotificationButton? {
73
- return self.__backSecondary.value
74
- }
75
-
76
- @inline(__always)
77
- var forwardSecondary: NotificationButton? {
78
- return self.__forwardSecondary.value
79
- }
80
-
81
- @inline(__always)
82
- var overflow: [NotificationButton]? {
83
- return { () -> [NotificationButton]? in
84
- if bridge.has_value_std__optional_std__vector_NotificationButton__(self.__overflow) {
85
- let __unwrapped = bridge.get_std__optional_std__vector_NotificationButton__(self.__overflow)
86
- return __unwrapped.map({ __item in __item })
87
- } else {
88
- return nil
89
- }
90
- }()
91
- }
92
- }