mirror of
https://github.com/tachiyomiorg/tachiyomi.git
synced 2024-11-05 01:15:14 +01:00
Add app's notification icon
This commit is contained in:
parent
7971b64d57
commit
8fc467652d
@ -5,6 +5,8 @@ import android.app.Service
|
||||
import android.content.BroadcastReceiver
|
||||
import android.content.Context
|
||||
import android.content.Intent
|
||||
import android.graphics.Bitmap
|
||||
import android.graphics.BitmapFactory
|
||||
import android.os.IBinder
|
||||
import android.os.PowerManager
|
||||
import android.support.v4.app.NotificationCompat
|
||||
@ -71,6 +73,8 @@ class LibraryUpdateService : Service() {
|
||||
private val notificationId: Int
|
||||
get() = Constants.NOTIFICATION_LIBRARY_ID
|
||||
|
||||
private var notificationBitmap: Bitmap? = null
|
||||
|
||||
companion object {
|
||||
|
||||
/**
|
||||
@ -137,6 +141,8 @@ class LibraryUpdateService : Service() {
|
||||
*/
|
||||
override fun onDestroy() {
|
||||
subscription?.unsubscribe()
|
||||
notificationBitmap?.recycle()
|
||||
notificationBitmap = null
|
||||
LibraryUpdateAlarm.startAlarm(this)
|
||||
destroyWakeLock()
|
||||
super.onDestroy()
|
||||
@ -160,6 +166,10 @@ class LibraryUpdateService : Service() {
|
||||
override fun onStartCommand(intent: Intent?, flags: Int, startId: Int): Int {
|
||||
if (intent == null) return Service.START_NOT_STICKY
|
||||
|
||||
if (notificationBitmap == null) {
|
||||
notificationBitmap = BitmapFactory.decodeResource(resources, R.mipmap.ic_launcher)
|
||||
}
|
||||
|
||||
// Unsubscribe from any previous subscription if needed.
|
||||
subscription?.unsubscribe()
|
||||
|
||||
@ -369,7 +379,8 @@ class LibraryUpdateService : Service() {
|
||||
*/
|
||||
private fun showNotification(title: String, body: String) {
|
||||
notificationManager.notify(notificationId, notification() {
|
||||
setSmallIcon(R.drawable.ic_refresh_white_24dp_img)
|
||||
setSmallIcon(R.drawable.notification_icon)
|
||||
setLargeIcon(notificationBitmap)
|
||||
setContentTitle(title)
|
||||
setContentText(body)
|
||||
})
|
||||
@ -384,7 +395,8 @@ class LibraryUpdateService : Service() {
|
||||
*/
|
||||
private fun showProgressNotification(manga: Manga, current: Int, total: Int, cancelIntent: PendingIntent) {
|
||||
notificationManager.notify(notificationId, notification() {
|
||||
setSmallIcon(R.drawable.ic_refresh_white_24dp_img)
|
||||
setSmallIcon(R.drawable.notification_icon)
|
||||
setLargeIcon(notificationBitmap)
|
||||
setContentTitle(manga.title)
|
||||
setProgress(total, current, false)
|
||||
setOngoing(true)
|
||||
@ -404,7 +416,8 @@ class LibraryUpdateService : Service() {
|
||||
val body = getUpdatedMangasBody(updates, failed)
|
||||
|
||||
notificationManager.notify(notificationId, notification() {
|
||||
setSmallIcon(R.drawable.ic_refresh_white_24dp_img)
|
||||
setSmallIcon(R.drawable.notification_icon)
|
||||
setLargeIcon(notificationBitmap)
|
||||
setContentTitle(title)
|
||||
setStyle(NotificationCompat.BigTextStyle().bigText(body))
|
||||
setContentIntent(notificationIntent)
|
||||
|
BIN
app/src/main/res/drawable-hdpi/notification_icon.png
Normal file
BIN
app/src/main/res/drawable-hdpi/notification_icon.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 554 B |
BIN
app/src/main/res/drawable-mdpi/notification_icon.png
Normal file
BIN
app/src/main/res/drawable-mdpi/notification_icon.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 403 B |
BIN
app/src/main/res/drawable-xhdpi/notification_icon.png
Normal file
BIN
app/src/main/res/drawable-xhdpi/notification_icon.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 754 B |
BIN
app/src/main/res/drawable-xxhdpi/notification_icon.png
Normal file
BIN
app/src/main/res/drawable-xxhdpi/notification_icon.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.1 KiB |
Loading…
Reference in New Issue
Block a user