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.
- package/android/src/main/java/com/audiobrowser/model/PlayerUpdateOptions.kt +11 -11
- package/android/src/main/java/com/audiobrowser/player/CapabilityControls.kt +111 -58
- package/android/src/main/java/com/audiobrowser/player/MediaSessionCallback.kt +9 -5
- package/android/src/main/java/com/audiobrowser/player/MediaSessionCommandManager.kt +218 -252
- package/android/src/main/java/com/audiobrowser/player/Player.kt +19 -8
- package/android/src/test/java/com/audiobrowser/player/CapabilityControlsTest.kt +100 -56
- package/android/src/test/java/com/audiobrowser/player/MediaSessionSlotMappingTest.kt +45 -0
- package/lib/commonjs/features/player/options.js +45 -15
- package/lib/commonjs/features/player/options.js.map +1 -1
- package/lib/commonjs/features/player/setup.js +13 -6
- package/lib/commonjs/features/player/setup.js.map +1 -1
- package/lib/module/features/player/options.js +45 -15
- package/lib/module/features/player/options.js.map +1 -1
- package/lib/module/features/player/setup.js +13 -6
- package/lib/module/features/player/setup.js.map +1 -1
- package/lib/typescript/src/features/player/options.d.ts +86 -36
- package/lib/typescript/src/features/player/options.d.ts.map +1 -1
- package/lib/typescript/src/features/player/setup.d.ts +10 -3
- package/lib/typescript/src/features/player/setup.d.ts.map +1 -1
- package/nitrogen/generated/android/AudioBrowser+autolinking.cmake +1 -1
- package/nitrogen/generated/android/c++/JAndroidOptions.hpp +10 -10
- package/nitrogen/generated/android/c++/JFunc_void_Options.hpp +5 -5
- package/nitrogen/generated/android/c++/JHybridAudioBrowserSpec.cpp +9 -9
- package/nitrogen/generated/android/c++/JNativeSetupPlayerOptions.hpp +5 -5
- package/nitrogen/generated/android/c++/JNativeUpdateOptions.hpp +5 -5
- package/nitrogen/generated/android/c++/JNitroAndroidUpdateOptions.hpp +10 -10
- package/nitrogen/generated/android/c++/JOptions.hpp +5 -5
- package/nitrogen/generated/android/c++/{JNotificationButton.hpp → JRemoteButton.hpp} +19 -19
- package/nitrogen/generated/android/c++/JRemoteButtonLayout.hpp +86 -0
- package/nitrogen/generated/android/c++/JVariant_NullType_RemoteButtonLayout.cpp +26 -0
- package/nitrogen/generated/android/c++/JVariant_NullType_RemoteButtonLayout.hpp +75 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/audiobrowser/AndroidOptions.kt +3 -3
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/audiobrowser/NitroAndroidUpdateOptions.kt +3 -3
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/audiobrowser/{NotificationButton.kt → RemoteButton.kt} +3 -3
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/audiobrowser/RemoteButtonLayout.kt +44 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/audiobrowser/{Variant_NullType_NotificationButtonLayout.kt → Variant_NullType_RemoteButtonLayout.kt} +9 -9
- package/nitrogen/generated/ios/AudioBrowser-Swift-Cxx-Bridge.hpp +36 -51
- package/nitrogen/generated/ios/AudioBrowser-Swift-Cxx-Umbrella.hpp +6 -6
- package/nitrogen/generated/ios/c++/HybridAudioBrowserSpecSwift.hpp +6 -6
- package/nitrogen/generated/ios/swift/AndroidOptions.swift +12 -12
- package/nitrogen/generated/ios/swift/NitroAndroidUpdateOptions.swift +12 -12
- package/nitrogen/generated/ios/swift/{NotificationButton.swift → RemoteButton.swift} +6 -6
- package/nitrogen/generated/ios/swift/RemoteButtonLayout.swift +57 -0
- package/nitrogen/generated/ios/swift/{Variant_NullType_NotificationButtonLayout.swift → Variant_NullType_RemoteButtonLayout.swift} +3 -3
- package/nitrogen/generated/shared/c++/AndroidOptions.hpp +8 -8
- package/nitrogen/generated/shared/c++/NitroAndroidUpdateOptions.hpp +8 -8
- package/nitrogen/generated/shared/c++/{NotificationButton.hpp → RemoteButton.hpp} +19 -19
- package/nitrogen/generated/shared/c++/RemoteButtonLayout.hpp +94 -0
- package/package.json +1 -1
- package/src/features/player/options.ts +97 -37
- package/src/features/player/setup.test.ts +12 -4
- package/src/features/player/setup.ts +14 -7
- package/nitrogen/generated/android/c++/JNotificationButtonLayout.hpp +0 -94
- package/nitrogen/generated/android/c++/JVariant_NullType_NotificationButtonLayout.cpp +0 -26
- package/nitrogen/generated/android/c++/JVariant_NullType_NotificationButtonLayout.hpp +0 -75
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/audiobrowser/NotificationButtonLayout.kt +0 -50
- package/nitrogen/generated/ios/swift/NotificationButtonLayout.swift +0 -92
- 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:
|
|
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
|
|
121
|
-
*
|
|
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
|
|
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
|
-
*
|
|
132
|
-
* Allows explicit control over which buttons appear in which slots.
|
|
133
|
+
* Where each button sits on Android.
|
|
133
134
|
*
|
|
134
|
-
*
|
|
135
|
-
*
|
|
136
|
-
*
|
|
137
|
-
*
|
|
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
|
|
142
|
-
*
|
|
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
|
|
149
|
-
*
|
|
173
|
+
* // Music-style: skip either side of play/pause
|
|
174
|
+
* remoteButtonLayout: {
|
|
150
175
|
* back: 'skip-to-previous',
|
|
151
176
|
* forward: 'skip-to-next',
|
|
152
|
-
*
|
|
153
|
-
*
|
|
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
|
|
158
|
-
/**
|
|
159
|
-
back
|
|
160
|
-
/**
|
|
161
|
-
forward
|
|
162
|
-
/**
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
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
|
-
*
|
|
277
|
-
*
|
|
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,
|
|
319
|
+
* When not specified, the layout is derived from capabilities.
|
|
280
320
|
*
|
|
281
321
|
* @platform android
|
|
282
322
|
*/
|
|
283
|
-
|
|
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
|
-
*
|
|
304
|
-
*
|
|
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,
|
|
346
|
+
* When not specified, the layout is derived from capabilities.
|
|
307
347
|
*
|
|
308
348
|
* @platform android
|
|
309
349
|
*/
|
|
310
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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: {
|
|
96
|
+
android: { remoteButtonLayout: null }
|
|
89
97
|
})
|
|
90
98
|
|
|
91
99
|
expect(payload().options).toEqual({
|
|
92
100
|
progressUpdateEventInterval: null,
|
|
93
|
-
android: {
|
|
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} — `
|
|
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
|
|
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, `
|
|
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
|
-
* `
|
|
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: {
|
|
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
|
-
|
|
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
|
-
|
|
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
|
package/nitrogen/generated/android/kotlin/com/margelo/nitro/audiobrowser/NotificationButtonLayout.kt
DELETED
|
@@ -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
|
-
}
|