Refactor some Screens to be classes

Not really much point in keeping these as singletons.
Hopefully allows for these to be GC-ed after closing them.
This commit is contained in:
arkon 2023-07-30 16:15:21 -04:00
parent dfbbbadfac
commit c9a1bd86b5
4 changed files with 22 additions and 13 deletions

View File

@ -114,7 +114,7 @@ object SettingsAdvancedScreen : SearchableSettings {
), ),
Preference.PreferenceItem.TextPreference( Preference.PreferenceItem.TextPreference(
title = stringResource(R.string.pref_debug_info), title = stringResource(R.string.pref_debug_info),
onClick = { navigator.push(DebugInfoScreen) }, onClick = { navigator.push(DebugInfoScreen()) },
), ),
), ),
) )

View File

@ -28,9 +28,11 @@ import eu.kanade.tachiyomi.util.system.copyToClipboard
import kotlinx.serialization.protobuf.schema.ProtoBufSchemaGenerator import kotlinx.serialization.protobuf.schema.ProtoBufSchemaGenerator
import tachiyomi.presentation.core.components.material.Scaffold import tachiyomi.presentation.core.components.material.Scaffold
object BackupSchemaScreen : Screen() { class BackupSchemaScreen : Screen() {
companion object {
const val title = "Backup file schema" const val title = "Backup file schema"
}
@Composable @Composable
override fun Content() { override fun Content() {

View File

@ -18,7 +18,8 @@ import eu.kanade.tachiyomi.R
import eu.kanade.tachiyomi.util.system.DeviceUtil import eu.kanade.tachiyomi.util.system.DeviceUtil
import kotlinx.coroutines.guava.await import kotlinx.coroutines.guava.await
object DebugInfoScreen : Screen() { class DebugInfoScreen : Screen() {
@Composable @Composable
override fun Content() { override fun Content() {
val navigator = LocalNavigator.currentOrThrow val navigator = LocalNavigator.currentOrThrow
@ -29,11 +30,11 @@ object DebugInfoScreen : Screen() {
listOf( listOf(
Preference.PreferenceItem.TextPreference( Preference.PreferenceItem.TextPreference(
title = WorkerInfoScreen.title, title = WorkerInfoScreen.title,
onClick = { navigator.push(WorkerInfoScreen) }, onClick = { navigator.push(WorkerInfoScreen()) },
), ),
Preference.PreferenceItem.TextPreference( Preference.PreferenceItem.TextPreference(
title = BackupSchemaScreen.title, title = BackupSchemaScreen.title,
onClick = { navigator.push(BackupSchemaScreen) }, onClick = { navigator.push(BackupSchemaScreen()) },
), ),
getAppInfoGroup(), getAppInfoGroup(),
getDeviceInfoGroup(), getDeviceInfoGroup(),
@ -67,11 +68,15 @@ object DebugInfoScreen : Screen() {
@Composable @Composable
@ReadOnlyComposable @ReadOnlyComposable
private fun getWebViewVersion(): String { private fun getWebViewVersion(): String {
return if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
val webView = WebView.getCurrentWebViewPackage() ?: return "how did you get here?" val webView = WebView.getCurrentWebViewPackage() ?: return "how did you get here?"
val pm = LocalContext.current.packageManager val pm = LocalContext.current.packageManager
val label = webView.applicationInfo.loadLabel(pm) val label = webView.applicationInfo.loadLabel(pm)
val version = webView.versionName val version = webView.versionName
return "$label $version" return "$label $version"
} else {
return "Unknown"
}
} }
@Composable @Composable

View File

@ -43,9 +43,11 @@ import kotlinx.coroutines.flow.stateIn
import tachiyomi.presentation.core.components.material.Scaffold import tachiyomi.presentation.core.components.material.Scaffold
import tachiyomi.presentation.core.util.plus import tachiyomi.presentation.core.util.plus
object WorkerInfoScreen : Screen() { class WorkerInfoScreen : Screen() {
companion object {
const val title = "Worker info" const val title = "Worker info"
}
@Composable @Composable
override fun Content() { override fun Content() {