v1.0.27: knot-inspired icon, fix media-not-found on photo open

Icon: two thick tube-style arcs with 3D glossy highlights.
  Arc 1 (left side): coral #E8665A to orange #E8A040
  Arc 2 (right side): steel blue #4A7FD4 to deep purple #7B5EA7
  Arrowheads: orange and purple. Background: dark purple-black.
  Inspired by the braided knot color palette.

Fix "media not found" when opening photos:
  - Intent now sets ClipData alongside FLAG_GRANT_READ_URI_PERMISSION
    so the permission correctly propagates through the system chooser
    to whichever app the user picks.
  - openFile() and downloadToCache() both call MediaScannerConnection
    so newly synced/downloaded files appear in gallery MediaStore index
    before the viewer launches.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-05-25 03:08:44 +00:00
parent 742f634084
commit dc2a0b2c68
5 changed files with 99 additions and 77 deletions
@@ -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}")
@@ -6,30 +6,14 @@
android:viewportWidth="108"
android:viewportHeight="108">
<!-- Deep blue-to-teal gradient background matching reference icon -->
<path
android:pathData="M0,0 H108 V108 H0 Z">
<!-- Deep purple-black base, matching the knot reference icon's dark background -->
<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"/>
<gradient android:type="radial"
android:gradientRadius="76"
android:centerX="54" android:centerY="44"
android:startColor="#1E1628"
android:endColor="#080610"/>
</aapt:attr>
</path>
@@ -1,4 +1,24 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
SyncFlow icon foreground (108x108dp, safe zone 72dp centred at 54,54).
Design: two thick tube-style sync arcs that form a circular refresh symbol,
inspired by the braided knot icon's color palette:
Arc 1 (left side, CW): coral #E8665A -> orange #E8A040
Arc 2 (right side, CW): steel blue #4A7FD4 -> purple #7B5EA7
Each arc has a thin inner highlight to give a 3D glossy tube look.
Geometry: circle centred at (54,54), radius 27.
Arc 1: 100 deg to 260 deg CW (160 deg, through west/left)
start (49.31, 80.59) end (49.31, 27.41)
Arc 2: 280 deg to 80 deg CW (160 deg, through east/right)
start (58.69, 27.41) end (58.69, 80.59)
20-degree gaps at top (~260-280) and bottom (~80-100).
Highlights at r=23 (inner edge):
Arc 1 highlight: (49.99, 76.64) to (49.99, 31.36)
Arc 2 highlight: (58.01, 31.36) to (58.01, 76.64)
-->
<vector xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:aapt="http://schemas.android.com/aapt"
android:width="108dp"
@@ -6,65 +26,74 @@
android:viewportWidth="108"
android:viewportHeight="108">
<!-- Cloud body: white, centred at (54,56). Composed of three arc bumps. -->
<!-- Arc 1 shadow (offset slightly down-right for depth) -->
<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"/>
<!-- Cloud drop shadow -->
<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"/>
<!-- 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:pathData="M 50.31,82.59 A 27,27 0 0,1 50.31,29.41"
android:fillColor="#00000000"
android:strokeWidth="5.5"
android:strokeWidth="9"
android:strokeLineCap="round"
android:strokeColor="#44000000"/>
<!-- Arc 2 shadow -->
<path
android:pathData="M 59.69,29.41 A 27,27 0 0,1 59.69,82.59"
android:fillColor="#00000000"
android:strokeWidth="9"
android:strokeLineCap="round"
android:strokeColor="#44000000"/>
<!-- Arc 1: left side, coral to orange -->
<path
android:pathData="M 49.31,80.59 A 27,27 0 0,1 49.31,27.41"
android:fillColor="#00000000"
android:strokeWidth="9"
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"/>
android:startX="49.31" android:startY="80.59"
android:endX="49.31" android:endY="27.41"
android:startColor="#E8665A"
android:endColor="#E8A040"/>
</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 -->
<!-- Arc 2: right side, blue to purple -->
<path
android:pathData="M 58.86,26.43 A 28,28 0 1,1 58.86,81.57"
android:pathData="M 58.69,27.41 A 27,27 0 0,1 58.69,80.59"
android:fillColor="#00000000"
android:strokeWidth="5.5"
android:strokeWidth="9"
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"/>
android:startX="58.69" android:startY="27.41"
android:endX="58.69" android:endY="80.59"
android:startColor="#4A7FD4"
android:endColor="#7B5EA7"/>
</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"/>
<!-- Arc 1 inner highlight (glossy tube sheen) -->
<path
android:pathData="M 49.99,76.64 A 23,23 0 0,1 49.99,31.36"
android:fillColor="#00000000"
android:strokeWidth="2.5"
android:strokeLineCap="round"
android:strokeColor="#55FFC8B0"/>
<!-- Arc 2 inner highlight -->
<path
android:pathData="M 58.01,31.36 A 23,23 0 0,1 58.01,76.64"
android:fillColor="#00000000"
android:strokeWidth="2.5"
android:strokeLineCap="round"
android:strokeColor="#55B0C8FF"/>
<!-- Arrowhead at end of Arc 1 (260 deg, top-left area, pointing right-up) -->
<path android:pathData="M 42.13,32.74 L 49.31,27.41 L 40.73,24.86 Z"
android:fillColor="#E8A040"/>
<!-- Arrowhead at end of Arc 2 (80 deg, bottom-right area, pointing left-down) -->
<path android:pathData="M 67.27,83.14 L 58.69,80.59 L 65.87,75.26 Z"
android:fillColor="#7B5EA7"/>
</vector>