From 40f971d18aea1711d915fd30dc79a318dc01449b Mon Sep 17 00:00:00 2001 From: topjohnwu Date: Sat, 15 Feb 2020 21:57:03 -0800 Subject: [PATCH] Add entrypoint for testing Should do it with proper unit test, but duh --- .../com/topjohnwu/magisk/ui/home/HomeViewModel.kt | 9 +++++++++ app/src/main/res/layout/fragment_home_md2.xml | 11 +++++++++++ 2 files changed, 20 insertions(+) diff --git a/app/src/main/java/com/topjohnwu/magisk/ui/home/HomeViewModel.kt b/app/src/main/java/com/topjohnwu/magisk/ui/home/HomeViewModel.kt index dfe57420f..ab9696973 100644 --- a/app/src/main/java/com/topjohnwu/magisk/ui/home/HomeViewModel.kt +++ b/app/src/main/java/com/topjohnwu/magisk/ui/home/HomeViewModel.kt @@ -6,6 +6,7 @@ import com.topjohnwu.magisk.BuildConfig import com.topjohnwu.magisk.R import com.topjohnwu.magisk.core.Config import com.topjohnwu.magisk.core.Info +import com.topjohnwu.magisk.core.base.BaseActivity import com.topjohnwu.magisk.core.download.RemoteFileService import com.topjohnwu.magisk.core.model.MagiskJson import com.topjohnwu.magisk.core.model.ManagerJson @@ -16,7 +17,9 @@ import com.topjohnwu.magisk.model.entity.internal.DownloadSubject.Magisk import com.topjohnwu.magisk.model.entity.internal.DownloadSubject.Manager import com.topjohnwu.magisk.model.entity.recycler.DeveloperItem import com.topjohnwu.magisk.model.entity.recycler.HomeItem +import com.topjohnwu.magisk.model.events.ActivityExecutor import com.topjohnwu.magisk.model.events.OpenInappLinkEvent +import com.topjohnwu.magisk.model.events.ViewEvent import com.topjohnwu.magisk.model.events.dialog.EnvFixDialog import com.topjohnwu.magisk.model.events.dialog.ManagerInstallDialog import com.topjohnwu.magisk.model.events.dialog.UninstallDialog @@ -97,6 +100,12 @@ class HomeViewModel( ensureEnv() } + fun onTestPressed() = object : ViewEvent(), ActivityExecutor { + override fun invoke(activity: BaseActivity) { + /* Entry point to trigger test events within the app */ + } + }.publish() + fun onLinkPressed(link: String) = OpenInappLinkEvent(link).publish() fun onDeletePressed() = UninstallDialog().publish() diff --git a/app/src/main/res/layout/fragment_home_md2.xml b/app/src/main/res/layout/fragment_home_md2.xml index 5b1b4be11..18db61566 100644 --- a/app/src/main/res/layout/fragment_home_md2.xml +++ b/app/src/main/res/layout/fragment_home_md2.xml @@ -27,6 +27,17 @@ android:orientation="vertical" android:paddingTop="@dimen/l1"> + +