Fix Android File Sharing
continuous-integration/drone/pr Build is running Details

This commit is contained in:
Sarah Jamie Lewis 2022-12-12 15:10:07 -08:00
parent c8bdc56507
commit 28ce08637b
4 changed files with 9 additions and 7 deletions

View File

@ -1 +1 @@
2022-12-11-12-38-v1.10.1-2-g1e4221c
2022-12-12-22-59-v1.10.1-3-g3d0a3a5

View File

@ -1 +1 @@
2022-12-11-17-40-v1.10.1-2-g1e4221c
2022-12-12-22-59-v1.10.1-3-g3d0a3a5

View File

@ -68,7 +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 dlToHandle = ""
private var dlToHandle = 0
private var dlToFileKey = ""
private var exportFromPath = ""
@ -128,9 +128,10 @@ 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,
"handle" to this.dlToHandle,
"conversation" to this.dlToHandle.toInt(),
"filepath" to filePath,
"manifestpath" to manifestPath,
"filekey" to this.dlToFileKey
@ -228,7 +229,7 @@ class MainActivity: FlutterActivity() {
var method = call.method
// todo change usage patern to match that in FlwtchWorker
// Unsafe for anything using int args, causes access time attempt to cast to string which will fail
val argmap: Map<String, String> = call.arguments as Map<String, String>
val argmap: Map<String, String> = call.arguments as Map<String,String>
// the frontend calls Start every time it fires up, but we don't want to *actually* call Cwtch.Start()
// in case the ForegroundService is still running. in both cases, however, we *do* want to re-register
@ -255,7 +256,7 @@ class MainActivity: FlutterActivity() {
}
"CreateDownloadableFile" -> {
this.dlToProfile = argmap["ProfileOnion"] ?: ""
this.dlToHandle = argmap["handle"] ?: ""
this.dlToHandle = call.argument("conversation")!!
val suggestedName = argmap["filename"] ?: "filename.ext"
this.dlToFileKey = argmap["filekey"] ?: ""
val intent = Intent(Intent.ACTION_CREATE_DOCUMENT).apply {
@ -427,6 +428,7 @@ class MainActivity: FlutterActivity() {
}
"DownloadFile" -> {
Log.d("MainActivity.kt", "Cwtch Download File Called...")
val profile: String = call.argument("ProfileOnion") ?: ""
val conversation: Int = call.argument("conversation") ?: 0
val filepath: String = call.argument("filepath") ?: ""

View File

@ -251,7 +251,7 @@ class FileBubbleState extends State<FileBubble> {
if (Platform.isAndroid) {
Provider.of<ProfileInfoState>(context, listen: false).downloadInit(widget.fileKey(), (widget.fileSize / 4096).ceil());
Provider.of<FlwtchState>(context, listen: false).cwtch.SetMessageAttribute(profileOnion, conversation, 0, idx, "file-downloaded", "true");
ContactInfoState? contact = Provider.of<ProfileInfoState>(context).contactList.findContact(Provider.of<MessageMetadata>(context).senderHandle);
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());
}