Skip to content

Commit

Permalink
set large image for chapter update & save image notification
Browse files Browse the repository at this point in the history
  • Loading branch information
cuong-tran committed Jan 7, 2025
1 parent a352872 commit cce38e2
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@ import androidx.core.content.ContextCompat
import coil3.asDrawable
import coil3.imageLoader
import coil3.request.ImageRequest
import coil3.request.transformations
import coil3.transform.CircleCropTransformation
import eu.kanade.presentation.util.formatChapterNumber
import eu.kanade.tachiyomi.R
import eu.kanade.tachiyomi.core.security.SecurityPreferences
Expand Down Expand Up @@ -242,13 +240,23 @@ class LibraryUpdateNotifier(

val description = getNewChaptersDescription(chapters)
setContentText(description)
setStyle(NotificationCompat.BigTextStyle().bigText(description))

setSmallIcon(R.drawable.ic_komikku)
setColor(ContextCompat.getColor(context, R.color.ic_launcher))

if (icon != null) {
setLargeIcon(icon)
// KMK -->
setStyle(
NotificationCompat.BigPictureStyle()
.bigPicture(icon)
.bigLargeIcon(notificationBitmap)
.setBigContentTitle(manga.title)
.setSummaryText(description),
)
// KMK <--
} else {
setStyle(NotificationCompat.BigTextStyle().bigText(description))
}

setGroup(Notifications.GROUP_NEW_CHAPTERS)
Expand Down Expand Up @@ -307,8 +315,10 @@ class LibraryUpdateNotifier(
private suspend fun getMangaIcon(manga: Manga): Bitmap? {
val request = ImageRequest.Builder(context)
.data(manga)
.transformations(CircleCropTransformation())
.size(NOTIF_ICON_SIZE)
// KMK -->
// .transformations(CircleCropTransformation())
// .size(NOTIF_ICON_SIZE)
// KMK <--
.build()
val drawable = context.imageLoader.execute(request).image?.asDrawable(context.resources)
return drawable?.getBitmapOrNull()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,14 +56,25 @@ class SaveImageNotifier(private val context: Context) {
context.cancelNotification(notificationId)
}

// KMK -->
/**
* Bitmap of the app for notifications.
*/
private val notificationBitmap by lazy {
BitmapFactory.decodeResource(context.resources, R.drawable.komikku)
}
// KMK <--

/**
* Called on error while downloading image.
* @param error string containing error information.
*/
fun onError(error: String?) {
// Create notification
with(notificationBuilder) {
setLargeIcon(BitmapFactory.decodeResource(context.resources, R.drawable.komikku))
// KMK -->
setLargeIcon(notificationBitmap)
// KMK <--
setContentTitle(context.stringResource(MR.strings.download_notifier_title_error))
setContentText(error ?: context.stringResource(MR.strings.unknown_error))
setSmallIcon(android.R.drawable.ic_menu_report_image)
Expand All @@ -75,8 +86,17 @@ class SaveImageNotifier(private val context: Context) {
with(notificationBuilder) {
setContentTitle(context.stringResource(MR.strings.picture_saved))
setSmallIcon(R.drawable.ic_photo_24dp)
image?.let { setStyle(NotificationCompat.BigPictureStyle().bigPicture(it)) }
setLargeIcon(image)
image?.let {
setStyle(
NotificationCompat.BigPictureStyle()
// KMK -->
.bigLargeIcon(notificationBitmap)
.setBigContentTitle(context.stringResource(MR.strings.picture_saved))
// KMK <--
.bigPicture(it),
)
setLargeIcon(image)
}
setAutoCancel(true)

// Clear old actions if they exist
Expand Down

0 comments on commit cce38e2

Please sign in to comment.