mirror of
https://github.com/aniyomiorg/aniyomi.git
synced 2024-11-29 01:29:02 +03:00
Option to either invert elapsed time or total time with remaining time (#647)
This commit is contained in:
parent
f21ecad844
commit
93da9278a2
4 changed files with 34 additions and 4 deletions
|
@ -135,6 +135,8 @@ class PreferencesHelper(val context: Context) {
|
|||
|
||||
fun invertedPlaybackTxt() = flowPrefs.getBoolean("pref_invert_playback_txt", false)
|
||||
|
||||
fun invertedDurationTxt() = flowPrefs.getBoolean("pref_invert_duration_txt", false)
|
||||
|
||||
fun mpvConf() = prefs.getString(Keys.mpvConf, "")
|
||||
|
||||
fun defaultOrientationType() = prefs.getInt(Keys.defaultOrientationType, OrientationType.FREE.flagValue)
|
||||
|
|
|
@ -1438,7 +1438,10 @@ class PlayerActivity :
|
|||
private fun eventPropertyUi(property: String, value: Long) {
|
||||
when (property) {
|
||||
"demuxer-cache-time" -> playerControls.updateBufferPosition(value.toInt())
|
||||
"time-pos" -> playerControls.updatePlaybackPos(value.toInt())
|
||||
"time-pos" -> {
|
||||
playerControls.updatePlaybackPos(value.toInt())
|
||||
if (preferences.invertedDurationTxt().get()) playerControls.updatePlaybackDuration(value.toInt())
|
||||
}
|
||||
"duration" -> playerControls.updatePlaybackDuration(value.toInt())
|
||||
}
|
||||
}
|
||||
|
|
|
@ -154,8 +154,21 @@ class PlayerControlsView @JvmOverloads constructor(context: Context, attrs: Attr
|
|||
|
||||
binding.pipBtn.isVisible = !preferences.pipOnExit() && activity.deviceSupportsPip
|
||||
binding.playbackPositionBtn.setOnClickListener {
|
||||
preferences.invertedDurationTxt().set(false)
|
||||
preferences.invertedPlaybackTxt().set(!preferences.invertedPlaybackTxt().get())
|
||||
if (activity.player.timePos != null) updatePlaybackPos(activity.player.timePos!!)
|
||||
if (activity.player.timePos != null) {
|
||||
updatePlaybackPos(activity.player.timePos!!)
|
||||
updatePlaybackDuration(activity.player.duration!!)
|
||||
}
|
||||
}
|
||||
|
||||
binding.playbackDurationBtn.setOnClickListener {
|
||||
preferences.invertedPlaybackTxt().set(false)
|
||||
preferences.invertedDurationTxt().set(!preferences.invertedDurationTxt().get())
|
||||
if (preferences.invertedDurationTxt().get() && activity.player.timePos != null) {
|
||||
updatePlaybackPos(activity.player.timePos!!)
|
||||
updatePlaybackDuration(activity.player.timePos!!)
|
||||
} else updatePlaybackDuration(activity.player.duration!!)
|
||||
}
|
||||
|
||||
binding.toggleAutoplay.setOnCheckedChangeListener { _, isChecked ->
|
||||
|
@ -222,10 +235,14 @@ class PlayerControlsView @JvmOverloads constructor(context: Context, attrs: Attr
|
|||
updateSpeedButton()
|
||||
}
|
||||
|
||||
@SuppressLint("SetTextI18n")
|
||||
internal fun updatePlaybackDuration(duration: Int) {
|
||||
binding.playbackDurationTxt.text = Utils.prettyTime(duration)
|
||||
if (preferences.invertedDurationTxt().get() && activity.player.duration != null) {
|
||||
binding.playbackDurationTxt.text = "-${ Utils.prettyTime(activity.player.duration!! - duration) }"
|
||||
} else binding.playbackDurationTxt.text = Utils.prettyTime(duration)
|
||||
|
||||
if (!userIsOperatingSeekbar) {
|
||||
binding.playbackSeekbar.max = duration
|
||||
binding.playbackSeekbar.max = activity.player.duration!!
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -392,6 +392,14 @@
|
|||
android:textColor="@android:color/white"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintRight_toRightOf="parent" />
|
||||
|
||||
<Button
|
||||
android:id="@+id/playbackDurationBtn"
|
||||
android:layout_width="96dp"
|
||||
android:layout_height="48dp"
|
||||
android:background="?attr/selectableItemBackground"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintRight_toRightOf="parent" />
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
</RelativeLayout>
|
||||
|
|
Loading…
Reference in a new issue