From 02e50411de8e233dfd0f2bd9671f39a4e71d297c Mon Sep 17 00:00:00 2001 From: arkon Date: Thu, 11 Jan 2024 18:21:03 -0500 Subject: [PATCH] Minor extension repo enhancements - Shortcut to settings from extensions tab - Don't show error toast anymore if nothing's loaded - Ability to copy extension repo URL to clipboard --- .../presentation/components/TabbedScreen.kt | 2 +- .../components/ExtensionReposContent.kt | 24 ++++++++++++++++++- .../tachiyomi/extension/api/ExtensionApi.kt | 10 +------- .../ui/browse/extension/ExtensionsTab.kt | 10 ++++---- 4 files changed, 31 insertions(+), 15 deletions(-) diff --git a/app/src/main/java/eu/kanade/presentation/components/TabbedScreen.kt b/app/src/main/java/eu/kanade/presentation/components/TabbedScreen.kt index 81ad61f2a4..9dae3de14f 100644 --- a/app/src/main/java/eu/kanade/presentation/components/TabbedScreen.kt +++ b/app/src/main/java/eu/kanade/presentation/components/TabbedScreen.kt @@ -101,6 +101,6 @@ data class TabContent( val titleRes: StringResource, val badgeNumber: Int? = null, val searchEnabled: Boolean = false, - val actions: ImmutableList = persistentListOf(), + val actions: ImmutableList = persistentListOf(), val content: @Composable (contentPadding: PaddingValues, snackbarHostState: SnackbarHostState) -> Unit, ) diff --git a/app/src/main/java/eu/kanade/presentation/more/settings/screen/browse/components/ExtensionReposContent.kt b/app/src/main/java/eu/kanade/presentation/more/settings/screen/browse/components/ExtensionReposContent.kt index 3d4772836e..7d837b32d1 100644 --- a/app/src/main/java/eu/kanade/presentation/more/settings/screen/browse/components/ExtensionReposContent.kt +++ b/app/src/main/java/eu/kanade/presentation/more/settings/screen/browse/components/ExtensionReposContent.kt @@ -9,6 +9,7 @@ import androidx.compose.foundation.lazy.LazyColumn import androidx.compose.foundation.lazy.LazyListState import androidx.compose.material.icons.Icons import androidx.compose.material.icons.automirrored.outlined.Label +import androidx.compose.material.icons.outlined.ContentCopy import androidx.compose.material.icons.outlined.Delete import androidx.compose.material3.ElevatedCard import androidx.compose.material3.Icon @@ -18,8 +19,12 @@ import androidx.compose.material3.Text import androidx.compose.runtime.Composable import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier +import androidx.compose.ui.platform.LocalContext +import eu.kanade.tachiyomi.util.system.copyToClipboard import kotlinx.collections.immutable.ImmutableSet +import tachiyomi.i18n.MR import tachiyomi.presentation.core.components.material.padding +import tachiyomi.presentation.core.i18n.stringResource @Composable fun ExtensionReposContent( @@ -53,6 +58,8 @@ private fun ExtensionRepoListItem( onDelete: () -> Unit, modifier: Modifier = Modifier, ) { + val context = LocalContext.current + ElevatedCard( modifier = modifier, ) { @@ -74,8 +81,23 @@ private fun ExtensionRepoListItem( modifier = Modifier.fillMaxWidth(), horizontalArrangement = Arrangement.End, ) { + IconButton( + onClick = { + val url = "$repo/index.min.json" + context.copyToClipboard(url, url) + }, + ) { + Icon( + imageVector = Icons.Outlined.ContentCopy, + contentDescription = stringResource(MR.strings.action_copy_to_clipboard), + ) + } + IconButton(onClick = onDelete) { - Icon(imageVector = Icons.Outlined.Delete, contentDescription = null) + Icon( + imageVector = Icons.Outlined.Delete, + contentDescription = stringResource(MR.strings.action_delete), + ) } } } diff --git a/app/src/main/java/eu/kanade/tachiyomi/extension/api/ExtensionApi.kt b/app/src/main/java/eu/kanade/tachiyomi/extension/api/ExtensionApi.kt index 185f7cefd1..26e1056169 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/extension/api/ExtensionApi.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/extension/api/ExtensionApi.kt @@ -35,15 +35,7 @@ internal class ExtensionApi { suspend fun findExtensions(): List { return withIOContext { - val extensions = sourcePreferences.extensionRepos().get().flatMap { getExtensions(it) } - - // Sanity check - a small number of extensions probably means something broke - // with the repo generator - if (extensions.isEmpty()) { - throw Exception() - } - - extensions + sourcePreferences.extensionRepos().get().flatMap { getExtensions(it) } } } diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/browse/extension/ExtensionsTab.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/browse/extension/ExtensionsTab.kt index 635c6cb830..be6d243b84 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/browse/extension/ExtensionsTab.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/browse/extension/ExtensionsTab.kt @@ -1,7 +1,5 @@ package eu.kanade.tachiyomi.ui.browse.extension -import androidx.compose.material.icons.Icons -import androidx.compose.material.icons.outlined.Translate import androidx.compose.runtime.Composable import androidx.compose.runtime.collectAsState import androidx.compose.runtime.getValue @@ -10,6 +8,7 @@ import cafe.adriel.voyager.navigator.currentOrThrow import eu.kanade.presentation.browse.ExtensionScreen import eu.kanade.presentation.components.AppBar import eu.kanade.presentation.components.TabContent +import eu.kanade.presentation.more.settings.screen.browse.ExtensionReposScreen import eu.kanade.tachiyomi.extension.model.Extension import eu.kanade.tachiyomi.ui.browse.extension.details.ExtensionDetailsScreen import eu.kanade.tachiyomi.ui.webview.WebViewScreen @@ -29,11 +28,14 @@ fun extensionsTab( badgeNumber = state.updates.takeIf { it > 0 }, searchEnabled = true, actions = persistentListOf( - AppBar.Action( + AppBar.OverflowAction( title = stringResource(MR.strings.action_filter), - icon = Icons.Outlined.Translate, onClick = { navigator.push(ExtensionFilterScreen()) }, ), + AppBar.OverflowAction( + title = stringResource(MR.strings.label_extension_repos), + onClick = { navigator.push(ExtensionReposScreen()) }, + ), ), content = { contentPadding, _ -> ExtensionScreen(