Save editing files on folderApp & make priority to local source on search
This commit is contained in:
parent
2d9df62a50
commit
685303c6e1
4 changed files with 29 additions and 8 deletions
|
|
@ -1184,8 +1184,8 @@ fun EditSourceCompose(
|
|||
onSave = {
|
||||
scope.launch {
|
||||
try {
|
||||
saveLauncher.launch(fileName)
|
||||
|
||||
val initialDir = solfaScreenModel.fileRepository.getAppPublicFolder().absolutePath
|
||||
saveLauncher.launch(fileName, initialDir)
|
||||
} catch (e: Exception) {
|
||||
e.printStackTrace()
|
||||
}
|
||||
|
|
|
|||
|
|
@ -9,6 +9,7 @@ import androidx.compose.foundation.lazy.itemsIndexed
|
|||
import androidx.compose.foundation.shape.CircleShape
|
||||
import androidx.compose.foundation.shape.RoundedCornerShape
|
||||
import androidx.compose.material.icons.Icons
|
||||
import androidx.compose.material.icons.automirrored.filled.InsertDriveFile
|
||||
import androidx.compose.material.icons.automirrored.filled.Undo
|
||||
import androidx.compose.material.icons.filled.*
|
||||
import androidx.compose.material3.*
|
||||
|
|
@ -284,7 +285,14 @@ fun MainScreenWithDrawer(
|
|||
) {
|
||||
FloatingActionButton(
|
||||
onClick = {
|
||||
saveLauncher.launch(fileName)
|
||||
scope.launch {
|
||||
try {
|
||||
val initialDir = solfaScreenModel.fileRepository.getAppPublicFolder().absolutePath
|
||||
saveLauncher.launch(fileName, initialDir)
|
||||
} catch (e: Exception) {
|
||||
e.printStackTrace()
|
||||
}
|
||||
}
|
||||
}, modifier = Modifier.alpha(0.45f)
|
||||
) {
|
||||
Icon(
|
||||
|
|
@ -483,16 +491,28 @@ fun MainScreenWithDrawer(
|
|||
)
|
||||
) {
|
||||
if (filteredSongs.isNotEmpty()) {
|
||||
val sortedSongs = remember(filteredSongs) {
|
||||
filteredSongs.sortedBy { item ->
|
||||
item.path.startsWith("assets://")
|
||||
}
|
||||
}
|
||||
LazyColumn(Modifier.fillMaxSize()) {
|
||||
itemsIndexed(filteredSongs, key = {_, item -> item.path}) { index, item ->
|
||||
itemsIndexed(sortedSongs, key = {_, item -> item.path}) { index, item ->
|
||||
val isFavorite = favoritePaths.contains(item)
|
||||
ListItem(
|
||||
leadingContent = {
|
||||
Icon(
|
||||
imageVector = if(item.path.startsWith("assets://")) Icons.Default.ArrowDropDownCircle else Icons.Default.Folder,
|
||||
contentDescription = null,
|
||||
modifier = Modifier.size(30.dp)
|
||||
)
|
||||
},
|
||||
headlineContent = { Text(item.title) },
|
||||
supportingContent = { Text(item.contentTitle, maxLines = 1) },
|
||||
trailingContent = {
|
||||
IconButton(
|
||||
onClick = { sharedScreenModel.toggleFavorite(item.path) },
|
||||
modifier = Modifier.size(30.dp)
|
||||
modifier = Modifier.size(25.dp)
|
||||
) {
|
||||
Icon(
|
||||
imageVector = Icons.Default.Star,
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@ package mg.dot.feufaro.ui
|
|||
import androidx.compose.runtime.Composable
|
||||
|
||||
interface FileSaveLauncher {
|
||||
fun launch(defaultName: String)
|
||||
fun launch(defaultName: String, initialDir: String?)
|
||||
}
|
||||
|
||||
@Composable
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@ package mg.dot.feufaro.ui
|
|||
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.runtime.remember
|
||||
import androidx.compose.ui.graphics.Color
|
||||
import kotlinx.coroutines.CoroutineScope
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.launch
|
||||
|
|
@ -16,10 +17,10 @@ actual fun rememberFileSaveLauncher(
|
|||
): FileSaveLauncher {
|
||||
return remember {
|
||||
object : FileSaveLauncher {
|
||||
override fun launch(defaultName: String) {
|
||||
override fun launch(defaultName: String, initialDir: String?) {
|
||||
CoroutineScope(Dispatchers.IO).launch {
|
||||
val dialog = FileDialog(null as Frame?, "Sauvegarder la source", FileDialog.SAVE)
|
||||
dialog.directory = System.getProperty("user.home")
|
||||
dialog.directory = initialDir
|
||||
dialog.file = defaultName
|
||||
dialog.isVisible = true
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue