diff --git a/app/src/main/java/eu/kanade/presentation/browse/anime/AnimeExtensionsScreen.kt b/app/src/main/java/eu/kanade/presentation/browse/anime/AnimeExtensionsScreen.kt index ddd0603fa..e5be41c43 100644 --- a/app/src/main/java/eu/kanade/presentation/browse/anime/AnimeExtensionsScreen.kt +++ b/app/src/main/java/eu/kanade/presentation/browse/anime/AnimeExtensionsScreen.kt @@ -38,6 +38,8 @@ import androidx.compose.ui.Modifier import androidx.compose.ui.platform.LocalContext import androidx.compose.ui.text.style.TextOverflow import androidx.compose.ui.unit.dp +import cafe.adriel.voyager.navigator.LocalNavigator +import cafe.adriel.voyager.navigator.currentOrThrow import eu.kanade.core.util.fastDistinctBy import eu.kanade.presentation.browse.BaseBrowseItem import eu.kanade.presentation.browse.anime.components.AnimeExtensionIcon @@ -45,6 +47,7 @@ import eu.kanade.presentation.browse.manga.ExtensionHeader import eu.kanade.presentation.browse.manga.ExtensionTrustDialog import eu.kanade.presentation.components.WarningBanner import eu.kanade.presentation.entries.components.DotSeparatorNoSpaceText +import eu.kanade.presentation.more.settings.screen.browse.AnimeExtensionReposScreen import eu.kanade.presentation.util.rememberRequestPackageInstallsPermissionState import eu.kanade.tachiyomi.extension.InstallStep import eu.kanade.tachiyomi.extension.anime.model.AnimeExtension @@ -52,6 +55,7 @@ import eu.kanade.tachiyomi.ui.browse.anime.extension.AnimeExtensionUiModel import eu.kanade.tachiyomi.ui.browse.anime.extension.AnimeExtensionsScreenModel import eu.kanade.tachiyomi.util.system.LocaleHelper import eu.kanade.tachiyomi.util.system.launchRequestPackageInstallsPermission +import kotlinx.collections.immutable.persistentListOf import tachiyomi.i18n.MR import tachiyomi.presentation.core.components.FastScrollLazyColumn import tachiyomi.presentation.core.components.material.PullRefresh @@ -59,6 +63,7 @@ import tachiyomi.presentation.core.components.material.padding import tachiyomi.presentation.core.components.material.topSmallPaddingValues import tachiyomi.presentation.core.i18n.stringResource import tachiyomi.presentation.core.screens.EmptyScreen +import tachiyomi.presentation.core.screens.EmptyScreenAction import tachiyomi.presentation.core.screens.LoadingScreen import tachiyomi.presentation.core.util.plus import tachiyomi.presentation.core.util.secondaryItemAlpha @@ -79,6 +84,8 @@ fun AnimeExtensionScreen( onClickUpdateAll: () -> Unit, onRefresh: () -> Unit, ) { + val navigator = LocalNavigator.currentOrThrow + PullRefresh( refreshing = state.isRefreshing, onRefresh = onRefresh, @@ -95,6 +102,13 @@ fun AnimeExtensionScreen( EmptyScreen( stringRes = msg, modifier = Modifier.padding(contentPadding), + actions = persistentListOf( + EmptyScreenAction( + stringRes = MR.strings.label_extension_repos, + icon = Icons.Outlined.Settings, + onClick = { navigator.push(AnimeExtensionReposScreen()) }, + ), + ), ) } else -> { diff --git a/app/src/main/java/eu/kanade/presentation/browse/manga/MangaExtensionsScreen.kt b/app/src/main/java/eu/kanade/presentation/browse/manga/MangaExtensionsScreen.kt index 3eaf77f68..52ecc009f 100644 --- a/app/src/main/java/eu/kanade/presentation/browse/manga/MangaExtensionsScreen.kt +++ b/app/src/main/java/eu/kanade/presentation/browse/manga/MangaExtensionsScreen.kt @@ -40,12 +40,15 @@ import androidx.compose.ui.Modifier import androidx.compose.ui.platform.LocalContext import androidx.compose.ui.text.style.TextOverflow import androidx.compose.ui.unit.dp +import cafe.adriel.voyager.navigator.LocalNavigator +import cafe.adriel.voyager.navigator.currentOrThrow import dev.icerock.moko.resources.StringResource import eu.kanade.core.util.fastDistinctBy import eu.kanade.presentation.browse.BaseBrowseItem import eu.kanade.presentation.browse.manga.components.MangaExtensionIcon import eu.kanade.presentation.components.WarningBanner import eu.kanade.presentation.entries.components.DotSeparatorNoSpaceText +import eu.kanade.presentation.more.settings.screen.browse.MangaExtensionReposScreen import eu.kanade.presentation.util.rememberRequestPackageInstallsPermissionState import eu.kanade.tachiyomi.extension.InstallStep import eu.kanade.tachiyomi.extension.manga.model.MangaExtension @@ -53,6 +56,7 @@ import eu.kanade.tachiyomi.ui.browse.manga.extension.MangaExtensionUiModel import eu.kanade.tachiyomi.ui.browse.manga.extension.MangaExtensionsScreenModel import eu.kanade.tachiyomi.util.system.LocaleHelper import eu.kanade.tachiyomi.util.system.launchRequestPackageInstallsPermission +import kotlinx.collections.immutable.persistentListOf import tachiyomi.i18n.MR import tachiyomi.presentation.core.components.FastScrollLazyColumn import tachiyomi.presentation.core.components.material.PullRefresh @@ -60,6 +64,7 @@ import tachiyomi.presentation.core.components.material.padding import tachiyomi.presentation.core.components.material.topSmallPaddingValues import tachiyomi.presentation.core.i18n.stringResource import tachiyomi.presentation.core.screens.EmptyScreen +import tachiyomi.presentation.core.screens.EmptyScreenAction import tachiyomi.presentation.core.screens.LoadingScreen import tachiyomi.presentation.core.theme.header import tachiyomi.presentation.core.util.plus @@ -81,6 +86,8 @@ fun MangaExtensionScreen( onClickUpdateAll: () -> Unit, onRefresh: () -> Unit, ) { + val navigator = LocalNavigator.currentOrThrow + PullRefresh( refreshing = state.isRefreshing, onRefresh = onRefresh, @@ -97,6 +104,13 @@ fun MangaExtensionScreen( EmptyScreen( stringRes = msg, modifier = Modifier.padding(contentPadding), + actions = persistentListOf( + EmptyScreenAction( + stringRes = MR.strings.label_extension_repos, + icon = Icons.Outlined.Settings, + onClick = { navigator.push(MangaExtensionReposScreen()) }, + ), + ), ) } else -> { diff --git a/app/src/main/java/eu/kanade/presentation/components/EmptyScreen.kt b/app/src/main/java/eu/kanade/presentation/components/EmptyScreen.kt index ddcf22cb4..5355318a9 100644 --- a/app/src/main/java/eu/kanade/presentation/components/EmptyScreen.kt +++ b/app/src/main/java/eu/kanade/presentation/components/EmptyScreen.kt @@ -6,7 +6,7 @@ import androidx.compose.material.icons.outlined.Refresh import androidx.compose.material3.Surface import androidx.compose.runtime.Composable import androidx.compose.ui.tooling.preview.PreviewLightDark -import eu.kanade.presentation.theme.TachiyomiTheme +import eu.kanade.presentation.theme.TachiyomiPreviewTheme import kotlinx.collections.immutable.persistentListOf import tachiyomi.i18n.MR import tachiyomi.presentation.core.screens.EmptyScreen @@ -15,7 +15,7 @@ import tachiyomi.presentation.core.screens.EmptyScreenAction @PreviewLightDark @Composable private fun NoActionPreview() { - TachiyomiTheme { + TachiyomiPreviewTheme { Surface { EmptyScreen( stringRes = MR.strings.empty_screen, @@ -27,7 +27,7 @@ private fun NoActionPreview() { @PreviewLightDark @Composable private fun WithActionPreview() { - TachiyomiTheme { + TachiyomiPreviewTheme { Surface { EmptyScreen( stringRes = MR.strings.empty_screen, 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 bbd8fbcb8..d9b41f3b2 100644 --- a/app/src/main/java/eu/kanade/presentation/components/TabbedScreen.kt +++ b/app/src/main/java/eu/kanade/presentation/components/TabbedScreen.kt @@ -133,7 +133,7 @@ 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, val numberTitle: Int = 0, val cancelAction: () -> Unit = {}, diff --git a/app/src/main/java/eu/kanade/presentation/crash/CrashScreen.kt b/app/src/main/java/eu/kanade/presentation/crash/CrashScreen.kt index a27472c45..4fb22201a 100644 --- a/app/src/main/java/eu/kanade/presentation/crash/CrashScreen.kt +++ b/app/src/main/java/eu/kanade/presentation/crash/CrashScreen.kt @@ -14,7 +14,7 @@ import androidx.compose.ui.Modifier import androidx.compose.ui.draw.clip import androidx.compose.ui.platform.LocalContext import androidx.compose.ui.tooling.preview.PreviewLightDark -import eu.kanade.presentation.theme.TachiyomiTheme +import eu.kanade.presentation.theme.TachiyomiPreviewTheme import eu.kanade.tachiyomi.util.CrashLogUtil import kotlinx.coroutines.launch import tachiyomi.i18n.MR @@ -66,7 +66,7 @@ fun CrashScreen( @PreviewLightDark @Composable private fun CrashScreenPreview() { - TachiyomiTheme { + TachiyomiPreviewTheme { CrashScreen(exception = RuntimeException("Dummy")) {} } } diff --git a/app/src/main/java/eu/kanade/presentation/entries/components/MissingItemCountListItem.kt b/app/src/main/java/eu/kanade/presentation/entries/components/MissingItemCountListItem.kt index 5facc81a4..34092a9d0 100644 --- a/app/src/main/java/eu/kanade/presentation/entries/components/MissingItemCountListItem.kt +++ b/app/src/main/java/eu/kanade/presentation/entries/components/MissingItemCountListItem.kt @@ -11,7 +11,7 @@ import androidx.compose.runtime.Composable import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier import androidx.compose.ui.tooling.preview.PreviewLightDark -import eu.kanade.presentation.theme.TachiyomiTheme +import eu.kanade.presentation.theme.TachiyomiPreviewTheme import tachiyomi.i18n.MR import tachiyomi.presentation.core.components.material.padding import tachiyomi.presentation.core.i18n.pluralStringResource @@ -44,7 +44,7 @@ fun MissingItemCountListItem( @PreviewLightDark @Composable private fun Preview() { - TachiyomiTheme { + TachiyomiPreviewTheme { Surface { MissingItemCountListItem(count = 42) } diff --git a/app/src/main/java/eu/kanade/presentation/history/HistoryDialogs.kt b/app/src/main/java/eu/kanade/presentation/history/HistoryDialogs.kt index 96df879ed..44975c135 100644 --- a/app/src/main/java/eu/kanade/presentation/history/HistoryDialogs.kt +++ b/app/src/main/java/eu/kanade/presentation/history/HistoryDialogs.kt @@ -12,7 +12,7 @@ import androidx.compose.runtime.mutableStateOf import androidx.compose.runtime.remember import androidx.compose.runtime.setValue import androidx.compose.ui.tooling.preview.PreviewLightDark -import eu.kanade.presentation.theme.TachiyomiTheme +import eu.kanade.presentation.theme.TachiyomiPreviewTheme import tachiyomi.i18n.MR import tachiyomi.presentation.core.components.LabeledCheckbox import tachiyomi.presentation.core.components.material.padding @@ -102,7 +102,7 @@ fun HistoryDeleteAllDialog( @PreviewLightDark @Composable private fun HistoryDeleteDialogPreview() { - TachiyomiTheme { + TachiyomiPreviewTheme { HistoryDeleteDialog( onDismissRequest = {}, onDelete = {}, diff --git a/app/src/main/java/eu/kanade/presentation/history/anime/AnimeHistoryScreen.kt b/app/src/main/java/eu/kanade/presentation/history/anime/AnimeHistoryScreen.kt index 30123ed2c..2c01590d6 100644 --- a/app/src/main/java/eu/kanade/presentation/history/anime/AnimeHistoryScreen.kt +++ b/app/src/main/java/eu/kanade/presentation/history/anime/AnimeHistoryScreen.kt @@ -11,7 +11,7 @@ import androidx.compose.ui.tooling.preview.PreviewLightDark import androidx.compose.ui.tooling.preview.PreviewParameter import eu.kanade.presentation.components.relativeDateText import eu.kanade.presentation.history.anime.components.AnimeHistoryItem -import eu.kanade.presentation.theme.TachiyomiTheme +import eu.kanade.presentation.theme.TachiyomiPreviewTheme import eu.kanade.tachiyomi.ui.history.anime.AnimeHistoryScreenModel import tachiyomi.domain.history.anime.model.AnimeHistoryWithRelations import tachiyomi.i18n.MR @@ -114,7 +114,7 @@ internal fun HistoryScreenPreviews( @PreviewParameter(AnimeHistoryScreenModelStateProvider::class) historyState: AnimeHistoryScreenModel.State, ) { - TachiyomiTheme { + TachiyomiPreviewTheme { AnimeHistoryScreen( state = historyState, snackbarHostState = SnackbarHostState(), diff --git a/app/src/main/java/eu/kanade/presentation/history/anime/components/AnimeHistoryItem.kt b/app/src/main/java/eu/kanade/presentation/history/anime/components/AnimeHistoryItem.kt index f1ce1161d..d0bf8eeac 100644 --- a/app/src/main/java/eu/kanade/presentation/history/anime/components/AnimeHistoryItem.kt +++ b/app/src/main/java/eu/kanade/presentation/history/anime/components/AnimeHistoryItem.kt @@ -23,7 +23,7 @@ import androidx.compose.ui.tooling.preview.PreviewLightDark import androidx.compose.ui.tooling.preview.PreviewParameter import androidx.compose.ui.unit.dp import eu.kanade.presentation.entries.components.ItemCover -import eu.kanade.presentation.theme.TachiyomiTheme +import eu.kanade.presentation.theme.TachiyomiPreviewTheme import eu.kanade.presentation.util.formatEpisodeNumber import eu.kanade.tachiyomi.util.lang.toTimestampString import tachiyomi.domain.history.anime.model.AnimeHistoryWithRelations @@ -101,7 +101,7 @@ private fun HistoryItemPreviews( @PreviewParameter(AnimeHistoryWithRelationsProvider::class) historyWithRelations: AnimeHistoryWithRelations, ) { - TachiyomiTheme { + TachiyomiPreviewTheme { Surface { AnimeHistoryItem( history = historyWithRelations, diff --git a/app/src/main/java/eu/kanade/presentation/history/manga/MangaHistoryScreen.kt b/app/src/main/java/eu/kanade/presentation/history/manga/MangaHistoryScreen.kt index e6c175e13..5021f5624 100644 --- a/app/src/main/java/eu/kanade/presentation/history/manga/MangaHistoryScreen.kt +++ b/app/src/main/java/eu/kanade/presentation/history/manga/MangaHistoryScreen.kt @@ -11,7 +11,7 @@ import androidx.compose.ui.tooling.preview.PreviewLightDark import androidx.compose.ui.tooling.preview.PreviewParameter import eu.kanade.presentation.components.relativeDateText import eu.kanade.presentation.history.manga.components.MangaHistoryItem -import eu.kanade.presentation.theme.TachiyomiTheme +import eu.kanade.presentation.theme.TachiyomiPreviewTheme import eu.kanade.tachiyomi.ui.history.manga.MangaHistoryScreenModel import tachiyomi.domain.history.manga.model.MangaHistoryWithRelations import tachiyomi.i18n.MR @@ -114,7 +114,7 @@ internal fun HistoryScreenPreviews( @PreviewParameter(MangaHistoryScreenModelStateProvider::class) historyState: MangaHistoryScreenModel.State, ) { - TachiyomiTheme { + TachiyomiPreviewTheme { MangaHistoryScreen( state = historyState, snackbarHostState = SnackbarHostState(), diff --git a/app/src/main/java/eu/kanade/presentation/history/manga/components/MangaHistoryItem.kt b/app/src/main/java/eu/kanade/presentation/history/manga/components/MangaHistoryItem.kt index 0a0563d4f..1f9a8cd53 100644 --- a/app/src/main/java/eu/kanade/presentation/history/manga/components/MangaHistoryItem.kt +++ b/app/src/main/java/eu/kanade/presentation/history/manga/components/MangaHistoryItem.kt @@ -23,7 +23,7 @@ import androidx.compose.ui.tooling.preview.PreviewLightDark import androidx.compose.ui.tooling.preview.PreviewParameter import androidx.compose.ui.unit.dp import eu.kanade.presentation.entries.components.ItemCover -import eu.kanade.presentation.theme.TachiyomiTheme +import eu.kanade.presentation.theme.TachiyomiPreviewTheme import eu.kanade.presentation.util.formatChapterNumber import eu.kanade.tachiyomi.util.lang.toTimestampString import tachiyomi.domain.history.manga.model.MangaHistoryWithRelations @@ -101,7 +101,7 @@ internal fun HistoryItemPreviews( @PreviewParameter(MangaHistoryWithRelationsProvider::class) historyWithRelations: MangaHistoryWithRelations, ) { - TachiyomiTheme { + TachiyomiPreviewTheme { Surface { MangaHistoryItem( history = historyWithRelations, diff --git a/app/src/main/java/eu/kanade/presentation/library/components/LibraryBadges.kt b/app/src/main/java/eu/kanade/presentation/library/components/LibraryBadges.kt index a19300f6a..a46724ed3 100644 --- a/app/src/main/java/eu/kanade/presentation/library/components/LibraryBadges.kt +++ b/app/src/main/java/eu/kanade/presentation/library/components/LibraryBadges.kt @@ -6,7 +6,7 @@ import androidx.compose.material.icons.outlined.Folder import androidx.compose.material3.MaterialTheme import androidx.compose.runtime.Composable import androidx.compose.ui.tooling.preview.PreviewLightDark -import eu.kanade.presentation.theme.TachiyomiTheme +import eu.kanade.presentation.theme.TachiyomiPreviewTheme import tachiyomi.presentation.core.components.Badge @Composable @@ -50,7 +50,7 @@ internal fun LanguageBadge( @PreviewLightDark @Composable private fun BadgePreview() { - TachiyomiTheme { + TachiyomiPreviewTheme { Column { DownloadsBadge(count = 10) UnviewedBadge(count = 10) diff --git a/app/src/main/java/eu/kanade/presentation/more/NewUpdateScreen.kt b/app/src/main/java/eu/kanade/presentation/more/NewUpdateScreen.kt index 96fd421dd..3d561b0c3 100644 --- a/app/src/main/java/eu/kanade/presentation/more/NewUpdateScreen.kt +++ b/app/src/main/java/eu/kanade/presentation/more/NewUpdateScreen.kt @@ -19,7 +19,7 @@ import com.halilibo.richtext.markdown.Markdown import com.halilibo.richtext.ui.RichTextStyle import com.halilibo.richtext.ui.material3.RichText import com.halilibo.richtext.ui.string.RichTextStringStyle -import eu.kanade.presentation.theme.TachiyomiTheme +import eu.kanade.presentation.theme.TachiyomiPreviewTheme import tachiyomi.i18n.MR import tachiyomi.presentation.core.components.material.padding import tachiyomi.presentation.core.i18n.stringResource @@ -69,7 +69,7 @@ fun NewUpdateScreen( @PreviewLightDark @Composable private fun NewUpdateScreenPreview() { - TachiyomiTheme { + TachiyomiPreviewTheme { NewUpdateScreen( versionName = "v0.99.9", changelogInfo = """ diff --git a/app/src/main/java/eu/kanade/presentation/more/onboarding/GuidesStep.kt b/app/src/main/java/eu/kanade/presentation/more/onboarding/GuidesStep.kt index 669268941..02ccb2813 100644 --- a/app/src/main/java/eu/kanade/presentation/more/onboarding/GuidesStep.kt +++ b/app/src/main/java/eu/kanade/presentation/more/onboarding/GuidesStep.kt @@ -13,7 +13,7 @@ import androidx.compose.ui.Modifier import androidx.compose.ui.platform.LocalUriHandler import androidx.compose.ui.tooling.preview.PreviewLightDark import androidx.compose.ui.unit.dp -import eu.kanade.presentation.theme.TachiyomiTheme +import eu.kanade.presentation.theme.TachiyomiPreviewTheme import tachiyomi.i18n.MR import tachiyomi.presentation.core.components.material.padding import tachiyomi.presentation.core.i18n.stringResource @@ -61,7 +61,7 @@ const val GETTING_STARTED_URL = "https://aniyomi.org/docs/guides/getting-started @PreviewLightDark @Composable private fun GuidesStepPreview() { - TachiyomiTheme { + TachiyomiPreviewTheme { GuidesStep( onRestoreBackup = {}, ).Content() 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 3d4772836..7d837b32d 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/presentation/more/settings/widget/AppThemePreferenceWidget.kt b/app/src/main/java/eu/kanade/presentation/more/settings/widget/AppThemePreferenceWidget.kt index c6a4b7025..72bb00a18 100644 --- a/app/src/main/java/eu/kanade/presentation/more/settings/widget/AppThemePreferenceWidget.kt +++ b/app/src/main/java/eu/kanade/presentation/more/settings/widget/AppThemePreferenceWidget.kt @@ -42,15 +42,19 @@ import androidx.compose.ui.text.style.TextAlign import androidx.compose.ui.tooling.preview.PreviewLightDark import androidx.compose.ui.unit.dp import androidx.core.app.ActivityCompat +import eu.kanade.domain.ui.UiPreferences import eu.kanade.domain.ui.model.AppTheme import eu.kanade.presentation.entries.components.ItemCover import eu.kanade.presentation.theme.TachiyomiTheme import eu.kanade.tachiyomi.util.system.DeviceUtil import eu.kanade.tachiyomi.util.system.isDynamicColorAvailable +import tachiyomi.core.preference.InMemoryPreferenceStore import tachiyomi.i18n.MR import tachiyomi.presentation.core.components.material.padding import tachiyomi.presentation.core.i18n.stringResource import tachiyomi.presentation.core.util.secondaryItemAlpha +import uy.kohesive.injekt.Injekt +import uy.kohesive.injekt.api.fullType @Composable internal fun AppThemePreferenceWidget( @@ -258,7 +262,8 @@ fun AppThemePreviewItem( @Composable private fun AppThemesListPreview() { var appTheme by remember { mutableStateOf(AppTheme.DEFAULT) } - TachiyomiTheme { + Injekt.addSingleton(fullType(), UiPreferences(InMemoryPreferenceStore())) + TachiyomiTheme(appTheme = appTheme) { Surface { AppThemesList( currentTheme = appTheme, diff --git a/app/src/main/java/eu/kanade/presentation/more/settings/widget/InfoWidget.kt b/app/src/main/java/eu/kanade/presentation/more/settings/widget/InfoWidget.kt index 5d9d8db85..46fee1e1c 100644 --- a/app/src/main/java/eu/kanade/presentation/more/settings/widget/InfoWidget.kt +++ b/app/src/main/java/eu/kanade/presentation/more/settings/widget/InfoWidget.kt @@ -12,7 +12,7 @@ import androidx.compose.material3.Text import androidx.compose.runtime.Composable import androidx.compose.ui.Modifier import androidx.compose.ui.tooling.preview.PreviewLightDark -import eu.kanade.presentation.theme.TachiyomiTheme +import eu.kanade.presentation.theme.TachiyomiPreviewTheme import tachiyomi.i18n.MR import tachiyomi.presentation.core.components.material.padding import tachiyomi.presentation.core.i18n.stringResource @@ -43,7 +43,7 @@ internal fun InfoWidget(text: String) { @PreviewLightDark @Composable private fun InfoWidgetPreview() { - TachiyomiTheme { + TachiyomiPreviewTheme { Surface { InfoWidget(text = stringResource(MR.strings.download_ahead_info)) } diff --git a/app/src/main/java/eu/kanade/presentation/more/settings/widget/SwitchPreferenceWidget.kt b/app/src/main/java/eu/kanade/presentation/more/settings/widget/SwitchPreferenceWidget.kt index bc026d3ba..41690242d 100644 --- a/app/src/main/java/eu/kanade/presentation/more/settings/widget/SwitchPreferenceWidget.kt +++ b/app/src/main/java/eu/kanade/presentation/more/settings/widget/SwitchPreferenceWidget.kt @@ -10,7 +10,7 @@ import androidx.compose.runtime.Composable import androidx.compose.ui.Modifier import androidx.compose.ui.graphics.vector.ImageVector import androidx.compose.ui.tooling.preview.PreviewLightDark -import eu.kanade.presentation.theme.TachiyomiTheme +import eu.kanade.presentation.theme.TachiyomiPreviewTheme @Composable fun SwitchPreferenceWidget( @@ -40,7 +40,7 @@ fun SwitchPreferenceWidget( @PreviewLightDark @Composable private fun SwitchPreferenceWidgetPreview() { - TachiyomiTheme { + TachiyomiPreviewTheme { Surface { Column { SwitchPreferenceWidget( diff --git a/app/src/main/java/eu/kanade/presentation/more/settings/widget/TextPreferenceWidget.kt b/app/src/main/java/eu/kanade/presentation/more/settings/widget/TextPreferenceWidget.kt index 05bd7f85d..f3423d8e4 100644 --- a/app/src/main/java/eu/kanade/presentation/more/settings/widget/TextPreferenceWidget.kt +++ b/app/src/main/java/eu/kanade/presentation/more/settings/widget/TextPreferenceWidget.kt @@ -13,7 +13,7 @@ import androidx.compose.ui.Modifier import androidx.compose.ui.graphics.Color import androidx.compose.ui.graphics.vector.ImageVector import androidx.compose.ui.tooling.preview.PreviewLightDark -import eu.kanade.presentation.theme.TachiyomiTheme +import eu.kanade.presentation.theme.TachiyomiPreviewTheme import tachiyomi.presentation.core.util.secondaryItemAlpha @Composable @@ -62,7 +62,7 @@ fun TextPreferenceWidget( @PreviewLightDark @Composable private fun TextPreferenceWidgetPreview() { - TachiyomiTheme { + TachiyomiPreviewTheme { Surface { Column { TextPreferenceWidget( diff --git a/app/src/main/java/eu/kanade/presentation/reader/ChapterTransition.kt b/app/src/main/java/eu/kanade/presentation/reader/ChapterTransition.kt index 1bdff37d9..807bd34ff 100644 --- a/app/src/main/java/eu/kanade/presentation/reader/ChapterTransition.kt +++ b/app/src/main/java/eu/kanade/presentation/reader/ChapterTransition.kt @@ -33,7 +33,7 @@ import androidx.compose.ui.text.style.TextOverflow import androidx.compose.ui.tooling.preview.PreviewLightDark import androidx.compose.ui.unit.dp import androidx.compose.ui.unit.sp -import eu.kanade.presentation.theme.TachiyomiTheme +import eu.kanade.presentation.theme.TachiyomiPreviewTheme import eu.kanade.tachiyomi.data.database.models.manga.toDomainChapter import eu.kanade.tachiyomi.ui.reader.model.ChapterTransition import eu.kanade.tachiyomi.ui.reader.model.ReaderChapter @@ -310,7 +310,7 @@ private val FakeChapterLongTitle = previewChapter( @PreviewLightDark @Composable private fun TransitionTextPreview() { - TachiyomiTheme { + TachiyomiPreviewTheme { Surface(modifier = Modifier.padding(48.dp)) { ChapterTransition( transition = ChapterTransition.Next( @@ -327,7 +327,7 @@ private fun TransitionTextPreview() { @PreviewLightDark @Composable private fun TransitionTextLongTitlePreview() { - TachiyomiTheme { + TachiyomiPreviewTheme { Surface(modifier = Modifier.padding(48.dp)) { ChapterTransition( transition = ChapterTransition.Next( @@ -344,7 +344,7 @@ private fun TransitionTextLongTitlePreview() { @PreviewLightDark @Composable private fun TransitionTextWithGapPreview() { - TachiyomiTheme { + TachiyomiPreviewTheme { Surface(modifier = Modifier.padding(48.dp)) { ChapterTransition( transition = ChapterTransition.Next( @@ -361,7 +361,7 @@ private fun TransitionTextWithGapPreview() { @PreviewLightDark @Composable private fun TransitionTextNoNextPreview() { - TachiyomiTheme { + TachiyomiPreviewTheme { Surface(modifier = Modifier.padding(48.dp)) { ChapterTransition( transition = ChapterTransition.Next(ReaderChapter(FakeChapter), null), @@ -375,7 +375,7 @@ private fun TransitionTextNoNextPreview() { @PreviewLightDark @Composable private fun TransitionTextNoPreviousPreview() { - TachiyomiTheme { + TachiyomiPreviewTheme { Surface(modifier = Modifier.padding(48.dp)) { ChapterTransition( transition = ChapterTransition.Prev(ReaderChapter(FakeChapter), null), diff --git a/app/src/main/java/eu/kanade/presentation/reader/OrientationSelectDialog.kt b/app/src/main/java/eu/kanade/presentation/reader/OrientationSelectDialog.kt index 82c998956..20c154cce 100644 --- a/app/src/main/java/eu/kanade/presentation/reader/OrientationSelectDialog.kt +++ b/app/src/main/java/eu/kanade/presentation/reader/OrientationSelectDialog.kt @@ -16,7 +16,7 @@ import dev.icerock.moko.resources.StringResource import eu.kanade.domain.entries.manga.model.readerOrientation import eu.kanade.presentation.components.AdaptiveSheet import eu.kanade.presentation.reader.components.ModeSelectionDialog -import eu.kanade.presentation.theme.TachiyomiTheme +import eu.kanade.presentation.theme.TachiyomiPreviewTheme import eu.kanade.tachiyomi.ui.reader.setting.ReaderOrientation import eu.kanade.tachiyomi.ui.reader.setting.ReaderSettingsScreenModel import tachiyomi.i18n.MR @@ -85,7 +85,7 @@ private fun DialogContent( @PreviewLightDark @Composable private fun DialogContentPreview() { - TachiyomiTheme { + TachiyomiPreviewTheme { Surface { Column { DialogContent( diff --git a/app/src/main/java/eu/kanade/presentation/reader/PageIndicatorText.kt b/app/src/main/java/eu/kanade/presentation/reader/PageIndicatorText.kt index 48998d165..fc1b6f716 100644 --- a/app/src/main/java/eu/kanade/presentation/reader/PageIndicatorText.kt +++ b/app/src/main/java/eu/kanade/presentation/reader/PageIndicatorText.kt @@ -12,7 +12,7 @@ import androidx.compose.ui.text.TextStyle import androidx.compose.ui.text.font.FontWeight import androidx.compose.ui.tooling.preview.PreviewLightDark import androidx.compose.ui.unit.sp -import eu.kanade.presentation.theme.TachiyomiTheme +import eu.kanade.presentation.theme.TachiyomiPreviewTheme @Composable fun PageIndicatorText( @@ -52,7 +52,7 @@ fun PageIndicatorText( @PreviewLightDark @Composable private fun PageIndicatorTextPreview() { - TachiyomiTheme { + TachiyomiPreviewTheme { Surface { PageIndicatorText(currentPage = 10, totalPages = 69) } diff --git a/app/src/main/java/eu/kanade/presentation/reader/ReadingModeSelectDialog.kt b/app/src/main/java/eu/kanade/presentation/reader/ReadingModeSelectDialog.kt index 50b5333ac..7d9fd928d 100644 --- a/app/src/main/java/eu/kanade/presentation/reader/ReadingModeSelectDialog.kt +++ b/app/src/main/java/eu/kanade/presentation/reader/ReadingModeSelectDialog.kt @@ -18,7 +18,7 @@ import dev.icerock.moko.resources.StringResource import eu.kanade.domain.entries.manga.model.readingMode import eu.kanade.presentation.components.AdaptiveSheet import eu.kanade.presentation.reader.components.ModeSelectionDialog -import eu.kanade.presentation.theme.TachiyomiTheme +import eu.kanade.presentation.theme.TachiyomiPreviewTheme import eu.kanade.tachiyomi.ui.reader.setting.ReaderSettingsScreenModel import eu.kanade.tachiyomi.ui.reader.setting.ReadingMode import tachiyomi.i18n.MR @@ -83,7 +83,7 @@ private fun DialogContent( @PreviewLightDark @Composable private fun DialogContentPreview() { - TachiyomiTheme { + TachiyomiPreviewTheme { Surface { Column { DialogContent( diff --git a/app/src/main/java/eu/kanade/presentation/reader/components/ModeSelectionDialog.kt b/app/src/main/java/eu/kanade/presentation/reader/components/ModeSelectionDialog.kt index 683534e9a..c6286bf22 100644 --- a/app/src/main/java/eu/kanade/presentation/reader/components/ModeSelectionDialog.kt +++ b/app/src/main/java/eu/kanade/presentation/reader/components/ModeSelectionDialog.kt @@ -19,7 +19,7 @@ import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier import androidx.compose.ui.tooling.preview.PreviewLightDark import androidx.compose.ui.unit.dp -import eu.kanade.presentation.theme.TachiyomiTheme +import eu.kanade.presentation.theme.TachiyomiPreviewTheme import tachiyomi.i18n.MR import tachiyomi.presentation.core.components.SettingsItemsPaddings import tachiyomi.presentation.core.components.material.padding @@ -70,7 +70,7 @@ fun ModeSelectionDialog( @PreviewLightDark @Composable private fun Preview() { - TachiyomiTheme { + TachiyomiPreviewTheme { Surface { Column { ModeSelectionDialog( diff --git a/app/src/main/java/eu/kanade/presentation/theme/TachiyomiTheme.kt b/app/src/main/java/eu/kanade/presentation/theme/TachiyomiTheme.kt index 18e07e1a0..75b91978c 100644 --- a/app/src/main/java/eu/kanade/presentation/theme/TachiyomiTheme.kt +++ b/app/src/main/java/eu/kanade/presentation/theme/TachiyomiTheme.kt @@ -34,9 +34,30 @@ fun TachiyomiTheme( appTheme: AppTheme? = null, amoled: Boolean? = null, content: @Composable () -> Unit, +) { + val uiPreferences = Injekt.get() + BaseTachiyomiTheme( + appTheme = appTheme ?: uiPreferences.appTheme().get(), + isAmoled = amoled ?: uiPreferences.themeDarkAmoled().get(), + content = content, + ) +} + +@Composable +fun TachiyomiPreviewTheme( + appTheme: AppTheme = AppTheme.DEFAULT, + isAmoled: Boolean = false, + content: @Composable () -> Unit, +) = BaseTachiyomiTheme(appTheme, isAmoled, content) + +@Composable +private fun BaseTachiyomiTheme( + appTheme: AppTheme, + isAmoled: Boolean, + content: @Composable () -> Unit, ) { MaterialTheme( - colorScheme = getThemeColorScheme(appTheme, amoled), + colorScheme = getThemeColorScheme(appTheme, isAmoled), content = content, ) } @@ -44,11 +65,11 @@ fun TachiyomiTheme( @Composable @ReadOnlyComposable private fun getThemeColorScheme( - appTheme: AppTheme?, - amoled: Boolean?, + appTheme: AppTheme, + isAmoled: Boolean, ): ColorScheme { val uiPreferences = Injekt.get() - val colorScheme = when (appTheme ?: uiPreferences.appTheme().get()) { + val colorScheme = when (appTheme) { AppTheme.DEFAULT -> TachiyomiColorScheme AppTheme.MONET -> MonetColorScheme(LocalContext.current) AppTheme.CLOUDFLARE -> CloudflareColorScheme @@ -71,6 +92,6 @@ private fun getThemeColorScheme( } return colorScheme.getColorScheme( isSystemInDarkTheme(), - amoled ?: uiPreferences.themeDarkAmoled().get(), + isAmoled, ) } diff --git a/app/src/main/java/eu/kanade/presentation/track/TrackInfoDialogSelector.kt b/app/src/main/java/eu/kanade/presentation/track/TrackInfoDialogSelector.kt index c93fc3dde..a1f9a496f 100644 --- a/app/src/main/java/eu/kanade/presentation/track/TrackInfoDialogSelector.kt +++ b/app/src/main/java/eu/kanade/presentation/track/TrackInfoDialogSelector.kt @@ -32,7 +32,7 @@ import androidx.compose.ui.draw.clip import androidx.compose.ui.tooling.preview.PreviewLightDark import androidx.compose.ui.unit.dp import dev.icerock.moko.resources.StringResource -import eu.kanade.presentation.theme.TachiyomiTheme +import eu.kanade.presentation.theme.TachiyomiPreviewTheme import kotlinx.collections.immutable.ImmutableList import kotlinx.collections.immutable.persistentMapOf import kotlinx.collections.immutable.toImmutableList @@ -244,7 +244,7 @@ fun BaseSelector( @PreviewLightDark @Composable private fun TrackStatusSelectorPreviews() { - TachiyomiTheme { + TachiyomiPreviewTheme { Surface { TrackStatusSelector( selection = 1, diff --git a/app/src/main/java/eu/kanade/presentation/track/anime/AnimeTrackInfoDialogHome.kt b/app/src/main/java/eu/kanade/presentation/track/anime/AnimeTrackInfoDialogHome.kt index 35dfe4818..3a9fffce5 100644 --- a/app/src/main/java/eu/kanade/presentation/track/anime/AnimeTrackInfoDialogHome.kt +++ b/app/src/main/java/eu/kanade/presentation/track/anime/AnimeTrackInfoDialogHome.kt @@ -34,7 +34,7 @@ import androidx.compose.ui.tooling.preview.PreviewLightDark import androidx.compose.ui.tooling.preview.PreviewParameter import androidx.compose.ui.unit.dp import dev.icerock.moko.resources.StringResource -import eu.kanade.presentation.theme.TachiyomiTheme +import eu.kanade.presentation.theme.TachiyomiPreviewTheme import eu.kanade.presentation.track.components.TrackLogoIcon import eu.kanade.presentation.track.manga.TrackDetailsItem import eu.kanade.presentation.track.manga.TrackInfoItemMenu @@ -255,5 +255,5 @@ private fun TrackInfoDialogHomePreviews( @PreviewParameter(AnimeTrackInfoDialogHomePreviewProvider::class) content: @Composable () -> Unit, ) { - TachiyomiTheme { content() } + TachiyomiPreviewTheme { content() } } diff --git a/app/src/main/java/eu/kanade/presentation/track/anime/AnimeTrackerSearch.kt b/app/src/main/java/eu/kanade/presentation/track/anime/AnimeTrackerSearch.kt index 912f6c2f9..a932c78f1 100644 --- a/app/src/main/java/eu/kanade/presentation/track/anime/AnimeTrackerSearch.kt +++ b/app/src/main/java/eu/kanade/presentation/track/anime/AnimeTrackerSearch.kt @@ -69,7 +69,7 @@ import androidx.compose.ui.tooling.preview.PreviewParameter import androidx.compose.ui.unit.dp import eu.kanade.presentation.components.DropdownMenu import eu.kanade.presentation.entries.components.ItemCover -import eu.kanade.presentation.theme.TachiyomiTheme +import eu.kanade.presentation.theme.TachiyomiPreviewTheme import eu.kanade.tachiyomi.data.track.model.AnimeTrackSearch import eu.kanade.tachiyomi.util.system.openInBrowser import tachiyomi.i18n.MR @@ -383,7 +383,7 @@ private fun TrackerSearchPreviews( @PreviewParameter(AnimeTrackerSearchPreviewProvider::class) content: @Composable () -> Unit, ) { - TachiyomiTheme { + TachiyomiPreviewTheme { Surface { content() } diff --git a/app/src/main/java/eu/kanade/presentation/track/components/TrackLogoIcon.kt b/app/src/main/java/eu/kanade/presentation/track/components/TrackLogoIcon.kt index 835cce95c..4dd03ecc7 100644 --- a/app/src/main/java/eu/kanade/presentation/track/components/TrackLogoIcon.kt +++ b/app/src/main/java/eu/kanade/presentation/track/components/TrackLogoIcon.kt @@ -14,7 +14,7 @@ import androidx.compose.ui.res.painterResource import androidx.compose.ui.tooling.preview.PreviewLightDark import androidx.compose.ui.tooling.preview.PreviewParameter import androidx.compose.ui.unit.dp -import eu.kanade.presentation.theme.TachiyomiTheme +import eu.kanade.presentation.theme.TachiyomiPreviewTheme import eu.kanade.tachiyomi.data.track.Tracker import tachiyomi.presentation.core.util.clickableNoIndication @@ -49,7 +49,7 @@ private fun TrackLogoIconPreviews( @PreviewParameter(TrackLogoIconPreviewProvider::class) tracker: Tracker, ) { - TachiyomiTheme { + TachiyomiPreviewTheme { TrackLogoIcon( tracker = tracker, onClick = null, diff --git a/app/src/main/java/eu/kanade/presentation/track/manga/MangaTrackInfoDialogHome.kt b/app/src/main/java/eu/kanade/presentation/track/manga/MangaTrackInfoDialogHome.kt index 7dfa77098..6993dabb2 100644 --- a/app/src/main/java/eu/kanade/presentation/track/manga/MangaTrackInfoDialogHome.kt +++ b/app/src/main/java/eu/kanade/presentation/track/manga/MangaTrackInfoDialogHome.kt @@ -47,7 +47,7 @@ import androidx.compose.ui.tooling.preview.PreviewParameter import androidx.compose.ui.unit.dp import dev.icerock.moko.resources.StringResource import eu.kanade.presentation.components.DropdownMenu -import eu.kanade.presentation.theme.TachiyomiTheme +import eu.kanade.presentation.theme.TachiyomiPreviewTheme import eu.kanade.presentation.track.components.TrackLogoIcon import eu.kanade.tachiyomi.data.track.Tracker import eu.kanade.tachiyomi.ui.entries.manga.track.MangaTrackItem @@ -326,5 +326,5 @@ private fun TrackInfoDialogHomePreviews( @PreviewParameter(MangaTrackInfoDialogHomePreviewProvider::class) content: @Composable () -> Unit, ) { - TachiyomiTheme { content() } + TachiyomiPreviewTheme { content() } } diff --git a/app/src/main/java/eu/kanade/presentation/track/manga/MangaTrackerSearch.kt b/app/src/main/java/eu/kanade/presentation/track/manga/MangaTrackerSearch.kt index da73695b5..69d8631a5 100644 --- a/app/src/main/java/eu/kanade/presentation/track/manga/MangaTrackerSearch.kt +++ b/app/src/main/java/eu/kanade/presentation/track/manga/MangaTrackerSearch.kt @@ -69,7 +69,7 @@ import androidx.compose.ui.tooling.preview.PreviewParameter import androidx.compose.ui.unit.dp import eu.kanade.presentation.components.DropdownMenu import eu.kanade.presentation.entries.components.ItemCover -import eu.kanade.presentation.theme.TachiyomiTheme +import eu.kanade.presentation.theme.TachiyomiPreviewTheme import eu.kanade.tachiyomi.data.track.model.MangaTrackSearch import eu.kanade.tachiyomi.util.system.openInBrowser import tachiyomi.i18n.MR @@ -383,7 +383,7 @@ private fun TrackerSearchPreviews( @PreviewParameter(MangaTrackerSearchPreviewProvider::class) content: @Composable () -> Unit, ) { - TachiyomiTheme { + TachiyomiPreviewTheme { Surface { content() } diff --git a/app/src/main/java/eu/kanade/tachiyomi/data/backup/restore/restorers/AnimeRestorer.kt b/app/src/main/java/eu/kanade/tachiyomi/data/backup/restore/restorers/AnimeRestorer.kt index 9dac081ee..aa88fdb8d 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/data/backup/restore/restorers/AnimeRestorer.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/data/backup/restore/restorers/AnimeRestorer.kt @@ -57,22 +57,24 @@ class AnimeRestorer( backupAnime: BackupAnime, backupCategories: List, ) { - val dbAnime = findExistingAnime(backupAnime) - val anime = backupAnime.getAnimeImpl() - val restoredAnime = if (dbAnime == null) { - restoreNewAnime(anime) - } else { - restoreExistingAnime(anime, dbAnime) - } + handler.await(inTransaction = true) { + val dbAnime = findExistingAnime(backupAnime) + val anime = backupAnime.getAnimeImpl() + val restoredAnime = if (dbAnime == null) { + restoreNewAnime(anime) + } else { + restoreExistingAnime(anime, dbAnime) + } - restoreAnimeDetails( - anime = restoredAnime, - episodes = backupAnime.episodes, - categories = backupAnime.categories, - backupCategories = backupCategories, - history = backupAnime.history + backupAnime.brokenHistory.map { it.toBackupHistory() }, - tracks = backupAnime.tracking, - ) + restoreAnimeDetails( + anime = restoredAnime, + episodes = backupAnime.episodes, + categories = backupAnime.categories, + backupCategories = backupCategories, + history = backupAnime.history + backupAnime.brokenHistory.map { it.toBackupHistory() }, + tracks = backupAnime.tracking, + ) + } } private suspend fun findExistingAnime(backupAnime: BackupAnime): Anime? { diff --git a/app/src/main/java/eu/kanade/tachiyomi/data/backup/restore/restorers/MangaRestorer.kt b/app/src/main/java/eu/kanade/tachiyomi/data/backup/restore/restorers/MangaRestorer.kt index 2932ba050..03f7875b1 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/data/backup/restore/restorers/MangaRestorer.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/data/backup/restore/restorers/MangaRestorer.kt @@ -57,22 +57,24 @@ class MangaRestorer( backupManga: BackupManga, backupCategories: List, ) { - val dbManga = findExistingManga(backupManga) - val manga = backupManga.getMangaImpl() - val restoredManga = if (dbManga == null) { - restoreNewManga(manga) - } else { - restoreExistingManga(manga, dbManga) - } + handler.await(inTransaction = true) { + val dbManga = findExistingManga(backupManga) + val manga = backupManga.getMangaImpl() + val restoredManga = if (dbManga == null) { + restoreNewManga(manga) + } else { + restoreExistingManga(manga, dbManga) + } - restoreMangaDetails( - manga = restoredManga, - chapters = backupManga.chapters, - categories = backupManga.categories, - backupCategories = backupCategories, - history = backupManga.history + backupManga.brokenHistory.map { it.toBackupHistory() }, - tracks = backupManga.tracking, - ) + restoreMangaDetails( + manga = restoredManga, + chapters = backupManga.chapters, + categories = backupManga.categories, + backupCategories = backupCategories, + history = backupManga.history + backupManga.brokenHistory.map { it.toBackupHistory() }, + tracks = backupManga.tracking, + ) + } } private suspend fun findExistingManga(backupManga: BackupManga): Manga? { diff --git a/app/src/main/java/eu/kanade/tachiyomi/data/download/anime/AnimeDownloadCache.kt b/app/src/main/java/eu/kanade/tachiyomi/data/download/anime/AnimeDownloadCache.kt index 176099cd6..b40686e78 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/data/download/anime/AnimeDownloadCache.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/data/download/anime/AnimeDownloadCache.kt @@ -94,12 +94,15 @@ class AnimeDownloadCache( scope.launch { rootDownloadsDirLock.withLock { try { - val diskCache = diskCacheFile.inputStream().use { - ProtoBuf.decodeFromByteArray(it.readBytes()) + if (diskCacheFile.exists()) { + val diskCache = diskCacheFile.inputStream().use { + ProtoBuf.decodeFromByteArray(it.readBytes()) + } + rootDownloadsDir = diskCache + lastRenew = System.currentTimeMillis() } - rootDownloadsDir = diskCache - lastRenew = System.currentTimeMillis() } catch (e: Throwable) { + logcat(LogPriority.ERROR, e) { "Failed to initialize disk cache" } diskCacheFile.delete() } } diff --git a/app/src/main/java/eu/kanade/tachiyomi/data/download/manga/MangaDownloadCache.kt b/app/src/main/java/eu/kanade/tachiyomi/data/download/manga/MangaDownloadCache.kt index ecf28e5a0..54cece8bb 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/data/download/manga/MangaDownloadCache.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/data/download/manga/MangaDownloadCache.kt @@ -105,12 +105,15 @@ class MangaDownloadCache( scope.launch { rootDownloadsDirLock.withLock { try { - val diskCache = diskCacheFile.inputStream().use { - ProtoBuf.decodeFromByteArray(it.readBytes()) + if (diskCacheFile.exists()) { + val diskCache = diskCacheFile.inputStream().use { + ProtoBuf.decodeFromByteArray(it.readBytes()) + } + rootDownloadsDir = diskCache + lastRenew = System.currentTimeMillis() } - rootDownloadsDir = diskCache - lastRenew = System.currentTimeMillis() } catch (e: Throwable) { + logcat(LogPriority.ERROR, e) { "Failed to initialize disk cache" } diskCacheFile.delete() } } diff --git a/app/src/main/java/eu/kanade/tachiyomi/extension/anime/api/AnimeExtensionApi.kt b/app/src/main/java/eu/kanade/tachiyomi/extension/anime/api/AnimeExtensionApi.kt index e920d52a7..54a2080b3 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/extension/anime/api/AnimeExtensionApi.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/extension/anime/api/AnimeExtensionApi.kt @@ -37,18 +37,10 @@ internal class AnimeExtensionApi { suspend fun findExtensions(): List { return withIOContext { - val extensions = buildList { + buildList { addAll(getExtensions(OFFICIAL_ANIYOMI_REPO_BASE_URL)) sourcePreferences.animeExtensionRepos().get().map { addAll(getExtensions(it)) } } - - // Sanity check - a small number of extensions probably means something broke - // with the repo generator - if (extensions.size < 50) { - throw Exception() - } - - extensions } } diff --git a/app/src/main/java/eu/kanade/tachiyomi/extension/manga/api/MangaExtensionApi.kt b/app/src/main/java/eu/kanade/tachiyomi/extension/manga/api/MangaExtensionApi.kt index c734466eb..8e888a1d9 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/extension/manga/api/MangaExtensionApi.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/extension/manga/api/MangaExtensionApi.kt @@ -36,15 +36,7 @@ internal class MangaExtensionApi { suspend fun findExtensions(): List { return withIOContext { - val extensions = sourcePreferences.mangaExtensionRepos().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.mangaExtensionRepos().get().flatMap { getExtensions(it) } } } diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/browse/anime/extension/AnimeExtensionsTab.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/browse/anime/extension/AnimeExtensionsTab.kt index 27aeffe11..ac0eaabb2 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/browse/anime/extension/AnimeExtensionsTab.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/browse/anime/extension/AnimeExtensionsTab.kt @@ -1,7 +1,5 @@ package eu.kanade.tachiyomi.ui.browse.anime.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.anime.AnimeExtensionScreen import eu.kanade.presentation.components.AppBar import eu.kanade.presentation.components.TabContent +import eu.kanade.presentation.more.settings.screen.browse.AnimeExtensionReposScreen import eu.kanade.tachiyomi.extension.anime.model.AnimeExtension import eu.kanade.tachiyomi.ui.browse.anime.extension.details.AnimeExtensionDetailsScreen import eu.kanade.tachiyomi.ui.webview.WebViewScreen @@ -29,15 +28,18 @@ fun animeExtensionsTab( 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( - eu.kanade.tachiyomi.ui.browse.anime.extension.AnimeExtensionFilterScreen(), + AnimeExtensionFilterScreen(), ) }, ), + AppBar.OverflowAction( + title = stringResource(MR.strings.label_extension_repos), + onClick = { navigator.push(AnimeExtensionReposScreen()) }, + ), ), content = { contentPadding, _ -> AnimeExtensionScreen( diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/browse/manga/extension/MangaExtensionsTab.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/browse/manga/extension/MangaExtensionsTab.kt index 1371d2b0f..df6539353 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/browse/manga/extension/MangaExtensionsTab.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/browse/manga/extension/MangaExtensionsTab.kt @@ -1,7 +1,5 @@ package eu.kanade.tachiyomi.ui.browse.manga.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.manga.MangaExtensionScreen import eu.kanade.presentation.components.AppBar import eu.kanade.presentation.components.TabContent +import eu.kanade.presentation.more.settings.screen.browse.MangaExtensionReposScreen import eu.kanade.tachiyomi.extension.manga.model.MangaExtension import eu.kanade.tachiyomi.ui.browse.manga.extension.details.MangaExtensionDetailsScreen import eu.kanade.tachiyomi.ui.webview.WebViewScreen @@ -29,11 +28,14 @@ fun mangaExtensionsTab( 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(MangaExtensionFilterScreen()) }, ), + AppBar.OverflowAction( + title = stringResource(MR.strings.label_extension_repos), + onClick = { navigator.push(MangaExtensionReposScreen()) }, + ), ), content = { contentPadding, _ -> MangaExtensionScreen( diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/reader/viewer/pager/PagerViewer.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/reader/viewer/pager/PagerViewer.kt index ef4b8b323..284da5966 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/reader/viewer/pager/PagerViewer.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/reader/viewer/pager/PagerViewer.kt @@ -102,7 +102,14 @@ abstract class PagerViewer(val activity: ReaderActivity) : Viewer { }, ) pager.tapListener = { event -> - val pos = PointF(event.x / pager.width, event.y / pager.height) + val viewPosition = IntArray(2) + pager.getLocationOnScreen(viewPosition) + val viewPositionRelativeToWindow = IntArray(2) + pager.getLocationInWindow(viewPositionRelativeToWindow) + val pos = PointF( + (event.rawX - viewPosition[0] + viewPositionRelativeToWindow[0]) / pager.width, + (event.rawY - viewPosition[1] + viewPositionRelativeToWindow[1]) / pager.height, + ) when (config.navigator.getAction(pos)) { NavigationRegion.MENU -> activity.toggleMenu() NavigationRegion.NEXT -> moveToNext() diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/reader/viewer/webtoon/WebtoonViewer.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/reader/viewer/webtoon/WebtoonViewer.kt index 12dc201e8..9737f22df 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/reader/viewer/webtoon/WebtoonViewer.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/reader/viewer/webtoon/WebtoonViewer.kt @@ -111,7 +111,14 @@ class WebtoonViewer(val activity: ReaderActivity, val isContinuous: Boolean = tr }, ) recycler.tapListener = { event -> - val pos = PointF(event.y / recycler.width, event.y / recycler.height) + val viewPosition = IntArray(2) + recycler.getLocationOnScreen(viewPosition) + val viewPositionRelativeToWindow = IntArray(2) + recycler.getLocationInWindow(viewPositionRelativeToWindow) + val pos = PointF( + (event.rawX - viewPosition[0] + viewPositionRelativeToWindow[0]) / recycler.width, + (event.rawY - viewPosition[1] + viewPositionRelativeToWindow[1]) / recycler.height, + ) when (config.navigator.getAction(pos)) { NavigationRegion.MENU -> activity.toggleMenu() NavigationRegion.NEXT, NavigationRegion.RIGHT -> scrollDown() diff --git a/core/src/main/java/eu/kanade/tachiyomi/network/NetworkHelper.kt b/core/src/main/java/eu/kanade/tachiyomi/network/NetworkHelper.kt index 1c270269f..1ad5dabcb 100644 --- a/core/src/main/java/eu/kanade/tachiyomi/network/NetworkHelper.kt +++ b/core/src/main/java/eu/kanade/tachiyomi/network/NetworkHelper.kt @@ -2,6 +2,7 @@ package eu.kanade.tachiyomi.network import android.content.Context import eu.kanade.tachiyomi.network.interceptor.CloudflareInterceptor +import eu.kanade.tachiyomi.network.interceptor.IgnoreGzipInterceptor import eu.kanade.tachiyomi.network.interceptor.UncaughtExceptionInterceptor import eu.kanade.tachiyomi.network.interceptor.UserAgentInterceptor import okhttp3.Cache @@ -30,9 +31,10 @@ class NetworkHelper( maxSize = 5L * 1024 * 1024, // 5 MiB ), ) - .addInterceptor(BrotliInterceptor) .addInterceptor(UncaughtExceptionInterceptor()) .addInterceptor(UserAgentInterceptor(::defaultUserAgentProvider)) + .addNetworkInterceptor(IgnoreGzipInterceptor()) + .addNetworkInterceptor(BrotliInterceptor) if (preferences.verboseLogging().get()) { val httpLoggingInterceptor = HttpLoggingInterceptor().apply { diff --git a/core/src/main/java/eu/kanade/tachiyomi/network/interceptor/IgnoreGzipInterceptor.kt b/core/src/main/java/eu/kanade/tachiyomi/network/interceptor/IgnoreGzipInterceptor.kt new file mode 100644 index 000000000..f1331a576 --- /dev/null +++ b/core/src/main/java/eu/kanade/tachiyomi/network/interceptor/IgnoreGzipInterceptor.kt @@ -0,0 +1,21 @@ +package eu.kanade.tachiyomi.network.interceptor + +import okhttp3.Interceptor +import okhttp3.Response + +/** + * To use [okhttp3.brotli.BrotliInterceptor] as a network interceptor, + * add [IgnoreGzipInterceptor] right before it. + * + * This nullifies the transparent gzip of [okhttp3.internal.http.BridgeInterceptor] + * so gzip and Brotli are explicitly handled by the [okhttp3.brotli.BrotliInterceptor]. + */ +class IgnoreGzipInterceptor : Interceptor { + override fun intercept(chain: Interceptor.Chain): Response { + var request = chain.request() + if (request.header("Accept-Encoding") == "gzip") { + request = request.newBuilder().removeHeader("Accept-Encoding").build() + } + return chain.proceed(request) + } +} diff --git a/gradle/compose.versions.toml b/gradle/compose.versions.toml index 0503a9e8d..3fa4daa3f 100644 --- a/gradle/compose.versions.toml +++ b/gradle/compose.versions.toml @@ -1,5 +1,5 @@ [versions] -compiler = "1.5.7" +compiler = "1.5.8" compose-bom = "2023.12.00-alpha04" accompanist = "0.33.2-alpha" diff --git a/gradle/kotlinx.versions.toml b/gradle/kotlinx.versions.toml index 924590cd7..114c2a35a 100644 --- a/gradle/kotlinx.versions.toml +++ b/gradle/kotlinx.versions.toml @@ -1,5 +1,5 @@ [versions] -kotlin_version = "1.9.21" +kotlin_version = "1.9.22" serialization_version = "1.6.2" xml_serialization_version = "0.86.3" diff --git a/i18n/src/commonMain/resources/MR/bg/strings.xml b/i18n/src/commonMain/resources/MR/bg/strings.xml index c18c66f92..c749e82e5 100644 --- a/i18n/src/commonMain/resources/MR/bg/strings.xml +++ b/i18n/src/commonMain/resources/MR/bg/strings.xml @@ -316,7 +316,7 @@ Възстановяването неуспешно Възстановяването е в процес Съхраняването неуспешно - Копието вече се запазва + Архивирането вече е в ход %02d мин, %02d сек Странично разстояние Четене @@ -331,7 +331,7 @@ Никога Винаги Заключи при неактивност - Изисквай отключване + Изискване на отключване Сигурност Уведомления Система на абонаментите diff --git a/i18n/src/commonMain/resources/MR/eo/plurals.xml b/i18n/src/commonMain/resources/MR/eo/plurals.xml index 3512d105e..e5d077a71 100644 --- a/i18n/src/commonMain/resources/MR/eo/plurals.xml +++ b/i18n/src/commonMain/resources/MR/eo/plurals.xml @@ -9,7 +9,7 @@ %d kategorioj - 1 ĉapitro + %1$s ĉapitro %1$s ĉapitroj @@ -33,7 +33,7 @@ %d ŝanĝspuriloj - 1 restas + %1$s restas %1$s restas @@ -68,4 +68,20 @@ + + 1 tago + %d tagoj + + + Sekva ĉapitro + Sekvaj %d ĉapitroj + + + Mankas %1$s ĉapitro + Mankas %1$s ĉapitroj + + + Sekva nelegita ĉapitro + Sekvaj %d nelegitaj ĉapitroj + \ No newline at end of file diff --git a/i18n/src/commonMain/resources/MR/eo/strings.xml b/i18n/src/commonMain/resources/MR/eo/strings.xml index 9d3009097..81d2eeb7e 100644 --- a/i18n/src/commonMain/resources/MR/eo/strings.xml +++ b/i18n/src/commonMain/resources/MR/eo/strings.xml @@ -7,13 +7,13 @@ Agordoj Pli Nomo - Neniuj ĝisdatigoj + Neniuj lastatempaj ĝisdatigoj Neniu elŝuto Asistado - Konektprogramaro Informaĵo + Informoj de aldonaĵo Aldonaĵoj Migri - Arkivi kaj restaŭri + Savkopii kaj restaŭri Retejo Uzantnomo Pasvorto @@ -51,7 +51,7 @@ Biblioteka kontribuoj Kategorioj Via biblioteko malplenas - Neniu legita laste + Neniu legita lastatempe Kaŝi enhavon de sciigoj Neniam Ĉiam @@ -345,7 +345,7 @@ Laŭ elŝuta dato Elekti inverse Defaŭlte - Vi havas neniun kategorion. Tuŝeti la butonon kun plus por krei unu por organizi vian bibliotekon. + Vi havas neniun kategorion. Tuŝeti la butonon kun plus, por krei unu kaj organizi vian bibliotekon. Kromaĵaj ĝisdatigoj Elŝutilo Por ĉi-serion diff --git a/i18n/src/commonMain/resources/MR/it/strings.xml b/i18n/src/commonMain/resources/MR/it/strings.xml index 04e720232..8c7a566bb 100644 --- a/i18n/src/commonMain/resources/MR/it/strings.xml +++ b/i18n/src/commonMain/resources/MR/it/strings.xml @@ -680,7 +680,7 @@ Fuori dal periodo di rilascio previsto Intervalli Stima ogni - Intervallo di recupero personalizzato + Intervallo di aggiornamento personalizzato Prossimo aggiornamento previsto Imposta l\'aggiornamento ogni Saltato perché oggi non era previsto alcun rilascio diff --git a/i18n/src/commonMain/resources/MR/ja/plurals.xml b/i18n/src/commonMain/resources/MR/ja/plurals.xml index 6f580782e..2e250027a 100644 --- a/i18n/src/commonMain/resources/MR/ja/plurals.xml +++ b/i18n/src/commonMain/resources/MR/ja/plurals.xml @@ -45,4 +45,7 @@ %d日 + + %dリポジトリ + \ No newline at end of file diff --git a/i18n/src/commonMain/resources/MR/ms/plurals.xml b/i18n/src/commonMain/resources/MR/ms/plurals.xml index 59560ccea..2883523c2 100644 --- a/i18n/src/commonMain/resources/MR/ms/plurals.xml +++ b/i18n/src/commonMain/resources/MR/ms/plurals.xml @@ -45,4 +45,7 @@ %d hari + + %d repositori + \ No newline at end of file diff --git a/i18n/src/commonMain/resources/MR/pt/strings.xml b/i18n/src/commonMain/resources/MR/pt/strings.xml index 32cb1eb88..2c860e84f 100644 --- a/i18n/src/commonMain/resources/MR/pt/strings.xml +++ b/i18n/src/commonMain/resources/MR/pt/strings.xml @@ -683,11 +683,11 @@ Próxima atualização esperada Definido para atualizar a cada Pulado, pois nenhum lançamento é esperado para hoje - Deletar dowloand + Apagar download Selecionado Não selecionado Mais opções - Rolar para cima + Navegar para cima Desbloquear %s Dados e armazenamento Categorias de Mangá diff --git a/i18n/src/commonMain/resources/MR/ru/strings.xml b/i18n/src/commonMain/resources/MR/ru/strings.xml index 3a6a25e94..4cccb03eb 100644 --- a/i18n/src/commonMain/resources/MR/ru/strings.xml +++ b/i18n/src/commonMain/resources/MR/ru/strings.xml @@ -533,7 +533,7 @@ Не удалось получить доступные расширения Политика конфиденциальности Пропускать серии с непрочитанными главами - Для помощи в исправлении ошибок библиотеки нажать %1$s + Для помощи в исправлении ошибок библиотеки, нажмите %1$s Сохранить как архив CBZ Отменено Перерыв diff --git a/i18n/src/commonMain/resources/MR/te/strings.xml b/i18n/src/commonMain/resources/MR/te/strings.xml index eeeba4b54..667c73ca4 100644 --- a/i18n/src/commonMain/resources/MR/te/strings.xml +++ b/i18n/src/commonMain/resources/MR/te/strings.xml @@ -160,7 +160,7 @@ సిరీస్ పైన పెట్టండి అన్వేషించండి… ఇప్పుడు కాదు - "ఏదైనా తెరవండి" + ఏదైనా తెరవండి అంతర్గత లోపం: మరింత సమాచారం కోసం క్రాష్ లాగ్‌లను తనిఖీ చేయండి థీమ్, తేదీ మరియు సమయ ఆకృతి లోపాలూ