Made the skip button dissappear after 5 seconds with a setting to turn it off (#224)
* Made the skip button dissappear after 5 seconds with a setting to turn it off * Resolved Merge Conflicts and Removed Unnecessary Imports * Resolved Merge Conflicts * Resolved Merge Conflicts * Resolved Merge Conflicts * Resolved problems * Fixed a little mistake * Made Requested Changes * Removed println I forgot
This commit is contained in:
parent
8fb6357fb5
commit
e915dd619d
4 changed files with 103 additions and 5 deletions
|
@ -20,6 +20,7 @@ import android.media.AudioManager.*
|
|||
import android.net.Uri
|
||||
import android.os.Build
|
||||
import android.os.Bundle
|
||||
import android.os.CountDownTimer
|
||||
import android.os.Handler
|
||||
import android.os.Looper
|
||||
import android.provider.Settings.System
|
||||
|
@ -115,6 +116,8 @@ class ExoplayerView : AppCompatActivity(), Player.Listener, SessionAvailabilityL
|
|||
private val resumePosition = "resumePosition"
|
||||
private val playerFullscreen = "playerFullscreen"
|
||||
private val playerOnPlay = "playerOnPlay"
|
||||
private var disappeared: Boolean = false
|
||||
private var functionstarted: Boolean = false
|
||||
|
||||
private lateinit var exoPlayer: ExoPlayer
|
||||
private var castPlayer: CastPlayer? = null
|
||||
|
@ -966,7 +969,11 @@ class ExoplayerView : AppCompatActivity(), Player.Listener, SessionAvailabilityL
|
|||
episodeTitle.setSelection(currentEpisodeIndex)
|
||||
episodeTitle.onItemSelectedListener = object : AdapterView.OnItemSelectedListener {
|
||||
override fun onItemSelected(p0: AdapterView<*>?, p1: View?, position: Int, p3: Long) {
|
||||
if (position != currentEpisodeIndex) change(position)
|
||||
if (position != currentEpisodeIndex) {
|
||||
disappeared = false
|
||||
functionstarted = false
|
||||
change(position)
|
||||
}
|
||||
}
|
||||
|
||||
override fun onNothingSelected(parent: AdapterView<*>) {}
|
||||
|
@ -978,6 +985,8 @@ class ExoplayerView : AppCompatActivity(), Player.Listener, SessionAvailabilityL
|
|||
if (isInitialized) {
|
||||
nextEpisode { i ->
|
||||
updateAniProgress()
|
||||
disappeared = false
|
||||
functionstarted = false
|
||||
change(currentEpisodeIndex + i)
|
||||
}
|
||||
}
|
||||
|
@ -986,6 +995,7 @@ class ExoplayerView : AppCompatActivity(), Player.Listener, SessionAvailabilityL
|
|||
exoPrev = playerView.findViewById(R.id.exo_prev_ep)
|
||||
exoPrev.setOnClickListener {
|
||||
if (currentEpisodeIndex > 0) {
|
||||
disappeared = false
|
||||
change(currentEpisodeIndex - 1)
|
||||
} else
|
||||
snackString(getString(R.string.first_episode))
|
||||
|
@ -1528,6 +1538,8 @@ class ExoplayerView : AppCompatActivity(), Player.Listener, SessionAvailabilityL
|
|||
private fun releasePlayer() {
|
||||
isPlayerPlaying = exoPlayer.playWhenReady
|
||||
playbackPosition = exoPlayer.currentPosition
|
||||
disappeared = false
|
||||
functionstarted = false
|
||||
exoPlayer.release()
|
||||
VideoCache.release()
|
||||
mediaSession?.release()
|
||||
|
@ -1701,26 +1713,71 @@ class ExoplayerView : AppCompatActivity(), Player.Listener, SessionAvailabilityL
|
|||
|
||||
val new = currentTimeStamp
|
||||
timeStampText.text = if (new != null) {
|
||||
if (PrefManager.getVal(PrefName.ShowTimeStampButton)) {
|
||||
fun DissapearSkip(){
|
||||
functionstarted = true
|
||||
skipTimeButton.visibility = View.VISIBLE
|
||||
exoSkip.visibility = View.GONE
|
||||
skipTimeText.text = new.skipType.getType()
|
||||
skipTimeButton.setOnClickListener {
|
||||
exoPlayer.seekTo((new.interval.endTime * 1000).toLong())
|
||||
}
|
||||
var timer: CountDownTimer? = null
|
||||
fun cancelTimer() {
|
||||
timer?.cancel()
|
||||
timer = null
|
||||
return
|
||||
}
|
||||
if (timer == null) {
|
||||
timer = object : CountDownTimer(5000, 1000) {
|
||||
override fun onTick(millisUntilFinished: Long) {
|
||||
if (new == null){
|
||||
skipTimeButton.visibility = View.GONE
|
||||
exoSkip.visibility = View.VISIBLE
|
||||
disappeared = false
|
||||
functionstarted = false
|
||||
cancelTimer()
|
||||
}
|
||||
}
|
||||
|
||||
override fun onFinish() {
|
||||
skipTimeButton.visibility = View.GONE
|
||||
exoSkip.visibility = View.VISIBLE
|
||||
disappeared = true
|
||||
functionstarted = false
|
||||
cancelTimer()
|
||||
}
|
||||
}
|
||||
timer?.start()
|
||||
}
|
||||
|
||||
}
|
||||
if (PrefManager.getVal(PrefName.ShowTimeStampButton)) {
|
||||
|
||||
if (!functionstarted && !disappeared && PrefManager.getVal<Boolean>(PrefName.AutoHideTimeStamps)) {
|
||||
DissapearSkip()
|
||||
} else if (!PrefManager.getVal<Boolean>(PrefName.AutoHideTimeStamps)){
|
||||
skipTimeButton.visibility = View.VISIBLE
|
||||
exoSkip.visibility = View.GONE
|
||||
skipTimeText.text = new.skipType.getType()
|
||||
skipTimeButton.setOnClickListener {
|
||||
exoPlayer.seekTo((new.interval.endTime * 1000).toLong())
|
||||
}
|
||||
}
|
||||
}
|
||||
if (PrefManager.getVal(PrefName.AutoSkipOPED) && (new.skipType == "op" || new.skipType == "ed") && !skippedTimeStamps.contains(
|
||||
new
|
||||
)
|
||||
new
|
||||
)
|
||||
) {
|
||||
exoPlayer.seekTo((new.interval.endTime * 1000).toLong())
|
||||
skippedTimeStamps.add(new)
|
||||
}
|
||||
new.skipType.getType()
|
||||
} else {
|
||||
disappeared = false
|
||||
functionstarted = false
|
||||
skipTimeButton.visibility = View.GONE
|
||||
if (PrefManager.getVal<Int>(PrefName.SkipTime) > 0) exoSkip.visibility =
|
||||
View.VISIBLE
|
||||
View.VISIBLE
|
||||
""
|
||||
}
|
||||
}
|
||||
|
@ -1841,6 +1898,8 @@ class ExoplayerView : AppCompatActivity(), Player.Listener, SessionAvailabilityL
|
|||
|
||||
if (isInitialized) {
|
||||
updateAniProgress()
|
||||
disappeared = false
|
||||
functionstarted = false
|
||||
releasePlayer()
|
||||
}
|
||||
|
||||
|
|
|
@ -129,6 +129,11 @@ class PlayerSettingsActivity : AppCompatActivity() {
|
|||
PrefManager.setVal(PrefName.TimeStampsEnabled, isChecked)
|
||||
}
|
||||
|
||||
binding.playerSettingsTimeStampsAutoHide.isChecked = PrefManager.getVal(PrefName.AutoHideTimeStamps)
|
||||
binding.playerSettingsTimeStampsAutoHide.setOnCheckedChangeListener { _, isChecked ->
|
||||
PrefManager.setVal(PrefName.AutoHideTimeStamps, isChecked)
|
||||
}
|
||||
|
||||
binding.playerSettingsTimeStampsProxy.isChecked =
|
||||
PrefManager.getVal(PrefName.UseProxyForTimeStamps)
|
||||
binding.playerSettingsTimeStampsProxy.setOnCheckedChangeListener { _, isChecked ->
|
||||
|
|
|
@ -85,6 +85,7 @@ enum class PrefName(val data: Pref) { //TODO: Split this into multiple files
|
|||
FontSize(Pref(Location.Player, Int::class, 20)),
|
||||
Locale(Pref(Location.Player, Int::class, 2)),
|
||||
TimeStampsEnabled(Pref(Location.Player, Boolean::class, true)),
|
||||
AutoHideTimeStamps(Pref(Location.Player, Boolean::class, true)),
|
||||
UseProxyForTimeStamps(Pref(Location.Player, Boolean::class, false)),
|
||||
ShowTimeStampButton(Pref(Location.Player, Boolean::class, true)),
|
||||
AutoSkipOPED(Pref(Location.Player, Boolean::class, false)),
|
||||
|
|
|
@ -439,6 +439,39 @@
|
|||
app:showText="false"
|
||||
app:thumbTint="@color/button_switch_track" />
|
||||
|
||||
<com.google.android.material.materialswitch.MaterialSwitch
|
||||
android:id="@+id/playerSettingsTimeStampsAutoHide"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginBottom="8dp"
|
||||
android:checked="true"
|
||||
android:drawableStart="@drawable/ic_round_art_track_24"
|
||||
android:drawablePadding="16dp"
|
||||
android:elegantTextHeight="true"
|
||||
android:fontFamily="@font/poppins_bold"
|
||||
android:minHeight="64dp"
|
||||
android:paddingStart="32dp"
|
||||
android:paddingEnd="32dp"
|
||||
android:text="Auto Hide Time Stamps"
|
||||
android:textAlignment="viewStart"
|
||||
android:textColor="@color/bg_opp"
|
||||
app:cornerRadius="0dp"
|
||||
app:drawableTint="?attr/colorPrimary"
|
||||
app:showText="false"
|
||||
app:thumbTint="@color/button_switch_track" />
|
||||
|
||||
<TextView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="-8dp"
|
||||
android:layout_marginBottom="8dp"
|
||||
android:alpha="0.58"
|
||||
android:fontFamily="@font/poppins_family"
|
||||
android:paddingStart="32dp"
|
||||
android:paddingEnd="32dp"
|
||||
android:text="Make the skip time stamp button disappear after 5 seconds"
|
||||
android:textSize="14sp" />
|
||||
|
||||
<com.google.android.material.materialswitch.MaterialSwitch
|
||||
android:id="@+id/playerSettingsTimeStampsProxy"
|
||||
android:layout_width="match_parent"
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue