mirror of
https://github.com/mihonapp/mihon.git
synced 2024-11-07 20:31:02 -05:00
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 cafe.adriel.voyager.navigator.currentOrThrow
|
||||||
import eu.kanade.domain.base.BasePreferences
|
import eu.kanade.domain.base.BasePreferences
|
||||||
import eu.kanade.presentation.more.settings.Preference
|
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.presentation.util.collectAsState
|
||||||
import eu.kanade.tachiyomi.R
|
import eu.kanade.tachiyomi.R
|
||||||
import eu.kanade.tachiyomi.data.cache.ChapterCache
|
import eu.kanade.tachiyomi.data.cache.ChapterCache
|
||||||
|
@ -75,6 +76,8 @@ object SettingsAdvancedScreen : SearchableSettings {
|
||||||
override fun getPreferences(): List<Preference> {
|
override fun getPreferences(): List<Preference> {
|
||||||
val scope = rememberCoroutineScope()
|
val scope = rememberCoroutineScope()
|
||||||
val context = LocalContext.current
|
val context = LocalContext.current
|
||||||
|
val navigator = LocalNavigator.currentOrThrow
|
||||||
|
|
||||||
val basePreferences = remember { Injekt.get<BasePreferences>() }
|
val basePreferences = remember { Injekt.get<BasePreferences>() }
|
||||||
val networkPreferences = remember { Injekt.get<NetworkPreferences>() }
|
val networkPreferences = remember { Injekt.get<NetworkPreferences>() }
|
||||||
|
|
||||||
|
@ -103,6 +106,10 @@ object SettingsAdvancedScreen : SearchableSettings {
|
||||||
true
|
true
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
|
Preference.PreferenceItem.TextPreference(
|
||||||
|
title = stringResource(R.string.pref_debug_info),
|
||||||
|
onClick = { navigator.push(DebugInfoScreen) },
|
||||||
|
),
|
||||||
getBackgroundActivityGroup(),
|
getBackgroundActivityGroup(),
|
||||||
getDataGroup(),
|
getDataGroup(),
|
||||||
getNetworkGroup(networkPreferences = networkPreferences),
|
getNetworkGroup(networkPreferences = networkPreferences),
|
||||||
|
@ -115,7 +122,6 @@ object SettingsAdvancedScreen : SearchableSettings {
|
||||||
private fun getBackgroundActivityGroup(): Preference.PreferenceGroup {
|
private fun getBackgroundActivityGroup(): Preference.PreferenceGroup {
|
||||||
val context = LocalContext.current
|
val context = LocalContext.current
|
||||||
val uriHandler = LocalUriHandler.current
|
val uriHandler = LocalUriHandler.current
|
||||||
val navigator = LocalNavigator.currentOrThrow
|
|
||||||
|
|
||||||
return Preference.PreferenceGroup(
|
return Preference.PreferenceGroup(
|
||||||
title = stringResource(R.string.label_background_activity),
|
title = stringResource(R.string.label_background_activity),
|
||||||
|
@ -147,10 +153,6 @@ object SettingsAdvancedScreen : SearchableSettings {
|
||||||
subtitle = stringResource(R.string.about_dont_kill_my_app),
|
subtitle = stringResource(R.string.about_dont_kill_my_app),
|
||||||
onClick = { uriHandler.openUri("https://dontkillmyapp.com/") },
|
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 android.content.Context
|
||||||
import androidx.compose.foundation.horizontalScroll
|
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.Icon
|
||||||
import androidx.compose.material3.IconButton
|
import androidx.compose.material3.IconButton
|
||||||
import androidx.compose.material3.MaterialTheme
|
import androidx.compose.material3.MaterialTheme
|
||||||
import androidx.compose.material3.SnackbarHost
|
|
||||||
import androidx.compose.material3.SnackbarHostState
|
|
||||||
import androidx.compose.material3.Text
|
import androidx.compose.material3.Text
|
||||||
import androidx.compose.material3.TopAppBar
|
import androidx.compose.material3.TopAppBar
|
||||||
import androidx.compose.runtime.Composable
|
import androidx.compose.runtime.Composable
|
||||||
import androidx.compose.runtime.collectAsState
|
import androidx.compose.runtime.collectAsState
|
||||||
import androidx.compose.runtime.getValue
|
import androidx.compose.runtime.getValue
|
||||||
import androidx.compose.runtime.remember
|
|
||||||
import androidx.compose.runtime.rememberCoroutineScope
|
|
||||||
import androidx.compose.ui.Modifier
|
import androidx.compose.ui.Modifier
|
||||||
import androidx.compose.ui.platform.LocalClipboardManager
|
|
||||||
import androidx.compose.ui.platform.LocalContext
|
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.text.font.FontFamily
|
||||||
import androidx.compose.ui.unit.dp
|
import androidx.compose.ui.unit.dp
|
||||||
|
import androidx.compose.ui.util.fastForEach
|
||||||
import androidx.lifecycle.asFlow
|
import androidx.lifecycle.asFlow
|
||||||
import androidx.work.WorkInfo
|
import androidx.work.WorkInfo
|
||||||
import androidx.work.WorkQuery
|
import androidx.work.WorkQuery
|
||||||
|
@ -36,47 +30,42 @@ import cafe.adriel.voyager.navigator.LocalNavigator
|
||||||
import cafe.adriel.voyager.navigator.currentOrThrow
|
import cafe.adriel.voyager.navigator.currentOrThrow
|
||||||
import eu.kanade.presentation.util.Screen
|
import eu.kanade.presentation.util.Screen
|
||||||
import eu.kanade.presentation.util.ioCoroutineScope
|
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 eu.kanade.tachiyomi.util.system.workManager
|
||||||
import kotlinx.coroutines.flow.SharingStarted
|
import kotlinx.coroutines.flow.SharingStarted
|
||||||
import kotlinx.coroutines.flow.map
|
import kotlinx.coroutines.flow.map
|
||||||
import kotlinx.coroutines.flow.stateIn
|
import kotlinx.coroutines.flow.stateIn
|
||||||
import kotlinx.coroutines.launch
|
|
||||||
import tachiyomi.presentation.core.components.LazyColumn
|
import tachiyomi.presentation.core.components.LazyColumn
|
||||||
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() {
|
object WorkerInfoScreen : Screen() {
|
||||||
|
|
||||||
|
const val title = "Worker info"
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
override fun Content() {
|
override fun Content() {
|
||||||
val context = LocalContext.current
|
val context = LocalContext.current
|
||||||
val navigator = LocalNavigator.currentOrThrow
|
val navigator = LocalNavigator.currentOrThrow
|
||||||
val clipboardManager = LocalClipboardManager.current
|
|
||||||
|
|
||||||
val screenModel = rememberScreenModel { Model(context) }
|
val screenModel = rememberScreenModel { Model(context) }
|
||||||
val enqueued by screenModel.enqueued.collectAsState()
|
val enqueued by screenModel.enqueued.collectAsState()
|
||||||
val finished by screenModel.finished.collectAsState()
|
val finished by screenModel.finished.collectAsState()
|
||||||
val running by screenModel.running.collectAsState()
|
val running by screenModel.running.collectAsState()
|
||||||
|
|
||||||
val snackbarHostState = remember { SnackbarHostState() }
|
|
||||||
val scope = rememberCoroutineScope()
|
|
||||||
|
|
||||||
Scaffold(
|
Scaffold(
|
||||||
topBar = {
|
topBar = {
|
||||||
TopAppBar(
|
TopAppBar(
|
||||||
title = { Text(text = stringResource(R.string.pref_worker_info)) },
|
title = { Text(text = title) },
|
||||||
navigationIcon = {
|
navigationIcon = {
|
||||||
IconButton(onClick = navigator::pop) {
|
IconButton(onClick = navigator::pop) {
|
||||||
Icon(imageVector = Icons.Default.ArrowBack, contentDescription = null)
|
Icon(imageVector = Icons.Default.ArrowBack, contentDescription = null)
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
actions = {
|
actions = {
|
||||||
val copiedString = stringResource(R.string.copied_to_clipboard_plain)
|
|
||||||
IconButton(
|
IconButton(
|
||||||
onClick = {
|
onClick = {
|
||||||
clipboardManager.setText(AnnotatedString(enqueued + finished + running))
|
context.copyToClipboard(title, enqueued + finished + running)
|
||||||
scope.launch { snackbarHostState.showSnackbar(copiedString) }
|
|
||||||
},
|
},
|
||||||
) {
|
) {
|
||||||
Icon(imageVector = Icons.Default.ContentCopy, contentDescription = null)
|
Icon(imageVector = Icons.Default.ContentCopy, contentDescription = null)
|
||||||
|
@ -85,7 +74,6 @@ object WorkerInfoScreen : Screen() {
|
||||||
scrollBehavior = it,
|
scrollBehavior = it,
|
||||||
)
|
)
|
||||||
},
|
},
|
||||||
snackbarHost = { SnackbarHost(hostState = snackbarHostState) },
|
|
||||||
) { contentPadding ->
|
) { contentPadding ->
|
||||||
LazyColumn(
|
LazyColumn(
|
||||||
contentPadding = contentPadding + PaddingValues(horizontal = 16.dp),
|
contentPadding = contentPadding + PaddingValues(horizontal = 16.dp),
|
||||||
|
@ -146,7 +134,7 @@ object WorkerInfoScreen : Screen() {
|
||||||
if (list.isEmpty()) {
|
if (list.isEmpty()) {
|
||||||
appendLine("-")
|
appendLine("-")
|
||||||
} else {
|
} else {
|
||||||
list.forEach { workInfo ->
|
list.fastForEach { workInfo ->
|
||||||
appendLine("Id: ${workInfo.id}")
|
appendLine("Id: ${workInfo.id}")
|
||||||
appendLine("Tags:")
|
appendLine("Tags:")
|
||||||
workInfo.tags.forEach {
|
workInfo.tags.forEach {
|
|
@ -540,7 +540,7 @@
|
||||||
<string name="pref_tablet_ui_mode">Tablet UI</string>
|
<string name="pref_tablet_ui_mode">Tablet UI</string>
|
||||||
<string name="pref_verbose_logging">Verbose logging</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_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 -->
|
<!-- About section -->
|
||||||
<string name="website">Website</string>
|
<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.res.stringResource
|
||||||
import androidx.compose.ui.text.style.TextAlign
|
import androidx.compose.ui.text.style.TextAlign
|
||||||
import androidx.compose.ui.unit.dp
|
import androidx.compose.ui.unit.dp
|
||||||
|
import androidx.compose.ui.util.fastForEach
|
||||||
import tachiyomi.presentation.core.components.material.padding
|
import tachiyomi.presentation.core.components.material.padding
|
||||||
import tachiyomi.presentation.core.util.secondaryItemAlpha
|
import tachiyomi.presentation.core.util.secondaryItemAlpha
|
||||||
import kotlin.random.Random
|
import kotlin.random.Random
|
||||||
|
@ -79,12 +80,10 @@ fun EmptyScreen(
|
||||||
if (!actions.isNullOrEmpty()) {
|
if (!actions.isNullOrEmpty()) {
|
||||||
Row(
|
Row(
|
||||||
modifier = Modifier
|
modifier = Modifier
|
||||||
.padding(
|
.padding(top = 24.dp),
|
||||||
top = 24.dp,
|
|
||||||
),
|
|
||||||
horizontalArrangement = Arrangement.spacedBy(MaterialTheme.padding.small),
|
horizontalArrangement = Arrangement.spacedBy(MaterialTheme.padding.small),
|
||||||
) {
|
) {
|
||||||
actions.forEach {
|
actions.fastForEach {
|
||||||
ActionButton(
|
ActionButton(
|
||||||
modifier = Modifier.weight(1f),
|
modifier = Modifier.weight(1f),
|
||||||
title = stringResource(it.stringResId),
|
title = stringResource(it.stringResId),
|
||||||
|
|
Loading…
Reference in a new issue