[Android] Video player: always lock in sensor mode

Nicolas Pomepuy git at videolan.org
Tue Apr 27 06:02:26 UTC 2021


vlc-android | branch: master | Nicolas Pomepuy <nicolas at videolabs.io> | Mon Apr 19 09:49:02 2021 +0200| [d557e5620c598f08799516c3873ae75f5b1d959e] | committer: Nicolas Pomepuy

Video player: always lock in sensor mode

> https://code.videolan.org/videolan/vlc-android/commit/d557e5620c598f08799516c3873ae75f5b1d959e
---

 .../resources/src/main/res/values/arrays.xml       |  2 --
 .../videolan/vlc/gui/video/VideoPlayerActivity.kt  | 34 +++++++---------------
 .../vlc/gui/video/VideoPlayerOverlayDelegate.kt    |  2 +-
 3 files changed, 12 insertions(+), 26 deletions(-)

diff --git a/application/resources/src/main/res/values/arrays.xml b/application/resources/src/main/res/values/arrays.xml
index c69181bd9..21725331d 100644
--- a/application/resources/src/main/res/values/arrays.xml
+++ b/application/resources/src/main/res/values/arrays.xml
@@ -237,14 +237,12 @@
         <item>@string/screen_orientation_sensor</item>
         <item>@string/screen_orientation_portrait</item>
         <item>@string/screen_orientation_landscape</item>
-        <item>@string/screen_orientation_landscape_reverse</item>
         <item>@string/screen_orientation_last_locked</item>
     </string-array>
     <string-array name="screen_orientation_values" translatable="false">
         <item>99</item>
         <item>102</item>
         <item>101</item>
-        <item>103</item>
         <item>98</item>
     </string-array>
 
diff --git a/application/vlc-android/src/org/videolan/vlc/gui/video/VideoPlayerActivity.kt b/application/vlc-android/src/org/videolan/vlc/gui/video/VideoPlayerActivity.kt
index dc58ed75e..42c5ef71c 100644
--- a/application/vlc-android/src/org/videolan/vlc/gui/video/VideoPlayerActivity.kt
+++ b/application/vlc-android/src/org/videolan/vlc/gui/video/VideoPlayerActivity.kt
@@ -406,10 +406,10 @@ open class VideoPlayerActivity : AppCompatActivity(), PlaybackService.Callback,
         val screenOrientationSetting = Integer.valueOf(settings.getString(SCREEN_ORIENTATION, "99" /*SCREEN ORIENTATION SENSOR*/)!!)
         orientationMode = when (screenOrientationSetting) {
             99 -> PlayerOrientationMode(false)
-            101 -> PlayerOrientationMode(true, ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE)
-            102 -> PlayerOrientationMode(true, ActivityInfo.SCREEN_ORIENTATION_PORTRAIT)
+            101 -> PlayerOrientationMode(true, ActivityInfo.SCREEN_ORIENTATION_SENSOR_LANDSCAPE)
+            102 -> PlayerOrientationMode(true, ActivityInfo.SCREEN_ORIENTATION_SENSOR_PORTRAIT)
             103 -> PlayerOrientationMode(true, ActivityInfo.SCREEN_ORIENTATION_REVERSE_LANDSCAPE)
-            98 -> PlayerOrientationMode(true, settings.getInt(LAST_LOCK_ORIENTATION, ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE))
+            98 -> PlayerOrientationMode(true, settings.getInt(LAST_LOCK_ORIENTATION, ActivityInfo.SCREEN_ORIENTATION_SENSOR_LANDSCAPE))
             else -> PlayerOrientationMode(true, getOrientationForLock())
         }
 
