Remove some deprecation warnings

This commit is contained in:
Matéo Duparc 2021-09-01 20:15:11 +02:00
parent 52eab2a2df
commit 4ede408aac
Signed by untrusted user: hardcoresushi
GPG Key ID: 007F84120107191E
3 changed files with 12 additions and 11 deletions

View File

@ -1,7 +1,8 @@
package sushi.hardcore.droidfs.file_viewers
import android.os.Bundle
import android.view.View
import androidx.core.view.WindowInsetsCompat
import androidx.core.view.WindowInsetsControllerCompat
import sushi.hardcore.droidfs.BaseActivity
import sushi.hardcore.droidfs.ConstValues
import sushi.hardcore.droidfs.GocryptfsVolume
@ -15,6 +16,8 @@ abstract class FileViewerActivity: BaseActivity() {
protected lateinit var gocryptfsVolume: GocryptfsVolume
protected lateinit var filePath: String
private lateinit var originalParentPath: String
private lateinit var windowInsetsController: WindowInsetsControllerCompat
private var windowTypeMask = 0
private var isFinishingIntentionally = false
private var usf_keep_open = false
private var foldersFirst = true
@ -30,18 +33,16 @@ abstract class FileViewerActivity: BaseActivity() {
gocryptfsVolume = GocryptfsVolume(sessionID)
usf_keep_open = sharedPrefs.getBoolean("usf_keep_open", false)
foldersFirst = sharedPrefs.getBoolean("folders_first", true)
windowInsetsController = WindowInsetsControllerCompat(window, window.decorView)
windowInsetsController.addOnControllableInsetsChangedListener { _, typeMask ->
windowTypeMask = typeMask
}
hideSystemUi()
viewFile()
}
open fun hideSystemUi(){
window.decorView.systemUiVisibility =
View.SYSTEM_UI_FLAG_FULLSCREEN/* or
View.SYSTEM_UI_FLAG_LOW_PROFILE or
View.SYSTEM_UI_FLAG_LAYOUT_STABLE or
View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY or
View.SYSTEM_UI_FLAG_HIDE_NAVIGATION or
View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION*/
windowInsetsController.hide(WindowInsetsCompat.Type.statusBars())
}
abstract fun getFileType(): String
@ -49,7 +50,7 @@ abstract class FileViewerActivity: BaseActivity() {
override fun onUserInteraction() {
super.onUserInteraction()
if (window.decorView.systemUiVisibility and View.SYSTEM_UI_FLAG_FULLSCREEN == 0){
if (windowTypeMask and WindowInsetsCompat.Type.statusBars() == 0) {
hideSystemUi()
}
}

View File

@ -31,13 +31,13 @@ class ImageViewer: FileViewerActivity() {
}
private lateinit var fileName: String
private lateinit var handler: Handler
private lateinit var glideImage: RequestBuilder<Drawable>
private var x1 = 0F
private var x2 = 0F
private var slideshowActive = false
private var rotationAngle: Float = 0F
private var rotatedBitmap: Bitmap? = null
private val handler = Handler()
private val hideUI = Runnable {
binding.actionButtons.visibility = View.GONE
binding.actionBar.visibility = View.GONE
@ -57,6 +57,7 @@ class ImageViewer: FileViewerActivity() {
override fun viewFile() {
binding = ActivityImageViewerBinding.inflate(layoutInflater)
setContentView(binding.root)
handler = Handler(mainLooper)
binding.imageViewer.setOnInteractionListener(object : ZoomableImageView.OnInteractionListener {
override fun onSingleTap(event: MotionEvent?) {
handler.removeCallbacks(hideUI)

View File

@ -19,7 +19,6 @@ abstract class MediaPlayer: FileViewerActivity() {
private lateinit var player: SimpleExoPlayer
override fun viewFile() {
hideSystemUi()
initializePlayer()
}