@capgo/capacitor-launch-navigator 8.0.21 → 8.0.22
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 +1 -1
- package/android/src/main/java/app/capgo/plugin/launch_navigator/LaunchNavigator.java +15 -26
- package/android/src/main/java/app/capgo/plugin/launch_navigator/LaunchNavigatorPlugin.java +1 -1
- package/ios/Sources/LaunchNavigatorPlugin/LaunchNavigator.swift +25 -31
- package/ios/Sources/LaunchNavigatorPlugin/LaunchNavigatorPlugin.swift +1 -1
- package/ios/Tests/LaunchNavigatorPluginTests/LaunchNavigatorPluginTests.swift +16 -6
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -164,7 +164,7 @@ console.log('Icon failures:', failures);
|
|
|
164
164
|
|
|
165
165
|
- **Coordinates Only**: This plugin only accepts latitude/longitude coordinates for navigation. Address strings are not supported.
|
|
166
166
|
- **Address Geocoding**: If you need to convert addresses to coordinates, use [@capgo/capacitor-nativegeocoder](https://github.com/Cap-go/capacitor-nativegeocoder).
|
|
167
|
-
- **Tesla**: `app: 'tesla'` shares a Google Maps
|
|
167
|
+
- **Tesla**: `app: 'tesla'` shares a Google Maps position text to the Tesla app. Android targets the Tesla app directly; iOS opens the native share sheet because iOS does not allow selecting another app's share extension programmatically.
|
|
168
168
|
|
|
169
169
|
## Supported Navigation Apps
|
|
170
170
|
|
|
@@ -206,7 +206,7 @@ public class LaunchNavigator {
|
|
|
206
206
|
case "gaode":
|
|
207
207
|
return createGaodeIntent(lat, lon, startLat, startLon);
|
|
208
208
|
case "tesla":
|
|
209
|
-
return createTeslaIntent(lat, lon,
|
|
209
|
+
return createTeslaIntent(lat, lon, destinationName);
|
|
210
210
|
default:
|
|
211
211
|
return null;
|
|
212
212
|
}
|
|
@@ -484,40 +484,29 @@ public class LaunchNavigator {
|
|
|
484
484
|
return intent;
|
|
485
485
|
}
|
|
486
486
|
|
|
487
|
-
private Intent createTeslaIntent(double lat, double lon,
|
|
487
|
+
private Intent createTeslaIntent(double lat, double lon, String destinationName) {
|
|
488
488
|
Intent intent = new Intent(Intent.ACTION_SEND);
|
|
489
489
|
intent.setType("text/plain");
|
|
490
|
-
intent.putExtra(Intent.EXTRA_TEXT,
|
|
490
|
+
intent.putExtra(Intent.EXTRA_TEXT, createTeslaShareText(lat, lon, destinationName));
|
|
491
491
|
intent.setPackage("com.teslamotors.tesla");
|
|
492
492
|
return intent;
|
|
493
493
|
}
|
|
494
494
|
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
Locale.US,
|
|
498
|
-
"https://www.google.com/maps/dir/?api=1&destination=%f,%f&travelmode=%s",
|
|
499
|
-
lat,
|
|
500
|
-
lon,
|
|
501
|
-
getGoogleMapsTravelMode(transportMode)
|
|
502
|
-
);
|
|
503
|
-
if (startLat != null && startLon != null) {
|
|
504
|
-
url += String.format(Locale.US, "&origin=%f,%f", startLat, startLon);
|
|
505
|
-
}
|
|
506
|
-
return url;
|
|
495
|
+
static String createTeslaShareText(double lat, double lon, String destinationName) {
|
|
496
|
+
return createTeslaShareLabel(destinationName) + "\n\n" + createGoogleMapsPositionUrl(lat, lon);
|
|
507
497
|
}
|
|
508
498
|
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
return "transit";
|
|
517
|
-
case "driving":
|
|
518
|
-
default:
|
|
519
|
-
return "driving";
|
|
499
|
+
static String createGoogleMapsPositionUrl(double lat, double lon) {
|
|
500
|
+
return String.format(Locale.US, "https://maps.google.com/?q=%.6f,%.6f", lat, lon);
|
|
501
|
+
}
|
|
502
|
+
|
|
503
|
+
private static String createTeslaShareLabel(String destinationName) {
|
|
504
|
+
if (destinationName == null) {
|
|
505
|
+
return "Dropped pin";
|
|
520
506
|
}
|
|
507
|
+
|
|
508
|
+
String normalizedName = destinationName.trim().replaceAll("[\\r\\n]+", " ");
|
|
509
|
+
return normalizedName.isEmpty() ? "Dropped pin" : normalizedName;
|
|
521
510
|
}
|
|
522
511
|
|
|
523
512
|
public boolean isAppAvailable(String app) {
|
|
@@ -10,7 +10,7 @@ import com.getcapacitor.annotation.CapacitorPlugin;
|
|
|
10
10
|
@CapacitorPlugin(name = "LaunchNavigator")
|
|
11
11
|
public class LaunchNavigatorPlugin extends Plugin {
|
|
12
12
|
|
|
13
|
-
private final String pluginVersion = "8.0.
|
|
13
|
+
private final String pluginVersion = "8.0.22";
|
|
14
14
|
|
|
15
15
|
private LaunchNavigator implementation;
|
|
16
16
|
|
|
@@ -171,8 +171,7 @@ struct NavigationAppInfo {
|
|
|
171
171
|
case "tesla":
|
|
172
172
|
shareToTesla(
|
|
173
173
|
destination: destination,
|
|
174
|
-
|
|
175
|
-
transportMode: transportMode,
|
|
174
|
+
destinationName: destinationName,
|
|
176
175
|
viewController: viewController,
|
|
177
176
|
completion: completion
|
|
178
177
|
)
|
|
@@ -493,8 +492,7 @@ struct NavigationAppInfo {
|
|
|
493
492
|
|
|
494
493
|
private func shareToTesla(
|
|
495
494
|
destination: CLLocationCoordinate2D,
|
|
496
|
-
|
|
497
|
-
transportMode: String,
|
|
495
|
+
destinationName: String?,
|
|
498
496
|
viewController: UIViewController?,
|
|
499
497
|
completion: @escaping (Bool, String?) -> Void
|
|
500
498
|
) {
|
|
@@ -503,12 +501,10 @@ struct NavigationAppInfo {
|
|
|
503
501
|
return
|
|
504
502
|
}
|
|
505
503
|
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
let activityViewController = UIActivityViewController(activityItems: [url], applicationActivities: nil)
|
|
504
|
+
let activityViewController = UIActivityViewController(
|
|
505
|
+
activityItems: [teslaShareText(destination: destination, destinationName: destinationName)],
|
|
506
|
+
applicationActivities: nil
|
|
507
|
+
)
|
|
512
508
|
activityViewController.popoverPresentationController?.sourceView = viewController.view
|
|
513
509
|
activityViewController.completionWithItemsHandler = { _, completed, _, error in
|
|
514
510
|
if let error = error {
|
|
@@ -523,31 +519,29 @@ struct NavigationAppInfo {
|
|
|
523
519
|
viewController.present(activityViewController, animated: true)
|
|
524
520
|
}
|
|
525
521
|
|
|
526
|
-
|
|
527
|
-
destination:
|
|
528
|
-
|
|
529
|
-
transportMode: String
|
|
530
|
-
) -> URL? {
|
|
531
|
-
var urlString = "https://www.google.com/maps/dir/?api=1&destination=\(destination.latitude),\(destination.longitude)&travelmode=\(googleMapsTravelMode(transportMode))"
|
|
532
|
-
|
|
533
|
-
if let startCoord = start {
|
|
534
|
-
urlString += "&origin=\(startCoord.latitude),\(startCoord.longitude)"
|
|
535
|
-
}
|
|
522
|
+
func teslaShareText(destination: CLLocationCoordinate2D, destinationName: String?) -> String {
|
|
523
|
+
"\(teslaShareLabel(destinationName))\n\n\(googleMapsPositionURLString(destination: destination))"
|
|
524
|
+
}
|
|
536
525
|
|
|
537
|
-
|
|
526
|
+
func googleMapsPositionURLString(destination: CLLocationCoordinate2D) -> String {
|
|
527
|
+
let coordinates = String(
|
|
528
|
+
format: "%.6f,%.6f",
|
|
529
|
+
locale: Locale(identifier: "en_US_POSIX"),
|
|
530
|
+
destination.latitude,
|
|
531
|
+
destination.longitude
|
|
532
|
+
)
|
|
533
|
+
return "https://maps.google.com/?q=\(coordinates)"
|
|
538
534
|
}
|
|
539
535
|
|
|
540
|
-
private func
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
return "walking"
|
|
544
|
-
case "bicycling":
|
|
545
|
-
return "bicycling"
|
|
546
|
-
case "transit":
|
|
547
|
-
return "transit"
|
|
548
|
-
default:
|
|
549
|
-
return "driving"
|
|
536
|
+
private func teslaShareLabel(_ destinationName: String?) -> String {
|
|
537
|
+
guard let destinationName = destinationName else {
|
|
538
|
+
return "Dropped pin"
|
|
550
539
|
}
|
|
540
|
+
|
|
541
|
+
let normalizedName = destinationName
|
|
542
|
+
.trimmingCharacters(in: .whitespacesAndNewlines)
|
|
543
|
+
.replacingOccurrences(of: "[\\r\\n]+", with: " ", options: .regularExpression)
|
|
544
|
+
return normalizedName.isEmpty ? "Dropped pin" : normalizedName
|
|
551
545
|
}
|
|
552
546
|
|
|
553
547
|
private func encoded(_ value: String) -> String {
|
|
@@ -9,7 +9,7 @@ import MapKit
|
|
|
9
9
|
*/
|
|
10
10
|
@objc(LaunchNavigatorPlugin)
|
|
11
11
|
public class LaunchNavigatorPlugin: CAPPlugin, CAPBridgedPlugin {
|
|
12
|
-
private let pluginVersion: String = "8.0.
|
|
12
|
+
private let pluginVersion: String = "8.0.22"
|
|
13
13
|
public let identifier = "LaunchNavigatorPlugin"
|
|
14
14
|
public let jsName = "LaunchNavigator"
|
|
15
15
|
public let pluginMethods: [CAPPluginMethod] = [
|
|
@@ -1,15 +1,25 @@
|
|
|
1
1
|
import XCTest
|
|
2
|
+
import MapKit
|
|
2
3
|
@testable import LaunchNavigatorPlugin
|
|
3
4
|
|
|
4
5
|
class LaunchNavigatorTests: XCTestCase {
|
|
5
|
-
func
|
|
6
|
-
|
|
7
|
-
|
|
6
|
+
func testTeslaShareTextUsesGoogleMapsPosition() {
|
|
7
|
+
let implementation = LaunchNavigator()
|
|
8
|
+
let destination = CLLocationCoordinate2D(latitude: 47.6205, longitude: -122.3493)
|
|
9
|
+
|
|
10
|
+
XCTAssertEqual(
|
|
11
|
+
"Space Needle\n\nhttps://maps.google.com/?q=47.620500,-122.349300",
|
|
12
|
+
implementation.teslaShareText(destination: destination, destinationName: "Space Needle")
|
|
13
|
+
)
|
|
14
|
+
}
|
|
8
15
|
|
|
16
|
+
func testTeslaShareTextFallsBackToDroppedPinLabel() {
|
|
9
17
|
let implementation = LaunchNavigator()
|
|
10
|
-
let
|
|
11
|
-
let result = implementation.echo(value)
|
|
18
|
+
let destination = CLLocationCoordinate2D(latitude: 47.6205, longitude: -122.3493)
|
|
12
19
|
|
|
13
|
-
XCTAssertEqual(
|
|
20
|
+
XCTAssertEqual(
|
|
21
|
+
"Dropped pin\n\nhttps://maps.google.com/?q=47.620500,-122.349300",
|
|
22
|
+
implementation.teslaShareText(destination: destination, destinationName: " \n ")
|
|
23
|
+
)
|
|
14
24
|
}
|
|
15
25
|
}
|
package/package.json
CHANGED