@@ -1893,30 +1893,18 @@ open class VideoPlayerActivity : AppCompatActivity(), PlaybackService.Callback,
             defaultWide = !defaultWide
         return if (defaultWide) {
             when (rot) {
-                Surface.ROTATION_0 -> ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE
-                Surface.ROTATION_90 -> ActivityInfo.SCREEN_ORIENTATION_PORTRAIT
-                Surface.ROTATION_180 ->
-                    // SCREEN_ORIENTATION_REVERSE_PORTRAIT only available since API
-                    // Level 9+
-                    ActivityInfo.SCREEN_ORIENTATION_REVERSE_LANDSCAPE
-                Surface.ROTATION_270 ->
-                    // SCREEN_ORIENTATION_REVERSE_LANDSCAPE only available since API
-                    // Level 9+
-                    ActivityInfo.SCREEN_ORIENTATION_REVERSE_PORTRAIT
+                Surface.ROTATION_0 -> ActivityInfo.SCREEN_ORIENTATION_SENSOR_LANDSCAPE
+                Surface.ROTATION_90 -> ActivityInfo.SCREEN_ORIENTATION_SENSOR_PORTRAIT
+                Surface.ROTATION_180 -> ActivityInfo.SCREEN_ORIENTATION_SENSOR_LANDSCAPE
+                Surface.ROTATION_270 -> ActivityInfo.SCREEN_ORIENTATION_SENSOR_PORTRAIT
                 else -> 0
             }
         } else {
             when (rot) {
-                Surface.ROTATION_0 -> ActivityInfo.SCREEN_ORIENTATION_PORTRAIT
-                Surface.ROTATION_90 -> ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE
-                Surface.ROTATION_180 ->
-                    // SCREEN_ORIENTATION_REVERSE_PORTRAIT only available since API
-                    // Level 9+
-                    ActivityInfo.SCREEN_ORIENTATION_REVERSE_PORTRAIT
-                Surface.ROTATION_270 ->
-                    // SCREEN_ORIENTATION_REVERSE_LANDSCAPE only available since API
-                    // Level 9+
-                    ActivityInfo.SCREEN_ORIENTATION_REVERSE_LANDSCAPE
+                Surface.ROTATION_0 -> ActivityInfo.SCREEN_ORIENTATION_SENSOR_PORTRAIT
+                Surface.ROTATION_90 -> ActivityInfo.SCREEN_ORIENTATION_SENSOR_LANDSCAPE
+                Surface.ROTATION_180 -> ActivityInfo.SCREEN_ORIENTATION_SENSOR_PORTRAIT
+                Surface.ROTATION_270 -> ActivityInfo.SCREEN_ORIENTATION_SENSOR_LANDSCAPE
                 else -> 0
             }
         }
diff --git a/application/vlc-android/src/org/videolan/vlc/gui/video/VideoPlayerOverlayDelegate.kt b/application/vlc-android/src/org/videolan/vlc/gui/video/VideoPlayerOverlayDelegate.kt
index 9d1d951de..508734329 100644
--- a/application/vlc-android/src/org/videolan/vlc/gui/video/VideoPlayerOverlayDelegate.kt
+++ b/application/vlc-android/src/org/videolan/vlc/gui/video/VideoPlayerOverlayDelegate.kt
@@ -533,7 +533,7 @@ class VideoPlayerOverlayDelegate (private val player: VideoPlayerActivity) {
         if (::hudBinding.isInitialized) {
             val drawable = if (!player.orientationMode.locked) {
                 R.drawable.ic_player_rotate
-            } else if (player.orientationMode.orientation == ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE || player.orientationMode.orientation == ActivityInfo.SCREEN_ORIENTATION_REVERSE_LANDSCAPE) {
+            } else if (player.orientationMode.orientation == ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE || player.orientationMode.orientation == ActivityInfo.SCREEN_ORIENTATION_REVERSE_LANDSCAPE || player.orientationMode.orientation == ActivityInfo.SCREEN_ORIENTATION_SENSOR_LANDSCAPE) {
                 R.drawable.ic_player_lock_landscape
             } else {
                 R.drawable.ic_player_lock_portrait



More information about the Android mailing list