wip image previews
This commit is contained in:
parent
63fc1fe772
commit
8c4a5aee90
|
@ -22,6 +22,7 @@ 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 android.net.Uri
|
import android.net.Uri
|
||||||
import android.provider.DocumentsContract
|
import android.provider.DocumentsContract
|
||||||
|
@ -57,9 +58,11 @@ class MainActivity: FlutterActivity() {
|
||||||
|
|
||||||
// "Download to..." prompt extra arguments
|
// "Download to..." prompt extra arguments
|
||||||
private val FILEPICKER_REQUEST_CODE = 234
|
private val FILEPICKER_REQUEST_CODE = 234
|
||||||
|
private val PREVIEW_EXPORT_REQUEST_CODE = 235
|
||||||
private var dlToProfile = ""
|
private var dlToProfile = ""
|
||||||
private var dlToHandle = ""
|
private var dlToHandle = ""
|
||||||
private var dlToFileKey = ""
|
private var dlToFileKey = ""
|
||||||
|
private var exportFromPath = ""
|
||||||
|
|
||||||
// handles clicks received from outside the app (ie, notifications)
|
// handles clicks received from outside the app (ie, notifications)
|
||||||
override fun onNewIntent(intent: Intent) {
|
override fun onNewIntent(intent: Intent) {
|
||||||
|
@ -102,6 +105,11 @@ class MainActivity: FlutterActivity() {
|
||||||
"manifestpath" to manifestPath,
|
"manifestpath" to manifestPath,
|
||||||
"filekey" to this.dlToFileKey
|
"filekey" to this.dlToFileKey
|
||||||
)), ErrorLogResult(""));//placeholder; this Result is never actually invoked
|
)), ErrorLogResult(""));//placeholder; this Result is never actually invoked
|
||||||
|
} else if (requestCode == PREVIEW_EXPORT_REQUEST_CODE) {
|
||||||
|
val targetPath = intent!!.getData().toString()
|
||||||
|
var srcFile = File(this.exportFromPath)
|
||||||
|
Log.i("MainActivity:PREVIEW_EXPORT", "exporting previewed file")
|
||||||
|
srcFile.copyTo(File(targetPath));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -170,6 +178,26 @@ class MainActivity: FlutterActivity() {
|
||||||
}
|
}
|
||||||
startActivityForResult(intent, FILEPICKER_REQUEST_CODE)
|
startActivityForResult(intent, FILEPICKER_REQUEST_CODE)
|
||||||
return
|
return
|
||||||
|
} else if (call.method == "ExportPreviewedFile") {
|
||||||
|
this.exportFromPath = argmap["Path"] ?: ""
|
||||||
|
val suggestion = argmap["FileName"] ?: "filename.ext"
|
||||||
|
var imgType = "jpeg"
|
||||||
|
if (suggestion.endsWith("png")) {
|
||||||
|
imgType = "png"
|
||||||
|
} else if (suggestion.endsWith("webp")) {
|
||||||
|
imgType = "webp"
|
||||||
|
} else if (suggestion.endsWith("bmp")) {
|
||||||
|
imgType = "bmp"
|
||||||
|
} else if (suggestion.endsWith("gif")) {
|
||||||
|
imgType = "gif"
|
||||||
|
}
|
||||||
|
val intent = Intent(Intent.ACTION_CREATE_DOCUMENT).apply {
|
||||||
|
addCategory(Intent.CATEGORY_OPENABLE)
|
||||||
|
type = "image/" + imgType
|
||||||
|
putExtra(Intent.EXTRA_TITLE, suggestion)
|
||||||
|
}
|
||||||
|
startActivityForResult(intent, PREVIEW_EXPORT_REQUEST_CODE)
|
||||||
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
// ...otherwise fallthru to a normal ffi method call (and return the result using the result callback)
|
// ...otherwise fallthru to a normal ffi method call (and return the result using the result callback)
|
||||||
|
|
|
@ -55,6 +55,8 @@ abstract class Cwtch {
|
||||||
void CheckDownloadStatus(String profile, String fileKey);
|
void CheckDownloadStatus(String profile, String fileKey);
|
||||||
// ignore: non_constant_identifier_names
|
// ignore: non_constant_identifier_names
|
||||||
void VerifyOrResumeDownload(String profile, int handle, String filekey);
|
void VerifyOrResumeDownload(String profile, int handle, String filekey);
|
||||||
|
// ignore: non_constant_identifier_names
|
||||||
|
void ExportPreviewedFile(String sourceFile, String suggestion);
|
||||||
|
|
||||||
// ignore: non_constant_identifier_names
|
// ignore: non_constant_identifier_names
|
||||||
void ArchiveConversation(String profile, int handle);
|
void ArchiveConversation(String profile, int handle);
|
||||||
|
|
|
@ -402,6 +402,11 @@ class CwtchFfi implements Cwtch {
|
||||||
// android only - do nothing
|
// android only - do nothing
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ignore: non_constant_identifier_names
|
||||||
|
void ExportPreviewedFile(String sourceFile, String suggestion) {
|
||||||
|
// android only - do nothing
|
||||||
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
// ignore: non_constant_identifier_names
|
// ignore: non_constant_identifier_names
|
||||||
void CheckDownloadStatus(String profileOnion, String fileKey) {
|
void CheckDownloadStatus(String profileOnion, String fileKey) {
|
||||||
|
|
|
@ -149,6 +149,11 @@ class CwtchGomobile implements Cwtch {
|
||||||
cwtchPlatform.invokeMethod("CreateDownloadableFile", {"ProfileOnion": profileOnion, "conversation": conversation, "filename": filenameSuggestion, "filekey": filekey});
|
cwtchPlatform.invokeMethod("CreateDownloadableFile", {"ProfileOnion": profileOnion, "conversation": conversation, "filename": filenameSuggestion, "filekey": filekey});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ignore: non_constant_identifier_names
|
||||||
|
void ExportPreviewedFile(String sourceFile, String suggestion) {
|
||||||
|
cwtchPlatform.invokeMethod("ExportPreviewedFile", {"Path": sourceFile, "FileName": suggestion,});
|
||||||
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
// ignore: non_constant_identifier_names
|
// ignore: non_constant_identifier_names
|
||||||
void CheckDownloadStatus(String profileOnion, String fileKey) {
|
void CheckDownloadStatus(String profileOnion, String fileKey) {
|
||||||
|
|
|
@ -227,7 +227,6 @@ class _GlobalSettingsViewState extends State<GlobalSettingsView> {
|
||||||
inactiveTrackColor: settings.theme.defaultButtonDisabledColor(),
|
inactiveTrackColor: settings.theme.defaultButtonDisabledColor(),
|
||||||
secondary: Icon(Icons.attach_file, color: settings.current().mainTextColor()),
|
secondary: Icon(Icons.attach_file, color: settings.current().mainTextColor()),
|
||||||
),
|
),
|
||||||
<<<<<<< HEAD
|
|
||||||
Visibility(
|
Visibility(
|
||||||
visible: settings.isExperimentEnabled(FileSharingExperiment),
|
visible: settings.isExperimentEnabled(FileSharingExperiment),
|
||||||
child: Column(children:[
|
child: Column(children:[
|
||||||
|
|
|
@ -322,8 +322,13 @@ class FileBubbleState extends State<FileBubble> {
|
||||||
fit: BoxFit.scaleDown
|
fit: BoxFit.scaleDown
|
||||||
)
|
)
|
||||||
),
|
),
|
||||||
),Icon(Icons.arrow_downward)]),
|
),IconButton(icon: Icon(Icons.arrow_downward), onPressed: androidExport),
|
||||||
|
]),
|
||||||
))
|
))
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void androidExport() async {
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue