From 071bad123208274a8d4858038b4073a0ce208aa3 Mon Sep 17 00:00:00 2001 From: arkon Date: Sun, 15 Aug 2021 17:42:31 -0400 Subject: [PATCH] Use separate string for toRelativeString "Today" Apparently 0 quantity is ignored for some locales... --- .../tachiyomi/ui/setting/SettingsAdvancedController.kt | 2 +- .../tachiyomi/ui/setting/SettingsGeneralController.kt | 1 - .../java/eu/kanade/tachiyomi/util/lang/DateExtensions.kt | 6 ++++-- app/src/main/res/values/strings.xml | 4 ++-- 4 files changed, 7 insertions(+), 6 deletions(-) diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/setting/SettingsAdvancedController.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/setting/SettingsAdvancedController.kt index a7b7839336..c6e6af932f 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/setting/SettingsAdvancedController.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/setting/SettingsAdvancedController.kt @@ -16,9 +16,9 @@ import eu.kanade.tachiyomi.data.database.DatabaseHelper import eu.kanade.tachiyomi.data.library.LibraryUpdateService import eu.kanade.tachiyomi.data.library.LibraryUpdateService.Target import eu.kanade.tachiyomi.network.NetworkHelper +import eu.kanade.tachiyomi.network.PREF_DOH_ADGUARD import eu.kanade.tachiyomi.network.PREF_DOH_CLOUDFLARE import eu.kanade.tachiyomi.network.PREF_DOH_GOOGLE -import eu.kanade.tachiyomi.network.PREF_DOH_ADGUARD import eu.kanade.tachiyomi.ui.base.controller.DialogController import eu.kanade.tachiyomi.ui.base.controller.openInBrowser import eu.kanade.tachiyomi.util.CrashLogUtil diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/setting/SettingsGeneralController.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/setting/SettingsGeneralController.kt index 47e8cead67..070bee9bcf 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/setting/SettingsGeneralController.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/setting/SettingsGeneralController.kt @@ -21,7 +21,6 @@ import kotlinx.coroutines.flow.launchIn import java.util.Date import eu.kanade.tachiyomi.data.preference.PreferenceKeys as Keys import eu.kanade.tachiyomi.data.preference.PreferenceValues as Values -import androidx.preference.Preference class SettingsGeneralController : SettingsController() { 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 f4614fcb94..046b5ef627 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 @@ -6,6 +6,7 @@ import java.text.DateFormat import java.util.Calendar import java.util.Date import java.util.TimeZone +import kotlin.math.floor fun Date.toDateTimestampString(dateFormatter: DateFormat): String { val date = dateFormatter.format(this) @@ -106,12 +107,13 @@ fun Date.toRelativeString( ): String { val now = Date() val difference = now.time - this.time - val days = difference / MILLISECONDS_IN_DAY + val days = floor(difference / 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( R.plurals.relative_time, - days.toInt(), + days, days ) else -> dateFormat.format(this) diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 3b3f8e86f5..cf179e108b 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -187,10 +187,10 @@ This does not prevent unofficial or potentially incorrectly flagged extensions from surfacing NSFW (18+) content within the app. Recently + Today - Today Yesterday - %1$.0f days ago + %1$d days ago Relative timestamps Short (Today, Yesterday)