Properly implemented all add and clear flags for staying awake.

This commit is contained in:
Koen 2023-09-27 11:58:01 +02:00
parent bc83f9b274
commit 4517e3dde8
5 changed files with 7 additions and 3 deletions

View file

@ -176,8 +176,7 @@ class AutoUpdateDialog(context: Context?) : AlertDialog(context) {
withContext(Dispatchers.Main) {
onReceiveResult("Failed to download update.");
}
}
finally {
} finally {
withContext(Dispatchers.Main) {
window?.clearFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
}

View file

@ -200,6 +200,8 @@ class ImportDialog : AlertDialog {
_uiResultBot.visibility = View.VISIBLE;
} catch (e: Throwable) {
Logger.e(TAG, "Failed to update import UI.", e)
} finally {
window?.clearFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
}
}
} catch (e: Throwable) {

View file

@ -213,6 +213,8 @@ class MigrateDialog : AlertDialog {
_uiResultBot.visibility = View.VISIBLE;
} catch (e: Throwable) {
Logger.e(TAG, "Failed to update import UI.", e)
} finally {
window?.clearFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
}
}
} catch (e: Throwable) {

View file

@ -142,7 +142,6 @@ class VideoDetailFragment : MainFragment {
}
override fun onHide() {
super.onHide();
activity?.window?.clearFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
}
fun preventPictureInPicture() {
@ -175,6 +174,7 @@ class VideoDetailFragment : MainFragment {
_viewDetail?.onStop();
close();
activity?.window?.clearFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
StatePlayer.instance.clearQueue();
StatePlayer.instance.setPlayerClosed();
}

View file

@ -23,6 +23,7 @@ import android.view.MotionEvent
import android.view.View
import android.view.ViewGroup.LayoutParams.MATCH_PARENT
import android.view.ViewGroup.LayoutParams.WRAP_CONTENT
import android.view.WindowManager
import android.widget.*
import androidx.constraintlayout.widget.ConstraintLayout
import androidx.lifecycle.lifecycleScope