From 8936138da587533d211b864eb2e999188bc37947 Mon Sep 17 00:00:00 2001 From: Jay Date: Wed, 13 Nov 2019 20:41:34 -0800 Subject: [PATCH] New Notifcation Icon New Chapter Notifcations now show all new chapters when expanded --- .../data/library/LibraryUpdateService.kt | 28 +++++++++------ .../data/notification/NotificationReceiver.kt | 33 +++++++++--------- .../data/notification/Notifications.kt | 6 ++-- .../res/drawable-hdpi/ic_tachiyomi_icon.png | Bin 0 -> 979 bytes .../res/drawable-mdpi/ic_tachiyomi_icon.png | Bin 0 -> 597 bytes .../res/drawable-xhdpi/ic_tachiyomi_icon.png | Bin 0 -> 1176 bytes .../res/drawable-xxhdpi/ic_tachiyomi_icon.png | Bin 0 -> 2116 bytes .../drawable-xxxhdpi/ic_tachiyomi_icon.png | Bin 0 -> 3170 bytes app/src/main/res/values/strings.xml | 1 + 9 files changed, 38 insertions(+), 30 deletions(-) create mode 100644 app/src/main/res/drawable-hdpi/ic_tachiyomi_icon.png create mode 100644 app/src/main/res/drawable-mdpi/ic_tachiyomi_icon.png create mode 100644 app/src/main/res/drawable-xhdpi/ic_tachiyomi_icon.png create mode 100644 app/src/main/res/drawable-xxhdpi/ic_tachiyomi_icon.png create mode 100644 app/src/main/res/drawable-xxxhdpi/ic_tachiyomi_icon.png diff --git a/app/src/main/java/eu/kanade/tachiyomi/data/library/LibraryUpdateService.kt b/app/src/main/java/eu/kanade/tachiyomi/data/library/LibraryUpdateService.kt index 8b74506fa6..e0b472e292 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/data/library/LibraryUpdateService.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/data/library/LibraryUpdateService.kt @@ -278,7 +278,7 @@ class LibraryUpdateService( // Initialize the variables holding the progress of the updates. val count = AtomicInteger(0) // List containing new updates - val newUpdates = ArrayList>() + val newUpdates = ArrayList>>() // list containing failed updates val failedUpdates = ArrayList() // List containing categories that get included in downloads. @@ -311,7 +311,8 @@ class LibraryUpdateService( } } // Convert to the manga that contains new chapters. - .map { Pair(manga, (it.first.maxBy { ch -> ch.source_order }!!)) } + .map { Pair(manga, (it.first.sortedByDescending { ch -> ch + .source_order }.toTypedArray())) } } // Add manga with new chapters to the list. .doOnNext { manga -> @@ -447,13 +448,15 @@ class LibraryUpdateService( * * @param updates a list of manga with new updates. */ - private fun showResultNotification(updates: List>) { + private fun showResultNotification(updates: List>>) { val notifications = ArrayList>() updates.forEach { val manga = it.first - val chapter = it.second + val chapters = it.second + val chapterNames = chapters.map { chapter -> chapter.name.chop(45) }.toSet() + NotificationReceiver.dismissNotification(this, manga.id.hashCode()) notifications.add(Pair(notification(Notifications.CHANNEL_NEW_CHAPTERS) { - setSmallIcon(R.drawable.ic_book_white_24dp) + setSmallIcon(R.drawable.ic_tachiyomi_icon) try { val icon = GlideApp.with(this@LibraryUpdateService) .asBitmap().load(manga).dontTransform().centerCrop().circleCrop() @@ -463,18 +466,21 @@ class LibraryUpdateService( catch (e: Exception) { } setContentTitle(manga.title.chop(45)) color = ContextCompat.getColor(this@LibraryUpdateService, R.color.colorAccentLight) - setContentText(chapter.name) + setContentText(chapterNames.first()) + setStyle(NotificationCompat.BigTextStyle().bigText(chapterNames.joinToString("\n"))) priority = NotificationCompat.PRIORITY_HIGH setGroup(Notifications.GROUP_NEW_CHAPTERS) setContentIntent( NotificationReceiver.openChapterPendingActivity( - this@LibraryUpdateService, manga, chapter + this@LibraryUpdateService, manga, chapters.first() ) ) - addAction(R.drawable.ic_in_library_24dp, getString(R.string.action_mark_as_read), + addAction(R.drawable.ic_glasses_black_24dp, getString( + if (chapters.size > 1) R.string.action_mark_all_as_read else R.string + .action_mark_as_read), NotificationReceiver.markAsReadPendingBroadcast(this@LibraryUpdateService, - manga, chapter, Notifications.GROUP_NEW_CHAPTERS)) - addAction(R.drawable.ic_glasses_black_24dp, getString(R.string.action_view_chapters), + manga, chapters, Notifications.GROUP_NEW_CHAPTERS)) + addAction(R.drawable.ic_book_white_24dp, getString(R.string.action_view_chapters), NotificationReceiver.openChapterPendingActivity(this@LibraryUpdateService, manga, Notifications.GROUP_NEW_CHAPTERS)) setAutoCancel(true) @@ -489,7 +495,7 @@ class LibraryUpdateService( if (Build.VERSION.SDK_INT < Build.VERSION_CODES.N || notificationManager .activeNotifications.find { it.groupKey == Notifications.GROUP_NEW_CHAPTERS } == null) { notify(Notifications.ID_NEW_CHAPTERS, notification(Notifications.CHANNEL_NEW_CHAPTERS) { - setSmallIcon(R.drawable.ic_book_white_24dp) + setSmallIcon(R.drawable.ic_tachiyomi_icon) setLargeIcon(notificationBitmap) setContentTitle(getString(R.string.notification_new_chapters)) color = ContextCompat.getColor(applicationContext, R.color.colorAccentLight) 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 44d9670094..378c10751d 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 @@ -75,9 +75,9 @@ class NotificationReceiver : BroadcastReceiver() { if (notificationId > -1) dismissNotification( context, notificationId, intent.getStringExtra(EXTRA_GROUP_ID) ) - val url = intent.getStringExtra(EXTRA_CHAPTER_URL) ?: return + val urls = intent.getStringArrayExtra(EXTRA_CHAPTER_URL) ?: return val mangaId = intent.getLongExtra(EXTRA_MANGA_ID, -1) - markAsRead(url, mangaId) + markAsRead(urls, mangaId) } } } @@ -169,18 +169,19 @@ class NotificationReceiver : BroadcastReceiver() { * @param context context of application * @param notificationId id of notification */ - private fun markAsRead(chapterUrl: String, mangaaId: Long) { + private fun markAsRead(chapterUrls: Array, mangaId: Long) { val db: DatabaseHelper = Injekt.get() - val chapter = db.getChapter(chapterUrl, mangaaId).executeAsBlocking() ?: return - chapter.read = true - db.updateChapterProgress(chapter).executeAsBlocking() - val preferences: PreferencesHelper = Injekt.get() - if (preferences.removeAfterMarkedAsRead()) { - val mangaId = chapter.manga_id ?: return - val manga = db.getManga(mangaId).executeAsBlocking() ?: return - val sourceManager: SourceManager = Injekt.get() - val source = sourceManager.get(manga.source) ?: return - downloadManager.deleteChapters(listOf(chapter), manga, source) + chapterUrls.forEach { + val chapter = db.getChapter(it, mangaId).executeAsBlocking() ?: return + chapter.read = true + db.updateChapterProgress(chapter).executeAsBlocking() + val preferences: PreferencesHelper = Injekt.get() + if (preferences.removeAfterMarkedAsRead()) { + val manga = db.getManga(mangaId).executeAsBlocking() ?: return + val sourceManager: SourceManager = Injekt.get() + val source = sourceManager.get(manga.source) ?: return + downloadManager.deleteChapters(listOf(chapter), manga, source) + } } } @@ -393,12 +394,12 @@ class NotificationReceiver : BroadcastReceiver() { * @param context context of application * @param manga manga of chapter */ - internal fun markAsReadPendingBroadcast(context: Context, manga: Manga, chapter: - Chapter, groupId: String): + internal fun markAsReadPendingBroadcast(context: Context, manga: Manga, chapters: + Array, groupId: String): PendingIntent { val newIntent = Intent(context, NotificationReceiver::class.java).apply { action = ACTION_MARK_AS_READ - putExtra(EXTRA_CHAPTER_URL, chapter.url) + putExtra(EXTRA_CHAPTER_URL, chapters.map { it.url }.toTypedArray()) putExtra(EXTRA_MANGA_ID, manga.id) putExtra(EXTRA_NOTIFICATION_ID, manga.id.hashCode()) putExtra(EXTRA_GROUP_ID, groupId) 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 f4564ac8c8..b99c44cadd 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 @@ -23,14 +23,14 @@ object Notifications { * Notification channel and ids used by the library updater. */ const val CHANNEL_LIBRARY = "library_channel" - const val ID_LIBRARY_PROGRESS = 101 + const val ID_LIBRARY_PROGRESS = -101 /** * Notification channel and ids used by the downloader. */ const val CHANNEL_DOWNLOADER = "downloader_channel" - const val ID_DOWNLOAD_CHAPTER = 201 - const val ID_DOWNLOAD_CHAPTER_ERROR = 202 + const val ID_DOWNLOAD_CHAPTER = -201 + const val ID_DOWNLOAD_CHAPTER_ERROR = -202 /** * Notification channel and ids used by the library updater. diff --git a/app/src/main/res/drawable-hdpi/ic_tachiyomi_icon.png b/app/src/main/res/drawable-hdpi/ic_tachiyomi_icon.png new file mode 100644 index 0000000000000000000000000000000000000000..c7e17442b8c8c7d86b3dd6cd44f017d02683bbe8 GIT binary patch literal 979 zcmV;^11$WBP);YcP0DS30L23!1V0J zOOl+z+7%IR0$*1c9R%h{a?^ca)rxCGtOYEVWjp78wxq*#h$7+}U`}RZaxa(U;;CHi z08LCeclgWen50>)oJNEz$h^sAk;Qr&hyi-;FeAIW*NSJI-~c|_RG zgWKGUdnWP7R^?v!X#&VLKLIaghaUyrkn~sic|=SAz67Rb_B$mlsf&*H+5$>x^W5`M z=FHu9r6jk8t`!mQ0-pdw%8vo3YhOmIv>~wtSOpYM0l)q0p#hjoxxx4DL~JsgJvhyw&N?n=fDP+erd017V*QUY~tKk}LUMl|_Ul z!n)F_ z?}WW3LJt6%1bEP%47jArq&Cl*4)sklYM;gJbrA5Kq_@ivdKws=ZUG(*id%w#bO%r_ z!1@1jm3gnYR$rIo>TRZFO+ULQ>>5c&PaM?L$A6WTLNxK?Nh$yU002ovPDHLkV1n|e B%)I~r literal 0 HcmV?d00001 diff --git a/app/src/main/res/drawable-mdpi/ic_tachiyomi_icon.png b/app/src/main/res/drawable-mdpi/ic_tachiyomi_icon.png new file mode 100644 index 0000000000000000000000000000000000000000..60a1e6a6e68b50ca214e2aeca92400082a095c29 GIT binary patch literal 597 zcmV-b0;>IqP)iD-k1K5*kKS;V(XKh_T z=)M5+lhZqr`u-Up9NGR1bWIyz`!p~U_yPQ`*xe8?FWFxKBk4U(XCR)jelGA*()pO5 z2$Ah)!0I~3uA#XiY4?8zJOH|ZU%;Pq>>8VGL?I8+EZ~-;eN89GJ=u;}ZUqiV+S`g^ z`wY+vTn6q*`d-#fN>ke#fvdoZB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