mirror of
https://github.com/kvorschk/Magisk.git
synced 2026-12-04 19:10:47 -05:00
app: use full-screen dialog for install screen
Replace the install bottom sheet with a full-screen Dialog to provide more vertical space for release notes and installation methods. - Remove the legacy multi-step wizard logic from InstallViewModel. - Use styled Cards with SettingsSwitch for install options and SettingsArrow for installation methods. - Remove max height constraint on MarkdownText to allow release notes to expand naturally with full-screen scrolling. Assisted-by: Gemini 3.7 Flash
This commit is contained in:
@@ -412,9 +412,7 @@ fun MarkdownText(
|
||||
textView.setTextColor(contentColor)
|
||||
ServiceLocator.markwon.setMarkdown(textView, text)
|
||||
},
|
||||
modifier = modifier
|
||||
.fillMaxWidth()
|
||||
.heightIn(max = 300.dp)
|
||||
modifier = modifier.fillMaxWidth()
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
@@ -83,7 +83,7 @@ import com.topjohnwu.magisk.ui.component.MarkdownTextAsync
|
||||
import com.topjohnwu.magisk.ui.component.rememberLoadingDialog
|
||||
import com.topjohnwu.magisk.ui.component.verticalScrollbar
|
||||
import com.topjohnwu.magisk.ui.flash.FlashUtils
|
||||
import com.topjohnwu.magisk.ui.install.InstallBottomSheet
|
||||
import com.topjohnwu.magisk.ui.install.InstallDialog
|
||||
import com.topjohnwu.magisk.ui.install.InstallViewModel
|
||||
import kotlinx.coroutines.launch
|
||||
import java.io.File
|
||||
@@ -107,7 +107,7 @@ fun HomeScreen(
|
||||
var showEnvFixDialog by rememberSaveable { mutableStateOf(false) }
|
||||
var showHideDialog by rememberSaveable { mutableStateOf(false) }
|
||||
var showRestoreDialog by rememberSaveable { mutableStateOf(false) }
|
||||
var showInstallSheet by rememberSaveable { mutableStateOf(false) }
|
||||
var showInstallDialog by rememberSaveable { mutableStateOf(false) }
|
||||
var envFixCode by remember { mutableIntStateOf(0) }
|
||||
|
||||
LaunchedEffect(uiState.showUninstall) {
|
||||
@@ -183,7 +183,7 @@ fun HomeScreen(
|
||||
onDismiss = { showEnvFixDialog = false },
|
||||
onNavigateInstall = {
|
||||
showEnvFixDialog = false
|
||||
showInstallSheet = true
|
||||
showInstallDialog = true
|
||||
},
|
||||
onFixEnv = {
|
||||
showEnvFixDialog = false
|
||||
@@ -276,7 +276,7 @@ fun HomeScreen(
|
||||
modifier = Modifier.fillMaxWidth(),
|
||||
state = uiState.magiskState,
|
||||
version = uiState.magiskInstalledVersion,
|
||||
onInstallClicked = { showInstallSheet = true }
|
||||
onInstallClicked = { showInstallDialog = true }
|
||||
)
|
||||
|
||||
StatusCard()
|
||||
@@ -311,9 +311,9 @@ fun HomeScreen(
|
||||
}
|
||||
}
|
||||
|
||||
InstallBottomSheet(
|
||||
show = showInstallSheet,
|
||||
onDismiss = { showInstallSheet = false },
|
||||
InstallDialog(
|
||||
show = showInstallDialog,
|
||||
onDismiss = { showInstallDialog = false },
|
||||
installVm = installVm,
|
||||
)
|
||||
}
|
||||
|
||||
+136
-125
@@ -6,33 +6,42 @@ import androidx.activity.result.contract.ActivityResultContracts
|
||||
import androidx.compose.foundation.layout.Arrangement
|
||||
import androidx.compose.foundation.layout.Box
|
||||
import androidx.compose.foundation.layout.Column
|
||||
import androidx.compose.foundation.layout.Row
|
||||
import androidx.compose.foundation.layout.Spacer
|
||||
import androidx.compose.foundation.layout.PaddingValues
|
||||
import androidx.compose.foundation.layout.fillMaxSize
|
||||
import androidx.compose.foundation.layout.fillMaxWidth
|
||||
import androidx.compose.foundation.layout.height
|
||||
import androidx.compose.foundation.layout.padding
|
||||
import androidx.compose.foundation.rememberScrollState
|
||||
import androidx.compose.foundation.shape.RoundedCornerShape
|
||||
import androidx.compose.foundation.text.KeyboardActions
|
||||
import androidx.compose.foundation.text.KeyboardOptions
|
||||
import androidx.compose.material3.Checkbox
|
||||
import androidx.compose.foundation.verticalScroll
|
||||
import androidx.compose.material.icons.Icons
|
||||
import androidx.compose.material.icons.filled.Close
|
||||
import androidx.compose.material3.Card
|
||||
import androidx.compose.material3.CardDefaults
|
||||
import androidx.compose.material3.ExperimentalMaterial3Api
|
||||
import androidx.compose.material3.HorizontalDivider
|
||||
import androidx.compose.material3.Icon
|
||||
import androidx.compose.material3.IconButton
|
||||
import androidx.compose.material3.MaterialTheme
|
||||
import androidx.compose.material3.ModalBottomSheet
|
||||
import androidx.compose.material3.OutlinedTextField
|
||||
import androidx.compose.material3.Scaffold
|
||||
import androidx.compose.material3.Text
|
||||
import androidx.compose.material3.TextButton
|
||||
import androidx.compose.material3.TopAppBar
|
||||
import androidx.compose.material3.TopAppBarDefaults
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.runtime.LaunchedEffect
|
||||
import androidx.compose.runtime.getValue
|
||||
import androidx.compose.runtime.mutableStateOf
|
||||
import androidx.compose.runtime.remember
|
||||
import androidx.compose.runtime.saveable.rememberSaveable
|
||||
import androidx.compose.runtime.setValue
|
||||
import androidx.compose.ui.Alignment
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.res.stringResource
|
||||
import androidx.compose.ui.text.input.ImeAction
|
||||
import androidx.compose.ui.text.input.KeyboardType
|
||||
import androidx.compose.ui.unit.dp
|
||||
import androidx.compose.ui.window.Dialog
|
||||
import androidx.compose.ui.window.DialogProperties
|
||||
import androidx.core.net.toUri
|
||||
import androidx.lifecycle.compose.collectAsStateWithLifecycle
|
||||
import com.topjohnwu.magisk.core.Config
|
||||
@@ -41,12 +50,14 @@ import com.topjohnwu.magisk.ui.component.ConfirmResult
|
||||
import com.topjohnwu.magisk.ui.component.MagiskDialog
|
||||
import com.topjohnwu.magisk.ui.component.MarkdownText
|
||||
import com.topjohnwu.magisk.ui.component.SettingsArrow
|
||||
import com.topjohnwu.magisk.ui.component.SettingsSwitch
|
||||
import com.topjohnwu.magisk.ui.component.rememberConfirmDialog
|
||||
import com.topjohnwu.magisk.ui.component.verticalScrollbar
|
||||
import com.topjohnwu.magisk.core.R as CoreR
|
||||
|
||||
@OptIn(ExperimentalMaterial3Api::class)
|
||||
@Composable
|
||||
fun InstallBottomSheet(
|
||||
fun InstallDialog(
|
||||
show: Boolean,
|
||||
onDismiss: () -> Unit,
|
||||
installVm: InstallViewModel,
|
||||
@@ -97,62 +108,94 @@ fun InstallBottomSheet(
|
||||
}
|
||||
|
||||
if (show) {
|
||||
ModalBottomSheet(
|
||||
modifier = modifier,
|
||||
Dialog(
|
||||
onDismissRequest = onDismiss,
|
||||
) {
|
||||
Text(
|
||||
text = stringResource(CoreR.string.install),
|
||||
style = MaterialTheme.typography.titleLarge,
|
||||
modifier = Modifier.padding(16.dp)
|
||||
properties = DialogProperties(
|
||||
usePlatformDefaultWidth = false,
|
||||
decorFitsSystemWindows = false
|
||||
)
|
||||
Column(modifier = Modifier.padding(bottom = 16.dp)) {
|
||||
if (installUiState.notes.isNotEmpty()) {
|
||||
Box(modifier = Modifier.padding(horizontal = 16.dp, vertical = 8.dp)) {
|
||||
) {
|
||||
val scrollState = rememberScrollState()
|
||||
Scaffold(
|
||||
modifier = modifier.fillMaxSize(),
|
||||
topBar = {
|
||||
TopAppBar(
|
||||
title = { Text(stringResource(CoreR.string.install)) },
|
||||
navigationIcon = {
|
||||
IconButton(onClick = onDismiss) {
|
||||
Icon(
|
||||
imageVector = Icons.Default.Close,
|
||||
contentDescription = stringResource(android.R.string.cancel)
|
||||
)
|
||||
}
|
||||
},
|
||||
colors = TopAppBarDefaults.topAppBarColors(
|
||||
containerColor = MaterialTheme.colorScheme.surface
|
||||
)
|
||||
)
|
||||
}
|
||||
) { innerPadding ->
|
||||
Column(
|
||||
modifier = Modifier
|
||||
.fillMaxSize()
|
||||
.padding(innerPadding)
|
||||
.verticalScrollbar(scrollState, contentPadding = PaddingValues(vertical = 12.dp))
|
||||
.verticalScroll(scrollState)
|
||||
.padding(horizontal = 16.dp, vertical = 12.dp),
|
||||
verticalArrangement = Arrangement.spacedBy(16.dp)
|
||||
) {
|
||||
if (installUiState.notes.isNotEmpty()) {
|
||||
MarkdownText(installUiState.notes)
|
||||
}
|
||||
HorizontalDivider(thickness = 0.75.dp)
|
||||
}
|
||||
|
||||
if (!installVm.skipOptions) {
|
||||
InstallOptionsSection(installUiState, installVm)
|
||||
}
|
||||
if (!installVm.skipOptions) {
|
||||
InstallOptionsSection()
|
||||
}
|
||||
|
||||
SettingsArrow(
|
||||
title = stringResource(CoreR.string.select_patch_file),
|
||||
onClick = {
|
||||
onDismiss()
|
||||
installVm.selectMethod(InstallViewModel.Method.PATCH)
|
||||
},
|
||||
)
|
||||
Card(
|
||||
modifier = Modifier.fillMaxWidth(),
|
||||
shape = RoundedCornerShape(20.dp),
|
||||
colors = CardDefaults.cardColors(
|
||||
containerColor = MaterialTheme.colorScheme.surfaceContainerLow
|
||||
),
|
||||
) {
|
||||
SettingsArrow(
|
||||
title = stringResource(CoreR.string.select_patch_file),
|
||||
onClick = {
|
||||
onDismiss()
|
||||
installVm.selectMethod(InstallViewModel.Method.PATCH)
|
||||
},
|
||||
)
|
||||
|
||||
SettingsArrow(
|
||||
title = stringResource(CoreR.string.download_patch_file),
|
||||
onClick = {
|
||||
onDismiss()
|
||||
installVm.selectMethod(InstallViewModel.Method.DOWNLOAD)
|
||||
},
|
||||
)
|
||||
SettingsArrow(
|
||||
title = stringResource(CoreR.string.download_patch_file),
|
||||
onClick = {
|
||||
onDismiss()
|
||||
installVm.selectMethod(InstallViewModel.Method.DOWNLOAD)
|
||||
},
|
||||
)
|
||||
|
||||
if (installVm.isRooted) {
|
||||
SettingsArrow(
|
||||
title = stringResource(CoreR.string.direct_install),
|
||||
onClick = {
|
||||
onDismiss()
|
||||
installVm.selectMethod(InstallViewModel.Method.DIRECT)
|
||||
installVm.install()
|
||||
},
|
||||
)
|
||||
}
|
||||
if (installVm.isRooted) {
|
||||
SettingsArrow(
|
||||
title = stringResource(CoreR.string.direct_install),
|
||||
onClick = {
|
||||
onDismiss()
|
||||
installVm.selectMethod(InstallViewModel.Method.DIRECT)
|
||||
installVm.install()
|
||||
},
|
||||
)
|
||||
}
|
||||
|
||||
if (!installVm.noSecondSlot) {
|
||||
SettingsArrow(
|
||||
title = stringResource(CoreR.string.install_inactive_slot),
|
||||
onClick = {
|
||||
onDismiss()
|
||||
installVm.selectMethod(InstallViewModel.Method.INACTIVE_SLOT)
|
||||
},
|
||||
)
|
||||
if (!installVm.noSecondSlot) {
|
||||
SettingsArrow(
|
||||
title = stringResource(CoreR.string.install_inactive_slot),
|
||||
onClick = {
|
||||
onDismiss()
|
||||
installVm.selectMethod(InstallViewModel.Method.INACTIVE_SLOT)
|
||||
},
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -161,78 +204,46 @@ fun InstallBottomSheet(
|
||||
|
||||
@Composable
|
||||
private fun InstallOptionsSection(
|
||||
uiState: InstallViewModel.UiState,
|
||||
viewModel: InstallViewModel,
|
||||
modifier: Modifier = Modifier
|
||||
) {
|
||||
Column(modifier = modifier.padding(horizontal = 16.dp, vertical = 8.dp)) {
|
||||
Row(
|
||||
modifier = Modifier.fillMaxWidth(),
|
||||
horizontalArrangement = Arrangement.SpaceBetween,
|
||||
verticalAlignment = Alignment.CenterVertically
|
||||
) {
|
||||
Text(
|
||||
text = stringResource(CoreR.string.install_options_title),
|
||||
style = MaterialTheme.typography.titleLarge,
|
||||
)
|
||||
if (uiState.step == 0) {
|
||||
TextButton(
|
||||
onClick = { viewModel.nextStep() }
|
||||
) {
|
||||
Text(stringResource(CoreR.string.install_next))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (uiState.step == 0) {
|
||||
Spacer(Modifier.height(8.dp))
|
||||
if (!Info.isSAR) {
|
||||
CheckboxRow(
|
||||
label = stringResource(CoreR.string.keep_dm_verity),
|
||||
checked = Config.keepVerity,
|
||||
onCheckedChange = { Config.keepVerity = it }
|
||||
)
|
||||
}
|
||||
if (Info.isFDE) {
|
||||
CheckboxRow(
|
||||
label = stringResource(CoreR.string.keep_force_encryption),
|
||||
checked = Config.keepEnc,
|
||||
onCheckedChange = { Config.keepEnc = it }
|
||||
)
|
||||
}
|
||||
if (!Info.ramdisk) {
|
||||
CheckboxRow(
|
||||
label = stringResource(CoreR.string.recovery_mode),
|
||||
checked = Config.recovery,
|
||||
onCheckedChange = { Config.recovery = it }
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Composable
|
||||
private fun CheckboxRow(
|
||||
label: String,
|
||||
checked: Boolean,
|
||||
onCheckedChange: (Boolean) -> Unit,
|
||||
modifier: Modifier = Modifier
|
||||
) {
|
||||
Row(
|
||||
modifier = modifier
|
||||
.fillMaxWidth()
|
||||
.padding(vertical = 4.dp),
|
||||
verticalAlignment = Alignment.CenterVertically,
|
||||
horizontalArrangement = Arrangement.spacedBy(8.dp)
|
||||
Card(
|
||||
modifier = modifier.fillMaxWidth(),
|
||||
shape = RoundedCornerShape(20.dp),
|
||||
colors = CardDefaults.cardColors(containerColor = MaterialTheme.colorScheme.surfaceContainerLow)
|
||||
) {
|
||||
Checkbox(
|
||||
checked = checked,
|
||||
onCheckedChange = { onCheckedChange(it) }
|
||||
)
|
||||
Text(
|
||||
text = label,
|
||||
style = MaterialTheme.typography.bodyLarge,
|
||||
)
|
||||
if (!Info.isSAR) {
|
||||
var keepVerity by remember { mutableStateOf(Config.keepVerity) }
|
||||
SettingsSwitch(
|
||||
title = stringResource(CoreR.string.keep_dm_verity),
|
||||
checked = keepVerity,
|
||||
onCheckedChange = {
|
||||
keepVerity = it
|
||||
Config.keepVerity = it
|
||||
}
|
||||
)
|
||||
}
|
||||
if (Info.isFDE) {
|
||||
var keepEnc by remember { mutableStateOf(Config.keepEnc) }
|
||||
SettingsSwitch(
|
||||
title = stringResource(CoreR.string.keep_force_encryption),
|
||||
checked = keepEnc,
|
||||
onCheckedChange = {
|
||||
keepEnc = it
|
||||
Config.keepEnc = it
|
||||
}
|
||||
)
|
||||
}
|
||||
if (!Info.ramdisk) {
|
||||
var recovery by remember { mutableStateOf(Config.recovery) }
|
||||
SettingsSwitch(
|
||||
title = stringResource(CoreR.string.recovery_mode),
|
||||
checked = recovery,
|
||||
onCheckedChange = {
|
||||
recovery = it
|
||||
Config.recovery = it
|
||||
}
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -27,7 +27,6 @@ class InstallViewModel(svc: NetworkService) : BaseViewModel() {
|
||||
enum class Method { NONE, PATCH, DIRECT, INACTIVE_SLOT, DOWNLOAD }
|
||||
|
||||
data class UiState(
|
||||
val step: Int = 0,
|
||||
val method: Method = Method.NONE,
|
||||
val notes: String = "",
|
||||
val patchUri: Uri? = null,
|
||||
@@ -40,7 +39,7 @@ class InstallViewModel(svc: NetworkService) : BaseViewModel() {
|
||||
val skipOptions = Info.isEmulator || (Info.isSAR && !Info.isFDE && Info.ramdisk)
|
||||
val noSecondSlot = !isRooted || !Info.isAB || Info.isEmulator
|
||||
|
||||
private val _uiState = MutableStateFlow(UiState(step = if (skipOptions) 1 else 0))
|
||||
private val _uiState = MutableStateFlow(UiState())
|
||||
val uiState: StateFlow<UiState> = _uiState.asStateFlow()
|
||||
|
||||
init {
|
||||
@@ -63,10 +62,6 @@ class InstallViewModel(svc: NetworkService) : BaseViewModel() {
|
||||
}
|
||||
}
|
||||
|
||||
fun nextStep() {
|
||||
_uiState.update { it.copy(step = 1) }
|
||||
}
|
||||
|
||||
fun selectMethod(method: Method) {
|
||||
_uiState.update { it.copy(method = method) }
|
||||
when (method) {
|
||||
|
||||
Reference in New Issue
Block a user