Compare commits
2 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 34fb06a673 | |||
| dc2a0b2c68 |
@@ -126,7 +126,9 @@ class SyncEngine @Inject constructor(
|
|||||||
logEvent(pair.id, SyncEventType.FILE_DOWNLOADED, rel, null, bytes)
|
logEvent(pair.id, SyncEventType.FILE_DOWNLOADED, rel, null, bytes)
|
||||||
FileOutcome(downloaded = 1, bytesTransferred = bytes,
|
FileOutcome(downloaded = 1, bytesTransferred = bytes,
|
||||||
newState = buildState(pair.id, rel,
|
newState = buildState(pair.id, rel,
|
||||||
LocalFileInfo(rel, remote!!.sizeBytes, localMtime), remoteAfterTransfer = remote))
|
LocalFileInfo(rel, remote!!.sizeBytes, localMtime),
|
||||||
|
remoteAfterTransfer = remote,
|
||||||
|
storeLocalMtime = false))
|
||||||
}
|
}
|
||||||
SyncDecision.DELETE_LOCAL -> {
|
SyncDecision.DELETE_LOCAL -> {
|
||||||
accessor.delete(rel)
|
accessor.delete(rel)
|
||||||
@@ -203,10 +205,13 @@ class SyncEngine @Inject constructor(
|
|||||||
rel: String,
|
rel: String,
|
||||||
local: LocalFileInfo?,
|
local: LocalFileInfo?,
|
||||||
remoteAfterTransfer: RemoteFile?,
|
remoteAfterTransfer: RemoteFile?,
|
||||||
|
storeLocalMtime: Boolean = true,
|
||||||
) = SyncFileStateEntity(
|
) = SyncFileStateEntity(
|
||||||
syncPairId = pairId,
|
syncPairId = pairId,
|
||||||
relativePath = rel,
|
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,
|
localSizeBytes = local?.sizeBytes ?: 0L,
|
||||||
localHash = null,
|
localHash = null,
|
||||||
remoteModifiedAt = remoteAfterTransfer?.modifiedAt,
|
remoteModifiedAt = remoteAfterTransfer?.modifiedAt,
|
||||||
@@ -236,12 +241,16 @@ internal fun syncDecide(
|
|||||||
|
|
||||||
// Treat null known timestamps as "not yet recorded" — don't treat as changed.
|
// 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.
|
// 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 ||
|
val localChanged = known == null ||
|
||||||
(localExists && known.localModifiedAt != null &&
|
(localExists && known.localModifiedAt != null &&
|
||||||
local!!.lastModifiedMs != known.localModifiedAt.toEpochMilli())
|
local!!.lastModifiedMs / 1000 != known.localModifiedAt.epochSecond)
|
||||||
val remoteChanged = known == null ||
|
val remoteChanged = known == null ||
|
||||||
(remoteExists && known.remoteModifiedAt != 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 {
|
return when {
|
||||||
!localExists && !remoteExists -> SyncDecision.SKIP
|
!localExists && !remoteExists -> SyncDecision.SKIP
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ import androidx.lifecycle.SavedStateHandle
|
|||||||
import androidx.lifecycle.ViewModel
|
import androidx.lifecycle.ViewModel
|
||||||
import androidx.lifecycle.viewModelScope
|
import androidx.lifecycle.viewModelScope
|
||||||
import com.syncflow.data.db.CloudAccountDao
|
import com.syncflow.data.db.CloudAccountDao
|
||||||
|
import com.syncflow.data.db.SyncFileStateDao
|
||||||
import com.syncflow.data.db.SyncPairDao
|
import com.syncflow.data.db.SyncPairDao
|
||||||
import com.syncflow.data.db.entities.CloudAccountEntity
|
import com.syncflow.data.db.entities.CloudAccountEntity
|
||||||
import com.syncflow.data.db.entities.SyncPairEntity
|
import com.syncflow.data.db.entities.SyncPairEntity
|
||||||
@@ -58,6 +59,7 @@ data class AddPairUiState(
|
|||||||
@HiltViewModel
|
@HiltViewModel
|
||||||
class AddPairViewModel @Inject constructor(
|
class AddPairViewModel @Inject constructor(
|
||||||
private val syncPairDao: SyncPairDao,
|
private val syncPairDao: SyncPairDao,
|
||||||
|
private val fileStateDao: SyncFileStateDao,
|
||||||
private val accountDao: CloudAccountDao,
|
private val accountDao: CloudAccountDao,
|
||||||
@ApplicationContext private val context: Context,
|
@ApplicationContext private val context: Context,
|
||||||
savedState: SavedStateHandle,
|
savedState: SavedStateHandle,
|
||||||
@@ -148,7 +150,20 @@ class AddPairViewModel @Inject constructor(
|
|||||||
notifyOnComplete = s.notifyOnComplete, notifyOnError = s.notifyOnError,
|
notifyOnComplete = s.notifyOnComplete, notifyOnError = s.notifyOnError,
|
||||||
isEnabled = true, lastSyncAt = null, lastSyncResult = SyncStatus.IDLE, pendingConflicts = 0,
|
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 {
|
.onSuccess {
|
||||||
if (s.scheduleType == ScheduleType.ON_CHANGE) FileWatchService.start(context)
|
if (s.scheduleType == ScheduleType.ON_CHANGE) FileWatchService.start(context)
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
package com.syncflow.ui.files
|
package com.syncflow.ui.files
|
||||||
|
|
||||||
|
import android.content.ClipData
|
||||||
import android.content.Intent
|
import android.content.Intent
|
||||||
import android.net.Uri
|
import android.net.Uri
|
||||||
import android.webkit.MimeTypeMap
|
import android.webkit.MimeTypeMap
|
||||||
@@ -57,15 +58,18 @@ fun FilesScreen(
|
|||||||
val uri = FileProvider.getUriForFile(
|
val uri = FileProvider.getUriForFile(
|
||||||
context, "${context.packageName}.fileprovider", action.file
|
context, "${context.packageName}.fileprovider", action.file
|
||||||
)
|
)
|
||||||
|
val mimeType = action.file.name.mimeType()
|
||||||
val intent = Intent(Intent.ACTION_VIEW).apply {
|
val intent = Intent(Intent.ACTION_VIEW).apply {
|
||||||
setDataAndType(uri, action.file.name.mimeType())
|
setDataAndType(uri, mimeType)
|
||||||
addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION or Intent.FLAG_ACTIVITY_NEW_TASK)
|
// ClipData is required so FLAG_GRANT_READ_URI_PERMISSION
|
||||||
}
|
// propagates to whichever app the system chooser picks.
|
||||||
context.startActivity(
|
clipData = ClipData.newRawUri("", uri)
|
||||||
Intent.createChooser(intent, "Open with").apply {
|
addFlags(
|
||||||
addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
|
Intent.FLAG_GRANT_READ_URI_PERMISSION or
|
||||||
}
|
Intent.FLAG_ACTIVITY_NEW_TASK
|
||||||
)
|
)
|
||||||
|
}
|
||||||
|
context.startActivity(intent)
|
||||||
} catch (e: Exception) {
|
} catch (e: Exception) {
|
||||||
snackbarHostState.showSnackbar("Cannot open file: ${e.message}")
|
snackbarHostState.showSnackbar("Cannot open file: ${e.message}")
|
||||||
}
|
}
|
||||||
@@ -78,6 +82,7 @@ fun FilesScreen(
|
|||||||
val intent = Intent(Intent.ACTION_SEND).apply {
|
val intent = Intent(Intent.ACTION_SEND).apply {
|
||||||
type = action.file.name.mimeType()
|
type = action.file.name.mimeType()
|
||||||
putExtra(Intent.EXTRA_STREAM, uri)
|
putExtra(Intent.EXTRA_STREAM, uri)
|
||||||
|
clipData = ClipData.newRawUri("", uri)
|
||||||
addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION or Intent.FLAG_ACTIVITY_NEW_TASK)
|
addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION or Intent.FLAG_ACTIVITY_NEW_TASK)
|
||||||
}
|
}
|
||||||
context.startActivity(
|
context.startActivity(
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
package com.syncflow.ui.files
|
package com.syncflow.ui.files
|
||||||
|
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
|
import android.media.MediaScannerConnection
|
||||||
import androidx.lifecycle.ViewModel
|
import androidx.lifecycle.ViewModel
|
||||||
import androidx.lifecycle.viewModelScope
|
import androidx.lifecycle.viewModelScope
|
||||||
import com.syncflow.data.db.SyncFileStateDao
|
import com.syncflow.data.db.SyncFileStateDao
|
||||||
@@ -71,6 +72,8 @@ class FilesViewModel @Inject constructor(
|
|||||||
fun openFile(file: SyncFileStateEntity) {
|
fun openFile(file: SyncFileStateEntity) {
|
||||||
val resolved = resolveFile(file, emitErrorIfMissing = false)
|
val resolved = resolveFile(file, emitErrorIfMissing = false)
|
||||||
if (resolved != null) {
|
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)) }
|
viewModelScope.launch { _fileAction.emit(FileAction.Open(resolved)) }
|
||||||
} else {
|
} else {
|
||||||
downloadAndOpen(file)
|
downloadAndOpen(file)
|
||||||
@@ -192,6 +195,7 @@ class FilesViewModel @Inject constructor(
|
|||||||
cacheFile.outputStream().use { out ->
|
cacheFile.outputStream().use { out ->
|
||||||
provider.downloadFile("${pair.remotePath}/${file.relativePath}", out) { }.getOrThrow()
|
provider.downloadFile("${pair.remotePath}/${file.relativePath}", out) { }.getOrThrow()
|
||||||
}
|
}
|
||||||
|
MediaScannerConnection.scanFile(context, arrayOf(cacheFile.absolutePath), null, null)
|
||||||
cacheFile
|
cacheFile
|
||||||
} catch (e: Exception) {
|
} catch (e: Exception) {
|
||||||
Timber.e(e, "Download for preview failed: ${file.relativePath}")
|
Timber.e(e, "Download for preview failed: ${file.relativePath}")
|
||||||
|
|||||||
@@ -6,29 +6,18 @@
|
|||||||
android:viewportWidth="108"
|
android:viewportWidth="108"
|
||||||
android:viewportHeight="108">
|
android:viewportHeight="108">
|
||||||
|
|
||||||
<!-- Deep blue-to-teal gradient background matching reference icon -->
|
<!-- Dark charcoal background, matching Avast-style dark icon bg -->
|
||||||
<path
|
<path android:pathData="M0,0 H108 V108 H0 Z"
|
||||||
android:pathData="M0,0 H108 V108 H0 Z">
|
android:fillColor="#1F1F2E"/>
|
||||||
<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 -->
|
<!-- Very subtle inner glow -->
|
||||||
<path
|
<path android:pathData="M0,0 H108 V108 H0 Z"
|
||||||
android:pathData="M108,0 A90,90 0 0,1 108,90 Z"
|
android:fillAlpha="0.25">
|
||||||
android:fillAlpha="0.18">
|
|
||||||
<aapt:attr name="android:fillColor">
|
<aapt:attr name="android:fillColor">
|
||||||
<gradient
|
<gradient android:type="radial"
|
||||||
android:type="radial"
|
android:gradientRadius="60"
|
||||||
android:gradientRadius="80"
|
android:centerX="54" android:centerY="50"
|
||||||
android:centerX="85" android:centerY="23"
|
android:startColor="#3D3A50"
|
||||||
android:startColor="#80DEEA"
|
|
||||||
android:endColor="#00000000"/>
|
android:endColor="#00000000"/>
|
||||||
</aapt:attr>
|
</aapt:attr>
|
||||||
</path>
|
</path>
|
||||||
|
|||||||
@@ -1,4 +1,13 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?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"
|
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
xmlns:aapt="http://schemas.android.com/aapt"
|
xmlns:aapt="http://schemas.android.com/aapt"
|
||||||
android:width="108dp"
|
android:width="108dp"
|
||||||
@@ -6,65 +15,88 @@
|
|||||||
android:viewportWidth="108"
|
android:viewportWidth="108"
|
||||||
android:viewportHeight="108">
|
android:viewportHeight="108">
|
||||||
|
|
||||||
<!-- Cloud body: white, centred at (54,56). Composed of three arc bumps. -->
|
<!-- 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
|
<path
|
||||||
android:pathData="
|
android:pathData="
|
||||||
M 38,67
|
M 36,62
|
||||||
A 9,9 0 0,1 38,49
|
A 9,9 0 0,1 36,44
|
||||||
A 9,9 0 0,1 47,40.5
|
A 9,9 0 0,1 45,36
|
||||||
A 12,12 0 0,1 68,42
|
A 12,12 0 0,1 66,37
|
||||||
A 8,8 0 0,1 76,53
|
A 8,8 0 0,1 74,48
|
||||||
A 8,8 0 0,1 70,67
|
A 8,8 0 0,1 68,62
|
||||||
Z"
|
Z"
|
||||||
android:fillColor="#FFFFFF"/>
|
android:fillColor="#FFFFFF"/>
|
||||||
|
|
||||||
<!-- Cloud drop shadow -->
|
<!-- Teal highlight on cloud top-left edge -->
|
||||||
<path
|
<path
|
||||||
android:pathData="
|
android:pathData="M 36,53 A 9,9 0 0,1 41,38"
|
||||||
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"/>
|
|
||||||
|
|
||||||
<!-- Sync arc 1: lower half CW, cyan to teal -->
|
|
||||||
<path
|
|
||||||
android:pathData="M 49.14,81.57 A 28,28 0 1,1 49.14,26.43"
|
|
||||||
android:fillColor="#00000000"
|
android:fillColor="#00000000"
|
||||||
android:strokeWidth="5.5"
|
android:strokeWidth="2"
|
||||||
android:strokeLineCap="round">
|
android:strokeLineCap="round"
|
||||||
<aapt:attr name="android:strokeColor">
|
android:strokeColor="#4000BFA5"/>
|
||||||
<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"/>
|
|
||||||
|
|
||||||
<!-- Sync arc 2: upper half CW, teal to cyan -->
|
<!-- Red highlight on cloud top-right edge -->
|
||||||
<path
|
<path
|
||||||
android:pathData="M 58.86,26.43 A 28,28 0 1,1 58.86,81.57"
|
android:pathData="M 63,37 A 8,8 0 0,1 73,48"
|
||||||
android:fillColor="#00000000"
|
android:fillColor="#00000000"
|
||||||
android:strokeWidth="5.5"
|
android:strokeWidth="2"
|
||||||
android:strokeLineCap="round">
|
android:strokeLineCap="round"
|
||||||
<aapt:attr name="android:strokeColor">
|
android:strokeColor="#40E53935"/>
|
||||||
<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"/>
|
|
||||||
|
|
||||||
</vector>
|
</vector>
|
||||||
|
|||||||
+2
-2
@@ -1,2 +1,2 @@
|
|||||||
VERSION_NAME=1.0.26
|
VERSION_NAME=1.0.28
|
||||||
VERSION_CODE=27
|
VERSION_CODE=29
|
||||||
|
|||||||
Reference in New Issue
Block a user