@iternio/react-native-auto-play 0.2.0-alpha.3 → 0.2.0-alpha.4
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/build.gradle +2 -2
- package/android/src/automotive/AndroidManifest.xml +2 -0
- package/android/src/automotive/java/com/margelo/nitro/swe/iternio/reactnativeautoplay/AndroidTelemetryObserver.kt +5 -2
- package/android/src/main/java/com/margelo/nitro/swe/iternio/reactnativeautoplay/SignInWithGoogleActivity.kt +63 -0
- package/android/src/main/java/com/margelo/nitro/swe/iternio/reactnativeautoplay/template/SignInTemplate.kt +52 -0
- package/lib/hooks/useAndroidAutoTelemetry.d.ts +4 -13
- package/lib/hooks/useAndroidAutoTelemetry.js +3 -6
- package/lib/index.d.ts +0 -4
- package/lib/index.js +0 -4
- package/lib/types/SignInMethod.d.ts +17 -2
- package/lib/types/SignInMethod.js +1 -1
- package/nitro.json +0 -3
- package/nitrogen/generated/android/ReactNativeAutoPlay+autolinking.cmake +1 -3
- package/nitrogen/generated/android/ReactNativeAutoPlayOnLoad.cpp +4 -16
- package/nitrogen/generated/android/c++/JFunc_void_std__optional_std__string__std__optional_GoogleSignInAccount_.hpp +79 -0
- package/nitrogen/generated/android/c++/JGoogleSignIn.hpp +81 -0
- package/nitrogen/generated/android/c++/JGoogleSignInAccount.hpp +86 -0
- package/nitrogen/generated/android/c++/JHybridSignInTemplateSpec.cpp +10 -1
- package/nitrogen/generated/android/c++/JSignInMethods.hpp +3 -3
- package/nitrogen/generated/android/c++/JSignInTemplateConfig.hpp +10 -5
- package/nitrogen/generated/android/c++/JVariant_QrSignIn_PinSignIn_InputSignIn_GoogleSignIn.cpp +34 -0
- package/nitrogen/generated/android/c++/{JVariant_QrSignIn_PinSignIn_InputSignIn.hpp → JVariant_QrSignIn_PinSignIn_InputSignIn_GoogleSignIn.hpp} +40 -20
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/swe/iternio/reactnativeautoplay/{Func_void_AppFocusState.kt → Func_void_std__optional_std__string__std__optional_GoogleSignInAccount_.kt} +14 -14
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/swe/iternio/reactnativeautoplay/GoogleSignIn.kt +48 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/swe/iternio/reactnativeautoplay/GoogleSignInAccount.kt +59 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/swe/iternio/reactnativeautoplay/SignInMethods.kt +1 -1
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/swe/iternio/reactnativeautoplay/SignInTemplateConfig.kt +3 -3
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/swe/iternio/reactnativeautoplay/{Variant_QrSignIn_PinSignIn_InputSignIn.kt → Variant_QrSignIn_PinSignIn_InputSignIn_GoogleSignIn.kt} +23 -10
- package/nitrogen/generated/shared/c++/GoogleSignIn.hpp +98 -0
- package/nitrogen/generated/shared/c++/GoogleSignInAccount.hpp +112 -0
- package/nitrogen/generated/shared/c++/SignInMethods.hpp +1 -1
- package/nitrogen/generated/shared/c++/SignInTemplateConfig.hpp +8 -5
- package/package.json +1 -1
- package/src/hooks/useAndroidAutoTelemetry.ts +32 -48
- package/src/index.ts +0 -11
- package/src/types/SignInMethod.ts +19 -2
- package/android/src/auto/java/com/margelo/nitro/swe/iternio/reactnativeautoplay/HybridAndroidAutomotive.kt +0 -25
- package/android/src/automotive/java/com/margelo/nitro/swe/iternio/reactnativeautoplay/HybridAndroidAutomotive.kt +0 -190
- package/lib/hooks/useIsAutoPlayFocused.d.ts +0 -7
- package/lib/hooks/useIsAutoPlayFocused.js +0 -20
- package/lib/hybrid.d.ts +0 -2
- package/lib/hybrid.js +0 -2
- package/lib/specs/AndroidAutomotive.nitro.d.ts +0 -33
- package/lib/specs/AndroidAutomotive.nitro.js +0 -13
- package/lib/specs/AutomotivePermissionRequestTemplate.d.ts +0 -11
- package/lib/specs/AutomotivePermissionRequestTemplate.js +0 -1
- package/lib/specs/AutomotivePermissionRequestTemplate.nitro.d.ts +0 -11
- package/lib/specs/AutomotivePermissionRequestTemplate.nitro.js +0 -1
- package/lib/templates/AutomotivePermissionRequestTemplate.d.ts +0 -23
- package/lib/templates/AutomotivePermissionRequestTemplate.js +0 -18
- package/nitrogen/generated/android/c++/JActiveCarUxRestrictions.hpp +0 -89
- package/nitrogen/generated/android/c++/JAppFocusState.hpp +0 -61
- package/nitrogen/generated/android/c++/JCarUxRestrictions.hpp +0 -82
- package/nitrogen/generated/android/c++/JFunc_void_ActiveCarUxRestrictions.hpp +0 -80
- package/nitrogen/generated/android/c++/JFunc_void_AppFocusState.hpp +0 -78
- package/nitrogen/generated/android/c++/JHybridAndroidAutomotiveSpec.cpp +0 -120
- package/nitrogen/generated/android/c++/JHybridAndroidAutomotiveSpec.hpp +0 -70
- package/nitrogen/generated/android/c++/JVariant_QrSignIn_PinSignIn_InputSignIn.cpp +0 -30
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/swe/iternio/reactnativeautoplay/ActiveCarUxRestrictions.kt +0 -47
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/swe/iternio/reactnativeautoplay/AppFocusState.kt +0 -41
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/swe/iternio/reactnativeautoplay/CarUxRestrictions.kt +0 -31
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/swe/iternio/reactnativeautoplay/Func_void_ActiveCarUxRestrictions.kt +0 -80
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/swe/iternio/reactnativeautoplay/HybridAndroidAutomotiveSpec.kt +0 -88
- package/nitrogen/generated/shared/c++/ActiveCarUxRestrictions.hpp +0 -97
- package/nitrogen/generated/shared/c++/AppFocusState.hpp +0 -87
- package/nitrogen/generated/shared/c++/CarUxRestrictions.hpp +0 -81
- package/nitrogen/generated/shared/c++/HybridAndroidAutomotiveSpec.cpp +0 -25
- package/nitrogen/generated/shared/c++/HybridAndroidAutomotiveSpec.hpp +0 -71
- package/src/specs/AndroidAutomotive.nitro.ts +0 -37
package/android/build.gradle
CHANGED
|
@@ -163,7 +163,7 @@ dependencies {
|
|
|
163
163
|
implementation "androidx.car.app:app-projected:1.7.0"
|
|
164
164
|
}
|
|
165
165
|
|
|
166
|
-
implementation 'com.google.android.gms:play-services-base:18.
|
|
167
|
-
implementation 'com.google.android.gms:play-services-auth:21.
|
|
166
|
+
implementation 'com.google.android.gms:play-services-base:18.10.0'
|
|
167
|
+
implementation 'com.google.android.gms:play-services-auth:21.5.0'
|
|
168
168
|
}
|
|
169
169
|
|
|
@@ -75,6 +75,8 @@
|
|
|
75
75
|
|
|
76
76
|
<service android:name="com.margelo.nitro.swe.iternio.reactnativeautoplay.HeadlessTaskService" />
|
|
77
77
|
|
|
78
|
+
<activity android:name="com.margelo.nitro.swe.iternio.reactnativeautoplay.SignInWithGoogleActivity" />
|
|
79
|
+
|
|
78
80
|
<provider
|
|
79
81
|
android:name="com.margelo.nitro.swe.iternio.reactnativeautoplay.ActivityRenderStateProvider"
|
|
80
82
|
android:authorities="${applicationId}.ActivityRenderStateProvider"
|
|
@@ -7,7 +7,6 @@ import android.car.VehiclePropertyIds
|
|
|
7
7
|
import android.car.hardware.CarPropertyValue
|
|
8
8
|
import android.car.hardware.property.CarPropertyManager
|
|
9
9
|
import android.util.Log
|
|
10
|
-
import com.margelo.nitro.NitroModules
|
|
11
10
|
import kotlin.math.floor
|
|
12
11
|
|
|
13
12
|
private val REQUIRED_VEHICLE_PROPERTY_IDS = listOf(
|
|
@@ -157,10 +156,14 @@ object AndroidTelemetryObserver : TelemetryObserver() {
|
|
|
157
156
|
return false
|
|
158
157
|
}
|
|
159
158
|
|
|
159
|
+
val carContext = AndroidAutoSession.getRootContext() ?: throw IllegalArgumentException(
|
|
160
|
+
"Car context not available, failed to start telemetry"
|
|
161
|
+
)
|
|
162
|
+
|
|
160
163
|
// create new instance so we can access all props after permissions were granted
|
|
161
164
|
mCar?.disconnect()
|
|
162
165
|
|
|
163
|
-
val car = Car.createCar(
|
|
166
|
+
val car = Car.createCar(carContext)
|
|
164
167
|
mCar = car
|
|
165
168
|
|
|
166
169
|
fetchStaticData(car)
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
package com.margelo.nitro.swe.iternio.reactnativeautoplay
|
|
2
|
+
|
|
3
|
+
import android.content.Intent
|
|
4
|
+
import android.os.Binder
|
|
5
|
+
import android.os.Bundle
|
|
6
|
+
import android.os.IBinder
|
|
7
|
+
import androidx.activity.ComponentActivity
|
|
8
|
+
import androidx.activity.result.ActivityResult
|
|
9
|
+
import androidx.activity.result.contract.ActivityResultContracts
|
|
10
|
+
import com.google.android.gms.auth.api.signin.GoogleSignIn
|
|
11
|
+
import com.google.android.gms.auth.api.signin.GoogleSignInAccount
|
|
12
|
+
import com.google.android.gms.auth.api.signin.GoogleSignInOptions
|
|
13
|
+
import java.security.InvalidParameterException
|
|
14
|
+
import javax.annotation.Nullable
|
|
15
|
+
|
|
16
|
+
class SignInWithGoogleActivity : ComponentActivity() {
|
|
17
|
+
override fun onCreate(savedInstanceState: Bundle?) {
|
|
18
|
+
super.onCreate(savedInstanceState)
|
|
19
|
+
|
|
20
|
+
val signInCompleteCallback =
|
|
21
|
+
intent.extras!!.getBinder(BINDER_KEY) as OnSignInComplete?
|
|
22
|
+
|
|
23
|
+
val serverClientId = intent.extras?.getString("serverClientId")
|
|
24
|
+
?: throw InvalidParameterException("missing serverClientId parameter")
|
|
25
|
+
|
|
26
|
+
val activityResultLauncher =
|
|
27
|
+
registerForActivityResult<Intent, ActivityResult>(
|
|
28
|
+
ActivityResultContracts.StartActivityForResult()
|
|
29
|
+
) { result: ActivityResult ->
|
|
30
|
+
val account =
|
|
31
|
+
GoogleSignIn.getSignedInAccountFromIntent(
|
|
32
|
+
result.data
|
|
33
|
+
).result
|
|
34
|
+
signInCompleteCallback!!.onSignInComplete(account)
|
|
35
|
+
finish()
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
val googleSignInClient = GoogleSignIn.getClient(
|
|
39
|
+
this, GoogleSignInOptions.Builder(GoogleSignInOptions.DEFAULT_SIGN_IN)
|
|
40
|
+
.requestServerAuthCode(serverClientId)
|
|
41
|
+
.requestEmail()
|
|
42
|
+
.build()
|
|
43
|
+
)
|
|
44
|
+
activityResultLauncher.launch(googleSignInClient.signInIntent)
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* Binder callback to provide to the sign in activity.
|
|
49
|
+
*/
|
|
50
|
+
abstract
|
|
51
|
+
class OnSignInComplete : Binder(), IBinder {
|
|
52
|
+
/**
|
|
53
|
+
* Notifies that sign in flow completed.
|
|
54
|
+
*
|
|
55
|
+
* @param account the account signed in or `null` if there were issues signing in.
|
|
56
|
+
*/
|
|
57
|
+
abstract fun onSignInComplete(@Nullable account: GoogleSignInAccount?)
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
companion object {
|
|
61
|
+
const val BINDER_KEY = "SignInWithGoogleActivity"
|
|
62
|
+
}
|
|
63
|
+
}
|
|
@@ -1,20 +1,29 @@
|
|
|
1
1
|
package com.margelo.nitro.swe.iternio.reactnativeautoplay.template
|
|
2
2
|
|
|
3
|
+
import android.content.Intent
|
|
3
4
|
import android.net.Uri
|
|
5
|
+
import android.os.Bundle
|
|
6
|
+
import androidx.annotation.Nullable
|
|
4
7
|
import androidx.car.app.CarContext
|
|
8
|
+
import androidx.car.app.CarToast
|
|
9
|
+
import androidx.car.app.model.Action
|
|
5
10
|
import androidx.car.app.model.ActionStrip
|
|
6
11
|
import androidx.car.app.model.InputCallback
|
|
12
|
+
import androidx.car.app.model.ParkedOnlyOnClickListener
|
|
7
13
|
import androidx.car.app.model.Template
|
|
8
14
|
import androidx.car.app.model.signin.InputSignInMethod
|
|
9
15
|
import androidx.car.app.model.signin.InputSignInMethod.INPUT_TYPE_DEFAULT
|
|
10
16
|
import androidx.car.app.model.signin.InputSignInMethod.INPUT_TYPE_PASSWORD
|
|
11
17
|
import androidx.car.app.model.signin.PinSignInMethod
|
|
18
|
+
import androidx.car.app.model.signin.ProviderSignInMethod
|
|
12
19
|
import androidx.car.app.model.signin.QRCodeSignInMethod
|
|
13
20
|
import androidx.car.app.model.signin.SignInTemplate
|
|
21
|
+
import com.google.android.gms.auth.api.signin.GoogleSignInAccount
|
|
14
22
|
import com.margelo.nitro.swe.iternio.reactnativeautoplay.KeyboardType
|
|
15
23
|
import com.margelo.nitro.swe.iternio.reactnativeautoplay.NitroAction
|
|
16
24
|
import com.margelo.nitro.swe.iternio.reactnativeautoplay.NitroActionType
|
|
17
25
|
import com.margelo.nitro.swe.iternio.reactnativeautoplay.SignInTemplateConfig
|
|
26
|
+
import com.margelo.nitro.swe.iternio.reactnativeautoplay.SignInWithGoogleActivity
|
|
18
27
|
import com.margelo.nitro.swe.iternio.reactnativeautoplay.TextInputType
|
|
19
28
|
import java.security.InvalidParameterException
|
|
20
29
|
|
|
@@ -55,6 +64,7 @@ class SignInTemplate(
|
|
|
55
64
|
val qrSignIn = config.signInMethod?.asFirstOrNull()
|
|
56
65
|
val pinSignIn = config.signInMethod?.asSecondOrNull()
|
|
57
66
|
val inputSignIn = config.signInMethod?.asThirdOrNull()
|
|
67
|
+
val googleSignIn = config.signInMethod?.asFourthOrNull()
|
|
58
68
|
|
|
59
69
|
val templateBuilder = when {
|
|
60
70
|
qrSignIn != null -> {
|
|
@@ -94,6 +104,48 @@ class SignInTemplate(
|
|
|
94
104
|
}.build())
|
|
95
105
|
}
|
|
96
106
|
|
|
107
|
+
googleSignIn != null -> {
|
|
108
|
+
val signInAction = Action.Builder().apply {
|
|
109
|
+
setOnClickListener(ParkedOnlyOnClickListener.create {
|
|
110
|
+
val extras = Bundle(1)
|
|
111
|
+
extras.putBinder(
|
|
112
|
+
SignInWithGoogleActivity.BINDER_KEY,
|
|
113
|
+
object : SignInWithGoogleActivity.OnSignInComplete() {
|
|
114
|
+
override fun onSignInComplete(@Nullable account: GoogleSignInAccount?) {
|
|
115
|
+
if (account == null) {
|
|
116
|
+
CarToast.makeText(
|
|
117
|
+
context,
|
|
118
|
+
"Error signing in",
|
|
119
|
+
CarToast.LENGTH_LONG
|
|
120
|
+
).show()
|
|
121
|
+
googleSignIn.callback("Error signing in", null)
|
|
122
|
+
} else {
|
|
123
|
+
googleSignIn.callback(
|
|
124
|
+
null,
|
|
125
|
+
com.margelo.nitro.swe.iternio.reactnativeautoplay.GoogleSignInAccount(
|
|
126
|
+
serverAuthCode = account.serverAuthCode,
|
|
127
|
+
email = account.email,
|
|
128
|
+
id = account.id,
|
|
129
|
+
displayName = account.displayName,
|
|
130
|
+
photoUrl = account.photoUrl.toString(),
|
|
131
|
+
idToken = account.idToken,
|
|
132
|
+
givenName = account.givenName,
|
|
133
|
+
familyName = account.familyName
|
|
134
|
+
)
|
|
135
|
+
)
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
})
|
|
139
|
+
extras.putString("serverClientId", googleSignIn.serverClientId)
|
|
140
|
+
context.startActivity(
|
|
141
|
+
Intent().setClass(context, SignInWithGoogleActivity::class.java)
|
|
142
|
+
.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK).putExtras(extras)
|
|
143
|
+
)
|
|
144
|
+
})
|
|
145
|
+
}.build()
|
|
146
|
+
SignInTemplate.Builder(ProviderSignInMethod(signInAction))
|
|
147
|
+
}
|
|
148
|
+
|
|
97
149
|
else -> throw InvalidParameterException("missing SignInTemplate builder")
|
|
98
150
|
}
|
|
99
151
|
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import type { AndroidAutoPermissions, Telemetry } from '../types/Telemetry';
|
|
2
|
-
|
|
2
|
+
interface Props {
|
|
3
3
|
/**
|
|
4
4
|
* Can be used to delay asking for permissions if set to false. True by default.
|
|
5
5
|
* Can be used to request other permissions first, so the permission request dialogs do not overlap.
|
|
6
6
|
* @default true
|
|
7
7
|
*/
|
|
8
|
-
requestTelemetryPermissions
|
|
8
|
+
requestTelemetryPermissions?: boolean;
|
|
9
9
|
/**
|
|
10
10
|
* The permissions to check.
|
|
11
11
|
*/
|
|
@@ -27,16 +27,7 @@ type Props = {
|
|
|
27
27
|
*/
|
|
28
28
|
cancelButtonText?: string;
|
|
29
29
|
};
|
|
30
|
-
|
|
31
|
-
* set to true in case your build variant targets Android Automotive
|
|
32
|
-
*/
|
|
33
|
-
isAndroidAutomotive?: boolean;
|
|
34
|
-
} | {
|
|
35
|
-
requestTelemetryPermissions: false | undefined;
|
|
36
|
-
requiredPermissions?: never;
|
|
37
|
-
automotivePermissionRequest?: never;
|
|
38
|
-
isAndroidAutomotive?: boolean;
|
|
39
|
-
};
|
|
30
|
+
}
|
|
40
31
|
/**
|
|
41
32
|
* Hook to check if the telemetry permissions are granted. If the permissions are not granted, it will request them from the user.
|
|
42
33
|
*
|
|
@@ -44,7 +35,7 @@ type Props = {
|
|
|
44
35
|
* @param requestTelemetryPermissions If true, the telemetry permissions will be requested from the user. Can be set to false initially, in case other permissions need to be requested first, so the permission request dialogs do not overlap.
|
|
45
36
|
* @param requiredPermissions The permissions to check.
|
|
46
37
|
*/
|
|
47
|
-
export declare const useAndroidAutoTelemetry: ({ requestTelemetryPermissions, requiredPermissions, automotivePermissionRequest,
|
|
38
|
+
export declare const useAndroidAutoTelemetry: ({ requestTelemetryPermissions, requiredPermissions, automotivePermissionRequest, }: Props) => {
|
|
48
39
|
/**
|
|
49
40
|
* null on pending permission check, True if the telemetry permissions are granted, false otherwise.
|
|
50
41
|
*/
|
|
@@ -8,15 +8,12 @@ import { HybridAndroidAutoTelemetry, HybridAutoPlay } from '..';
|
|
|
8
8
|
* @param requestTelemetryPermissions If true, the telemetry permissions will be requested from the user. Can be set to false initially, in case other permissions need to be requested first, so the permission request dialogs do not overlap.
|
|
9
9
|
* @param requiredPermissions The permissions to check.
|
|
10
10
|
*/
|
|
11
|
-
export const useAndroidAutoTelemetry = ({ requestTelemetryPermissions = true, requiredPermissions
|
|
11
|
+
export const useAndroidAutoTelemetry = ({ requestTelemetryPermissions = true, requiredPermissions, automotivePermissionRequest, }) => {
|
|
12
12
|
const [permissionsGranted, setPermissionsGranted] = useState(null);
|
|
13
13
|
const [telemetry, setTelemetry] = useState(undefined);
|
|
14
14
|
const [error, setError] = useState(undefined);
|
|
15
|
-
const [isConnected, setIsConnected] = useState(
|
|
15
|
+
const [isConnected, setIsConnected] = useState(false);
|
|
16
16
|
useEffect(() => {
|
|
17
|
-
if (isAndroidAutomotive) {
|
|
18
|
-
return;
|
|
19
|
-
}
|
|
20
17
|
const removeDidConnect = HybridAutoPlay.addListener('didConnect', () => setIsConnected(true));
|
|
21
18
|
const removeDidDisconnect = HybridAutoPlay.addListener('didDisconnect', () => setIsConnected(false));
|
|
22
19
|
setIsConnected(HybridAutoPlay.isConnected());
|
|
@@ -24,7 +21,7 @@ export const useAndroidAutoTelemetry = ({ requestTelemetryPermissions = true, re
|
|
|
24
21
|
removeDidConnect();
|
|
25
22
|
removeDidDisconnect();
|
|
26
23
|
};
|
|
27
|
-
}, [
|
|
24
|
+
}, []);
|
|
28
25
|
useEffect(() => {
|
|
29
26
|
const checkPermissions = async () => {
|
|
30
27
|
const state = await Promise.all(requiredPermissions.map((permission) => PermissionsAndroid.check(permission).catch(() => false)));
|
package/lib/index.d.ts
CHANGED
|
@@ -1,9 +1,7 @@
|
|
|
1
|
-
import type { AndroidAutomotive } from './specs/AndroidAutomotive.nitro';
|
|
2
1
|
import type { AndroidAutoTelemetry as NitroAndroidAutoTelemetry } from './specs/AndroidAutoTelemetry.nitro';
|
|
3
2
|
import type { AutoPlay as NitroAutoPlay } from './specs/AutoPlay.nitro';
|
|
4
3
|
export declare const HybridAutoPlay: NitroAutoPlay;
|
|
5
4
|
export declare const HybridAndroidAutoTelemetry: NitroAndroidAutoTelemetry | null;
|
|
6
|
-
export declare const HybridAndroidAutomotive: AndroidAutomotive | null;
|
|
7
5
|
/**
|
|
8
6
|
* These are the static module names for the app running on the mobile device, head unit screen and the CarPlay dashboard.
|
|
9
7
|
* Clusters generate uuids on native side that are passed in the RootComponentInitialProps
|
|
@@ -21,8 +19,6 @@ export * from './hooks/useSafeAreaInsets';
|
|
|
21
19
|
export * from './hooks/useVoiceInput';
|
|
22
20
|
export * from './scenes/AutoPlayCluster';
|
|
23
21
|
export * from './scenes/CarPlayDashboardScene';
|
|
24
|
-
export type { ActiveCarUxRestrictions, AppFocusState, } from './specs/AndroidAutomotive.nitro';
|
|
25
|
-
export { CarUxRestrictions } from './specs/AndroidAutomotive.nitro';
|
|
26
22
|
export * from './templates/GridTemplate';
|
|
27
23
|
export * from './templates/InformationTemplate';
|
|
28
24
|
export * from './templates/ListTemplate';
|
package/lib/index.js
CHANGED
|
@@ -6,9 +6,6 @@ export const HybridAutoPlay = NitroModules.createHybridObject('AutoPlay');
|
|
|
6
6
|
export const HybridAndroidAutoTelemetry = Platform.OS === 'android'
|
|
7
7
|
? NitroModules.createHybridObject('AndroidAutoTelemetry')
|
|
8
8
|
: null;
|
|
9
|
-
export const HybridAndroidAutomotive = Platform.OS === 'android'
|
|
10
|
-
? NitroModules.createHybridObject('AndroidAutomotive')
|
|
11
|
-
: null;
|
|
12
9
|
/**
|
|
13
10
|
* These are the static module names for the app running on the mobile device, head unit screen and the CarPlay dashboard.
|
|
14
11
|
* Clusters generate uuids on native side that are passed in the RootComponentInitialProps
|
|
@@ -27,7 +24,6 @@ export * from './hooks/useSafeAreaInsets';
|
|
|
27
24
|
export * from './hooks/useVoiceInput';
|
|
28
25
|
export * from './scenes/AutoPlayCluster';
|
|
29
26
|
export * from './scenes/CarPlayDashboardScene';
|
|
30
|
-
export { CarUxRestrictions } from './specs/AndroidAutomotive.nitro';
|
|
31
27
|
export * from './templates/GridTemplate';
|
|
32
28
|
export * from './templates/InformationTemplate';
|
|
33
29
|
export * from './templates/ListTemplate';
|
|
@@ -1,9 +1,24 @@
|
|
|
1
1
|
export declare enum SignInMethods {
|
|
2
2
|
QR = 0,
|
|
3
|
-
|
|
3
|
+
GOOGLE = 1,
|
|
4
4
|
PIN = 2,
|
|
5
5
|
INPUT = 3
|
|
6
6
|
}
|
|
7
|
+
export type GoogleSignInAccount = {
|
|
8
|
+
serverAuthCode?: string;
|
|
9
|
+
email?: string;
|
|
10
|
+
id?: string;
|
|
11
|
+
displayName?: string;
|
|
12
|
+
photoUrl?: string;
|
|
13
|
+
idToken?: string;
|
|
14
|
+
givenName?: string;
|
|
15
|
+
familyName?: string;
|
|
16
|
+
};
|
|
17
|
+
export type GoogleSignIn = {
|
|
18
|
+
method: SignInMethods.GOOGLE;
|
|
19
|
+
serverClientId: string;
|
|
20
|
+
callback: (error?: string, signInAccount?: GoogleSignInAccount) => void;
|
|
21
|
+
};
|
|
7
22
|
export type PinSignIn = {
|
|
8
23
|
method: SignInMethods.PIN;
|
|
9
24
|
/**
|
|
@@ -35,4 +50,4 @@ export type QrSignIn = {
|
|
|
35
50
|
method: SignInMethods.QR;
|
|
36
51
|
url: string;
|
|
37
52
|
};
|
|
38
|
-
export type SignInMethod = QrSignIn | PinSignIn | InputSignIn;
|
|
53
|
+
export type SignInMethod = QrSignIn | PinSignIn | InputSignIn | GoogleSignIn;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
export var SignInMethods;
|
|
2
2
|
(function (SignInMethods) {
|
|
3
3
|
SignInMethods[SignInMethods["QR"] = 0] = "QR";
|
|
4
|
-
SignInMethods[SignInMethods["
|
|
4
|
+
SignInMethods[SignInMethods["GOOGLE"] = 1] = "GOOGLE";
|
|
5
5
|
SignInMethods[SignInMethods["PIN"] = 2] = "PIN";
|
|
6
6
|
SignInMethods[SignInMethods["INPUT"] = 3] = "INPUT";
|
|
7
7
|
})(SignInMethods || (SignInMethods = {}));
|
package/nitro.json
CHANGED
|
@@ -33,7 +33,6 @@ target_sources(
|
|
|
33
33
|
# Autolinking Setup
|
|
34
34
|
../nitrogen/generated/android/ReactNativeAutoPlayOnLoad.cpp
|
|
35
35
|
# Shared Nitrogen C++ sources
|
|
36
|
-
../nitrogen/generated/shared/c++/HybridAndroidAutomotiveSpec.cpp
|
|
37
36
|
../nitrogen/generated/shared/c++/HybridAndroidAutoTelemetrySpec.cpp
|
|
38
37
|
../nitrogen/generated/shared/c++/HybridAutoPlaySpec.cpp
|
|
39
38
|
../nitrogen/generated/shared/c++/HybridCarPlayDashboardSpec.cpp
|
|
@@ -46,7 +45,6 @@ target_sources(
|
|
|
46
45
|
../nitrogen/generated/shared/c++/HybridSearchTemplateSpec.cpp
|
|
47
46
|
../nitrogen/generated/shared/c++/HybridSignInTemplateSpec.cpp
|
|
48
47
|
# Android-specific Nitrogen C++ sources
|
|
49
|
-
../nitrogen/generated/android/c++/JHybridAndroidAutomotiveSpec.cpp
|
|
50
48
|
../nitrogen/generated/android/c++/JHybridAndroidAutoTelemetrySpec.cpp
|
|
51
49
|
../nitrogen/generated/android/c++/JHybridAutoPlaySpec.cpp
|
|
52
50
|
../nitrogen/generated/android/c++/JVariant_GlyphImage_AssetImage.cpp
|
|
@@ -61,7 +59,7 @@ target_sources(
|
|
|
61
59
|
../nitrogen/generated/android/c++/JHybridMessageTemplateSpec.cpp
|
|
62
60
|
../nitrogen/generated/android/c++/JHybridSearchTemplateSpec.cpp
|
|
63
61
|
../nitrogen/generated/android/c++/JHybridSignInTemplateSpec.cpp
|
|
64
|
-
../nitrogen/generated/android/c++/
|
|
62
|
+
../nitrogen/generated/android/c++/JVariant_QrSignIn_PinSignIn_InputSignIn_GoogleSignIn.cpp
|
|
65
63
|
)
|
|
66
64
|
|
|
67
65
|
# From node_modules/react-native/ReactAndroid/cmake-utils/folly-flags.cmake
|
|
@@ -15,11 +15,8 @@
|
|
|
15
15
|
#include <fbjni/fbjni.h>
|
|
16
16
|
#include <NitroModules/HybridObjectRegistry.hpp>
|
|
17
17
|
|
|
18
|
-
#include "JHybridAndroidAutomotiveSpec.hpp"
|
|
19
|
-
#include "JFunc_void.hpp"
|
|
20
|
-
#include "JFunc_void_ActiveCarUxRestrictions.hpp"
|
|
21
|
-
#include "JFunc_void_AppFocusState.hpp"
|
|
22
18
|
#include "JHybridAndroidAutoTelemetrySpec.hpp"
|
|
19
|
+
#include "JFunc_void.hpp"
|
|
23
20
|
#include "JFunc_void_std__optional_Telemetry_.hpp"
|
|
24
21
|
#include "JHybridAutoPlaySpec.hpp"
|
|
25
22
|
#include "JFunc_void_VisibilityState.hpp"
|
|
@@ -45,6 +42,7 @@
|
|
|
45
42
|
#include "JHybridMessageTemplateSpec.hpp"
|
|
46
43
|
#include "JHybridSearchTemplateSpec.hpp"
|
|
47
44
|
#include "JHybridSignInTemplateSpec.hpp"
|
|
45
|
+
#include "JFunc_void_std__optional_std__string__std__optional_GoogleSignInAccount_.hpp"
|
|
48
46
|
#include <NitroModules/DefaultConstructableObject.hpp>
|
|
49
47
|
|
|
50
48
|
namespace margelo::nitro::swe::iternio::reactnativeautoplay {
|
|
@@ -56,11 +54,8 @@ int initialize(JavaVM* vm) {
|
|
|
56
54
|
|
|
57
55
|
return facebook::jni::initialize(vm, [] {
|
|
58
56
|
// Register native JNI methods
|
|
59
|
-
margelo::nitro::swe::iternio::reactnativeautoplay::JHybridAndroidAutomotiveSpec::registerNatives();
|
|
60
|
-
margelo::nitro::swe::iternio::reactnativeautoplay::JFunc_void_cxx::registerNatives();
|
|
61
|
-
margelo::nitro::swe::iternio::reactnativeautoplay::JFunc_void_ActiveCarUxRestrictions_cxx::registerNatives();
|
|
62
|
-
margelo::nitro::swe::iternio::reactnativeautoplay::JFunc_void_AppFocusState_cxx::registerNatives();
|
|
63
57
|
margelo::nitro::swe::iternio::reactnativeautoplay::JHybridAndroidAutoTelemetrySpec::registerNatives();
|
|
58
|
+
margelo::nitro::swe::iternio::reactnativeautoplay::JFunc_void_cxx::registerNatives();
|
|
64
59
|
margelo::nitro::swe::iternio::reactnativeautoplay::JFunc_void_std__optional_Telemetry__cxx::registerNatives();
|
|
65
60
|
margelo::nitro::swe::iternio::reactnativeautoplay::JHybridAutoPlaySpec::registerNatives();
|
|
66
61
|
margelo::nitro::swe::iternio::reactnativeautoplay::JFunc_void_VisibilityState_cxx::registerNatives();
|
|
@@ -86,6 +81,7 @@ int initialize(JavaVM* vm) {
|
|
|
86
81
|
margelo::nitro::swe::iternio::reactnativeautoplay::JHybridMessageTemplateSpec::registerNatives();
|
|
87
82
|
margelo::nitro::swe::iternio::reactnativeautoplay::JHybridSearchTemplateSpec::registerNatives();
|
|
88
83
|
margelo::nitro::swe::iternio::reactnativeautoplay::JHybridSignInTemplateSpec::registerNatives();
|
|
84
|
+
margelo::nitro::swe::iternio::reactnativeautoplay::JFunc_void_std__optional_std__string__std__optional_GoogleSignInAccount__cxx::registerNatives();
|
|
89
85
|
|
|
90
86
|
// Register Nitro Hybrid Objects
|
|
91
87
|
HybridObjectRegistry::registerHybridObjectConstructor(
|
|
@@ -104,14 +100,6 @@ int initialize(JavaVM* vm) {
|
|
|
104
100
|
return instance->cthis()->shared();
|
|
105
101
|
}
|
|
106
102
|
);
|
|
107
|
-
HybridObjectRegistry::registerHybridObjectConstructor(
|
|
108
|
-
"AndroidAutomotive",
|
|
109
|
-
[]() -> std::shared_ptr<HybridObject> {
|
|
110
|
-
static DefaultConstructableObject<JHybridAndroidAutomotiveSpec::javaobject> object("com/margelo/nitro/swe/iternio/reactnativeautoplay/HybridAndroidAutomotive");
|
|
111
|
-
auto instance = object.create();
|
|
112
|
-
return instance->cthis()->shared();
|
|
113
|
-
}
|
|
114
|
-
);
|
|
115
103
|
HybridObjectRegistry::registerHybridObjectConstructor(
|
|
116
104
|
"SignInTemplate",
|
|
117
105
|
[]() -> std::shared_ptr<HybridObject> {
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// JFunc_void_std__optional_std__string__std__optional_GoogleSignInAccount_.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 <string>
|
|
14
|
+
#include <optional>
|
|
15
|
+
#include "GoogleSignInAccount.hpp"
|
|
16
|
+
#include <functional>
|
|
17
|
+
#include <NitroModules/JNICallable.hpp>
|
|
18
|
+
#include "JGoogleSignInAccount.hpp"
|
|
19
|
+
|
|
20
|
+
namespace margelo::nitro::swe::iternio::reactnativeautoplay {
|
|
21
|
+
|
|
22
|
+
using namespace facebook;
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* Represents the Java/Kotlin callback `(error: String?, signInAccount: GoogleSignInAccount?) -> Unit`.
|
|
26
|
+
* This can be passed around between C++ and Java/Kotlin.
|
|
27
|
+
*/
|
|
28
|
+
struct JFunc_void_std__optional_std__string__std__optional_GoogleSignInAccount_: public jni::JavaClass<JFunc_void_std__optional_std__string__std__optional_GoogleSignInAccount_> {
|
|
29
|
+
public:
|
|
30
|
+
static auto constexpr kJavaDescriptor = "Lcom/margelo/nitro/swe/iternio/reactnativeautoplay/Func_void_std__optional_std__string__std__optional_GoogleSignInAccount_;";
|
|
31
|
+
|
|
32
|
+
public:
|
|
33
|
+
/**
|
|
34
|
+
* Invokes the function this `JFunc_void_std__optional_std__string__std__optional_GoogleSignInAccount_` instance holds through JNI.
|
|
35
|
+
*/
|
|
36
|
+
void invoke(const std::optional<std::string>& error, const std::optional<GoogleSignInAccount>& signInAccount) const {
|
|
37
|
+
static const auto method = javaClassStatic()->getMethod<void(jni::alias_ref<jni::JString> /* error */, jni::alias_ref<JGoogleSignInAccount> /* signInAccount */)>("invoke");
|
|
38
|
+
method(self(), error.has_value() ? jni::make_jstring(error.value()) : nullptr, signInAccount.has_value() ? JGoogleSignInAccount::fromCpp(signInAccount.value()) : nullptr);
|
|
39
|
+
}
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* An implementation of Func_void_std__optional_std__string__std__optional_GoogleSignInAccount_ that is backed by a C++ implementation (using `std::function<...>`)
|
|
44
|
+
*/
|
|
45
|
+
class JFunc_void_std__optional_std__string__std__optional_GoogleSignInAccount__cxx final: public jni::HybridClass<JFunc_void_std__optional_std__string__std__optional_GoogleSignInAccount__cxx, JFunc_void_std__optional_std__string__std__optional_GoogleSignInAccount_> {
|
|
46
|
+
public:
|
|
47
|
+
static jni::local_ref<JFunc_void_std__optional_std__string__std__optional_GoogleSignInAccount_::javaobject> fromCpp(const std::function<void(const std::optional<std::string>& /* error */, const std::optional<GoogleSignInAccount>& /* signInAccount */)>& func) {
|
|
48
|
+
return JFunc_void_std__optional_std__string__std__optional_GoogleSignInAccount__cxx::newObjectCxxArgs(func);
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
public:
|
|
52
|
+
/**
|
|
53
|
+
* Invokes the C++ `std::function<...>` this `JFunc_void_std__optional_std__string__std__optional_GoogleSignInAccount__cxx` instance holds.
|
|
54
|
+
*/
|
|
55
|
+
void invoke_cxx(jni::alias_ref<jni::JString> error, jni::alias_ref<JGoogleSignInAccount> signInAccount) {
|
|
56
|
+
_func(error != nullptr ? std::make_optional(error->toStdString()) : std::nullopt, signInAccount != nullptr ? std::make_optional(signInAccount->toCpp()) : std::nullopt);
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
public:
|
|
60
|
+
[[nodiscard]]
|
|
61
|
+
inline const std::function<void(const std::optional<std::string>& /* error */, const std::optional<GoogleSignInAccount>& /* signInAccount */)>& getFunction() const {
|
|
62
|
+
return _func;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
public:
|
|
66
|
+
static auto constexpr kJavaDescriptor = "Lcom/margelo/nitro/swe/iternio/reactnativeautoplay/Func_void_std__optional_std__string__std__optional_GoogleSignInAccount__cxx;";
|
|
67
|
+
static void registerNatives() {
|
|
68
|
+
registerHybrid({makeNativeMethod("invoke_cxx", JFunc_void_std__optional_std__string__std__optional_GoogleSignInAccount__cxx::invoke_cxx)});
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
private:
|
|
72
|
+
explicit JFunc_void_std__optional_std__string__std__optional_GoogleSignInAccount__cxx(const std::function<void(const std::optional<std::string>& /* error */, const std::optional<GoogleSignInAccount>& /* signInAccount */)>& func): _func(func) { }
|
|
73
|
+
|
|
74
|
+
private:
|
|
75
|
+
friend HybridBase;
|
|
76
|
+
std::function<void(const std::optional<std::string>& /* error */, const std::optional<GoogleSignInAccount>& /* signInAccount */)> _func;
|
|
77
|
+
};
|
|
78
|
+
|
|
79
|
+
} // namespace margelo::nitro::swe::iternio::reactnativeautoplay
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// JGoogleSignIn.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 "GoogleSignIn.hpp"
|
|
12
|
+
|
|
13
|
+
#include "GoogleSignInAccount.hpp"
|
|
14
|
+
#include "JFunc_void_std__optional_std__string__std__optional_GoogleSignInAccount_.hpp"
|
|
15
|
+
#include "JGoogleSignInAccount.hpp"
|
|
16
|
+
#include "JSignInMethods.hpp"
|
|
17
|
+
#include "SignInMethods.hpp"
|
|
18
|
+
#include <NitroModules/JNICallable.hpp>
|
|
19
|
+
#include <functional>
|
|
20
|
+
#include <optional>
|
|
21
|
+
#include <string>
|
|
22
|
+
|
|
23
|
+
namespace margelo::nitro::swe::iternio::reactnativeautoplay {
|
|
24
|
+
|
|
25
|
+
using namespace facebook;
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* The C++ JNI bridge between the C++ struct "GoogleSignIn" and the the Kotlin data class "GoogleSignIn".
|
|
29
|
+
*/
|
|
30
|
+
struct JGoogleSignIn final: public jni::JavaClass<JGoogleSignIn> {
|
|
31
|
+
public:
|
|
32
|
+
static auto constexpr kJavaDescriptor = "Lcom/margelo/nitro/swe/iternio/reactnativeautoplay/GoogleSignIn;";
|
|
33
|
+
|
|
34
|
+
public:
|
|
35
|
+
/**
|
|
36
|
+
* Convert this Java/Kotlin-based struct to the C++ struct GoogleSignIn by copying all values to C++.
|
|
37
|
+
*/
|
|
38
|
+
[[maybe_unused]]
|
|
39
|
+
[[nodiscard]]
|
|
40
|
+
GoogleSignIn toCpp() const {
|
|
41
|
+
static const auto clazz = javaClassStatic();
|
|
42
|
+
static const auto fieldMethod = clazz->getField<JSignInMethods>("method");
|
|
43
|
+
jni::local_ref<JSignInMethods> method = this->getFieldValue(fieldMethod);
|
|
44
|
+
static const auto fieldServerClientId = clazz->getField<jni::JString>("serverClientId");
|
|
45
|
+
jni::local_ref<jni::JString> serverClientId = this->getFieldValue(fieldServerClientId);
|
|
46
|
+
static const auto fieldCallback = clazz->getField<JFunc_void_std__optional_std__string__std__optional_GoogleSignInAccount_::javaobject>("callback");
|
|
47
|
+
jni::local_ref<JFunc_void_std__optional_std__string__std__optional_GoogleSignInAccount_::javaobject> callback = this->getFieldValue(fieldCallback);
|
|
48
|
+
return GoogleSignIn(
|
|
49
|
+
method->toCpp(),
|
|
50
|
+
serverClientId->toStdString(),
|
|
51
|
+
[&]() -> std::function<void(const std::optional<std::string>& /* error */, const std::optional<GoogleSignInAccount>& /* signInAccount */)> {
|
|
52
|
+
if (callback->isInstanceOf(JFunc_void_std__optional_std__string__std__optional_GoogleSignInAccount__cxx::javaClassStatic())) [[likely]] {
|
|
53
|
+
auto downcast = jni::static_ref_cast<JFunc_void_std__optional_std__string__std__optional_GoogleSignInAccount__cxx::javaobject>(callback);
|
|
54
|
+
return downcast->cthis()->getFunction();
|
|
55
|
+
} else {
|
|
56
|
+
auto callbackRef = jni::make_global(callback);
|
|
57
|
+
return JNICallable<JFunc_void_std__optional_std__string__std__optional_GoogleSignInAccount_, void(std::optional<std::string>, std::optional<GoogleSignInAccount>)>(std::move(callbackRef));
|
|
58
|
+
}
|
|
59
|
+
}()
|
|
60
|
+
);
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
public:
|
|
64
|
+
/**
|
|
65
|
+
* Create a Java/Kotlin-based struct by copying all values from the given C++ struct to Java.
|
|
66
|
+
*/
|
|
67
|
+
[[maybe_unused]]
|
|
68
|
+
static jni::local_ref<JGoogleSignIn::javaobject> fromCpp(const GoogleSignIn& value) {
|
|
69
|
+
using JSignature = JGoogleSignIn(jni::alias_ref<JSignInMethods>, jni::alias_ref<jni::JString>, jni::alias_ref<JFunc_void_std__optional_std__string__std__optional_GoogleSignInAccount_::javaobject>);
|
|
70
|
+
static const auto clazz = javaClassStatic();
|
|
71
|
+
static const auto create = clazz->getStaticMethod<JSignature>("fromCpp");
|
|
72
|
+
return create(
|
|
73
|
+
clazz,
|
|
74
|
+
JSignInMethods::fromCpp(value.method),
|
|
75
|
+
jni::make_jstring(value.serverClientId),
|
|
76
|
+
JFunc_void_std__optional_std__string__std__optional_GoogleSignInAccount__cxx::fromCpp(value.callback)
|
|
77
|
+
);
|
|
78
|
+
}
|
|
79
|
+
};
|
|
80
|
+
|
|
81
|
+
} // namespace margelo::nitro::swe::iternio::reactnativeautoplay
|