Merge pull request 'Fix Android File Sharing' (#600) from newjson into trunk
continuous-integration/drone/push Build is passing
Details
continuous-integration/drone/push Build is passing
Details
Reviewed-on: #600
This commit is contained in:
commit
abec0f3ad5
|
@ -1 +1 @@
|
||||||
2022-12-11-12-38-v1.10.1-2-g1e4221c
|
2022-12-12-22-59-v1.10.1-3-g3d0a3a5
|
|
@ -1 +1 @@
|
||||||
2022-12-11-17-40-v1.10.1-2-g1e4221c
|
2022-12-12-22-59-v1.10.1-3-g3d0a3a5
|
|
@ -68,7 +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 dlToHandle = ""
|
private var dlToHandle = 0
|
||||||
private var dlToFileKey = ""
|
private var dlToFileKey = ""
|
||||||
private var exportFromPath = ""
|
private var exportFromPath = ""
|
||||||
|
|
||||||
|
@ -128,9 +128,10 @@ 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();
|
val manifestPath = StringBuilder().append(this.applicationContext.cacheDir).append("/").append(this.dlToFileKey).toString();
|
||||||
|
Log.d("MainActivity:FILEPICKER_REQUEST_CODE", "DownloadableFileCreated");
|
||||||
handleCwtch(MethodCall("DownloadFile", mapOf(
|
handleCwtch(MethodCall("DownloadFile", mapOf(
|
||||||
"ProfileOnion" to this.dlToProfile,
|
"ProfileOnion" to this.dlToProfile,
|
||||||
"handle" to this.dlToHandle,
|
"conversation" to this.dlToHandle.toInt(),
|
||||||
"filepath" to filePath,
|
"filepath" to filePath,
|
||||||
"manifestpath" to manifestPath,
|
"manifestpath" to manifestPath,
|
||||||
"filekey" to this.dlToFileKey
|
"filekey" to this.dlToFileKey
|
||||||
|
@ -228,7 +229,7 @@ class MainActivity: FlutterActivity() {
|
||||||
var method = call.method
|
var method = call.method
|
||||||
// todo change usage patern to match that in FlwtchWorker
|
// 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
|
// 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()
|
// 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
|
// 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" -> {
|
"CreateDownloadableFile" -> {
|
||||||
this.dlToProfile = argmap["ProfileOnion"] ?: ""
|
this.dlToProfile = argmap["ProfileOnion"] ?: ""
|
||||||
this.dlToHandle = argmap["handle"] ?: ""
|
this.dlToHandle = call.argument("conversation")!!
|
||||||
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 {
|
||||||
|
@ -427,6 +428,7 @@ class MainActivity: FlutterActivity() {
|
||||||
}
|
}
|
||||||
|
|
||||||
"DownloadFile" -> {
|
"DownloadFile" -> {
|
||||||
|
Log.d("MainActivity.kt", "Cwtch Download File Called...")
|
||||||
val profile: String = call.argument("ProfileOnion") ?: ""
|
val profile: String = call.argument("ProfileOnion") ?: ""
|
||||||
val conversation: Int = call.argument("conversation") ?: 0
|
val conversation: Int = call.argument("conversation") ?: 0
|
||||||
val filepath: String = call.argument("filepath") ?: ""
|
val filepath: String = call.argument("filepath") ?: ""
|
||||||
|
|
|
@ -251,7 +251,7 @@ class FileBubbleState extends State<FileBubble> {
|
||||||
if (Platform.isAndroid) {
|
if (Platform.isAndroid) {
|
||||||
Provider.of<ProfileInfoState>(context, listen: false).downloadInit(widget.fileKey(), (widget.fileSize / 4096).ceil());
|
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");
|
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) {
|
if (contact != null) {
|
||||||
Provider.of<FlwtchState>(context, listen: false).cwtch.CreateDownloadableFile(profileOnion, contact.identifier, widget.nameSuggestion, widget.fileKey());
|
Provider.of<FlwtchState>(context, listen: false).cwtch.CreateDownloadableFile(profileOnion, contact.identifier, widget.nameSuggestion, widget.fileKey());
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue