Compare commits
7 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 897b685c70 | |||
| 4b20697bb1 | |||
| 66d28761a8 | |||
| ec478531da | |||
| 5ade80a334 | |||
| 34fb06a673 | |||
| dc2a0b2c68 |
@@ -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)
|
||||
@@ -126,16 +141,20 @@ class SyncEngine @Inject constructor(
|
||||
logEvent(pair.id, SyncEventType.FILE_DOWNLOADED, rel, null, bytes)
|
||||
FileOutcome(downloaded = 1, bytesTransferred = bytes,
|
||||
newState = buildState(pair.id, rel,
|
||||
LocalFileInfo(rel, remote!!.sizeBytes, localMtime), remoteAfterTransfer = remote))
|
||||
LocalFileInfo(rel, remote!!.sizeBytes, localMtime),
|
||||
remoteAfterTransfer = remote,
|
||||
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)
|
||||
@@ -203,10 +222,13 @@ class SyncEngine @Inject constructor(
|
||||
rel: String,
|
||||
local: LocalFileInfo?,
|
||||
remoteAfterTransfer: RemoteFile?,
|
||||
storeLocalMtime: Boolean = true,
|
||||
) = SyncFileStateEntity(
|
||||
syncPairId = pairId,
|
||||
relativePath = rel,
|
||||
localModifiedAt = local?.lastModifiedMs?.let { Instant.ofEpochMilli(it) },
|
||||
// When storeLocalMtime=false, leave localModifiedAt null so the SKIP reconciliation
|
||||
// pass on the next sync reads it from the walkFiles cursor (avoids SAF stale-mtime loops).
|
||||
localModifiedAt = if (storeLocalMtime) local?.lastModifiedMs?.let { Instant.ofEpochMilli(it) } else null,
|
||||
localSizeBytes = local?.sizeBytes ?: 0L,
|
||||
localHash = null,
|
||||
remoteModifiedAt = remoteAfterTransfer?.modifiedAt,
|
||||
@@ -236,12 +258,16 @@ internal fun syncDecide(
|
||||
|
||||
// Treat null known timestamps as "not yet recorded" — don't treat as changed.
|
||||
// The SKIP reconciliation pass will fill them in on the next sync.
|
||||
// Use second-precision for both sides: FAT32 has 2-second mtime resolution, WebDAV
|
||||
// RFC-1123 has 1-second resolution, so millisecond comparison causes phantom "changed"
|
||||
// detections and rewrite loops after a fresh download/upload.
|
||||
val localChanged = known == null ||
|
||||
(localExists && known.localModifiedAt != null &&
|
||||
local!!.lastModifiedMs != known.localModifiedAt.toEpochMilli())
|
||||
local!!.lastModifiedMs / 1000 != known.localModifiedAt.epochSecond)
|
||||
val remoteChanged = known == null ||
|
||||
(remoteExists && known.remoteModifiedAt != null &&
|
||||
(remote!!.etag != known.remoteEtag || remote.modifiedAt != known.remoteModifiedAt))
|
||||
(remote!!.etag != known.remoteEtag ||
|
||||
remote.modifiedAt.epochSecond != known.remoteModifiedAt.epochSecond))
|
||||
|
||||
return when {
|
||||
!localExists && !remoteExists -> SyncDecision.SKIP
|
||||
@@ -259,21 +285,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
|
||||
|
||||
@@ -5,6 +5,7 @@ import androidx.lifecycle.SavedStateHandle
|
||||
import androidx.lifecycle.ViewModel
|
||||
import androidx.lifecycle.viewModelScope
|
||||
import com.syncflow.data.db.CloudAccountDao
|
||||
import com.syncflow.data.db.SyncFileStateDao
|
||||
import com.syncflow.data.db.SyncPairDao
|
||||
import com.syncflow.data.db.entities.CloudAccountEntity
|
||||
import com.syncflow.data.db.entities.SyncPairEntity
|
||||
@@ -58,6 +59,7 @@ data class AddPairUiState(
|
||||
@HiltViewModel
|
||||
class AddPairViewModel @Inject constructor(
|
||||
private val syncPairDao: SyncPairDao,
|
||||
private val fileStateDao: SyncFileStateDao,
|
||||
private val accountDao: CloudAccountDao,
|
||||
@ApplicationContext private val context: Context,
|
||||
savedState: SavedStateHandle,
|
||||
@@ -148,7 +150,20 @@ class AddPairViewModel @Inject constructor(
|
||||
notifyOnComplete = s.notifyOnComplete, notifyOnError = s.notifyOnError,
|
||||
isEnabled = true, lastSyncAt = null, lastSyncResult = SyncStatus.IDLE, pendingConflicts = 0,
|
||||
)
|
||||
if (editPairId == null) syncPairDao.insert(entity) else syncPairDao.update(entity)
|
||||
if (editPairId == null) {
|
||||
syncPairDao.insert(entity)
|
||||
} else {
|
||||
val existing = syncPairDao.getById(editPairId)
|
||||
syncPairDao.update(entity)
|
||||
// If local or remote folder changed, old file-state records no longer
|
||||
// correspond to any real path — wipe them so the next sync starts fresh
|
||||
// instead of trying to delete/re-upload stale paths.
|
||||
if (existing != null &&
|
||||
(existing.localPath != entity.localPath || existing.remotePath != entity.remotePath)
|
||||
) {
|
||||
fileStateDao.deleteForPair(editPairId)
|
||||
}
|
||||
}
|
||||
}
|
||||
.onSuccess {
|
||||
if (s.scheduleType == ScheduleType.ON_CHANGE) FileWatchService.start(context)
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package com.syncflow.ui.files
|
||||
|
||||
import android.content.ClipData
|
||||
import android.content.Intent
|
||||
import android.net.Uri
|
||||
import android.webkit.MimeTypeMap
|
||||
@@ -57,15 +58,18 @@ fun FilesScreen(
|
||||
val uri = FileProvider.getUriForFile(
|
||||
context, "${context.packageName}.fileprovider", action.file
|
||||
)
|
||||
val mimeType = action.file.name.mimeType()
|
||||
val intent = Intent(Intent.ACTION_VIEW).apply {
|
||||
setDataAndType(uri, action.file.name.mimeType())
|
||||
addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION or Intent.FLAG_ACTIVITY_NEW_TASK)
|
||||
setDataAndType(uri, mimeType)
|
||||
// ClipData is required so FLAG_GRANT_READ_URI_PERMISSION
|
||||
// propagates to whichever app the system chooser picks.
|
||||
clipData = ClipData.newRawUri("", uri)
|
||||
addFlags(
|
||||
Intent.FLAG_GRANT_READ_URI_PERMISSION or
|
||||
Intent.FLAG_ACTIVITY_NEW_TASK
|
||||
)
|
||||
}
|
||||
context.startActivity(
|
||||
Intent.createChooser(intent, "Open with").apply {
|
||||
addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
|
||||
}
|
||||
)
|
||||
context.startActivity(intent)
|
||||
} catch (e: Exception) {
|
||||
snackbarHostState.showSnackbar("Cannot open file: ${e.message}")
|
||||
}
|
||||
@@ -78,6 +82,7 @@ fun FilesScreen(
|
||||
val intent = Intent(Intent.ACTION_SEND).apply {
|
||||
type = action.file.name.mimeType()
|
||||
putExtra(Intent.EXTRA_STREAM, uri)
|
||||
clipData = ClipData.newRawUri("", uri)
|
||||
addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION or Intent.FLAG_ACTIVITY_NEW_TASK)
|
||||
}
|
||||
context.startActivity(
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package com.syncflow.ui.files
|
||||
|
||||
import android.content.Context
|
||||
import android.media.MediaScannerConnection
|
||||
import androidx.lifecycle.ViewModel
|
||||
import androidx.lifecycle.viewModelScope
|
||||
import com.syncflow.data.db.SyncFileStateDao
|
||||
@@ -71,6 +72,8 @@ class FilesViewModel @Inject constructor(
|
||||
fun openFile(file: SyncFileStateEntity) {
|
||||
val resolved = resolveFile(file, emitErrorIfMissing = false)
|
||||
if (resolved != null) {
|
||||
// Ensure MediaStore knows about this file so gallery apps can open it
|
||||
MediaScannerConnection.scanFile(context, arrayOf(resolved.absolutePath), null, null)
|
||||
viewModelScope.launch { _fileAction.emit(FileAction.Open(resolved)) }
|
||||
} else {
|
||||
downloadAndOpen(file)
|
||||
@@ -192,6 +195,7 @@ class FilesViewModel @Inject constructor(
|
||||
cacheFile.outputStream().use { out ->
|
||||
provider.downloadFile("${pair.remotePath}/${file.relativePath}", out) { }.getOrThrow()
|
||||
}
|
||||
MediaScannerConnection.scanFile(context, arrayOf(cacheFile.absolutePath), null, null)
|
||||
cacheFile
|
||||
} catch (e: Exception) {
|
||||
Timber.e(e, "Download for preview failed: ${file.relativePath}")
|
||||
|
||||
@@ -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() {
|
||||
|
||||
@@ -1,36 +1,12 @@
|
||||
<?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">
|
||||
|
||||
<!-- Deep blue-to-teal gradient background matching reference icon -->
|
||||
<path
|
||||
android:pathData="M0,0 H108 V108 H0 Z">
|
||||
<aapt:attr name="android:fillColor">
|
||||
<gradient
|
||||
android:type="linear"
|
||||
android:startX="0" android:startY="0"
|
||||
android:endX="108" android:endY="108"
|
||||
android:startColor="#1565C0"
|
||||
android:endColor="#00897B"/>
|
||||
</aapt:attr>
|
||||
</path>
|
||||
|
||||
<!-- Subtle radial highlight in upper-right -->
|
||||
<path
|
||||
android:pathData="M108,0 A90,90 0 0,1 108,90 Z"
|
||||
android:fillAlpha="0.18">
|
||||
<aapt:attr name="android:fillColor">
|
||||
<gradient
|
||||
android:type="radial"
|
||||
android:gradientRadius="80"
|
||||
android:centerX="85" android:centerY="23"
|
||||
android:startColor="#80DEEA"
|
||||
android:endColor="#00000000"/>
|
||||
</aapt:attr>
|
||||
</path>
|
||||
<!-- Pure black background -->
|
||||
<path android:pathData="M0,0 H108 V108 H0 Z"
|
||||
android:fillColor="#000000"/>
|
||||
|
||||
</vector>
|
||||
|
||||
@@ -1,70 +1,84 @@
|
||||
<?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">
|
||||
|
||||
<!-- Cloud body: white, centred at (54,56). Composed of three arc bumps. -->
|
||||
<path
|
||||
android:pathData="
|
||||
M 38,67
|
||||
A 9,9 0 0,1 38,49
|
||||
A 9,9 0 0,1 47,40.5
|
||||
A 12,12 0 0,1 68,42
|
||||
A 8,8 0 0,1 76,53
|
||||
A 8,8 0 0,1 70,67
|
||||
Z"
|
||||
android:fillColor="#FFFFFF"/>
|
||||
<!--
|
||||
Four thick arcs arranged as an interlocked pinwheel.
|
||||
Each arc sweeps ~210 degrees, rounded caps, radius 18 from center (54,54).
|
||||
Draw order creates natural over/under at the four crossing points:
|
||||
blue under green, green under red, red under orange, orange under blue (re-draw blue tip).
|
||||
|
||||
<!-- Cloud drop shadow -->
|
||||
Arc endpoints computed at radius 18, sweep 210 deg clockwise:
|
||||
start angle end angle start point end point
|
||||
270 (top) 120 (54, 36) (45, 70)
|
||||
0 (right) 210 (72, 54) (39, 45)
|
||||
90 (bot) 300 (54, 72) (63, 38)
|
||||
180 (left) 390=30 (36, 54) (69, 63)
|
||||
-->
|
||||
|
||||
<!-- Blue — starts at top, sweeps clockwise to lower-left -->
|
||||
<path
|
||||
android:strokeColor="#2979FF"
|
||||
android:strokeWidth="8.5"
|
||||
android:fillColor="#00000000"
|
||||
android:strokeLineCap="round"
|
||||
android:pathData="M 54,36 A 18,18 0 1,1 45,70"/>
|
||||
|
||||
<!-- Green — starts at bottom, sweeps clockwise to upper-right -->
|
||||
<path
|
||||
android:strokeColor="#00C853"
|
||||
android:strokeWidth="8.5"
|
||||
android:fillColor="#00000000"
|
||||
android:strokeLineCap="round"
|
||||
android:pathData="M 54,72 A 18,18 0 1,1 63,38"/>
|
||||
|
||||
<!-- Red — starts at right, sweeps clockwise to lower-left -->
|
||||
<path
|
||||
android:strokeColor="#E53935"
|
||||
android:strokeWidth="8.5"
|
||||
android:fillColor="#00000000"
|
||||
android:strokeLineCap="round"
|
||||
android:pathData="M 72,54 A 18,18 0 1,1 39,45"/>
|
||||
|
||||
<!-- Orange — starts at left, sweeps clockwise to upper-right -->
|
||||
<path
|
||||
android:strokeColor="#FF6D00"
|
||||
android:strokeWidth="8.5"
|
||||
android:fillColor="#00000000"
|
||||
android:strokeLineCap="round"
|
||||
android:pathData="M 36,54 A 18,18 0 1,1 69,63"/>
|
||||
|
||||
<!-- Re-draw blue start cap on top so it goes OVER orange end -->
|
||||
<path
|
||||
android:strokeColor="#2979FF"
|
||||
android:strokeWidth="8.5"
|
||||
android:fillColor="#00000000"
|
||||
android:strokeLineCap="round"
|
||||
android:pathData="M 54,36 A 18,18 0 0,1 62,37.5"/>
|
||||
|
||||
<!-- White sync circle at center -->
|
||||
<path
|
||||
android:pathData="
|
||||
M 38,69
|
||||
A 9,9 0 0,1 38,51
|
||||
A 9,9 0 0,1 47,42.5
|
||||
A 12,12 0 0,1 68,44
|
||||
A 8,8 0 0,1 76,55
|
||||
A 8,8 0 0,1 70,69
|
||||
Z"
|
||||
android:fillColor="#000000"
|
||||
android:fillAlpha="0.10"/>
|
||||
android:pathData="M 45,54 A 9,9 0 1,0 63,54 A 9,9 0 1,0 45,54 Z"/>
|
||||
|
||||
<!-- Sync arc 1: lower half CW, cyan to teal -->
|
||||
<!-- Sync ring -->
|
||||
<path
|
||||
android:pathData="M 49.14,81.57 A 28,28 0 1,1 49.14,26.43"
|
||||
android:strokeColor="#FFFFFF"
|
||||
android:strokeWidth="2.5"
|
||||
android:fillColor="#00000000"
|
||||
android:strokeWidth="5.5"
|
||||
android:strokeLineCap="round">
|
||||
<aapt:attr name="android:strokeColor">
|
||||
<gradient android:type="linear"
|
||||
android:startX="49.14" android:startY="81.57"
|
||||
android:endX="49.14" android:endY="26.43"
|
||||
android:startColor="#40C4FF"
|
||||
android:endColor="#00BFA5"/>
|
||||
</aapt:attr>
|
||||
</path>
|
||||
<!-- Arrowhead at end of arc 1 (near 260 deg) -->
|
||||
<path android:pathData="M 42.5,30.5 L 49.14,26.43 L 46.0,34.5 Z"
|
||||
android:fillColor="#00BFA5"/>
|
||||
android:pathData="M 46.5,54 A 7.5,7.5 0 1,0 61.5,54 A 7.5,7.5 0 1,0 46.5,54 Z"/>
|
||||
|
||||
<!-- Sync arc 2: upper half CW, teal to cyan -->
|
||||
<!-- Top arrow head (pointing up) -->
|
||||
<path
|
||||
android:pathData="M 58.86,26.43 A 28,28 0 1,1 58.86,81.57"
|
||||
android:fillColor="#00000000"
|
||||
android:strokeWidth="5.5"
|
||||
android:strokeLineCap="round">
|
||||
<aapt:attr name="android:strokeColor">
|
||||
<gradient android:type="linear"
|
||||
android:startX="58.86" android:startY="26.43"
|
||||
android:endX="58.86" android:endY="81.57"
|
||||
android:startColor="#00BFA5"
|
||||
android:endColor="#40C4FF"/>
|
||||
</aapt:attr>
|
||||
</path>
|
||||
<!-- Arrowhead at end of arc 2 (near 80 deg) -->
|
||||
<path android:pathData="M 65.5,77.5 L 58.86,81.57 L 62.0,73.5 Z"
|
||||
android:fillColor="#40C4FF"/>
|
||||
android:fillColor="#FFFFFF"
|
||||
android:pathData="M 54,46.5 L 57,50.5 L 51,50.5 Z"/>
|
||||
|
||||
<!-- Bottom arrow head (pointing down) -->
|
||||
<path
|
||||
android:fillColor="#FFFFFF"
|
||||
android:pathData="M 54,61.5 L 51,57.5 L 57,57.5 Z"/>
|
||||
|
||||
</vector>
|
||||
|
||||
+2
-2
@@ -1,2 +1,2 @@
|
||||
VERSION_NAME=1.0.26
|
||||
VERSION_CODE=27
|
||||
VERSION_NAME=1.0.37
|
||||
VERSION_CODE=38
|
||||
|
||||
Reference in New Issue
Block a user