KEEP_SCREEN_ON in slideshow

This commit is contained in:
Hardcore Sushi 2020-09-29 11:14:30 +02:00
parent 85f5aac441
commit 0ca5bbcbb4

View File

@ -7,6 +7,7 @@ import android.graphics.drawable.Drawable
import android.os.Handler import android.os.Handler
import android.view.MotionEvent import android.view.MotionEvent
import android.view.View import android.view.View
import android.view.WindowManager
import android.widget.Toast import android.widget.Toast
import com.bumptech.glide.Glide import com.bumptech.glide.Glide
import com.bumptech.glide.RequestBuilder import com.bumptech.glide.RequestBuilder
@ -155,6 +156,7 @@ class ImageViewer: FileViewerActivity() {
Thread.sleep(ConstValues.slideshow_delay) Thread.sleep(ConstValues.slideshow_delay)
} }
}.start() }.start()
window.addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON)
hideUI.run() hideUI.run()
Toast.makeText(this, R.string.slideshow_started, Toast.LENGTH_SHORT).show() Toast.makeText(this, R.string.slideshow_started, Toast.LENGTH_SHORT).show()
} else { } else {
@ -164,6 +166,7 @@ class ImageViewer: FileViewerActivity() {
private fun stopSlideshow(){ private fun stopSlideshow(){
slideshowActive = false slideshowActive = false
window.clearFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON)
Toast.makeText(this, R.string.slideshow_stopped, Toast.LENGTH_SHORT).show() Toast.makeText(this, R.string.slideshow_stopped, Toast.LENGTH_SHORT).show()
} }