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:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user