Fix file viewers navigation bar color in dark mode

This commit is contained in:
Matéo Duparc 2022-10-04 12:23:25 +02:00
parent 7c2f87109a
commit 991e435e5e
Signed by untrusted user: hardcoresushi
GPG Key ID: AFE384344A45E13A
3 changed files with 14 additions and 12 deletions

View File

@ -3,6 +3,7 @@ package sushi.hardcore.droidfs.file_viewers
import android.os.Bundle import android.os.Bundle
import android.view.View import android.view.View
import androidx.activity.addCallback import androidx.activity.addCallback
import androidx.core.content.ContextCompat
import androidx.core.view.WindowInsetsCompat import androidx.core.view.WindowInsetsCompat
import androidx.core.view.WindowInsetsControllerCompat import androidx.core.view.WindowInsetsControllerCompat
import sushi.hardcore.droidfs.BaseActivity import sushi.hardcore.droidfs.BaseActivity
@ -27,6 +28,7 @@ abstract class FileViewerActivity: BaseActivity() {
private var wasMapped = false private var wasMapped = false
protected val mappedPlaylist = mutableListOf<ExplorerElement>() protected val mappedPlaylist = mutableListOf<ExplorerElement>()
protected var currentPlaylistIndex = -1 protected var currentPlaylistIndex = -1
protected open var fullscreenMode = true
private val legacyMod by lazy { private val legacyMod by lazy {
sharedPrefs.getBoolean("legacyMod", false) sharedPrefs.getBoolean("legacyMod", false)
} }
@ -47,11 +49,18 @@ abstract class FileViewerActivity: BaseActivity() {
isEnabled = false isEnabled = false
onBackPressedDispatcher.onBackPressed() onBackPressedDispatcher.onBackPressed()
} }
hideSystemUi() if (fullscreenMode) {
fixNavBarColor()
hideSystemUi()
}
viewFile() viewFile()
} }
open fun hideSystemUi() { private fun fixNavBarColor() {
window.navigationBarColor = ContextCompat.getColor(this, R.color.fullScreenBackgroundColor)
}
private fun hideSystemUi() {
if (legacyMod) { if (legacyMod) {
@Suppress("Deprecation") @Suppress("Deprecation")
window.decorView.systemUiVisibility = window.decorView.systemUiVisibility =
@ -67,7 +76,7 @@ abstract class FileViewerActivity: BaseActivity() {
override fun onUserInteraction() { override fun onUserInteraction() {
super.onUserInteraction() super.onUserInteraction()
if (windowTypeMask and WindowInsetsCompat.Type.statusBars() == 0) { if (fullscreenMode && windowTypeMask and WindowInsetsCompat.Type.statusBars() == 0) {
hideSystemUi() hideSystemUi()
} }
} }

View File

@ -10,12 +10,9 @@ class PdfViewer: FileViewerActivity() {
init { init {
applyCustomTheme = false applyCustomTheme = false
} }
override var fullscreenMode = false
private lateinit var pdfViewer: PdfViewer private lateinit var pdfViewer: PdfViewer
override fun hideSystemUi() {
//don't hide system ui
}
override fun getFileType(): String { override fun getFileType(): String {
return "pdf" return "pdf"
} }

View File

@ -7,20 +7,16 @@ import android.view.Menu
import android.view.MenuItem import android.view.MenuItem
import android.widget.EditText import android.widget.EditText
import android.widget.Toast import android.widget.Toast
import sushi.hardcore.droidfs.ConstValues
import sushi.hardcore.droidfs.R import sushi.hardcore.droidfs.R
import sushi.hardcore.droidfs.widgets.CustomAlertDialogBuilder import sushi.hardcore.droidfs.widgets.CustomAlertDialogBuilder
import java.io.ByteArrayInputStream
import java.io.File import java.io.File
class TextEditor: FileViewerActivity() { class TextEditor: FileViewerActivity() {
override var fullscreenMode = false
private lateinit var fileName: String private lateinit var fileName: String
private lateinit var editor: EditText private lateinit var editor: EditText
private var changedSinceLastSave = false private var changedSinceLastSave = false
private var wordWrap = true private var wordWrap = true
override fun hideSystemUi() {
//don't hide system ui
}
override fun getFileType(): String { override fun getFileType(): String {
return "text" return "text"