recloudstream / cloudstream

Android app for streaming and downloading media.
GNU General Public License v3.0
6.58k stars 526 forks source link

Backbutton break on TV #1280

Open fire-light42 opened 1 month ago

fire-light42 commented 1 month ago

Steps to reproduce

You can test this by pressing back on the mainpage on tv, then you will get a "do you want to exit dialog", however if you go into downloads then back this dialog wont appear. See #1258

Expected behavior

Shows "do you want to exit dialog"

Actual behavior

Quits the app.

Cloudstream version and commit hash

d67fc368fdf259f83b2324bc88aef3f7a960c163

Android version

All

Logcat

No response

Other details

No response

Acknowledgements

zzjjaayy commented 4 days ago

Checked the back handler, found this to be weird in DownloadFragment -

override fun onDestroyView() {
        activity?.detachBackPressedCallback()
        binding = null
        super.onDestroyView()
 }

We attach a back callback when the user comes to home wherein the dialog is triggered. The back callback is being detached in DownloadFragment's onDestroyView which is being called after the attaching of the callback for home {I think this is usual behaviour, onDestroyView is called after the next fragment resumes}.

For extra context, we use the backhandler in DownloadFragment to dismiss the multidelete function before navigating up on the following back action.

@Luna712 can you comment on this? Was there some reason you chose to detach on onDestroyView? I am assuming it to be some race condition but not too sure. Removing this detach call, fixes the issue.