Update Cwtch. Make File Download Consistent on Android #641
|
@ -1 +1 @@
|
|||
2023-03-14-11-33-v0.0.3
|
||||
2023-03-16-15-07-v0.0.3-1-g50c853a
|
|
@ -68,6 +68,7 @@ class MainActivity: FlutterActivity() {
|
|||
private val PROFILE_EXPORT_REQUEST_CODE = 236
|
||||
private val REQUEST_DOZE_WHITELISTING_CODE:Int = 9
|
||||
private var dlToProfile = ""
|
||||
private var dlManifestPath = ""
|
||||
private var dlToHandle = 0
|
||||
private var dlToFileKey = ""
|
||||
private var exportFromPath = ""
|
||||
|
@ -127,13 +128,14 @@ class MainActivity: FlutterActivity() {
|
|||
|
||||
if (requestCode == FILEPICKER_REQUEST_CODE) {
|
||||
val filePath = intent!!.getData().toString();
|
||||
val manifestPath = StringBuilder().append(this.applicationContext.cacheDir).append("/").append(this.dlToFileKey).toString();
|
||||
Log.d("MainActivity:FILEPICKER_REQUEST_CODE", "DownloadableFileCreated");
|
||||
Log.d("MainActivity:FILEPICKER_REQUEST_CODE", this.dlManifestPath);
|
||||
Log.d("MainActivity:FILEPICKER_REQUEST_CODE", filePath);
|
||||
handleCwtch(MethodCall("DownloadFile", mapOf(
|
||||
"ProfileOnion" to this.dlToProfile,
|
||||
"conversation" to this.dlToHandle.toInt(),
|
||||
"filepath" to filePath,
|
||||
"manifestpath" to manifestPath,
|
||||
"manifestpath" to this.dlManifestPath,
|
||||
"filekey" to this.dlToFileKey
|
||||
)), ErrorLogResult(""));//placeholder; this Result is never actually invoked
|
||||
} else if (requestCode == PREVIEW_EXPORT_REQUEST_CODE) {
|
||||
|
@ -257,6 +259,7 @@ class MainActivity: FlutterActivity() {
|
|||
"CreateDownloadableFile" -> {
|
||||
this.dlToProfile = argmap["ProfileOnion"] ?: ""
|
||||
this.dlToHandle = call.argument("conversation")!!
|
||||
this.dlManifestPath = argmap["manifestpath"] ?: ""
|
||||
val suggestedName = argmap["filename"] ?: "filename.ext"
|
||||
this.dlToFileKey = argmap["filekey"] ?: ""
|
||||
val intent = Intent(Intent.ACTION_CREATE_DOCUMENT).apply {
|
||||
|
@ -429,6 +432,7 @@ class MainActivity: FlutterActivity() {
|
|||
val filekey: String = call.argument("filekey") ?: ""
|
||||
// FIXME: Prevent spurious calls by Intent
|
||||
if (profile != "") {
|
||||
Log.d("MainActivity.kt", "Cwtch Download File Calling...")
|
||||
Cwtch.downloadFileDefaultLimit(profile, conversation.toLong(), filepath, manifestpath, filekey)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -74,7 +74,7 @@ abstract class Cwtch {
|
|||
void DownloadFile(String profile, int handle, String filepath, String manifestpath, String filekey);
|
||||
// android-only
|
||||
// ignore: non_constant_identifier_names
|
||||
void CreateDownloadableFile(String profile, int handle, String filenameSuggestion, String filekey);
|
||||
void CreateDownloadableFile(String profile, int handle, String filenameSuggestion, String filekey, String manifestPath);
|
||||
// ignore: non_constant_identifier_names
|
||||
void CheckDownloadStatus(String profile, String fileKey);
|
||||
// ignore: non_constant_identifier_names
|
||||
|
|
|
@ -70,7 +70,7 @@ class CwtchNotifier {
|
|||
if (data["Online"] == null) {
|
||||
break;
|
||||
}
|
||||
// EnvironmentConfig.debugLog("NewPeer $data");
|
||||
// EnvironmentConfig.debugLog("NewPeer $data");
|
||||
// if tag != v1-defaultPassword then it is either encrypted OR it is an unencrypted account created during pre-beta...
|
||||
profileCN.add(data["Identity"], data["name"], data["picture"], data["defaultPicture"], data["ContactsJson"], data["ServerList"], data["Online"] == "true", data["autostart"] == "true",
|
||||
data["tag"] != "v1-defaultPassword");
|
||||
|
|
|
@ -460,7 +460,7 @@ class CwtchFfi implements Cwtch {
|
|||
|
||||
@override
|
||||
// ignore: non_constant_identifier_names
|
||||
void CreateDownloadableFile(String profileOnion, int contactHandle, String filenameSuggestion, String filekey) {
|
||||
void CreateDownloadableFile(String profileOnion, int contactHandle, String filenameSuggestion, String filekey, String manifestPath) {
|
||||
// android only - do nothing
|
||||
}
|
||||
|
||||
|
|
|
@ -168,8 +168,9 @@ class CwtchGomobile implements Cwtch {
|
|||
}
|
||||
|
||||
// ignore: non_constant_identifier_names
|
||||
void CreateDownloadableFile(String profileOnion, int conversation, String filenameSuggestion, String filekey) {
|
||||
cwtchPlatform.invokeMethod("CreateDownloadableFile", {"ProfileOnion": profileOnion, "conversation": conversation, "filename": filenameSuggestion, "filekey": filekey});
|
||||
void CreateDownloadableFile(String profileOnion, int conversation, String filenameSuggestion, String filekey, String manifestpath) {
|
||||
cwtchPlatform
|
||||
.invokeMethod("CreateDownloadableFile", {"ProfileOnion": profileOnion, "conversation": conversation, "manifestpath": manifestpath, "filename": filenameSuggestion, "filekey": filekey});
|
||||
}
|
||||
|
||||
// ignore: non_constant_identifier_names
|
||||
|
|
|
@ -265,7 +265,9 @@ class FileBubbleState extends State<FileBubble> {
|
|||
Provider.of<FlwtchState>(context, listen: false).cwtch.SetMessageAttribute(profileOnion, conversation, 0, idx, "file-downloaded", "true");
|
||||
ContactInfoState? contact = Provider.of<ProfileInfoState>(context, listen: false).contactList.findContact(Provider.of<MessageMetadata>(context, listen: false).senderHandle);
|
||||
if (contact != null) {
|
||||
Provider.of<FlwtchState>(context, listen: false).cwtch.CreateDownloadableFile(profileOnion, contact.identifier, widget.nameSuggestion, widget.fileKey());
|
||||
var manifestPath = Provider.of<Settings>(context, listen: false).downloadPath + "/" + widget.fileKey() + ".manifest";
|
||||
|
||||
Provider.of<FlwtchState>(context, listen: false).cwtch.CreateDownloadableFile(profileOnion, contact.identifier, widget.nameSuggestion, widget.fileKey(), manifestPath);
|
||||
}
|
||||
} else {
|
||||
try {
|
||||
|
|
Loading…
Reference in New Issue