react-native-nitro-location-tracking 0.1.5 → 0.1.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/README.md +677 -7
- package/android/src/main/java/com/margelo/nitro/nitrolocationtracking/GeofenceManager.kt +148 -0
- package/android/src/main/java/com/margelo/nitro/nitrolocationtracking/LocationEngine.kt +55 -1
- package/android/src/main/java/com/margelo/nitro/nitrolocationtracking/NitroLocationTracking.kt +127 -0
- package/android/src/main/java/com/margelo/nitro/nitrolocationtracking/ProviderStatusMonitor.kt +73 -0
- package/android/src/main/java/com/margelo/nitro/nitrolocationtracking/SpeedMonitor.kt +38 -0
- package/android/src/main/java/com/margelo/nitro/nitrolocationtracking/TripCalculator.kt +85 -0
- package/ios/GeofenceManager.swift +69 -0
- package/ios/LocationEngine.swift +56 -2
- package/ios/NitroLocationTracking.swift +104 -0
- package/ios/SpeedMonitor.swift +48 -0
- package/ios/TripCalculator.swift +93 -0
- package/lib/module/index.js.map +1 -1
- package/lib/typescript/src/NitroLocationTracking.nitro.d.ts +44 -0
- package/lib/typescript/src/NitroLocationTracking.nitro.d.ts.map +1 -1
- package/lib/typescript/src/index.d.ts +1 -1
- package/lib/typescript/src/index.d.ts.map +1 -1
- package/lib/typescript/test.d.ts +1 -0
- package/lib/typescript/test.d.ts.map +1 -0
- package/nitrogen/generated/android/c++/JFunc_void_GeofenceEvent_std__string.hpp +78 -0
- package/nitrogen/generated/android/c++/JFunc_void_LocationData.hpp +1 -0
- package/nitrogen/generated/android/c++/JFunc_void_LocationProviderStatus_LocationProviderStatus.hpp +77 -0
- package/nitrogen/generated/android/c++/JFunc_void_SpeedAlertType_double.hpp +77 -0
- package/nitrogen/generated/android/c++/JGeofenceEvent.hpp +58 -0
- package/nitrogen/generated/android/c++/JGeofenceRegion.hpp +77 -0
- package/nitrogen/generated/android/c++/JHybridNitroLocationTrackingSpec.cpp +102 -0
- package/nitrogen/generated/android/c++/JHybridNitroLocationTrackingSpec.hpp +16 -0
- package/nitrogen/generated/android/c++/JLocationData.hpp +8 -4
- package/nitrogen/generated/android/c++/JLocationProviderStatus.hpp +58 -0
- package/nitrogen/generated/android/c++/JPermissionStatus.hpp +67 -0
- package/nitrogen/generated/android/c++/JSpeedAlertType.hpp +61 -0
- package/nitrogen/generated/android/c++/JSpeedConfig.hpp +65 -0
- package/nitrogen/generated/android/c++/JTripStats.hpp +73 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitrolocationtracking/Func_void_GeofenceEvent_std__string.kt +80 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitrolocationtracking/Func_void_LocationProviderStatus_LocationProviderStatus.kt +80 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitrolocationtracking/Func_void_SpeedAlertType_double.kt +80 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitrolocationtracking/GeofenceEvent.kt +23 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitrolocationtracking/GeofenceRegion.kt +53 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitrolocationtracking/HybridNitroLocationTrackingSpec.kt +79 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitrolocationtracking/LocationData.kt +6 -3
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitrolocationtracking/LocationProviderStatus.kt +23 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitrolocationtracking/PermissionStatus.kt +26 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitrolocationtracking/SpeedAlertType.kt +24 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitrolocationtracking/SpeedConfig.kt +44 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitrolocationtracking/TripStats.kt +50 -0
- package/nitrogen/generated/android/nitrolocationtrackingOnLoad.cpp +6 -0
- package/nitrogen/generated/ios/NitroLocationTracking-Swift-Cxx-Bridge.cpp +24 -0
- package/nitrogen/generated/ios/NitroLocationTracking-Swift-Cxx-Bridge.hpp +124 -0
- package/nitrogen/generated/ios/NitroLocationTracking-Swift-Cxx-Umbrella.hpp +22 -0
- package/nitrogen/generated/ios/c++/HybridNitroLocationTrackingSpecSwift.hpp +130 -0
- package/nitrogen/generated/ios/swift/Func_void_GeofenceEvent_std__string.swift +46 -0
- package/nitrogen/generated/ios/swift/Func_void_LocationProviderStatus_LocationProviderStatus.swift +46 -0
- package/nitrogen/generated/ios/swift/Func_void_SpeedAlertType_double.swift +46 -0
- package/nitrogen/generated/ios/swift/GeofenceEvent.swift +40 -0
- package/nitrogen/generated/ios/swift/GeofenceRegion.swift +54 -0
- package/nitrogen/generated/ios/swift/HybridNitroLocationTrackingSpec.swift +16 -0
- package/nitrogen/generated/ios/swift/HybridNitroLocationTrackingSpec_cxx.swift +197 -0
- package/nitrogen/generated/ios/swift/LocationData.swift +20 -2
- package/nitrogen/generated/ios/swift/LocationProviderStatus.swift +40 -0
- package/nitrogen/generated/ios/swift/PermissionStatus.swift +52 -0
- package/nitrogen/generated/ios/swift/SpeedAlertType.swift +44 -0
- package/nitrogen/generated/ios/swift/SpeedConfig.swift +39 -0
- package/nitrogen/generated/ios/swift/TripStats.swift +49 -0
- package/nitrogen/generated/shared/c++/GeofenceEvent.hpp +76 -0
- package/nitrogen/generated/shared/c++/GeofenceRegion.hpp +103 -0
- package/nitrogen/generated/shared/c++/HybridNitroLocationTrackingSpec.cpp +16 -0
- package/nitrogen/generated/shared/c++/HybridNitroLocationTrackingSpec.hpp +37 -0
- package/nitrogen/generated/shared/c++/LocationData.hpp +7 -3
- package/nitrogen/generated/shared/c++/LocationProviderStatus.hpp +76 -0
- package/nitrogen/generated/shared/c++/PermissionStatus.hpp +88 -0
- package/nitrogen/generated/shared/c++/SpeedAlertType.hpp +80 -0
- package/nitrogen/generated/shared/c++/SpeedConfig.hpp +91 -0
- package/nitrogen/generated/shared/c++/TripStats.hpp +99 -0
- package/package.json +2 -2
- package/src/NitroLocationTracking.nitro.ts +71 -0
- package/src/index.tsx +10 -0
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// JFunc_void_SpeedAlertType_double.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 "SpeedAlertType.hpp"
|
|
14
|
+
#include <functional>
|
|
15
|
+
#include <NitroModules/JNICallable.hpp>
|
|
16
|
+
#include "JSpeedAlertType.hpp"
|
|
17
|
+
|
|
18
|
+
namespace margelo::nitro::nitrolocationtracking {
|
|
19
|
+
|
|
20
|
+
using namespace facebook;
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* Represents the Java/Kotlin callback `(alert: SpeedAlertType, currentSpeedKmh: Double) -> Unit`.
|
|
24
|
+
* This can be passed around between C++ and Java/Kotlin.
|
|
25
|
+
*/
|
|
26
|
+
struct JFunc_void_SpeedAlertType_double: public jni::JavaClass<JFunc_void_SpeedAlertType_double> {
|
|
27
|
+
public:
|
|
28
|
+
static auto constexpr kJavaDescriptor = "Lcom/margelo/nitro/nitrolocationtracking/Func_void_SpeedAlertType_double;";
|
|
29
|
+
|
|
30
|
+
public:
|
|
31
|
+
/**
|
|
32
|
+
* Invokes the function this `JFunc_void_SpeedAlertType_double` instance holds through JNI.
|
|
33
|
+
*/
|
|
34
|
+
void invoke(SpeedAlertType alert, double currentSpeedKmh) const {
|
|
35
|
+
static const auto method = javaClassStatic()->getMethod<void(jni::alias_ref<JSpeedAlertType> /* alert */, double /* currentSpeedKmh */)>("invoke");
|
|
36
|
+
method(self(), JSpeedAlertType::fromCpp(alert), currentSpeedKmh);
|
|
37
|
+
}
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* An implementation of Func_void_SpeedAlertType_double that is backed by a C++ implementation (using `std::function<...>`)
|
|
42
|
+
*/
|
|
43
|
+
class JFunc_void_SpeedAlertType_double_cxx final: public jni::HybridClass<JFunc_void_SpeedAlertType_double_cxx, JFunc_void_SpeedAlertType_double> {
|
|
44
|
+
public:
|
|
45
|
+
static jni::local_ref<JFunc_void_SpeedAlertType_double::javaobject> fromCpp(const std::function<void(SpeedAlertType /* alert */, double /* currentSpeedKmh */)>& func) {
|
|
46
|
+
return JFunc_void_SpeedAlertType_double_cxx::newObjectCxxArgs(func);
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
public:
|
|
50
|
+
/**
|
|
51
|
+
* Invokes the C++ `std::function<...>` this `JFunc_void_SpeedAlertType_double_cxx` instance holds.
|
|
52
|
+
*/
|
|
53
|
+
void invoke_cxx(jni::alias_ref<JSpeedAlertType> alert, double currentSpeedKmh) {
|
|
54
|
+
_func(alert->toCpp(), currentSpeedKmh);
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
public:
|
|
58
|
+
[[nodiscard]]
|
|
59
|
+
inline const std::function<void(SpeedAlertType /* alert */, double /* currentSpeedKmh */)>& getFunction() const {
|
|
60
|
+
return _func;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
public:
|
|
64
|
+
static auto constexpr kJavaDescriptor = "Lcom/margelo/nitro/nitrolocationtracking/Func_void_SpeedAlertType_double_cxx;";
|
|
65
|
+
static void registerNatives() {
|
|
66
|
+
registerHybrid({makeNativeMethod("invoke_cxx", JFunc_void_SpeedAlertType_double_cxx::invoke_cxx)});
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
private:
|
|
70
|
+
explicit JFunc_void_SpeedAlertType_double_cxx(const std::function<void(SpeedAlertType /* alert */, double /* currentSpeedKmh */)>& func): _func(func) { }
|
|
71
|
+
|
|
72
|
+
private:
|
|
73
|
+
friend HybridBase;
|
|
74
|
+
std::function<void(SpeedAlertType /* alert */, double /* currentSpeedKmh */)> _func;
|
|
75
|
+
};
|
|
76
|
+
|
|
77
|
+
} // namespace margelo::nitro::nitrolocationtracking
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// JGeofenceEvent.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 "GeofenceEvent.hpp"
|
|
12
|
+
|
|
13
|
+
namespace margelo::nitro::nitrolocationtracking {
|
|
14
|
+
|
|
15
|
+
using namespace facebook;
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* The C++ JNI bridge between the C++ enum "GeofenceEvent" and the the Kotlin enum "GeofenceEvent".
|
|
19
|
+
*/
|
|
20
|
+
struct JGeofenceEvent final: public jni::JavaClass<JGeofenceEvent> {
|
|
21
|
+
public:
|
|
22
|
+
static auto constexpr kJavaDescriptor = "Lcom/margelo/nitro/nitrolocationtracking/GeofenceEvent;";
|
|
23
|
+
|
|
24
|
+
public:
|
|
25
|
+
/**
|
|
26
|
+
* Convert this Java/Kotlin-based enum to the C++ enum GeofenceEvent.
|
|
27
|
+
*/
|
|
28
|
+
[[maybe_unused]]
|
|
29
|
+
[[nodiscard]]
|
|
30
|
+
GeofenceEvent 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<GeofenceEvent>(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<JGeofenceEvent> fromCpp(GeofenceEvent value) {
|
|
43
|
+
static const auto clazz = javaClassStatic();
|
|
44
|
+
switch (value) {
|
|
45
|
+
case GeofenceEvent::ENTER:
|
|
46
|
+
static const auto fieldENTER = clazz->getStaticField<JGeofenceEvent>("ENTER");
|
|
47
|
+
return clazz->getStaticFieldValue(fieldENTER);
|
|
48
|
+
case GeofenceEvent::EXIT:
|
|
49
|
+
static const auto fieldEXIT = clazz->getStaticField<JGeofenceEvent>("EXIT");
|
|
50
|
+
return clazz->getStaticFieldValue(fieldEXIT);
|
|
51
|
+
default:
|
|
52
|
+
std::string stringValue = std::to_string(static_cast<int>(value));
|
|
53
|
+
throw std::invalid_argument("Invalid enum value (" + stringValue + "!");
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
};
|
|
57
|
+
|
|
58
|
+
} // namespace margelo::nitro::nitrolocationtracking
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// JGeofenceRegion.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 "GeofenceRegion.hpp"
|
|
12
|
+
|
|
13
|
+
#include <string>
|
|
14
|
+
|
|
15
|
+
namespace margelo::nitro::nitrolocationtracking {
|
|
16
|
+
|
|
17
|
+
using namespace facebook;
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* The C++ JNI bridge between the C++ struct "GeofenceRegion" and the the Kotlin data class "GeofenceRegion".
|
|
21
|
+
*/
|
|
22
|
+
struct JGeofenceRegion final: public jni::JavaClass<JGeofenceRegion> {
|
|
23
|
+
public:
|
|
24
|
+
static auto constexpr kJavaDescriptor = "Lcom/margelo/nitro/nitrolocationtracking/GeofenceRegion;";
|
|
25
|
+
|
|
26
|
+
public:
|
|
27
|
+
/**
|
|
28
|
+
* Convert this Java/Kotlin-based struct to the C++ struct GeofenceRegion by copying all values to C++.
|
|
29
|
+
*/
|
|
30
|
+
[[maybe_unused]]
|
|
31
|
+
[[nodiscard]]
|
|
32
|
+
GeofenceRegion toCpp() const {
|
|
33
|
+
static const auto clazz = javaClassStatic();
|
|
34
|
+
static const auto fieldId = clazz->getField<jni::JString>("id");
|
|
35
|
+
jni::local_ref<jni::JString> id = this->getFieldValue(fieldId);
|
|
36
|
+
static const auto fieldLatitude = clazz->getField<double>("latitude");
|
|
37
|
+
double latitude = this->getFieldValue(fieldLatitude);
|
|
38
|
+
static const auto fieldLongitude = clazz->getField<double>("longitude");
|
|
39
|
+
double longitude = this->getFieldValue(fieldLongitude);
|
|
40
|
+
static const auto fieldRadius = clazz->getField<double>("radius");
|
|
41
|
+
double radius = this->getFieldValue(fieldRadius);
|
|
42
|
+
static const auto fieldNotifyOnEntry = clazz->getField<jboolean>("notifyOnEntry");
|
|
43
|
+
jboolean notifyOnEntry = this->getFieldValue(fieldNotifyOnEntry);
|
|
44
|
+
static const auto fieldNotifyOnExit = clazz->getField<jboolean>("notifyOnExit");
|
|
45
|
+
jboolean notifyOnExit = this->getFieldValue(fieldNotifyOnExit);
|
|
46
|
+
return GeofenceRegion(
|
|
47
|
+
id->toStdString(),
|
|
48
|
+
latitude,
|
|
49
|
+
longitude,
|
|
50
|
+
radius,
|
|
51
|
+
static_cast<bool>(notifyOnEntry),
|
|
52
|
+
static_cast<bool>(notifyOnExit)
|
|
53
|
+
);
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
public:
|
|
57
|
+
/**
|
|
58
|
+
* Create a Java/Kotlin-based struct by copying all values from the given C++ struct to Java.
|
|
59
|
+
*/
|
|
60
|
+
[[maybe_unused]]
|
|
61
|
+
static jni::local_ref<JGeofenceRegion::javaobject> fromCpp(const GeofenceRegion& value) {
|
|
62
|
+
using JSignature = JGeofenceRegion(jni::alias_ref<jni::JString>, double, double, double, jboolean, jboolean);
|
|
63
|
+
static const auto clazz = javaClassStatic();
|
|
64
|
+
static const auto create = clazz->getStaticMethod<JSignature>("fromCpp");
|
|
65
|
+
return create(
|
|
66
|
+
clazz,
|
|
67
|
+
jni::make_jstring(value.id),
|
|
68
|
+
value.latitude,
|
|
69
|
+
value.longitude,
|
|
70
|
+
value.radius,
|
|
71
|
+
value.notifyOnEntry,
|
|
72
|
+
value.notifyOnExit
|
|
73
|
+
);
|
|
74
|
+
}
|
|
75
|
+
};
|
|
76
|
+
|
|
77
|
+
} // namespace margelo::nitro::nitrolocationtracking
|
|
@@ -11,19 +11,38 @@
|
|
|
11
11
|
namespace margelo::nitro::nitrolocationtracking { struct LocationData; }
|
|
12
12
|
// Forward declaration of `ConnectionState` to properly resolve imports.
|
|
13
13
|
namespace margelo::nitro::nitrolocationtracking { enum class ConnectionState; }
|
|
14
|
+
// Forward declaration of `TripStats` to properly resolve imports.
|
|
15
|
+
namespace margelo::nitro::nitrolocationtracking { struct TripStats; }
|
|
16
|
+
// Forward declaration of `PermissionStatus` to properly resolve imports.
|
|
17
|
+
namespace margelo::nitro::nitrolocationtracking { enum class PermissionStatus; }
|
|
14
18
|
// Forward declaration of `LocationConfig` to properly resolve imports.
|
|
15
19
|
namespace margelo::nitro::nitrolocationtracking { struct LocationConfig; }
|
|
16
20
|
// Forward declaration of `AccuracyLevel` to properly resolve imports.
|
|
17
21
|
namespace margelo::nitro::nitrolocationtracking { enum class AccuracyLevel; }
|
|
18
22
|
// Forward declaration of `ConnectionConfig` to properly resolve imports.
|
|
19
23
|
namespace margelo::nitro::nitrolocationtracking { struct ConnectionConfig; }
|
|
24
|
+
// Forward declaration of `GeofenceRegion` to properly resolve imports.
|
|
25
|
+
namespace margelo::nitro::nitrolocationtracking { struct GeofenceRegion; }
|
|
26
|
+
// Forward declaration of `GeofenceEvent` to properly resolve imports.
|
|
27
|
+
namespace margelo::nitro::nitrolocationtracking { enum class GeofenceEvent; }
|
|
28
|
+
// Forward declaration of `SpeedConfig` to properly resolve imports.
|
|
29
|
+
namespace margelo::nitro::nitrolocationtracking { struct SpeedConfig; }
|
|
30
|
+
// Forward declaration of `SpeedAlertType` to properly resolve imports.
|
|
31
|
+
namespace margelo::nitro::nitrolocationtracking { enum class SpeedAlertType; }
|
|
32
|
+
// Forward declaration of `LocationProviderStatus` to properly resolve imports.
|
|
33
|
+
namespace margelo::nitro::nitrolocationtracking { enum class LocationProviderStatus; }
|
|
20
34
|
|
|
21
35
|
#include "LocationData.hpp"
|
|
22
36
|
#include <NitroModules/Promise.hpp>
|
|
23
37
|
#include <NitroModules/JPromise.hpp>
|
|
24
38
|
#include "JLocationData.hpp"
|
|
39
|
+
#include <optional>
|
|
25
40
|
#include "ConnectionState.hpp"
|
|
26
41
|
#include "JConnectionState.hpp"
|
|
42
|
+
#include "TripStats.hpp"
|
|
43
|
+
#include "JTripStats.hpp"
|
|
44
|
+
#include "PermissionStatus.hpp"
|
|
45
|
+
#include "JPermissionStatus.hpp"
|
|
27
46
|
#include "LocationConfig.hpp"
|
|
28
47
|
#include "JLocationConfig.hpp"
|
|
29
48
|
#include "AccuracyLevel.hpp"
|
|
@@ -37,6 +56,19 @@ namespace margelo::nitro::nitrolocationtracking { struct ConnectionConfig; }
|
|
|
37
56
|
#include "JConnectionConfig.hpp"
|
|
38
57
|
#include "JFunc_void_ConnectionState.hpp"
|
|
39
58
|
#include "JFunc_void_std__string.hpp"
|
|
59
|
+
#include "GeofenceRegion.hpp"
|
|
60
|
+
#include "JGeofenceRegion.hpp"
|
|
61
|
+
#include "GeofenceEvent.hpp"
|
|
62
|
+
#include "JFunc_void_GeofenceEvent_std__string.hpp"
|
|
63
|
+
#include "JGeofenceEvent.hpp"
|
|
64
|
+
#include "SpeedConfig.hpp"
|
|
65
|
+
#include "JSpeedConfig.hpp"
|
|
66
|
+
#include "SpeedAlertType.hpp"
|
|
67
|
+
#include "JFunc_void_SpeedAlertType_double.hpp"
|
|
68
|
+
#include "JSpeedAlertType.hpp"
|
|
69
|
+
#include "LocationProviderStatus.hpp"
|
|
70
|
+
#include "JFunc_void_LocationProviderStatus_LocationProviderStatus.hpp"
|
|
71
|
+
#include "JLocationProviderStatus.hpp"
|
|
40
72
|
|
|
41
73
|
namespace margelo::nitro::nitrolocationtracking {
|
|
42
74
|
|
|
@@ -163,6 +195,76 @@ namespace margelo::nitro::nitrolocationtracking {
|
|
|
163
195
|
return __promise;
|
|
164
196
|
}();
|
|
165
197
|
}
|
|
198
|
+
bool JHybridNitroLocationTrackingSpec::isFakeGpsEnabled() {
|
|
199
|
+
static const auto method = javaClassStatic()->getMethod<jboolean()>("isFakeGpsEnabled");
|
|
200
|
+
auto __result = method(_javaPart);
|
|
201
|
+
return static_cast<bool>(__result);
|
|
202
|
+
}
|
|
203
|
+
void JHybridNitroLocationTrackingSpec::setRejectMockLocations(bool reject) {
|
|
204
|
+
static const auto method = javaClassStatic()->getMethod<void(jboolean /* reject */)>("setRejectMockLocations");
|
|
205
|
+
method(_javaPart, reject);
|
|
206
|
+
}
|
|
207
|
+
void JHybridNitroLocationTrackingSpec::addGeofence(const GeofenceRegion& region) {
|
|
208
|
+
static const auto method = javaClassStatic()->getMethod<void(jni::alias_ref<JGeofenceRegion> /* region */)>("addGeofence");
|
|
209
|
+
method(_javaPart, JGeofenceRegion::fromCpp(region));
|
|
210
|
+
}
|
|
211
|
+
void JHybridNitroLocationTrackingSpec::removeGeofence(const std::string& regionId) {
|
|
212
|
+
static const auto method = javaClassStatic()->getMethod<void(jni::alias_ref<jni::JString> /* regionId */)>("removeGeofence");
|
|
213
|
+
method(_javaPart, jni::make_jstring(regionId));
|
|
214
|
+
}
|
|
215
|
+
void JHybridNitroLocationTrackingSpec::removeAllGeofences() {
|
|
216
|
+
static const auto method = javaClassStatic()->getMethod<void()>("removeAllGeofences");
|
|
217
|
+
method(_javaPart);
|
|
218
|
+
}
|
|
219
|
+
void JHybridNitroLocationTrackingSpec::onGeofenceEvent(const std::function<void(GeofenceEvent /* event */, const std::string& /* regionId */)>& callback) {
|
|
220
|
+
static const auto method = javaClassStatic()->getMethod<void(jni::alias_ref<JFunc_void_GeofenceEvent_std__string::javaobject> /* callback */)>("onGeofenceEvent_cxx");
|
|
221
|
+
method(_javaPart, JFunc_void_GeofenceEvent_std__string_cxx::fromCpp(callback));
|
|
222
|
+
}
|
|
223
|
+
void JHybridNitroLocationTrackingSpec::configureSpeedMonitor(const SpeedConfig& config) {
|
|
224
|
+
static const auto method = javaClassStatic()->getMethod<void(jni::alias_ref<JSpeedConfig> /* config */)>("configureSpeedMonitor");
|
|
225
|
+
method(_javaPart, JSpeedConfig::fromCpp(config));
|
|
226
|
+
}
|
|
227
|
+
void JHybridNitroLocationTrackingSpec::onSpeedAlert(const std::function<void(SpeedAlertType /* alert */, double /* currentSpeedKmh */)>& callback) {
|
|
228
|
+
static const auto method = javaClassStatic()->getMethod<void(jni::alias_ref<JFunc_void_SpeedAlertType_double::javaobject> /* callback */)>("onSpeedAlert_cxx");
|
|
229
|
+
method(_javaPart, JFunc_void_SpeedAlertType_double_cxx::fromCpp(callback));
|
|
230
|
+
}
|
|
231
|
+
double JHybridNitroLocationTrackingSpec::getCurrentSpeed() {
|
|
232
|
+
static const auto method = javaClassStatic()->getMethod<double()>("getCurrentSpeed");
|
|
233
|
+
auto __result = method(_javaPart);
|
|
234
|
+
return __result;
|
|
235
|
+
}
|
|
236
|
+
void JHybridNitroLocationTrackingSpec::startTripCalculation() {
|
|
237
|
+
static const auto method = javaClassStatic()->getMethod<void()>("startTripCalculation");
|
|
238
|
+
method(_javaPart);
|
|
239
|
+
}
|
|
240
|
+
TripStats JHybridNitroLocationTrackingSpec::stopTripCalculation() {
|
|
241
|
+
static const auto method = javaClassStatic()->getMethod<jni::local_ref<JTripStats>()>("stopTripCalculation");
|
|
242
|
+
auto __result = method(_javaPart);
|
|
243
|
+
return __result->toCpp();
|
|
244
|
+
}
|
|
245
|
+
TripStats JHybridNitroLocationTrackingSpec::getTripStats() {
|
|
246
|
+
static const auto method = javaClassStatic()->getMethod<jni::local_ref<JTripStats>()>("getTripStats");
|
|
247
|
+
auto __result = method(_javaPart);
|
|
248
|
+
return __result->toCpp();
|
|
249
|
+
}
|
|
250
|
+
void JHybridNitroLocationTrackingSpec::resetTripCalculation() {
|
|
251
|
+
static const auto method = javaClassStatic()->getMethod<void()>("resetTripCalculation");
|
|
252
|
+
method(_javaPart);
|
|
253
|
+
}
|
|
254
|
+
bool JHybridNitroLocationTrackingSpec::isLocationServicesEnabled() {
|
|
255
|
+
static const auto method = javaClassStatic()->getMethod<jboolean()>("isLocationServicesEnabled");
|
|
256
|
+
auto __result = method(_javaPart);
|
|
257
|
+
return static_cast<bool>(__result);
|
|
258
|
+
}
|
|
259
|
+
void JHybridNitroLocationTrackingSpec::onProviderStatusChange(const std::function<void(LocationProviderStatus /* gps */, LocationProviderStatus /* network */)>& callback) {
|
|
260
|
+
static const auto method = javaClassStatic()->getMethod<void(jni::alias_ref<JFunc_void_LocationProviderStatus_LocationProviderStatus::javaobject> /* callback */)>("onProviderStatusChange_cxx");
|
|
261
|
+
method(_javaPart, JFunc_void_LocationProviderStatus_LocationProviderStatus_cxx::fromCpp(callback));
|
|
262
|
+
}
|
|
263
|
+
PermissionStatus JHybridNitroLocationTrackingSpec::getLocationPermissionStatus() {
|
|
264
|
+
static const auto method = javaClassStatic()->getMethod<jni::local_ref<JPermissionStatus>()>("getLocationPermissionStatus");
|
|
265
|
+
auto __result = method(_javaPart);
|
|
266
|
+
return __result->toCpp();
|
|
267
|
+
}
|
|
166
268
|
void JHybridNitroLocationTrackingSpec::showLocalNotification(const std::string& title, const std::string& body) {
|
|
167
269
|
static const auto method = javaClassStatic()->getMethod<void(jni::alias_ref<jni::JString> /* title */, jni::alias_ref<jni::JString> /* body */)>("showLocalNotification");
|
|
168
270
|
method(_javaPart, jni::make_jstring(title), jni::make_jstring(body));
|
|
@@ -70,6 +70,22 @@ namespace margelo::nitro::nitrolocationtracking {
|
|
|
70
70
|
void onConnectionStateChange(const std::function<void(ConnectionState /* state */)>& callback) override;
|
|
71
71
|
void onMessage(const std::function<void(const std::string& /* message */)>& callback) override;
|
|
72
72
|
std::shared_ptr<Promise<bool>> forceSync() override;
|
|
73
|
+
bool isFakeGpsEnabled() override;
|
|
74
|
+
void setRejectMockLocations(bool reject) override;
|
|
75
|
+
void addGeofence(const GeofenceRegion& region) override;
|
|
76
|
+
void removeGeofence(const std::string& regionId) override;
|
|
77
|
+
void removeAllGeofences() override;
|
|
78
|
+
void onGeofenceEvent(const std::function<void(GeofenceEvent /* event */, const std::string& /* regionId */)>& callback) override;
|
|
79
|
+
void configureSpeedMonitor(const SpeedConfig& config) override;
|
|
80
|
+
void onSpeedAlert(const std::function<void(SpeedAlertType /* alert */, double /* currentSpeedKmh */)>& callback) override;
|
|
81
|
+
double getCurrentSpeed() override;
|
|
82
|
+
void startTripCalculation() override;
|
|
83
|
+
TripStats stopTripCalculation() override;
|
|
84
|
+
TripStats getTripStats() override;
|
|
85
|
+
void resetTripCalculation() override;
|
|
86
|
+
bool isLocationServicesEnabled() override;
|
|
87
|
+
void onProviderStatusChange(const std::function<void(LocationProviderStatus /* gps */, LocationProviderStatus /* network */)>& callback) override;
|
|
88
|
+
PermissionStatus getLocationPermissionStatus() override;
|
|
73
89
|
void showLocalNotification(const std::string& title, const std::string& body) override;
|
|
74
90
|
void updateForegroundNotification(const std::string& title, const std::string& body) override;
|
|
75
91
|
void destroy() override;
|
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
#include <fbjni/fbjni.h>
|
|
11
11
|
#include "LocationData.hpp"
|
|
12
12
|
|
|
13
|
-
|
|
13
|
+
#include <optional>
|
|
14
14
|
|
|
15
15
|
namespace margelo::nitro::nitrolocationtracking {
|
|
16
16
|
|
|
@@ -45,6 +45,8 @@ namespace margelo::nitro::nitrolocationtracking {
|
|
|
45
45
|
double accuracy = this->getFieldValue(fieldAccuracy);
|
|
46
46
|
static const auto fieldTimestamp = clazz->getField<double>("timestamp");
|
|
47
47
|
double timestamp = this->getFieldValue(fieldTimestamp);
|
|
48
|
+
static const auto fieldIsMockLocation = clazz->getField<jni::JBoolean>("isMockLocation");
|
|
49
|
+
jni::local_ref<jni::JBoolean> isMockLocation = this->getFieldValue(fieldIsMockLocation);
|
|
48
50
|
return LocationData(
|
|
49
51
|
latitude,
|
|
50
52
|
longitude,
|
|
@@ -52,7 +54,8 @@ namespace margelo::nitro::nitrolocationtracking {
|
|
|
52
54
|
speed,
|
|
53
55
|
bearing,
|
|
54
56
|
accuracy,
|
|
55
|
-
timestamp
|
|
57
|
+
timestamp,
|
|
58
|
+
isMockLocation != nullptr ? std::make_optional(static_cast<bool>(isMockLocation->value())) : std::nullopt
|
|
56
59
|
);
|
|
57
60
|
}
|
|
58
61
|
|
|
@@ -62,7 +65,7 @@ namespace margelo::nitro::nitrolocationtracking {
|
|
|
62
65
|
*/
|
|
63
66
|
[[maybe_unused]]
|
|
64
67
|
static jni::local_ref<JLocationData::javaobject> fromCpp(const LocationData& value) {
|
|
65
|
-
using JSignature = JLocationData(double, double, double, double, double, double, double);
|
|
68
|
+
using JSignature = JLocationData(double, double, double, double, double, double, double, jni::alias_ref<jni::JBoolean>);
|
|
66
69
|
static const auto clazz = javaClassStatic();
|
|
67
70
|
static const auto create = clazz->getStaticMethod<JSignature>("fromCpp");
|
|
68
71
|
return create(
|
|
@@ -73,7 +76,8 @@ namespace margelo::nitro::nitrolocationtracking {
|
|
|
73
76
|
value.speed,
|
|
74
77
|
value.bearing,
|
|
75
78
|
value.accuracy,
|
|
76
|
-
value.timestamp
|
|
79
|
+
value.timestamp,
|
|
80
|
+
value.isMockLocation.has_value() ? jni::JBoolean::valueOf(value.isMockLocation.value()) : nullptr
|
|
77
81
|
);
|
|
78
82
|
}
|
|
79
83
|
};
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// JLocationProviderStatus.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 "LocationProviderStatus.hpp"
|
|
12
|
+
|
|
13
|
+
namespace margelo::nitro::nitrolocationtracking {
|
|
14
|
+
|
|
15
|
+
using namespace facebook;
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* The C++ JNI bridge between the C++ enum "LocationProviderStatus" and the the Kotlin enum "LocationProviderStatus".
|
|
19
|
+
*/
|
|
20
|
+
struct JLocationProviderStatus final: public jni::JavaClass<JLocationProviderStatus> {
|
|
21
|
+
public:
|
|
22
|
+
static auto constexpr kJavaDescriptor = "Lcom/margelo/nitro/nitrolocationtracking/LocationProviderStatus;";
|
|
23
|
+
|
|
24
|
+
public:
|
|
25
|
+
/**
|
|
26
|
+
* Convert this Java/Kotlin-based enum to the C++ enum LocationProviderStatus.
|
|
27
|
+
*/
|
|
28
|
+
[[maybe_unused]]
|
|
29
|
+
[[nodiscard]]
|
|
30
|
+
LocationProviderStatus 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<LocationProviderStatus>(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<JLocationProviderStatus> fromCpp(LocationProviderStatus value) {
|
|
43
|
+
static const auto clazz = javaClassStatic();
|
|
44
|
+
switch (value) {
|
|
45
|
+
case LocationProviderStatus::ENABLED:
|
|
46
|
+
static const auto fieldENABLED = clazz->getStaticField<JLocationProviderStatus>("ENABLED");
|
|
47
|
+
return clazz->getStaticFieldValue(fieldENABLED);
|
|
48
|
+
case LocationProviderStatus::DISABLED:
|
|
49
|
+
static const auto fieldDISABLED = clazz->getStaticField<JLocationProviderStatus>("DISABLED");
|
|
50
|
+
return clazz->getStaticFieldValue(fieldDISABLED);
|
|
51
|
+
default:
|
|
52
|
+
std::string stringValue = std::to_string(static_cast<int>(value));
|
|
53
|
+
throw std::invalid_argument("Invalid enum value (" + stringValue + "!");
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
};
|
|
57
|
+
|
|
58
|
+
} // namespace margelo::nitro::nitrolocationtracking
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// JPermissionStatus.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 "PermissionStatus.hpp"
|
|
12
|
+
|
|
13
|
+
namespace margelo::nitro::nitrolocationtracking {
|
|
14
|
+
|
|
15
|
+
using namespace facebook;
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* The C++ JNI bridge between the C++ enum "PermissionStatus" and the the Kotlin enum "PermissionStatus".
|
|
19
|
+
*/
|
|
20
|
+
struct JPermissionStatus final: public jni::JavaClass<JPermissionStatus> {
|
|
21
|
+
public:
|
|
22
|
+
static auto constexpr kJavaDescriptor = "Lcom/margelo/nitro/nitrolocationtracking/PermissionStatus;";
|
|
23
|
+
|
|
24
|
+
public:
|
|
25
|
+
/**
|
|
26
|
+
* Convert this Java/Kotlin-based enum to the C++ enum PermissionStatus.
|
|
27
|
+
*/
|
|
28
|
+
[[maybe_unused]]
|
|
29
|
+
[[nodiscard]]
|
|
30
|
+
PermissionStatus 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<PermissionStatus>(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<JPermissionStatus> fromCpp(PermissionStatus value) {
|
|
43
|
+
static const auto clazz = javaClassStatic();
|
|
44
|
+
switch (value) {
|
|
45
|
+
case PermissionStatus::NOTDETERMINED:
|
|
46
|
+
static const auto fieldNOTDETERMINED = clazz->getStaticField<JPermissionStatus>("NOTDETERMINED");
|
|
47
|
+
return clazz->getStaticFieldValue(fieldNOTDETERMINED);
|
|
48
|
+
case PermissionStatus::DENIED:
|
|
49
|
+
static const auto fieldDENIED = clazz->getStaticField<JPermissionStatus>("DENIED");
|
|
50
|
+
return clazz->getStaticFieldValue(fieldDENIED);
|
|
51
|
+
case PermissionStatus::RESTRICTED:
|
|
52
|
+
static const auto fieldRESTRICTED = clazz->getStaticField<JPermissionStatus>("RESTRICTED");
|
|
53
|
+
return clazz->getStaticFieldValue(fieldRESTRICTED);
|
|
54
|
+
case PermissionStatus::WHENINUSE:
|
|
55
|
+
static const auto fieldWHENINUSE = clazz->getStaticField<JPermissionStatus>("WHENINUSE");
|
|
56
|
+
return clazz->getStaticFieldValue(fieldWHENINUSE);
|
|
57
|
+
case PermissionStatus::ALWAYS:
|
|
58
|
+
static const auto fieldALWAYS = clazz->getStaticField<JPermissionStatus>("ALWAYS");
|
|
59
|
+
return clazz->getStaticFieldValue(fieldALWAYS);
|
|
60
|
+
default:
|
|
61
|
+
std::string stringValue = std::to_string(static_cast<int>(value));
|
|
62
|
+
throw std::invalid_argument("Invalid enum value (" + stringValue + "!");
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
};
|
|
66
|
+
|
|
67
|
+
} // namespace margelo::nitro::nitrolocationtracking
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// JSpeedAlertType.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 "SpeedAlertType.hpp"
|
|
12
|
+
|
|
13
|
+
namespace margelo::nitro::nitrolocationtracking {
|
|
14
|
+
|
|
15
|
+
using namespace facebook;
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* The C++ JNI bridge between the C++ enum "SpeedAlertType" and the the Kotlin enum "SpeedAlertType".
|
|
19
|
+
*/
|
|
20
|
+
struct JSpeedAlertType final: public jni::JavaClass<JSpeedAlertType> {
|
|
21
|
+
public:
|
|
22
|
+
static auto constexpr kJavaDescriptor = "Lcom/margelo/nitro/nitrolocationtracking/SpeedAlertType;";
|
|
23
|
+
|
|
24
|
+
public:
|
|
25
|
+
/**
|
|
26
|
+
* Convert this Java/Kotlin-based enum to the C++ enum SpeedAlertType.
|
|
27
|
+
*/
|
|
28
|
+
[[maybe_unused]]
|
|
29
|
+
[[nodiscard]]
|
|
30
|
+
SpeedAlertType 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<SpeedAlertType>(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<JSpeedAlertType> fromCpp(SpeedAlertType value) {
|
|
43
|
+
static const auto clazz = javaClassStatic();
|
|
44
|
+
switch (value) {
|
|
45
|
+
case SpeedAlertType::EXCEEDED:
|
|
46
|
+
static const auto fieldEXCEEDED = clazz->getStaticField<JSpeedAlertType>("EXCEEDED");
|
|
47
|
+
return clazz->getStaticFieldValue(fieldEXCEEDED);
|
|
48
|
+
case SpeedAlertType::NORMALIZED:
|
|
49
|
+
static const auto fieldNORMALIZED = clazz->getStaticField<JSpeedAlertType>("NORMALIZED");
|
|
50
|
+
return clazz->getStaticFieldValue(fieldNORMALIZED);
|
|
51
|
+
case SpeedAlertType::BELOW_MINIMUM:
|
|
52
|
+
static const auto fieldBELOW_MINIMUM = clazz->getStaticField<JSpeedAlertType>("BELOW_MINIMUM");
|
|
53
|
+
return clazz->getStaticFieldValue(fieldBELOW_MINIMUM);
|
|
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::nitrolocationtracking
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// JSpeedConfig.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 "SpeedConfig.hpp"
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
namespace margelo::nitro::nitrolocationtracking {
|
|
16
|
+
|
|
17
|
+
using namespace facebook;
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* The C++ JNI bridge between the C++ struct "SpeedConfig" and the the Kotlin data class "SpeedConfig".
|
|
21
|
+
*/
|
|
22
|
+
struct JSpeedConfig final: public jni::JavaClass<JSpeedConfig> {
|
|
23
|
+
public:
|
|
24
|
+
static auto constexpr kJavaDescriptor = "Lcom/margelo/nitro/nitrolocationtracking/SpeedConfig;";
|
|
25
|
+
|
|
26
|
+
public:
|
|
27
|
+
/**
|
|
28
|
+
* Convert this Java/Kotlin-based struct to the C++ struct SpeedConfig by copying all values to C++.
|
|
29
|
+
*/
|
|
30
|
+
[[maybe_unused]]
|
|
31
|
+
[[nodiscard]]
|
|
32
|
+
SpeedConfig toCpp() const {
|
|
33
|
+
static const auto clazz = javaClassStatic();
|
|
34
|
+
static const auto fieldMaxSpeedKmh = clazz->getField<double>("maxSpeedKmh");
|
|
35
|
+
double maxSpeedKmh = this->getFieldValue(fieldMaxSpeedKmh);
|
|
36
|
+
static const auto fieldMinSpeedKmh = clazz->getField<double>("minSpeedKmh");
|
|
37
|
+
double minSpeedKmh = this->getFieldValue(fieldMinSpeedKmh);
|
|
38
|
+
static const auto fieldCheckIntervalMs = clazz->getField<double>("checkIntervalMs");
|
|
39
|
+
double checkIntervalMs = this->getFieldValue(fieldCheckIntervalMs);
|
|
40
|
+
return SpeedConfig(
|
|
41
|
+
maxSpeedKmh,
|
|
42
|
+
minSpeedKmh,
|
|
43
|
+
checkIntervalMs
|
|
44
|
+
);
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
public:
|
|
48
|
+
/**
|
|
49
|
+
* Create a Java/Kotlin-based struct by copying all values from the given C++ struct to Java.
|
|
50
|
+
*/
|
|
51
|
+
[[maybe_unused]]
|
|
52
|
+
static jni::local_ref<JSpeedConfig::javaobject> fromCpp(const SpeedConfig& value) {
|
|
53
|
+
using JSignature = JSpeedConfig(double, double, double);
|
|
54
|
+
static const auto clazz = javaClassStatic();
|
|
55
|
+
static const auto create = clazz->getStaticMethod<JSignature>("fromCpp");
|
|
56
|
+
return create(
|
|
57
|
+
clazz,
|
|
58
|
+
value.maxSpeedKmh,
|
|
59
|
+
value.minSpeedKmh,
|
|
60
|
+
value.checkIntervalMs
|
|
61
|
+
);
|
|
62
|
+
}
|
|
63
|
+
};
|
|
64
|
+
|
|
65
|
+
} // namespace margelo::nitro::nitrolocationtracking
|