mirror of
https://github.com/tachiyomiorg/tachiyomi.git
synced 2024-11-19 22:59:18 +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.BroadcastReceiver
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
import android.content.Intent
|
import android.content.Intent
|
||||||
|
import android.graphics.Bitmap
|
||||||
|
import android.graphics.BitmapFactory
|
||||||
import android.os.IBinder
|
import android.os.IBinder
|
||||||
import android.os.PowerManager
|
import android.os.PowerManager
|
||||||
import android.support.v4.app.NotificationCompat
|
import android.support.v4.app.NotificationCompat
|
||||||
@ -71,6 +73,8 @@ class LibraryUpdateService : Service() {
|
|||||||
private val notificationId: Int
|
private val notificationId: Int
|
||||||
get() = Constants.NOTIFICATION_LIBRARY_ID
|
get() = Constants.NOTIFICATION_LIBRARY_ID
|
||||||
|
|
||||||
|
private var notificationBitmap: Bitmap? = null
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -137,6 +141,8 @@ class LibraryUpdateService : Service() {
|
|||||||
*/
|
*/
|
||||||
override fun onDestroy() {
|
override fun onDestroy() {
|
||||||
subscription?.unsubscribe()
|
subscription?.unsubscribe()
|
||||||
|
notificationBitmap?.recycle()
|
||||||
|
notificationBitmap = null
|
||||||
LibraryUpdateAlarm.startAlarm(this)
|
LibraryUpdateAlarm.startAlarm(this)
|
||||||
destroyWakeLock()
|
destroyWakeLock()
|
||||||
super.onDestroy()
|
super.onDestroy()
|
||||||
@ -160,6 +166,10 @@ class LibraryUpdateService : Service() {
|
|||||||
override fun onStartCommand(intent: Intent?, flags: Int, startId: Int): Int {
|
override fun onStartCommand(intent: Intent?, flags: Int, startId: Int): Int {
|
||||||
if (intent == null) return Service.START_NOT_STICKY
|
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.
|
// Unsubscribe from any previous subscription if needed.
|
||||||
subscription?.unsubscribe()
|
subscription?.unsubscribe()
|
||||||
|
|
||||||
@ -369,7 +379,8 @@ class LibraryUpdateService : Service() {
|
|||||||
*/
|
*/
|
||||||
private fun showNotification(title: String, body: String) {
|
private fun showNotification(title: String, body: String) {
|
||||||
notificationManager.notify(notificationId, notification() {
|
notificationManager.notify(notificationId, notification() {
|
||||||
setSmallIcon(R.drawable.ic_refresh_white_24dp_img)
|
setSmallIcon(R.drawable.notification_icon)
|
||||||
|
setLargeIcon(notificationBitmap)
|
||||||
setContentTitle(title)
|
setContentTitle(title)
|
||||||
setContentText(body)
|
setContentText(body)
|
||||||
})
|
})
|
||||||
@ -384,7 +395,8 @@ class LibraryUpdateService : Service() {
|
|||||||
*/
|
*/
|
||||||
private fun showProgressNotification(manga: Manga, current: Int, total: Int, cancelIntent: PendingIntent) {
|
private fun showProgressNotification(manga: Manga, current: Int, total: Int, cancelIntent: PendingIntent) {
|
||||||
notificationManager.notify(notificationId, notification() {
|
notificationManager.notify(notificationId, notification() {
|
||||||
setSmallIcon(R.drawable.ic_refresh_white_24dp_img)
|
setSmallIcon(R.drawable.notification_icon)
|
||||||
|
setLargeIcon(notificationBitmap)
|
||||||
setContentTitle(manga.title)
|
setContentTitle(manga.title)
|
||||||
setProgress(total, current, false)
|
setProgress(total, current, false)
|
||||||
setOngoing(true)
|
setOngoing(true)
|
||||||
@ -404,7 +416,8 @@ class LibraryUpdateService : Service() {
|
|||||||
val body = getUpdatedMangasBody(updates, failed)
|
val body = getUpdatedMangasBody(updates, failed)
|
||||||
|
|
||||||
notificationManager.notify(notificationId, notification() {
|
notificationManager.notify(notificationId, notification() {
|
||||||
setSmallIcon(R.drawable.ic_refresh_white_24dp_img)
|
setSmallIcon(R.drawable.notification_icon)
|
||||||
|
setLargeIcon(notificationBitmap)
|
||||||
setContentTitle(title)
|
setContentTitle(title)
|
||||||
setStyle(NotificationCompat.BigTextStyle().bigText(body))
|
setStyle(NotificationCompat.BigTextStyle().bigText(body))
|
||||||
setContentIntent(notificationIntent)
|
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