File tree Expand file tree Collapse file tree 4 files changed +46
-3
lines changed
java/com/topjohnwu/magisk Expand file tree Collapse file tree 4 files changed +46
-3
lines changed Original file line number Diff line number Diff line change
1
+
2
+ package com.topjohnwu.magisk.dialog
3
+
4
+ import android.R as AndroidR
5
+ import com.topjohnwu.magisk.core.R as CoreR
6
+ import com.topjohnwu.magisk.core.model.module.OnlineModule
7
+ import com.topjohnwu.magisk.events.DialogBuilder
8
+ import com.topjohnwu.magisk.ui.module.ModuleViewModel
9
+ import com.topjohnwu.magisk.view.MagiskDialog
10
+
11
+ class ReinstallConfirmationDialog (
12
+ private val viewModel : ModuleViewModel ,
13
+ private val item : OnlineModule
14
+ ) : DialogBuilder {
15
+ override fun build (dialog : MagiskDialog ) {
16
+ dialog.apply {
17
+ setTitle(CoreR .string.module_reinstall_title)
18
+ setMessage(CoreR .string.module_reinstall_message)
19
+ setButton(MagiskDialog .ButtonType .POSITIVE ) {
20
+ text = CoreR .string.module_reinstall
21
+ onClick { viewModel.downloadPressed(item) }
22
+ }
23
+ setButton(MagiskDialog .ButtonType .NEGATIVE ) {
24
+ text = AndroidR .string.cancel
25
+ }
26
+ setCancelable(true )
27
+ }
28
+ }
29
+ }
Original file line number Diff line number Diff line change @@ -19,6 +19,7 @@ import com.topjohnwu.magisk.databinding.diffList
19
19
import com.topjohnwu.magisk.databinding.set
20
20
import com.topjohnwu.magisk.dialog.LocalModuleInstallDialog
21
21
import com.topjohnwu.magisk.dialog.OnlineModuleInstallDialog
22
+ import com.topjohnwu.magisk.dialog.ReinstallConfirmationDialog
22
23
import com.topjohnwu.magisk.events.GetContentEvent
23
24
import com.topjohnwu.magisk.events.SnackbarEvent
24
25
import kotlinx.coroutines.Dispatchers
@@ -91,6 +92,15 @@ class ModuleViewModel : AsyncLoadViewModel() {
91
92
LocalModuleInstallDialog (this , uri, displayName).show()
92
93
}
93
94
95
+ fun onUpdateClicked (item : LocalModuleRvItem ) {
96
+ val updateInfo = item.item.updateInfo ? : return
97
+ if (item.updateReady) {
98
+ downloadPressed(updateInfo)
99
+ } else {
100
+ ReinstallConfirmationDialog (this , updateInfo).show()
101
+ }
102
+ }
103
+
94
104
@Parcelize
95
105
class UriCallback : ContentResultCallback {
96
106
override fun onActivityResult (result : Uri ) {
Original file line number Diff line number Diff line change 132
132
133
133
<Button
134
134
android : id =" @+id/module_update"
135
- style =" @style/WidgetFoundation .Button.Text"
135
+ style =" @style/Widget.Foundation .Button.Text"
136
136
goneUnless =" @{item.showUpdate}"
137
137
android : layout_width =" wrap_content"
138
138
android : layout_height =" wrap_content"
139
139
android : clickable =" true"
140
- android : enabled =" @{item.updateReady} "
140
+ android : enabled =" true "
141
141
android : focusable =" true"
142
- android : onClick =" @{() -> viewModel.downloadPressed(item.item.updateInfo)}"
142
+ android : alpha =" @{item.updateReady ? 1.0f : 0.38f}"
143
+ android : onClick =" @{() -> viewModel.onUpdateClicked(item)}"
143
144
android : text =" @string/update"
144
145
android : textAllCaps =" false"
145
146
app : icon =" @drawable/ic_update_md2"
Original file line number Diff line number Diff line change 116
116
<string name =" module_empty" >No module installed</string >
117
117
<string name =" confirm_install" >Install module %1$s?</string >
118
118
<string name =" confirm_install_title" >Install confirmation</string >
119
+ <string name =" module_reinstall_title" >Reinstall Module</string >
120
+ <string name =" module_reinstall_message" >This module is already up-to-date. Do you want to redownload and reinstall it?</string >
121
+ <string name =" module_reinstall" >Reinstall</string >
119
122
120
123
<!-- Settings-->
121
124
<string name =" settings_dark_mode_title" >Theme mode</string >
You can’t perform that action at this time.
0 commit comments