From c068f1bfb60c1ebf4b728f34961532837192be38 Mon Sep 17 00:00:00 2001 From: Farhan Arshad Date: Mon, 4 Nov 2024 13:15:54 +0500 Subject: [PATCH] fix: Inconsistency of `keepScreenOn` to restriction display timeout - Replace `keepScreenOn` property with activity level flag `FLAG_KEEP_SCREEN_ON` fixes: LEARNER-10283 --- .../presentation/unit/video/VideoFullScreenFragment.kt | 5 +++-- .../course/presentation/unit/video/VideoUnitFragment.kt | 5 +++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/course/src/main/java/org/openedx/course/presentation/unit/video/VideoFullScreenFragment.kt b/course/src/main/java/org/openedx/course/presentation/unit/video/VideoFullScreenFragment.kt index d459eee4e..6ef3fdfd3 100644 --- a/course/src/main/java/org/openedx/course/presentation/unit/video/VideoFullScreenFragment.kt +++ b/course/src/main/java/org/openedx/course/presentation/unit/video/VideoFullScreenFragment.kt @@ -3,6 +3,7 @@ package org.openedx.course.presentation.unit.video import android.annotation.SuppressLint import android.os.Bundle import android.view.View +import android.view.WindowManager import android.widget.FrameLayout import androidx.core.os.bundleOf import androidx.core.view.WindowInsetsCompat @@ -184,7 +185,7 @@ class VideoFullScreenFragment : Fragment(R.layout.fragment_video_full_screen) { } override fun onPause() { - binding.playerView.keepScreenOn = false + requireActivity().window.clearFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON) exoPlayer?.removeListener(exoPlayerListener) exoPlayer?.pause() super.onPause() @@ -205,7 +206,7 @@ class VideoFullScreenFragment : Fragment(R.layout.fragment_video_full_screen) { override fun onResume() { super.onResume() - binding.playerView.keepScreenOn = true + requireActivity().window.addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON) exoPlayer?.addListener(exoPlayerListener) } diff --git a/course/src/main/java/org/openedx/course/presentation/unit/video/VideoUnitFragment.kt b/course/src/main/java/org/openedx/course/presentation/unit/video/VideoUnitFragment.kt index 559b0c44a..00a48949a 100644 --- a/course/src/main/java/org/openedx/course/presentation/unit/video/VideoUnitFragment.kt +++ b/course/src/main/java/org/openedx/course/presentation/unit/video/VideoUnitFragment.kt @@ -5,6 +5,7 @@ import android.os.Bundle import android.os.Handler import android.os.Looper import android.view.View +import android.view.WindowManager import android.widget.FrameLayout import androidx.compose.foundation.lazy.rememberLazyListState import androidx.compose.runtime.collectAsState @@ -241,11 +242,11 @@ class VideoUnitFragment : Fragment(R.layout.fragment_video_unit) { override fun onResume() { super.onResume() - binding.playerView.keepScreenOn = true + requireActivity().window.addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON) } override fun onPause() { - binding.playerView.keepScreenOn = false + requireActivity().window.clearFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON) super.onPause() }