[Android] Improve the Video screen orientation by adding landscape reverse and last used values
Nicolas Pomepuy
git at videolan.org
Fri Apr 16 06:01:09 UTC 2021
vlc-android | branch: master | Nicolas Pomepuy <nicolas at videolabs.io> | Thu Apr 15 08:20:35 2021 +0200| [438a02b51db2346c7684892bc9cf7328d818f955] | committer: Nicolas Pomepuy
Improve the Video screen orientation by adding landscape reverse and last used values
Fixes #1494
> https://code.videolan.org/videolan/vlc-android/commit/438a02b51db2346c7684892bc9cf7328d818f955
---
application/resources/src/main/res/values/arrays.xml | 10 ++++++----
application/resources/src/main/res/values/strings.xml | 3 ++-
application/tools/src/main/java/org/videolan/tools/Settings.kt | 2 ++
application/vlc-android/res/xml/preferences.xml | 1 +
.../src/org/videolan/vlc/gui/video/VideoPlayerActivity.kt | 6 +++++-
5 files changed, 16 insertions(+), 6 deletions(-)
diff --git a/application/resources/src/main/res/values/arrays.xml b/application/resources/src/main/res/values/arrays.xml
index d4c985375..c69181bd9 100644
--- a/application/resources/src/main/res/values/arrays.xml
+++ b/application/resources/src/main/res/values/arrays.xml
@@ -235,15 +235,17 @@
<string-array name="screen_orientation_list">
<item>@string/screen_orientation_sensor</item>
- <item>@string/screen_orientation_start_lock</item>
- <item>@string/screen_orientation_landscape</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>100</item>
- <item>101</item>
<item>102</item>
+ <item>101</item>
+ <item>103</item>
+ <item>98</item>
</string-array>
<string-array name="list_title_ellipsize_list">
diff --git a/application/resources/src/main/res/values/strings.xml b/application/resources/src/main/res/values/strings.xml
index b1071abc3..32bd1b855 100644
--- a/application/resources/src/main/res/values/strings.xml
+++ b/application/resources/src/main/res/values/strings.xml
@@ -258,9 +258,10 @@
<string name="automatic">Automatic</string>
<string name="screen_orientation">Video screen orientation</string>
<string name="screen_orientation_sensor">Automatic (sensor)</string>
- <string name="screen_orientation_start_lock">Locked at start</string>
<string name="screen_orientation_portrait">Portrait</string>
<string name="screen_orientation_landscape">Landscape</string>
+ <string name="screen_orientation_landscape_reverse">Landscape reverse</string>
+ <string name="screen_orientation_last_locked">Last locked orientation</string>
<string name="enable_black_theme">Black theme</string>
<string name="subtitle_text_encoding">Subtitle text encoding</string>
<string name="daynight_title">DayNight mode</string>
diff --git a/application/tools/src/main/java/org/videolan/tools/Settings.kt b/application/tools/src/main/java/org/videolan/tools/Settings.kt
index 3a31744dd..ed6c1b58e 100644
--- a/application/tools/src/main/java/org/videolan/tools/Settings.kt
+++ b/application/tools/src/main/java/org/videolan/tools/Settings.kt
@@ -105,6 +105,8 @@ const val AUDIO_DELAY_GLOBAL = "audio_delay_global"
const val AUDIO_PLAY_PROGRESS_MODE = "audio_play_progress_mode"
const val AUDIO_STOP_AFTER = "audio_stop_after"
+const val LAST_LOCK_ORIENTATION = "last_lock_orientation"
+
class DeviceInfo(context: Context) {
val pm = context.packageManager
val tm = context.getSystemService<TelephonyManager>()!!
diff --git a/application/vlc-android/res/xml/preferences.xml b/application/vlc-android/res/xml/preferences.xml
index 4da8af752..8f88cff19 100644
--- a/application/vlc-android/res/xml/preferences.xml
+++ b/application/vlc-android/res/xml/preferences.xml
@@ -37,6 +37,7 @@
android:entries="@array/screen_orientation_list"
android:entryValues="@array/screen_orientation_values"
android:key="screen_orientation"
+ android:summary="%s"
android:title="@string/screen_orientation"/>
</PreferenceCategory>
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 16bb5cec8..dc58ed75e 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,8 +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, if (windowManager.defaultDisplay.rotation == Surface.ROTATION_270) ActivityInfo.SCREEN_ORIENTATION_REVERSE_LANDSCAPE else ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE)
+ 101 -> PlayerOrientationMode(true, ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE)
102 -> PlayerOrientationMode(true, ActivityInfo.SCREEN_ORIENTATION_PORTRAIT)
+ 103 -> PlayerOrientationMode(true, ActivityInfo.SCREEN_ORIENTATION_REVERSE_LANDSCAPE)
+ 98 -> PlayerOrientationMode(true, settings.getInt(LAST_LOCK_ORIENTATION, ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE))
else -> PlayerOrientationMode(true, getOrientationForLock())
}
@@ -431,6 +433,7 @@ open class VideoPlayerActivity : AppCompatActivity(), PlaybackService.Callback,
// 100 is the value for screen_orientation_start_lock
try {
requestedOrientation = getScreenOrientation(orientationMode)
+ if (orientationMode.locked) settings.putSingle(LAST_LOCK_ORIENTATION, requestedOrientation)
} catch (ignored: IllegalStateException) {
Log.w(TAG, "onCreate: failed to set orientation")
}
@@ -1952,6 +1955,7 @@ open class VideoPlayerActivity : AppCompatActivity(), PlaybackService.Callback,
orientationMode.orientation = getOrientationForLock()
requestedOrientation = getScreenOrientation(orientationMode)
+ if (orientationMode.locked) settings.putSingle(LAST_LOCK_ORIENTATION, requestedOrientation)
overlayDelegate.updateOrientationIcon()
}
More information about the Android
mailing list