mirror of
https://github.com/aniyomiorg/aniyomi.git
synced 2024-11-24 05:38:01 +03:00
Use separate string for toRelativeString "Today"
Apparently 0 quantity is ignored for some locales...
This commit is contained in:
parent
ae1a76da2b
commit
071bad1232
4 changed files with 7 additions and 6 deletions
|
@ -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
|
||||
|
|
|
@ -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() {
|
||||
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -187,10 +187,10 @@
|
|||
<string name="parental_controls_info">This does not prevent unofficial or potentially incorrectly flagged extensions from surfacing NSFW (18+) content within the app.</string>
|
||||
|
||||
<string name="recently">Recently</string>
|
||||
<string name="relative_time_today">Today</string>
|
||||
<plurals name="relative_time">
|
||||
<item quantity="zero">Today</item>
|
||||
<item quantity="one">Yesterday</item>
|
||||
<item quantity="other">%1$.0f days ago</item>
|
||||
<item quantity="other">%1$d days ago</item>
|
||||
</plurals>
|
||||
<string name="pref_relative_format">Relative timestamps</string>
|
||||
<string name="pref_relative_time_short">Short (Today, Yesterday)</string>
|
||||
|
|
Loading…
Reference in a new issue