diff --git a/app/src/main/java/eu/kanade/tachiyomi/data/library/LibraryUpdateJob.kt b/app/src/main/java/eu/kanade/tachiyomi/data/library/LibraryUpdateJob.kt index 670aa875d..2703c9304 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/data/library/LibraryUpdateJob.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/data/library/LibraryUpdateJob.kt @@ -24,7 +24,6 @@ import eu.kanade.tachiyomi.data.download.DownloadManager import eu.kanade.tachiyomi.data.notification.Notifications import eu.kanade.tachiyomi.source.model.SManga import eu.kanade.tachiyomi.source.model.UpdateStrategy -import eu.kanade.tachiyomi.util.storage.getUriCompat import eu.kanade.tachiyomi.util.system.createFileInCacheDir import eu.kanade.tachiyomi.util.system.isConnectedToWifi import eu.kanade.tachiyomi.util.system.isRunning @@ -322,10 +321,8 @@ class LibraryUpdateJob(private val context: Context, workerParams: WorkerParamet if (failedUpdates.isNotEmpty()) { writeErrorsToDB(failedUpdates) - val errorFile = writeErrorFile(failedUpdates) notifier.showUpdateErrorNotification( failedUpdates.size, - errorFile.getUriCompat(context), ) } } diff --git a/app/src/main/java/eu/kanade/tachiyomi/data/library/LibraryUpdateNotifier.kt b/app/src/main/java/eu/kanade/tachiyomi/data/library/LibraryUpdateNotifier.kt index f7d6c5dbc..722bef7aa 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/data/library/LibraryUpdateNotifier.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/data/library/LibraryUpdateNotifier.kt @@ -6,7 +6,6 @@ import android.content.Context import android.content.Intent import android.graphics.Bitmap import android.graphics.BitmapFactory -import android.net.Uri import androidx.core.app.NotificationCompat import androidx.core.app.NotificationManagerCompat import coil3.asDrawable @@ -142,9 +141,8 @@ class LibraryUpdateNotifier( * Shows notification containing update entries that failed with action to open full log. * * @param failed Number of entries that failed to update. - * @param uri Uri for error log file containing all titles that failed. */ - fun showUpdateErrorNotification(failed: Int, uri: Uri) { + fun showUpdateErrorNotification(failed: Int) { if (failed == 0) { return } @@ -157,7 +155,7 @@ class LibraryUpdateNotifier( setContentText(context.stringResource(MR.strings.action_show_errors)) setSmallIcon(R.drawable.ic_mihon) - setContentIntent(NotificationReceiver.openErrorLogPendingActivity(context, uri)) + setContentIntent(NotificationReceiver.openErrorLogPendingActivity(context)) } } diff --git a/app/src/main/java/eu/kanade/tachiyomi/data/notification/NotificationReceiver.kt b/app/src/main/java/eu/kanade/tachiyomi/data/notification/NotificationReceiver.kt index 01dada5c8..89e8c2fe7 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/data/notification/NotificationReceiver.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/data/notification/NotificationReceiver.kt @@ -618,6 +618,20 @@ class NotificationReceiver : BroadcastReceiver() { return PendingIntent.getActivity(context, 0, intent, PendingIntent.FLAG_IMMUTABLE) } + /** + * Returns [PendingIntent] that opens the error log file in an external viewer + * + * @param context context of application + * @return [PendingIntent] + */ + internal fun openErrorLogPendingActivity(context: Context): PendingIntent { + val intent = Intent(context, MainActivity::class.java).apply { + action = Constants.SHORTCUT_LIBRARY_UPDATE_ERRORS + flags = Intent.FLAG_ACTIVITY_CLEAR_TOP + } + return PendingIntent.getActivity(context, 0, intent, PendingIntent.FLAG_UPDATE_CURRENT) + } + /** * Returns [PendingIntent] that cancels a backup restore job. * diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/home/HomeScreen.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/home/HomeScreen.kt index ac708ec2f..7c51c79b2 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/home/HomeScreen.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/home/HomeScreen.kt @@ -41,6 +41,7 @@ import eu.kanade.tachiyomi.ui.browse.BrowseTab import eu.kanade.tachiyomi.ui.download.DownloadQueueScreen import eu.kanade.tachiyomi.ui.history.HistoryTab import eu.kanade.tachiyomi.ui.library.LibraryTab +import eu.kanade.tachiyomi.ui.libraryUpdateError.LibraryUpdateErrorScreen import eu.kanade.tachiyomi.ui.manga.MangaScreen import eu.kanade.tachiyomi.ui.more.MoreTab import eu.kanade.tachiyomi.ui.updates.UpdatesTab @@ -166,8 +167,12 @@ object HomeScreen : Screen() { if (it is Tab.Library && it.mangaIdToOpen != null) { navigator.push(MangaScreen(it.mangaIdToOpen)) } - if (it is Tab.More && it.toDownloads) { - navigator.push(DownloadQueueScreen) + if (it is Tab.More) { + if (it.toDownloads) { + navigator.push(DownloadQueueScreen) + } else if (it.toLibraryUpdateErrors) { + navigator.push(LibraryUpdateErrorScreen()) + } } } } @@ -307,6 +312,9 @@ object HomeScreen : Screen() { data object Updates : Tab data object History : Tab data class Browse(val toExtensions: Boolean = false) : Tab - data class More(val toDownloads: Boolean) : Tab + data class More( + val toDownloads: Boolean, + val toLibraryUpdateErrors: Boolean = false, + ) : Tab } } 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 aefe0fe77..8b45db322 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 @@ -403,6 +403,10 @@ class MainActivity : BaseActivity() { navigator.popUntilRoot() HomeScreen.Tab.More(toDownloads = true) } + Constants.SHORTCUT_LIBRARY_UPDATE_ERRORS -> { + navigator.popUntilRoot() + HomeScreen.Tab.More(toDownloads = false, toLibraryUpdateErrors = true) + } Intent.ACTION_SEARCH, Intent.ACTION_SEND, "com.google.android.gms.actions.SEARCH_ACTION" -> { // If the intent match the "standard" Android search intent // or the Google-specific search intent (triggered by saying or typing "search *query* on *Tachiyomi*" in Google Search/Google Assistant) diff --git a/core/common/src/main/kotlin/tachiyomi/core/common/Constants.kt b/core/common/src/main/kotlin/tachiyomi/core/common/Constants.kt index 38caeb3dc..9ea18ce78 100644 --- a/core/common/src/main/kotlin/tachiyomi/core/common/Constants.kt +++ b/core/common/src/main/kotlin/tachiyomi/core/common/Constants.kt @@ -16,4 +16,6 @@ object Constants { const val SHORTCUT_SOURCES = "eu.kanade.tachiyomi.SHOW_CATALOGUES" const val SHORTCUT_EXTENSIONS = "eu.kanade.tachiyomi.EXTENSIONS" const val SHORTCUT_DOWNLOADS = "eu.kanade.tachiyomi.SHOW_DOWNLOADS" + + const val SHORTCUT_LIBRARY_UPDATE_ERRORS = "eu.kanade.tachiyomi.SHOW_LIBRARY_UPDATE_ERRORS" }