Added new string to for mentioning times when the date time is at 0

This commit is contained in:
Jays2Kings 2021-04-13 14:53:35 -04:00
parent 5b840161e7
commit 3553013191
4 changed files with 19 additions and 7 deletions

View File

@ -146,7 +146,7 @@ class LibraryCategoryAdapter(val controller: LibraryController) :
if (last != null && last.last_read > 100) { if (last != null && last.last_read > 100) {
recyclerView.context.getString( recyclerView.context.getString(
R.string.read_, R.string.read_,
last.last_read.timeSpanFromNow last.last_read.timeSpanFromNow(preferences.context)
) )
} else { } else {
"N/A" "N/A"
@ -173,7 +173,7 @@ class LibraryCategoryAdapter(val controller: LibraryController) :
if (lastUpdate > 0) { if (lastUpdate > 0) {
recyclerView.context.getString( recyclerView.context.getString(
R.string.updated_, R.string.updated_,
lastUpdate.timeSpanFromNow lastUpdate.timeSpanFromNow(preferences.context)
) )
} else { } else {
"N/A" "N/A"
@ -182,7 +182,7 @@ class LibraryCategoryAdapter(val controller: LibraryController) :
LibrarySort.DATE_ADDED -> { LibrarySort.DATE_ADDED -> {
val added = item.manga.date_added val added = item.manga.date_added
if (added > 0) { if (added > 0) {
recyclerView.context.getString(R.string.added_, added.timeSpanFromNow) recyclerView.context.getString(R.string.added_, added.timeSpanFromNow(preferences.context))
} else { } else {
"N/A" "N/A"
} }

View File

@ -86,12 +86,12 @@ class RecentMangaHolder(
binding.body.text = when { binding.body.text = when {
item.mch.chapter.id == null -> binding.body.context.getString( item.mch.chapter.id == null -> binding.body.context.getString(
R.string.added_, R.string.added_,
item.mch.manga.date_added.timeSpanFromNow item.mch.manga.date_added.timeSpanFromNow(itemView.context)
) )
adapter.viewType == RecentsPresenter.VIEW_TYPE_ONLY_UPDATES -> "" adapter.viewType == RecentsPresenter.VIEW_TYPE_ONLY_UPDATES -> ""
item.mch.history.id == null -> binding.body.context.getString( item.mch.history.id == null -> binding.body.context.getString(
R.string.updated_, R.string.updated_,
item.chapter.date_upload.timeSpanFromNow item.chapter.date_upload.timeSpanFromNow(itemView.context)
) )
item.chapter.id != item.mch.chapter.id -> item.chapter.id != item.mch.chapter.id ->
binding.body.context.getString( binding.body.context.getString(
@ -104,7 +104,7 @@ class RecentMangaHolder(
item.chapter.pages_left > 0 && !item.chapter.read -> item.chapter.pages_left > 0 && !item.chapter.read ->
binding.body.context.getString( binding.body.context.getString(
R.string.read_, R.string.read_,
item.mch.history.last_read.timeSpanFromNow item.mch.history.last_read.timeSpanFromNow(itemView.context)
) + "\n" + itemView.resources.getQuantityString( ) + "\n" + itemView.resources.getQuantityString(
R.plurals.pages_left, R.plurals.pages_left,
item.chapter.pages_left, item.chapter.pages_left,
@ -112,7 +112,7 @@ class RecentMangaHolder(
) )
else -> binding.body.context.getString( else -> binding.body.context.getString(
R.string.read_, R.string.read_,
item.mch.history.last_read.timeSpanFromNow item.mch.history.last_read.timeSpanFromNow(itemView.context)
) )
} }
if ((itemView.context as? Activity)?.isDestroyed != true) { if ((itemView.context as? Activity)?.isDestroyed != true) {

View File

@ -1,6 +1,17 @@
package eu.kanade.tachiyomi.util.system package eu.kanade.tachiyomi.util.system
import android.content.Context
import android.text.format.DateUtils import android.text.format.DateUtils
import eu.kanade.tachiyomi.R
import java.util.Locale
val Long.timeSpanFromNow: String val Long.timeSpanFromNow: String
get() = DateUtils.getRelativeTimeSpanString(this).toString() get() = DateUtils.getRelativeTimeSpanString(this).toString()
fun Long.timeSpanFromNow(context: Context): String {
return if (this == 0L) {
context.getString(R.string.a_while_ago).lowercase(Locale.ROOT)
} else {
DateUtils.getRelativeTimeSpanString(this).toString()
}
}

View File

@ -229,6 +229,7 @@
<string name="show_reset_history_button">Show reset history button</string> <string name="show_reset_history_button">Show reset history button</string>
<string name="show_read_in_all">Show read in all</string> <string name="show_read_in_all">Show read in all</string>
<string name="show_title_first">Show title first</string> <string name="show_title_first">Show title first</string>
<string name="a_while_ago">A while ago</string>
<!-- Browse --> <!-- Browse -->
<string name="search_filters">Search filters</string> <string name="search_filters">Search filters</string>