Merge pull request 'Update Cwtch. Make File Download Consistent on Android' (#641) from autobindings into trunk
continuous-integration/drone/push Build is passing Details

Reviewed-on: #641
Reviewed-by: Dan Ballard <dan@openprivacy.ca>
This commit is contained in:
Sarah Jamie Lewis 2023-03-17 17:38:45 +00:00
commit a2d36e62ff
7 changed files with 13 additions and 9 deletions

View File

@ -1 +1 @@
2023-03-14-11-33-v0.0.3
2023-03-16-15-07-v0.0.3-1-g50c853a

View File

@ -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,12 @@ 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");
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 +257,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 {

View File

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

View File

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

View File

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

View File

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

View File

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