From 56d7331aaeb4796a7cec85be76e39085177e9a86 Mon Sep 17 00:00:00 2001 From: Jays2Kings Date: Sun, 11 Apr 2021 16:23:02 -0400 Subject: [PATCH] Fix share button for crash logs --- .../data/notification/NotificationReceiver.kt | 29 +++++++++++++++++++ 1 file changed, 29 insertions(+) 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 eca72803a9..6f71500a11 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 @@ -98,6 +98,15 @@ class NotificationReceiver : BroadcastReceiver() { val mangaId = intent.getLongExtra(EXTRA_MANGA_ID, -1) markAsRead(urls, mangaId) } + + // Share crash dump file + ACTION_SHARE_CRASH_LOG -> + shareFile( + context, + intent.getParcelableExtra(EXTRA_URI), + "text/plain", + intent.getIntExtra(EXTRA_NOTIFICATION_ID, -1) + ) } } @@ -172,6 +181,26 @@ class NotificationReceiver : BroadcastReceiver() { } } + /** + * Called to start share intent to share backup file + * + * @param context context of application + * @param path path of file + * @param notificationId id of notification + */ + private fun shareFile(context: Context, uri: Uri, fileMimeType: String, notificationId: Int) { + val sendIntent = Intent(Intent.ACTION_SEND).apply { + putExtra(Intent.EXTRA_STREAM, uri) + clipData = ClipData.newRawUri(null, uri) + type = fileMimeType + flags = Intent.FLAG_ACTIVITY_NEW_TASK or Intent.FLAG_GRANT_READ_URI_PERMISSION + } + // Dismiss notification + dismissNotification(context, notificationId) + // Launch share activity + context.startActivity(sendIntent) + } + /** * Called to delete image *