feat: Show better splitted path

This commit is contained in:
Myzel394 2023-11-19 18:29:05 +01:00
parent 703e783193
commit d0701868cf
No known key found for this signature in database
GPG Key ID: 79CC92F37B3E1A2B

View File

@ -2,6 +2,7 @@ package app.myzel394.alibi.ui.components.SettingsScreen.atoms
import android.content.Intent
import android.net.Uri
import android.text.TextUtils.split
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Spacer
@ -38,6 +39,7 @@ import app.myzel394.alibi.db.AppSettings
import app.myzel394.alibi.ui.components.atoms.SettingsTile
import app.myzel394.alibi.ui.utils.rememberFolderSelectorDialog
import kotlinx.coroutines.launch
import java.net.URLDecoder
@Composable
fun SaveFolderTile(
@ -165,6 +167,7 @@ fun SaveFolderTile(
}
},
extra = {
println(settings.audioRecorderSettings.saveFolder)
Column(
modifier = Modifier.fillMaxWidth(),
horizontalAlignment = Alignment.CenterHorizontally,
@ -174,11 +177,7 @@ fun SaveFolderTile(
Text(
text = stringResource(
R.string.form_value_selected,
settings
.audioRecorderSettings
.saveFolder
.split(":")[1]
.replace("/", " > ")
splitPath(settings.audioRecorderSettings.saveFolder).joinToString(" > ")
),
style = MaterialTheme.typography.bodySmall,
color = MaterialTheme.colorScheme.onSurfaceVariant,
@ -220,3 +219,14 @@ fun SaveFolderTile(
}
)
}
fun splitPath(path: String): List<String> {
return try {
URLDecoder
.decode(path, "UTF-8")
.split(":", limit = 3)[2]
.split("/")
} catch (e: Exception) {
listOf(path)
}
}