forked from cwtch.im/cwtch-ui
Merge pull request 'fix filesharing on android' (#197) from filefix into trunk
Reviewed-on: cwtch.im/cwtch-ui#197 Reviewed-by: Sarah Jamie Lewis <sarah@openprivacy.ca>
This commit is contained in:
commit
10197dc300
|
@ -56,6 +56,7 @@ class MainActivity: FlutterActivity() {
|
||||||
private var shutdownClickChannel: MethodChannel? = null
|
private var shutdownClickChannel: MethodChannel? = null
|
||||||
|
|
||||||
// "Download to..." prompt extra arguments
|
// "Download to..." prompt extra arguments
|
||||||
|
private val FILEPICKER_REQUEST_CODE = 234
|
||||||
private var dlToProfile = ""
|
private var dlToProfile = ""
|
||||||
private var dlToHandle = ""
|
private var dlToHandle = ""
|
||||||
private var dlToFileKey = ""
|
private var dlToFileKey = ""
|
||||||
|
@ -84,20 +85,24 @@ class MainActivity: FlutterActivity() {
|
||||||
|
|
||||||
// handles return values from the system file picker
|
// handles return values from the system file picker
|
||||||
override fun onActivityResult(requestCode: Int, result: Int, intent: Intent?) {
|
override fun onActivityResult(requestCode: Int, result: Int, intent: Intent?) {
|
||||||
|
super.onActivityResult(requestCode, result, intent);
|
||||||
|
|
||||||
if (intent == null || intent!!.getData() == null) {
|
if (intent == null || intent!!.getData() == null) {
|
||||||
Log.i("MainActivity:onActivityResult", "user canceled activity");
|
Log.i("MainActivity:onActivityResult", "user canceled activity");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
val filePath = intent!!.getData().toString();
|
if (requestCode == FILEPICKER_REQUEST_CODE) {
|
||||||
val manifestPath = StringBuilder().append(this.applicationContext.cacheDir).append("/").append(this.dlToFileKey).toString();
|
val filePath = intent!!.getData().toString();
|
||||||
handleCwtch(MethodCall("DownloadFile", mapOf(
|
val manifestPath = StringBuilder().append(this.applicationContext.cacheDir).append("/").append(this.dlToFileKey).toString();
|
||||||
"ProfileOnion" to this.dlToProfile,
|
handleCwtch(MethodCall("DownloadFile", mapOf(
|
||||||
"handle" to this.dlToHandle,
|
"ProfileOnion" to this.dlToProfile,
|
||||||
"filepath" to filePath,
|
"handle" to this.dlToHandle,
|
||||||
"manifestpath" to manifestPath,
|
"filepath" to filePath,
|
||||||
"filekey" to this.dlToFileKey
|
"manifestpath" to manifestPath,
|
||||||
)), ErrorLogResult(""));//placeholder; this Result is never actually invoked
|
"filekey" to this.dlToFileKey
|
||||||
|
)), ErrorLogResult(""));//placeholder; this Result is never actually invoked
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun configureFlutterEngine(@NonNull flutterEngine: FlutterEngine) {
|
override fun configureFlutterEngine(@NonNull flutterEngine: FlutterEngine) {
|
||||||
|
@ -167,7 +172,7 @@ class MainActivity: FlutterActivity() {
|
||||||
type = "application/octet-stream"
|
type = "application/octet-stream"
|
||||||
putExtra(Intent.EXTRA_TITLE, suggestedName)
|
putExtra(Intent.EXTRA_TITLE, suggestedName)
|
||||||
}
|
}
|
||||||
startActivityForResult(intent, 1)
|
startActivityForResult(intent, FILEPICKER_REQUEST_CODE)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -81,9 +81,10 @@ class _MessageViewState extends State<MessageView> {
|
||||||
return Card(child: Center(child: Text(AppLocalizations.of(context)!.addContactFirst)));
|
return Card(child: Center(child: Text(AppLocalizations.of(context)!.addContactFirst)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var showFileSharing = Provider.of<Settings>(context).isExperimentEnabled(FileSharingExperiment);
|
||||||
var appBarButtons = <Widget>[];
|
var appBarButtons = <Widget>[];
|
||||||
if (Provider.of<ContactInfoState>(context).isOnline()) {
|
if (Provider.of<ContactInfoState>(context).isOnline()) {
|
||||||
if (Platform.isAndroid == false) {
|
if (showFileSharing) {
|
||||||
appBarButtons.add(IconButton(
|
appBarButtons.add(IconButton(
|
||||||
icon: Icon(Icons.attach_file, size: 24),
|
icon: Icon(Icons.attach_file, size: 24),
|
||||||
tooltip: AppLocalizations.of(context)!.tooltipSendFile,
|
tooltip: AppLocalizations.of(context)!.tooltipSendFile,
|
||||||
|
|
|
@ -21,7 +21,7 @@ packages:
|
||||||
name: async
|
name: async
|
||||||
url: "https://pub.dartlang.org"
|
url: "https://pub.dartlang.org"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "2.8.1"
|
version: "2.8.2"
|
||||||
boolean_selector:
|
boolean_selector:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
|
@ -195,7 +195,7 @@ packages:
|
||||||
name: matcher
|
name: matcher
|
||||||
url: "https://pub.dartlang.org"
|
url: "https://pub.dartlang.org"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "0.12.10"
|
version: "0.12.11"
|
||||||
meta:
|
meta:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
|
@ -403,7 +403,7 @@ packages:
|
||||||
name: test_api
|
name: test_api
|
||||||
url: "https://pub.dartlang.org"
|
url: "https://pub.dartlang.org"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "0.4.2"
|
version: "0.4.3"
|
||||||
typed_data:
|
typed_data:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
|
|
Loading…
Reference in New Issue