From c5e5b70e08a743497f24fb6a77eb372fd40de522 Mon Sep 17 00:00:00 2001 From: Viktor De Pasquale Date: Tue, 21 Jan 2020 22:01:55 +0100 Subject: [PATCH] Added safe mode notice to modules --- .../topjohnwu/magisk/ui/module/ModuleViewModel.kt | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/app/src/main/java/com/topjohnwu/magisk/ui/module/ModuleViewModel.kt b/app/src/main/java/com/topjohnwu/magisk/ui/module/ModuleViewModel.kt index 7c9528c10..97c04cf19 100644 --- a/app/src/main/java/com/topjohnwu/magisk/ui/module/ModuleViewModel.kt +++ b/app/src/main/java/com/topjohnwu/magisk/ui/module/ModuleViewModel.kt @@ -81,12 +81,14 @@ class ModuleViewModel( it.add(itemNoneUpdatable) } + private val itemsCoreOnly = ObservableArrayList() private val itemsInstalled = diffListOf() private val itemsUpdatable = diffListOf() private val itemsRemote = diffListOf() val adapter = adapterOf>() val items = MergeObservableList>() + .insertList(itemsCoreOnly) .insertItem(sectionActive) .insertList(itemsInstalledHelpers) .insertList(itemsInstalled) @@ -159,6 +161,7 @@ class ModuleViewModel( // --- override fun refresh(): Disposable { + updateCoreOnlyWarning() if (itemsRemote.isEmpty()) loadRemote() return loadInstalled().subscribeK() @@ -268,6 +271,15 @@ class ModuleViewModel( .subscribeK { it.progress.value = progress } .add() + private fun updateCoreOnlyWarning() { + if (Config.coreOnly) { + if (itemsCoreOnly.isNotEmpty()) return + itemsCoreOnly.add(SafeModeNotice) + } else { + itemsCoreOnly.clear() + } + } + // --- @WorkerThread