Show confirmation dialog before restore app

This commit is contained in:
canyie 2022-01-21 01:02:55 -08:00 committed by John Wu
parent 47545b45b8
commit 454e5dfc5d
5 changed files with 28 additions and 1 deletions

View File

@ -136,6 +136,7 @@ object HideAPK {
val dialog = android.app.ProgressDialog(activity).apply {
setTitle(activity.getString(R.string.hide_app_title))
isIndeterminate = true
setCancelable(false)
show()
}
val result = withContext(Dispatchers.IO) {
@ -152,6 +153,7 @@ object HideAPK {
val dialog = android.app.ProgressDialog(activity).apply {
setTitle(activity.getString(R.string.restore_img_msg))
isIndeterminate = true
setCancelable(false)
show()
}
val apk = DynAPK.current(activity)

View File

@ -0,0 +1,22 @@
package com.topjohnwu.magisk.events.dialog
import com.topjohnwu.magisk.R
import com.topjohnwu.magisk.core.tasks.HideAPK
import com.topjohnwu.magisk.view.MagiskDialog
class RestoreAppDialog : DialogEvent() {
override fun build(dialog: MagiskDialog) {
dialog.apply {
setTitle(R.string.settings_restore_app_title)
setMessage(R.string.restore_app_confirmation)
setButton(MagiskDialog.ButtonType.POSITIVE) {
text = R.string.yes
onClick { HideAPK.restore(dialog.ownerActivity!!) }
}
setButton(MagiskDialog.ButtonType.NEGATIVE) {
text = R.string.no
}
setCancelable(true)
}
}
}

View File

@ -20,6 +20,7 @@ import com.topjohnwu.magisk.events.AddHomeIconEvent
import com.topjohnwu.magisk.events.RecreateEvent
import com.topjohnwu.magisk.events.SnackbarEvent
import com.topjohnwu.magisk.events.dialog.BiometricEvent
import com.topjohnwu.magisk.events.dialog.RestoreAppDialog
import com.topjohnwu.magisk.ktx.activity
import com.topjohnwu.magisk.utils.Utils
import com.topjohnwu.superuser.Shell
@ -104,7 +105,7 @@ class SettingsViewModel : BaseViewModel(), BaseSettingsItem.Callback {
is DenyListConfig ->
SettingsFragmentDirections.actionSettingsFragmentToDenyFragment().navigate()
is SystemlessHosts -> createHosts()
is Restore -> HideAPK.restore(view.activity)
is Restore -> RestoreAppDialog().publish()
is AddShortcut -> AddHomeIconEvent().publish()
else -> callback()
}

View File

@ -229,5 +229,6 @@
<string name="add_shortcut_msg">隐藏后应用的名字和图标可能难以识别。需要在桌面上添加具有原始名称和图标的快捷方式吗?</string>
<string name="app_not_found">找不到可处理此操作的应用</string>
<string name="reboot_apply_change">重启后生效</string>
<string name="restore_app_confirmation">即将把隐藏的 Magisk 应用恢复回原始应用,是否继续?</string>
</resources>

View File

@ -229,5 +229,6 @@
<string name="add_shortcut_msg">After hiding this app, its name and icon might become difficult to recognize. Do you want to add a pretty shortcut to the home screen?</string>
<string name="app_not_found">No app found to handle this action</string>
<string name="reboot_apply_change">Reboot to apply changes</string>
<string name="restore_app_confirmation">This will restore the hidden app back to the original app. Do you really want to do this?</string>
</resources>