[Android] Force opening the video player in fullscreen on dex

Nicolas Pomepuy git at videolan.org
Thu May 11 14:08:00 UTC 2023


vlc-android | branch: master | Nicolas Pomepuy <nicolas at videolabs.io> | Thu May 11 12:09:34 2023 +0200| [8d24c2cc47126713b91ccca1850815bf25093360] | committer: Duncan McNamara

Force opening the video player in fullscreen on dex

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

 application/vlc-android/src/org/videolan/vlc/StartActivity.kt  |  3 ++-
 .../src/org/videolan/vlc/gui/video/VideoPlayerActivity.kt      |  4 +---
 application/vlc-android/src/org/videolan/vlc/util/Util.kt      | 10 ++++++++++
 3 files changed, 13 insertions(+), 4 deletions(-)

diff --git a/application/vlc-android/src/org/videolan/vlc/StartActivity.kt b/application/vlc-android/src/org/videolan/vlc/StartActivity.kt
index 633952a489..768b782964 100644
--- a/application/vlc-android/src/org/videolan/vlc/StartActivity.kt
+++ b/application/vlc-android/src/org/videolan/vlc/StartActivity.kt
@@ -52,6 +52,7 @@ import org.videolan.vlc.gui.video.VideoPlayerActivity
 import org.videolan.vlc.media.MediaUtils
 import org.videolan.vlc.util.FileUtils
 import org.videolan.vlc.util.Permissions
+import org.videolan.vlc.util.Util
 import org.videolan.vlc.util.checkWatchNextId
 import videolan.org.commontools.TV_CHANNEL_PATH_APP
 import videolan.org.commontools.TV_CHANNEL_PATH_VIDEO
@@ -249,7 +250,7 @@ class StartActivity : FragmentActivity() {
         intent.flags = Intent.FLAG_ACTIVITY_FORWARD_RESULT.inv() and intent.flags
         if (Permissions.canReadStorage(applicationContext) || getStoragePermission()) when {
             intent.type?.startsWith("video") == true -> try {
-                startActivityForResult(intent.setClass(this at StartActivity, VideoPlayerActivity::class.java).apply { putExtra(VideoPlayerActivity.FROM_EXTERNAL, true) }, PROPAGATE_RESULT)
+                startActivityForResult(intent.setClass(this at StartActivity, VideoPlayerActivity::class.java).apply { putExtra(VideoPlayerActivity.FROM_EXTERNAL, true) }, PROPAGATE_RESULT, Util.getFullScreenBundle())
             } catch (ex: SecurityException) {
                 intent.data?.let { MediaUtils.openMediaNoUi(it) }
             }
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 3786bb545b..82510227df 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
@@ -23,7 +23,6 @@ package org.videolan.vlc.gui.video
 import android.annotation.SuppressLint
 import android.annotation.TargetApi
 import android.app.Activity
-import android.app.ActivityOptions
 import android.app.KeyguardManager
 import android.app.PictureInPictureParams
 import android.bluetooth.BluetoothA2dp
@@ -32,7 +31,6 @@ import android.content.*
 import android.content.pm.ActivityInfo
 import android.content.res.Configuration
 import android.graphics.Bitmap
-import android.graphics.Rect
 import android.media.AudioManager
 import android.net.Uri
 import android.os.*
@@ -2379,7 +2377,7 @@ open class VideoPlayerActivity : AppCompatActivity(), PlaybackService.Callback,
 
         private fun start(context: Context, uri: Uri, title: String?, fromStart: Boolean, openedPosition: Int) {
             val intent = getIntent(context, uri, title, fromStart, openedPosition)
-            context.startActivity(intent)
+            context.startActivity(intent, Util.getFullScreenBundle())
         }
 
         fun getIntent(action: String, mw: MediaWrapper, fromStart: Boolean, openedPosition: Int): Intent {
diff --git a/application/vlc-android/src/org/videolan/vlc/util/Util.kt b/application/vlc-android/src/org/videolan/vlc/util/Util.kt
index 8a67ff4603..d2fce8a4cd 100644
--- a/application/vlc-android/src/org/videolan/vlc/util/Util.kt
+++ b/application/vlc-android/src/org/videolan/vlc/util/Util.kt
@@ -21,8 +21,12 @@
 package org.videolan.vlc.util
 
 import android.app.Activity
+import android.app.ActivityOptions
 import android.app.Service
 import android.content.Context
+import android.graphics.Rect
+import android.os.Build
+import android.os.Bundle
 import org.videolan.resources.AppContextProvider
 import org.videolan.resources.VLCInstance
 import org.videolan.tools.CloseableUtils
@@ -76,4 +80,10 @@ object Util {
         })
     }
 
+    fun getFullScreenBundle() = if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
+        val options = ActivityOptions.makeBasic()
+        options.launchBounds = Rect(0, 0, 0, 0)
+        options.toBundle()
+    } else Bundle()
+
 }



More information about the Android mailing list