mirror of
https://github.com/tachiyomiorg/tachiyomi.git
synced 2024-11-04 08:55:06 +01:00
Move themeing to base activity
This commit is contained in:
parent
0b6f7fab81
commit
10d514f8f4
@ -1,13 +1,29 @@
|
|||||||
package eu.kanade.tachiyomi.ui.base.activity
|
package eu.kanade.tachiyomi.ui.base.activity
|
||||||
|
|
||||||
|
import android.os.Bundle
|
||||||
import androidx.appcompat.app.AppCompatActivity
|
import androidx.appcompat.app.AppCompatActivity
|
||||||
|
import androidx.appcompat.app.AppCompatDelegate
|
||||||
|
import eu.kanade.tachiyomi.R
|
||||||
|
import eu.kanade.tachiyomi.data.preference.PreferencesHelper
|
||||||
import eu.kanade.tachiyomi.util.LocaleHelper
|
import eu.kanade.tachiyomi.util.LocaleHelper
|
||||||
|
import uy.kohesive.injekt.injectLazy
|
||||||
|
|
||||||
abstract class BaseActivity : AppCompatActivity() {
|
abstract class BaseActivity : AppCompatActivity() {
|
||||||
|
|
||||||
|
val preferences: PreferencesHelper by injectLazy()
|
||||||
|
|
||||||
init {
|
init {
|
||||||
@Suppress("LeakingThis")
|
@Suppress("LeakingThis")
|
||||||
LocaleHelper.updateConfiguration(this)
|
LocaleHelper.updateConfiguration(this)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
override fun onCreate(savedInstanceState: Bundle?) {
|
||||||
|
setTheme(when (preferences.theme()) {
|
||||||
|
3, 6 -> R.style.Theme_Tachiyomi_Amoled
|
||||||
|
4, 7 -> R.style.Theme_Tachiyomi_DarkBlue
|
||||||
|
else -> R.style.Theme_Tachiyomi
|
||||||
|
})
|
||||||
|
super.onCreate(savedInstanceState)
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -50,12 +50,14 @@ class LibraryCategoryAdapter(val view: LibraryCategoryView) :
|
|||||||
}
|
}
|
||||||
|
|
||||||
fun performFilter() {
|
fun performFilter() {
|
||||||
var s = getFilter(String::class.java)
|
val s = getFilter(String::class.java)
|
||||||
if (s == null) {
|
if (s.isNullOrBlank()) {
|
||||||
s = ""
|
updateDataSet(mangas)
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
updateDataSet(mangas.filter { it.filter(s) })
|
||||||
}
|
}
|
||||||
isLongPressDragEnabled = view.canDrag() && s.isNullOrBlank()
|
isLongPressDragEnabled = view.canDrag() && s.isNullOrBlank()
|
||||||
updateDataSet(mangas.filter { it.filter(s) })
|
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onCreateBubbleText(position: Int):String {
|
override fun onCreateBubbleText(position: Int):String {
|
||||||
|
@ -96,8 +96,6 @@ class LibraryController(
|
|||||||
*/
|
*/
|
||||||
private var migratingMangas = mutableSetOf<Manga>()
|
private var migratingMangas = mutableSetOf<Manga>()
|
||||||
|
|
||||||
private var selectedCoverManga: Manga? = null
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Relay to notify the UI of selection updates.
|
* Relay to notify the UI of selection updates.
|
||||||
*/
|
*/
|
||||||
|
@ -58,7 +58,7 @@ class LibraryGridHolder(
|
|||||||
GlideApp.with(view.context).clear(thumbnail)
|
GlideApp.with(view.context).clear(thumbnail)
|
||||||
GlideApp.with(view.context)
|
GlideApp.with(view.context)
|
||||||
.load(item.manga)
|
.load(item.manga)
|
||||||
.diskCacheStrategy(DiskCacheStrategy.RESOURCE)
|
.diskCacheStrategy(DiskCacheStrategy.AUTOMATIC)
|
||||||
.signature(ObjectKey(MangaImpl.getLastCoverFetch(item.manga.id!!).toString()))
|
.signature(ObjectKey(MangaImpl.getLastCoverFetch(item.manga.id!!).toString()))
|
||||||
.centerCrop()
|
.centerCrop()
|
||||||
.into(thumbnail)
|
.into(thumbnail)
|
||||||
|
@ -59,7 +59,7 @@ class LibraryListHolder(
|
|||||||
GlideApp.with(itemView.context).clear(thumbnail)
|
GlideApp.with(itemView.context).clear(thumbnail)
|
||||||
GlideApp.with(itemView.context)
|
GlideApp.with(itemView.context)
|
||||||
.load(item.manga)
|
.load(item.manga)
|
||||||
.diskCacheStrategy(DiskCacheStrategy.RESOURCE)
|
.diskCacheStrategy(DiskCacheStrategy.AUTOMATIC)
|
||||||
.signature(ObjectKey(MangaImpl.getLastCoverFetch(item.manga.id!!).toString()))
|
.signature(ObjectKey(MangaImpl.getLastCoverFetch(item.manga.id!!).toString()))
|
||||||
.centerCrop()
|
.centerCrop()
|
||||||
.circleCrop()
|
.circleCrop()
|
||||||
|
@ -12,7 +12,6 @@ import java.util.concurrent.Executors
|
|||||||
class BiometricActivity : BaseActivity() {
|
class BiometricActivity : BaseActivity() {
|
||||||
val executor = Executors.newSingleThreadExecutor()
|
val executor = Executors.newSingleThreadExecutor()
|
||||||
|
|
||||||
val preferences: PreferencesHelper by injectLazy()
|
|
||||||
override fun onCreate(savedInstanceState: Bundle?) {
|
override fun onCreate(savedInstanceState: Bundle?) {
|
||||||
super.onCreate(savedInstanceState)
|
super.onCreate(savedInstanceState)
|
||||||
val biometricPrompt = BiometricPrompt(this, executor, object : BiometricPrompt
|
val biometricPrompt = BiometricPrompt(this, executor, object : BiometricPrompt
|
||||||
|
@ -17,6 +17,7 @@ import android.webkit.WebView
|
|||||||
import android.widget.FrameLayout
|
import android.widget.FrameLayout
|
||||||
import android.widget.LinearLayout
|
import android.widget.LinearLayout
|
||||||
import android.widget.TextView
|
import android.widget.TextView
|
||||||
|
import androidx.appcompat.app.AppCompatDelegate
|
||||||
import androidx.appcompat.app.AppCompatDelegate.MODE_NIGHT_FOLLOW_SYSTEM
|
import androidx.appcompat.app.AppCompatDelegate.MODE_NIGHT_FOLLOW_SYSTEM
|
||||||
import androidx.appcompat.app.AppCompatDelegate.MODE_NIGHT_NO
|
import androidx.appcompat.app.AppCompatDelegate.MODE_NIGHT_NO
|
||||||
import androidx.appcompat.app.AppCompatDelegate.MODE_NIGHT_YES
|
import androidx.appcompat.app.AppCompatDelegate.MODE_NIGHT_YES
|
||||||
@ -77,8 +78,6 @@ open class MainActivity : BaseActivity() {
|
|||||||
|
|
||||||
protected lateinit var router: Router
|
protected lateinit var router: Router
|
||||||
|
|
||||||
val preferences: PreferencesHelper by injectLazy()
|
|
||||||
|
|
||||||
protected var drawerArrow: DrawerArrowDrawable? = null
|
protected var drawerArrow: DrawerArrowDrawable? = null
|
||||||
|
|
||||||
protected open var trulyGoBack = false
|
protected open var trulyGoBack = false
|
||||||
@ -109,17 +108,14 @@ open class MainActivity : BaseActivity() {
|
|||||||
|
|
||||||
lateinit var tabAnimator: TabsAnimator
|
lateinit var tabAnimator: TabsAnimator
|
||||||
|
|
||||||
override fun getTheme(): Resources.Theme {
|
|
||||||
val theme = super.getTheme()
|
|
||||||
theme.applyStyle(when (preferences.theme()) {
|
|
||||||
3, 6 -> R.style.Theme_Tachiyomi_Amoled
|
|
||||||
4, 7 -> R.style.Theme_Tachiyomi_DarkBlue
|
|
||||||
else -> R.style.Theme_Tachiyomi
|
|
||||||
}, true)
|
|
||||||
return theme
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun onCreate(savedInstanceState: Bundle?) {
|
override fun onCreate(savedInstanceState: Bundle?) {
|
||||||
|
setDefaultNightMode(
|
||||||
|
when (preferences.theme()) {
|
||||||
|
1 -> MODE_NIGHT_NO
|
||||||
|
2, 3, 4 -> MODE_NIGHT_YES
|
||||||
|
else -> MODE_NIGHT_FOLLOW_SYSTEM
|
||||||
|
}
|
||||||
|
)
|
||||||
// Some webview somewwhere breaks night mode, we create a webview to solve this:
|
// Some webview somewwhere breaks night mode, we create a webview to solve this:
|
||||||
// https://stackoverflow.com/a/45430282
|
// https://stackoverflow.com/a/45430282
|
||||||
if (preferences.theme() in 2..4) {
|
if (preferences.theme() in 2..4) {
|
||||||
@ -130,11 +126,6 @@ open class MainActivity : BaseActivity() {
|
|||||||
Timber.e(e, "Exception when creating webview at start")
|
Timber.e(e, "Exception when creating webview at start")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
setDefaultNightMode(when (preferences.theme()) {
|
|
||||||
1 -> MODE_NIGHT_NO
|
|
||||||
2, 3, 4 -> MODE_NIGHT_YES
|
|
||||||
else -> MODE_NIGHT_FOLLOW_SYSTEM
|
|
||||||
})
|
|
||||||
super.onCreate(savedInstanceState)
|
super.onCreate(savedInstanceState)
|
||||||
if (trulyGoBack) return
|
if (trulyGoBack) return
|
||||||
|
|
||||||
|
@ -38,7 +38,6 @@ class WebViewActivity : BaseActivity() {
|
|||||||
|
|
||||||
private val sourceManager by injectLazy<SourceManager>()
|
private val sourceManager by injectLazy<SourceManager>()
|
||||||
private var bundle:Bundle? = null
|
private var bundle:Bundle? = null
|
||||||
val preferences: PreferencesHelper by injectLazy()
|
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
const val SOURCE_KEY = "source_key"
|
const val SOURCE_KEY = "source_key"
|
||||||
@ -55,7 +54,7 @@ class WebViewActivity : BaseActivity() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun getTheme(): Resources.Theme {
|
/*override fun getTheme(): Resources.Theme {
|
||||||
val theme = super.getTheme()
|
val theme = super.getTheme()
|
||||||
theme.applyStyle(when (preferences.theme()) {
|
theme.applyStyle(when (preferences.theme()) {
|
||||||
3, 6 -> R.style.Theme_Tachiyomi_Amoled
|
3, 6 -> R.style.Theme_Tachiyomi_Amoled
|
||||||
@ -63,7 +62,7 @@ class WebViewActivity : BaseActivity() {
|
|||||||
else -> R.style.Theme_Tachiyomi
|
else -> R.style.Theme_Tachiyomi
|
||||||
}, true)
|
}, true)
|
||||||
return theme
|
return theme
|
||||||
}
|
}*/
|
||||||
|
|
||||||
override fun onCreate(savedInstanceState: Bundle?) {
|
override fun onCreate(savedInstanceState: Bundle?) {
|
||||||
super.onCreate(savedInstanceState)
|
super.onCreate(savedInstanceState)
|
||||||
|
Loading…
Reference in New Issue
Block a user