mirror of
https://github.com/tachiyomiorg/tachiyomi.git
synced 2024-11-17 16:09:16 +01:00
Add last update time to Updates Tab (closes #5466)
Co-authored-by: datreesezcup <datreesezcup@users.noreply.github.com>
This commit is contained in:
parent
8a3a7418d0
commit
43c195e14a
@ -163,6 +163,11 @@ fun UpdateScreen(
|
||||
state = updatesListState,
|
||||
contentPadding = contentPaddingWithNavBar,
|
||||
) {
|
||||
if (presenter.lastUpdated > 0L) {
|
||||
item(key = "last_updated") {
|
||||
UpdatesLastUpdatedItem(presenter.lastUpdated)
|
||||
}
|
||||
}
|
||||
updatesUiItems(
|
||||
uiModels = presenter.uiModels,
|
||||
selectionMode = presenter.selectionMode,
|
||||
|
@ -1,7 +1,9 @@
|
||||
package eu.kanade.presentation.updates
|
||||
|
||||
import android.text.format.DateUtils
|
||||
import androidx.compose.foundation.background
|
||||
import androidx.compose.foundation.combinedClickable
|
||||
import androidx.compose.foundation.layout.Box
|
||||
import androidx.compose.foundation.layout.Column
|
||||
import androidx.compose.foundation.layout.Row
|
||||
import androidx.compose.foundation.layout.Spacer
|
||||
@ -15,6 +17,7 @@ import androidx.compose.foundation.lazy.items
|
||||
import androidx.compose.material.icons.Icons
|
||||
import androidx.compose.material.icons.filled.Bookmark
|
||||
import androidx.compose.material3.Icon
|
||||
import androidx.compose.material3.LocalTextStyle
|
||||
import androidx.compose.material3.MaterialTheme
|
||||
import androidx.compose.material3.Text
|
||||
import androidx.compose.runtime.Composable
|
||||
@ -30,6 +33,7 @@ import androidx.compose.ui.hapticfeedback.HapticFeedbackType
|
||||
import androidx.compose.ui.platform.LocalDensity
|
||||
import androidx.compose.ui.platform.LocalHapticFeedback
|
||||
import androidx.compose.ui.res.stringResource
|
||||
import androidx.compose.ui.text.font.FontStyle
|
||||
import androidx.compose.ui.text.style.TextOverflow
|
||||
import androidx.compose.ui.unit.dp
|
||||
import eu.kanade.domain.updates.model.UpdatesWithRelations
|
||||
@ -43,6 +47,28 @@ import eu.kanade.tachiyomi.R
|
||||
import eu.kanade.tachiyomi.data.download.model.Download
|
||||
import eu.kanade.tachiyomi.ui.recent.updates.UpdatesItem
|
||||
import java.text.DateFormat
|
||||
import java.util.Date
|
||||
|
||||
@Composable
|
||||
fun UpdatesLastUpdatedItem(
|
||||
lastUpdated: Long,
|
||||
) {
|
||||
val time = remember(lastUpdated) {
|
||||
DateUtils.getRelativeTimeSpanString(lastUpdated, Date().time, DateUtils.MINUTE_IN_MILLIS)
|
||||
}
|
||||
|
||||
Box(
|
||||
modifier = Modifier
|
||||
.padding(horizontal = horizontalPadding, vertical = 8.dp),
|
||||
) {
|
||||
Text(
|
||||
text = stringResource(R.string.updates_last_update_info, time),
|
||||
style = LocalTextStyle.current.copy(
|
||||
fontStyle = FontStyle.Italic,
|
||||
),
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
fun LazyListScope.updatesUiItems(
|
||||
uiModels: List<UpdatesUiModel>,
|
||||
|
@ -68,6 +68,7 @@ import logcat.LogPriority
|
||||
import uy.kohesive.injekt.Injekt
|
||||
import uy.kohesive.injekt.api.get
|
||||
import java.io.File
|
||||
import java.util.Date
|
||||
import java.util.concurrent.CopyOnWriteArrayList
|
||||
import java.util.concurrent.atomic.AtomicBoolean
|
||||
import java.util.concurrent.atomic.AtomicInteger
|
||||
@ -225,6 +226,11 @@ class LibraryUpdateService(
|
||||
updateJob?.cancel()
|
||||
ioScope?.cancel()
|
||||
|
||||
// If this is a chapter update; set the last update time to now
|
||||
if (target == Target.CHAPTERS) {
|
||||
preferences.libraryUpdateLastTimestamp().set(Date().time)
|
||||
}
|
||||
|
||||
// Update favorite manga
|
||||
val categoryId = intent.getLongExtra(KEY_CATEGORY, -1L)
|
||||
addMangaToQueue(categoryId)
|
||||
|
@ -219,6 +219,7 @@ class PreferencesHelper(val context: Context) {
|
||||
fun removeExcludeCategories() = flowPrefs.getStringSet("remove_exclude_categories", emptySet())
|
||||
|
||||
fun libraryUpdateInterval() = flowPrefs.getInt("pref_library_update_interval_key", 24)
|
||||
fun libraryUpdateLastTimestamp() = flowPrefs.getLong("library_update_last_timestamp", 0L)
|
||||
|
||||
fun libraryUpdateDeviceRestriction() = flowPrefs.getStringSet("library_update_restriction", setOf(DEVICE_ONLY_ON_WIFI))
|
||||
fun libraryUpdateMangaRestriction() = flowPrefs.getStringSet("library_update_manga_restriction", setOf(MANGA_HAS_UNREAD, MANGA_NON_COMPLETED, MANGA_NON_READ))
|
||||
|
@ -52,11 +52,11 @@ class UpdatesPresenter(
|
||||
) : BasePresenter<UpdatesController>(), UpdatesState by state {
|
||||
|
||||
val isDownloadOnly: Boolean by preferences.downloadedOnly().asState()
|
||||
|
||||
val isIncognitoMode: Boolean by preferences.incognitoMode().asState()
|
||||
|
||||
val relativeTime: Int by preferences.relativeTime().asState()
|
||||
val lastUpdated by preferences.libraryUpdateLastTimestamp().asState()
|
||||
|
||||
val relativeTime: Int by preferences.relativeTime().asState()
|
||||
val dateFormat: DateFormat by mutableStateOf(preferences.dateFormat())
|
||||
|
||||
private val _events: Channel<Event> = Channel(Int.MAX_VALUE)
|
||||
|
@ -742,6 +742,7 @@
|
||||
<string name="updating_library">Updating library</string>
|
||||
<string name="update_already_running">An update is already running</string>
|
||||
<string name="cant_open_last_read_chapter">Unable to open last read chapter</string>
|
||||
<string name="updates_last_update_info">Library last updated: %1$s</string>
|
||||
|
||||
<!-- History fragment -->
|
||||
<string name="recent_manga_time">Ch. %1$s - %2$s</string>
|
||||
|
Loading…
Reference in New Issue
Block a user