Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import android.content.Intent
import android.os.Bundle
import android.util.Log
import android.view.KeyEvent
import androidx.appcompat.app.AlertDialog
import androidx.appcompat.app.AppCompatActivity
import com.lagradost.cloudstream3.CommonActivity
import com.lagradost.cloudstream3.R
Expand Down Expand Up @@ -60,7 +61,28 @@ class DownloadedPlayerActivity : AppCompatActivity() {
Log.i(TAG, "onCreate")

handleIntent(intent)
attachBackPressedCallback("DownloadedPlayerActivity") { finish() }
attachBackPressedCallback("DownloadedPlayerActivity") {
if (exitDialog?.isShowing == true) {
exitDialog?.dismiss()
return@attachBackPressedCallback
}
showExitConfirmDialog()
}
}

private var exitDialog: AlertDialog? = null

private fun showExitConfirmDialog() {
if (isFinishing || isDestroyed) return
exitDialog = AlertDialog.Builder(this, R.style.AlertDialogCustom)
.setTitle(R.string.exit_player_confirm_title)
.setMessage(R.string.exit_player_confirm_message)
.setPositiveButton(R.string.yes) { _, _ ->
finish()
}
.setNegativeButton(R.string.no, null)
.setOnDismissListener { exitDialog = null }
.show()
}

private fun handleIntent(intent: Intent) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -442,6 +442,26 @@ open class FullScreenPlayer : AbstractPlayerFragment<FragmentPlayerBinding>(
}
}

private var exitConfirmDialog: AlertDialog? = null

private fun showExitConfirmDialog() {
val act = activity ?: return
if (exitConfirmDialog?.isShowing == true) return
if (act.isFinishing || act.isDestroyed) return
exitConfirmDialog = AlertDialog.Builder(act, R.style.AlertDialogCustom)
.setTitle(R.string.exit_player_confirm_title)
.setMessage(R.string.exit_player_confirm_message)
.setPositiveButton(R.string.yes) { _, _ ->
activity?.popCurrentPage("FullScreenPlayer")
}
.setNegativeButton(R.string.no, null)
.setOnDismissListener {
exitConfirmDialog = null
activity?.hideSystemUI()
}
.show()
}

private fun setupKeyEventListener() {
keyEventListener = { (event, hasNavigated) ->
when {
Expand Down Expand Up @@ -473,7 +493,7 @@ open class FullScreenPlayer : AbstractPlayerFragment<FragmentPlayerBinding>(
// netflix capture back and hide ~monke
onClickChange()
} else {
activity?.popCurrentPage("FullScreenPlayer")
showExitConfirmDialog()
}
}
playerHostView?.requestUpdateBrightnessOverlayOnNextLayout()
Expand Down
6 changes: 4 additions & 2 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -439,8 +439,8 @@
<!--
Example text (pangram) can optionally be translated; if you do, include all the letters in the alphabet,
see:
https://en.wikipedia.org/w/index.php?title=Pangram&oldid=225849300
https://en.wikipedia.org/wiki/The_quick_brown_fox_jumps_over_the_lazy_dog
https://en.wikipedia.org/w/index.php?title=Pangram&oldid=225849300
https://en.wikipedia.org/wiki/The_quick_brown_fox_jumps_over_the_lazy_dog
-->
<string name="subtitles_example_text">The quick brown fox jumps over the lazy dog</string>
<string name="recommended">Recommended</string>
Expand Down Expand Up @@ -572,6 +572,8 @@
<string name="action_mark_as_watched">Mark as watched</string>
<string name="action_remove_from_watched">Remove from watched</string>
<string name="confirm_exit_dialog">Are you sure you want to exit\?</string>
<string name="exit_player_confirm_title">Exit Player?</string>
<string name="exit_player_confirm_message">Your buffered stream will be lost. Are you sure you want to exit?</string>
<string name="yes">Yes</string>
<string name="no">No</string>
<string name="ok">OK</string>
Expand Down