mirror of
https://github.com/mihonapp/mihon.git
synced 2025-01-30 20:04:56 +01:00
Open library update errors screen on clicking library update error notification
(cherry picked from commit d2d22f437a1d61b086f1e19dfbcd2c0a2bc125f4)
This commit is contained in:
parent
ee78212c75
commit
7c638ad452
@ -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),
|
||||
)
|
||||
}
|
||||
}
|
||||
|
@ -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))
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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.
|
||||
*
|
||||
|
@ -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) {
|
||||
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
|
||||
}
|
||||
}
|
||||
|
@ -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)
|
||||
|
@ -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"
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user