Feat: Display selected sync folder in navigation drawer

Adds the currently selected sync folder path to the navigation drawer.

This provides users with clear feedback on which folder is configured for synchronization. The displayed path is shortened to `Parent / Child` for readability and to prevent layout issues.
This commit is contained in:
2025-10-20 13:07:12 +02:00
parent 6068833eba
commit 312477ab19

View File

@@ -1105,7 +1105,36 @@ fun AppShell(
item {
NavigationDrawerItem(
label = { Text(stringResource(R.string.select_sync_folder)) },
label = {
Column {
Text(stringResource(id = R.string.select_sync_folder))
val syncFolderUriString = sharedPrefs.getString("sync_folder_uri", null)
if (!syncFolderUriString.isNullOrBlank()) {
val displayPath = remember(syncFolderUriString) {
try {
val uri = android.net.Uri.parse(syncFolderUriString)
val docFile = DocumentFile.fromTreeUri(context, uri)
val currentName = docFile?.name
val parentName = docFile?.parentFile?.name
if (parentName != null && currentName != null) {
"$parentName / $currentName"
} else {
currentName ?: ""
}
} catch (e: Exception) {
"Ungültiger Pfad"
}
}
Text(
text = displayPath,
style = MaterialTheme.typography.bodySmall,
color = MaterialTheme.colorScheme.onSurfaceVariant,
maxLines = 1,
overflow = androidx.compose.ui.text.style.TextOverflow.Ellipsis
)
}
}
},
selected = false,
onClick = {
syncFolderLauncher.launch(null)