@javascriptcommon/react-native-carplay 2.3.11 → 2.4.2
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 +110 -0
- package/android/gradle/wrapper/gradle-wrapper.jar +0 -0
- package/android/gradle/wrapper/gradle-wrapper.properties +5 -0
- package/android/gradle.properties +20 -0
- package/android/gradlew +234 -0
- package/android/gradlew.bat +89 -0
- package/android/src/main/AndroidManifest.xml +30 -0
- package/android/src/main/AndroidManifestNew.xml +30 -0
- package/android/src/main/java/org/birkir/carplay/CarPlayModule.kt +321 -0
- package/android/src/main/java/org/birkir/carplay/CarPlayPackage.kt +18 -0
- package/android/src/main/java/org/birkir/carplay/CarPlayService.kt +35 -0
- package/android/src/main/java/org/birkir/carplay/CarPlaySession.kt +126 -0
- package/android/src/main/java/org/birkir/carplay/parser/Ext.kt +11 -0
- package/android/src/main/java/org/birkir/carplay/parser/Parser.kt +18 -0
- package/android/src/main/java/org/birkir/carplay/parser/RCTGridTemplate.kt +28 -0
- package/android/src/main/java/org/birkir/carplay/parser/RCTListTemplate.kt +64 -0
- package/android/src/main/java/org/birkir/carplay/parser/RCTMapTemplate.kt +128 -0
- package/android/src/main/java/org/birkir/carplay/parser/RCTMessageTemplate.kt +28 -0
- package/android/src/main/java/org/birkir/carplay/parser/RCTPaneTemplate.kt +24 -0
- package/android/src/main/java/org/birkir/carplay/parser/RCTSearchTemplate.kt +41 -0
- package/android/src/main/java/org/birkir/carplay/parser/RCTTabTemplate.kt +157 -0
- package/android/src/main/java/org/birkir/carplay/parser/RCTTemplate.kt +419 -0
- package/android/src/main/java/org/birkir/carplay/parser/TemplateParser.kt +35 -0
- package/android/src/main/java/org/birkir/carplay/screens/CarScreen.kt +76 -0
- package/android/src/main/java/org/birkir/carplay/screens/CarScreenContext.kt +10 -0
- package/android/src/main/java/org/birkir/carplay/utils/EventEmitter.kt +167 -0
- package/android/src/main/java/org/birkir/carplay/utils/VirtualRenderer.kt +75 -0
- package/ios/RCTConvert+RNCarPlay.h +7 -8
- package/ios/RCTConvert+RNCarPlay.m +4 -3
- package/ios/RNCarPlay.h +11 -14
- package/ios/RNCarPlay.m +749 -945
- package/ios/RNCarPlayViewController.h +10 -0
- package/ios/RNCarPlayViewController.m +50 -0
- package/lib/CarPlay.d.ts +183 -0
- package/lib/CarPlay.d.ts.map +1 -0
- package/lib/index.d.ts +44 -0
- package/lib/index.d.ts.map +1 -0
- package/lib/interfaces/Action.d.ts +13 -0
- package/lib/interfaces/Action.d.ts.map +1 -0
- package/lib/interfaces/AlertAction.d.ts +6 -0
- package/lib/interfaces/AlertAction.d.ts.map +1 -0
- package/lib/interfaces/BarButton.d.ts +39 -0
- package/lib/interfaces/BarButton.d.ts.map +1 -0
- package/lib/interfaces/CarColor.d.ts +2 -0
- package/lib/interfaces/CarColor.d.ts.map +1 -0
- package/lib/interfaces/GridButton.d.ts +24 -0
- package/lib/interfaces/GridButton.d.ts.map +1 -0
- package/lib/interfaces/Header.d.ts +15 -0
- package/lib/interfaces/Header.d.ts.map +1 -0
- package/lib/interfaces/ListItem.d.ts +90 -0
- package/lib/interfaces/ListItem.d.ts.map +1 -0
- package/lib/interfaces/ListItemUpdate.d.ts +15 -0
- package/lib/interfaces/ListItemUpdate.d.ts.map +1 -0
- package/lib/interfaces/ListSection.d.ts +21 -0
- package/lib/interfaces/ListSection.d.ts.map +1 -0
- package/lib/interfaces/Maneuver.d.ts +31 -0
- package/lib/interfaces/Maneuver.d.ts.map +1 -0
- package/lib/interfaces/MapButton.d.ts +27 -0
- package/lib/interfaces/MapButton.d.ts.map +1 -0
- package/lib/interfaces/NavigationAlert.d.ts +44 -0
- package/lib/interfaces/NavigationAlert.d.ts.map +1 -0
- package/lib/interfaces/NavigationInfo.d.ts +17 -0
- package/lib/interfaces/NavigationInfo.d.ts.map +1 -0
- package/lib/interfaces/NavigationStep.d.ts +17 -0
- package/lib/interfaces/NavigationStep.d.ts.map +1 -0
- package/lib/interfaces/Pane.d.ts +29 -0
- package/lib/interfaces/Pane.d.ts.map +1 -0
- package/lib/interfaces/PauseReason.d.ts +8 -0
- package/lib/interfaces/PauseReason.d.ts.map +1 -0
- package/lib/interfaces/Place.d.ts +11 -0
- package/lib/interfaces/Place.d.ts.map +1 -0
- package/lib/interfaces/TextConfiguration.d.ts +6 -0
- package/lib/interfaces/TextConfiguration.d.ts.map +1 -0
- package/lib/interfaces/TimeRemainingColor.d.ts +2 -0
- package/lib/interfaces/TimeRemainingColor.d.ts.map +1 -0
- package/lib/interfaces/TravelEstimates.d.ts +37 -0
- package/lib/interfaces/TravelEstimates.d.ts.map +1 -0
- package/lib/interfaces/VoiceControlState.d.ts +8 -0
- package/lib/interfaces/VoiceControlState.d.ts.map +1 -0
- package/lib/navigation/NavigationSession.d.ts +18 -0
- package/lib/navigation/NavigationSession.d.ts.map +1 -0
- package/lib/navigation/Trip.d.ts +22 -0
- package/lib/navigation/Trip.d.ts.map +1 -0
- package/lib/templates/ActionSheetTemplate.d.ts +18 -0
- package/lib/templates/ActionSheetTemplate.d.ts.map +1 -0
- package/lib/templates/AlertTemplate.d.ts +17 -0
- package/lib/templates/AlertTemplate.d.ts.map +1 -0
- package/lib/templates/ContactTemplate.d.ts +36 -0
- package/lib/templates/ContactTemplate.d.ts.map +1 -0
- package/lib/templates/GridTemplate.d.ts +38 -0
- package/lib/templates/GridTemplate.d.ts.map +1 -0
- package/lib/templates/InformationTemplate.d.ts +28 -0
- package/lib/templates/InformationTemplate.d.ts.map +1 -0
- package/lib/templates/ListTemplate.d.ts +127 -0
- package/lib/templates/ListTemplate.d.ts.map +1 -0
- package/lib/templates/ListTemplate.js +24 -16
- package/lib/templates/MapTemplate.d.ts +171 -0
- package/lib/templates/MapTemplate.d.ts.map +1 -0
- package/lib/templates/NowPlayingTemplate.d.ts +31 -0
- package/lib/templates/NowPlayingTemplate.d.ts.map +1 -0
- package/lib/templates/PointOfInterestTemplate.d.ts +33 -0
- package/lib/templates/PointOfInterestTemplate.d.ts.map +1 -0
- package/lib/templates/SearchTemplate.d.ts +32 -0
- package/lib/templates/SearchTemplate.d.ts.map +1 -0
- package/lib/templates/SearchTemplate.js +2 -2
- package/lib/templates/TabBarTemplate.d.ts +27 -0
- package/lib/templates/TabBarTemplate.d.ts.map +1 -0
- package/lib/templates/Template.d.ts +82 -0
- package/lib/templates/Template.d.ts.map +1 -0
- package/lib/templates/Template.js +1 -1
- package/lib/templates/VoiceControlTemplate.d.ts +18 -0
- package/lib/templates/VoiceControlTemplate.d.ts.map +1 -0
- package/lib/templates/android/AndroidNavigationBaseTemplate.d.ts +19 -0
- package/lib/templates/android/AndroidNavigationBaseTemplate.d.ts.map +1 -0
- package/lib/templates/android/MessageTemplate.d.ts +16 -0
- package/lib/templates/android/MessageTemplate.d.ts.map +1 -0
- package/lib/templates/android/NavigationTemplate.d.ts +44 -0
- package/lib/templates/android/NavigationTemplate.d.ts.map +1 -0
- package/lib/templates/android/PaneTemplate.d.ts +13 -0
- package/lib/templates/android/PaneTemplate.d.ts.map +1 -0
- package/lib/templates/android/PlaceListMapTemplate.d.ts +58 -0
- package/lib/templates/android/PlaceListMapTemplate.d.ts.map +1 -0
- package/lib/templates/android/PlaceListNavigationTemplate.d.ts +51 -0
- package/lib/templates/android/PlaceListNavigationTemplate.d.ts.map +1 -0
- package/lib/templates/android/RoutePreviewNavigationTemplate.d.ts +60 -0
- package/lib/templates/android/RoutePreviewNavigationTemplate.d.ts.map +1 -0
- package/package.json +3 -3
- package/react-native-carplay.podspec +3 -3
- package/src/CarPlay.ts +28 -16
- package/src/interfaces/ListItem.ts +14 -8
- package/src/interfaces/ListSection.ts +1 -1
- package/src/templates/ListTemplate.ts +64 -44
- package/src/templates/NowPlayingTemplate.ts +10 -3
- package/src/templates/SearchTemplate.ts +2 -2
- package/src/templates/Template.ts +1 -1
- package/README.md +0 -633
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
package org.birkir.carplay.utils
|
|
2
|
+
|
|
3
|
+
import android.app.Presentation
|
|
4
|
+
import android.content.Context
|
|
5
|
+
import android.hardware.display.DisplayManager
|
|
6
|
+
import android.os.Bundle
|
|
7
|
+
import android.util.Log
|
|
8
|
+
import android.view.Display
|
|
9
|
+
import android.view.ViewGroup
|
|
10
|
+
import androidx.car.app.AppManager
|
|
11
|
+
import androidx.car.app.CarContext
|
|
12
|
+
import androidx.car.app.SurfaceCallback
|
|
13
|
+
import androidx.car.app.SurfaceContainer
|
|
14
|
+
import com.facebook.react.ReactApplication
|
|
15
|
+
import com.facebook.react.ReactRootView
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Renders the view tree into a surface using VirtualDisplay. It runs the ReactNative component registered
|
|
19
|
+
*/
|
|
20
|
+
class VirtualRenderer(private val context: CarContext, private val moduleName: String) {
|
|
21
|
+
|
|
22
|
+
private var rootView: ReactRootView? = null
|
|
23
|
+
|
|
24
|
+
init {
|
|
25
|
+
context.getCarService(AppManager::class.java).setSurfaceCallback(object : SurfaceCallback {
|
|
26
|
+
override fun onSurfaceAvailable(surfaceContainer: SurfaceContainer) {
|
|
27
|
+
val surface = surfaceContainer.surface
|
|
28
|
+
if (surface == null) {
|
|
29
|
+
Log.w(TAG, "surface is null")
|
|
30
|
+
} else {
|
|
31
|
+
renderPresentation(surfaceContainer)
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
})
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
private fun renderPresentation(container: SurfaceContainer) {
|
|
38
|
+
val manager = context.getSystemService(Context.DISPLAY_SERVICE) as DisplayManager
|
|
39
|
+
val display = manager.createVirtualDisplay(
|
|
40
|
+
"AndroidAutoMapTemplate",
|
|
41
|
+
container.width,
|
|
42
|
+
container.height,
|
|
43
|
+
container.dpi,
|
|
44
|
+
container.surface,
|
|
45
|
+
DisplayManager.VIRTUAL_DISPLAY_FLAG_PRESENTATION,
|
|
46
|
+
)
|
|
47
|
+
val presentation = MapPresentation(context, display.display, moduleName)
|
|
48
|
+
presentation.show()
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
inner class MapPresentation(context: Context, display: Display, private val moduleName: String) :
|
|
52
|
+
Presentation(context, display) {
|
|
53
|
+
override fun onCreate(savedInstanceState: Bundle?) {
|
|
54
|
+
super.onCreate(savedInstanceState)
|
|
55
|
+
val instanceManager =
|
|
56
|
+
(context.applicationContext as ReactApplication).reactNativeHost.reactInstanceManager
|
|
57
|
+
if (rootView == null) {
|
|
58
|
+
Log.d(TAG, "onCreate: rootView is null, initializing rootView")
|
|
59
|
+
rootView = ReactRootView(context).apply {
|
|
60
|
+
startReactApplication(instanceManager, moduleName)
|
|
61
|
+
runApplication()
|
|
62
|
+
}
|
|
63
|
+
} else {
|
|
64
|
+
(rootView?.parent as? ViewGroup)?.removeView(rootView)
|
|
65
|
+
}
|
|
66
|
+
rootView?.let {
|
|
67
|
+
setContentView(it)
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
companion object {
|
|
73
|
+
const val TAG = "VirtualRenderer"
|
|
74
|
+
}
|
|
75
|
+
}
|
|
@@ -3,17 +3,16 @@
|
|
|
3
3
|
#import <CarPlay/CarPlay.h>
|
|
4
4
|
#import <React/RCTConvert.h>
|
|
5
5
|
|
|
6
|
-
API_AVAILABLE(ios(12.0))
|
|
7
6
|
@interface RCTConvert (RNCarPlay)
|
|
8
7
|
|
|
9
8
|
+ (CPTripEstimateStyle)CPTripEstimateStyle:(id)json;
|
|
10
9
|
+ (CPPanDirection)CPPanDirection:(id)json;
|
|
11
|
-
+ (CPAssistantCellPosition)CPAssistantCellPosition:(id)json
|
|
12
|
-
+ (CPAssistantCellVisibility)CPAssistantCellVisibility:(id)json
|
|
13
|
-
+ (CPAssistantCellActionType)CPAssistantCellActionType:(id)json
|
|
14
|
-
+ (CPMapButton
|
|
15
|
-
+ (CPRouteChoice
|
|
16
|
-
+ (MKMapItem
|
|
17
|
-
+ (CPPointOfInterest
|
|
10
|
+
+ (CPAssistantCellPosition)CPAssistantCellPosition:(id)json;
|
|
11
|
+
+ (CPAssistantCellVisibility)CPAssistantCellVisibility:(id)json;
|
|
12
|
+
+ (CPAssistantCellActionType)CPAssistantCellActionType:(id)json;
|
|
13
|
+
+ (CPMapButton*)CPMapButton:(id)json withHandler:(void (^)(CPMapButton * _Nonnull mapButton))handler;
|
|
14
|
+
+ (CPRouteChoice*)CPRouteChoice:(id)json;
|
|
15
|
+
+ (MKMapItem*)MKMapItem:(id)json;
|
|
16
|
+
+ (CPPointOfInterest*)CPPointOfInterest:(id)json;
|
|
18
17
|
+ (CPAlertActionStyle)CPAlertActionStyle:(id)json;
|
|
19
18
|
@end
|
|
@@ -33,7 +33,8 @@ RCT_ENUM_CONVERTER(CPAssistantCellVisibility, (@{
|
|
|
33
33
|
RCT_ENUM_CONVERTER(CPAssistantCellActionType, (@{
|
|
34
34
|
@"playMedia": @(CPAssistantCellActionTypePlayMedia),
|
|
35
35
|
@"startCall": @(CPAssistantCellActionTypeStartCall)
|
|
36
|
-
}),
|
|
36
|
+
}), CPAssistantCellActionTypePlayMedia, integerValue)
|
|
37
|
+
|
|
37
38
|
|
|
38
39
|
+ (CPMapButton*)CPMapButton:(id)json withHandler:(void (^)(CPMapButton * _Nonnull mapButton))handler {
|
|
39
40
|
CPMapButton *mapButton = [[CPMapButton alloc] initWithHandler:handler];
|
|
@@ -43,7 +44,7 @@ RCT_ENUM_CONVERTER(CPAssistantCellActionType, (@{
|
|
|
43
44
|
}
|
|
44
45
|
|
|
45
46
|
if ([json objectForKey:@"focusedImage"]) {
|
|
46
|
-
[mapButton
|
|
47
|
+
[mapButton setFocusedImage:[RCTConvert UIImage:json[@"focusedImage"]]];
|
|
47
48
|
}
|
|
48
49
|
|
|
49
50
|
if ([json objectForKey:@"disabled"]) {
|
|
@@ -70,7 +71,7 @@ RCT_ENUM_CONVERTER(CPAssistantCellActionType, (@{
|
|
|
70
71
|
return [[CPRouteChoice alloc] initWithSummaryVariants:[RCTConvert NSStringArray:json[@"additionalInformationVariants"]] additionalInformationVariants:[RCTConvert NSStringArray:json[@"selectionSummaryVariants"]] selectionSummaryVariants:[RCTConvert NSStringArray:json[@"summaryVariants"]]];
|
|
71
72
|
}
|
|
72
73
|
|
|
73
|
-
+ (CPPointOfInterest*)CPPointOfInterest:(id)json
|
|
74
|
+
+ (CPPointOfInterest*)CPPointOfInterest:(id)json {
|
|
74
75
|
MKMapItem *location = [RCTConvert MKMapItem:json[@"location"]];
|
|
75
76
|
NSString *title = [RCTConvert NSString:json[@"title"]];
|
|
76
77
|
NSString *subtitle = [RCTConvert NSString:json[@"subtitle"]];
|
package/ios/RNCarPlay.h
CHANGED
|
@@ -5,13 +5,10 @@
|
|
|
5
5
|
#import "RCTConvert+RNCarPlay.h"
|
|
6
6
|
#import "RNCPStore.h"
|
|
7
7
|
|
|
8
|
-
|
|
9
|
-
typedef void
|
|
10
|
-
typedef void (^SelectedResultBlock)(void);
|
|
8
|
+
typedef void(^SearchResultUpdateBlock)(NSArray<CPListItem *> * _Nonnull);
|
|
9
|
+
typedef void(^SelectedResultBlock)(void);
|
|
11
10
|
|
|
12
|
-
|
|
13
|
-
@interface RNCarPlay : RCTEventEmitter <RCTBridgeModule, CPInterfaceControllerDelegate, CPSearchTemplateDelegate, CPListTemplateDelegate, CPMapTemplateDelegate, CPTabBarTemplateDelegate, CPPointOfInterestTemplateDelegate, CPNowPlayingTemplateObserver>
|
|
14
|
-
{
|
|
11
|
+
@interface RNCarPlay : RCTEventEmitter<RCTBridgeModule, CPInterfaceControllerDelegate, CPSearchTemplateDelegate, CPListTemplateDelegate, CPMapTemplateDelegate, CPTabBarTemplateDelegate, CPPointOfInterestTemplateDelegate, CPNowPlayingTemplateObserver> {
|
|
15
12
|
CPInterfaceController *interfaceController;
|
|
16
13
|
CPWindow *window;
|
|
17
14
|
SearchResultUpdateBlock searchResultBlock;
|
|
@@ -19,14 +16,14 @@ API_AVAILABLE(ios(12.0))
|
|
|
19
16
|
BOOL isNowPlayingActive;
|
|
20
17
|
}
|
|
21
18
|
|
|
22
|
-
@property(nonatomic, retain) CPInterfaceController *
|
|
23
|
-
@property(nonatomic, retain) CPWindow *
|
|
24
|
-
@property(nonatomic, copy) SearchResultUpdateBlock
|
|
25
|
-
@property(nonatomic, copy) SelectedResultBlock
|
|
26
|
-
@property(nonatomic) BOOL isNowPlayingActive;
|
|
27
|
-
@property(nullable, nonatomic, copy) void (^listImageRowHandler)(CPListImageRowItem * _Nonnull item, NSInteger index, dispatch_block_t _Nonnull completionBlock) API_AVAILABLE(ios(14.0));
|
|
19
|
+
@property (nonatomic, retain) CPInterfaceController *interfaceController;
|
|
20
|
+
@property (nonatomic, retain) CPWindow *window;
|
|
21
|
+
@property (nonatomic, copy) SearchResultUpdateBlock searchResultBlock;
|
|
22
|
+
@property (nonatomic, copy) SelectedResultBlock selectedResultBlock;
|
|
23
|
+
@property (nonatomic) BOOL isNowPlayingActive;
|
|
28
24
|
|
|
29
|
-
+ (void)connectWithInterfaceController:(CPInterfaceController
|
|
30
|
-
+ (void)disconnect;
|
|
25
|
+
+ (void) connectWithInterfaceController:(CPInterfaceController*)interfaceController window:(CPWindow*)window;
|
|
26
|
+
+ (void) disconnect;
|
|
27
|
+
- (NSArray<CPListSection*>*) parseSections:(NSArray*)sections templateId:(NSString *)templateId;
|
|
31
28
|
|
|
32
29
|
@end
|