forked from cwtch.im/cwtch-ui
Merge pull request 'Update Cwtch. Make File Download Consistent on Android' (#641) from autobindings into trunk
Reviewed-on: cwtch.im/cwtch-ui#641 Reviewed-by: Dan Ballard <dan@openprivacy.ca>
This commit is contained in:
commit
a2d36e62ff
|
@ -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 PROFILE_EXPORT_REQUEST_CODE = 236
|
||||||
private val REQUEST_DOZE_WHITELISTING_CODE:Int = 9
|
private val REQUEST_DOZE_WHITELISTING_CODE:Int = 9
|
||||||
private var dlToProfile = ""
|
private var dlToProfile = ""
|
||||||
|
private var dlManifestPath = ""
|
||||||
private var dlToHandle = 0
|
private var dlToHandle = 0
|
||||||
private var dlToFileKey = ""
|
private var dlToFileKey = ""
|
||||||
private var exportFromPath = ""
|
private var exportFromPath = ""
|
||||||
|
@ -127,13 +128,12 @@ class MainActivity: FlutterActivity() {
|
||||||
|
|
||||||
if (requestCode == FILEPICKER_REQUEST_CODE) {
|
if (requestCode == FILEPICKER_REQUEST_CODE) {
|
||||||
val filePath = intent!!.getData().toString();
|
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", "DownloadableFileCreated");
|
||||||
handleCwtch(MethodCall("DownloadFile", mapOf(
|
handleCwtch(MethodCall("DownloadFile", mapOf(
|
||||||
"ProfileOnion" to this.dlToProfile,
|
"ProfileOnion" to this.dlToProfile,
|
||||||
"conversation" to this.dlToHandle.toInt(),
|
"conversation" to this.dlToHandle.toInt(),
|
||||||
"filepath" to filePath,
|
"filepath" to filePath,
|
||||||
"manifestpath" to manifestPath,
|
"manifestpath" to this.dlManifestPath,
|
||||||
"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) {
|
} else if (requestCode == PREVIEW_EXPORT_REQUEST_CODE) {
|
||||||
|
@ -257,6 +257,7 @@ class MainActivity: FlutterActivity() {
|
||||||
"CreateDownloadableFile" -> {
|
"CreateDownloadableFile" -> {
|
||||||
this.dlToProfile = argmap["ProfileOnion"] ?: ""
|
this.dlToProfile = argmap["ProfileOnion"] ?: ""
|
||||||
this.dlToHandle = call.argument("conversation")!!
|
this.dlToHandle = call.argument("conversation")!!
|
||||||
|
this.dlManifestPath = argmap["manifestpath"] ?: ""
|
||||||
val suggestedName = argmap["filename"] ?: "filename.ext"
|
val suggestedName = argmap["filename"] ?: "filename.ext"
|
||||||
this.dlToFileKey = argmap["filekey"] ?: ""
|
this.dlToFileKey = argmap["filekey"] ?: ""
|
||||||
val intent = Intent(Intent.ACTION_CREATE_DOCUMENT).apply {
|
val intent = Intent(Intent.ACTION_CREATE_DOCUMENT).apply {
|
||||||
|
|
|
@ -74,7 +74,7 @@ abstract class Cwtch {
|
||||||
void DownloadFile(String profile, int handle, String filepath, String manifestpath, String filekey);
|
void DownloadFile(String profile, int handle, String filepath, String manifestpath, String filekey);
|
||||||
// android-only
|
// android-only
|
||||||
// ignore: non_constant_identifier_names
|
// 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
|
// ignore: non_constant_identifier_names
|
||||||
void CheckDownloadStatus(String profile, String fileKey);
|
void CheckDownloadStatus(String profile, String fileKey);
|
||||||
// ignore: non_constant_identifier_names
|
// ignore: non_constant_identifier_names
|
||||||
|
|
|
@ -70,7 +70,7 @@ class CwtchNotifier {
|
||||||
if (data["Online"] == null) {
|
if (data["Online"] == null) {
|
||||||
break;
|
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...
|
// 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",
|
profileCN.add(data["Identity"], data["name"], data["picture"], data["defaultPicture"], data["ContactsJson"], data["ServerList"], data["Online"] == "true", data["autostart"] == "true",
|
||||||
data["tag"] != "v1-defaultPassword");
|
data["tag"] != "v1-defaultPassword");
|
||||||
|
|
|
@ -460,7 +460,7 @@ class CwtchFfi implements Cwtch {
|
||||||
|
|
||||||
@override
|
@override
|
||||||
// ignore: non_constant_identifier_names
|
// 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
|
// android only - do nothing
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -168,8 +168,9 @@ class CwtchGomobile implements Cwtch {
|
||||||
}
|
}
|
||||||
|
|
||||||
// ignore: non_constant_identifier_names
|
// ignore: non_constant_identifier_names
|
||||||
void CreateDownloadableFile(String profileOnion, int conversation, String filenameSuggestion, String filekey) {
|
void CreateDownloadableFile(String profileOnion, int conversation, String filenameSuggestion, String filekey, String manifestpath) {
|
||||||
cwtchPlatform.invokeMethod("CreateDownloadableFile", {"ProfileOnion": profileOnion, "conversation": conversation, "filename": filenameSuggestion, "filekey": filekey});
|
cwtchPlatform
|
||||||
|
.invokeMethod("CreateDownloadableFile", {"ProfileOnion": profileOnion, "conversation": conversation, "manifestpath": manifestpath, "filename": filenameSuggestion, "filekey": filekey});
|
||||||
}
|
}
|
||||||
|
|
||||||
// ignore: non_constant_identifier_names
|
// 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");
|
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);
|
ContactInfoState? contact = Provider.of<ProfileInfoState>(context, listen: false).contactList.findContact(Provider.of<MessageMetadata>(context, listen: false).senderHandle);
|
||||||
if (contact != null) {
|
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 {
|
} else {
|
||||||
try {
|
try {
|
||||||
|
|
Loading…
Reference in New Issue