Consolidate Magisk download subject
This commit is contained in:
parent
a97972aac0
commit
a8932706d8
@ -50,7 +50,6 @@ open class DownloadService : RemoteFileService() {
|
|||||||
Uninstall -> FlashActivity.uninstall(this, file)
|
Uninstall -> FlashActivity.uninstall(this, file)
|
||||||
is Patch -> FlashActivity.patch(this, file, conf.fileUri)
|
is Patch -> FlashActivity.patch(this, file, conf.fileUri)
|
||||||
is Flash -> FlashActivity.flash(this, file, conf is Secondary)
|
is Flash -> FlashActivity.flash(this, file, conf is Secondary)
|
||||||
else -> Unit
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun onFinishedInternal(
|
private fun onFinishedInternal(
|
||||||
|
@ -16,24 +16,36 @@ sealed class DownloadSubject : Parcelable {
|
|||||||
val module: Repo,
|
val module: Repo,
|
||||||
val configuration: Configuration
|
val configuration: Configuration
|
||||||
) : DownloadSubject() {
|
) : DownloadSubject() {
|
||||||
|
|
||||||
override val url: String get() = module.zipUrl
|
override val url: String get() = module.zipUrl
|
||||||
override val fileName: String get() = "${module.name}-v${module.version}(${module.versionCode}).zip"
|
override val fileName: String get() = "${module.name}-v${module.version}(${module.versionCode}).zip"
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Parcelize
|
sealed class Magisk : DownloadSubject() {
|
||||||
data class Magisk(
|
|
||||||
val configuration: Configuration,
|
|
||||||
val magisk: MagiskJson = Info.remote.magisk
|
|
||||||
) : DownloadSubject() {
|
|
||||||
|
|
||||||
override val url: String get() = magisk.link
|
abstract val configuration: Configuration
|
||||||
override val fileName get() =
|
val magisk: MagiskJson = Info.remote.magisk
|
||||||
if (configuration is Configuration.Flash)
|
|
||||||
"magisk.zip"
|
@Parcelize
|
||||||
else
|
protected data class Flash(
|
||||||
"Magisk-v${magisk.version}(${magisk.versionCode}).zip"
|
override val configuration: Configuration
|
||||||
|
) : Magisk() {
|
||||||
|
override val url: String get() = magisk.link
|
||||||
|
override val fileName get() = "magisk.zip"
|
||||||
|
}
|
||||||
|
|
||||||
|
@Parcelize
|
||||||
|
protected object Download : Magisk() {
|
||||||
|
override val configuration: Configuration get() = Configuration.Download
|
||||||
|
override val url: String get() = magisk.link
|
||||||
|
override val fileName get() = "Magisk-v${magisk.version}(${magisk.versionCode}).zip"
|
||||||
|
}
|
||||||
|
|
||||||
|
companion object {
|
||||||
|
operator fun invoke(configuration: Configuration) = when (configuration) {
|
||||||
|
Configuration.Download -> Download
|
||||||
|
else -> Flash(configuration)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user