Browse Source

wip image previews

pull/267/head
erinn 1 month ago
parent
commit
b994c42803
  1. 2
      android/app/src/main/kotlin/im/cwtch/flwtch/FlwtchWorker.kt
  2. 14
      android/app/src/main/kotlin/im/cwtch/flwtch/MainActivity.kt
  3. 2
      lib/views/globalsettingsview.dart
  4. 2
      pubspec.lock

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

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

2
lib/views/globalsettingsview.dart

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

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

Loading…
Cancel
Save