Skip to content

Commit d46f002

Browse files
committed
fix: Showing progress if downloading an APK + minor fixes
1 parent dbc64e5 commit d46f002

File tree

9 files changed

+23
-275
lines changed

9 files changed

+23
-275
lines changed

β€ŽREADME.mdβ€Ž

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,15 +72,15 @@ The collection of ReVanced downloaders.
7272
- The downloader will now be usable.
7373

7474

75-
### APMMirror Downloader
75+
### APKMirror Downloader
7676
This downloader will open an [APKMirror](https://www.apkmirror.com/) page where you can download the apk as you would normally do.
7777
If the chosen file is a bundle (.apkm file), the downloader will automatically merge it into a .apk file.
7878

7979
### Play Store Downloader
8080
When you get prompted, log in to Google with your account. After that, you will be able to download apps from the Play Store.
8181

8282
> [!WARNING]
83-
> Due to technical limitations, it is only possible to download the latest version of the app. If the ReVanced suggested version differs from the latest, the installation will fail.
83+
> Due to technical limitations, it is only possible to download the latest version of the app. If the suggested version differs from the latest, the installation will fail.
8484
8585
## πŸ“š Everything else
8686

β€Ždownloaders/apkmirror-downloader/src/main/kotlin/app/revanced/manager/plugin/downloader/apkmirror/APKMirrorDownloader.ktβ€Ž

Lines changed: 21 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -15,15 +15,15 @@ import kotlinx.parcelize.Parcelize
1515
import java.io.File
1616
import java.net.URI
1717
import java.nio.file.Files
18+
import java.util.UUID
1819
import java.util.zip.ZipFile
1920
import kotlin.io.path.ExperimentalPathApi
2021
import kotlin.io.path.deleteRecursively
2122
import kotlin.io.path.outputStream
2223

2324
@Parcelize
2425
class ApkMirrorApp(
25-
val downloadUrl: DownloadUrl,
26-
val packageName: String
26+
val downloadUrl: DownloadUrl
2727
) : Parcelable
2828

2929
private object ArscLogger : APKLogger {
@@ -56,37 +56,33 @@ val ApkMirrorDownloader = Downloader<ApkMirrorApp> {
5656
)
5757
}
5858

59-
with(Uri.Builder()) {
60-
scheme("https")
61-
authority("www.apkmirror.com")
62-
mapOf(
63-
"post_type" to "app_release",
64-
"searchtype" to "apk",
65-
"s" to (version?.let { "$packageName $it" } ?: packageName),
66-
"bundles%5B%5D" to "apk_files" // bundles[]
67-
).forEach { (key, value) ->
68-
appendQueryParameter(key, value)
69-
}
70-
71-
build().toString()
72-
}
73-
},
74-
packageName = packageName
59+
Uri.Builder()
60+
.scheme("https")
61+
.authority("www.apkmirror.com")
62+
.appendQueryParameter("post_type", "app_release")
63+
.appendQueryParameter("searchtype", "apk")
64+
.appendQueryParameter("s", version?.let { "$packageName $it" } ?: packageName)
65+
.appendQueryParameter("bundles%5B%5D" /* bundles[] */, "apk_files")
66+
.toString()
67+
}
7568
) to version
7669
}
7770

7871
download { app, outputStream ->
7972
val workingDir = Files.createTempDirectory("apkmirror_dl")
80-
val downloadedFile = workingDir.resolve("${app.packageName}.apk").also {
81-
it.outputStream().use { output ->
82-
app.downloadUrl.toDownloadResult().first.copyTo(output)
83-
}
84-
}
85-
8673
try {
8774
if (URI(app.downloadUrl.url).path.substringAfterLast('/').endsWith(".apk")) {
88-
Files.copy(downloadedFile, outputStream)
75+
val (inputStream, size) = app.downloadUrl.toDownloadResult()
76+
inputStream.use {
77+
if (size != null) reportSize(size)
78+
it.copyTo(outputStream)
79+
}
8980
} else {
81+
val downloadedFile = workingDir.resolve(UUID.randomUUID().toString()).also {
82+
it.outputStream().use { output ->
83+
app.downloadUrl.toDownloadResult().first.copyTo(output)
84+
}
85+
}
9086
val xapkWorkingDir = workingDir.resolve("xapk").also { it.toFile().mkdirs() }
9187

9288
ZipFile(downloadedFile.toString()).use { zip ->

β€Žsrc/main/AndroidManifest.xmlβ€Ž

Lines changed: 0 additions & 16 deletions
This file was deleted.

β€Žsrc/main/kotlin/app/revanced/manager/plugin/downloader/apkmirror/APKMirrorDownloader.ktβ€Ž

Lines changed: 0 additions & 17 deletions
This file was deleted.

β€Žsrc/main/res/drawable/ic_launcher_background.xmlβ€Ž

Lines changed: 0 additions & 170 deletions
This file was deleted.

β€Žsrc/main/res/drawable/ic_launcher_foreground.xmlβ€Ž

Lines changed: 0 additions & 30 deletions
This file was deleted.

β€Žsrc/main/res/mipmap-anydpi/ic_launcher.xmlβ€Ž

Lines changed: 0 additions & 6 deletions
This file was deleted.

β€Žsrc/main/res/mipmap-anydpi/ic_launcher_round.xmlβ€Ž

Lines changed: 0 additions & 6 deletions
This file was deleted.

β€Žsrc/main/res/values/strings.xmlβ€Ž

Lines changed: 0 additions & 3 deletions
This file was deleted.

0 commit comments

Comments
Β (0)