@@ -15,6 +15,7 @@ import kotlinx.coroutines.runBlocking
1515import project.pipepipe.app.MR
1616import project.pipepipe.app.database.DatabaseOperations
1717import dev.icerock.moko.resources.desc.desc
18+ import project.pipepipe.app.MainActivity
1819
1920/* *
2021 * Foreground service for managing downloads
@@ -36,6 +37,7 @@ class DownloadService : Service() {
3637 .setSmallIcon(android.R .drawable.stat_sys_download)
3738 .setPriority(NotificationCompat .PRIORITY_LOW )
3839 .setOngoing(true )
40+ .setContentIntent(makePendingIntent(this , ACTION_OPEN_DOWNLOADS_FINISHED ))
3941 .build()
4042 startForeground(FOREGROUND_NOTIFICATION_ID , notification)
4143 isForeground = true
@@ -100,6 +102,7 @@ class DownloadService : Service() {
100102 .setSmallIcon(android.R .drawable.stat_sys_download)
101103 .setPriority(NotificationCompat .PRIORITY_LOW )
102104 .setOngoing(true )
105+ .setContentIntent(makePendingIntent(this , ACTION_OPEN_DOWNLOADS_FINISHED ))
103106 .build()
104107 startForeground(FOREGROUND_NOTIFICATION_ID , notification)
105108 isForeground = true
@@ -124,8 +127,8 @@ class DownloadService : Service() {
124127 private const val COMPLETION_NOTIFICATION_ID = 3002
125128 private const val ERROR_NOTIFICATION_BASE_ID = 3100
126129
127- private const val ACTION_RESET_DOWNLOAD_FINISHED = " project.pipepipe.reset_download_finished"
128- private const val ACTION_OPEN_DOWNLOADS_FINISHED = " project.pipepipe.open_downloads_finished"
130+ const val ACTION_RESET_DOWNLOAD_FINISHED = " project.pipepipe.reset_download_finished"
131+ const val ACTION_OPEN_DOWNLOADS_FINISHED = " project.pipepipe.open_downloads_finished"
129132
130133 private var instance: DownloadService ? = null
131134
@@ -177,13 +180,13 @@ class DownloadService : Service() {
177180 }
178181
179182 private fun makePendingIntent (context : Context , action : String ): PendingIntent {
180- val intent = Intent (context, DownloadService ::class .java).setAction(action)
183+ val intent = Intent (context, MainActivity ::class .java).setAction(action)
181184 val flags = if (Build .VERSION .SDK_INT >= Build .VERSION_CODES .M ) {
182185 PendingIntent .FLAG_IMMUTABLE or PendingIntent .FLAG_UPDATE_CURRENT
183186 } else {
184187 PendingIntent .FLAG_UPDATE_CURRENT
185188 }
186- return PendingIntent .getService (context, action.hashCode(), intent, flags)
189+ return PendingIntent .getActivity (context, action.hashCode(), intent, flags)
187190 }
188191 }
189192}
0 commit comments