mirror of
https://github.com/YTVanced/VancedManager
synced 2024-11-27 13:33:00 +00:00
testing
This commit is contained in:
parent
2dacfb0616
commit
b569ec6bd5
2 changed files with 9 additions and 9 deletions
|
@ -9,9 +9,8 @@ import com.downloader.PRDownloader
|
||||||
class DownloadBroadcastReceiver: BroadcastReceiver() {
|
class DownloadBroadcastReceiver: BroadcastReceiver() {
|
||||||
|
|
||||||
override fun onReceive(context: Context?, intent: Intent?) {
|
override fun onReceive(context: Context?, intent: Intent?) {
|
||||||
val tag: Int? = intent?.getIntExtra("dwnldId", 0)
|
val tag: Int? = intent?.getIntExtra("tag", 0)
|
||||||
PRDownloader.cancel(tag)
|
PRDownloader.cancel(tag)
|
||||||
Log.d("VMNotification", "Canceled ${intent?.getIntExtra("dwnldId", 0)} download")
|
Log.d("VMNotification", "Canceled $tag download")
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -17,29 +17,30 @@ object NotificationHelper {
|
||||||
val notifChannel = NotificationChannel(
|
val notifChannel = NotificationChannel(
|
||||||
"69420",
|
"69420",
|
||||||
context.getString(R.string.notif_channel_name),
|
context.getString(R.string.notif_channel_name),
|
||||||
NotificationManager.IMPORTANCE_LOW
|
NotificationManager.IMPORTANCE_HIGH
|
||||||
)
|
)
|
||||||
val notificationManager = context.getSystemService(Context.NOTIFICATION_SERVICE) as NotificationManager
|
val notificationManager = context.getSystemService(Context.NOTIFICATION_SERVICE) as NotificationManager
|
||||||
notificationManager.createNotificationChannel(notifChannel)
|
notificationManager.createNotificationChannel(notifChannel)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun displayDownloadNotif(channel: Int, progress:Int, filename: String, downId: Int, context: Context) {
|
fun displayDownloadNotif(channel: Int, progress:Int, filename: String, tag: Int, context: Context) {
|
||||||
val notifBuilder =
|
val notifBuilder =
|
||||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O)
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O)
|
||||||
Notification.Builder(context, channel.toString()).setChannelId("69420")
|
Notification.Builder(context, channel.toString()).setChannelId("69420")
|
||||||
else
|
else
|
||||||
Notification.Builder(context).setPriority(Notification.PRIORITY_LOW)
|
Notification.Builder(context).setPriority(Notification.PRIORITY_HIGH)
|
||||||
|
|
||||||
|
val cancelDownload = Intent(context, DownloadBroadcastReceiver::class.java)
|
||||||
|
cancelDownload.putExtra("tag", tag)
|
||||||
|
|
||||||
val cancelDownload = Intent(context, DownloadBroadcastReceiver::class.java).apply {
|
|
||||||
putExtra("dwnldId", downId)
|
|
||||||
}
|
|
||||||
val cancelPendingIntent = PendingIntent.getBroadcast(context, 0, cancelDownload, PendingIntent.FLAG_UPDATE_CURRENT)
|
val cancelPendingIntent = PendingIntent.getBroadcast(context, 0, cancelDownload, PendingIntent.FLAG_UPDATE_CURRENT)
|
||||||
|
|
||||||
notifBuilder.apply {
|
notifBuilder.apply {
|
||||||
setContentTitle(context.getString(R.string.app_name))
|
setContentTitle(context.getString(R.string.app_name))
|
||||||
setContentText(context.getString(R.string.downloading_file, filename))
|
setContentText(context.getString(R.string.downloading_file, filename))
|
||||||
setSmallIcon(R.drawable.ic_stat_name)
|
setSmallIcon(R.drawable.ic_stat_name)
|
||||||
|
setOnlyAlertOnce(true)
|
||||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M)
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M)
|
||||||
addAction(Notification.Action.Builder(null, context.getString(R.string.cancel), cancelPendingIntent).build())
|
addAction(Notification.Action.Builder(null, context.getString(R.string.cancel), cancelPendingIntent).build())
|
||||||
else
|
else
|
||||||
|
|
Loading…
Reference in a new issue