mirror of
https://github.com/topjohnwu/Magisk.git
synced 2024-12-24 12:17:38 +00:00
Correctly get displayName of live uri
This commit is contained in:
parent
1cd595a598
commit
f29cc26103
@ -4,19 +4,19 @@ 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.events.DialogBuilder
|
||||
import com.topjohnwu.magisk.ui.module.ModuleViewModel
|
||||
import com.topjohnwu.magisk.view.MagiskDialog
|
||||
|
||||
class LocalModuleInstallDialog(
|
||||
private val viewModel: ModuleViewModel,
|
||||
private val uri: Uri
|
||||
private val uri: Uri,
|
||||
private val displayName: String
|
||||
) : DialogBuilder {
|
||||
override fun build(dialog: MagiskDialog) {
|
||||
dialog.apply {
|
||||
setTitle(R.string.confirm_install_title)
|
||||
setMessage(context.getString(R.string.confirm_install, uri.displayName))
|
||||
setMessage(context.getString(R.string.confirm_install, displayName))
|
||||
setButton(MagiskDialog.ButtonType.POSITIVE) {
|
||||
text = android.R.string.ok
|
||||
onClick {
|
||||
|
@ -5,6 +5,7 @@ import android.view.View
|
||||
import com.topjohnwu.magisk.R
|
||||
import com.topjohnwu.magisk.arch.BaseFragment
|
||||
import com.topjohnwu.magisk.arch.viewModel
|
||||
import com.topjohnwu.magisk.core.utils.MediaStoreUtils.displayName
|
||||
import com.topjohnwu.magisk.databinding.FragmentModuleMd2Binding
|
||||
import rikka.recyclerview.addEdgeSpacing
|
||||
import rikka.recyclerview.addInvalidateItemDecorationsObserver
|
||||
@ -21,7 +22,8 @@ class ModuleFragment : BaseFragment<FragmentModuleMd2Binding>() {
|
||||
activity?.title = resources.getString(R.string.modules)
|
||||
viewModel.data.observe(this) {
|
||||
it ?: return@observe
|
||||
viewModel.requestInstallLocalModule(it)
|
||||
val displayName = runCatching { it.displayName }.getOrNull() ?: return@observe
|
||||
viewModel.requestInstallLocalModule(it, displayName)
|
||||
viewModel.data.value = null
|
||||
}
|
||||
}
|
||||
|
@ -84,8 +84,8 @@ class ModuleViewModel : AsyncLoadViewModel() {
|
||||
GetContentEvent("application/zip", UriCallback()).publish()
|
||||
}
|
||||
|
||||
fun requestInstallLocalModule(uri: Uri) {
|
||||
LocalModuleInstallDialog(this, uri).show()
|
||||
fun requestInstallLocalModule(uri: Uri, displayName: String) {
|
||||
LocalModuleInstallDialog(this, uri, displayName).show()
|
||||
}
|
||||
|
||||
@Parcelize
|
||||
|
Loading…
x
Reference in New Issue
Block a user