@iternio/react-native-auto-play 0.5.6 → 0.5.8

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.
@@ -23,6 +23,7 @@ import androidx.annotation.RequiresApi
23
23
  import androidx.car.app.CarContext
24
24
  import androidx.car.app.media.CarAudioRecord
25
25
  import androidx.core.content.ContextCompat
26
+ import androidx.core.net.toUri
26
27
  import com.facebook.react.bridge.UiThreadUtil
27
28
  import com.margelo.nitro.NitroModules
28
29
  import com.margelo.nitro.core.ArrayBuffer
@@ -495,7 +496,7 @@ class VoiceInputManager(
495
496
  .setUsage(AudioAttributes.USAGE_ASSISTANCE_NAVIGATION_GUIDANCE)
496
497
  .build()
497
498
  )
498
- player.setDataSource(context, Uri.parse(uri))
499
+ player.setDataSource(context, resolveUri(context, uri))
499
500
  player.setOnCompletionListener {
500
501
  it.release()
501
502
  if (cont.isActive) { cont.resume(Unit) }
@@ -516,6 +517,21 @@ class VoiceInputManager(
516
517
  }
517
518
  }
518
519
 
520
+ private fun resolveUri(context: Context, uri: String): Uri {
521
+ val parsed = uri.toUri()
522
+ return if (parsed.scheme != null) {
523
+ // Real URI already (dev/Metro http://, file://, content://, etc.)
524
+ parsed
525
+ } else {
526
+ // Release build: bare raw-resource name from RN's Android asset packager
527
+ val resId = context.resources.getIdentifier(uri, "raw", context.packageName)
528
+ if (resId == 0) {
529
+ throw IllegalArgumentException("Raw resource not found for: $uri")
530
+ }
531
+ "android.resource://${context.packageName}/$resId".toUri()
532
+ }
533
+ }
534
+
519
535
  @RequiresApi(Build.VERSION_CODES.O)
520
536
  private fun releaseResources() {
521
537
  carAudioRecord?.stopRecording()
@@ -733,7 +733,7 @@ class MapTemplate: AutoPlayHeaderProviding,
733
733
  Parser.parseTravelEstimates(
734
734
  travelEstimates: nitroManeuver.travelEstimates
735
735
  ),
736
- for: navigationSession.upcomingManeuvers[maneuverIndex]
736
+ for: sessionManeuvers[maneuverIndex]
737
737
  )
738
738
 
739
739
  if index != maneuverIndex {
@@ -805,6 +805,19 @@ class MapTemplate: AutoPlayHeaderProviding,
805
805
  }
806
806
 
807
807
  navigationSession.upcomingManeuvers = upcomingManeuvers
808
+
809
+ // CarPlay only applies an estimate update if the maneuver is already active,
810
+ // since we set new upcomingManeuvers we need to apply the latest travelEstimates on the active maneuver here
811
+ if let currentManeuver = navigationSession.upcomingManeuvers.first,
812
+ let currentNitroManeuver = maneuvers.first
813
+ {
814
+ navigationSession.updateEstimates(
815
+ Parser.parseTravelEstimates(
816
+ travelEstimates: currentNitroManeuver.travelEstimates
817
+ ),
818
+ for: currentManeuver
819
+ )
820
+ }
808
821
  }
809
822
  }
810
823
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@iternio/react-native-auto-play",
3
- "version": "0.5.6",
3
+ "version": "0.5.8",
4
4
  "description": "Android Auto and Apple CarPlay for react-native",
5
5
  "main": "lib/index",
6
6
  "module": "lib/index",