Compare commits
2 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| d6220b7bd7 | |||
| c8e50ac17e |
@@ -1,5 +1,6 @@
|
|||||||
package com.syncflow.ui.addpair
|
package com.syncflow.ui.addpair
|
||||||
|
|
||||||
|
import android.content.Intent
|
||||||
import android.net.Uri
|
import android.net.Uri
|
||||||
import androidx.activity.compose.rememberLauncherForActivityResult
|
import androidx.activity.compose.rememberLauncherForActivityResult
|
||||||
import androidx.activity.result.contract.ActivityResultContracts
|
import androidx.activity.result.contract.ActivityResultContracts
|
||||||
@@ -14,6 +15,7 @@ import androidx.compose.material3.*
|
|||||||
import androidx.compose.runtime.*
|
import androidx.compose.runtime.*
|
||||||
import androidx.compose.ui.Alignment
|
import androidx.compose.ui.Alignment
|
||||||
import androidx.compose.ui.Modifier
|
import androidx.compose.ui.Modifier
|
||||||
|
import androidx.compose.ui.platform.LocalContext
|
||||||
import androidx.compose.ui.text.font.FontWeight
|
import androidx.compose.ui.text.font.FontWeight
|
||||||
import androidx.compose.ui.text.input.ImeAction
|
import androidx.compose.ui.text.input.ImeAction
|
||||||
import androidx.compose.ui.text.input.KeyboardType
|
import androidx.compose.ui.text.input.KeyboardType
|
||||||
@@ -29,10 +31,17 @@ fun AddPairScreen(onDone: () -> Unit, vm: AddPairViewModel = hiltViewModel()) {
|
|||||||
val s by vm.state.collectAsState()
|
val s by vm.state.collectAsState()
|
||||||
LaunchedEffect(s.done) { if (s.done) onDone() }
|
LaunchedEffect(s.done) { if (s.done) onDone() }
|
||||||
|
|
||||||
|
val context = LocalContext.current
|
||||||
var showRemoteBrowser by remember { mutableStateOf(false) }
|
var showRemoteBrowser by remember { mutableStateOf(false) }
|
||||||
|
|
||||||
val dirPicker = rememberLauncherForActivityResult(ActivityResultContracts.OpenDocumentTree()) { uri: Uri? ->
|
val dirPicker = rememberLauncherForActivityResult(ActivityResultContracts.OpenDocumentTree()) { uri: Uri? ->
|
||||||
uri?.let { vm.update { copy(localPath = it.toString()) } }
|
uri?.let {
|
||||||
|
context.contentResolver.takePersistableUriPermission(
|
||||||
|
it,
|
||||||
|
Intent.FLAG_GRANT_READ_URI_PERMISSION or Intent.FLAG_GRANT_WRITE_URI_PERMISSION,
|
||||||
|
)
|
||||||
|
vm.update { copy(localPath = it.toString()) }
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (showRemoteBrowser && s.selectedAccountId != -1L) {
|
if (showRemoteBrowser && s.selectedAccountId != -1L) {
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ class HomeViewModel @Inject constructor(
|
|||||||
.stateIn(viewModelScope, SharingStarted.WhileSubscribed(5000), emptyList())
|
.stateIn(viewModelScope, SharingStarted.WhileSubscribed(5000), emptyList())
|
||||||
|
|
||||||
fun triggerSync(pair: SyncPairEntity) {
|
fun triggerSync(pair: SyncPairEntity) {
|
||||||
val req = SyncWorker.buildOneTimeRequest(pair.id, pair.wifiOnly, pair.chargingOnly)
|
val req = SyncWorker.buildOneTimeRequest(pair.id, wifiOnly = false, chargingOnly = false)
|
||||||
workManager.enqueue(req)
|
workManager.enqueue(req)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -48,6 +48,7 @@ fun SyncFlowNavGraph(navController: NavHostController) {
|
|||||||
) {
|
) {
|
||||||
PairDetailScreen(
|
PairDetailScreen(
|
||||||
onBack = { navController.popBackStack() },
|
onBack = { navController.popBackStack() },
|
||||||
|
onEdit = { id -> navController.navigate(Screen.AddPair.route(id)) },
|
||||||
onConflicts = { id -> navController.navigate(Screen.Conflicts.route(id)) },
|
onConflicts = { id -> navController.navigate(Screen.Conflicts.route(id)) },
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -21,6 +21,7 @@ import java.time.format.FormatStyle
|
|||||||
@Composable
|
@Composable
|
||||||
fun PairDetailScreen(
|
fun PairDetailScreen(
|
||||||
onBack: () -> Unit,
|
onBack: () -> Unit,
|
||||||
|
onEdit: (Long) -> Unit,
|
||||||
onConflicts: (Long) -> Unit,
|
onConflicts: (Long) -> Unit,
|
||||||
vm: PairDetailViewModel = hiltViewModel(),
|
vm: PairDetailViewModel = hiltViewModel(),
|
||||||
) {
|
) {
|
||||||
@@ -49,6 +50,7 @@ fun PairDetailScreen(
|
|||||||
title = { Text(pair?.name ?: "…") },
|
title = { Text(pair?.name ?: "…") },
|
||||||
navigationIcon = { IconButton(onClick = onBack) { Icon(Icons.Default.ArrowBack, "Back") } },
|
navigationIcon = { IconButton(onClick = onBack) { Icon(Icons.Default.ArrowBack, "Back") } },
|
||||||
actions = {
|
actions = {
|
||||||
|
IconButton(onClick = { pair?.let { onEdit(it.id) } }) { Icon(Icons.Default.Edit, "Edit") }
|
||||||
IconButton(onClick = { vm.syncNow() }) { Icon(Icons.Default.Sync, "Sync now") }
|
IconButton(onClick = { vm.syncNow() }) { Icon(Icons.Default.Sync, "Sync now") }
|
||||||
IconButton(onClick = { showDelete = true }) { Icon(Icons.Default.Delete, "Delete") }
|
IconButton(onClick = { showDelete = true }) { Icon(Icons.Default.Delete, "Delete") }
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -36,7 +36,7 @@ class PairDetailViewModel @Inject constructor(
|
|||||||
|
|
||||||
fun syncNow() {
|
fun syncNow() {
|
||||||
val p = pair.value ?: return
|
val p = pair.value ?: return
|
||||||
workManager.enqueue(SyncWorker.buildOneTimeRequest(p.id, p.wifiOnly, p.chargingOnly))
|
workManager.enqueue(SyncWorker.buildOneTimeRequest(p.id, wifiOnly = false, chargingOnly = false))
|
||||||
}
|
}
|
||||||
|
|
||||||
fun delete() {
|
fun delete() {
|
||||||
|
|||||||
+2
-2
@@ -1,2 +1,2 @@
|
|||||||
VERSION_NAME=1.0.1
|
VERSION_NAME=1.0.3
|
||||||
VERSION_CODE=2
|
VERSION_CODE=4
|
||||||
|
|||||||
Reference in New Issue
Block a user