Move worker info screen into debug info menu
No need to translate anything for debug info. Dunno what else will end up in that menu in the future.
This commit is contained in:
parent
18acf66cb8
commit
4bcd623829
5 changed files with 48 additions and 30 deletions
|
@ -26,6 +26,7 @@ import cafe.adriel.voyager.navigator.LocalNavigator
|
|||
import cafe.adriel.voyager.navigator.currentOrThrow
|
||||
import eu.kanade.domain.base.BasePreferences
|
||||
import eu.kanade.presentation.more.settings.Preference
|
||||
import eu.kanade.presentation.more.settings.screen.debug.DebugInfoScreen
|
||||
import eu.kanade.presentation.util.collectAsState
|
||||
import eu.kanade.tachiyomi.R
|
||||
import eu.kanade.tachiyomi.data.cache.ChapterCache
|
||||
|
@ -75,6 +76,8 @@ object SettingsAdvancedScreen : SearchableSettings {
|
|||
override fun getPreferences(): List<Preference> {
|
||||
val scope = rememberCoroutineScope()
|
||||
val context = LocalContext.current
|
||||
val navigator = LocalNavigator.currentOrThrow
|
||||
|
||||
val basePreferences = remember { Injekt.get<BasePreferences>() }
|
||||
val networkPreferences = remember { Injekt.get<NetworkPreferences>() }
|
||||
|
||||
|
@ -103,6 +106,10 @@ object SettingsAdvancedScreen : SearchableSettings {
|
|||
true
|
||||
},
|
||||
),
|
||||
Preference.PreferenceItem.TextPreference(
|
||||
title = stringResource(R.string.pref_debug_info),
|
||||
onClick = { navigator.push(DebugInfoScreen) },
|
||||
),
|
||||
getBackgroundActivityGroup(),
|
||||
getDataGroup(),
|
||||
getNetworkGroup(networkPreferences = networkPreferences),
|
||||
|
@ -115,7 +122,6 @@ object SettingsAdvancedScreen : SearchableSettings {
|
|||
private fun getBackgroundActivityGroup(): Preference.PreferenceGroup {
|
||||
val context = LocalContext.current
|
||||
val uriHandler = LocalUriHandler.current
|
||||
val navigator = LocalNavigator.currentOrThrow
|
||||
|
||||
return Preference.PreferenceGroup(
|
||||
title = stringResource(R.string.label_background_activity),
|
||||
|
@ -147,10 +153,6 @@ object SettingsAdvancedScreen : SearchableSettings {
|
|||
subtitle = stringResource(R.string.about_dont_kill_my_app),
|
||||
onClick = { uriHandler.openUri("https://dontkillmyapp.com/") },
|
||||
),
|
||||
Preference.PreferenceItem.TextPreference(
|
||||
title = stringResource(R.string.pref_worker_info),
|
||||
onClick = { navigator.push(WorkerInfoScreen) },
|
||||
),
|
||||
),
|
||||
)
|
||||
}
|
||||
|
|
|
@ -0,0 +1,29 @@
|
|||
package eu.kanade.presentation.more.settings.screen.debug
|
||||
|
||||
import androidx.annotation.StringRes
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.runtime.ReadOnlyComposable
|
||||
import cafe.adriel.voyager.navigator.LocalNavigator
|
||||
import cafe.adriel.voyager.navigator.currentOrThrow
|
||||
import eu.kanade.presentation.more.settings.Preference
|
||||
import eu.kanade.presentation.more.settings.screen.SearchableSettings
|
||||
import eu.kanade.tachiyomi.R
|
||||
|
||||
object DebugInfoScreen : SearchableSettings {
|
||||
@ReadOnlyComposable
|
||||
@Composable
|
||||
@StringRes
|
||||
override fun getTitleRes() = R.string.pref_debug_info
|
||||
|
||||
@Composable
|
||||
override fun getPreferences(): List<Preference> {
|
||||
val navigator = LocalNavigator.currentOrThrow
|
||||
|
||||
return listOf(
|
||||
Preference.PreferenceItem.TextPreference(
|
||||
title = WorkerInfoScreen.title,
|
||||
onClick = { navigator.push(WorkerInfoScreen) },
|
||||
),
|
||||
)
|
||||
}
|
||||
}
|
|
@ -1,4 +1,4 @@
|
|||
package eu.kanade.presentation.more.settings.screen
|
||||
package eu.kanade.presentation.more.settings.screen.debug
|
||||
|
||||
import android.content.Context
|
||||
import androidx.compose.foundation.horizontalScroll
|
||||
|
@ -11,22 +11,16 @@ import androidx.compose.material.icons.filled.ContentCopy
|
|||
import androidx.compose.material3.Icon
|
||||
import androidx.compose.material3.IconButton
|
||||
import androidx.compose.material3.MaterialTheme
|
||||
import androidx.compose.material3.SnackbarHost
|
||||
import androidx.compose.material3.SnackbarHostState
|
||||
import androidx.compose.material3.Text
|
||||
import androidx.compose.material3.TopAppBar
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.runtime.collectAsState
|
||||
import androidx.compose.runtime.getValue
|
||||
import androidx.compose.runtime.remember
|
||||
import androidx.compose.runtime.rememberCoroutineScope
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.platform.LocalClipboardManager
|
||||
import androidx.compose.ui.platform.LocalContext
|
||||
import androidx.compose.ui.res.stringResource
|
||||
import androidx.compose.ui.text.AnnotatedString
|
||||
import androidx.compose.ui.text.font.FontFamily
|
||||
import androidx.compose.ui.unit.dp
|
||||
import androidx.compose.ui.util.fastForEach
|
||||
import androidx.lifecycle.asFlow
|
||||
import androidx.work.WorkInfo
|
||||
import androidx.work.WorkQuery
|
||||
|
@ -36,47 +30,42 @@ import cafe.adriel.voyager.navigator.LocalNavigator
|
|||
import cafe.adriel.voyager.navigator.currentOrThrow
|
||||
import eu.kanade.presentation.util.Screen
|
||||
import eu.kanade.presentation.util.ioCoroutineScope
|
||||
import eu.kanade.tachiyomi.R
|
||||
import eu.kanade.tachiyomi.util.system.copyToClipboard
|
||||
import eu.kanade.tachiyomi.util.system.workManager
|
||||
import kotlinx.coroutines.flow.SharingStarted
|
||||
import kotlinx.coroutines.flow.map
|
||||
import kotlinx.coroutines.flow.stateIn
|
||||
import kotlinx.coroutines.launch
|
||||
import tachiyomi.presentation.core.components.LazyColumn
|
||||
import tachiyomi.presentation.core.components.material.Scaffold
|
||||
import tachiyomi.presentation.core.util.plus
|
||||
|
||||
object WorkerInfoScreen : Screen() {
|
||||
|
||||
const val title = "Worker info"
|
||||
|
||||
@Composable
|
||||
override fun Content() {
|
||||
val context = LocalContext.current
|
||||
val navigator = LocalNavigator.currentOrThrow
|
||||
val clipboardManager = LocalClipboardManager.current
|
||||
|
||||
val screenModel = rememberScreenModel { Model(context) }
|
||||
val enqueued by screenModel.enqueued.collectAsState()
|
||||
val finished by screenModel.finished.collectAsState()
|
||||
val running by screenModel.running.collectAsState()
|
||||
|
||||
val snackbarHostState = remember { SnackbarHostState() }
|
||||
val scope = rememberCoroutineScope()
|
||||
|
||||
Scaffold(
|
||||
topBar = {
|
||||
TopAppBar(
|
||||
title = { Text(text = stringResource(R.string.pref_worker_info)) },
|
||||
title = { Text(text = title) },
|
||||
navigationIcon = {
|
||||
IconButton(onClick = navigator::pop) {
|
||||
Icon(imageVector = Icons.Default.ArrowBack, contentDescription = null)
|
||||
}
|
||||
},
|
||||
actions = {
|
||||
val copiedString = stringResource(R.string.copied_to_clipboard_plain)
|
||||
IconButton(
|
||||
onClick = {
|
||||
clipboardManager.setText(AnnotatedString(enqueued + finished + running))
|
||||
scope.launch { snackbarHostState.showSnackbar(copiedString) }
|
||||
context.copyToClipboard(title, enqueued + finished + running)
|
||||
},
|
||||
) {
|
||||
Icon(imageVector = Icons.Default.ContentCopy, contentDescription = null)
|
||||
|
@ -85,7 +74,6 @@ object WorkerInfoScreen : Screen() {
|
|||
scrollBehavior = it,
|
||||
)
|
||||
},
|
||||
snackbarHost = { SnackbarHost(hostState = snackbarHostState) },
|
||||
) { contentPadding ->
|
||||
LazyColumn(
|
||||
contentPadding = contentPadding + PaddingValues(horizontal = 16.dp),
|
||||
|
@ -146,7 +134,7 @@ object WorkerInfoScreen : Screen() {
|
|||
if (list.isEmpty()) {
|
||||
appendLine("-")
|
||||
} else {
|
||||
list.forEach { workInfo ->
|
||||
list.fastForEach { workInfo ->
|
||||
appendLine("Id: ${workInfo.id}")
|
||||
appendLine("Tags:")
|
||||
workInfo.tags.forEach {
|
|
@ -540,7 +540,7 @@
|
|||
<string name="pref_tablet_ui_mode">Tablet UI</string>
|
||||
<string name="pref_verbose_logging">Verbose logging</string>
|
||||
<string name="pref_verbose_logging_summary">Print verbose logs to system log (reduces app performance)</string>
|
||||
<string name="pref_worker_info">Worker info</string>
|
||||
<string name="pref_debug_info">Debug info</string>
|
||||
|
||||
<!-- About section -->
|
||||
<string name="website">Website</string>
|
||||
|
|
|
@ -23,6 +23,7 @@ import androidx.compose.ui.graphics.vector.ImageVector
|
|||
import androidx.compose.ui.res.stringResource
|
||||
import androidx.compose.ui.text.style.TextAlign
|
||||
import androidx.compose.ui.unit.dp
|
||||
import androidx.compose.ui.util.fastForEach
|
||||
import tachiyomi.presentation.core.components.material.padding
|
||||
import tachiyomi.presentation.core.util.secondaryItemAlpha
|
||||
import kotlin.random.Random
|
||||
|
@ -79,12 +80,10 @@ fun EmptyScreen(
|
|||
if (!actions.isNullOrEmpty()) {
|
||||
Row(
|
||||
modifier = Modifier
|
||||
.padding(
|
||||
top = 24.dp,
|
||||
),
|
||||
.padding(top = 24.dp),
|
||||
horizontalArrangement = Arrangement.spacedBy(MaterialTheme.padding.small),
|
||||
) {
|
||||
actions.forEach {
|
||||
actions.fastForEach {
|
||||
ActionButton(
|
||||
modifier = Modifier.weight(1f),
|
||||
title = stringResource(it.stringResId),
|
||||
|
|
Reference in a new issue