From dd327bdb48a08c0c9ad784f2063c47a1d0fdc174 Mon Sep 17 00:00:00 2001 From: Jay Date: Tue, 19 May 2020 02:42:42 -0400 Subject: [PATCH] Added cancel cta to long press library update snackbar --- .../main/java/eu/kanade/tachiyomi/ui/main/MainActivity.kt | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/main/MainActivity.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/main/MainActivity.kt index 5a7dcbd467..65c4bdadd4 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/main/MainActivity.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/main/MainActivity.kt @@ -8,6 +8,7 @@ import android.graphics.Rect import android.graphics.drawable.Drawable import android.os.Build import android.os.Bundle +import android.os.Handler import android.provider.Settings import android.view.GestureDetector import android.view.MenuItem @@ -40,6 +41,7 @@ import eu.kanade.tachiyomi.data.download.DownloadService import eu.kanade.tachiyomi.data.download.DownloadServiceListener import eu.kanade.tachiyomi.data.library.LibraryUpdateService import eu.kanade.tachiyomi.data.notification.NotificationReceiver +import eu.kanade.tachiyomi.data.notification.Notifications import eu.kanade.tachiyomi.data.preference.getOrDefault import eu.kanade.tachiyomi.data.updater.UpdateChecker import eu.kanade.tachiyomi.data.updater.UpdateResult @@ -155,6 +157,10 @@ open class MainActivity : BaseActivity(), DownloadServiceListener { LibraryUpdateService.start(this) main_content.snack(R.string.updating_library) { anchorView = bottom_nav + setAction(R.string.cancel) { + LibraryUpdateService.stop(context) + Handler().post { NotificationReceiver.dismissNotification(context, Notifications.ID_LIBRARY_PROGRESS) } + } } } true