@@ -2,18 +2,23 @@ package app.revanced.manager.ui.screen.settings
22
33import androidx.annotation.StringRes
44import androidx.compose.foundation.clickable
5+ import androidx.compose.foundation.layout.Arrangement
56import androidx.compose.foundation.layout.Box
7+ import androidx.compose.foundation.layout.Column
68import androidx.compose.foundation.layout.fillMaxSize
79import androidx.compose.foundation.layout.fillMaxWidth
810import androidx.compose.foundation.layout.padding
911import androidx.compose.foundation.lazy.items
1012import androidx.compose.material.icons.Icons
1113import androidx.compose.material.icons.filled.Delete
1214import androidx.compose.material3.AlertDialog
15+ import androidx.compose.material3.Card
16+ import androidx.compose.material3.CardDefaults
1317import androidx.compose.material3.ExperimentalMaterial3Api
1418import androidx.compose.material3.Icon
1519import androidx.compose.material3.IconButton
1620import androidx.compose.material3.MaterialTheme
21+ import androidx.compose.material3.OutlinedCard
1722import androidx.compose.material3.Scaffold
1823import androidx.compose.material3.Text
1924import androidx.compose.material3.TextButton
@@ -31,8 +36,10 @@ import androidx.compose.runtime.setValue
3136import androidx.compose.ui.Alignment
3237import androidx.compose.ui.Modifier
3338import androidx.compose.ui.input.nestedscroll.nestedScroll
39+ import androidx.compose.ui.platform.LocalContext
3440import androidx.compose.ui.res.stringResource
3541import androidx.compose.ui.text.style.TextAlign
42+ import androidx.compose.ui.tooling.preview.Preview
3643import androidx.compose.ui.unit.dp
3744import androidx.compose.ui.zIndex
3845import androidx.lifecycle.compose.collectAsStateWithLifecycle
@@ -59,6 +66,7 @@ fun DownloadsSettingsScreen(
5966 val downloadedApps by viewModel.downloadedApps.collectAsStateWithLifecycle(emptyList())
6067 val pluginStates by viewModel.downloaderPluginStates.collectAsStateWithLifecycle()
6168 val scrollBehavior = TopAppBarDefaults .pinnedScrollBehavior(rememberTopAppBarState())
69+ val context = LocalContext .current
6270
6371 Scaffold (
6472 topBar = {
@@ -129,15 +137,18 @@ fun DownloadsSettingsScreen(
129137 .digest(androidSignature.toByteArray())
130138 hash.toHexString(format = HexFormat .UpperCase )
131139 }
140+ val appName = packageInfo.applicationInfo?.loadLabel(context.packageManager)
141+ ?.toString()
142+ ? : packageName
132143
133144 when (state) {
134145 is DownloaderPluginState .Loaded -> TrustDialog (
135146 title = R .string.downloader_plugin_revoke_trust_dialog_title,
136147 body = stringResource(
137148 R .string.downloader_plugin_trust_dialog_body,
138- packageName,
139- signature
140149 ),
150+ pluginName = appName,
151+ signature = signature,
141152 onDismiss = ::dismiss,
142153 onConfirm = {
143154 viewModel.revokePluginTrust(packageName)
@@ -152,19 +163,20 @@ fun DownloadsSettingsScreen(
152163 onDismiss = ::dismiss
153164 )
154165
155- is DownloaderPluginState .Untrusted -> TrustDialog (
156- title = R .string.downloader_plugin_trust_dialog_title,
157- body = stringResource(
158- R .string.downloader_plugin_trust_dialog_body,
159- packageName,
160- signature
161- ),
162- onDismiss = ::dismiss,
163- onConfirm = {
164- viewModel.trustPlugin(packageName)
165- dismiss()
166- }
167- )
166+ is DownloaderPluginState .Untrusted ->
167+ TrustDialog (
168+ title = R .string.downloader_plugin_trust_dialog_title,
169+ body = stringResource(
170+ R .string.downloader_plugin_trust_dialog_body
171+ ),
172+ pluginName = appName,
173+ signature = signature,
174+ onDismiss = ::dismiss,
175+ onConfirm = {
176+ viewModel.trustPlugin(packageName)
177+ dismiss()
178+ }
179+ )
168180 }
169181 }
170182
@@ -229,10 +241,27 @@ fun DownloadsSettingsScreen(
229241 }
230242}
231243
244+ @Preview
245+ @Composable
246+ private fun PreviewTrustDialog () {
247+ TrustDialog (
248+ title = R .string.downloader_plugin_trust_dialog_title,
249+ body = stringResource(
250+ R .string.downloader_plugin_trust_dialog_body,
251+ ),
252+ onDismiss = { },
253+ onConfirm = { },
254+ pluginName = " app.revanced.manager.apkmirror" ,
255+ 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"
256+ )
257+ }
258+
232259@Composable
233260private fun TrustDialog (
234261 @StringRes title : Int ,
235262 body : String ,
263+ pluginName : String ,
264+ signature : String ,
236265 onDismiss : () -> Unit ,
237266 onConfirm : () -> Unit
238267) {
@@ -249,6 +278,35 @@ private fun TrustDialog(
249278 }
250279 },
251280 title = { Text (stringResource(title)) },
252- text = { Text (body) }
281+ text = {
282+ Column (verticalArrangement = Arrangement .spacedBy(12 .dp)) {
283+ Text (body)
284+ Card {
285+ Column (
286+ Modifier .padding(12 .dp),
287+ verticalArrangement = Arrangement .spacedBy(12 .dp)
288+ ) {
289+ Text (
290+ stringResource(
291+ R .string.downloader_plugin_trust_dialog_plugin,
292+ pluginName
293+ ),
294+ )
295+ OutlinedCard (
296+ colors = CardDefaults .outlinedCardColors(
297+ containerColor = MaterialTheme .colorScheme.surfaceContainerHighest
298+ )
299+ ) {
300+ Text (
301+ stringResource(
302+ R .string.downloader_plugin_trust_dialog_signature,
303+ signature.chunked(2 ).joinToString(" " )
304+ ), modifier = Modifier .padding(12 .dp)
305+ )
306+ }
307+ }
308+ }
309+ }
310+ }
253311 )
254312}
0 commit comments