offline anime

This commit is contained in:
rebelonion 2024-01-14 23:59:39 -06:00
parent 52dadf34cf
commit 98cb11e841
17 changed files with 630 additions and 22 deletions

View file

@ -4,12 +4,15 @@ 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
import com.google.android.material.color.DynamicColors
import com.google.android.material.color.DynamicColorsOptions
class ThemeManager(private val context: Context) {
class ThemeManager(private val context: Activity) {
fun applyTheme(fromImage: Bitmap? = null) {
val useOLED = context.getSharedPreferences("Dantotsu", Context.MODE_PRIVATE)
.getBoolean("use_oled", false) && isDarkThemeActive(context)
@ -54,9 +57,24 @@ class ThemeManager(private val context: Context) {
else -> if (useOLED) R.style.Theme_Dantotsu_PurpleOLED else R.style.Theme_Dantotsu_Purple
}
val window = context.window
window.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS)
window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS)
window.statusBarColor = 0x00000000
context.setTheme(themeToApply)
}
fun setWindowFlag(activity: Activity, bits: Int, on: Boolean) {
val win: Window = activity.window
val winParams: WindowManager.LayoutParams = win.attributes
if (on) {
winParams.flags = winParams.flags or bits
} else {
winParams.flags = winParams.flags and bits.inv()
}
win.setAttributes(winParams)
}
private fun applyDynamicColors(
useMaterialYou: Boolean,
context: Context,