mirror of
https://github.com/topjohnwu/Magisk.git
synced 2025-01-11 19:53:37 +00:00
Show confirm dialog when installing local module
It can avoid miss click Co-authored-by: 南宫雪珊 <vvb2060@gmail.com>
This commit is contained in:
parent
97731a519a
commit
aa785b5845
@ -0,0 +1,32 @@
|
||||
package com.topjohnwu.magisk.events.dialog
|
||||
|
||||
import android.net.Uri
|
||||
import com.topjohnwu.magisk.MainDirections
|
||||
import com.topjohnwu.magisk.R
|
||||
import com.topjohnwu.magisk.core.Const
|
||||
import com.topjohnwu.magisk.core.utils.MediaStoreUtils.displayName
|
||||
import com.topjohnwu.magisk.ui.module.ModuleViewModel
|
||||
import com.topjohnwu.magisk.view.MagiskDialog
|
||||
|
||||
class ConfirmInstallLocalModuleDialog(
|
||||
private val viewModel: ModuleViewModel,
|
||||
private val uri: Uri
|
||||
) : DialogEvent() {
|
||||
override fun build(dialog: MagiskDialog) {
|
||||
dialog.apply {
|
||||
setTitle(R.string.confirm_install_title)
|
||||
setMessage(context.getString(R.string.confirm_install, uri.displayName))
|
||||
setButton(MagiskDialog.ButtonType.POSITIVE) {
|
||||
text = android.R.string.ok
|
||||
onClick {
|
||||
viewModel.apply {
|
||||
MainDirections.actionFlashFragment(Const.Value.FLASH_ZIP, uri).navigate()
|
||||
}
|
||||
}
|
||||
}
|
||||
setButton(MagiskDialog.ButtonType.NEGATIVE) {
|
||||
text = android.R.string.cancel
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -2,11 +2,9 @@ package com.topjohnwu.magisk.ui.module
|
||||
|
||||
import android.os.Bundle
|
||||
import android.view.View
|
||||
import com.topjohnwu.magisk.MainDirections
|
||||
import com.topjohnwu.magisk.R
|
||||
import com.topjohnwu.magisk.arch.BaseFragment
|
||||
import com.topjohnwu.magisk.arch.viewModel
|
||||
import com.topjohnwu.magisk.core.Const
|
||||
import com.topjohnwu.magisk.databinding.FragmentModuleMd2Binding
|
||||
import rikka.recyclerview.addEdgeSpacing
|
||||
import rikka.recyclerview.addInvalidateItemDecorationsObserver
|
||||
@ -23,7 +21,7 @@ class ModuleFragment : BaseFragment<FragmentModuleMd2Binding>() {
|
||||
activity?.title = resources.getString(R.string.modules)
|
||||
viewModel.data.observe(this) {
|
||||
it ?: return@observe
|
||||
MainDirections.actionFlashFragment(Const.Value.FLASH_ZIP, it).navigate()
|
||||
viewModel.requestInstallLocalModule(it)
|
||||
viewModel.data.value = null
|
||||
}
|
||||
}
|
||||
|
@ -17,6 +17,7 @@ import com.topjohnwu.magisk.databinding.bindExtra
|
||||
import com.topjohnwu.magisk.databinding.set
|
||||
import com.topjohnwu.magisk.events.GetContentEvent
|
||||
import com.topjohnwu.magisk.events.SnackbarEvent
|
||||
import com.topjohnwu.magisk.events.dialog.ConfirmInstallLocalModuleDialog
|
||||
import com.topjohnwu.magisk.events.dialog.ModuleInstallDialog
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.withContext
|
||||
@ -83,6 +84,10 @@ class ModuleViewModel : AsyncLoadViewModel() {
|
||||
GetContentEvent("application/zip", UriCallback()).publish()
|
||||
}
|
||||
|
||||
fun requestInstallLocalModule(uri: Uri) {
|
||||
ConfirmInstallLocalModuleDialog(this, uri).publish()
|
||||
}
|
||||
|
||||
@Parcelize
|
||||
class UriCallback : ContentResultCallback {
|
||||
override fun onActivityResult(result: Uri) {
|
||||
|
@ -113,6 +113,8 @@
|
||||
<string name="suspend_text_zygisk">%1$s 未启用,此模块暂停加载</string>
|
||||
<string name="zygisk_module_unloaded">存在兼容性问题,此模块未加载</string>
|
||||
<string name="module_empty">未安装任何模块</string>
|
||||
<string name="confirm_install">安装模块 %1$s?</string>
|
||||
<string name="confirm_install_title">安装确认</string>
|
||||
|
||||
<!--Settings-->
|
||||
<string name="settings_dark_mode_title">主题模式</string>
|
||||
|
@ -113,6 +113,8 @@
|
||||
<string name="suspend_text_zygisk">此模組因 %1$s 未啟用而暫停運作</string>
|
||||
<string name="zygisk_module_unloaded">此模組因不相容 Zygisk 而未載入</string>
|
||||
<string name="module_empty">未安裝任何模組</string>
|
||||
<string name="confirm_install">安裝模組 %1$s?</string>
|
||||
<string name="confirm_install_title">安裝確認</string>
|
||||
|
||||
<!--Settings -->
|
||||
<string name="settings_dark_mode_title">主題模式</string>
|
||||
|
@ -113,6 +113,8 @@
|
||||
<string name="suspend_text_zygisk">Module suspended because %1$s is not enabled</string>
|
||||
<string name="zygisk_module_unloaded">Zygisk module not loaded due to incompatibility</string>
|
||||
<string name="module_empty">No module installed</string>
|
||||
<string name="confirm_install">Install module %1$s?</string>
|
||||
<string name="confirm_install_title">Install Confirmation</string>
|
||||
|
||||
<!--Settings-->
|
||||
<string name="settings_dark_mode_title">Theme Mode</string>
|
||||
|
Loading…
x
Reference in New Issue
Block a user