From 991e435e5e259ad862885be845efa528c16b58cb Mon Sep 17 00:00:00 2001 From: Hardcore Sushi Date: Tue, 4 Oct 2022 12:23:25 +0200 Subject: [PATCH] Fix file viewers navigation bar color in dark mode --- .../droidfs/file_viewers/FileViewerActivity.kt | 15 ++++++++++++--- .../hardcore/droidfs/file_viewers/PdfViewer.kt | 5 +---- .../hardcore/droidfs/file_viewers/TextEditor.kt | 6 +----- 3 files changed, 14 insertions(+), 12 deletions(-) diff --git a/app/src/main/java/sushi/hardcore/droidfs/file_viewers/FileViewerActivity.kt b/app/src/main/java/sushi/hardcore/droidfs/file_viewers/FileViewerActivity.kt index 65953e2..d1b0012 100644 --- a/app/src/main/java/sushi/hardcore/droidfs/file_viewers/FileViewerActivity.kt +++ b/app/src/main/java/sushi/hardcore/droidfs/file_viewers/FileViewerActivity.kt @@ -3,6 +3,7 @@ package sushi.hardcore.droidfs.file_viewers import android.os.Bundle import android.view.View import androidx.activity.addCallback +import androidx.core.content.ContextCompat import androidx.core.view.WindowInsetsCompat import androidx.core.view.WindowInsetsControllerCompat import sushi.hardcore.droidfs.BaseActivity @@ -27,6 +28,7 @@ abstract class FileViewerActivity: BaseActivity() { private var wasMapped = false protected val mappedPlaylist = mutableListOf() protected var currentPlaylistIndex = -1 + protected open var fullscreenMode = true private val legacyMod by lazy { sharedPrefs.getBoolean("legacyMod", false) } @@ -47,11 +49,18 @@ abstract class FileViewerActivity: BaseActivity() { isEnabled = false onBackPressedDispatcher.onBackPressed() } - hideSystemUi() + if (fullscreenMode) { + fixNavBarColor() + hideSystemUi() + } viewFile() } - open fun hideSystemUi() { + private fun fixNavBarColor() { + window.navigationBarColor = ContextCompat.getColor(this, R.color.fullScreenBackgroundColor) + } + + private fun hideSystemUi() { if (legacyMod) { @Suppress("Deprecation") window.decorView.systemUiVisibility = @@ -67,7 +76,7 @@ abstract class FileViewerActivity: BaseActivity() { override fun onUserInteraction() { super.onUserInteraction() - if (windowTypeMask and WindowInsetsCompat.Type.statusBars() == 0) { + if (fullscreenMode && windowTypeMask and WindowInsetsCompat.Type.statusBars() == 0) { hideSystemUi() } } diff --git a/app/src/main/java/sushi/hardcore/droidfs/file_viewers/PdfViewer.kt b/app/src/main/java/sushi/hardcore/droidfs/file_viewers/PdfViewer.kt index 98378de..5844757 100644 --- a/app/src/main/java/sushi/hardcore/droidfs/file_viewers/PdfViewer.kt +++ b/app/src/main/java/sushi/hardcore/droidfs/file_viewers/PdfViewer.kt @@ -10,12 +10,9 @@ class PdfViewer: FileViewerActivity() { init { applyCustomTheme = false } + override var fullscreenMode = false private lateinit var pdfViewer: PdfViewer - override fun hideSystemUi() { - //don't hide system ui - } - override fun getFileType(): String { return "pdf" } diff --git a/app/src/main/java/sushi/hardcore/droidfs/file_viewers/TextEditor.kt b/app/src/main/java/sushi/hardcore/droidfs/file_viewers/TextEditor.kt index 483c621..563fe65 100644 --- a/app/src/main/java/sushi/hardcore/droidfs/file_viewers/TextEditor.kt +++ b/app/src/main/java/sushi/hardcore/droidfs/file_viewers/TextEditor.kt @@ -7,20 +7,16 @@ import android.view.Menu import android.view.MenuItem import android.widget.EditText import android.widget.Toast -import sushi.hardcore.droidfs.ConstValues import sushi.hardcore.droidfs.R import sushi.hardcore.droidfs.widgets.CustomAlertDialogBuilder -import java.io.ByteArrayInputStream import java.io.File class TextEditor: FileViewerActivity() { + override var fullscreenMode = false private lateinit var fileName: String private lateinit var editor: EditText private var changedSinceLastSave = false private var wordWrap = true - override fun hideSystemUi() { - //don't hide system ui - } override fun getFileType(): String { return "text"