mirror of
https://github.com/tachiyomiorg/tachiyomi.git
synced 2024-12-22 19:11:50 +01:00
Fix notification and add visual cues when triggering a second update (#7783)
This commit is contained in:
parent
80b4b7bee6
commit
1f34f5277c
@ -35,7 +35,7 @@ fun LibraryScreen(
|
|||||||
onClickSelectAll: () -> Unit,
|
onClickSelectAll: () -> Unit,
|
||||||
onClickInvertSelection: () -> Unit,
|
onClickInvertSelection: () -> Unit,
|
||||||
onClickFilter: () -> Unit,
|
onClickFilter: () -> Unit,
|
||||||
onClickRefresh: (Category?) -> Unit,
|
onClickRefresh: (Category?) -> Boolean,
|
||||||
) {
|
) {
|
||||||
val scrollBehavior = TopAppBarDefaults.pinnedScrollBehavior(rememberTopAppBarState())
|
val scrollBehavior = TopAppBarDefaults.pinnedScrollBehavior(rememberTopAppBarState())
|
||||||
val insets = WindowInsets.navigationBars.only(WindowInsetsSides.Horizontal)
|
val insets = WindowInsets.navigationBars.only(WindowInsetsSides.Horizontal)
|
||||||
|
@ -42,7 +42,7 @@ fun LibraryContent(
|
|||||||
onChangeCurrentPage: (Int) -> Unit,
|
onChangeCurrentPage: (Int) -> Unit,
|
||||||
onMangaClicked: (Long) -> Unit,
|
onMangaClicked: (Long) -> Unit,
|
||||||
onToggleSelection: (LibraryManga) -> Unit,
|
onToggleSelection: (LibraryManga) -> Unit,
|
||||||
onRefresh: (Category?) -> Unit,
|
onRefresh: (Category?) -> Boolean,
|
||||||
onGlobalSearchClicked: () -> Unit,
|
onGlobalSearchClicked: () -> Unit,
|
||||||
getNumberOfMangaForCategory: @Composable (Long) -> State<Int?>,
|
getNumberOfMangaForCategory: @Composable (Long) -> State<Int?>,
|
||||||
getDisplayModeForPage: @Composable (Int) -> State<DisplayModeSetting>,
|
getDisplayModeForPage: @Composable (Int) -> State<DisplayModeSetting>,
|
||||||
@ -84,7 +84,8 @@ fun LibraryContent(
|
|||||||
SwipeRefresh(
|
SwipeRefresh(
|
||||||
state = rememberSwipeRefreshState(isRefreshing = isRefreshing),
|
state = rememberSwipeRefreshState(isRefreshing = isRefreshing),
|
||||||
onRefresh = {
|
onRefresh = {
|
||||||
onRefresh(categories[currentPage()])
|
val started = onRefresh(categories[currentPage()])
|
||||||
|
if (!started) return@SwipeRefresh
|
||||||
scope.launch {
|
scope.launch {
|
||||||
// Fake refresh status but hide it after a second as it's a long running task
|
// Fake refresh status but hide it after a second as it's a long running task
|
||||||
isRefreshing = true
|
isRefreshing = true
|
||||||
|
@ -83,9 +83,9 @@ fun UpdateScreen(
|
|||||||
val context = LocalContext.current
|
val context = LocalContext.current
|
||||||
|
|
||||||
val onUpdateLibrary = {
|
val onUpdateLibrary = {
|
||||||
if (LibraryUpdateService.start(context)) {
|
val started = LibraryUpdateService.start(context)
|
||||||
context.toast(R.string.updating_library)
|
context.toast(if (started) R.string.updating_library else R.string.update_already_running)
|
||||||
}
|
started
|
||||||
}
|
}
|
||||||
|
|
||||||
val scrollBehavior = TopAppBarDefaults.pinnedScrollBehavior(rememberTopAppBarState())
|
val scrollBehavior = TopAppBarDefaults.pinnedScrollBehavior(rememberTopAppBarState())
|
||||||
@ -97,7 +97,7 @@ fun UpdateScreen(
|
|||||||
UpdatesAppBar(
|
UpdatesAppBar(
|
||||||
incognitoMode = presenter.isIncognitoMode,
|
incognitoMode = presenter.isIncognitoMode,
|
||||||
downloadedOnlyMode = presenter.isDownloadOnly,
|
downloadedOnlyMode = presenter.isDownloadOnly,
|
||||||
onUpdateLibrary = onUpdateLibrary,
|
onUpdateLibrary = { onUpdateLibrary() },
|
||||||
actionModeCounter = presenter.selected.size,
|
actionModeCounter = presenter.selected.size,
|
||||||
onSelectAll = { presenter.toggleAllSelection(true) },
|
onSelectAll = { presenter.toggleAllSelection(true) },
|
||||||
onInvertSelection = { presenter.invertSelection() },
|
onInvertSelection = { presenter.invertSelection() },
|
||||||
@ -132,7 +132,8 @@ fun UpdateScreen(
|
|||||||
SwipeRefresh(
|
SwipeRefresh(
|
||||||
state = rememberSwipeRefreshState(isRefreshing = isRefreshing),
|
state = rememberSwipeRefreshState(isRefreshing = isRefreshing),
|
||||||
onRefresh = {
|
onRefresh = {
|
||||||
onUpdateLibrary()
|
val started = onUpdateLibrary()
|
||||||
|
if (!started) return@SwipeRefresh
|
||||||
scope.launch {
|
scope.launch {
|
||||||
// Fake refresh status but hide it after a second as it's a long running task
|
// Fake refresh status but hide it after a second as it's a long running task
|
||||||
isRefreshing = true
|
isRefreshing = true
|
||||||
|
@ -154,18 +154,15 @@ class LibraryUpdateService(
|
|||||||
* @return true if service newly started, false otherwise
|
* @return true if service newly started, false otherwise
|
||||||
*/
|
*/
|
||||||
fun start(context: Context, category: Category? = null, target: Target = Target.CHAPTERS): Boolean {
|
fun start(context: Context, category: Category? = null, target: Target = Target.CHAPTERS): Boolean {
|
||||||
return if (!isRunning(context)) {
|
if (isRunning(context)) return false
|
||||||
|
|
||||||
val intent = Intent(context, LibraryUpdateService::class.java).apply {
|
val intent = Intent(context, LibraryUpdateService::class.java).apply {
|
||||||
putExtra(KEY_TARGET, target)
|
putExtra(KEY_TARGET, target)
|
||||||
category?.let { putExtra(KEY_CATEGORY, it.id) }
|
category?.let { putExtra(KEY_CATEGORY, it.id) }
|
||||||
}
|
}
|
||||||
ContextCompat.startForegroundService(context, intent)
|
ContextCompat.startForegroundService(context, intent)
|
||||||
|
|
||||||
true
|
return true
|
||||||
} else {
|
|
||||||
instance?.addMangaToQueue(category?.id ?: -1)
|
|
||||||
false
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -57,9 +57,9 @@ class LibraryController(
|
|||||||
onDeleteClicked = ::showDeleteMangaDialog,
|
onDeleteClicked = ::showDeleteMangaDialog,
|
||||||
onClickFilter = ::showSettingsSheet,
|
onClickFilter = ::showSettingsSheet,
|
||||||
onClickRefresh = {
|
onClickRefresh = {
|
||||||
if (LibraryUpdateService.start(context, it)) {
|
val started = LibraryUpdateService.start(context, it)
|
||||||
context.toast(R.string.updating_library)
|
context.toast(if (started) R.string.updating_library else R.string.update_already_running)
|
||||||
}
|
started
|
||||||
},
|
},
|
||||||
onClickInvertSelection = { presenter.invertSelection(presenter.activeCategory) },
|
onClickInvertSelection = { presenter.invertSelection(presenter.activeCategory) },
|
||||||
onClickSelectAll = { presenter.selectAll(presenter.activeCategory) },
|
onClickSelectAll = { presenter.selectAll(presenter.activeCategory) },
|
||||||
|
@ -729,6 +729,7 @@
|
|||||||
|
|
||||||
<!-- Updates fragment -->
|
<!-- Updates fragment -->
|
||||||
<string name="updating_library">Updating library</string>
|
<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="cant_open_last_read_chapter">Unable to open last read chapter</string>
|
||||||
|
|
||||||
<!-- History fragment -->
|
<!-- History fragment -->
|
||||||
|
Loading…
Reference in New Issue
Block a user