@@ -3,6 +3,7 @@ package net.kuama.documentscanner.presentation
33import android.os.Bundle
44import android.util.Log
55import android.view.View
6+ import android.view.Window
67import android.view.WindowManager
78import android.widget.SeekBar
89import androidx.activity.viewModels
@@ -20,8 +21,15 @@ abstract class BaseScannerActivity : AppCompatActivity() {
2021
2122 override fun onCreate (savedInstanceState : Bundle ? ) {
2223 super .onCreate(savedInstanceState)
23- window.addFlags(WindowManager .LayoutParams .FLAG_KEEP_SCREEN_ON )
24-
24+ window.decorView.systemUiVisibility = (View .SYSTEM_UI_FLAG_IMMERSIVE
25+ // Set the content to appear under the system bars so that the
26+ // content doesn't resize when the system bars hide and show.
27+ or View .SYSTEM_UI_FLAG_LAYOUT_STABLE
28+ or View .SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
29+ or View .SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
30+ // Hide the nav bar and status bar
31+ or View .SYSTEM_UI_FLAG_HIDE_NAVIGATION
32+ or View .SYSTEM_UI_FLAG_FULLSCREEN )
2533 setContentView(R .layout.activity_scanner)
2634 val viewModel: ScannerViewModel by viewModels()
2735 viewModel.isBusy.observe(this , Observer { isBusy ->
@@ -84,11 +92,11 @@ abstract class BaseScannerActivity : AppCompatActivity() {
8492 }
8593
8694 closePreview.setOnClickListener {
87- previewWrap.visibility = View .GONE
88- viewModel.onClosePreview()
95+ closePreview()
8996 }
9097
9198 confirmDocument.setOnClickListener {
99+ previewWrap.visibility = View .GONE
92100 onDocumentAccepted(viewModel.documentPath!! )
93101 }
94102
@@ -113,6 +121,11 @@ abstract class BaseScannerActivity : AppCompatActivity() {
113121 viewModel.onViewCreated(Loader (this ), this , viewFinder)
114122 }
115123
124+ public fun closePreview () {
125+ previewWrap.visibility = View .GONE
126+ viewModel.onClosePreview()
127+ }
128+
116129 abstract fun onError (throwable : Throwable )
117130 abstract fun onDocumentAccepted (path : String )
118131 abstract fun onClose ()
0 commit comments