Browse Source

android file sending bugfix

pull/197/head
erinn 3 weeks ago
parent
commit
74e25534c5
  1. 25
      android/app/src/main/kotlin/im/cwtch/flwtch/MainActivity.kt
  2. 13
      lib/views/messageview.dart
  3. 6
      pubspec.lock

25
android/app/src/main/kotlin/im/cwtch/flwtch/MainActivity.kt

@ -56,6 +56,7 @@ class MainActivity: FlutterActivity() {
private var shutdownClickChannel: MethodChannel? = null
// "Download to..." prompt extra arguments
private val FILEPICKER_REQUEST_CODE = 234
private var dlToProfile = ""
private var dlToHandle = ""
private var dlToFileKey = ""
@ -84,20 +85,24 @@ class MainActivity: FlutterActivity() {
// handles return values from the system file picker
override fun onActivityResult(requestCode: Int, result: Int, intent: Intent?) {
super.onActivityResult(requestCode, result, intent);
if (intent == null || intent!!.getData() == null) {
Log.i("MainActivity:onActivityResult", "user canceled activity");
return;
}
val filePath = intent!!.getData().toString();
val manifestPath = StringBuilder().append(this.applicationContext.cacheDir).append("/").append(this.dlToFileKey).toString();
handleCwtch(MethodCall("DownloadFile", mapOf(
"ProfileOnion" to this.dlToProfile,
"handle" to this.dlToHandle,
"filepath" to filePath,
"manifestpath" to manifestPath,
"filekey" to this.dlToFileKey
)), ErrorLogResult(""));//placeholder; this Result is never actually invoked
if (requestCode == FILEPICKER_REQUEST_CODE) {
val filePath = intent!!.getData().toString();
val manifestPath = StringBuilder().append(this.applicationContext.cacheDir).append("/").append(this.dlToFileKey).toString();
handleCwtch(MethodCall("DownloadFile", mapOf(
"ProfileOnion" to this.dlToProfile,
"handle" to this.dlToHandle,
"filepath" to filePath,
"manifestpath" to manifestPath,
"filekey" to this.dlToFileKey
)), ErrorLogResult(""));//placeholder; this Result is never actually invoked
}
}
override fun configureFlutterEngine(@NonNull flutterEngine: FlutterEngine) {
@ -167,7 +172,7 @@ class MainActivity: FlutterActivity() {
type = "application/octet-stream"
putExtra(Intent.EXTRA_TITLE, suggestedName)
}
startActivityForResult(intent, 1)
startActivityForResult(intent, FILEPICKER_REQUEST_CODE)
return
}

13
lib/views/messageview.dart

@ -81,13 +81,16 @@ class _MessageViewState extends State<MessageView> {
return Card(child: Center(child: Text(AppLocalizations.of(context)!.addContactFirst)));
}
var showFileSharing = Provider.of<Settings>(context).isExperimentEnabled(FileSharingExperiment);
var appBarButtons = <Widget>[];
if (Provider.of<ContactInfoState>(context).isOnline()) {
appBarButtons.add(IconButton(
icon: Icon(Icons.attach_file, size: 24),
tooltip: AppLocalizations.of(context)!.tooltipSendFile,
onPressed: _showFilePicker,
));
if (showFileSharing) {
appBarButtons.add(IconButton(
icon: Icon(Icons.attach_file, size: 24),
tooltip: AppLocalizations.of(context)!.tooltipSendFile,
onPressed: _showFilePicker,
));
}
appBarButtons.add(IconButton(
icon: Icon(CwtchIcons.send_invite, size: 24),
tooltip: AppLocalizations.of(context)!.sendInvite,

6
pubspec.lock

@ -21,7 +21,7 @@ packages:
name: async
url: "https://pub.dartlang.org"
source: hosted
version: "2.8.1"
version: "2.8.2"
boolean_selector:
dependency: transitive
description:
@ -195,7 +195,7 @@ packages:
name: matcher
url: "https://pub.dartlang.org"
source: hosted
version: "0.12.10"
version: "0.12.11"
meta:
dependency: transitive
description:
@ -403,7 +403,7 @@ packages:
name: test_api
url: "https://pub.dartlang.org"
source: hosted
version: "0.4.2"
version: "0.4.3"
typed_data:
dependency: transitive
description:

Loading…
Cancel
Save