@onekeyfe/react-native-device-utils 6.7.0-2 → 6.7.0-21
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/margelo/nitro/reactnativedeviceutils/ReactNativeDeviceUtils.kt +61 -6
- package/ios/DualScreenDetector.swift +170 -0
- package/ios/MainMenuController.swift +170 -0
- package/ios/ReactNativeDeviceUtils.swift +29 -4
- package/ios/WindowControlsInsetsObserver.swift +151 -0
- package/lib/typescript/src/ReactNativeDeviceUtils.nitro.d.ts +46 -0
- package/nitrogen/generated/android/c++/JFunc_void_MainMenuCommand.hpp +77 -0
- package/nitrogen/generated/android/c++/JFunc_void_WindowControlsInsets.hpp +77 -0
- package/nitrogen/generated/android/c++/JHybridReactNativeDeviceUtilsSpec.cpp +45 -0
- package/nitrogen/generated/android/c++/JHybridReactNativeDeviceUtilsSpec.hpp +6 -0
- package/nitrogen/generated/android/c++/JMainMenuCommand.hpp +61 -0
- package/nitrogen/generated/android/c++/JMainMenuConfig.hpp +90 -0
- package/nitrogen/generated/android/c++/JMainMenuLink.hpp +61 -0
- package/nitrogen/generated/android/c++/JWindowControlsInsets.hpp +69 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/reactnativedeviceutils/Func_void_MainMenuCommand.kt +78 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/reactnativedeviceutils/Func_void_WindowControlsInsets.kt +78 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/reactnativedeviceutils/HybridReactNativeDeviceUtilsSpec.kt +34 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/reactnativedeviceutils/MainMenuCommand.kt +24 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/reactnativedeviceutils/MainMenuConfig.kt +66 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/reactnativedeviceutils/MainMenuLink.kt +56 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/reactnativedeviceutils/WindowControlsInsets.kt +66 -0
- package/nitrogen/generated/android/reactnativedeviceutilsOnLoad.cpp +4 -0
- package/nitrogen/generated/ios/ReactNativeDeviceUtils-Swift-Cxx-Bridge.cpp +16 -0
- package/nitrogen/generated/ios/ReactNativeDeviceUtils-Swift-Cxx-Bridge.hpp +73 -0
- package/nitrogen/generated/ios/ReactNativeDeviceUtils-Swift-Cxx-Umbrella.hpp +12 -0
- package/nitrogen/generated/ios/c++/HybridReactNativeDeviceUtilsSpecSwift.hpp +55 -1
- package/nitrogen/generated/ios/swift/Func_void_MainMenuCommand.swift +46 -0
- package/nitrogen/generated/ios/swift/Func_void_WindowControlsInsets.swift +46 -0
- package/nitrogen/generated/ios/swift/HybridReactNativeDeviceUtilsSpec.swift +6 -0
- package/nitrogen/generated/ios/swift/HybridReactNativeDeviceUtilsSpec_cxx.swift +79 -0
- package/nitrogen/generated/ios/swift/MainMenuCommand.swift +44 -0
- package/nitrogen/generated/ios/swift/MainMenuConfig.swift +50 -0
- package/nitrogen/generated/ios/swift/MainMenuLink.swift +34 -0
- package/nitrogen/generated/ios/swift/WindowControlsInsets.swift +44 -0
- package/nitrogen/generated/shared/c++/HybridReactNativeDeviceUtilsSpec.cpp +6 -0
- package/nitrogen/generated/shared/c++/HybridReactNativeDeviceUtilsSpec.hpp +15 -0
- package/nitrogen/generated/shared/c++/MainMenuCommand.hpp +80 -0
- package/nitrogen/generated/shared/c++/MainMenuConfig.hpp +98 -0
- package/nitrogen/generated/shared/c++/MainMenuLink.hpp +87 -0
- package/nitrogen/generated/shared/c++/WindowControlsInsets.hpp +95 -0
- package/package.json +1 -1
- package/src/ReactNativeDeviceUtils.nitro.ts +54 -0
|
@@ -9,6 +9,35 @@ export interface DualScreenInfoRect {
|
|
|
9
9
|
width: number;
|
|
10
10
|
height: number;
|
|
11
11
|
}
|
|
12
|
+
/**
|
|
13
|
+
* Extra room, in points beyond the safe area, that content near the window
|
|
14
|
+
* corners must leave for system window controls (the iPadOS window controls in
|
|
15
|
+
* the top-leading corner, for example). All zero when no controls are shown.
|
|
16
|
+
*/
|
|
17
|
+
export interface WindowControlsInsets {
|
|
18
|
+
top: number;
|
|
19
|
+
left: number;
|
|
20
|
+
bottom: number;
|
|
21
|
+
right: number;
|
|
22
|
+
}
|
|
23
|
+
/** App commands in the iPadOS menu bar that JS performs. */
|
|
24
|
+
export type MainMenuCommand = 'about' | 'preferences' | 'lockNow';
|
|
25
|
+
export interface MainMenuLink {
|
|
26
|
+
title: string;
|
|
27
|
+
url: string;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Localized content of the custom main menu (the iPadOS menu bar). Help links
|
|
31
|
+
* open in the system browser natively; the other items notify JS. An empty
|
|
32
|
+
* `aboutTitle` removes the About item and empty `helpLinks` remove the Help
|
|
33
|
+
* menu.
|
|
34
|
+
*/
|
|
35
|
+
export interface MainMenuConfig {
|
|
36
|
+
aboutTitle: string;
|
|
37
|
+
preferencesTitle: string;
|
|
38
|
+
lockNowTitle: string;
|
|
39
|
+
helpLinks: MainMenuLink[];
|
|
40
|
+
}
|
|
12
41
|
export interface LaunchOptions {
|
|
13
42
|
launchType: string;
|
|
14
43
|
deepLink?: string;
|
|
@@ -43,6 +72,23 @@ export interface ReactNativeDeviceUtils extends HybridObject<{
|
|
|
43
72
|
addSpanningChangedListener(callback: (isSpanning: boolean) => void): number;
|
|
44
73
|
removeSpanningChangedListener(id: number): void;
|
|
45
74
|
setUserInterfaceStyle(style: UserInterfaceStyle): void;
|
|
75
|
+
/**
|
|
76
|
+
* Window-controls insets of the app's main window, for content that adapts
|
|
77
|
+
* horizontally (a header row beside the controls). iOS 26+ reads UIKit's
|
|
78
|
+
* safe area with horizontal corner adaptation; Android and older iOS return
|
|
79
|
+
* all zeros. Listeners fire on the main thread when the value changes.
|
|
80
|
+
*/
|
|
81
|
+
getWindowControlsInsets(): WindowControlsInsets;
|
|
82
|
+
addWindowControlsInsetsChangedListener(callback: (insets: WindowControlsInsets) => void): number;
|
|
83
|
+
removeWindowControlsInsetsChangedListener(id: number): void;
|
|
84
|
+
/**
|
|
85
|
+
* Replaces the custom main menu content and rebuilds the menu bar. The menu
|
|
86
|
+
* only shows on iPadOS (and in windows with a menu bar); Android ignores it.
|
|
87
|
+
*/
|
|
88
|
+
setMainMenuConfig(config: MainMenuConfig): void;
|
|
89
|
+
/** Listeners fire on the main thread when the user picks an app command. */
|
|
90
|
+
addMainMenuCommandListener(callback: (command: MainMenuCommand) => void): number;
|
|
91
|
+
removeMainMenuCommandListener(id: number): void;
|
|
46
92
|
getLaunchOptions(): Promise<LaunchOptions>;
|
|
47
93
|
clearLaunchOptions(): Promise<boolean>;
|
|
48
94
|
getDeviceToken(): Promise<string>;
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// JFunc_void_MainMenuCommand.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 <functional>
|
|
12
|
+
|
|
13
|
+
#include "MainMenuCommand.hpp"
|
|
14
|
+
#include <functional>
|
|
15
|
+
#include <NitroModules/JNICallable.hpp>
|
|
16
|
+
#include "JMainMenuCommand.hpp"
|
|
17
|
+
|
|
18
|
+
namespace margelo::nitro::reactnativedeviceutils {
|
|
19
|
+
|
|
20
|
+
using namespace facebook;
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* Represents the Java/Kotlin callback `(command: MainMenuCommand) -> Unit`.
|
|
24
|
+
* This can be passed around between C++ and Java/Kotlin.
|
|
25
|
+
*/
|
|
26
|
+
struct JFunc_void_MainMenuCommand: public jni::JavaClass<JFunc_void_MainMenuCommand> {
|
|
27
|
+
public:
|
|
28
|
+
static constexpr auto kJavaDescriptor = "Lcom/margelo/nitro/reactnativedeviceutils/Func_void_MainMenuCommand;";
|
|
29
|
+
|
|
30
|
+
public:
|
|
31
|
+
/**
|
|
32
|
+
* Invokes the function this `JFunc_void_MainMenuCommand` instance holds through JNI.
|
|
33
|
+
*/
|
|
34
|
+
void invoke(MainMenuCommand command) const {
|
|
35
|
+
static const auto method = javaClassStatic()->getMethod<void(jni::alias_ref<JMainMenuCommand> /* command */)>("invoke");
|
|
36
|
+
method(self(), JMainMenuCommand::fromCpp(command));
|
|
37
|
+
}
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* An implementation of Func_void_MainMenuCommand that is backed by a C++ implementation (using `std::function<...>`)
|
|
42
|
+
*/
|
|
43
|
+
class JFunc_void_MainMenuCommand_cxx final: public jni::HybridClass<JFunc_void_MainMenuCommand_cxx, JFunc_void_MainMenuCommand> {
|
|
44
|
+
public:
|
|
45
|
+
static jni::local_ref<JFunc_void_MainMenuCommand::javaobject> fromCpp(const std::function<void(MainMenuCommand /* command */)>& func) {
|
|
46
|
+
return JFunc_void_MainMenuCommand_cxx::newObjectCxxArgs(func);
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
public:
|
|
50
|
+
/**
|
|
51
|
+
* Invokes the C++ `std::function<...>` this `JFunc_void_MainMenuCommand_cxx` instance holds.
|
|
52
|
+
*/
|
|
53
|
+
void invoke_cxx(jni::alias_ref<JMainMenuCommand> command) {
|
|
54
|
+
_func(command->toCpp());
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
public:
|
|
58
|
+
[[nodiscard]]
|
|
59
|
+
inline const std::function<void(MainMenuCommand /* command */)>& getFunction() const {
|
|
60
|
+
return _func;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
public:
|
|
64
|
+
static constexpr auto kJavaDescriptor = "Lcom/margelo/nitro/reactnativedeviceutils/Func_void_MainMenuCommand_cxx;";
|
|
65
|
+
static void registerNatives() {
|
|
66
|
+
registerHybrid({makeNativeMethod("invoke_cxx", JFunc_void_MainMenuCommand_cxx::invoke_cxx)});
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
private:
|
|
70
|
+
explicit JFunc_void_MainMenuCommand_cxx(const std::function<void(MainMenuCommand /* command */)>& func): _func(func) { }
|
|
71
|
+
|
|
72
|
+
private:
|
|
73
|
+
friend HybridBase;
|
|
74
|
+
std::function<void(MainMenuCommand /* command */)> _func;
|
|
75
|
+
};
|
|
76
|
+
|
|
77
|
+
} // namespace margelo::nitro::reactnativedeviceutils
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// JFunc_void_WindowControlsInsets.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 <functional>
|
|
12
|
+
|
|
13
|
+
#include "WindowControlsInsets.hpp"
|
|
14
|
+
#include <functional>
|
|
15
|
+
#include <NitroModules/JNICallable.hpp>
|
|
16
|
+
#include "JWindowControlsInsets.hpp"
|
|
17
|
+
|
|
18
|
+
namespace margelo::nitro::reactnativedeviceutils {
|
|
19
|
+
|
|
20
|
+
using namespace facebook;
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* Represents the Java/Kotlin callback `(insets: WindowControlsInsets) -> Unit`.
|
|
24
|
+
* This can be passed around between C++ and Java/Kotlin.
|
|
25
|
+
*/
|
|
26
|
+
struct JFunc_void_WindowControlsInsets: public jni::JavaClass<JFunc_void_WindowControlsInsets> {
|
|
27
|
+
public:
|
|
28
|
+
static constexpr auto kJavaDescriptor = "Lcom/margelo/nitro/reactnativedeviceutils/Func_void_WindowControlsInsets;";
|
|
29
|
+
|
|
30
|
+
public:
|
|
31
|
+
/**
|
|
32
|
+
* Invokes the function this `JFunc_void_WindowControlsInsets` instance holds through JNI.
|
|
33
|
+
*/
|
|
34
|
+
void invoke(const WindowControlsInsets& insets) const {
|
|
35
|
+
static const auto method = javaClassStatic()->getMethod<void(jni::alias_ref<JWindowControlsInsets> /* insets */)>("invoke");
|
|
36
|
+
method(self(), JWindowControlsInsets::fromCpp(insets));
|
|
37
|
+
}
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* An implementation of Func_void_WindowControlsInsets that is backed by a C++ implementation (using `std::function<...>`)
|
|
42
|
+
*/
|
|
43
|
+
class JFunc_void_WindowControlsInsets_cxx final: public jni::HybridClass<JFunc_void_WindowControlsInsets_cxx, JFunc_void_WindowControlsInsets> {
|
|
44
|
+
public:
|
|
45
|
+
static jni::local_ref<JFunc_void_WindowControlsInsets::javaobject> fromCpp(const std::function<void(const WindowControlsInsets& /* insets */)>& func) {
|
|
46
|
+
return JFunc_void_WindowControlsInsets_cxx::newObjectCxxArgs(func);
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
public:
|
|
50
|
+
/**
|
|
51
|
+
* Invokes the C++ `std::function<...>` this `JFunc_void_WindowControlsInsets_cxx` instance holds.
|
|
52
|
+
*/
|
|
53
|
+
void invoke_cxx(jni::alias_ref<JWindowControlsInsets> insets) {
|
|
54
|
+
_func(insets->toCpp());
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
public:
|
|
58
|
+
[[nodiscard]]
|
|
59
|
+
inline const std::function<void(const WindowControlsInsets& /* insets */)>& getFunction() const {
|
|
60
|
+
return _func;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
public:
|
|
64
|
+
static constexpr auto kJavaDescriptor = "Lcom/margelo/nitro/reactnativedeviceutils/Func_void_WindowControlsInsets_cxx;";
|
|
65
|
+
static void registerNatives() {
|
|
66
|
+
registerHybrid({makeNativeMethod("invoke_cxx", JFunc_void_WindowControlsInsets_cxx::invoke_cxx)});
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
private:
|
|
70
|
+
explicit JFunc_void_WindowControlsInsets_cxx(const std::function<void(const WindowControlsInsets& /* insets */)>& func): _func(func) { }
|
|
71
|
+
|
|
72
|
+
private:
|
|
73
|
+
friend HybridBase;
|
|
74
|
+
std::function<void(const WindowControlsInsets& /* insets */)> _func;
|
|
75
|
+
};
|
|
76
|
+
|
|
77
|
+
} // namespace margelo::nitro::reactnativedeviceutils
|
|
@@ -9,6 +9,8 @@
|
|
|
9
9
|
|
|
10
10
|
// Forward declaration of `DualScreenInfoRect` to properly resolve imports.
|
|
11
11
|
namespace margelo::nitro::reactnativedeviceutils { struct DualScreenInfoRect; }
|
|
12
|
+
// Forward declaration of `WindowControlsInsets` to properly resolve imports.
|
|
13
|
+
namespace margelo::nitro::reactnativedeviceutils { struct WindowControlsInsets; }
|
|
12
14
|
// Forward declaration of `LaunchOptions` to properly resolve imports.
|
|
13
15
|
namespace margelo::nitro::reactnativedeviceutils { struct LaunchOptions; }
|
|
14
16
|
// Forward declaration of `WebViewPackageInfo` to properly resolve imports.
|
|
@@ -21,12 +23,20 @@ namespace margelo::nitro::reactnativedeviceutils { enum class AndroidChannel; }
|
|
|
21
23
|
namespace margelo::nitro::reactnativedeviceutils { enum class InstallerPackageName; }
|
|
22
24
|
// Forward declaration of `UserInterfaceStyle` to properly resolve imports.
|
|
23
25
|
namespace margelo::nitro::reactnativedeviceutils { enum class UserInterfaceStyle; }
|
|
26
|
+
// Forward declaration of `MainMenuConfig` to properly resolve imports.
|
|
27
|
+
namespace margelo::nitro::reactnativedeviceutils { struct MainMenuConfig; }
|
|
28
|
+
// Forward declaration of `MainMenuLink` to properly resolve imports.
|
|
29
|
+
namespace margelo::nitro::reactnativedeviceutils { struct MainMenuLink; }
|
|
30
|
+
// Forward declaration of `MainMenuCommand` to properly resolve imports.
|
|
31
|
+
namespace margelo::nitro::reactnativedeviceutils { enum class MainMenuCommand; }
|
|
24
32
|
|
|
25
33
|
#include "DualScreenInfoRect.hpp"
|
|
26
34
|
#include <vector>
|
|
27
35
|
#include <NitroModules/Promise.hpp>
|
|
28
36
|
#include <NitroModules/JPromise.hpp>
|
|
29
37
|
#include "JDualScreenInfoRect.hpp"
|
|
38
|
+
#include "WindowControlsInsets.hpp"
|
|
39
|
+
#include "JWindowControlsInsets.hpp"
|
|
30
40
|
#include "LaunchOptions.hpp"
|
|
31
41
|
#include "JLaunchOptions.hpp"
|
|
32
42
|
#include <string>
|
|
@@ -47,6 +57,14 @@ namespace margelo::nitro::reactnativedeviceutils { enum class UserInterfaceStyle
|
|
|
47
57
|
#include <NitroModules/JNICallable.hpp>
|
|
48
58
|
#include "UserInterfaceStyle.hpp"
|
|
49
59
|
#include "JUserInterfaceStyle.hpp"
|
|
60
|
+
#include "JFunc_void_WindowControlsInsets.hpp"
|
|
61
|
+
#include "MainMenuConfig.hpp"
|
|
62
|
+
#include "JMainMenuConfig.hpp"
|
|
63
|
+
#include "MainMenuLink.hpp"
|
|
64
|
+
#include "JMainMenuLink.hpp"
|
|
65
|
+
#include "MainMenuCommand.hpp"
|
|
66
|
+
#include "JFunc_void_MainMenuCommand.hpp"
|
|
67
|
+
#include "JMainMenuCommand.hpp"
|
|
50
68
|
|
|
51
69
|
namespace margelo::nitro::reactnativedeviceutils {
|
|
52
70
|
|
|
@@ -157,6 +175,33 @@ namespace margelo::nitro::reactnativedeviceutils {
|
|
|
157
175
|
static const auto method = _javaPart->javaClassStatic()->getMethod<void(jni::alias_ref<JUserInterfaceStyle> /* style */)>("setUserInterfaceStyle");
|
|
158
176
|
method(_javaPart, JUserInterfaceStyle::fromCpp(style));
|
|
159
177
|
}
|
|
178
|
+
WindowControlsInsets JHybridReactNativeDeviceUtilsSpec::getWindowControlsInsets() {
|
|
179
|
+
static const auto method = _javaPart->javaClassStatic()->getMethod<jni::local_ref<JWindowControlsInsets>()>("getWindowControlsInsets");
|
|
180
|
+
auto __result = method(_javaPart);
|
|
181
|
+
return __result->toCpp();
|
|
182
|
+
}
|
|
183
|
+
double JHybridReactNativeDeviceUtilsSpec::addWindowControlsInsetsChangedListener(const std::function<void(const WindowControlsInsets& /* insets */)>& callback) {
|
|
184
|
+
static const auto method = _javaPart->javaClassStatic()->getMethod<double(jni::alias_ref<JFunc_void_WindowControlsInsets::javaobject> /* callback */)>("addWindowControlsInsetsChangedListener_cxx");
|
|
185
|
+
auto __result = method(_javaPart, JFunc_void_WindowControlsInsets_cxx::fromCpp(callback));
|
|
186
|
+
return __result;
|
|
187
|
+
}
|
|
188
|
+
void JHybridReactNativeDeviceUtilsSpec::removeWindowControlsInsetsChangedListener(double id) {
|
|
189
|
+
static const auto method = _javaPart->javaClassStatic()->getMethod<void(double /* id */)>("removeWindowControlsInsetsChangedListener");
|
|
190
|
+
method(_javaPart, id);
|
|
191
|
+
}
|
|
192
|
+
void JHybridReactNativeDeviceUtilsSpec::setMainMenuConfig(const MainMenuConfig& config) {
|
|
193
|
+
static const auto method = _javaPart->javaClassStatic()->getMethod<void(jni::alias_ref<JMainMenuConfig> /* config */)>("setMainMenuConfig");
|
|
194
|
+
method(_javaPart, JMainMenuConfig::fromCpp(config));
|
|
195
|
+
}
|
|
196
|
+
double JHybridReactNativeDeviceUtilsSpec::addMainMenuCommandListener(const std::function<void(MainMenuCommand /* command */)>& callback) {
|
|
197
|
+
static const auto method = _javaPart->javaClassStatic()->getMethod<double(jni::alias_ref<JFunc_void_MainMenuCommand::javaobject> /* callback */)>("addMainMenuCommandListener_cxx");
|
|
198
|
+
auto __result = method(_javaPart, JFunc_void_MainMenuCommand_cxx::fromCpp(callback));
|
|
199
|
+
return __result;
|
|
200
|
+
}
|
|
201
|
+
void JHybridReactNativeDeviceUtilsSpec::removeMainMenuCommandListener(double id) {
|
|
202
|
+
static const auto method = _javaPart->javaClassStatic()->getMethod<void(double /* id */)>("removeMainMenuCommandListener");
|
|
203
|
+
method(_javaPart, id);
|
|
204
|
+
}
|
|
160
205
|
std::shared_ptr<Promise<LaunchOptions>> JHybridReactNativeDeviceUtilsSpec::getLaunchOptions() {
|
|
161
206
|
static const auto method = _javaPart->javaClassStatic()->getMethod<jni::local_ref<JPromise::javaobject>()>("getLaunchOptions");
|
|
162
207
|
auto __result = method(_javaPart);
|
|
@@ -64,6 +64,12 @@ namespace margelo::nitro::reactnativedeviceutils {
|
|
|
64
64
|
double addSpanningChangedListener(const std::function<void(bool /* isSpanning */)>& callback) override;
|
|
65
65
|
void removeSpanningChangedListener(double id) override;
|
|
66
66
|
void setUserInterfaceStyle(UserInterfaceStyle style) override;
|
|
67
|
+
WindowControlsInsets getWindowControlsInsets() override;
|
|
68
|
+
double addWindowControlsInsetsChangedListener(const std::function<void(const WindowControlsInsets& /* insets */)>& callback) override;
|
|
69
|
+
void removeWindowControlsInsetsChangedListener(double id) override;
|
|
70
|
+
void setMainMenuConfig(const MainMenuConfig& config) override;
|
|
71
|
+
double addMainMenuCommandListener(const std::function<void(MainMenuCommand /* command */)>& callback) override;
|
|
72
|
+
void removeMainMenuCommandListener(double id) override;
|
|
67
73
|
std::shared_ptr<Promise<LaunchOptions>> getLaunchOptions() override;
|
|
68
74
|
std::shared_ptr<Promise<bool>> clearLaunchOptions() override;
|
|
69
75
|
std::shared_ptr<Promise<std::string>> getDeviceToken() override;
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// JMainMenuCommand.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 "MainMenuCommand.hpp"
|
|
12
|
+
|
|
13
|
+
namespace margelo::nitro::reactnativedeviceutils {
|
|
14
|
+
|
|
15
|
+
using namespace facebook;
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* The C++ JNI bridge between the C++ enum "MainMenuCommand" and the Kotlin enum "MainMenuCommand".
|
|
19
|
+
*/
|
|
20
|
+
struct JMainMenuCommand final: public jni::JavaClass<JMainMenuCommand> {
|
|
21
|
+
public:
|
|
22
|
+
static constexpr auto kJavaDescriptor = "Lcom/margelo/nitro/reactnativedeviceutils/MainMenuCommand;";
|
|
23
|
+
|
|
24
|
+
public:
|
|
25
|
+
/**
|
|
26
|
+
* Convert this Java/Kotlin-based enum to the C++ enum MainMenuCommand.
|
|
27
|
+
*/
|
|
28
|
+
[[maybe_unused]]
|
|
29
|
+
[[nodiscard]]
|
|
30
|
+
MainMenuCommand toCpp() const {
|
|
31
|
+
static const auto clazz = javaClassStatic();
|
|
32
|
+
static const auto fieldOrdinal = clazz->getField<int>("value");
|
|
33
|
+
int ordinal = this->getFieldValue(fieldOrdinal);
|
|
34
|
+
return static_cast<MainMenuCommand>(ordinal);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
public:
|
|
38
|
+
/**
|
|
39
|
+
* Create a Java/Kotlin-based enum with the given C++ enum's value.
|
|
40
|
+
*/
|
|
41
|
+
[[maybe_unused]]
|
|
42
|
+
static jni::alias_ref<JMainMenuCommand> fromCpp(MainMenuCommand value) {
|
|
43
|
+
static const auto clazz = javaClassStatic();
|
|
44
|
+
switch (value) {
|
|
45
|
+
case MainMenuCommand::ABOUT:
|
|
46
|
+
static const auto fieldABOUT = clazz->getStaticField<JMainMenuCommand>("ABOUT");
|
|
47
|
+
return clazz->getStaticFieldValue(fieldABOUT);
|
|
48
|
+
case MainMenuCommand::PREFERENCES:
|
|
49
|
+
static const auto fieldPREFERENCES = clazz->getStaticField<JMainMenuCommand>("PREFERENCES");
|
|
50
|
+
return clazz->getStaticFieldValue(fieldPREFERENCES);
|
|
51
|
+
case MainMenuCommand::LOCKNOW:
|
|
52
|
+
static const auto fieldLOCKNOW = clazz->getStaticField<JMainMenuCommand>("LOCKNOW");
|
|
53
|
+
return clazz->getStaticFieldValue(fieldLOCKNOW);
|
|
54
|
+
default:
|
|
55
|
+
std::string stringValue = std::to_string(static_cast<int>(value));
|
|
56
|
+
throw std::invalid_argument("Invalid enum value (" + stringValue + "!");
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
};
|
|
60
|
+
|
|
61
|
+
} // namespace margelo::nitro::reactnativedeviceutils
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// JMainMenuConfig.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 "MainMenuConfig.hpp"
|
|
12
|
+
|
|
13
|
+
#include "JMainMenuLink.hpp"
|
|
14
|
+
#include "MainMenuLink.hpp"
|
|
15
|
+
#include <string>
|
|
16
|
+
#include <vector>
|
|
17
|
+
|
|
18
|
+
namespace margelo::nitro::reactnativedeviceutils {
|
|
19
|
+
|
|
20
|
+
using namespace facebook;
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* The C++ JNI bridge between the C++ struct "MainMenuConfig" and the Kotlin data class "MainMenuConfig".
|
|
24
|
+
*/
|
|
25
|
+
struct JMainMenuConfig final: public jni::JavaClass<JMainMenuConfig> {
|
|
26
|
+
public:
|
|
27
|
+
static constexpr auto kJavaDescriptor = "Lcom/margelo/nitro/reactnativedeviceutils/MainMenuConfig;";
|
|
28
|
+
|
|
29
|
+
public:
|
|
30
|
+
/**
|
|
31
|
+
* Convert this Java/Kotlin-based struct to the C++ struct MainMenuConfig by copying all values to C++.
|
|
32
|
+
*/
|
|
33
|
+
[[maybe_unused]]
|
|
34
|
+
[[nodiscard]]
|
|
35
|
+
MainMenuConfig toCpp() const {
|
|
36
|
+
static const auto clazz = javaClassStatic();
|
|
37
|
+
static const auto fieldAboutTitle = clazz->getField<jni::JString>("aboutTitle");
|
|
38
|
+
jni::local_ref<jni::JString> aboutTitle = this->getFieldValue(fieldAboutTitle);
|
|
39
|
+
static const auto fieldPreferencesTitle = clazz->getField<jni::JString>("preferencesTitle");
|
|
40
|
+
jni::local_ref<jni::JString> preferencesTitle = this->getFieldValue(fieldPreferencesTitle);
|
|
41
|
+
static const auto fieldLockNowTitle = clazz->getField<jni::JString>("lockNowTitle");
|
|
42
|
+
jni::local_ref<jni::JString> lockNowTitle = this->getFieldValue(fieldLockNowTitle);
|
|
43
|
+
static const auto fieldHelpLinks = clazz->getField<jni::JArrayClass<JMainMenuLink>>("helpLinks");
|
|
44
|
+
jni::local_ref<jni::JArrayClass<JMainMenuLink>> helpLinks = this->getFieldValue(fieldHelpLinks);
|
|
45
|
+
return MainMenuConfig(
|
|
46
|
+
aboutTitle->toStdString(),
|
|
47
|
+
preferencesTitle->toStdString(),
|
|
48
|
+
lockNowTitle->toStdString(),
|
|
49
|
+
[&](auto&& __input) {
|
|
50
|
+
size_t __size = __input->size();
|
|
51
|
+
std::vector<MainMenuLink> __vector;
|
|
52
|
+
__vector.reserve(__size);
|
|
53
|
+
for (size_t __i = 0; __i < __size; __i++) {
|
|
54
|
+
auto __element = __input->getElement(__i);
|
|
55
|
+
__vector.push_back(__element->toCpp());
|
|
56
|
+
}
|
|
57
|
+
return __vector;
|
|
58
|
+
}(helpLinks)
|
|
59
|
+
);
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
public:
|
|
63
|
+
/**
|
|
64
|
+
* Create a Java/Kotlin-based struct by copying all values from the given C++ struct to Java.
|
|
65
|
+
*/
|
|
66
|
+
[[maybe_unused]]
|
|
67
|
+
static jni::local_ref<JMainMenuConfig::javaobject> fromCpp(const MainMenuConfig& value) {
|
|
68
|
+
using JSignature = JMainMenuConfig(jni::alias_ref<jni::JString>, jni::alias_ref<jni::JString>, jni::alias_ref<jni::JString>, jni::alias_ref<jni::JArrayClass<JMainMenuLink>>);
|
|
69
|
+
static const auto clazz = javaClassStatic();
|
|
70
|
+
static const auto create = clazz->getStaticMethod<JSignature>("fromCpp");
|
|
71
|
+
return create(
|
|
72
|
+
clazz,
|
|
73
|
+
jni::make_jstring(value.aboutTitle),
|
|
74
|
+
jni::make_jstring(value.preferencesTitle),
|
|
75
|
+
jni::make_jstring(value.lockNowTitle),
|
|
76
|
+
[&](auto&& __input) {
|
|
77
|
+
size_t __size = __input.size();
|
|
78
|
+
jni::local_ref<jni::JArrayClass<JMainMenuLink>> __array = jni::JArrayClass<JMainMenuLink>::newArray(__size);
|
|
79
|
+
for (size_t __i = 0; __i < __size; __i++) {
|
|
80
|
+
const auto& __element = __input[__i];
|
|
81
|
+
auto __elementJni = JMainMenuLink::fromCpp(__element);
|
|
82
|
+
__array->setElement(__i, *__elementJni);
|
|
83
|
+
}
|
|
84
|
+
return __array;
|
|
85
|
+
}(value.helpLinks)
|
|
86
|
+
);
|
|
87
|
+
}
|
|
88
|
+
};
|
|
89
|
+
|
|
90
|
+
} // namespace margelo::nitro::reactnativedeviceutils
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// JMainMenuLink.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 "MainMenuLink.hpp"
|
|
12
|
+
|
|
13
|
+
#include <string>
|
|
14
|
+
|
|
15
|
+
namespace margelo::nitro::reactnativedeviceutils {
|
|
16
|
+
|
|
17
|
+
using namespace facebook;
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* The C++ JNI bridge between the C++ struct "MainMenuLink" and the Kotlin data class "MainMenuLink".
|
|
21
|
+
*/
|
|
22
|
+
struct JMainMenuLink final: public jni::JavaClass<JMainMenuLink> {
|
|
23
|
+
public:
|
|
24
|
+
static constexpr auto kJavaDescriptor = "Lcom/margelo/nitro/reactnativedeviceutils/MainMenuLink;";
|
|
25
|
+
|
|
26
|
+
public:
|
|
27
|
+
/**
|
|
28
|
+
* Convert this Java/Kotlin-based struct to the C++ struct MainMenuLink by copying all values to C++.
|
|
29
|
+
*/
|
|
30
|
+
[[maybe_unused]]
|
|
31
|
+
[[nodiscard]]
|
|
32
|
+
MainMenuLink toCpp() const {
|
|
33
|
+
static const auto clazz = javaClassStatic();
|
|
34
|
+
static const auto fieldTitle = clazz->getField<jni::JString>("title");
|
|
35
|
+
jni::local_ref<jni::JString> title = this->getFieldValue(fieldTitle);
|
|
36
|
+
static const auto fieldUrl = clazz->getField<jni::JString>("url");
|
|
37
|
+
jni::local_ref<jni::JString> url = this->getFieldValue(fieldUrl);
|
|
38
|
+
return MainMenuLink(
|
|
39
|
+
title->toStdString(),
|
|
40
|
+
url->toStdString()
|
|
41
|
+
);
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
public:
|
|
45
|
+
/**
|
|
46
|
+
* Create a Java/Kotlin-based struct by copying all values from the given C++ struct to Java.
|
|
47
|
+
*/
|
|
48
|
+
[[maybe_unused]]
|
|
49
|
+
static jni::local_ref<JMainMenuLink::javaobject> fromCpp(const MainMenuLink& value) {
|
|
50
|
+
using JSignature = JMainMenuLink(jni::alias_ref<jni::JString>, jni::alias_ref<jni::JString>);
|
|
51
|
+
static const auto clazz = javaClassStatic();
|
|
52
|
+
static const auto create = clazz->getStaticMethod<JSignature>("fromCpp");
|
|
53
|
+
return create(
|
|
54
|
+
clazz,
|
|
55
|
+
jni::make_jstring(value.title),
|
|
56
|
+
jni::make_jstring(value.url)
|
|
57
|
+
);
|
|
58
|
+
}
|
|
59
|
+
};
|
|
60
|
+
|
|
61
|
+
} // namespace margelo::nitro::reactnativedeviceutils
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// JWindowControlsInsets.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 "WindowControlsInsets.hpp"
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
namespace margelo::nitro::reactnativedeviceutils {
|
|
16
|
+
|
|
17
|
+
using namespace facebook;
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* The C++ JNI bridge between the C++ struct "WindowControlsInsets" and the Kotlin data class "WindowControlsInsets".
|
|
21
|
+
*/
|
|
22
|
+
struct JWindowControlsInsets final: public jni::JavaClass<JWindowControlsInsets> {
|
|
23
|
+
public:
|
|
24
|
+
static constexpr auto kJavaDescriptor = "Lcom/margelo/nitro/reactnativedeviceutils/WindowControlsInsets;";
|
|
25
|
+
|
|
26
|
+
public:
|
|
27
|
+
/**
|
|
28
|
+
* Convert this Java/Kotlin-based struct to the C++ struct WindowControlsInsets by copying all values to C++.
|
|
29
|
+
*/
|
|
30
|
+
[[maybe_unused]]
|
|
31
|
+
[[nodiscard]]
|
|
32
|
+
WindowControlsInsets toCpp() const {
|
|
33
|
+
static const auto clazz = javaClassStatic();
|
|
34
|
+
static const auto fieldTop = clazz->getField<double>("top");
|
|
35
|
+
double top = this->getFieldValue(fieldTop);
|
|
36
|
+
static const auto fieldLeft = clazz->getField<double>("left");
|
|
37
|
+
double left = this->getFieldValue(fieldLeft);
|
|
38
|
+
static const auto fieldBottom = clazz->getField<double>("bottom");
|
|
39
|
+
double bottom = this->getFieldValue(fieldBottom);
|
|
40
|
+
static const auto fieldRight = clazz->getField<double>("right");
|
|
41
|
+
double right = this->getFieldValue(fieldRight);
|
|
42
|
+
return WindowControlsInsets(
|
|
43
|
+
top,
|
|
44
|
+
left,
|
|
45
|
+
bottom,
|
|
46
|
+
right
|
|
47
|
+
);
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
public:
|
|
51
|
+
/**
|
|
52
|
+
* Create a Java/Kotlin-based struct by copying all values from the given C++ struct to Java.
|
|
53
|
+
*/
|
|
54
|
+
[[maybe_unused]]
|
|
55
|
+
static jni::local_ref<JWindowControlsInsets::javaobject> fromCpp(const WindowControlsInsets& value) {
|
|
56
|
+
using JSignature = JWindowControlsInsets(double, double, double, double);
|
|
57
|
+
static const auto clazz = javaClassStatic();
|
|
58
|
+
static const auto create = clazz->getStaticMethod<JSignature>("fromCpp");
|
|
59
|
+
return create(
|
|
60
|
+
clazz,
|
|
61
|
+
value.top,
|
|
62
|
+
value.left,
|
|
63
|
+
value.bottom,
|
|
64
|
+
value.right
|
|
65
|
+
);
|
|
66
|
+
}
|
|
67
|
+
};
|
|
68
|
+
|
|
69
|
+
} // namespace margelo::nitro::reactnativedeviceutils
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// Func_void_MainMenuCommand.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.reactnativedeviceutils
|
|
9
|
+
|
|
10
|
+
import androidx.annotation.Keep
|
|
11
|
+
import com.facebook.jni.HybridData
|
|
12
|
+
import com.facebook.proguard.annotations.DoNotStrip
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Represents the JavaScript callback `(command: enum) => void`.
|
|
17
|
+
* This can be either implemented in C++ (in which case it might be a callback coming from JS),
|
|
18
|
+
* or in Kotlin/Java (in which case it is a native callback).
|
|
19
|
+
*/
|
|
20
|
+
@DoNotStrip
|
|
21
|
+
@Keep
|
|
22
|
+
@Suppress("ClassName", "RedundantUnitReturnType")
|
|
23
|
+
fun interface Func_void_MainMenuCommand: (MainMenuCommand) -> Unit {
|
|
24
|
+
/**
|
|
25
|
+
* Call the given JS callback.
|
|
26
|
+
* @throws Throwable if the JS function itself throws an error, or if the JS function/runtime has already been deleted.
|
|
27
|
+
*/
|
|
28
|
+
@DoNotStrip
|
|
29
|
+
@Keep
|
|
30
|
+
override fun invoke(command: MainMenuCommand): Unit
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* Represents the JavaScript callback `(command: enum) => void`.
|
|
35
|
+
* This is implemented in C++, via a `std::function<...>`.
|
|
36
|
+
* The callback might be coming from JS.
|
|
37
|
+
*/
|
|
38
|
+
@DoNotStrip
|
|
39
|
+
@Keep
|
|
40
|
+
@Suppress(
|
|
41
|
+
"KotlinJniMissingFunction", "unused",
|
|
42
|
+
"RedundantSuppression", "RedundantUnitReturnType", "FunctionName",
|
|
43
|
+
"ConvertSecondaryConstructorToPrimary", "ClassName", "LocalVariableName",
|
|
44
|
+
)
|
|
45
|
+
class Func_void_MainMenuCommand_cxx: Func_void_MainMenuCommand {
|
|
46
|
+
@DoNotStrip
|
|
47
|
+
@Keep
|
|
48
|
+
private val mHybridData: HybridData
|
|
49
|
+
|
|
50
|
+
@DoNotStrip
|
|
51
|
+
@Keep
|
|
52
|
+
private constructor(hybridData: HybridData) {
|
|
53
|
+
mHybridData = hybridData
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
@DoNotStrip
|
|
57
|
+
@Keep
|
|
58
|
+
override fun invoke(command: MainMenuCommand): Unit
|
|
59
|
+
= invoke_cxx(command)
|
|
60
|
+
|
|
61
|
+
private external fun invoke_cxx(command: MainMenuCommand): Unit
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
* Represents the JavaScript callback `(command: enum) => void`.
|
|
66
|
+
* This is implemented in Java/Kotlin, via a `(MainMenuCommand) -> Unit`.
|
|
67
|
+
* The callback is always coming from native.
|
|
68
|
+
*/
|
|
69
|
+
@DoNotStrip
|
|
70
|
+
@Keep
|
|
71
|
+
@Suppress("ClassName", "RedundantUnitReturnType", "unused")
|
|
72
|
+
class Func_void_MainMenuCommand_java(private val function: (MainMenuCommand) -> Unit): Func_void_MainMenuCommand {
|
|
73
|
+
@DoNotStrip
|
|
74
|
+
@Keep
|
|
75
|
+
override fun invoke(command: MainMenuCommand): Unit {
|
|
76
|
+
return this.function(command)
|
|
77
|
+
}
|
|
78
|
+
}
|