feat(GPPDialog): add option to never show again
This commit is contained in:
parent
89dee2ab0b
commit
7ec6c16b9b
4 changed files with 51 additions and 15 deletions
|
|
@ -13,4 +13,5 @@ class PreferencesManager(preferences: SharedPreferences) : BasePreferenceManager
|
|||
var installer by enumPreference<InstallerSetting>("installer", InstallerSetting.PM)
|
||||
var keepPatchedApks by booleanPreference("keep_patched_apks", false)
|
||||
var showNetworkWarning by booleanPreference("show_network_warning", true)
|
||||
var showPlayProtectWarning by booleanPreference("show_play_protect_warning", true)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -54,11 +54,16 @@ class InstallStep(private val options: PatchOptions) : Step(), KoinComponent {
|
|||
ProcessLifecycleOwner.get().lifecycle.withResumed {}
|
||||
|
||||
// Show [PlayProtectDialog] and wait until it gets dismissed
|
||||
if (!prefs.devMode && !context.isPackageInstalled(options.packageName) && context.isPlayProtectEnabled() == true) {
|
||||
if (prefs.showPlayProtectWarning
|
||||
&& !prefs.devMode
|
||||
&& !context.isPackageInstalled(options.packageName)
|
||||
&& context.isPlayProtectEnabled() == true
|
||||
) {
|
||||
container.log("Showing play protect warning dialog")
|
||||
overlays.startComposableForResult { callback ->
|
||||
PlayProtectDialog(onDismiss = { callback(Unit) })
|
||||
val neverShowAgain = overlays.startComposableForResult { callback ->
|
||||
PlayProtectDialog(onDismiss = callback)
|
||||
}
|
||||
prefs.showPlayProtectWarning = !neverShowAgain
|
||||
}
|
||||
|
||||
container.log("Installing ${apk.absolutePath}, silent: ${!prefs.devMode}")
|
||||
|
|
|
|||
|
|
@ -2,10 +2,13 @@ package com.aliucord.manager.ui.components.dialogs
|
|||
|
||||
import android.content.Context
|
||||
import android.content.Intent
|
||||
import androidx.compose.foundation.layout.padding
|
||||
import androidx.compose.foundation.layout.size
|
||||
import androidx.compose.foundation.clickable
|
||||
import androidx.compose.foundation.interaction.MutableInteractionSource
|
||||
import androidx.compose.foundation.layout.*
|
||||
import androidx.compose.material3.*
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.runtime.*
|
||||
import androidx.compose.runtime.saveable.rememberSaveable
|
||||
import androidx.compose.ui.Alignment
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.platform.LocalContext
|
||||
import androidx.compose.ui.res.painterResource
|
||||
|
|
@ -18,13 +21,15 @@ import com.aliucord.manager.ui.components.customColors
|
|||
|
||||
@Composable
|
||||
fun PlayProtectDialog(
|
||||
onDismiss: () -> Unit,
|
||||
modifier: Modifier = Modifier,
|
||||
onDismiss: (neverShow: Boolean) -> Unit,
|
||||
) {
|
||||
val context = LocalContext.current
|
||||
val interactionSource = remember(::MutableInteractionSource)
|
||||
var neverShow by rememberSaveable { mutableStateOf(false) }
|
||||
val rememberedNeverShow by rememberUpdatedState(neverShow)
|
||||
|
||||
AlertDialog(
|
||||
onDismissRequest = onDismiss,
|
||||
onDismissRequest = { onDismiss(rememberedNeverShow) },
|
||||
dismissButton = {
|
||||
FilledTonalButton(onClick = context::launchPlayProtect) {
|
||||
Text(stringResource(R.string.play_protect_warning_open_gpp))
|
||||
|
|
@ -32,7 +37,7 @@ fun PlayProtectDialog(
|
|||
},
|
||||
confirmButton = {
|
||||
FilledTonalButton(
|
||||
onClick = onDismiss,
|
||||
onClick = { onDismiss(rememberedNeverShow) },
|
||||
colors = ButtonDefaults.filledTonalButtonColors(
|
||||
containerColor = MaterialTheme.colorScheme.primary,
|
||||
contentColor = MaterialTheme.colorScheme.onPrimary,
|
||||
|
|
@ -51,16 +56,40 @@ fun PlayProtectDialog(
|
|||
},
|
||||
title = { Text(stringResource(R.string.play_protect_warning_title)) },
|
||||
text = {
|
||||
Text(
|
||||
text = stringResource(R.string.play_protect_warning_desc),
|
||||
textAlign = TextAlign.Center,
|
||||
)
|
||||
Column(
|
||||
verticalArrangement = Arrangement.spacedBy(12.dp),
|
||||
horizontalAlignment = Alignment.CenterHorizontally,
|
||||
) {
|
||||
Text(
|
||||
text = stringResource(R.string.play_protect_warning_desc),
|
||||
textAlign = TextAlign.Center,
|
||||
)
|
||||
|
||||
Row(
|
||||
verticalAlignment = Alignment.CenterVertically,
|
||||
modifier = Modifier
|
||||
.clickable(
|
||||
interactionSource = interactionSource,
|
||||
indication = null,
|
||||
onClick = { neverShow = !rememberedNeverShow },
|
||||
)
|
||||
.padding(end = 16.dp)
|
||||
) {
|
||||
Checkbox(
|
||||
checked = neverShow,
|
||||
onCheckedChange = { neverShow = it },
|
||||
interactionSource = interactionSource,
|
||||
)
|
||||
|
||||
Text(stringResource(R.string.play_protect_warning_disable))
|
||||
}
|
||||
}
|
||||
},
|
||||
properties = DialogProperties(
|
||||
dismissOnBackPress = false,
|
||||
usePlatformDefaultWidth = false,
|
||||
),
|
||||
modifier = modifier
|
||||
modifier = Modifier
|
||||
.padding(25.dp),
|
||||
)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -224,6 +224,7 @@
|
|||
<string name="play_protect_warning_desc">Google Play Protect appears to be enabled on your device. It may attempt to interfere with a new installation due to the usage of a unique signing key. You can disable it in Play Protect\'s settings.\n\nIf it does show a warning dialog, press\n\"More Details\" -> \"Install anyway\"</string>
|
||||
<string name="play_protect_warning_ok">Continue</string>
|
||||
<string name="play_protect_warning_open_gpp">Open Play Protect</string>
|
||||
<string name="play_protect_warning_disable">Don\'t show this again</string>
|
||||
|
||||
<string name="custom_component_picker_title">Custom Component</string>
|
||||
<string name="custom_component_picker_desc">A custom local version for a patching component (%s) has been found. Would you like to use it?</string>
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue