wip image previews

This commit is contained in:
erinn 2021-12-14 17:13:13 -08:00
parent c16800bc0c
commit b994c42803
4 changed files with 16 additions and 4 deletions

View File

@ -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);

View File

@ -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);
}
}
}

View File

@ -232,7 +232,7 @@ class _GlobalSettingsViewState extends State<GlobalSettingsView> {
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) {

View File

@ -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: