From 8af832a496a999e9403aa7dc219214a17a517844 Mon Sep 17 00:00:00 2001 From: Viktor De Pasquale Date: Tue, 9 Jul 2019 20:06:33 +0200 Subject: [PATCH] Added several calls to FlashActivity so it manages its launch parameters by itself Its reach will be deepened further in the future commits --- .../magisk/ui/flash/FlashActivity.kt | 26 +++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/app/src/main/java/com/topjohnwu/magisk/ui/flash/FlashActivity.kt b/app/src/main/java/com/topjohnwu/magisk/ui/flash/FlashActivity.kt index 48579b832..d3670aea8 100644 --- a/app/src/main/java/com/topjohnwu/magisk/ui/flash/FlashActivity.kt +++ b/app/src/main/java/com/topjohnwu/magisk/ui/flash/FlashActivity.kt @@ -1,11 +1,16 @@ package com.topjohnwu.magisk.ui.flash +import android.content.Context +import android.content.Intent +import androidx.core.net.toUri +import com.topjohnwu.magisk.ClassMap import com.topjohnwu.magisk.Const import com.topjohnwu.magisk.R import com.topjohnwu.magisk.databinding.ActivityFlashBinding import com.topjohnwu.magisk.ui.base.MagiskActivity import org.koin.androidx.viewmodel.ext.android.viewModel import org.koin.core.parameter.parametersOf +import java.io.File open class FlashActivity : MagiskActivity() { @@ -21,4 +26,25 @@ open class FlashActivity : MagiskActivity( super.onBackPressed() } + companion object { + + private fun intent(context: Context) = Intent(context, ClassMap[FlashActivity::class.java]) + + fun flashMagiskIntent(context: Context, file: File) = intent(context) + .setData(file.toUri()) + .putExtra(Const.Key.FLASH_ACTION, Const.Value.FLASH_MAGISK) + + fun flashMagisk(context: Context, file: File) = + context.startActivity(flashMagiskIntent(context, file)) + + + fun flashModuleIntent(context: Context, file: File) = intent(context) + .setData(file.toUri()) + .putExtra(Const.Key.FLASH_ACTION, Const.Value.FLASH_ZIP) + + fun flashModule(context: Context, file: File) = + context.startActivity(flashModuleIntent(context, file)) + + } + }