@iternio/react-native-auto-play 0.4.4 → 0.4.6
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/src/main/java/com/margelo/nitro/swe/iternio/reactnativeautoplay/VirtualRenderer.kt
CHANGED
|
@@ -7,6 +7,7 @@ import android.graphics.Rect
|
|
|
7
7
|
import android.hardware.display.DisplayManager
|
|
8
8
|
import android.hardware.display.VirtualDisplay
|
|
9
9
|
import android.os.Bundle
|
|
10
|
+
import android.view.ContextThemeWrapper
|
|
10
11
|
import android.view.Display
|
|
11
12
|
import android.view.LayoutInflater
|
|
12
13
|
import android.view.View
|
|
@@ -78,6 +79,7 @@ class VirtualRenderer(
|
|
|
78
79
|
}
|
|
79
80
|
|
|
80
81
|
val manager = context.getSystemService(Context.DISPLAY_SERVICE) as DisplayManager
|
|
82
|
+
virtualDisplay?.release()
|
|
81
83
|
virtualDisplay = manager.createVirtualDisplay(
|
|
82
84
|
moduleName,
|
|
83
85
|
surfaceContainer.width,
|
|
@@ -282,8 +284,14 @@ class VirtualRenderer(
|
|
|
282
284
|
override fun onCreate(savedInstanceState: Bundle?) {
|
|
283
285
|
super.onCreate(savedInstanceState)
|
|
284
286
|
|
|
287
|
+
// Wrap applicationContext with the app theme so AppCompat widgets (e.g. ReactTextView)
|
|
288
|
+
// can resolve their required text-appearance attrs on OEM themes that don't define them
|
|
289
|
+
// (notably Polestar/Volvo Android Automotive: Theme.DeviceDefault.Light.DarkActionBar).
|
|
290
|
+
val appTheme = context.applicationContext.applicationInfo.theme
|
|
291
|
+
val themedContext = ContextThemeWrapper(context.applicationContext, appTheme)
|
|
292
|
+
|
|
285
293
|
if (!this@VirtualRenderer::reactSurfaceImpl.isInitialized) {
|
|
286
|
-
reactSurfaceImpl = ReactSurfaceImpl(
|
|
294
|
+
reactSurfaceImpl = ReactSurfaceImpl(themedContext, moduleName, initialProperties)
|
|
287
295
|
}
|
|
288
296
|
|
|
289
297
|
var splashScreenView: View? = null
|
|
@@ -292,9 +300,9 @@ class VirtualRenderer(
|
|
|
292
300
|
(it.parent as ViewGroup).removeView(it)
|
|
293
301
|
} ?: run {
|
|
294
302
|
splashScreenView =
|
|
295
|
-
if (isCluster) getClusterSplashScreen(
|
|
303
|
+
if (isCluster) getClusterSplashScreen(themedContext, height, width) else null
|
|
296
304
|
|
|
297
|
-
val surfaceView = ReactSurfaceView(
|
|
305
|
+
val surfaceView = ReactSurfaceView(themedContext, reactSurfaceImpl).apply {
|
|
298
306
|
layoutParams = FrameLayout.LayoutParams(
|
|
299
307
|
(width / reactNativeScale).toInt(), (height / reactNativeScale).toInt()
|
|
300
308
|
)
|
|
@@ -330,7 +338,7 @@ class VirtualRenderer(
|
|
|
330
338
|
}
|
|
331
339
|
|
|
332
340
|
|
|
333
|
-
val rootContainer = FrameLayout(
|
|
341
|
+
val rootContainer = FrameLayout(themedContext).apply {
|
|
334
342
|
layoutParams = FrameLayout.LayoutParams(
|
|
335
343
|
FrameLayout.LayoutParams.MATCH_PARENT, FrameLayout.LayoutParams.MATCH_PARENT
|
|
336
344
|
)
|