rn-system-bar 3.1.4 → 3.1.5
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.
|
@@ -340,13 +340,41 @@ class SystemBarModule(
|
|
|
340
340
|
|
|
341
341
|
@ReactMethod
|
|
342
342
|
fun setOrientation(mode: String) {
|
|
343
|
+
// "auto" → always unspecified (follow system auto-rotate toggle unconditionally)
|
|
344
|
+
if (mode == "auto") {
|
|
345
|
+
activity()?.requestedOrientation = ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED
|
|
346
|
+
return
|
|
347
|
+
}
|
|
348
|
+
|
|
349
|
+
// For a specific orientation: check if the device's auto-rotate toggle is ON.
|
|
350
|
+
// auto-rotate ON → use sensor-based variant so the device can still rotate
|
|
351
|
+
// within the requested axis (portrait ↔ reverse-portrait, etc.)
|
|
352
|
+
// auto-rotate OFF → hard-lock to the exact orientation requested
|
|
353
|
+
val autoRotateOn = Settings.System.getInt(
|
|
354
|
+
reactContext.contentResolver,
|
|
355
|
+
Settings.System.ACCELEROMETER_ROTATION,
|
|
356
|
+
0 // default = locked (off)
|
|
357
|
+
) == 1
|
|
358
|
+
|
|
343
359
|
activity()?.requestedOrientation = when (mode) {
|
|
344
|
-
"portrait"
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
360
|
+
"portrait" ->
|
|
361
|
+
if (autoRotateOn) ActivityInfo.SCREEN_ORIENTATION_SENSOR_PORTRAIT
|
|
362
|
+
else ActivityInfo.SCREEN_ORIENTATION_PORTRAIT
|
|
363
|
+
|
|
364
|
+
"landscape" ->
|
|
365
|
+
if (autoRotateOn) ActivityInfo.SCREEN_ORIENTATION_SENSOR_LANDSCAPE
|
|
366
|
+
else ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE
|
|
367
|
+
|
|
368
|
+
"landscape-left" ->
|
|
369
|
+
// Reverse landscape — no sensor variant; honour toggle by using full sensor landscape
|
|
370
|
+
if (autoRotateOn) ActivityInfo.SCREEN_ORIENTATION_SENSOR_LANDSCAPE
|
|
371
|
+
else ActivityInfo.SCREEN_ORIENTATION_REVERSE_LANDSCAPE
|
|
372
|
+
|
|
373
|
+
"landscape-right" ->
|
|
374
|
+
if (autoRotateOn) ActivityInfo.SCREEN_ORIENTATION_SENSOR_LANDSCAPE
|
|
375
|
+
else ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE
|
|
376
|
+
|
|
377
|
+
else -> ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED
|
|
350
378
|
}
|
|
351
379
|
}
|
|
352
380
|
|
package/package.json
CHANGED