[Android] Fix overscan incorrectly applied on SecondaryActivity

Nicolas Pomepuy git at videolan.org
Wed Mar 16 10:15:33 UTC 2022


vlc-android | branch: master | Nicolas Pomepuy <nicolas at videolabs.io> | Tue Mar 15 15:21:21 2022 +0100| [8aa59924aff3ce620314ac7dab08e89e79a4b136] | committer: Nicolas Pomepuy

Fix overscan incorrectly applied on SecondaryActivity

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

 .../src/main/java/org/videolan/resources/AndroidDevices.kt         | 2 +-
 application/vlc-android/src/org/videolan/vlc/StartActivity.kt      | 7 +++++--
 .../vlc-android/src/org/videolan/vlc/util/VersionMigration.kt      | 6 +++---
 3 files changed, 9 insertions(+), 6 deletions(-)

diff --git a/application/resources/src/main/java/org/videolan/resources/AndroidDevices.kt b/application/resources/src/main/java/org/videolan/resources/AndroidDevices.kt
index 9fb9aa53d..04bfad5c8 100644
--- a/application/resources/src/main/java/org/videolan/resources/AndroidDevices.kt
+++ b/application/resources/src/main/java/org/videolan/resources/AndroidDevices.kt
@@ -130,7 +130,7 @@ object AndroidDevices {
         isAndroidTv = pm != null && pm.hasSystemFeature("android.software.leanback")
         watchDevices = isAndroidTv && Build.MODEL.startsWith("Bouygtel")
         isChromeBook = pm != null && pm.hasSystemFeature("org.chromium.arc.device_management")
-        isTv = isAndroidTv || !isChromeBook
+        isTv = isAndroidTv || !isChromeBook && !hasTsp
         hasPlayServices = pm == null || hasPlayServices(pm)
         hasPiP = AndroidUtil.isOOrLater && pm != null && pm.hasSystemFeature(PackageManager.FEATURE_PICTURE_IN_PICTURE) || AndroidUtil.isNougatOrLater && isAndroidTv
         pipAllowed = hasPiP || hasTsp && !AndroidUtil.isOOrLater
diff --git a/application/vlc-android/src/org/videolan/vlc/StartActivity.kt b/application/vlc-android/src/org/videolan/vlc/StartActivity.kt
index 7ee59e63f..4cda2fab7 100644
--- a/application/vlc-android/src/org/videolan/vlc/StartActivity.kt
+++ b/application/vlc-android/src/org/videolan/vlc/StartActivity.kt
@@ -236,7 +236,10 @@ class StartActivity : FragmentActivity() {
     }
 
     private fun showTvUi(): Boolean {
-        return (AndroidDevices.isAndroidTv || !AndroidDevices.isChromeBook && !AndroidDevices.hasTsp) &&
-                Settings.getInstance(this).getBoolean("tv_ui", false)
+        val settings = Settings.getInstance(this)
+        //because the [VersionMigration] is done after the first call to this method, we have to keep the old implementation for people coming from an older version of the app
+        if (settings.getInt(KEY_CURRENT_SETTINGS_VERSION, 0) < 5) return AndroidDevices.isAndroidTv || !AndroidDevices.isChromeBook && !AndroidDevices.hasTsp ||
+                settings.getBoolean("tv_ui", false)
+        return  settings.getBoolean("tv_ui", false)
     }
 }
diff --git a/application/vlc-android/src/org/videolan/vlc/util/VersionMigration.kt b/application/vlc-android/src/org/videolan/vlc/util/VersionMigration.kt
index 552947731..c76259b7c 100644
--- a/application/vlc-android/src/org/videolan/vlc/util/VersionMigration.kt
+++ b/application/vlc-android/src/org/videolan/vlc/util/VersionMigration.kt
@@ -139,10 +139,10 @@ object VersionMigration {
     }
 
     /**
-     * Migrate the video hud timeout preference to a value in seconds
+     * Migrate the TV Ui to make sure the preference is setup
      */
     private fun migrateToVersion5(settings: SharedPreferences) {
-        Log.i(this::class.java.simpleName, "Migrating to Version 5: force the TV ui setting if TVui is enforced")
-        if (Settings.showTvUi) settings.putSingle("tv_ui", true)
+        Log.i(this::class.java.simpleName, "Migrating to Version 5: force the TV ui setting if device is TV")
+        if (Settings.device.isTv && settings.getBoolean("tv_ui", false) != settings.getBoolean("tv_ui", true)) settings.putSingle("tv_ui", true)
     }
 }
\ No newline at end of file



More information about the Android mailing list