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) { withContext(Dispatchers.Main) {
onReceiveResult("Failed to download update."); onReceiveResult("Failed to download update.");
} }
} } finally {
finally {
withContext(Dispatchers.Main) { withContext(Dispatchers.Main) {
window?.clearFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON); window?.clearFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
} }

View File

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

View File

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

View File

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

View File

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