Commit 0dcd3ece authored by Viktor De Pasquale's avatar Viktor De Pasquale Committed by John Wu

Updated downloading modules

parent 224fff89
package com.topjohnwu.magisk.ui.module package com.topjohnwu.magisk.ui.module
import android.annotation.SuppressLint
import android.app.AlertDialog import android.app.AlertDialog
import android.content.Intent
import android.os.Build
import android.view.Menu import android.view.Menu
import android.view.MenuInflater import android.view.MenuInflater
import android.view.MenuItem import android.view.MenuItem
import android.widget.SearchView import android.widget.SearchView
import com.skoumal.teanity.viewevents.ViewEvent import com.skoumal.teanity.viewevents.ViewEvent
import com.topjohnwu.magisk.ClassMap
import com.topjohnwu.magisk.Config import com.topjohnwu.magisk.Config
import com.topjohnwu.magisk.R import com.topjohnwu.magisk.R
import com.topjohnwu.magisk.databinding.FragmentReposBinding import com.topjohnwu.magisk.databinding.FragmentReposBinding
import com.topjohnwu.magisk.model.download.DownloadModuleService import com.topjohnwu.magisk.model.download.CompoundDownloadService
import com.topjohnwu.magisk.model.entity.Repo import com.topjohnwu.magisk.model.entity.Repo
import com.topjohnwu.magisk.model.entity.internal.Configuration
import com.topjohnwu.magisk.model.entity.internal.DownloadSubject
import com.topjohnwu.magisk.model.events.InstallModuleEvent import com.topjohnwu.magisk.model.events.InstallModuleEvent
import com.topjohnwu.magisk.model.events.OpenChangelogEvent import com.topjohnwu.magisk.model.events.OpenChangelogEvent
import com.topjohnwu.magisk.ui.base.MagiskFragment import com.topjohnwu.magisk.ui.base.MagiskFragment
...@@ -92,19 +92,16 @@ class ReposFragment : MagiskFragment<ModuleViewModel, FragmentReposBinding>(), ...@@ -92,19 +92,16 @@ class ReposFragment : MagiskFragment<ModuleViewModel, FragmentReposBinding>(),
MarkDownWindow.show(requireActivity(), null, item.detailUrl) MarkDownWindow.show(requireActivity(), null, item.detailUrl)
} }
@SuppressLint("MissingPermission")
private fun installModule(item: Repo) { private fun installModule(item: Repo) {
val context = magiskActivity val context = magiskActivity
fun download(install: Boolean) { fun download(install: Boolean) {
context.withExternalRW { context.withExternalRW {
onSuccess { onSuccess {
val intent = Intent(activity, ClassMap[DownloadModuleService::class.java]) val config = if (install) Configuration.Flash() else Configuration.Download
.putExtra("repo", item).putExtra("install", install) val subject = DownloadSubject.Module(item, config)
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { CompoundDownloadService.download(context, subject)
context.startForegroundService(intent)
} else {
context.startService(intent)
}
} }
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment