@iternio/react-native-auto-play 0.5.1 → 0.5.3

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 CHANGED
@@ -196,6 +196,13 @@ In case you wanna open up your CarPlay app from one of the CarPlay dashboard but
196
196
  ### Android Auto
197
197
  No platform specific setup required - we got you covered with all the required stuff.
198
198
 
199
+ #### ProGuard
200
+ In case you have ProGuard enabled (`def enableProguardInReleaseBuilds = true` in `android/app/build.gradle`), add the following rule to `android/app/proguard-rules.pro`:
201
+
202
+ ```
203
+ -keep class com.margelo.nitro.swe.iternio.reactnativeautoplay.** { *; }
204
+ ```
205
+
199
206
  ### Android Auto Customization
200
207
  You can customize certain behaviors of the library on Android Auto by setting properties in your app's `android/gradle.properties` file.
201
208
 
@@ -9,7 +9,6 @@ import androidx.car.app.hardware.info.Mileage
9
9
  import androidx.car.app.hardware.info.Model
10
10
  import androidx.car.app.hardware.info.Speed
11
11
  import androidx.car.app.versioning.CarAppApiLevels
12
- import androidx.core.content.ContextCompat
13
12
 
14
13
  object AndroidTelemetryObserver : TelemetryObserver() {
15
14
  private var carContext: CarContext? = null
@@ -81,8 +80,6 @@ object AndroidTelemetryObserver : TelemetryObserver() {
81
80
  throw UnsupportedOperationException("Telemetry not supported for this API level ${carContext.carAppApiLevel}")
82
81
  }
83
82
 
84
- val carHardwareExecutor = ContextCompat.getMainExecutor(carContext)
85
-
86
83
  val carHardwareManager = carContext.getCarService(
87
84
  CarHardwareManager::class.java
88
85
  )
@@ -90,7 +87,7 @@ object AndroidTelemetryObserver : TelemetryObserver() {
90
87
 
91
88
  // Request any single shot values.
92
89
  try {
93
- carInfo.fetchModel(carHardwareExecutor, mModelListener)
90
+ carInfo.fetchModel(telemetryExecutor, mModelListener)
94
91
  } catch (_: SecurityException) {
95
92
  } catch (_: NullPointerException) {
96
93
  }
@@ -102,19 +99,19 @@ object AndroidTelemetryObserver : TelemetryObserver() {
102
99
  }
103
100
 
104
101
  try {
105
- carInfo.addEnergyLevelListener(carHardwareExecutor, mEnergyLevelListener)
102
+ carInfo.addEnergyLevelListener(telemetryExecutor, mEnergyLevelListener)
106
103
  } catch (_: SecurityException) {
107
104
  } catch (_: NullPointerException) {
108
105
  }
109
106
 
110
107
  try {
111
- carInfo.addSpeedListener(carHardwareExecutor, mSpeedListener)
108
+ carInfo.addSpeedListener(telemetryExecutor, mSpeedListener)
112
109
  } catch (_: SecurityException) {
113
110
  } catch (_: NullPointerException) {
114
111
  }
115
112
 
116
113
  try {
117
- carInfo.addMileageListener(carHardwareExecutor, mMileageListener)
114
+ carInfo.addMileageListener(telemetryExecutor, mMileageListener)
118
115
  } catch (_: SecurityException) {
119
116
  } catch (_: NullPointerException) {
120
117
  }
@@ -160,7 +160,7 @@ object AndroidTelemetryObserver : TelemetryObserver() {
160
160
  // create new instance so we can access all props after permissions were granted
161
161
  mCar?.disconnect()
162
162
 
163
- val car = Car.createCar(NitroModules.applicationContext)
163
+ val car = Car.createCar(NitroModules.applicationContext, handler)
164
164
  mCar = car
165
165
 
166
166
  fetchStaticData(car)
@@ -1,5 +1,5 @@
1
1
  package com.margelo.nitro.swe.iternio.reactnativeautoplay
2
2
 
3
- class TemplateNotFoundException(templateId: String): Exception(templateId) {
4
- override fun toString(): String = "templateNotFound($message)"
3
+ class TemplateNotFoundException(private val templateId: String): Exception("templateNotFound(\"$templateId\")") {
4
+ override fun toString(): String = "templateNotFound(\"$templateId\")"
5
5
  }
@@ -3,6 +3,7 @@ package com.margelo.nitro.swe.iternio.reactnativeautoplay
3
3
  import android.os.Handler
4
4
  import android.os.HandlerThread
5
5
  import java.util.concurrent.CopyOnWriteArrayList
6
+ import java.util.concurrent.Executor
6
7
 
7
8
  abstract class TelemetryObserver {
8
9
  abstract fun startTelemetryObserver(): Boolean
@@ -12,11 +13,16 @@ abstract class TelemetryObserver {
12
13
  val telemetryHolder = AndroidAutoTelemetryHolder()
13
14
  var isObserverRunning = false
14
15
  val handler: Handler
16
+ val telemetryExecutor: Executor
15
17
 
16
18
  init {
17
19
  val thread = HandlerThread("AndroidTelemetryThread")
18
20
  thread.start()
19
21
  handler = Handler(thread.looper)
22
+
23
+ telemetryExecutor = Executor { command ->
24
+ handler.post(command)
25
+ }
20
26
  }
21
27
 
22
28
  fun addListener(callback: (Telemetry?) -> Unit): () -> Unit {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@iternio/react-native-auto-play",
3
- "version": "0.5.1",
3
+ "version": "0.5.3",
4
4
  "description": "Android Auto and Apple CarPlay for react-native",
5
5
  "main": "lib/index",
6
6
  "module": "lib/index",