Skip to content

Commit 7fa133c

Browse files
Fixed: Clicking on "No" button was not working.
* Added a `DownloadTimeoutDismissReceiver` which will listen for the "No" button event and dismiss the notification.
1 parent c7857d4 commit 7fa133c

File tree

3 files changed

+43
-2
lines changed

3 files changed

+43
-2
lines changed

core/src/main/AndroidManifest.xml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,5 +97,8 @@
9797
<service
9898
android:name=".downloader.downloadManager.DownloadMonitorService"
9999
android:foregroundServiceType="dataSync" />
100+
<receiver
101+
android:name=".downloader.downloadManager.DownloadTimeoutDismissReceiver"
102+
android:exported="false" />
100103
</application>
101104
</manifest>

core/src/main/java/org/kiwix/kiwixmobile/core/downloader/downloadManager/DownloadMonitorService.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -183,10 +183,10 @@ class DownloadMonitorService : Service() {
183183
FLAG_IMMUTABLE or FLAG_UPDATE_CURRENT
184184
)
185185

186-
val noIntent = Intent(this, javaClass).apply {
186+
val noIntent = Intent(this, DownloadTimeoutDismissReceiver::class.java).apply {
187187
action = BACKGROUND_DOWNLOAD_LIMIT_REACH_ACTION
188188
}
189-
val noPendingIntent = PendingIntent.getService(
189+
val noPendingIntent = PendingIntent.getBroadcast(
190190
this,
191191
DOWNLOAD_TIMEOUT_NOTIFICATION_NO_REQUEST_CODE,
192192
noIntent,
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
/*
2+
* Kiwix Android
3+
* Copyright (c) 2025 Kiwix <android.kiwix.org>
4+
* This program is free software: you can redistribute it and/or modify
5+
* it under the terms of the GNU General Public License as published by
6+
* the Free Software Foundation, either version 3 of the License, or
7+
* (at your option) any later version.
8+
*
9+
* This program is distributed in the hope that it will be useful,
10+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
11+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12+
* GNU General Public License for more details.
13+
*
14+
* You should have received a copy of the GNU General Public License
15+
* along with this program. If not, see <http://www.gnu.org/licenses/>.
16+
*
17+
*/
18+
19+
package org.kiwix.kiwixmobile.core.downloader.downloadManager
20+
21+
import android.app.NotificationManager
22+
import android.content.Context
23+
import android.content.Intent
24+
import org.kiwix.kiwixmobile.core.base.BaseBroadcastReceiver
25+
26+
class DownloadTimeoutDismissReceiver : BaseBroadcastReceiver() {
27+
override val action = BACKGROUND_DOWNLOAD_LIMIT_REACH_ACTION
28+
override fun onIntentWithActionReceived(
29+
context: Context,
30+
intent: Intent
31+
) {
32+
runCatching {
33+
val notificationManager =
34+
context.getSystemService(Context.NOTIFICATION_SERVICE) as NotificationManager
35+
notificationManager.cancel(DOWNLOAD_TIMEOUT_LIMIT_REACH_NOTIFICATION_ID)
36+
}
37+
}
38+
}

0 commit comments

Comments
 (0)