mirror of
https://github.com/aniyomiorg/aniyomi.git
synced 2024-11-29 09:39:03 +03:00
Few more QOLs (#602)
This commit is contained in:
parent
0c657faac1
commit
17bf803421
5 changed files with 225 additions and 88 deletions
|
@ -19,8 +19,16 @@ object PreferenceKeys {
|
|||
|
||||
const val defaultPlayerOrientationType = "pref_default_player_orientation_type_key"
|
||||
|
||||
const val adjustOrientationVideoDimensions = "pref_adjust_orientation_video_dimensions"
|
||||
|
||||
const val defaultPlayerOrientationLandscape = "pref_default_player_orientation_landscape_key"
|
||||
|
||||
const val defaultPlayerOrientationPortrait = "pref_default_player_orientation_portrait_key"
|
||||
|
||||
const val playerSpeed = "pref_player_speed"
|
||||
|
||||
const val playerFastSeek = "pref_player_fast_seek"
|
||||
|
||||
const val playerViewMode = "pref_player_view_mode"
|
||||
|
||||
const val progressPreference = "pref_progress_preference"
|
||||
|
|
|
@ -129,7 +129,13 @@ class PreferencesHelper(val context: Context) {
|
|||
|
||||
fun defaultOrientationType() = prefs.getInt(Keys.defaultOrientationType, OrientationType.FREE.flagValue)
|
||||
|
||||
fun defaultPlayerOrientationType() = prefs.getInt(Keys.defaultPlayerOrientationType, OrientationType.FREE.flagValue)
|
||||
fun defaultPlayerOrientationType() = prefs.getString(Keys.defaultPlayerOrientationType, "10")!!.toInt()
|
||||
|
||||
fun adjustOrientationVideoDimensions() = prefs.getBoolean(Keys.adjustOrientationVideoDimensions, true)
|
||||
|
||||
fun defaultPlayerOrientationLandscape() = prefs.getString(Keys.defaultPlayerOrientationLandscape, "6")!!.toInt()
|
||||
|
||||
fun defaultPlayerOrientationPortrait() = prefs.getString(Keys.defaultPlayerOrientationPortrait, "7")!!.toInt()
|
||||
|
||||
fun getPlayerSpeed() = prefs.getFloat(Keys.playerSpeed, 1F)
|
||||
|
||||
|
@ -137,6 +143,8 @@ class PreferencesHelper(val context: Context) {
|
|||
putFloat(Keys.playerSpeed, newSpeed)
|
||||
}
|
||||
|
||||
fun getPlayerFastSeek() = prefs.getBoolean(Keys.playerFastSeek, false)
|
||||
|
||||
fun getPlayerViewMode() = prefs.getInt(Keys.playerViewMode, 1)
|
||||
|
||||
fun playerFullscreen() = prefs.getBoolean("player_fullscreen", true)
|
||||
|
|
|
@ -9,12 +9,9 @@ import android.content.BroadcastReceiver
|
|||
import android.content.Context
|
||||
import android.content.Intent
|
||||
import android.content.IntentFilter
|
||||
import android.content.pm.ActivityInfo
|
||||
import android.content.pm.PackageManager
|
||||
import android.content.res.ColorStateList
|
||||
import android.content.res.Configuration
|
||||
import android.content.res.Configuration.ORIENTATION_LANDSCAPE
|
||||
import android.content.res.Configuration.ORIENTATION_PORTRAIT
|
||||
import android.graphics.Color
|
||||
import android.graphics.drawable.Icon
|
||||
import android.media.AudioFocusRequest
|
||||
|
@ -208,6 +205,7 @@ class PlayerActivity :
|
|||
AnimationUtils.loadAnimation(this, R.anim.fade_out_medium).also { fadeAnimation ->
|
||||
binding.seekView.startAnimation(fadeAnimation)
|
||||
binding.seekView.visibility = View.GONE
|
||||
diffSeekMain = 0
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -235,7 +233,7 @@ class PlayerActivity :
|
|||
"seek" -> {
|
||||
callback = seekTextRunnable
|
||||
itemView = binding.seekView
|
||||
delay = 750L
|
||||
delay = 1000L
|
||||
}
|
||||
"volume" -> {
|
||||
callback = volumeViewRunnable
|
||||
|
@ -288,6 +286,8 @@ class PlayerActivity :
|
|||
binding = PlayerActivityBinding.inflate(layoutInflater)
|
||||
setContentView(binding.root)
|
||||
|
||||
this@PlayerActivity.requestedOrientation = preferences.defaultPlayerOrientationType()
|
||||
|
||||
window.statusBarColor = 70000000
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O_MR1) {
|
||||
window.navigationBarColor = 70000000
|
||||
|
@ -440,9 +440,9 @@ class PlayerActivity :
|
|||
override fun onConfigurationChanged(newConfig: Configuration) {
|
||||
super.onConfigurationChanged(newConfig)
|
||||
if (!isPipStarted) {
|
||||
if (newConfig.orientation == ORIENTATION_LANDSCAPE) {
|
||||
if (newConfig.orientation == Configuration.ORIENTATION_LANDSCAPE) {
|
||||
switchOrientation(true)
|
||||
} else if (newConfig.orientation == ORIENTATION_PORTRAIT) {
|
||||
} else if (newConfig.orientation == Configuration.ORIENTATION_PORTRAIT) {
|
||||
switchOrientation(false)
|
||||
}
|
||||
}
|
||||
|
@ -591,10 +591,10 @@ class PlayerActivity :
|
|||
@Suppress("UNUSED_PARAMETER")
|
||||
@SuppressLint("SourceLockedOrientationActivity")
|
||||
fun rotatePlayer(view: View) {
|
||||
if (this.requestedOrientation == ActivityInfo.SCREEN_ORIENTATION_SENSOR_PORTRAIT) {
|
||||
this.requestedOrientation = ActivityInfo.SCREEN_ORIENTATION_SENSOR_LANDSCAPE
|
||||
if (this.resources.configuration.orientation == Configuration.ORIENTATION_PORTRAIT) {
|
||||
this.requestedOrientation = preferences.defaultPlayerOrientationLandscape()
|
||||
} else {
|
||||
this.requestedOrientation = ActivityInfo.SCREEN_ORIENTATION_SENSOR_PORTRAIT
|
||||
this.requestedOrientation = preferences.defaultPlayerOrientationPortrait()
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -640,11 +640,9 @@ class PlayerActivity :
|
|||
ObjectAnimator.ofFloat(v, "alpha", 0f, 0.2f).setDuration(500).start()
|
||||
ObjectAnimator.ofFloat(v, "alpha", 0.2f, 0.2f, 0f).setDuration(1000).start()
|
||||
val newPos = (player.timePos ?: 0) + time // only for display
|
||||
MPVLib.command(arrayOf("seek", time.toString(), "relative"))
|
||||
MPVLib.command(arrayOf("seek", time.toString(), "relative+exact"))
|
||||
|
||||
val diffText = Utils.prettyTime(time, true)
|
||||
binding.seekText.text = getString(R.string.ui_seek_distance, Utils.prettyTime(newPos), diffText)
|
||||
showGestureView("seek")
|
||||
editSeekText(newPos, time)
|
||||
}
|
||||
|
||||
fun verticalScrollLeft(diff: Float) {
|
||||
|
@ -741,11 +739,26 @@ class PlayerActivity :
|
|||
}
|
||||
val newPos = (initialSeek + diff.toInt()).coerceIn(0, duration)
|
||||
val newDiff = newPos - initialSeek
|
||||
// seek faster than assigning to timePos but less precise
|
||||
MPVLib.command(arrayOf("seek", newPos.toString(), "absolute+keyframes"))
|
||||
|
||||
val seekFlags = if (preferences.getPlayerFastSeek()) "absolute+keyframes" else "absolute"
|
||||
|
||||
MPVLib.command(arrayOf("seek", newPos.toString(), seekFlags))
|
||||
playerControls.updatePlaybackPos(newPos)
|
||||
|
||||
val diffText = Utils.prettyTime(newDiff, true)
|
||||
editSeekText(newPos, newDiff, true)
|
||||
}
|
||||
|
||||
private var diffSeekMain = 0
|
||||
private var diffSeekHorizontal = 0
|
||||
private fun editSeekText(newPos: Int, diff: Int, isHorizontalSeek: Boolean = false) {
|
||||
if (isHorizontalSeek) {
|
||||
diffSeekMain += diff - diffSeekHorizontal
|
||||
diffSeekHorizontal = diff
|
||||
} else {
|
||||
diffSeekMain += diff
|
||||
diffSeekHorizontal = 0
|
||||
}
|
||||
val diffText = Utils.prettyTime(diffSeekMain, true)
|
||||
binding.seekText.text = getString(R.string.ui_seek_distance, Utils.prettyTime(newPos), diffText)
|
||||
showGestureView("seek")
|
||||
}
|
||||
|
@ -1206,12 +1219,14 @@ class PlayerActivity :
|
|||
}
|
||||
launchUI {
|
||||
showLoadingIndicator(false)
|
||||
if (player.videoW!! / player.videoH!! >= 1) {
|
||||
this@PlayerActivity.requestedOrientation = ActivityInfo.SCREEN_ORIENTATION_SENSOR_LANDSCAPE
|
||||
switchOrientation(true)
|
||||
} else {
|
||||
this@PlayerActivity.requestedOrientation = ActivityInfo.SCREEN_ORIENTATION_SENSOR_PORTRAIT
|
||||
switchOrientation(false)
|
||||
if (preferences.adjustOrientationVideoDimensions()) {
|
||||
if (player.videoW!! / player.videoH!! >= 1) {
|
||||
this@PlayerActivity.requestedOrientation = preferences.defaultPlayerOrientationLandscape()
|
||||
switchOrientation(true)
|
||||
} else {
|
||||
this@PlayerActivity.requestedOrientation = preferences.defaultPlayerOrientationPortrait()
|
||||
switchOrientation(false)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
package eu.kanade.tachiyomi.ui.setting
|
||||
|
||||
import android.content.pm.ActivityInfo
|
||||
import android.content.pm.PackageManager
|
||||
import android.os.Build
|
||||
import android.text.InputType.TYPE_CLASS_TEXT
|
||||
|
@ -11,6 +12,8 @@ import eu.kanade.tachiyomi.util.preference.defaultValue
|
|||
import eu.kanade.tachiyomi.util.preference.editTextPreference
|
||||
import eu.kanade.tachiyomi.util.preference.entriesRes
|
||||
import eu.kanade.tachiyomi.util.preference.listPreference
|
||||
import eu.kanade.tachiyomi.util.preference.preferenceCategory
|
||||
import eu.kanade.tachiyomi.util.preference.summaryRes
|
||||
import eu.kanade.tachiyomi.util.preference.switchPreference
|
||||
import eu.kanade.tachiyomi.util.preference.titleRes
|
||||
import eu.kanade.tachiyomi.data.preference.PreferenceKeys as Keys
|
||||
|
@ -47,85 +50,176 @@ class SettingsPlayerController : SettingsController() {
|
|||
summary = "%s"
|
||||
}
|
||||
|
||||
listPreference {
|
||||
key = Keys.skipLengthPreference
|
||||
titleRes = R.string.pref_skip_length
|
||||
preferenceCategory {
|
||||
titleRes = R.string.pref_category_player_orientation
|
||||
|
||||
entriesRes = arrayOf(
|
||||
R.string.pref_skip_30,
|
||||
R.string.pref_skip_20,
|
||||
R.string.pref_skip_10,
|
||||
R.string.pref_skip_5,
|
||||
R.string.pref_skip_disable,
|
||||
)
|
||||
entryValues = arrayOf(
|
||||
"30",
|
||||
"20",
|
||||
"10",
|
||||
"5",
|
||||
"0",
|
||||
)
|
||||
defaultValue = "10"
|
||||
listPreference {
|
||||
key = Keys.defaultPlayerOrientationType
|
||||
titleRes = R.string.pref_default_player_orientation
|
||||
|
||||
summary = "%s"
|
||||
}
|
||||
entriesRes = arrayOf(
|
||||
R.string.rotation_free,
|
||||
R.string.rotation_portrait,
|
||||
R.string.rotation_reverse_portrait,
|
||||
R.string.rotation_landscape,
|
||||
R.string.rotation_reverse_landscape,
|
||||
R.string.rotation_sensor_portrait,
|
||||
R.string.rotation_sensor_landscape,
|
||||
)
|
||||
entryValues = arrayOf(
|
||||
"${ActivityInfo.SCREEN_ORIENTATION_FULL_SENSOR}",
|
||||
"${ActivityInfo.SCREEN_ORIENTATION_PORTRAIT}",
|
||||
"${ActivityInfo.SCREEN_ORIENTATION_REVERSE_PORTRAIT}",
|
||||
"${ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE}",
|
||||
"${ActivityInfo.SCREEN_ORIENTATION_REVERSE_LANDSCAPE}",
|
||||
"${ActivityInfo.SCREEN_ORIENTATION_SENSOR_PORTRAIT}",
|
||||
"${ActivityInfo.SCREEN_ORIENTATION_SENSOR_LANDSCAPE}",
|
||||
)
|
||||
defaultValue = "${ActivityInfo.SCREEN_ORIENTATION_FULL_SENSOR}"
|
||||
|
||||
summary = "%s"
|
||||
}
|
||||
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) {
|
||||
switchPreference {
|
||||
key = "player_fullscreen"
|
||||
titleRes = R.string.pref_player_fullscreen
|
||||
key = Keys.adjustOrientationVideoDimensions
|
||||
titleRes = R.string.pref_adjust_orientation_video_dimensions
|
||||
defaultValue = true
|
||||
}
|
||||
|
||||
listPreference {
|
||||
key = Keys.defaultPlayerOrientationPortrait
|
||||
titleRes = R.string.pref_default_portrait_orientation
|
||||
|
||||
entriesRes = arrayOf(
|
||||
R.string.rotation_portrait,
|
||||
R.string.rotation_reverse_portrait,
|
||||
R.string.rotation_sensor_portrait,
|
||||
)
|
||||
entryValues = arrayOf(
|
||||
"${ActivityInfo.SCREEN_ORIENTATION_PORTRAIT}",
|
||||
"${ActivityInfo.SCREEN_ORIENTATION_REVERSE_PORTRAIT}",
|
||||
"${ActivityInfo.SCREEN_ORIENTATION_SENSOR_PORTRAIT}",
|
||||
)
|
||||
defaultValue = "${ActivityInfo.SCREEN_ORIENTATION_SENSOR_PORTRAIT}"
|
||||
|
||||
summary = "%s"
|
||||
}
|
||||
|
||||
listPreference {
|
||||
key = Keys.defaultPlayerOrientationLandscape
|
||||
titleRes = R.string.pref_default_landscape_orientation
|
||||
|
||||
entriesRes = arrayOf(
|
||||
R.string.rotation_landscape,
|
||||
R.string.rotation_reverse_landscape,
|
||||
R.string.rotation_sensor_landscape,
|
||||
)
|
||||
entryValues = arrayOf(
|
||||
"${ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE}",
|
||||
"${ActivityInfo.SCREEN_ORIENTATION_REVERSE_LANDSCAPE}",
|
||||
"${ActivityInfo.SCREEN_ORIENTATION_SENSOR_LANDSCAPE}",
|
||||
)
|
||||
defaultValue = "${ActivityInfo.SCREEN_ORIENTATION_SENSOR_LANDSCAPE}"
|
||||
|
||||
summary = "%s"
|
||||
}
|
||||
}
|
||||
|
||||
if (context.packageManager.hasSystemFeature(PackageManager.FEATURE_PICTURE_IN_PICTURE) && Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
||||
preferenceCategory {
|
||||
titleRes = R.string.pref_category_internal_player
|
||||
|
||||
listPreference {
|
||||
key = Keys.skipLengthPreference
|
||||
titleRes = R.string.pref_skip_length
|
||||
|
||||
entriesRes = arrayOf(
|
||||
R.string.pref_skip_30,
|
||||
R.string.pref_skip_20,
|
||||
R.string.pref_skip_10,
|
||||
R.string.pref_skip_5,
|
||||
R.string.pref_skip_disable,
|
||||
)
|
||||
entryValues = arrayOf(
|
||||
"30",
|
||||
"20",
|
||||
"10",
|
||||
"5",
|
||||
"0",
|
||||
)
|
||||
defaultValue = "10"
|
||||
|
||||
summary = "%s"
|
||||
}
|
||||
|
||||
switchPreference {
|
||||
key = Keys.pipEpisodeToasts
|
||||
titleRes = R.string.pref_pip_episode_toasts
|
||||
defaultValue = true
|
||||
key = Keys.playerFastSeek
|
||||
titleRes = R.string.pref_player_fast_seek
|
||||
defaultValue = false
|
||||
summaryRes = R.string.pref_player_fast_seek_summary
|
||||
}
|
||||
}
|
||||
|
||||
editTextPreference {
|
||||
key = Keys.mpvConf
|
||||
titleRes = R.string.pref_mpv_conf
|
||||
setOnBindEditTextListener {
|
||||
it.inputType = TYPE_CLASS_TEXT or TYPE_TEXT_FLAG_MULTI_LINE or TYPE_TEXT_FLAG_NO_SUGGESTIONS
|
||||
}
|
||||
}
|
||||
|
||||
switchPreference {
|
||||
key = Keys.alwaysUseExternalPlayer
|
||||
titleRes = R.string.pref_always_use_external_player
|
||||
defaultValue = false
|
||||
}
|
||||
|
||||
listPreference {
|
||||
key = Keys.externalPlayerPreference
|
||||
titleRes = R.string.pref_external_player_preference
|
||||
|
||||
val pm = context.packageManager
|
||||
val installedPackages = pm.getInstalledPackages(0)
|
||||
val supportedPlayers = installedPackages.filter {
|
||||
when (it.packageName) {
|
||||
"is.xyz.mpv" -> true
|
||||
"com.mxtech.videoplayer" -> true
|
||||
"com.mxtech.videoplayer.ad" -> true
|
||||
"com.mxtech.videoplayer.pro" -> true
|
||||
"org.videolan.vlc" -> true
|
||||
"com.husudosu.mpvremote" -> true
|
||||
else -> false
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) {
|
||||
switchPreference {
|
||||
key = "player_fullscreen"
|
||||
titleRes = R.string.pref_player_fullscreen
|
||||
defaultValue = true
|
||||
}
|
||||
}
|
||||
val packageNames = supportedPlayers.map { it.packageName }
|
||||
val packageNamesReadable = supportedPlayers
|
||||
.map { pm.getApplicationLabel(it.applicationInfo).toString() }
|
||||
|
||||
entries = arrayOf("None") + packageNamesReadable.toTypedArray()
|
||||
entryValues = arrayOf("") + packageNames.toTypedArray()
|
||||
defaultValue = ""
|
||||
if (context.packageManager.hasSystemFeature(PackageManager.FEATURE_PICTURE_IN_PICTURE) && Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
||||
switchPreference {
|
||||
key = Keys.pipEpisodeToasts
|
||||
titleRes = R.string.pref_pip_episode_toasts
|
||||
defaultValue = true
|
||||
}
|
||||
}
|
||||
|
||||
summary = "%s"
|
||||
editTextPreference {
|
||||
key = Keys.mpvConf
|
||||
titleRes = R.string.pref_mpv_conf
|
||||
setOnBindEditTextListener {
|
||||
it.inputType =
|
||||
TYPE_CLASS_TEXT or TYPE_TEXT_FLAG_MULTI_LINE or TYPE_TEXT_FLAG_NO_SUGGESTIONS
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
preferenceCategory {
|
||||
titleRes = R.string.pref_category_external_player
|
||||
|
||||
switchPreference {
|
||||
key = Keys.alwaysUseExternalPlayer
|
||||
titleRes = R.string.pref_always_use_external_player
|
||||
defaultValue = false
|
||||
}
|
||||
|
||||
listPreference {
|
||||
key = Keys.externalPlayerPreference
|
||||
titleRes = R.string.pref_external_player_preference
|
||||
|
||||
val pm = context.packageManager
|
||||
val installedPackages = pm.getInstalledPackages(0)
|
||||
val supportedPlayers = installedPackages.filter {
|
||||
when (it.packageName) {
|
||||
"is.xyz.mpv" -> true
|
||||
"com.mxtech.videoplayer" -> true
|
||||
"com.mxtech.videoplayer.ad" -> true
|
||||
"com.mxtech.videoplayer.pro" -> true
|
||||
"org.videolan.vlc" -> true
|
||||
"com.husudosu.mpvremote" -> true
|
||||
else -> false
|
||||
}
|
||||
}
|
||||
val packageNames = supportedPlayers.map { it.packageName }
|
||||
val packageNamesReadable = supportedPlayers
|
||||
.map { pm.getApplicationLabel(it.applicationInfo).toString() }
|
||||
|
||||
entries = arrayOf("None") + packageNamesReadable.toTypedArray()
|
||||
entryValues = arrayOf("") + packageNames.toTypedArray()
|
||||
defaultValue = ""
|
||||
|
||||
summary = "%s"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -424,6 +424,9 @@
|
|||
<string name="rotation_portrait">Portrait</string>
|
||||
<string name="rotation_reverse_portrait">Reverse portrait</string>
|
||||
<string name="rotation_landscape">Landscape</string>
|
||||
<string name="rotation_reverse_landscape">Reverse Landscape</string>
|
||||
<string name="rotation_sensor_portrait">Sensor Portrait</string>
|
||||
<string name="rotation_sensor_landscape">Sensor Landscape</string>
|
||||
<string name="rotation_force_portrait">Locked portrait</string>
|
||||
<string name="rotation_force_landscape">Locked landscape</string>
|
||||
<string name="color_filter_r_value">R</string>
|
||||
|
@ -450,16 +453,25 @@
|
|||
<string name="pref_category_player">Player</string>
|
||||
<string name="pref_category_progress">Progress</string>
|
||||
<string name="pref_progress_mark_as_seen">At what point to mark the episode as seen</string>
|
||||
<string name="pref_category_player_orientation">Orientation</string>
|
||||
<string name="pref_default_player_orientation">Default orientation</string>
|
||||
<string name="pref_adjust_orientation_video_dimensions">Adjust the orientation based on a video\'s dimensions</string>
|
||||
<string name="pref_default_portrait_orientation">Default portrait</string>
|
||||
<string name="pref_default_landscape_orientation">Default landscape</string>
|
||||
<string name="pref_category_internal_player">Internal player</string>
|
||||
<string name="pref_skip_length">Double tap to skip length</string>
|
||||
<string name="pref_skip_30">30s</string>
|
||||
<string name="pref_skip_20">20s</string>
|
||||
<string name="pref_skip_10">10s</string>
|
||||
<string name="pref_skip_5">5s</string>
|
||||
<string name="pref_skip_disable">Disable</string>
|
||||
<string name="pref_always_use_external_player">Always use external player</string>
|
||||
<string name="pref_player_fast_seek">Enable faster horizontal seeking</string>
|
||||
<string name="pref_player_fast_seek_summary">Horizontal scroll will focus on keyframes, leading to faster but less precise seeking</string>
|
||||
<string name="pref_player_fullscreen">Show content in display cutout</string>
|
||||
<string name="pref_pip_episode_toasts">Show episode toasts when switching episodes in PiP mode</string>
|
||||
<string name="pref_mpv_conf">Edit MPV configuration file for further player settings</string>
|
||||
<string name="pref_category_external_player">External player</string>
|
||||
<string name="pref_always_use_external_player">Always use external player</string>
|
||||
<string name="pref_external_player_preference">External player preference</string>
|
||||
<string name="pref_progress_70">70%</string>
|
||||
<string name="pref_progress_75">75%</string>
|
||||
|
|
Loading…
Reference in a new issue