Compare commits
10 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 99193af2c5 | |||
| 3c008ec8df | |||
| c869f84a9d | |||
| c3be23417d | |||
| ae10ed0c82 | |||
| 897b685c70 | |||
| 4b20697bb1 | |||
| 66d28761a8 | |||
| ec478531da | |||
| 5ade80a334 |
@@ -13,6 +13,8 @@ import okhttp3.*
|
||||
import okhttp3.HttpUrl.Companion.toHttpUrlOrNull
|
||||
import okhttp3.MediaType.Companion.toMediaType
|
||||
import okhttp3.RequestBody.Companion.toRequestBody
|
||||
import okio.BufferedSink
|
||||
import okio.source
|
||||
import org.xmlpull.v1.XmlPullParser
|
||||
import org.xmlpull.v1.XmlPullParserFactory
|
||||
import java.io.InputStream
|
||||
@@ -84,13 +86,18 @@ open class WebDavProvider(protected val account: CloudAccount) : CloudProvider {
|
||||
onProgress: (Long) -> Unit,
|
||||
): Result<RemoteFile> = runCatching {
|
||||
withContext(Dispatchers.IO) {
|
||||
val bytes = localStream.readBytes()
|
||||
val body = bytes.toRequestBody("application/octet-stream".toMediaType())
|
||||
val body = object : RequestBody() {
|
||||
override fun contentType() = "application/octet-stream".toMediaType()
|
||||
override fun contentLength() = sizeBytes
|
||||
override fun writeTo(sink: BufferedSink) {
|
||||
localStream.source().use { source -> sink.writeAll(source) }
|
||||
}
|
||||
}
|
||||
val req = Request.Builder().url(url(remotePath)).put(body).build()
|
||||
client.newCall(req).execute().use { resp ->
|
||||
if (!resp.isSuccessful) throw Exception("Upload HTTP ${resp.code}")
|
||||
}
|
||||
onProgress(bytes.size.toLong())
|
||||
onProgress(sizeBytes)
|
||||
getFileMetadata(remotePath).getOrThrow()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -62,13 +62,28 @@ class SyncEngine @Inject constructor(
|
||||
else
|
||||
LocalAccessor.JavaFile(File(localPath))
|
||||
|
||||
private suspend fun performSync(pair: SyncPair, provider: CloudProvider): SyncResult {
|
||||
private suspend fun performSync(
|
||||
pair: SyncPair,
|
||||
provider: CloudProvider,
|
||||
isRetry: Boolean = false,
|
||||
): SyncResult {
|
||||
val accessor = makeAccessor(pair.localPath)
|
||||
val knownStates = fileStateDao.getForPair(pair.id).associateBy { it.relativePath }
|
||||
var knownStates = fileStateDao.getForPair(pair.id).associateBy { it.relativePath }
|
||||
val remoteFiles = provider.listFiles(pair.remotePath).getOrThrow()
|
||||
.associateBy { it.path.removePrefix(pair.remotePath).trimStart('/') }
|
||||
val localFiles = accessor.walkFiles(pair)
|
||||
|
||||
// Self-healing: if every known-state path is absent from the current local scan but
|
||||
// the local folder does have files, the localPath was changed without clearing state.
|
||||
// The stale records would cause every old file to look like "DELETE_REMOTE" and every
|
||||
// new file to re-upload indefinitely. Wipe and retry once as a fresh initial sync.
|
||||
if (!isRetry && knownStates.isNotEmpty() && localFiles.isNotEmpty() &&
|
||||
knownStates.keys.none { it in localFiles }) {
|
||||
Timber.w("SyncEngine: stale folder states detected for pair ${pair.id} — resetting")
|
||||
fileStateDao.deleteForPair(pair.id)
|
||||
return performSync(pair, provider, isRetry = true)
|
||||
}
|
||||
|
||||
val allPaths = (localFiles.keys + remoteFiles.keys + knownStates.keys).toSet()
|
||||
val hasPriorSyncState = knownStates.isNotEmpty()
|
||||
val semaphore = Semaphore(4)
|
||||
@@ -92,11 +107,10 @@ class SyncEngine @Inject constructor(
|
||||
|
||||
when (decision) {
|
||||
SyncDecision.UPLOAD -> {
|
||||
var uploadedRemoteFile: RemoteFile? = null
|
||||
val bytes = runCatching {
|
||||
ensureRemoteDirs(provider, pair.remotePath, rel)
|
||||
accessor.openInputStream(rel)?.use { stream ->
|
||||
uploadedRemoteFile = provider.uploadFile(stream, "${pair.remotePath}/$rel", local!!.sizeBytes) { }.getOrThrow()
|
||||
provider.uploadFile(stream, "${pair.remotePath}/$rel", local!!.sizeBytes) { }.getOrThrow()
|
||||
}
|
||||
local!!.sizeBytes
|
||||
}.getOrElse { e ->
|
||||
@@ -105,8 +119,12 @@ class SyncEngine @Inject constructor(
|
||||
return@withPermit FileOutcome(failed = 1)
|
||||
}
|
||||
logEvent(pair.id, SyncEventType.FILE_UPLOADED, rel, null, bytes)
|
||||
// Don't store remote metadata from upload response — the server (Nextcloud etc.)
|
||||
// may change mtime/etag during post-upload processing. Leaving remoteModifiedAt
|
||||
// null forces the SKIP reconciliation on the next sync to fill it in from the
|
||||
// directory listing, which is the same source all future syncs will use.
|
||||
FileOutcome(uploaded = 1, bytesTransferred = bytes,
|
||||
newState = buildState(pair.id, rel, local!!, remoteAfterTransfer = uploadedRemoteFile))
|
||||
newState = buildState(pair.id, rel, local!!, remoteAfterTransfer = null))
|
||||
}
|
||||
SyncDecision.DOWNLOAD -> {
|
||||
val bytes = runCatching {
|
||||
@@ -131,13 +149,15 @@ class SyncEngine @Inject constructor(
|
||||
storeLocalMtime = false))
|
||||
}
|
||||
SyncDecision.DELETE_LOCAL -> {
|
||||
accessor.delete(rel)
|
||||
val deleted = accessor.delete(rel)
|
||||
if (!deleted) Timber.w("SyncEngine: DELETE_LOCAL failed (silent) for $rel")
|
||||
fileStateDao.delete(pair.id, rel)
|
||||
logEvent(pair.id, SyncEventType.FILE_DELETED, rel, "local", 0)
|
||||
FileOutcome(deleted = 1)
|
||||
}
|
||||
SyncDecision.DELETE_REMOTE -> {
|
||||
provider.deleteFile("${pair.remotePath}/$rel")
|
||||
runCatching { provider.deleteFile("${pair.remotePath}/$rel") }
|
||||
.onFailure { e -> Timber.e(e, "SyncEngine: DELETE_REMOTE failed for $rel") }
|
||||
fileStateDao.delete(pair.id, rel)
|
||||
logEvent(pair.id, SyncEventType.FILE_DELETED, rel, "remote", 0)
|
||||
FileOutcome(deleted = 1)
|
||||
@@ -268,21 +288,15 @@ internal fun syncDecide(
|
||||
}
|
||||
|
||||
!localExists && remoteExists -> when {
|
||||
known == null -> if (!hasPriorSyncState) {
|
||||
// Initial sync: no history at all — remote files are new, download them.
|
||||
known == null -> {
|
||||
// No state record: could be a new remote file OR a file whose state was lost.
|
||||
// Downloading is always safer than deleting — if the user deleted the local
|
||||
// copy intentionally, the state record will still exist (known != null) and
|
||||
// the else-branch below correctly deletes the remote copy.
|
||||
when (direction) {
|
||||
SyncDirection.DOWNLOAD_ONLY, SyncDirection.TWO_WAY -> SyncDecision.DOWNLOAD
|
||||
else -> SyncDecision.SKIP
|
||||
}
|
||||
} else {
|
||||
// Pair has been synced before but this file has no state record
|
||||
// (e.g. uploaded before state-tracking was fixed). Treat the same
|
||||
// as a known remote-deletion: apply mirror/keep behavior.
|
||||
when {
|
||||
deleteBehavior == DeleteBehavior.KEEP -> SyncDecision.SKIP
|
||||
direction == SyncDirection.UPLOAD_ONLY || direction == SyncDirection.TWO_WAY -> SyncDecision.DELETE_REMOTE
|
||||
else -> SyncDecision.SKIP
|
||||
}
|
||||
}
|
||||
else -> when {
|
||||
deleteBehavior == DeleteBehavior.KEEP -> SyncDecision.SKIP
|
||||
|
||||
@@ -1,10 +1,7 @@
|
||||
package com.syncflow.ui.addpair
|
||||
|
||||
import android.content.Intent
|
||||
import android.net.Uri
|
||||
import androidx.activity.compose.rememberLauncherForActivityResult
|
||||
import androidx.activity.result.contract.ActivityResultContracts
|
||||
import androidx.compose.animation.AnimatedVisibility
|
||||
import androidx.compose.foundation.clickable
|
||||
import androidx.compose.foundation.layout.*
|
||||
import androidx.compose.foundation.rememberScrollState
|
||||
import androidx.compose.foundation.text.KeyboardOptions
|
||||
@@ -15,13 +12,13 @@ import androidx.compose.material3.*
|
||||
import androidx.compose.runtime.*
|
||||
import androidx.compose.ui.Alignment
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.platform.LocalContext
|
||||
import androidx.compose.ui.text.font.FontWeight
|
||||
import androidx.compose.ui.text.input.ImeAction
|
||||
import androidx.compose.ui.text.input.KeyboardType
|
||||
import androidx.compose.ui.unit.dp
|
||||
import androidx.hilt.navigation.compose.hiltViewModel
|
||||
import com.syncflow.domain.model.*
|
||||
import com.syncflow.ui.browser.LocalBrowserDialog
|
||||
import com.syncflow.ui.browser.RemoteBrowserDialog
|
||||
import java.time.DayOfWeek
|
||||
|
||||
@@ -31,17 +28,18 @@ fun AddPairScreen(onDone: () -> Unit, vm: AddPairViewModel = hiltViewModel()) {
|
||||
val s by vm.state.collectAsState()
|
||||
LaunchedEffect(s.done) { if (s.done) onDone() }
|
||||
|
||||
val context = LocalContext.current
|
||||
var showRemoteBrowser by remember { mutableStateOf(false) }
|
||||
var showLocalBrowser by remember { mutableStateOf(false) }
|
||||
|
||||
val dirPicker = rememberLauncherForActivityResult(ActivityResultContracts.OpenDocumentTree()) { uri: Uri? ->
|
||||
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 (showLocalBrowser) {
|
||||
LocalBrowserDialog(
|
||||
initialPath = s.localPath.ifBlank { "" },
|
||||
onSelect = { path ->
|
||||
vm.update { copy(localPath = path) }
|
||||
showLocalBrowser = false
|
||||
},
|
||||
onDismiss = { showLocalBrowser = false },
|
||||
)
|
||||
}
|
||||
|
||||
if (showRemoteBrowser && s.selectedAccountId != -1L) {
|
||||
@@ -108,18 +106,17 @@ fun AddPairScreen(onDone: () -> Unit, vm: AddPairViewModel = hiltViewModel()) {
|
||||
Spacer(Modifier.height(4.dp))
|
||||
|
||||
// Local folder
|
||||
OutlinedTextField(
|
||||
value = uriToDisplay(s.localPath), onValueChange = {},
|
||||
label = { Text("Local folder") },
|
||||
leadingIcon = { Icon(Icons.Default.PhoneAndroid, null) },
|
||||
trailingIcon = {
|
||||
IconButton(onClick = { dirPicker.launch(null) }) {
|
||||
Icon(Icons.Default.FolderOpen, "Browse")
|
||||
}
|
||||
},
|
||||
readOnly = true, singleLine = true, modifier = Modifier.fillMaxWidth(),
|
||||
placeholder = { Text("Tap to choose folder…") },
|
||||
)
|
||||
Box(modifier = Modifier.fillMaxWidth()) {
|
||||
OutlinedTextField(
|
||||
value = uriToDisplay(s.localPath), onValueChange = {},
|
||||
label = { Text("Local folder") },
|
||||
leadingIcon = { Icon(Icons.Default.PhoneAndroid, null) },
|
||||
trailingIcon = { Icon(Icons.Default.FolderOpen, null) },
|
||||
readOnly = true, singleLine = true, modifier = Modifier.fillMaxWidth(),
|
||||
placeholder = { Text("Tap to choose folder…") },
|
||||
)
|
||||
Box(modifier = Modifier.matchParentSize().clickable { showLocalBrowser = true })
|
||||
}
|
||||
|
||||
// Remote folder
|
||||
OutlinedTextField(
|
||||
|
||||
@@ -0,0 +1,352 @@
|
||||
package com.syncflow.ui.browser
|
||||
|
||||
import androidx.compose.foundation.background
|
||||
import androidx.compose.foundation.clickable
|
||||
import androidx.compose.foundation.layout.*
|
||||
import androidx.compose.foundation.lazy.LazyColumn
|
||||
import androidx.compose.foundation.lazy.LazyRow
|
||||
import androidx.compose.foundation.lazy.items
|
||||
import androidx.compose.foundation.lazy.itemsIndexed
|
||||
import androidx.compose.foundation.lazy.rememberLazyListState
|
||||
import androidx.compose.foundation.shape.RoundedCornerShape
|
||||
import androidx.compose.foundation.text.KeyboardActions
|
||||
import androidx.compose.foundation.text.KeyboardOptions
|
||||
import androidx.compose.material.icons.Icons
|
||||
import androidx.compose.material.icons.automirrored.filled.ArrowBack
|
||||
import androidx.compose.material.icons.filled.*
|
||||
import androidx.compose.material3.*
|
||||
import androidx.compose.runtime.*
|
||||
import androidx.compose.ui.Alignment
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.draw.clip
|
||||
import androidx.compose.ui.focus.FocusRequester
|
||||
import androidx.compose.ui.focus.focusRequester
|
||||
import androidx.compose.ui.graphics.Color
|
||||
import androidx.compose.ui.graphics.vector.ImageVector
|
||||
import androidx.compose.ui.text.font.FontWeight
|
||||
import androidx.compose.ui.text.input.ImeAction
|
||||
import androidx.compose.ui.text.style.TextOverflow
|
||||
import androidx.compose.ui.platform.LocalDensity
|
||||
import androidx.compose.ui.platform.LocalView
|
||||
import androidx.compose.ui.unit.Dp
|
||||
import androidx.compose.ui.unit.dp
|
||||
import androidx.compose.ui.window.Dialog
|
||||
import androidx.compose.ui.window.DialogProperties
|
||||
import androidx.core.view.ViewCompat
|
||||
import androidx.core.view.WindowInsetsCompat
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.launch
|
||||
import kotlinx.coroutines.withContext
|
||||
import java.io.File
|
||||
|
||||
private data class LocalEntry(val file: File, val childCount: Int)
|
||||
|
||||
private val STORAGE_ROOT = File("/storage/emulated/0")
|
||||
|
||||
private data class Shortcut(val label: String, val icon: ImageVector, val path: String)
|
||||
private val SHORTCUTS = listOf(
|
||||
Shortcut("Camera", Icons.Default.PhotoCamera, "/storage/emulated/0/DCIM/Camera"),
|
||||
Shortcut("Downloads", Icons.Default.Download, "/storage/emulated/0/Download"),
|
||||
Shortcut("Documents", Icons.Default.Description, "/storage/emulated/0/Documents"),
|
||||
Shortcut("Pictures", Icons.Default.Image, "/storage/emulated/0/Pictures"),
|
||||
Shortcut("Music", Icons.Default.MusicNote, "/storage/emulated/0/Music"),
|
||||
Shortcut("Videos", Icons.Default.Videocam, "/storage/emulated/0/Movies"),
|
||||
)
|
||||
|
||||
@OptIn(ExperimentalMaterial3Api::class)
|
||||
@Composable
|
||||
fun LocalBrowserDialog(
|
||||
initialPath: String = STORAGE_ROOT.absolutePath,
|
||||
onSelect: (path: String) -> Unit,
|
||||
onDismiss: () -> Unit,
|
||||
) {
|
||||
var currentPath by remember { mutableStateOf(File(initialPath.ifBlank { STORAGE_ROOT.absolutePath }).let { if (it.isDirectory) it else STORAGE_ROOT }) }
|
||||
var pathStack by remember { mutableStateOf(listOf(currentPath)) }
|
||||
var entries by remember { mutableStateOf<List<LocalEntry>>(emptyList()) }
|
||||
var isLoading by remember { mutableStateOf(true) }
|
||||
var searchQuery by remember { mutableStateOf("") }
|
||||
var searchActive by remember { mutableStateOf(false) }
|
||||
val breadcrumbState = rememberLazyListState()
|
||||
val scope = rememberCoroutineScope()
|
||||
|
||||
fun loadDir(dir: File) {
|
||||
isLoading = true
|
||||
entries = emptyList()
|
||||
scope.launch {
|
||||
val result = withContext(Dispatchers.IO) {
|
||||
dir.listFiles()
|
||||
?.filter { it.isDirectory && !it.name.startsWith(".") }
|
||||
?.sortedBy { it.name.lowercase() }
|
||||
?.map { f -> LocalEntry(f, f.listFiles()?.count { it.isDirectory } ?: 0) }
|
||||
?: emptyList()
|
||||
}
|
||||
entries = result
|
||||
isLoading = false
|
||||
}
|
||||
}
|
||||
|
||||
fun navigateTo(dir: File) {
|
||||
currentPath = dir
|
||||
pathStack = pathStack + dir
|
||||
searchQuery = ""
|
||||
searchActive = false
|
||||
loadDir(dir)
|
||||
}
|
||||
|
||||
fun navigateUp(): Boolean {
|
||||
if (pathStack.size <= 1) return false
|
||||
val newStack = pathStack.dropLast(1)
|
||||
pathStack = newStack
|
||||
currentPath = newStack.last()
|
||||
searchQuery = ""
|
||||
searchActive = false
|
||||
loadDir(currentPath)
|
||||
return true
|
||||
}
|
||||
|
||||
fun navigateToBreadcrumb(dir: File) {
|
||||
val idx = pathStack.indexOfLast { it.absolutePath == dir.absolutePath }
|
||||
pathStack = if (idx >= 0) pathStack.take(idx + 1) else listOf(dir)
|
||||
currentPath = dir
|
||||
searchQuery = ""
|
||||
searchActive = false
|
||||
loadDir(dir)
|
||||
}
|
||||
|
||||
LaunchedEffect(Unit) { loadDir(currentPath) }
|
||||
|
||||
// Build breadcrumb segments relative to storage root
|
||||
val relParts = currentPath.absolutePath
|
||||
.removePrefix(STORAGE_ROOT.absolutePath)
|
||||
.trimStart('/')
|
||||
.split('/')
|
||||
.filter { it.isNotEmpty() }
|
||||
|
||||
// Auto-scroll breadcrumbs to end
|
||||
LaunchedEffect(currentPath) {
|
||||
scope.launch { breadcrumbState.animateScrollToItem(maxOf(0, relParts.size)) }
|
||||
}
|
||||
|
||||
val filtered = if (searchQuery.isBlank()) entries
|
||||
else entries.filter { it.file.name.contains(searchQuery, ignoreCase = true) }
|
||||
|
||||
val currentFolderName = currentPath.name.ifBlank { "Internal Storage" }
|
||||
|
||||
Dialog(
|
||||
onDismissRequest = onDismiss,
|
||||
properties = DialogProperties(usePlatformDefaultWidth = false, decorFitsSystemWindows = false),
|
||||
) {
|
||||
val view = LocalView.current
|
||||
val density = LocalDensity.current
|
||||
var topInset by remember { mutableStateOf(0.dp) }
|
||||
var bottomInset by remember { mutableStateOf(56.dp) }
|
||||
DisposableEffect(view) {
|
||||
ViewCompat.setOnApplyWindowInsetsListener(view) { _, insets ->
|
||||
val bars = insets.getInsets(WindowInsetsCompat.Type.systemBars())
|
||||
with(density) {
|
||||
topInset = bars.top.toDp()
|
||||
bottomInset = maxOf(bars.bottom.toDp(), 56.dp)
|
||||
}
|
||||
insets
|
||||
}
|
||||
ViewCompat.requestApplyInsets(view)
|
||||
onDispose { ViewCompat.setOnApplyWindowInsetsListener(view, null) }
|
||||
}
|
||||
|
||||
Surface(modifier = Modifier.fillMaxSize(), color = MaterialTheme.colorScheme.surface) {
|
||||
Column(modifier = Modifier.fillMaxSize().padding(top = topInset)) {
|
||||
|
||||
// ── Top bar ──────────────────────────────────────────────────
|
||||
TopAppBar(
|
||||
navigationIcon = {
|
||||
IconButton(onClick = { if (!navigateUp()) onDismiss() }) {
|
||||
Icon(Icons.AutoMirrored.Filled.ArrowBack, null)
|
||||
}
|
||||
},
|
||||
title = {
|
||||
if (searchActive) {
|
||||
val focusRequester = remember { FocusRequester() }
|
||||
LaunchedEffect(Unit) { focusRequester.requestFocus() }
|
||||
OutlinedTextField(
|
||||
value = searchQuery,
|
||||
onValueChange = { searchQuery = it },
|
||||
modifier = Modifier.fillMaxWidth().focusRequester(focusRequester),
|
||||
placeholder = { Text("Search folders…") },
|
||||
singleLine = true,
|
||||
keyboardOptions = KeyboardOptions(imeAction = ImeAction.Search),
|
||||
keyboardActions = KeyboardActions(onSearch = {}),
|
||||
colors = OutlinedTextFieldDefaults.colors(
|
||||
focusedBorderColor = Color.Transparent,
|
||||
unfocusedBorderColor = Color.Transparent,
|
||||
),
|
||||
)
|
||||
} else {
|
||||
Text("Choose Local Folder", style = MaterialTheme.typography.titleMedium)
|
||||
}
|
||||
},
|
||||
actions = {
|
||||
IconButton(onClick = { searchActive = !searchActive; if (!searchActive) searchQuery = "" }) {
|
||||
Icon(if (searchActive) Icons.Default.Close else Icons.Default.Search, "Search")
|
||||
}
|
||||
},
|
||||
colors = TopAppBarDefaults.topAppBarColors(containerColor = MaterialTheme.colorScheme.surface),
|
||||
)
|
||||
|
||||
// ── Breadcrumbs ──────────────────────────────────────────────
|
||||
Surface(tonalElevation = 1.dp) {
|
||||
LazyRow(
|
||||
state = breadcrumbState,
|
||||
modifier = Modifier.fillMaxWidth().padding(horizontal = 8.dp, vertical = 6.dp),
|
||||
verticalAlignment = Alignment.CenterVertically,
|
||||
horizontalArrangement = Arrangement.spacedBy(2.dp),
|
||||
) {
|
||||
item {
|
||||
BreadcrumbChip(label = "📱 Storage", isLast = relParts.isEmpty(),
|
||||
onClick = { navigateToBreadcrumb(STORAGE_ROOT) })
|
||||
}
|
||||
itemsIndexed(relParts) { idx, part ->
|
||||
Icon(Icons.Default.ChevronRight, null, Modifier.size(14.dp), tint = MaterialTheme.colorScheme.onSurfaceVariant)
|
||||
val partPath = STORAGE_ROOT.absolutePath + "/" + relParts.take(idx + 1).joinToString("/")
|
||||
BreadcrumbChip(label = part, isLast = idx == relParts.lastIndex,
|
||||
onClick = { navigateToBreadcrumb(File(partPath)) })
|
||||
}
|
||||
}
|
||||
}
|
||||
HorizontalDivider()
|
||||
|
||||
// ── Content ──────────────────────────────────────────────────
|
||||
Box(modifier = Modifier.weight(1f)) {
|
||||
when {
|
||||
isLoading -> Box(Modifier.fillMaxSize(), contentAlignment = Alignment.Center) {
|
||||
CircularProgressIndicator()
|
||||
}
|
||||
else -> LazyColumn(modifier = Modifier.fillMaxSize()) {
|
||||
if (currentPath.absolutePath == STORAGE_ROOT.absolutePath && searchQuery.isBlank()) {
|
||||
item {
|
||||
Text("Quick access", style = MaterialTheme.typography.labelSmall,
|
||||
color = MaterialTheme.colorScheme.onSurfaceVariant,
|
||||
modifier = Modifier.padding(start = 20.dp, top = 14.dp, bottom = 6.dp))
|
||||
LazyRow(contentPadding = PaddingValues(horizontal = 16.dp),
|
||||
horizontalArrangement = Arrangement.spacedBy(10.dp),
|
||||
modifier = Modifier.padding(bottom = 8.dp)) {
|
||||
items(SHORTCUTS.filter { File(it.path).isDirectory }) { sc ->
|
||||
ShortcutChip(sc, onClick = { navigateTo(File(sc.path)) })
|
||||
}
|
||||
}
|
||||
HorizontalDivider(modifier = Modifier.padding(vertical = 6.dp))
|
||||
Text("All folders", style = MaterialTheme.typography.labelSmall,
|
||||
color = MaterialTheme.colorScheme.onSurfaceVariant,
|
||||
modifier = Modifier.padding(start = 20.dp, top = 4.dp, bottom = 4.dp))
|
||||
}
|
||||
}
|
||||
if (filtered.isEmpty()) {
|
||||
item {
|
||||
Box(Modifier.fillParentMaxSize(), contentAlignment = Alignment.Center) {
|
||||
Column(horizontalAlignment = Alignment.CenterHorizontally) {
|
||||
Icon(Icons.Default.FolderOpen, null, Modifier.size(56.dp),
|
||||
tint = MaterialTheme.colorScheme.onSurfaceVariant.copy(alpha = 0.4f))
|
||||
Spacer(Modifier.height(12.dp))
|
||||
Text(if (searchQuery.isBlank()) "No subfolders" else "No results for \"$searchQuery\"",
|
||||
style = MaterialTheme.typography.bodyLarge,
|
||||
color = MaterialTheme.colorScheme.onSurfaceVariant)
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
items(filtered, key = { it.file.absolutePath }) { entry ->
|
||||
LocalFolderItem(entry = entry, onClick = { navigateTo(entry.file) })
|
||||
}
|
||||
}
|
||||
item { Spacer(Modifier.height(8.dp)) }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// ── Select button ────────────────────────────────────────────
|
||||
Surface(tonalElevation = 4.dp, modifier = Modifier.fillMaxWidth()) {
|
||||
Column {
|
||||
Button(
|
||||
onClick = { onSelect(currentPath.absolutePath) },
|
||||
modifier = Modifier
|
||||
.fillMaxWidth()
|
||||
.padding(start = 16.dp, top = 12.dp, end = 16.dp, bottom = 12.dp)
|
||||
.height(52.dp),
|
||||
shape = RoundedCornerShape(14.dp),
|
||||
) {
|
||||
Icon(Icons.Default.CheckCircle, null, Modifier.size(20.dp))
|
||||
Spacer(Modifier.width(8.dp))
|
||||
Text("Select \"$currentFolderName\"",
|
||||
style = MaterialTheme.typography.titleSmall, fontWeight = FontWeight.SemiBold)
|
||||
}
|
||||
Spacer(Modifier.height(bottomInset))
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Composable
|
||||
private fun BreadcrumbChip(label: String, isLast: Boolean, onClick: () -> Unit) {
|
||||
if (isLast) {
|
||||
Surface(shape = RoundedCornerShape(8.dp), color = MaterialTheme.colorScheme.primaryContainer) {
|
||||
Text(label, modifier = Modifier.padding(horizontal = 10.dp, vertical = 4.dp),
|
||||
style = MaterialTheme.typography.labelMedium, fontWeight = FontWeight.SemiBold,
|
||||
color = MaterialTheme.colorScheme.onPrimaryContainer, maxLines = 1)
|
||||
}
|
||||
} else {
|
||||
TextButton(onClick = onClick, contentPadding = PaddingValues(horizontal = 8.dp, vertical = 2.dp)) {
|
||||
Text(label, style = MaterialTheme.typography.labelMedium, color = MaterialTheme.colorScheme.primary, maxLines = 1)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Composable
|
||||
private fun ShortcutChip(sc: Shortcut, onClick: () -> Unit) {
|
||||
Surface(
|
||||
onClick = onClick,
|
||||
shape = RoundedCornerShape(14.dp),
|
||||
color = MaterialTheme.colorScheme.secondaryContainer,
|
||||
modifier = Modifier.height(72.dp).width(80.dp),
|
||||
) {
|
||||
Column(
|
||||
modifier = Modifier.fillMaxSize().padding(8.dp),
|
||||
horizontalAlignment = Alignment.CenterHorizontally,
|
||||
verticalArrangement = Arrangement.Center,
|
||||
) {
|
||||
Icon(sc.icon, null, Modifier.size(24.dp), tint = MaterialTheme.colorScheme.onSecondaryContainer)
|
||||
Spacer(Modifier.height(4.dp))
|
||||
Text(sc.label, style = MaterialTheme.typography.labelSmall, color = MaterialTheme.colorScheme.onSecondaryContainer, maxLines = 1)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Composable
|
||||
private fun LocalFolderItem(entry: LocalEntry, onClick: () -> Unit) {
|
||||
Row(
|
||||
modifier = Modifier
|
||||
.fillMaxWidth()
|
||||
.clickable(onClick = onClick)
|
||||
.padding(horizontal = 16.dp, vertical = 10.dp),
|
||||
verticalAlignment = Alignment.CenterVertically,
|
||||
horizontalArrangement = Arrangement.spacedBy(14.dp),
|
||||
) {
|
||||
Box(
|
||||
modifier = Modifier
|
||||
.size(46.dp)
|
||||
.clip(RoundedCornerShape(12.dp))
|
||||
.background(Color(0xFF1B5E20).copy(alpha = 0.12f)),
|
||||
contentAlignment = Alignment.Center,
|
||||
) {
|
||||
Icon(Icons.Default.Folder, null, Modifier.size(26.dp), tint = Color(0xFF2E7D32))
|
||||
}
|
||||
Column(modifier = Modifier.weight(1f)) {
|
||||
Text(entry.file.name, style = MaterialTheme.typography.bodyLarge, maxLines = 1, overflow = TextOverflow.Ellipsis, fontWeight = FontWeight.Medium)
|
||||
if (entry.childCount > 0) {
|
||||
Text("${entry.childCount} subfolder${if (entry.childCount == 1) "" else "s"}", style = MaterialTheme.typography.bodySmall, color = MaterialTheme.colorScheme.onSurfaceVariant)
|
||||
}
|
||||
}
|
||||
Icon(Icons.Default.ChevronRight, null, Modifier.size(20.dp), tint = MaterialTheme.colorScheme.onSurfaceVariant.copy(alpha = 0.5f))
|
||||
}
|
||||
HorizontalDivider(modifier = Modifier.padding(start = 76.dp), thickness = 0.5.dp)
|
||||
}
|
||||
@@ -1,22 +1,40 @@
|
||||
package com.syncflow.ui.browser
|
||||
|
||||
import androidx.compose.foundation.background
|
||||
import androidx.compose.foundation.clickable
|
||||
import androidx.compose.foundation.layout.*
|
||||
import androidx.compose.foundation.lazy.LazyColumn
|
||||
import androidx.compose.foundation.lazy.LazyRow
|
||||
import androidx.compose.foundation.lazy.items
|
||||
import androidx.compose.foundation.lazy.itemsIndexed
|
||||
import androidx.compose.foundation.lazy.rememberLazyListState
|
||||
import androidx.compose.foundation.shape.RoundedCornerShape
|
||||
import androidx.compose.foundation.text.KeyboardActions
|
||||
import androidx.compose.foundation.text.KeyboardOptions
|
||||
import androidx.compose.material.icons.Icons
|
||||
import androidx.compose.material.icons.automirrored.filled.ArrowBack
|
||||
import androidx.compose.material.icons.filled.*
|
||||
import androidx.compose.material3.*
|
||||
import androidx.compose.runtime.*
|
||||
import androidx.compose.ui.Alignment
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.draw.clip
|
||||
import androidx.compose.ui.focus.FocusRequester
|
||||
import androidx.compose.ui.focus.focusRequester
|
||||
import androidx.compose.ui.graphics.Color
|
||||
import androidx.compose.ui.text.font.FontWeight
|
||||
import androidx.compose.ui.text.input.ImeAction
|
||||
import androidx.compose.ui.text.style.TextOverflow
|
||||
import androidx.compose.ui.platform.LocalDensity
|
||||
import androidx.compose.ui.platform.LocalView
|
||||
import androidx.compose.ui.unit.dp
|
||||
import androidx.compose.ui.window.Dialog
|
||||
import androidx.compose.ui.window.DialogProperties
|
||||
import androidx.core.view.ViewCompat
|
||||
import androidx.core.view.WindowInsetsCompat
|
||||
import androidx.hilt.navigation.compose.hiltViewModel
|
||||
import com.syncflow.domain.model.RemoteFile
|
||||
import kotlinx.coroutines.launch
|
||||
|
||||
@OptIn(ExperimentalMaterial3Api::class)
|
||||
@Composable
|
||||
@@ -30,79 +48,205 @@ fun RemoteBrowserDialog(
|
||||
LaunchedEffect(accountId, initialPath) { vm.init(accountId, initialPath) }
|
||||
|
||||
val state by vm.state.collectAsState()
|
||||
var searchQuery by remember { mutableStateOf("") }
|
||||
var searchActive by remember { mutableStateOf(false) }
|
||||
var showNewFolderDialog by remember { mutableStateOf(false) }
|
||||
val breadcrumbState = rememberLazyListState()
|
||||
val scope = rememberCoroutineScope()
|
||||
|
||||
// Auto-scroll breadcrumbs to end when path changes
|
||||
val segments = state.currentPath.trimEnd('/').split('/').filter { it.isNotEmpty() }
|
||||
LaunchedEffect(state.currentPath) {
|
||||
scope.launch { breadcrumbState.animateScrollToItem(maxOf(0, segments.size)) }
|
||||
searchQuery = ""
|
||||
searchActive = false
|
||||
}
|
||||
|
||||
val filtered = if (searchQuery.isBlank()) state.entries
|
||||
else state.entries.filter { it.name.contains(searchQuery, ignoreCase = true) }
|
||||
|
||||
val currentFolderName = state.currentPath.trimEnd('/').substringAfterLast('/').ifBlank { "Root" }
|
||||
|
||||
if (showNewFolderDialog) {
|
||||
NewFolderDialog(
|
||||
onConfirm = { name ->
|
||||
vm.createFolder(name)
|
||||
showNewFolderDialog = false
|
||||
},
|
||||
onDismiss = { showNewFolderDialog = false },
|
||||
)
|
||||
}
|
||||
|
||||
Dialog(
|
||||
onDismissRequest = onDismiss,
|
||||
properties = DialogProperties(usePlatformDefaultWidth = false),
|
||||
properties = DialogProperties(usePlatformDefaultWidth = false, decorFitsSystemWindows = false),
|
||||
) {
|
||||
Surface(
|
||||
modifier = Modifier
|
||||
.fillMaxWidth(0.95f)
|
||||
.fillMaxHeight(0.85f),
|
||||
shape = MaterialTheme.shapes.extraLarge,
|
||||
tonalElevation = 6.dp,
|
||||
) {
|
||||
Column {
|
||||
// Title bar
|
||||
val view = LocalView.current
|
||||
val density = LocalDensity.current
|
||||
var topInset by remember { mutableStateOf(0.dp) }
|
||||
var bottomInset by remember { mutableStateOf(56.dp) }
|
||||
DisposableEffect(view) {
|
||||
ViewCompat.setOnApplyWindowInsetsListener(view) { _, insets ->
|
||||
val bars = insets.getInsets(WindowInsetsCompat.Type.systemBars())
|
||||
with(density) {
|
||||
topInset = bars.top.toDp()
|
||||
bottomInset = maxOf(bars.bottom.toDp(), 56.dp)
|
||||
}
|
||||
insets
|
||||
}
|
||||
ViewCompat.requestApplyInsets(view)
|
||||
onDispose { ViewCompat.setOnApplyWindowInsetsListener(view, null) }
|
||||
}
|
||||
|
||||
Surface(modifier = Modifier.fillMaxSize(), color = MaterialTheme.colorScheme.surface) {
|
||||
Column(modifier = Modifier.fillMaxSize().padding(top = topInset)) {
|
||||
|
||||
// ── Top bar ──────────────────────────────────────────────────
|
||||
TopAppBar(
|
||||
title = {
|
||||
Column {
|
||||
Text("Choose remote folder", style = MaterialTheme.typography.titleMedium)
|
||||
Text(
|
||||
state.currentPath,
|
||||
style = MaterialTheme.typography.labelSmall,
|
||||
color = MaterialTheme.colorScheme.onSurfaceVariant,
|
||||
maxLines = 1,
|
||||
overflow = TextOverflow.Ellipsis,
|
||||
)
|
||||
}
|
||||
},
|
||||
navigationIcon = {
|
||||
IconButton(onClick = { if (!vm.navigateUp()) onDismiss() }) {
|
||||
Icon(Icons.Default.ArrowBack, null)
|
||||
Icon(Icons.AutoMirrored.Filled.ArrowBack, null)
|
||||
}
|
||||
},
|
||||
title = {
|
||||
if (searchActive) {
|
||||
val focusRequester = remember { FocusRequester() }
|
||||
LaunchedEffect(Unit) { focusRequester.requestFocus() }
|
||||
OutlinedTextField(
|
||||
value = searchQuery,
|
||||
onValueChange = { searchQuery = it },
|
||||
modifier = Modifier.fillMaxWidth().focusRequester(focusRequester),
|
||||
placeholder = { Text("Search in folder…") },
|
||||
singleLine = true,
|
||||
keyboardOptions = KeyboardOptions(imeAction = ImeAction.Search),
|
||||
keyboardActions = KeyboardActions(onSearch = {}),
|
||||
colors = OutlinedTextFieldDefaults.colors(
|
||||
focusedBorderColor = Color.Transparent,
|
||||
unfocusedBorderColor = Color.Transparent,
|
||||
),
|
||||
)
|
||||
} else {
|
||||
Text("Choose Folder", style = MaterialTheme.typography.titleMedium)
|
||||
}
|
||||
},
|
||||
actions = {
|
||||
// Select current folder
|
||||
TextButton(onClick = { onSelect(state.currentPath) }) {
|
||||
Text("Select here")
|
||||
IconButton(onClick = { searchActive = !searchActive; if (!searchActive) searchQuery = "" }) {
|
||||
Icon(if (searchActive) Icons.Default.Close else Icons.Default.Search, "Search")
|
||||
}
|
||||
IconButton(onClick = { showNewFolderDialog = true }) {
|
||||
Icon(Icons.Default.CreateNewFolder, "New Folder")
|
||||
}
|
||||
},
|
||||
colors = TopAppBarDefaults.topAppBarColors(containerColor = MaterialTheme.colorScheme.surfaceContainerHigh),
|
||||
colors = TopAppBarDefaults.topAppBarColors(containerColor = MaterialTheme.colorScheme.surface),
|
||||
)
|
||||
|
||||
// ── Breadcrumbs ──────────────────────────────────────────────
|
||||
Surface(tonalElevation = 1.dp) {
|
||||
LazyRow(
|
||||
state = breadcrumbState,
|
||||
modifier = Modifier.fillMaxWidth().padding(horizontal = 8.dp, vertical = 6.dp),
|
||||
verticalAlignment = Alignment.CenterVertically,
|
||||
horizontalArrangement = Arrangement.spacedBy(2.dp),
|
||||
) {
|
||||
item {
|
||||
BreadcrumbChip(
|
||||
label = "⌂",
|
||||
isLast = segments.isEmpty(),
|
||||
onClick = { vm.navigateToBreadcrumb("/") },
|
||||
)
|
||||
}
|
||||
itemsIndexed(segments) { idx, seg ->
|
||||
Icon(Icons.Default.ChevronRight, null, Modifier.size(14.dp), tint = MaterialTheme.colorScheme.onSurfaceVariant)
|
||||
val segPath = "/" + segments.take(idx + 1).joinToString("/")
|
||||
BreadcrumbChip(
|
||||
label = seg,
|
||||
isLast = idx == segments.lastIndex,
|
||||
onClick = { vm.navigateToBreadcrumb(segPath) },
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
HorizontalDivider()
|
||||
|
||||
when {
|
||||
state.isLoading -> Box(Modifier.fillMaxSize(), contentAlignment = Alignment.Center) {
|
||||
CircularProgressIndicator()
|
||||
}
|
||||
state.error != null -> Box(Modifier.fillMaxSize().padding(24.dp), contentAlignment = Alignment.Center) {
|
||||
Column(horizontalAlignment = Alignment.CenterHorizontally, verticalArrangement = Arrangement.spacedBy(8.dp)) {
|
||||
Icon(Icons.Default.ErrorOutline, null, Modifier.size(48.dp), tint = MaterialTheme.colorScheme.error)
|
||||
Text(state.error!!, color = MaterialTheme.colorScheme.error)
|
||||
FilledTonalButton(onClick = { vm.retry() }) { Text("Retry") }
|
||||
// ── Content ──────────────────────────────────────────────────
|
||||
Box(modifier = Modifier.weight(1f)) {
|
||||
when {
|
||||
state.isLoading -> Box(Modifier.fillMaxSize(), contentAlignment = Alignment.Center) {
|
||||
CircularProgressIndicator()
|
||||
}
|
||||
|
||||
state.error != null -> Column(
|
||||
modifier = Modifier.fillMaxSize().padding(32.dp),
|
||||
horizontalAlignment = Alignment.CenterHorizontally,
|
||||
verticalArrangement = Arrangement.Center,
|
||||
) {
|
||||
Icon(Icons.Default.CloudOff, null, Modifier.size(56.dp), tint = MaterialTheme.colorScheme.error)
|
||||
Spacer(Modifier.height(12.dp))
|
||||
Text(state.error!!, color = MaterialTheme.colorScheme.error, style = MaterialTheme.typography.bodyMedium)
|
||||
Spacer(Modifier.height(16.dp))
|
||||
FilledTonalButton(onClick = vm::retry) {
|
||||
Icon(Icons.Default.Refresh, null, Modifier.size(18.dp))
|
||||
Spacer(Modifier.width(6.dp))
|
||||
Text("Retry")
|
||||
}
|
||||
}
|
||||
|
||||
filtered.isEmpty() && searchQuery.isBlank() -> Column(
|
||||
modifier = Modifier.fillMaxSize().padding(32.dp),
|
||||
horizontalAlignment = Alignment.CenterHorizontally,
|
||||
verticalArrangement = Arrangement.Center,
|
||||
) {
|
||||
Icon(Icons.Default.FolderOpen, null, Modifier.size(56.dp), tint = MaterialTheme.colorScheme.onSurfaceVariant.copy(alpha = 0.4f))
|
||||
Spacer(Modifier.height(12.dp))
|
||||
Text("This folder is empty", style = MaterialTheme.typography.bodyLarge, color = MaterialTheme.colorScheme.onSurfaceVariant)
|
||||
Text("You can still select it", style = MaterialTheme.typography.bodySmall, color = MaterialTheme.colorScheme.onSurfaceVariant.copy(alpha = 0.6f))
|
||||
}
|
||||
|
||||
filtered.isEmpty() -> Column(
|
||||
modifier = Modifier.fillMaxSize().padding(32.dp),
|
||||
horizontalAlignment = Alignment.CenterHorizontally,
|
||||
verticalArrangement = Arrangement.Center,
|
||||
) {
|
||||
Icon(Icons.Default.SearchOff, null, Modifier.size(56.dp), tint = MaterialTheme.colorScheme.onSurfaceVariant.copy(alpha = 0.4f))
|
||||
Spacer(Modifier.height(12.dp))
|
||||
Text("No results for \"$searchQuery\"", style = MaterialTheme.typography.bodyLarge, color = MaterialTheme.colorScheme.onSurfaceVariant)
|
||||
}
|
||||
|
||||
else -> LazyColumn(modifier = Modifier.fillMaxSize()) {
|
||||
items(filtered, key = { it.path }) { entry ->
|
||||
FolderItem(
|
||||
file = entry,
|
||||
onClick = {
|
||||
if (entry.isDirectory) vm.navigateTo(entry.path)
|
||||
else onSelect(entry.path.substringBeforeLast('/').ifBlank { "/" })
|
||||
},
|
||||
)
|
||||
}
|
||||
item { Spacer(Modifier.height(8.dp)) }
|
||||
}
|
||||
}
|
||||
state.entries.isEmpty() -> Box(Modifier.fillMaxSize(), contentAlignment = Alignment.Center) {
|
||||
Column(horizontalAlignment = Alignment.CenterHorizontally, verticalArrangement = Arrangement.spacedBy(8.dp)) {
|
||||
Icon(Icons.Default.FolderOff, null, Modifier.size(48.dp), tint = MaterialTheme.colorScheme.onSurfaceVariant)
|
||||
Text("Empty folder", color = MaterialTheme.colorScheme.onSurfaceVariant)
|
||||
TextButton(onClick = { onSelect(state.currentPath) }) { Text("Select this folder anyway") }
|
||||
}
|
||||
}
|
||||
else -> LazyColumn(modifier = Modifier.fillMaxSize()) {
|
||||
items(state.entries, key = { it.path }) { entry ->
|
||||
BrowserEntry(
|
||||
file = entry,
|
||||
onClick = {
|
||||
if (entry.isDirectory) vm.navigateTo(entry.path)
|
||||
else onSelect(entry.path.substringBeforeLast('/').ifBlank { "/" })
|
||||
},
|
||||
onSelectFolder = if (entry.isDirectory) ({ onSelect(entry.path) }) else null,
|
||||
}
|
||||
|
||||
// ── Select button ────────────────────────────────────────────
|
||||
Surface(tonalElevation = 4.dp, modifier = Modifier.fillMaxWidth()) {
|
||||
Column {
|
||||
Button(
|
||||
onClick = { onSelect(state.currentPath) },
|
||||
modifier = Modifier
|
||||
.fillMaxWidth()
|
||||
.padding(start = 16.dp, top = 12.dp, end = 16.dp, bottom = 12.dp)
|
||||
.height(52.dp),
|
||||
shape = RoundedCornerShape(14.dp),
|
||||
) {
|
||||
Icon(Icons.Default.CheckCircle, null, Modifier.size(20.dp))
|
||||
Spacer(Modifier.width(8.dp))
|
||||
Text(
|
||||
"Select \"$currentFolderName\"",
|
||||
style = MaterialTheme.typography.titleSmall,
|
||||
fontWeight = FontWeight.SemiBold,
|
||||
)
|
||||
HorizontalDivider(modifier = Modifier.padding(start = 56.dp))
|
||||
}
|
||||
Spacer(Modifier.height(bottomInset))
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -111,44 +255,119 @@ fun RemoteBrowserDialog(
|
||||
}
|
||||
|
||||
@Composable
|
||||
private fun BrowserEntry(
|
||||
file: RemoteFile,
|
||||
onClick: () -> Unit,
|
||||
onSelectFolder: (() -> Unit)?,
|
||||
) {
|
||||
private fun BreadcrumbChip(label: String, isLast: Boolean, onClick: () -> Unit) {
|
||||
if (isLast) {
|
||||
Surface(
|
||||
shape = RoundedCornerShape(8.dp),
|
||||
color = MaterialTheme.colorScheme.primaryContainer,
|
||||
) {
|
||||
Text(
|
||||
label,
|
||||
modifier = Modifier.padding(horizontal = 10.dp, vertical = 4.dp),
|
||||
style = MaterialTheme.typography.labelMedium,
|
||||
fontWeight = FontWeight.SemiBold,
|
||||
color = MaterialTheme.colorScheme.onPrimaryContainer,
|
||||
maxLines = 1,
|
||||
)
|
||||
}
|
||||
} else {
|
||||
TextButton(
|
||||
onClick = onClick,
|
||||
contentPadding = PaddingValues(horizontal = 8.dp, vertical = 2.dp),
|
||||
) {
|
||||
Text(
|
||||
label,
|
||||
style = MaterialTheme.typography.labelMedium,
|
||||
color = MaterialTheme.colorScheme.primary,
|
||||
maxLines = 1,
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Composable
|
||||
private fun FolderItem(file: RemoteFile, onClick: () -> Unit) {
|
||||
Row(
|
||||
modifier = Modifier
|
||||
.fillMaxWidth()
|
||||
.clickable(onClick = onClick)
|
||||
.padding(horizontal = 16.dp, vertical = 10.dp),
|
||||
verticalAlignment = Alignment.CenterVertically,
|
||||
horizontalArrangement = Arrangement.spacedBy(14.dp),
|
||||
) {
|
||||
Icon(
|
||||
imageVector = if (file.isDirectory) Icons.Default.Folder else Icons.Default.InsertDriveFile,
|
||||
contentDescription = null,
|
||||
modifier = Modifier.size(24.dp),
|
||||
tint = if (file.isDirectory) MaterialTheme.colorScheme.primary else MaterialTheme.colorScheme.onSurfaceVariant,
|
||||
)
|
||||
Spacer(Modifier.width(14.dp))
|
||||
// Colored icon badge
|
||||
Box(
|
||||
modifier = Modifier
|
||||
.size(46.dp)
|
||||
.clip(RoundedCornerShape(12.dp))
|
||||
.background(
|
||||
if (file.isDirectory) Color(0xFF1B5E20).copy(alpha = 0.12f)
|
||||
else Color(0xFF0D47A1).copy(alpha = 0.10f)
|
||||
),
|
||||
contentAlignment = Alignment.Center,
|
||||
) {
|
||||
Icon(
|
||||
imageVector = if (file.isDirectory) Icons.Default.Folder else Icons.Default.InsertDriveFile,
|
||||
contentDescription = null,
|
||||
modifier = Modifier.size(26.dp),
|
||||
tint = if (file.isDirectory) Color(0xFF2E7D32) else Color(0xFF1565C0),
|
||||
)
|
||||
}
|
||||
|
||||
Column(modifier = Modifier.weight(1f)) {
|
||||
Text(file.name, style = MaterialTheme.typography.bodyMedium, maxLines = 1, overflow = TextOverflow.Ellipsis)
|
||||
Text(
|
||||
file.name,
|
||||
style = MaterialTheme.typography.bodyLarge,
|
||||
maxLines = 1,
|
||||
overflow = TextOverflow.Ellipsis,
|
||||
fontWeight = if (file.isDirectory) FontWeight.Medium else FontWeight.Normal,
|
||||
)
|
||||
if (!file.isDirectory) {
|
||||
Text(file.sizeBytes.formatBytes(), style = MaterialTheme.typography.labelSmall, color = MaterialTheme.colorScheme.onSurfaceVariant)
|
||||
Text(
|
||||
file.sizeBytes.formatBytes(),
|
||||
style = MaterialTheme.typography.bodySmall,
|
||||
color = MaterialTheme.colorScheme.onSurfaceVariant,
|
||||
)
|
||||
}
|
||||
}
|
||||
if (onSelectFolder != null) {
|
||||
IconButton(onClick = onSelectFolder, modifier = Modifier.size(36.dp)) {
|
||||
Icon(Icons.Default.CheckCircleOutline, "Select this folder", Modifier.size(20.dp), tint = MaterialTheme.colorScheme.primary)
|
||||
}
|
||||
} else {
|
||||
Icon(Icons.Default.ChevronRight, null, Modifier.size(20.dp), tint = MaterialTheme.colorScheme.onSurfaceVariant)
|
||||
|
||||
if (file.isDirectory) {
|
||||
Icon(Icons.Default.ChevronRight, null, Modifier.size(20.dp), tint = MaterialTheme.colorScheme.onSurfaceVariant.copy(alpha = 0.5f))
|
||||
}
|
||||
}
|
||||
HorizontalDivider(modifier = Modifier.padding(start = 76.dp), thickness = 0.5.dp)
|
||||
}
|
||||
|
||||
@Composable
|
||||
private fun NewFolderDialog(onConfirm: (String) -> Unit, onDismiss: () -> Unit) {
|
||||
var name by remember { mutableStateOf("") }
|
||||
AlertDialog(
|
||||
onDismissRequest = onDismiss,
|
||||
icon = { Icon(Icons.Default.CreateNewFolder, null) },
|
||||
title = { Text("New Folder") },
|
||||
text = {
|
||||
OutlinedTextField(
|
||||
value = name,
|
||||
onValueChange = { name = it },
|
||||
label = { Text("Folder name") },
|
||||
singleLine = true,
|
||||
modifier = Modifier.fillMaxWidth(),
|
||||
keyboardOptions = KeyboardOptions(imeAction = ImeAction.Done),
|
||||
keyboardActions = KeyboardActions(onDone = { if (name.isNotBlank()) onConfirm(name.trim()) }),
|
||||
)
|
||||
},
|
||||
confirmButton = {
|
||||
TextButton(onClick = { if (name.isNotBlank()) onConfirm(name.trim()) }, enabled = name.isNotBlank()) {
|
||||
Text("Create")
|
||||
}
|
||||
},
|
||||
dismissButton = { TextButton(onClick = onDismiss) { Text("Cancel") } },
|
||||
)
|
||||
}
|
||||
|
||||
private fun Long.formatBytes(): String = when {
|
||||
this < 1024 -> "${this}B"
|
||||
this < 1_048_576 -> "${"%.1f".format(this / 1024.0)}KB"
|
||||
this < 1_073_741_824 -> "${"%.1f".format(this / 1_048_576.0)}MB"
|
||||
else -> "${"%.1f".format(this / 1_073_741_824.0)}GB"
|
||||
this < 1024 -> "${this} B"
|
||||
this < 1_048_576 -> "${"%.1f".format(this / 1024.0)} KB"
|
||||
this < 1_073_741_824 -> "${"%.1f".format(this / 1_048_576.0)} MB"
|
||||
else -> "${"%.1f".format(this / 1_073_741_824.0)} GB"
|
||||
}
|
||||
|
||||
@@ -57,6 +57,27 @@ class RemoteBrowserViewModel @Inject constructor(
|
||||
return true
|
||||
}
|
||||
|
||||
fun navigateToBreadcrumb(path: String) {
|
||||
val stack = _state.value.pathStack
|
||||
val idx = stack.lastIndexOf(path)
|
||||
val newStack = if (idx >= 0) stack.take(idx + 1) else listOf(path)
|
||||
loadJob?.cancel()
|
||||
_state.update { it.copy(currentPath = path, pathStack = newStack, isLoading = true, entries = emptyList(), error = null) }
|
||||
loadJob = loadPath(_state.value.accountId, path)
|
||||
}
|
||||
|
||||
fun createFolder(name: String) {
|
||||
val s = _state.value
|
||||
val newPath = if (s.currentPath.trimEnd('/') == "") "/$name" else "${s.currentPath.trimEnd('/')}/$name"
|
||||
viewModelScope.launch {
|
||||
val account = accountRepository.getAccount(s.accountId) ?: return@launch
|
||||
val provider = runCatching { providerFactory.create(account) }.getOrElse { return@launch }
|
||||
provider.createDirectory(newPath)
|
||||
.onSuccess { retry() }
|
||||
.onFailure { e -> _state.update { it.copy(error = "Could not create folder: ${e.message}") } }
|
||||
}
|
||||
}
|
||||
|
||||
fun retry() {
|
||||
val s = _state.value
|
||||
if (s.accountId == -1L) return
|
||||
|
||||
@@ -247,12 +247,12 @@ private fun EmptyState(modifier: Modifier = Modifier, onAdd: () -> Unit) {
|
||||
|
||||
private val SyncStatus.accentColor: Color
|
||||
@Composable get() = when (this) {
|
||||
SyncStatus.SUCCESS -> MaterialTheme.colorScheme.primary
|
||||
SyncStatus.SYNCING -> MaterialTheme.colorScheme.secondary
|
||||
SyncStatus.FAILED -> MaterialTheme.colorScheme.error
|
||||
SyncStatus.CONFLICT,
|
||||
SyncStatus.PARTIAL -> MaterialTheme.colorScheme.tertiary
|
||||
SyncStatus.IDLE -> MaterialTheme.colorScheme.outline
|
||||
SyncStatus.SUCCESS -> Color(0xFF2E7D32) // green — done, healthy
|
||||
SyncStatus.SYNCING -> Color(0xFF1565C0) // blue — in progress
|
||||
SyncStatus.FAILED -> Color(0xFFC62828) // red — error
|
||||
SyncStatus.PARTIAL -> Color(0xFFE65100) // orange — some files failed
|
||||
SyncStatus.CONFLICT -> Color(0xFFF9A825) // amber — needs resolution
|
||||
SyncStatus.IDLE -> MaterialTheme.colorScheme.outline
|
||||
}
|
||||
|
||||
private fun String.toDisplayPath(): String {
|
||||
|
||||
@@ -20,9 +20,13 @@ import com.syncflow.MainActivity
|
||||
import com.syncflow.R
|
||||
import com.syncflow.data.db.SyncFileStateDao
|
||||
import com.syncflow.data.db.SyncPairDao
|
||||
import com.syncflow.data.db.entities.toDomain
|
||||
import com.syncflow.domain.model.ScheduleType
|
||||
import com.syncflow.domain.sync.LocalAccessor
|
||||
import dagger.hilt.android.AndroidEntryPoint
|
||||
import kotlinx.coroutines.*
|
||||
import kotlinx.coroutines.sync.Mutex
|
||||
import kotlinx.coroutines.sync.withLock
|
||||
import timber.log.Timber
|
||||
import java.io.File
|
||||
import javax.inject.Inject
|
||||
@@ -35,11 +39,18 @@ class FileWatchService : Service() {
|
||||
|
||||
private val scope = CoroutineScope(Dispatchers.IO + SupervisorJob())
|
||||
private val mainHandler = Handler(Looper.getMainLooper())
|
||||
// Prevents concurrent refresh() calls from doubling watchers + catchup scans
|
||||
private val refreshMutex = Mutex()
|
||||
|
||||
// Multiple FileObserver instances per pair: one per directory (recursive)
|
||||
private val fileObservers = mutableMapOf<Long, MutableList<FileObserver>>()
|
||||
private val contentObservers = mutableMapOf<Long, ContentObserver>()
|
||||
private val debounceJobs = mutableMapOf<Long, Job>()
|
||||
// Persistent monitors that watch WorkManager for ANY sync (manual, catchup, onchange)
|
||||
// so the cooldown is set regardless of who triggered the sync.
|
||||
private val syncMonitorJobs = mutableMapOf<Long, Job>()
|
||||
// After a sync completes, suppress FileObserver events for this long.
|
||||
private val syncCooldownUntil = mutableMapOf<Long, Long>()
|
||||
|
||||
companion object {
|
||||
const val CHANNEL_WATCH = "sync_watching"
|
||||
@@ -78,7 +89,7 @@ class FileWatchService : Service() {
|
||||
|
||||
override fun onBind(intent: Intent?): IBinder? = null
|
||||
|
||||
private suspend fun refresh() {
|
||||
private suspend fun refresh() = refreshMutex.withLock {
|
||||
clearWatchers()
|
||||
val pairs = syncPairDao.getEnabled().filter { it.scheduleType == ScheduleType.ON_CHANGE }
|
||||
|
||||
@@ -142,11 +153,41 @@ class FileWatchService : Service() {
|
||||
return
|
||||
}
|
||||
fileObservers[pairId] = mutableListOf()
|
||||
// Set startup cooldown BEFORE registering watchers so inotify events that fire
|
||||
// immediately on registration don't trigger the debounce before catchupScan runs.
|
||||
syncCooldownUntil[pairId] = System.currentTimeMillis() + 15_000
|
||||
watchDirRecursive(dir, pairId, wifiOnly, chargingOnly)
|
||||
Timber.d("FileWatchService: watching pair $pairId at $path (${fileObservers[pairId]?.size} dirs)")
|
||||
startSyncMonitor(pairId)
|
||||
scope.launch { catchupScan(pairId, dir, wifiOnly, chargingOnly) }
|
||||
}
|
||||
|
||||
// Watches WorkManager for ANY sync tagged sync_$pairId (manual, catchup, onchange).
|
||||
// Sets cooldown while running and for 60s after, so FileObserver events from our
|
||||
// own file writes never trigger a re-sync regardless of what started the sync.
|
||||
private fun startSyncMonitor(pairId: Long) {
|
||||
syncMonitorJobs[pairId]?.cancel()
|
||||
syncMonitorJobs[pairId] = scope.launch {
|
||||
var wasSyncing = false
|
||||
WorkManager.getInstance(applicationContext)
|
||||
.getWorkInfosByTagFlow("sync_$pairId")
|
||||
.collect { infos ->
|
||||
val isSyncing = infos.any {
|
||||
it.state == WorkInfo.State.RUNNING || it.state == WorkInfo.State.ENQUEUED
|
||||
}
|
||||
if (isSyncing) {
|
||||
Timber.d("FileWatchService: sync active for pair $pairId — cooldown extended")
|
||||
syncCooldownUntil[pairId] = System.currentTimeMillis() + 120_000
|
||||
wasSyncing = true
|
||||
} else if (wasSyncing) {
|
||||
Timber.d("FileWatchService: sync finished for pair $pairId — 60s settle cooldown")
|
||||
syncCooldownUntil[pairId] = System.currentTimeMillis() + 60_000
|
||||
wasSyncing = false
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun watchDirRecursive(dir: File, pairId: Long, wifiOnly: Boolean, chargingOnly: Boolean) {
|
||||
if (!dir.isDirectory) return
|
||||
val mask = FileObserver.CREATE or FileObserver.DELETE or FileObserver.MODIFY or
|
||||
@@ -185,51 +226,85 @@ class FileWatchService : Service() {
|
||||
val known = fileStateDao.getForPair(pairId).associateBy { it.relativePath }
|
||||
if (known.isEmpty()) return // Never synced — first sync will be triggered manually
|
||||
|
||||
val current = mutableMapOf<String, Long>()
|
||||
dir.walk().filter { it.isFile }.forEach { f ->
|
||||
current[f.relativeTo(dir).path.replace('\\', '/')] = f.lastModified()
|
||||
}
|
||||
val pairEntity = syncPairDao.getById(pairId) ?: return
|
||||
val pair = pairEntity.toDomain()
|
||||
// Use the same accessor + filters as SyncEngine so hidden/excluded/size-filtered files
|
||||
// don't appear as "new" in the catchup scan and trigger a perpetual sync loop.
|
||||
val accessor = if (pair.localPath.startsWith("content://"))
|
||||
LocalAccessor.Saf(Uri.parse(pair.localPath), contentResolver)
|
||||
else
|
||||
LocalAccessor.JavaFile(dir)
|
||||
val current = accessor.walkFiles(pair)
|
||||
|
||||
val hasNew = current.any { (rel, _) -> rel !in known }
|
||||
val hasModified = current.any { (rel, mtime) ->
|
||||
val hasModified = current.any { (rel, info) ->
|
||||
val s = known[rel]; s != null && s.localModifiedAt != null &&
|
||||
s.localModifiedAt.toEpochMilli() != mtime
|
||||
s.localModifiedAt.epochSecond != info.lastModifiedMs / 1000
|
||||
}
|
||||
val hasDeleted = known.keys.any { rel -> rel !in current }
|
||||
|
||||
if (hasNew || hasModified || hasDeleted) {
|
||||
Timber.d("FileWatchService: catchup detected changes for pair $pairId, scheduling sync")
|
||||
val pair = syncPairDao.getById(pairId) ?: return
|
||||
// Cancel any debounce that started before our startup cooldown was set
|
||||
debounceJobs[pairId]?.cancel()
|
||||
debounceJobs.remove(pairId)
|
||||
// Hold cooldown for duration of sync + 60s settle
|
||||
syncCooldownUntil[pairId] = System.currentTimeMillis() + 120_000
|
||||
val req = SyncWorker.buildOneTimeRequest(pairId, wifiOnly, chargingOnly)
|
||||
WorkManager.getInstance(applicationContext)
|
||||
.enqueueUniqueWork(
|
||||
"catchup_$pairId",
|
||||
ExistingWorkPolicy.KEEP,
|
||||
SyncWorker.buildOneTimeRequest(pairId, wifiOnly, chargingOnly),
|
||||
)
|
||||
.enqueueUniqueWork("catchup_$pairId", ExistingWorkPolicy.KEEP, req)
|
||||
scope.launch {
|
||||
try {
|
||||
WorkManager.getInstance(applicationContext)
|
||||
.getWorkInfoByIdFlow(req.id)
|
||||
.first { it?.state?.isFinished == true }
|
||||
syncCooldownUntil[pairId] = System.currentTimeMillis() + 60_000
|
||||
} catch (e: CancellationException) {
|
||||
throw e
|
||||
} catch (_: Exception) {
|
||||
syncCooldownUntil[pairId] = System.currentTimeMillis() + 60_000
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun onChangeDetected(pairId: Long, wifiOnly: Boolean, chargingOnly: Boolean) {
|
||||
// Ignore events fired by our own sync writing files — prevents the feedback loop
|
||||
// where downloaded/uploaded files trigger another sync indefinitely.
|
||||
if (System.currentTimeMillis() < (syncCooldownUntil[pairId] ?: 0L)) {
|
||||
Timber.d("FileWatchService: suppressing change event for pair $pairId (sync cooldown)")
|
||||
return
|
||||
}
|
||||
|
||||
debounceJobs[pairId]?.cancel()
|
||||
debounceJobs[pairId] = scope.launch {
|
||||
delay(5_000)
|
||||
// Re-check: catchupScan or another path may have already set a cooldown
|
||||
// and handled this sync while we were waiting.
|
||||
if (System.currentTimeMillis() < (syncCooldownUntil[pairId] ?: 0L)) {
|
||||
Timber.d("FileWatchService: debounce fired but cooldown active for pair $pairId, skipping")
|
||||
return@launch
|
||||
}
|
||||
val pair = syncPairDao.getById(pairId)
|
||||
if (pair == null || !pair.isEnabled) return@launch
|
||||
Timber.d("FileWatchService: triggering sync for pair $pairId after debounce")
|
||||
|
||||
// Block new triggers from this point until 60s after sync completes
|
||||
syncCooldownUntil[pairId] = System.currentTimeMillis() + 120_000
|
||||
|
||||
val req = SyncWorker.buildOneTimeRequest(pairId, wifiOnly, chargingOnly, silent = true)
|
||||
WorkManager.getInstance(applicationContext)
|
||||
.enqueueUniqueWork("onchange_$pairId", ExistingWorkPolicy.KEEP, req)
|
||||
|
||||
// Update notification while sync is in progress
|
||||
updateNotificationDynamic("Syncing: ${pair.name}…")
|
||||
|
||||
// Wait for completion and show result in the persistent notification
|
||||
scope.launch {
|
||||
try {
|
||||
val info = WorkManager.getInstance(applicationContext)
|
||||
.getWorkInfoByIdFlow(req.id)
|
||||
.first { it?.state?.isFinished == true }
|
||||
// Extend cooldown: 60s after sync finishes to let filesystem settle
|
||||
syncCooldownUntil[pairId] = System.currentTimeMillis() + 60_000
|
||||
val summary = info?.outputData?.getString(SyncWorker.KEY_RESULT_SUMMARY)
|
||||
val watchCount = fileObservers.keys.size + contentObservers.size
|
||||
val watching = "Watching $watchCount folder${if (watchCount != 1) "s" else ""}"
|
||||
@@ -239,8 +314,11 @@ class FileWatchService : Service() {
|
||||
updateNotificationDynamic("$watching")
|
||||
}
|
||||
delay(12_000)
|
||||
updateNotificationDynamic(null) // revert to default watching text
|
||||
updateNotificationDynamic(null)
|
||||
} catch (e: CancellationException) {
|
||||
throw e
|
||||
} catch (_: Exception) {
|
||||
syncCooldownUntil[pairId] = System.currentTimeMillis() + 60_000
|
||||
updateNotificationDynamic(null)
|
||||
}
|
||||
}
|
||||
@@ -254,6 +332,9 @@ class FileWatchService : Service() {
|
||||
contentObservers.clear()
|
||||
debounceJobs.values.forEach { it.cancel() }
|
||||
debounceJobs.clear()
|
||||
syncMonitorJobs.values.forEach { it.cancel() }
|
||||
syncMonitorJobs.clear()
|
||||
syncCooldownUntil.clear()
|
||||
}
|
||||
|
||||
private fun ensureChannel() {
|
||||
|
||||
|
After Width: | Height: | Size: 30 KiB |
|
After Width: | Height: | Size: 14 KiB |
|
After Width: | Height: | Size: 52 KiB |
|
After Width: | Height: | Size: 110 KiB |
|
After Width: | Height: | Size: 188 KiB |
@@ -1,25 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:aapt="http://schemas.android.com/aapt"
|
||||
android:width="108dp"
|
||||
android:height="108dp"
|
||||
android:viewportWidth="108"
|
||||
android:viewportHeight="108">
|
||||
|
||||
<!-- Dark charcoal background, matching Avast-style dark icon bg -->
|
||||
<path android:pathData="M0,0 H108 V108 H0 Z"
|
||||
android:fillColor="#1F1F2E"/>
|
||||
|
||||
<!-- Very subtle inner glow -->
|
||||
<path android:pathData="M0,0 H108 V108 H0 Z"
|
||||
android:fillAlpha="0.25">
|
||||
<aapt:attr name="android:fillColor">
|
||||
<gradient android:type="radial"
|
||||
android:gradientRadius="60"
|
||||
android:centerX="54" android:centerY="50"
|
||||
android:startColor="#3D3A50"
|
||||
android:endColor="#00000000"/>
|
||||
</aapt:attr>
|
||||
</path>
|
||||
|
||||
</vector>
|
||||
@@ -1,102 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!--
|
||||
SyncFlow icon foreground.
|
||||
Design: three bold teardrop "speed streak" shapes in Avast color palette
|
||||
(teal, red, yellow) converging on a white cloud in the centre.
|
||||
Each teardrop has a pointed tail (far from cloud) and a wide rounded head
|
||||
(near the cloud), like motion streaks flying into the sync point.
|
||||
|
||||
Safe zone: 18-90dp band. Cloud centred at (54, 55).
|
||||
-->
|
||||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:aapt="http://schemas.android.com/aapt"
|
||||
android:width="108dp"
|
||||
android:height="108dp"
|
||||
android:viewportWidth="108"
|
||||
android:viewportHeight="108">
|
||||
|
||||
<!-- SHADOW layer under teardrops for depth -->
|
||||
<path
|
||||
android:pathData="M 54,28 C 42,28 30,36 32,50 C 22,55 22,70 34,72 L 74,72 C 84,72 88,62 82,55 C 86,43 76,33 66,35 C 62,30 58,28 54,28 Z"
|
||||
android:fillColor="#000000"
|
||||
android:fillAlpha="0.20"
|
||||
android:translateY="2.5"/>
|
||||
|
||||
<!-- TEAL teardrop: enters from upper-left, tail at (22,22), head near cloud top-left -->
|
||||
<!-- Teardrop shape: pointed at tail, fat elliptical head, rotated ~45 deg into centre -->
|
||||
<path
|
||||
android:pathData="M 35.5,26.5
|
||||
C 30,21 22,22 22,22
|
||||
C 22,22 27,30 32.5,35.5
|
||||
C 36,38 40,40 43,42
|
||||
C 40,39 36,32 35.5,26.5 Z">
|
||||
<aapt:attr name="android:fillColor">
|
||||
<gradient android:type="linear"
|
||||
android:startX="22" android:startY="22"
|
||||
android:endX="43" android:endY="42"
|
||||
android:startColor="#00BFA5"
|
||||
android:endColor="#26D6C0"/>
|
||||
</aapt:attr>
|
||||
</path>
|
||||
|
||||
<!-- RED teardrop: enters from upper-right, tail at (86,22), head near cloud top-right -->
|
||||
<path
|
||||
android:pathData="M 72.5,26.5
|
||||
C 78,21 86,22 86,22
|
||||
C 86,22 81,30 75.5,35.5
|
||||
C 72,38 68,40 65,42
|
||||
C 68,39 72,32 72.5,26.5 Z">
|
||||
<aapt:attr name="android:fillColor">
|
||||
<gradient android:type="linear"
|
||||
android:startX="86" android:startY="22"
|
||||
android:endX="65" android:endY="42"
|
||||
android:startColor="#E53935"
|
||||
android:endColor="#EF6558"/>
|
||||
</aapt:attr>
|
||||
</path>
|
||||
|
||||
<!-- YELLOW teardrop: enters from bottom-centre, tail at (54,88), head near cloud base -->
|
||||
<path
|
||||
android:pathData="M 48,75
|
||||
C 45,82 47,88 54,88
|
||||
C 61,88 63,82 60,75
|
||||
C 58,71 56,68 54,66
|
||||
C 52,68 50,71 48,75 Z">
|
||||
<aapt:attr name="android:fillColor">
|
||||
<gradient android:type="linear"
|
||||
android:startX="54" android:startY="88"
|
||||
android:endX="54" android:endY="66"
|
||||
android:startColor="#F9A825"
|
||||
android:endColor="#FFD740"/>
|
||||
</aapt:attr>
|
||||
</path>
|
||||
|
||||
<!-- CLOUD body (white, centred at 54,50) -->
|
||||
<path
|
||||
android:pathData="
|
||||
M 36,62
|
||||
A 9,9 0 0,1 36,44
|
||||
A 9,9 0 0,1 45,36
|
||||
A 12,12 0 0,1 66,37
|
||||
A 8,8 0 0,1 74,48
|
||||
A 8,8 0 0,1 68,62
|
||||
Z"
|
||||
android:fillColor="#FFFFFF"/>
|
||||
|
||||
<!-- Teal highlight on cloud top-left edge -->
|
||||
<path
|
||||
android:pathData="M 36,53 A 9,9 0 0,1 41,38"
|
||||
android:fillColor="#00000000"
|
||||
android:strokeWidth="2"
|
||||
android:strokeLineCap="round"
|
||||
android:strokeColor="#4000BFA5"/>
|
||||
|
||||
<!-- Red highlight on cloud top-right edge -->
|
||||
<path
|
||||
android:pathData="M 63,37 A 8,8 0 0,1 73,48"
|
||||
android:fillColor="#00000000"
|
||||
android:strokeWidth="2"
|
||||
android:strokeLineCap="round"
|
||||
android:strokeColor="#40E53935"/>
|
||||
|
||||
</vector>
|
||||
@@ -1,5 +1,5 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<background android:drawable="@drawable/ic_launcher_background"/>
|
||||
<background android:drawable="@color/ic_launcher_background"/>
|
||||
<foreground android:drawable="@drawable/ic_launcher_foreground"/>
|
||||
</adaptive-icon>
|
||||
@@ -1,5 +1,5 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<background android:drawable="@drawable/ic_launcher_background"/>
|
||||
<background android:drawable="@color/ic_launcher_background"/>
|
||||
<foreground android:drawable="@drawable/ic_launcher_foreground"/>
|
||||
</adaptive-icon>
|
||||
|
After Width: | Height: | Size: 14 KiB |
@@ -1,5 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<background android:drawable="@drawable/ic_launcher_background"/>
|
||||
<foreground android:drawable="@drawable/ic_launcher_foreground"/>
|
||||
</adaptive-icon>
|
||||
|
After Width: | Height: | Size: 12 KiB |
@@ -1,5 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<background android:drawable="@drawable/ic_launcher_background"/>
|
||||
<foreground android:drawable="@drawable/ic_launcher_foreground"/>
|
||||
</adaptive-icon>
|
||||
|
After Width: | Height: | Size: 6.5 KiB |
|
After Width: | Height: | Size: 5.5 KiB |
@@ -1,5 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<background android:drawable="@drawable/ic_launcher_background"/>
|
||||
<foreground android:drawable="@drawable/ic_launcher_foreground"/>
|
||||
</adaptive-icon>
|
||||
|
After Width: | Height: | Size: 24 KiB |
@@ -1,5 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<background android:drawable="@drawable/ic_launcher_background"/>
|
||||
<foreground android:drawable="@drawable/ic_launcher_foreground"/>
|
||||
</adaptive-icon>
|
||||
|
After Width: | Height: | Size: 20 KiB |
|
After Width: | Height: | Size: 52 KiB |
@@ -1,5 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<background android:drawable="@drawable/ic_launcher_background"/>
|
||||
<foreground android:drawable="@drawable/ic_launcher_foreground"/>
|
||||
</adaptive-icon>
|
||||
|
After Width: | Height: | Size: 44 KiB |
@@ -1,5 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<background android:drawable="@drawable/ic_launcher_background"/>
|
||||
<foreground android:drawable="@drawable/ic_launcher_foreground"/>
|
||||
</adaptive-icon>
|
||||
|
After Width: | Height: | Size: 88 KiB |
@@ -1,5 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<background android:drawable="@drawable/ic_launcher_background"/>
|
||||
<foreground android:drawable="@drawable/ic_launcher_foreground"/>
|
||||
</adaptive-icon>
|
||||
|
After Width: | Height: | Size: 75 KiB |
@@ -1,5 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<background android:drawable="@drawable/ic_launcher_background"/>
|
||||
<foreground android:drawable="@drawable/ic_launcher_foreground"/>
|
||||
</adaptive-icon>
|
||||
@@ -1,4 +1,4 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
<color name="ic_launcher_background">#2196F3</color>
|
||||
<color name="ic_launcher_background">#050E05</color>
|
||||
</resources>
|
||||
|
||||
@@ -1,2 +1,2 @@
|
||||
VERSION_NAME=1.0.28
|
||||
VERSION_CODE=29
|
||||
VERSION_NAME=1.0.52
|
||||
VERSION_CODE=53
|
||||
|
||||