diff --git a/app/src/main/java/eu/kanade/presentation/components/RelativeDateHeader.kt b/app/src/main/java/eu/kanade/presentation/components/RelativeDateHeader.kt index 1a7683293..89bb61b4f 100644 --- a/app/src/main/java/eu/kanade/presentation/components/RelativeDateHeader.kt +++ b/app/src/main/java/eu/kanade/presentation/components/RelativeDateHeader.kt @@ -13,18 +13,13 @@ import java.util.Date fun RelativeDateHeader( modifier: Modifier = Modifier, date: Date, - relativeTime: Int, dateFormat: DateFormat, ) { val context = LocalContext.current ListGroupHeader( modifier = modifier, text = remember { - date.toRelativeString( - context, - relativeTime, - dateFormat, - ) + date.toRelativeString(context, dateFormat) }, ) } diff --git a/app/src/main/java/eu/kanade/presentation/history/HistoryScreen.kt b/app/src/main/java/eu/kanade/presentation/history/HistoryScreen.kt index 3cd5be4f0..1a80c8f01 100644 --- a/app/src/main/java/eu/kanade/presentation/history/HistoryScreen.kt +++ b/app/src/main/java/eu/kanade/presentation/history/HistoryScreen.kt @@ -98,7 +98,6 @@ private fun HistoryScreenContent( onClickDelete: (HistoryWithRelations) -> Unit, preferences: UiPreferences = Injekt.get(), ) { - val relativeTime: Int = remember { preferences.relativeTime().get() } val dateFormat: DateFormat = remember { UiPreferences.dateFormat(preferences.dateFormat().get()) } FastScrollLazyColumn( @@ -119,7 +118,6 @@ private fun HistoryScreenContent( RelativeDateHeader( modifier = Modifier.animateItemPlacement(), date = item.date, - relativeTime = relativeTime, dateFormat = dateFormat, ) } diff --git a/app/src/main/java/eu/kanade/presentation/manga/MangaScreen.kt b/app/src/main/java/eu/kanade/presentation/manga/MangaScreen.kt index fe906c8fd..5fe018d80 100644 --- a/app/src/main/java/eu/kanade/presentation/manga/MangaScreen.kt +++ b/app/src/main/java/eu/kanade/presentation/manga/MangaScreen.kt @@ -84,7 +84,6 @@ import java.util.Date fun MangaScreen( state: MangaScreenModel.State.Success, snackbarHostState: SnackbarHostState, - dateRelativeTime: Int, intervalDisplay: () -> Pair?, dateFormat: DateFormat, isTabletUi: Boolean, @@ -141,7 +140,6 @@ fun MangaScreen( MangaScreenSmallImpl( state = state, snackbarHostState = snackbarHostState, - dateRelativeTime = dateRelativeTime, dateFormat = dateFormat, intervalDisplay = intervalDisplay, chapterSwipeStartAction = chapterSwipeStartAction, @@ -178,7 +176,6 @@ fun MangaScreen( MangaScreenLargeImpl( state = state, snackbarHostState = snackbarHostState, - dateRelativeTime = dateRelativeTime, chapterSwipeStartAction = chapterSwipeStartAction, chapterSwipeEndAction = chapterSwipeEndAction, dateFormat = dateFormat, @@ -218,7 +215,6 @@ fun MangaScreen( private fun MangaScreenSmallImpl( state: MangaScreenModel.State.Success, snackbarHostState: SnackbarHostState, - dateRelativeTime: Int, dateFormat: DateFormat, intervalDisplay: () -> Pair?, chapterSwipeStartAction: LibraryPreferences.ChapterSwipeAction, @@ -287,9 +283,11 @@ private fun MangaScreenSmallImpl( } val animatedTitleAlpha by animateFloatAsState( if (firstVisibleItemIndex > 0) 1f else 0f, + label = "titleAlpha", ) val animatedBgAlpha by animateFloatAsState( if (firstVisibleItemIndex > 0 || firstVisibleItemScrollOffset > 0) 1f else 0f, + label = "bgAlpha", ) MangaToolbar( title = state.manga.title, @@ -430,7 +428,6 @@ private fun MangaScreenSmallImpl( sharedChapterItems( manga = state.manga, chapters = chapters, - dateRelativeTime = dateRelativeTime, dateFormat = dateFormat, chapterSwipeStartAction = chapterSwipeStartAction, chapterSwipeEndAction = chapterSwipeEndAction, @@ -449,7 +446,6 @@ private fun MangaScreenSmallImpl( fun MangaScreenLargeImpl( state: MangaScreenModel.State.Success, snackbarHostState: SnackbarHostState, - dateRelativeTime: Int, dateFormat: DateFormat, intervalDisplay: () -> Pair?, chapterSwipeStartAction: LibraryPreferences.ChapterSwipeAction, @@ -655,7 +651,6 @@ fun MangaScreenLargeImpl( sharedChapterItems( manga = state.manga, chapters = chapters, - dateRelativeTime = dateRelativeTime, dateFormat = dateFormat, chapterSwipeStartAction = chapterSwipeStartAction, chapterSwipeEndAction = chapterSwipeEndAction, @@ -717,7 +712,6 @@ private fun SharedMangaBottomActionMenu( private fun LazyListScope.sharedChapterItems( manga: Manga, chapters: List, - dateRelativeTime: Int, dateFormat: DateFormat, chapterSwipeStartAction: LibraryPreferences.ChapterSwipeAction, chapterSwipeEndAction: LibraryPreferences.ChapterSwipeAction, @@ -746,11 +740,7 @@ private fun LazyListScope.sharedChapterItems( date = chapterItem.chapter.dateUpload .takeIf { it > 0L } ?.let { - Date(it).toRelativeString( - context, - dateRelativeTime, - dateFormat, - ) + Date(it).toRelativeString(context, dateFormat) }, readProgress = chapterItem.chapter.lastPageRead .takeIf { !chapterItem.chapter.read && it > 0L } diff --git a/app/src/main/java/eu/kanade/presentation/more/settings/screen/SettingsAppearanceScreen.kt b/app/src/main/java/eu/kanade/presentation/more/settings/screen/SettingsAppearanceScreen.kt index cd2a53904..d98198155 100644 --- a/app/src/main/java/eu/kanade/presentation/more/settings/screen/SettingsAppearanceScreen.kt +++ b/app/src/main/java/eu/kanade/presentation/more/settings/screen/SettingsAppearanceScreen.kt @@ -162,15 +162,6 @@ object SettingsAppearanceScreen : SearchableSettings { "${it.ifEmpty { stringResource(R.string.label_default) }} ($formattedDate)" }, ), - Preference.PreferenceItem.ListPreference( - pref = uiPreferences.relativeTime(), - title = stringResource(R.string.pref_relative_format), - entries = mapOf( - 0 to stringResource(R.string.off), - 2 to stringResource(R.string.pref_relative_time_short), - 7 to stringResource(R.string.pref_relative_time_long), - ), - ), ), ) } diff --git a/app/src/main/java/eu/kanade/presentation/updates/UpdatesScreen.kt b/app/src/main/java/eu/kanade/presentation/updates/UpdatesScreen.kt index a896e8d58..dbb5e3305 100644 --- a/app/src/main/java/eu/kanade/presentation/updates/UpdatesScreen.kt +++ b/app/src/main/java/eu/kanade/presentation/updates/UpdatesScreen.kt @@ -43,7 +43,6 @@ fun UpdateScreen( state: UpdatesScreenModel.State, snackbarHostState: SnackbarHostState, lastUpdated: Long, - relativeTime: Int, onClickCover: (UpdatesItem) -> Unit, onSelectAll: (Boolean) -> Unit, onInvertSelection: () -> Unit, @@ -114,7 +113,7 @@ fun UpdateScreen( } updatesUiItems( - uiModels = state.getUiModel(context, relativeTime), + uiModels = state.getUiModel(context), selectionMode = state.selectionMode, onUpdateSelected = onUpdateSelected, onClickCover = onClickCover, 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 87124b560..ac47fe112 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 @@ -99,7 +99,6 @@ class MangaScreen( MangaScreen( state = successState, snackbarHostState = screenModel.snackbarHostState, - dateRelativeTime = screenModel.relativeTime, dateFormat = screenModel.dateFormat, intervalDisplay = screenModel::intervalDisplay, isTabletUi = isTabletUi(), diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/manga/MangaScreenModel.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/manga/MangaScreenModel.kt index 69dfb4b23..ae7abe611 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/manga/MangaScreenModel.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/manga/MangaScreenModel.kt @@ -126,7 +126,6 @@ class MangaScreenModel( val chapterSwipeStartAction = libraryPreferences.swipeToEndAction().get() val chapterSwipeEndAction = libraryPreferences.swipeToStartAction().get() - val relativeTime by uiPreferences.relativeTime().asState(coroutineScope) val dateFormat by mutableStateOf(UiPreferences.dateFormat(uiPreferences.dateFormat().get())) private val skipFiltered by readerPreferences.skipFiltered().asState(coroutineScope) diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/updates/UpdatesScreenModel.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/updates/UpdatesScreenModel.kt index 5986aba47..212029fbd 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/updates/UpdatesScreenModel.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/updates/UpdatesScreenModel.kt @@ -59,14 +59,12 @@ class UpdatesScreenModel( private val getChapter: GetChapter = Injekt.get(), private val libraryPreferences: LibraryPreferences = Injekt.get(), val snackbarHostState: SnackbarHostState = SnackbarHostState(), - uiPreferences: UiPreferences = Injekt.get(), ) : StateScreenModel(State()) { private val _events: Channel = Channel(Int.MAX_VALUE) val events: Flow = _events.receiveAsFlow() val lastUpdated by libraryPreferences.libraryUpdateLastTimestamp().asState(coroutineScope) - val relativeTime by uiPreferences.relativeTime().asState(coroutineScope) // First and last selected index in list private val selectedPositions: Array = arrayOf(-1, -1) @@ -370,12 +368,12 @@ class UpdatesScreenModel( data class State( val isLoading: Boolean = true, val items: List = emptyList(), - val dialog: UpdatesScreenModel.Dialog? = null, + val dialog: Dialog? = null, ) { val selected = items.filter { it.selected } val selectionMode = selected.isNotEmpty() - fun getUiModel(context: Context, relativeTime: Int): List { + fun getUiModel(context: Context): List { val dateFormat by mutableStateOf(UiPreferences.dateFormat(Injekt.get().dateFormat().get())) return items @@ -385,11 +383,7 @@ class UpdatesScreenModel( val afterDate = after?.item?.update?.dateFetch?.toDateKey() ?: Date(0) when { beforeDate.time != afterDate.time && afterDate.time != 0L -> { - val text = afterDate.toRelativeString( - context = context, - range = relativeTime, - dateFormat = dateFormat, - ) + val text = afterDate.toRelativeString(context, dateFormat) UpdatesUiModel.Header(text) } // Return null to avoid adding a separator between two items. diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/updates/UpdatesTab.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/updates/UpdatesTab.kt index 78a44dd23..cf33f69c4 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/updates/UpdatesTab.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/updates/UpdatesTab.kt @@ -57,7 +57,6 @@ object UpdatesTab : Tab { state = state, snackbarHostState = screenModel.snackbarHostState, lastUpdated = screenModel.lastUpdated, - relativeTime = screenModel.relativeTime, onClickCover = { item -> navigator.push(MangaScreen(item.update.mangaId)) }, onSelectAll = screenModel::toggleAllSelection, onInvertSelection = screenModel::invertSelection, diff --git a/app/src/main/java/eu/kanade/tachiyomi/util/lang/DateExtensions.kt b/app/src/main/java/eu/kanade/tachiyomi/util/lang/DateExtensions.kt index c7c29561b..f0612506c 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/util/lang/DateExtensions.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/util/lang/DateExtensions.kt @@ -114,19 +114,15 @@ private const val MILLISECONDS_IN_DAY = 86_400_000L fun Date.toRelativeString( context: Context, - range: Int = 7, dateFormat: DateFormat = DateFormat.getDateInstance(DateFormat.SHORT), ): String { - if (range == 0) { - return dateFormat.format(this) - } val now = Date() val difference = now.timeWithOffset.floorNearest(MILLISECONDS_IN_DAY) - this.timeWithOffset.floorNearest(MILLISECONDS_IN_DAY) val days = difference.floorDiv(MILLISECONDS_IN_DAY).toInt() return when { difference < 0 -> context.getString(R.string.recently) difference < MILLISECONDS_IN_DAY -> context.getString(R.string.relative_time_today) - difference < MILLISECONDS_IN_DAY.times(range) -> context.resources.getQuantityString( + difference < MILLISECONDS_IN_DAY.times(7) -> context.resources.getQuantityString( R.plurals.relative_time, days, days, diff --git a/i18n/src/main/res/values/strings.xml b/i18n/src/main/res/values/strings.xml index feeee4a90..c3a296c1b 100644 --- a/i18n/src/main/res/values/strings.xml +++ b/i18n/src/main/res/values/strings.xml @@ -201,9 +201,6 @@ Yotsuba Tidal Wave Pure black dark mode - Relative timestamps - Short (Today, Yesterday) - Long (Short+, n days ago) Date format Manage notifications diff --git a/presentation-core/src/main/java/tachiyomi/presentation/core/components/AdaptiveSheet.kt b/presentation-core/src/main/java/tachiyomi/presentation/core/components/AdaptiveSheet.kt index 24ae1b48d..87e17416a 100644 --- a/presentation-core/src/main/java/tachiyomi/presentation/core/components/AdaptiveSheet.kt +++ b/presentation-core/src/main/java/tachiyomi/presentation/core/components/AdaptiveSheet.kt @@ -70,6 +70,7 @@ fun AdaptiveSheet( val alpha by animateFloatAsState( targetValue = targetAlpha, animationSpec = sheetAnimationSpec, + label = "alpha", ) val internalOnDismissRequest: () -> Unit = { scope.launch {