diff --git a/android/app/src/main/kotlin/im/cwtch/flwtch/FlwtchWorker.kt b/android/app/src/main/kotlin/im/cwtch/flwtch/FlwtchWorker.kt index e8c737ad..ed5283d8 100644 --- a/android/app/src/main/kotlin/im/cwtch/flwtch/FlwtchWorker.kt +++ b/android/app/src/main/kotlin/im/cwtch/flwtch/FlwtchWorker.kt @@ -140,7 +140,7 @@ class FlwtchWorker(context: Context, parameters: WorkerParameters) : val data = JSONObject(evt.Data); val tempFile = data.getString("TempFile"); val fileKey = data.getString("FileKey"); - if (tempFile != "") { + if (tempFile != "" && tempFile != data.getString("FilePath")) { val filePath = data.getString("FilePath"); Log.i("FlwtchWorker", "moving "+tempFile+" to "+filePath); val sourcePath = Paths.get(tempFile); diff --git a/android/app/src/main/kotlin/im/cwtch/flwtch/MainActivity.kt b/android/app/src/main/kotlin/im/cwtch/flwtch/MainActivity.kt index d0e3d06e..2663f54c 100644 --- a/android/app/src/main/kotlin/im/cwtch/flwtch/MainActivity.kt +++ b/android/app/src/main/kotlin/im/cwtch/flwtch/MainActivity.kt @@ -23,6 +23,9 @@ import io.flutter.plugin.common.ErrorLogResult import org.json.JSONObject import java.util.concurrent.TimeUnit import java.io.File +import java.nio.file.Files +import java.nio.file.Paths +import java.nio.file.StandardCopyOption import android.net.Uri import android.provider.DocumentsContract @@ -109,7 +112,16 @@ class MainActivity: FlutterActivity() { val targetPath = intent!!.getData().toString() var srcFile = File(this.exportFromPath) Log.i("MainActivity:PREVIEW_EXPORT", "exporting previewed file") - srcFile.copyTo(File(targetPath)); + val sourcePath = Paths.get(this.exportFromPath); + val targetUri = Uri.parse(targetPath); + val os = this.applicationContext.getContentResolver().openOutputStream(targetUri); + val bytesWritten = Files.copy(sourcePath, os); + Log.d("MainActivity:PREVIEW_EXPORT", "copied " + bytesWritten.toString() + " bytes"); + if (bytesWritten != 0L) { + os?.flush(); + os?.close(); + //Files.delete(sourcePath); + } } } diff --git a/lib/views/globalsettingsview.dart b/lib/views/globalsettingsview.dart index 2179e4a4..a88f121b 100644 --- a/lib/views/globalsettingsview.dart +++ b/lib/views/globalsettingsview.dart @@ -232,7 +232,7 @@ class _GlobalSettingsViewState extends State { child: Column(children:[ SwitchListTile( title: Text("Image Previews and Profile Pics", style: TextStyle(color: settings.current().mainTextColor())), - subtitle: Text("TODO: Write a description with lots of warnings about how image previews can be an insecurity vector and you should only enable them with great caution..."), + subtitle: Text("Images"), value: settings.isExperimentEnabled(ImagePreviewsExperiment), onChanged: (bool value) { if (value) { diff --git a/pubspec.lock b/pubspec.lock index e990cfd9..3c1db18c 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -417,7 +417,7 @@ packages: name: test_api url: "https://pub.dartlang.org" source: hosted - version: "0.4.7" + version: "0.4.3" typed_data: dependency: transitive description: