Skip to content
This repository has been archived by the owner on Jul 7, 2024. It is now read-only.

Commit

Permalink
Fix downloads not working on Android 14
Browse files Browse the repository at this point in the history
  • Loading branch information
wingio committed Sep 4, 2023
1 parent d4fe3b4 commit 393a894
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 6 deletions.
4 changes: 2 additions & 2 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ android {
applicationId = "dev.beefers.vendetta.manager"
minSdk = 28
targetSdk = 34
versionCode = 1089
versionName = "1.0.89"
versionCode = 1090
versionName = "1.0.9"

buildConfigField("String", "GIT_BRANCH", "\"${getCurrentBranch()}\"")
buildConfigField("String", "GIT_COMMIT", "\"${getLatestCommit()}\"")
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
package dev.beefers.vendetta.manager.domain.manager

import android.annotation.SuppressLint
import android.app.DownloadManager
import android.content.BroadcastReceiver
import android.content.Context
import android.content.Intent
import android.content.IntentFilter
import android.os.Build
import androidx.core.content.getSystemService
import androidx.core.net.toUri
import dev.beefers.vendetta.manager.BuildConfig
Expand Down Expand Up @@ -97,10 +99,19 @@ class DownloadManager(
}
}

context.registerReceiver(
receiver,
IntentFilter(DownloadManager.ACTION_DOWNLOAD_COMPLETE)
)
@SuppressLint("UnspecifiedRegisterReceiverFlag")
if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) {
context.registerReceiver(
receiver,
IntentFilter(DownloadManager.ACTION_DOWNLOAD_COMPLETE),
Context.RECEIVER_EXPORTED
)
} else {
context.registerReceiver(
receiver,
IntentFilter(DownloadManager.ACTION_DOWNLOAD_COMPLETE)
)
}

receiver.downloadId = DownloadManager.Request(url.toUri()).run {
setTitle("Vendetta Manager: Downloading ${out.name}")
Expand Down

0 comments on commit 393a894

Please sign in to comment.