forked from cwtch.im/cwtch-ui
wip image previews
This commit is contained in:
parent
c16800bc0c
commit
b994c42803
|
@ -140,7 +140,7 @@ class FlwtchWorker(context: Context, parameters: WorkerParameters) :
|
||||||
val data = JSONObject(evt.Data);
|
val data = JSONObject(evt.Data);
|
||||||
val tempFile = data.getString("TempFile");
|
val tempFile = data.getString("TempFile");
|
||||||
val fileKey = data.getString("FileKey");
|
val fileKey = data.getString("FileKey");
|
||||||
if (tempFile != "") {
|
if (tempFile != "" && tempFile != data.getString("FilePath")) {
|
||||||
val filePath = data.getString("FilePath");
|
val filePath = data.getString("FilePath");
|
||||||
Log.i("FlwtchWorker", "moving "+tempFile+" to "+filePath);
|
Log.i("FlwtchWorker", "moving "+tempFile+" to "+filePath);
|
||||||
val sourcePath = Paths.get(tempFile);
|
val sourcePath = Paths.get(tempFile);
|
||||||
|
|
|
@ -23,6 +23,9 @@ import io.flutter.plugin.common.ErrorLogResult
|
||||||
import org.json.JSONObject
|
import org.json.JSONObject
|
||||||
import java.util.concurrent.TimeUnit
|
import java.util.concurrent.TimeUnit
|
||||||
import java.io.File
|
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.net.Uri
|
||||||
import android.provider.DocumentsContract
|
import android.provider.DocumentsContract
|
||||||
|
@ -109,7 +112,16 @@ class MainActivity: FlutterActivity() {
|
||||||
val targetPath = intent!!.getData().toString()
|
val targetPath = intent!!.getData().toString()
|
||||||
var srcFile = File(this.exportFromPath)
|
var srcFile = File(this.exportFromPath)
|
||||||
Log.i("MainActivity:PREVIEW_EXPORT", "exporting previewed file")
|
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);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -232,7 +232,7 @@ class _GlobalSettingsViewState extends State<GlobalSettingsView> {
|
||||||
child: Column(children:[
|
child: Column(children:[
|
||||||
SwitchListTile(
|
SwitchListTile(
|
||||||
title: Text("Image Previews and Profile Pics", style: TextStyle(color: settings.current().mainTextColor())),
|
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),
|
value: settings.isExperimentEnabled(ImagePreviewsExperiment),
|
||||||
onChanged: (bool value) {
|
onChanged: (bool value) {
|
||||||
if (value) {
|
if (value) {
|
||||||
|
|
|
@ -417,7 +417,7 @@ packages:
|
||||||
name: test_api
|
name: test_api
|
||||||
url: "https://pub.dartlang.org"
|
url: "https://pub.dartlang.org"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "0.4.7"
|
version: "0.4.3"
|
||||||
typed_data:
|
typed_data:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
|
|
Loading…
Reference in New Issue