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 b2c34a1ca8..5110aaca6a 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 @@ -119,14 +119,6 @@ class NotificationReceiver : BroadcastReceiver() { downloadChapters(urls, mangaId) } } - // Share crash dump file - ACTION_SHARE_CRASH_LOG -> - shareFile( - context, - intent.getParcelableExtraCompat(EXTRA_URI)!!, - "text/plain", - intent.getIntExtra(EXTRA_NOTIFICATION_ID, -1), - ) } } @@ -272,8 +264,6 @@ class NotificationReceiver : BroadcastReceiver() { private const val ACTION_SHARE_BACKUP = "$ID.$NAME.SEND_BACKUP" - private const val ACTION_SHARE_CRASH_LOG = "$ID.$NAME.SEND_CRASH_LOG" - private const val ACTION_CANCEL_RESTORE = "$ID.$NAME.CANCEL_RESTORE" private const val ACTION_CANCEL_LIBRARY_UPDATE = "$ID.$NAME.CANCEL_LIBRARY_UPDATE" @@ -566,23 +556,6 @@ class NotificationReceiver : BroadcastReceiver() { return PendingIntent.getActivity(context, 0, intent, PendingIntent.FLAG_IMMUTABLE) } - /** - * Returns [PendingIntent] that starts a share activity for a crash log dump file. - * - * @param context context of application - * @param uri uri of file - * @param notificationId id of notification - * @return [PendingIntent] - */ - internal fun shareCrashLogPendingBroadcast(context: Context, uri: Uri, notificationId: Int): PendingIntent { - val intent = Intent(context, NotificationReceiver::class.java).apply { - action = ACTION_SHARE_CRASH_LOG - putExtra(EXTRA_URI, uri) - putExtra(EXTRA_NOTIFICATION_ID, notificationId) - } - return PendingIntent.getBroadcast(context, 0, intent, PendingIntent.FLAG_UPDATE_CURRENT or PendingIntent.FLAG_IMMUTABLE) - } - /** * Returns [PendingIntent] that cancels a backup restore job. * diff --git a/app/src/main/java/eu/kanade/tachiyomi/data/notification/Notifications.kt b/app/src/main/java/eu/kanade/tachiyomi/data/notification/Notifications.kt index bebce9749d..2559795dbf 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/data/notification/Notifications.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/data/notification/Notifications.kt @@ -59,12 +59,6 @@ object Notifications { const val ID_BACKUP_COMPLETE = -502 const val ID_RESTORE_COMPLETE = -504 - /** - * Notification channel used for crash log file sharing. - */ - const val CHANNEL_CRASH_LOGS = "crash_logs_channel" - const val ID_CRASH_LOGS = -601 - /** * Notification channel used for Incognito Mode */ @@ -90,6 +84,7 @@ object Notifications { "library_progress_channel", "updates_ext_channel", "downloader_cache_renewal", + "crash_logs_channel", ) /** @@ -165,9 +160,6 @@ object Notifications { setShowBadge(false) setSound(null, null) }, - buildNotificationChannel(CHANNEL_CRASH_LOGS, IMPORTANCE_HIGH) { - setName(context.getString(R.string.channel_crash_logs)) - }, buildNotificationChannel(CHANNEL_INCOGNITO_MODE, IMPORTANCE_LOW) { setName(context.getString(R.string.pref_incognito_mode)) }, diff --git a/app/src/main/java/eu/kanade/tachiyomi/util/CrashLogUtil.kt b/app/src/main/java/eu/kanade/tachiyomi/util/CrashLogUtil.kt index 0a5c4bc825..aa9830de82 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/util/CrashLogUtil.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/util/CrashLogUtil.kt @@ -1,16 +1,11 @@ package eu.kanade.tachiyomi.util import android.content.Context -import android.net.Uri import android.os.Build import eu.kanade.tachiyomi.BuildConfig -import eu.kanade.tachiyomi.R -import eu.kanade.tachiyomi.data.notification.NotificationReceiver -import eu.kanade.tachiyomi.data.notification.Notifications import eu.kanade.tachiyomi.util.storage.getUriCompat -import eu.kanade.tachiyomi.util.system.cancelNotification import eu.kanade.tachiyomi.util.system.createFileInCacheDir -import eu.kanade.tachiyomi.util.system.notify +import eu.kanade.tachiyomi.util.system.toShareIntent import eu.kanade.tachiyomi.util.system.toast import tachiyomi.core.util.lang.withNonCancellableContext import tachiyomi.core.util.lang.withUIContext @@ -23,7 +18,8 @@ class CrashLogUtil(private val context: Context) { Runtime.getRuntime().exec("logcat *:E -d -f ${file.absolutePath}").waitFor() file.appendText(getDebugInfo()) - showNotification(file.getUriCompat(context)) + val uri = file.getUriCompat(context) + context.startActivity(uri.toShareIntent(context, "text/plain")) } catch (e: Throwable) { withUIContext { context.toast("Failed to get logs") } } @@ -41,28 +37,4 @@ class CrashLogUtil(private val context: Context) { Device product name: ${Build.PRODUCT} """.trimIndent() } - - private fun showNotification(uri: Uri) { - context.cancelNotification(Notifications.ID_CRASH_LOGS) - - context.notify( - Notifications.ID_CRASH_LOGS, - Notifications.CHANNEL_CRASH_LOGS, - ) { - setContentTitle(context.getString(R.string.crash_log_saved)) - setSmallIcon(R.drawable.ic_tachi) - - clearActions() - addAction( - R.drawable.ic_folder_24dp, - context.getString(R.string.action_open_log), - NotificationReceiver.openErrorLogPendingActivity(context, uri), - ) - addAction( - R.drawable.ic_share_24dp, - context.getString(R.string.action_share), - NotificationReceiver.shareCrashLogPendingBroadcast(context, uri, Notifications.ID_CRASH_LOGS), - ) - } - } } diff --git a/i18n/src/main/res/values/strings.xml b/i18n/src/main/res/values/strings.xml index 67087aff24..fc60be1566 100644 --- a/i18n/src/main/res/values/strings.xml +++ b/i18n/src/main/res/values/strings.xml @@ -529,9 +529,8 @@ Resets reading mode and orientation of all series All reader settings reset Couldn\'t reset reader settings - Dump crash logs + Share crash logs Saves error logs to a file for sharing with the developers - Crash logs saved Background activity Disable battery optimization Helps with background library updates and backups @@ -794,7 +793,7 @@ Whoops! - %s ran into an unexpected error. We suggest you screenshot this message, dump the crash logs, and then share it in our support channel on Discord. + %s ran into an unexpected error. We suggest you share the crash logs in our support channel on Discord. Restart the application @@ -915,7 +914,6 @@ Chapter updates App updates Extension updates - Crash logs Previous page