Skip to content

Commit

Permalink
fix: Inconsistency of keepScreenOn to restriction display timeout (#65
Browse files Browse the repository at this point in the history
)

- Replace `keepScreenOn` property with activity level flag `FLAG_KEEP_SCREEN_ON`

fixes: LEARNER-10283
  • Loading branch information
farhan-arshad-dev authored Nov 4, 2024
1 parent c673d74 commit 2e3be03
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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()
Expand All @@ -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)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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()
}

Expand Down

0 comments on commit 2e3be03

Please sign in to comment.