diff --git a/app/src/main/java/eu/kanade/presentation/components/DateText.kt b/app/src/main/java/eu/kanade/presentation/components/DateText.kt index c79cfac12..9fa8c85d1 100644 --- a/app/src/main/java/eu/kanade/presentation/components/DateText.kt +++ b/app/src/main/java/eu/kanade/presentation/components/DateText.kt @@ -13,9 +13,11 @@ import java.util.Date @Composable fun relativeDateText( - date: Long, + dateEpochMillis: Long, ): String { - return relativeDateText(date = Date(date).takeIf { date > 0L }) + return relativeDateText( + date = Date(dateEpochMillis).takeIf { dateEpochMillis > 0L }, + ) } @Composable @@ -30,9 +32,9 @@ fun relativeDateText( return date ?.toRelativeString( - context, - relativeTime, - dateFormat, + context = context, + relative = relativeTime, + dateFormat = dateFormat, ) ?: stringResource(MR.strings.not_applicable) } diff --git a/app/src/main/java/eu/kanade/presentation/manga/components/MangaDialogs.kt b/app/src/main/java/eu/kanade/presentation/manga/components/MangaDialogs.kt index 268928ebb..5d899c046 100644 --- a/app/src/main/java/eu/kanade/presentation/manga/components/MangaDialogs.kt +++ b/app/src/main/java/eu/kanade/presentation/manga/components/MangaDialogs.kt @@ -1,6 +1,7 @@ package eu.kanade.presentation.manga.components import androidx.compose.foundation.layout.BoxWithConstraints +import androidx.compose.foundation.layout.Column import androidx.compose.foundation.layout.fillMaxWidth import androidx.compose.material3.AlertDialog import androidx.compose.material3.Text @@ -8,6 +9,7 @@ import androidx.compose.material3.TextButton import androidx.compose.runtime.Composable import androidx.compose.runtime.getValue import androidx.compose.runtime.mutableIntStateOf +import androidx.compose.runtime.remember import androidx.compose.runtime.saveable.rememberSaveable import androidx.compose.runtime.setValue import androidx.compose.ui.Alignment @@ -18,7 +20,10 @@ import kotlinx.collections.immutable.toImmutableList import tachiyomi.domain.manga.interactor.FetchInterval import tachiyomi.i18n.MR import tachiyomi.presentation.core.components.WheelTextPicker +import tachiyomi.presentation.core.i18n.pluralStringResource import tachiyomi.presentation.core.i18n.stringResource +import java.time.Instant +import java.time.temporal.ChronoUnit @Composable fun DeleteChaptersDialog( @@ -54,35 +59,59 @@ fun DeleteChaptersDialog( @Composable fun SetIntervalDialog( interval: Int, + nextUpdate: Long, onDismissRequest: () -> Unit, onValueChanged: (Int) -> Unit, ) { var selectedInterval by rememberSaveable { mutableIntStateOf(if (interval < 0) -interval else 0) } + val nextUpdateDays = remember(nextUpdate) { + val now = Instant.now() + val nextUpdateInstant = Instant.ofEpochMilli(nextUpdate) + + now.until(nextUpdateInstant, ChronoUnit.DAYS) + } + AlertDialog( onDismissRequest = onDismissRequest, - title = { Text(text = stringResource(MR.strings.manga_modify_calculated_interval_title)) }, + title = { Text(stringResource(MR.strings.manga_modify_calculated_interval_title)) }, text = { - BoxWithConstraints( - modifier = Modifier.fillMaxWidth(), - contentAlignment = Alignment.Center, - ) { - val size = DpSize(width = maxWidth / 2, height = 128.dp) - val items = (0..FetchInterval.MAX_INTERVAL) - .map { - if (it == 0) { - stringResource(MR.strings.label_default) - } else { - it.toString() + Column { + // TODO: figure out why nextUpdate is a weird number sometimes + if (nextUpdateDays >= 0) { + Text( + stringResource( + MR.strings.manga_interval_expected_update, + pluralStringResource( + MR.plurals.day, + count = nextUpdateDays.toInt(), + nextUpdateDays, + ), + ), + ) + } + + BoxWithConstraints( + modifier = Modifier.fillMaxWidth(), + contentAlignment = Alignment.Center, + ) { + val size = DpSize(width = maxWidth / 2, height = 128.dp) + val items = (0..FetchInterval.MAX_INTERVAL) + .map { + if (it == 0) { + stringResource(MR.strings.label_default) + } else { + it.toString() + } } - } - .toImmutableList() - WheelTextPicker( - items = items, - size = size, - startIndex = selectedInterval, - onSelectionChanged = { selectedInterval = it }, - ) + .toImmutableList() + WheelTextPicker( + items = items, + size = size, + startIndex = selectedInterval, + onSelectionChanged = { selectedInterval = it }, + ) + } } }, dismissButton = { diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/manga/MangaScreen.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/manga/MangaScreen.kt index 1bb46d82e..f4c7c48b6 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/manga/MangaScreen.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/manga/MangaScreen.kt @@ -243,6 +243,7 @@ class MangaScreen( is MangaScreenModel.Dialog.SetFetchInterval -> { SetIntervalDialog( interval = dialog.manga.fetchInterval, + nextUpdate = dialog.manga.nextUpdate, onDismissRequest = onDismissRequest, onValueChanged = { screenModel.setFetchInterval(dialog.manga, it) }, ) diff --git a/i18n/src/commonMain/resources/MR/base/strings.xml b/i18n/src/commonMain/resources/MR/base/strings.xml index 0a91a88dd..cad687b24 100644 --- a/i18n/src/commonMain/resources/MR/base/strings.xml +++ b/i18n/src/commonMain/resources/MR/base/strings.xml @@ -669,6 +669,8 @@ Chapter %1$s Estimate every Set to update every + + Next update expected in around %s Customize interval Downloading (%1$d/%2$d) Error