This commit is contained in:
rebelonion 2024-03-11 04:28:15 -05:00
commit 4838e69aea
4 changed files with 15 additions and 7 deletions

View file

@ -167,6 +167,7 @@ fun initActivity(a: Activity) {
navBarHeight = insets.bottom
}
}
if (a !is MainActivity) a.setNavigationTheme()
}
fun Activity.hideSystemBars() {
@ -178,11 +179,11 @@ fun Activity.hideSystemBars() {
}
fun Activity.setNavigationTheme() {
val a = TypedValue()
theme.resolveAttribute(android.R.attr.colorBackground, a, true)
if ((Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q && a.isColorType)
|| (a.type >= TypedValue.TYPE_FIRST_COLOR_INT && a.type <= TypedValue.TYPE_LAST_COLOR_INT)) {
window.navigationBarColor = a.data
val tv = TypedValue()
theme.resolveAttribute(android.R.attr.colorBackground, tv, true)
if ((Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q && tv.isColorType)
|| (tv.type >= TypedValue.TYPE_FIRST_COLOR_INT && tv.type <= TypedValue.TYPE_LAST_COLOR_INT)) {
window.navigationBarColor = tv.data
}
}

View file

@ -559,6 +559,8 @@ class AnimeWatchFragment : Fragment() {
super.onResume()
binding.mediaInfoProgressBar.visibility = progress
binding.animeSourceRecycler.layoutManager?.onRestoreInstanceState(state)
requireActivity().setNavigationTheme()
}
override fun onPause() {

View file

@ -601,6 +601,7 @@ open class MangaReadFragment : Fragment(), ScanlatorSelectionListener {
super.onResume()
binding.mediaInfoProgressBar.visibility = progress
binding.animeSourceRecycler.layoutManager?.onRestoreInstanceState(state)
requireActivity().setNavigationTheme()
}

View file

@ -4,6 +4,7 @@ import android.app.Activity
import android.content.Context
import android.content.res.Configuration
import android.graphics.Bitmap
import android.os.Build
import android.view.Window
import android.view.WindowManager
import ani.dantotsu.R
@ -54,7 +55,10 @@ class ThemeManager(private val context: Activity) {
}
val window = context.window
window.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS)
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.R) {
@Suppress("DEPRECATION")
window.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS)
}
window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS)
window.statusBarColor = 0x00000000
context.setTheme(themeToApply)
@ -137,7 +141,7 @@ class ThemeManager(private val context: Activity) {
companion object {
fun fromString(value: String): Theme {
return values().find { it.theme == value } ?: PURPLE
return entries.find { it.theme == value } ?: PURPLE
}
}
}