disable file manager if no root, tap to request for root

This commit is contained in:
2026-03-12 16:19:12 +05:00
parent 71534ac79f
commit 0c0476b413
2 changed files with 52 additions and 4 deletions

View File

@@ -27,6 +27,7 @@ import androidx.compose.material3.Scaffold
import androidx.compose.material3.SnackbarHost
import androidx.compose.material3.SnackbarHostState
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
@@ -183,6 +184,31 @@ fun MainScreen(
canNavigateUp = viewModel.canNavigateUp(),
modifier = Modifier.weight(1f)
)
} else if (uiState.hasRoot != true) {
Box(
modifier = Modifier.fillMaxSize(),
contentAlignment = Alignment.Center
) {
Column(
horizontalAlignment = Alignment.CenterHorizontally
) {
Text(
text = "Root Access Required",
style = MaterialTheme.typography.titleLarge,
color = MaterialTheme.colorScheme.onSurface
)
Spacer(modifier = Modifier.height(8.dp))
Text(
text = "Grant root access to use ISO Droid",
style = MaterialTheme.typography.bodyMedium,
color = MaterialTheme.colorScheme.onSurfaceVariant
)
Spacer(modifier = Modifier.height(16.dp))
TextButton(onClick = { viewModel.requestRootAccess() }) {
Text("Grant Root Access")
}
}
}
}
}
}

View File

@@ -172,11 +172,20 @@ fun SettingsScreen(
// Storage section
SectionHeader(title = "Storage")
val hasRootForStorage = uiState.hasRoot ?: false
SettingsItem(
icon = Icons.Default.Folder,
title = "ISO Directory",
subtitle = uiState.isoDirectory,
onClick = { showPathDialog = true }
enabled = hasRootForStorage,
disabledHint = "Tap to grant root access",
onClick = {
if (hasRootForStorage) {
showPathDialog = true
} else {
viewModel.requestRootAccess()
}
}
)
HorizontalDivider(modifier = Modifier.padding(horizontal = 16.dp))
@@ -814,8 +823,12 @@ private fun SettingsItem(
icon: ImageVector,
title: String,
subtitle: String,
enabled: Boolean = true,
disabledHint: String? = null,
onClick: () -> Unit
) {
val contentAlpha = if (enabled) 1f else 0.38f
Row(
modifier = Modifier
.fillMaxWidth()
@@ -826,19 +839,28 @@ private fun SettingsItem(
Icon(
imageVector = icon,
contentDescription = null,
tint = MaterialTheme.colorScheme.onSurfaceVariant
tint = MaterialTheme.colorScheme.onSurfaceVariant.copy(alpha = contentAlpha)
)
Spacer(modifier = Modifier.width(16.dp))
Column(modifier = Modifier.weight(1f)) {
Text(
text = title,
style = MaterialTheme.typography.bodyLarge
style = MaterialTheme.typography.bodyLarge,
color = MaterialTheme.colorScheme.onSurface.copy(alpha = contentAlpha)
)
Text(
text = subtitle,
style = MaterialTheme.typography.bodySmall,
color = MaterialTheme.colorScheme.onSurfaceVariant
color = MaterialTheme.colorScheme.onSurfaceVariant.copy(alpha = contentAlpha)
)
if (!enabled && disabledHint != null) {
Spacer(modifier = Modifier.height(4.dp))
Text(
text = disabledHint,
style = MaterialTheme.typography.bodySmall,
color = MaterialTheme.colorScheme.error.copy(alpha = 0.7f)
)
}
}
}
}