Remove crash log notification in favor of sharing directly

This commit is contained in:
arkon 2023-04-02 15:30:07 -04:00
parent c9bd3a5314
commit 75460e01c8
4 changed files with 6 additions and 71 deletions

View File

@ -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.
*

View File

@ -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))
},

View File

@ -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),
)
}
}
}

View File

@ -529,9 +529,8 @@
<string name="pref_reset_viewer_flags_summary">Resets reading mode and orientation of all series</string>
<string name="pref_reset_viewer_flags_success">All reader settings reset</string>
<string name="pref_reset_viewer_flags_error">Couldn\'t reset reader settings</string>
<string name="pref_dump_crash_logs">Dump crash logs</string>
<string name="pref_dump_crash_logs">Share crash logs</string>
<string name="pref_dump_crash_logs_summary">Saves error logs to a file for sharing with the developers</string>
<string name="crash_log_saved">Crash logs saved</string>
<string name="label_background_activity">Background activity</string>
<string name="pref_disable_battery_optimization">Disable battery optimization</string>
<string name="pref_disable_battery_optimization_summary">Helps with background library updates and backups</string>
@ -794,7 +793,7 @@
<!-- Crash screen -->
<string name="crash_screen_title">Whoops!</string>
<string name="crash_screen_description">%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.</string>
<string name="crash_screen_description">%s ran into an unexpected error. We suggest you share the crash logs in our support channel on Discord.</string>
<string name="crash_screen_restart_application">Restart the application</string>
<!-- Stats screen -->
@ -915,7 +914,6 @@
<string name="channel_new_chapters">Chapter updates</string>
<string name="channel_app_updates">App updates</string>
<string name="channel_ext_updates">Extension updates</string>
<string name="channel_crash_logs">Crash logs</string>
<!-- S Pen actions -->
<string name="spen_previous_page">Previous page</string>