From 6fbc38d764ddc031c99b0419a81e4cb06daeb677 Mon Sep 17 00:00:00 2001 From: topjohnwu Date: Sat, 29 Feb 2020 02:04:31 -0800 Subject: [PATCH] Add more notice/messages --- .../main/java/com/topjohnwu/magisk/core/Hacks.kt | 2 -- .../events/dialog/SecondSlotWarningDialog.kt | 16 ++++++++++++++++ .../magisk/ui/install/InstallViewModel.kt | 13 +++++++++++-- 3 files changed, 27 insertions(+), 4 deletions(-) create mode 100644 app/src/main/java/com/topjohnwu/magisk/model/events/dialog/SecondSlotWarningDialog.kt diff --git a/app/src/main/java/com/topjohnwu/magisk/core/Hacks.kt b/app/src/main/java/com/topjohnwu/magisk/core/Hacks.kt index 8e5472b56..ef9784d05 100644 --- a/app/src/main/java/com/topjohnwu/magisk/core/Hacks.kt +++ b/app/src/main/java/com/topjohnwu/magisk/core/Hacks.kt @@ -161,12 +161,10 @@ object ClassMap { * being removed when running "remove unused resources" */ val shouldKeepResources = listOf( /* TODO: The following strings should be used somewhere */ - R.string.patch_file_msg, R.string.no_apps_found, R.string.no_info_provided, R.string.release_notes, R.string.settings_download_path_error, - R.string.install_inactive_slot_msg, R.string.invalid_update_channel, R.string.update_available ) diff --git a/app/src/main/java/com/topjohnwu/magisk/model/events/dialog/SecondSlotWarningDialog.kt b/app/src/main/java/com/topjohnwu/magisk/model/events/dialog/SecondSlotWarningDialog.kt new file mode 100644 index 000000000..150afa28a --- /dev/null +++ b/app/src/main/java/com/topjohnwu/magisk/model/events/dialog/SecondSlotWarningDialog.kt @@ -0,0 +1,16 @@ +package com.topjohnwu.magisk.model.events.dialog + +import com.topjohnwu.magisk.R +import com.topjohnwu.magisk.view.MagiskDialog + +class SecondSlotWarningDialog : DialogEvent() { + + override fun build(dialog: MagiskDialog) { + dialog.applyTitle(android.R.string.dialog_alert_title) + .applyMessage(R.string.install_inactive_slot_msg) + .applyButton(MagiskDialog.ButtonType.POSITIVE) { + titleRes = android.R.string.ok + } + .cancellable(true) + } +} diff --git a/app/src/main/java/com/topjohnwu/magisk/ui/install/InstallViewModel.kt b/app/src/main/java/com/topjohnwu/magisk/ui/install/InstallViewModel.kt index 1f84e1ca6..2d8fa4110 100644 --- a/app/src/main/java/com/topjohnwu/magisk/ui/install/InstallViewModel.kt +++ b/app/src/main/java/com/topjohnwu/magisk/ui/install/InstallViewModel.kt @@ -1,14 +1,17 @@ package com.topjohnwu.magisk.ui.install import android.net.Uri +import android.widget.Toast import com.topjohnwu.magisk.R import com.topjohnwu.magisk.core.Info import com.topjohnwu.magisk.core.download.DownloadService import com.topjohnwu.magisk.core.download.RemoteFileService +import com.topjohnwu.magisk.core.utils.Utils import com.topjohnwu.magisk.extensions.addOnPropertyChangedCallback import com.topjohnwu.magisk.model.entity.internal.Configuration import com.topjohnwu.magisk.model.entity.internal.DownloadSubject import com.topjohnwu.magisk.model.events.RequestFileEvent +import com.topjohnwu.magisk.model.events.dialog.SecondSlotWarningDialog import com.topjohnwu.magisk.ui.base.BaseViewModel import com.topjohnwu.magisk.utils.KObservableField import com.topjohnwu.superuser.Shell @@ -41,8 +44,14 @@ class InstallViewModel : BaseViewModel(State.LOADED) { } } method.addOnPropertyChangedCallback { - if (method.value == R.id.method_patch) { - RequestFileEvent().publish() + when (method.value) { + R.id.method_patch -> { + Utils.toast(R.string.patch_file_msg, Toast.LENGTH_LONG) + RequestFileEvent().publish() + } + R.id.method_inactive_slot -> { + SecondSlotWarningDialog().publish() + } } } }