@@ -2,7 +2,9 @@ package app.revanced.manager.ui.screen.settings
2
2
3
3
import androidx.annotation.StringRes
4
4
import androidx.compose.foundation.clickable
5
+ import androidx.compose.foundation.layout.Arrangement
5
6
import androidx.compose.foundation.layout.Box
7
+ import androidx.compose.foundation.layout.Column
6
8
import androidx.compose.foundation.layout.fillMaxSize
7
9
import androidx.compose.foundation.layout.fillMaxWidth
8
10
import androidx.compose.foundation.layout.padding
@@ -11,10 +13,13 @@ import androidx.compose.material.icons.Icons
11
13
import androidx.compose.material.icons.filled.Delete
12
14
import androidx.compose.material.icons.outlined.Delete
13
15
import androidx.compose.material3.AlertDialog
16
+ import androidx.compose.material3.Card
17
+ import androidx.compose.material3.CardDefaults
14
18
import androidx.compose.material3.ExperimentalMaterial3Api
15
19
import androidx.compose.material3.Icon
16
20
import androidx.compose.material3.IconButton
17
21
import androidx.compose.material3.MaterialTheme
22
+ import androidx.compose.material3.OutlinedCard
18
23
import androidx.compose.material3.Scaffold
19
24
import androidx.compose.material3.Text
20
25
import androidx.compose.material3.TextButton
@@ -32,8 +37,10 @@ import androidx.compose.runtime.setValue
32
37
import androidx.compose.ui.Alignment
33
38
import androidx.compose.ui.Modifier
34
39
import androidx.compose.ui.input.nestedscroll.nestedScroll
40
+ import androidx.compose.ui.platform.LocalContext
35
41
import androidx.compose.ui.res.stringResource
36
42
import androidx.compose.ui.text.style.TextAlign
43
+ import androidx.compose.ui.tooling.preview.Preview
37
44
import androidx.compose.ui.unit.dp
38
45
import androidx.compose.ui.zIndex
39
46
import androidx.lifecycle.compose.collectAsStateWithLifecycle
@@ -57,6 +64,7 @@ fun DownloadsSettingsScreen(
57
64
onBackClick : () -> Unit ,
58
65
viewModel : DownloadsViewModel = koinViewModel()
59
66
) {
67
+ val context = LocalContext .current
60
68
val pullRefreshState = rememberPullToRefreshState()
61
69
val downloadedApps by viewModel.downloadedApps.collectAsStateWithLifecycle(emptyList())
62
70
val pluginStates by viewModel.downloaderPluginStates.collectAsStateWithLifecycle()
@@ -81,7 +89,7 @@ fun DownloadsSettingsScreen(
81
89
onBackClick = onBackClick,
82
90
actions = {
83
91
if (viewModel.appSelection.isNotEmpty()) {
84
- IconButton (onClick = { showDeleteConfirmationDialog = true }) {
92
+ IconButton (onClick = { viewModel.deleteApps() }) {
85
93
Icon (Icons .Default .Delete , stringResource(R .string.delete))
86
94
}
87
95
}
@@ -142,15 +150,20 @@ fun DownloadsSettingsScreen(
142
150
.digest(androidSignature.toByteArray())
143
151
hash.toHexString(format = HexFormat .UpperCase )
144
152
}
153
+ val appName = remember {
154
+ packageInfo.applicationInfo?.loadLabel(context.packageManager)
155
+ ?.toString()
156
+ ? : packageName
157
+ }
145
158
146
159
when (state) {
147
160
is DownloaderPluginState .Loaded -> TrustDialog (
148
161
title = R .string.downloader_plugin_revoke_trust_dialog_title,
149
162
body = stringResource(
150
163
R .string.downloader_plugin_trust_dialog_body,
151
- packageName,
152
- signature
153
164
),
165
+ pluginName = appName,
166
+ signature = signature,
154
167
onDismiss = ::dismiss,
155
168
onConfirm = {
156
169
viewModel.revokePluginTrust(packageName)
@@ -165,19 +178,20 @@ fun DownloadsSettingsScreen(
165
178
onDismiss = ::dismiss
166
179
)
167
180
168
- is DownloaderPluginState .Untrusted -> TrustDialog (
169
- title = R .string.downloader_plugin_trust_dialog_title,
170
- body = stringResource(
171
- R .string.downloader_plugin_trust_dialog_body,
172
- packageName,
173
- signature
174
- ),
175
- onDismiss = ::dismiss,
176
- onConfirm = {
177
- viewModel.trustPlugin(packageName)
178
- dismiss()
179
- }
180
- )
181
+ is DownloaderPluginState .Untrusted ->
182
+ TrustDialog (
183
+ title = R .string.downloader_plugin_trust_dialog_title,
184
+ body = stringResource(
185
+ R .string.downloader_plugin_trust_dialog_body
186
+ ),
187
+ pluginName = appName,
188
+ signature = signature,
189
+ onDismiss = ::dismiss,
190
+ onConfirm = {
191
+ viewModel.trustPlugin(packageName)
192
+ dismiss()
193
+ }
194
+ )
181
195
}
182
196
}
183
197
@@ -242,10 +256,27 @@ fun DownloadsSettingsScreen(
242
256
}
243
257
}
244
258
259
+ @Preview
260
+ @Composable
261
+ private fun PreviewTrustDialog () {
262
+ TrustDialog (
263
+ title = R .string.downloader_plugin_trust_dialog_title,
264
+ body = stringResource(
265
+ R .string.downloader_plugin_trust_dialog_body,
266
+ ),
267
+ onDismiss = { },
268
+ onConfirm = { },
269
+ pluginName = " app.revanced.manager.apkmirror" ,
270
+ signature = " 23 01 84 F6 0B AE 2F EA F2 44 F1 0A 8B AC 05 3C 8F F3 3A 18 3B CC 36 5B 4D 8B 87 6D 2B 7F 48 09"
271
+ )
272
+ }
273
+
245
274
@Composable
246
275
private fun TrustDialog (
247
276
@StringRes title : Int ,
248
277
body : String ,
278
+ pluginName : String ,
279
+ signature : String ,
249
280
onDismiss : () -> Unit ,
250
281
onConfirm : () -> Unit
251
282
) {
@@ -262,6 +293,35 @@ private fun TrustDialog(
262
293
}
263
294
},
264
295
title = { Text (stringResource(title)) },
265
- text = { Text (body) }
296
+ text = {
297
+ Column (verticalArrangement = Arrangement .spacedBy(12 .dp)) {
298
+ Text (body)
299
+ Card {
300
+ Column (
301
+ Modifier .padding(12 .dp),
302
+ verticalArrangement = Arrangement .spacedBy(12 .dp)
303
+ ) {
304
+ Text (
305
+ stringResource(
306
+ R .string.downloader_plugin_trust_dialog_plugin,
307
+ pluginName
308
+ ),
309
+ )
310
+ OutlinedCard (
311
+ colors = CardDefaults .outlinedCardColors(
312
+ containerColor = MaterialTheme .colorScheme.surfaceContainerHighest
313
+ )
314
+ ) {
315
+ Text (
316
+ stringResource(
317
+ R .string.downloader_plugin_trust_dialog_signature,
318
+ signature.chunked(2 ).joinToString(" " )
319
+ ), modifier = Modifier .padding(12 .dp)
320
+ )
321
+ }
322
+ }
323
+ }
324
+ }
325
+ }
266
326
)
267
327
}
0 commit comments