Legacy fullscreen mode option & Button to toggle screen orientation in video player
This commit is contained in:
parent
d1a556b8c6
commit
be802aa5af
@ -1,6 +1,7 @@
|
|||||||
package sushi.hardcore.droidfs.file_viewers
|
package sushi.hardcore.droidfs.file_viewers
|
||||||
|
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
|
import android.view.View
|
||||||
import androidx.core.view.WindowInsetsCompat
|
import androidx.core.view.WindowInsetsCompat
|
||||||
import androidx.core.view.WindowInsetsControllerCompat
|
import androidx.core.view.WindowInsetsControllerCompat
|
||||||
import sushi.hardcore.droidfs.BaseActivity
|
import sushi.hardcore.droidfs.BaseActivity
|
||||||
@ -24,6 +25,9 @@ abstract class FileViewerActivity: BaseActivity() {
|
|||||||
private var wasMapped = false
|
private var wasMapped = false
|
||||||
protected val mappedPlaylist = mutableListOf<ExplorerElement>()
|
protected val mappedPlaylist = mutableListOf<ExplorerElement>()
|
||||||
protected var currentPlaylistIndex = -1
|
protected var currentPlaylistIndex = -1
|
||||||
|
private val legacyMod by lazy {
|
||||||
|
sharedPrefs.getBoolean("legacyMod", false)
|
||||||
|
}
|
||||||
|
|
||||||
override fun onCreate(savedInstanceState: Bundle?) {
|
override fun onCreate(savedInstanceState: Bundle?) {
|
||||||
super.onCreate(savedInstanceState)
|
super.onCreate(savedInstanceState)
|
||||||
@ -42,8 +46,15 @@ abstract class FileViewerActivity: BaseActivity() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
open fun hideSystemUi() {
|
open fun hideSystemUi() {
|
||||||
|
if (legacyMod) {
|
||||||
|
@Suppress("Deprecation")
|
||||||
|
window.decorView.systemUiVisibility =
|
||||||
|
View.SYSTEM_UI_FLAG_LOW_PROFILE or
|
||||||
|
View.SYSTEM_UI_FLAG_FULLSCREEN
|
||||||
|
} else {
|
||||||
windowInsetsController.hide(WindowInsetsCompat.Type.statusBars())
|
windowInsetsController.hide(WindowInsetsCompat.Type.statusBars())
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
abstract fun getFileType(): String
|
abstract fun getFileType(): String
|
||||||
abstract fun viewFile()
|
abstract fun viewFile()
|
||||||
|
@ -19,6 +19,17 @@ class VideoPlayer: MediaPlayer() {
|
|||||||
|
|
||||||
override fun bindPlayer(player: ExoPlayer) {
|
override fun bindPlayer(player: ExoPlayer) {
|
||||||
binding.videoPlayer.player = player
|
binding.videoPlayer.player = player
|
||||||
|
binding.videoPlayer.setControllerVisibilityListener { visibility ->
|
||||||
|
binding.rotateButton.visibility = visibility
|
||||||
|
}
|
||||||
|
binding.rotateButton.setOnClickListener {
|
||||||
|
requestedOrientation =
|
||||||
|
if (requestedOrientation == ActivityInfo.SCREEN_ORIENTATION_USER_LANDSCAPE)
|
||||||
|
ActivityInfo.SCREEN_ORIENTATION_PORTRAIT
|
||||||
|
else
|
||||||
|
ActivityInfo.SCREEN_ORIENTATION_USER_LANDSCAPE
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun getFileType(): String {
|
override fun getFileType(): String {
|
||||||
|
6
app/src/main/res/drawable/icon_mod.xml
Normal file
6
app/src/main/res/drawable/icon_mod.xml
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
<vector android:height="24dp"
|
||||||
|
android:viewportHeight="24" android:viewportWidth="24"
|
||||||
|
android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android">
|
||||||
|
<path android:fillColor="?attr/colorAccent"
|
||||||
|
android:pathData="M5,16c0,3.87 3.13,7 7,7s7,-3.13 7,-7v-4L5,12v4zM16.12,4.37l2.1,-2.1 -0.82,-0.83 -2.3,2.31C14.16,3.28 13.12,3 12,3s-2.16,0.28 -3.09,0.75L6.6,1.44l-0.82,0.83 2.1,2.1C6.14,5.64 5,7.68 5,10v1h14v-1c0,-2.32 -1.14,-4.36 -2.88,-5.63zM9,9c-0.55,0 -1,-0.45 -1,-1s0.45,-1 1,-1 1,0.45 1,1 -0.45,1 -1,1zM15,9c-0.55,0 -1,-0.45 -1,-1s0.45,-1 1,-1 1,0.45 1,1 -0.45,1 -1,1z"/>
|
||||||
|
</vector>
|
@ -1,9 +1,10 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||||
android:gravity="center"
|
android:gravity="center"
|
||||||
|
android:layoutDirection="ltr"
|
||||||
android:background="@color/fullScreenBackgroundColor">
|
android:background="@color/fullScreenBackgroundColor">
|
||||||
|
|
||||||
<com.google.android.exoplayer2.ui.PlayerView
|
<com.google.android.exoplayer2.ui.PlayerView
|
||||||
@ -14,4 +15,11 @@
|
|||||||
app:show_shuffle_button="true"
|
app:show_shuffle_button="true"
|
||||||
app:repeat_toggle_modes="all|one"/>
|
app:repeat_toggle_modes="all|one"/>
|
||||||
|
|
||||||
</LinearLayout>
|
<ImageButton
|
||||||
|
android:id="@+id/rotate_button"
|
||||||
|
style="@style/ExoMediaButton"
|
||||||
|
android:layout_gravity="top|end"
|
||||||
|
android:layout_marginTop="15dp"
|
||||||
|
android:src="@drawable/icon_screen_rotation"
|
||||||
|
app:tint="@color/white"/>
|
||||||
|
</FrameLayout>
|
@ -190,6 +190,8 @@
|
|||||||
<string name="folders_first_summary">Show folders at the beginning of the list</string>
|
<string name="folders_first_summary">Show folders at the beginning of the list</string>
|
||||||
<string name="auto_fit_title">Video player screen auto-rotation</string>
|
<string name="auto_fit_title">Video player screen auto-rotation</string>
|
||||||
<string name="auto_fit_summary">Auto-rotate the screen to fit video dimensions</string>
|
<string name="auto_fit_summary">Auto-rotate the screen to fit video dimensions</string>
|
||||||
|
<string name="legacy_mod_title">Legacy fullscreen mode</string>
|
||||||
|
<string name="legacy_mod_summary">Try this if windowInsetsController doesn\'t work properly on your device (usually not needed)</string>
|
||||||
<string name="open_tree_failed">No file explorer found. Please install one and retry.</string>
|
<string name="open_tree_failed">No file explorer found. Please install one and retry.</string>
|
||||||
<string name="close_volume">Close volume</string>
|
<string name="close_volume">Close volume</string>
|
||||||
<string name="sort_by">Sort By</string>
|
<string name="sort_by">Sort By</string>
|
||||||
|
@ -19,6 +19,13 @@
|
|||||||
android:defaultValue="false"
|
android:defaultValue="false"
|
||||||
android:icon="@drawable/icon_screen_rotation"/>
|
android:icon="@drawable/icon_screen_rotation"/>
|
||||||
|
|
||||||
|
<SwitchPreferenceCompat
|
||||||
|
android:title="@string/legacy_mod_title"
|
||||||
|
android:summary="@string/legacy_mod_summary"
|
||||||
|
android:key="legacyMod"
|
||||||
|
android:defaultValue="false"
|
||||||
|
android:icon="@drawable/icon_mod"/>
|
||||||
|
|
||||||
</PreferenceCategory>
|
</PreferenceCategory>
|
||||||
|
|
||||||
<PreferenceCategory android:title="@string/explorer">
|
<PreferenceCategory android:title="@string/explorer">
|
||||||
|
Loading…
Reference in New Issue
Block a user