From 0dcd3ece9d36278ac2e755f2dc60bb654894ae71 Mon Sep 17 00:00:00 2001 From: Viktor De Pasquale Date: Wed, 10 Jul 2019 19:36:01 +0200 Subject: [PATCH] Updated downloading modules --- .../magisk/ui/module/ReposFragment.kt | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/app/src/main/java/com/topjohnwu/magisk/ui/module/ReposFragment.kt b/app/src/main/java/com/topjohnwu/magisk/ui/module/ReposFragment.kt index a6f915bde..fc01b8152 100644 --- a/app/src/main/java/com/topjohnwu/magisk/ui/module/ReposFragment.kt +++ b/app/src/main/java/com/topjohnwu/magisk/ui/module/ReposFragment.kt @@ -1,19 +1,19 @@ package com.topjohnwu.magisk.ui.module +import android.annotation.SuppressLint import android.app.AlertDialog -import android.content.Intent -import android.os.Build import android.view.Menu import android.view.MenuInflater import android.view.MenuItem import android.widget.SearchView import com.skoumal.teanity.viewevents.ViewEvent -import com.topjohnwu.magisk.ClassMap import com.topjohnwu.magisk.Config import com.topjohnwu.magisk.R 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.internal.Configuration +import com.topjohnwu.magisk.model.entity.internal.DownloadSubject import com.topjohnwu.magisk.model.events.InstallModuleEvent import com.topjohnwu.magisk.model.events.OpenChangelogEvent import com.topjohnwu.magisk.ui.base.MagiskFragment @@ -92,19 +92,16 @@ class ReposFragment : MagiskFragment(), MarkDownWindow.show(requireActivity(), null, item.detailUrl) } + @SuppressLint("MissingPermission") private fun installModule(item: Repo) { val context = magiskActivity fun download(install: Boolean) { context.withExternalRW { onSuccess { - val intent = Intent(activity, ClassMap[DownloadModuleService::class.java]) - .putExtra("repo", item).putExtra("install", install) - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { - context.startForegroundService(intent) - } else { - context.startService(intent) - } + val config = if (install) Configuration.Flash() else Configuration.Download + val subject = DownloadSubject.Module(item, config) + CompoundDownloadService.download(context, subject) } } }