Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion android/app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
<action android:name="android.intent.action.SEND" />
<category android:name="android.intent.category.DEFAULT" />
<data android:mimeType="*/*" />
<data android:pathPattern=".*\\.(invoice|receipt|commit|friend|relay|index)" />
<data android:pathPattern=".*\\.(invoice|receipt|commit|friend|relay|index|rcard)" />
</intent-filter>
</activity>
<!-- Don't delete the meta-data below.
Expand Down
8 changes: 6 additions & 2 deletions lib/logic/handle_shared_file.dart
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,12 @@ final logger = createLogger('logic::handle_shared_file');
AppState handleSharedFile(AppState appState, String filePath) {
// Are we in a state that may be interrupted? If not, return early.
AppView oldAppView;
final interruptible = appState.viewState
.match(view: (appView) => true, transition: (_a, _b, _c, _d) => false);
final interruptible = appState.viewState.match(
view: (appView) {
oldAppView = appView;
return true;
},
transition: (_a, _b, _c, _d) => false);

if (!interruptible) {
return appState;
Expand Down
26 changes: 15 additions & 11 deletions lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import 'dart:math';
import 'package:logger/logger.dart';

import 'package:built_collection/built_collection.dart';
import 'package:receive_file_intent/receive_file_intent.dart';
import 'package:receive_sharing_intent/receive_sharing_intent.dart';

import 'dart:convert';
import 'dart:async';
Expand Down Expand Up @@ -153,38 +153,42 @@ class MainAppState extends State<MainApp> {
}));

// Handle shared files:
final handleSharedFiles = (List<String> filePaths) {
if (filePaths == null) {
logger.w('handleSharedFiles(): Received null filePaths. Aborting');
final handleSharedFiles = (List<SharedMediaFile> sharedMediaFiles) {
if (sharedMediaFiles == null) {
logger.i('handleSharedFiles(): Received null filePaths. Aborting');
return;
}
if (filePaths.isEmpty) {
if (sharedMediaFiles.isEmpty) {
logger.w('handleSharedFiles(): Received empty shared filePaths!');
return;
}
if (filePaths.length > 1) {
if (sharedMediaFiles.length > 1) {
logger.w(
'handleSharedFiles(): Received more than one file path! Aborting.');
return;
}
// We received exactly one filePath:
final filePath = filePaths[0];
final filePath = sharedMediaFiles[0].path;
logger.w(
'handleSharedFiles(): fileType = ${sharedMediaFiles[0].type}');
logger.w(
'handleSharedFiles(): filePath = $filePath');
// Queue shared file event:
_eventController.add(AppEvent.sharedFile(filePath));
};

// Listen to incoming shared files:
// For sharing files coming from outside the app while the app is in the memory
_streamSubs
.add(ReceiveFileIntent.getFileStream().listen((List<String> filePaths) {
handleSharedFiles(filePaths);
.add(ReceiveSharingIntent.getMediaStream().listen((List<SharedMediaFile> sharedMediaFiles) {
handleSharedFiles(sharedMediaFiles);
}, onError: (err) {
throw MainAppError('getIntentDataStreamError: $err');
}));

// For sharing files coming from outside the app while the app is closed
ReceiveFileIntent.getInitialFile().then((List<String> filePaths) {
handleSharedFiles(filePaths);
ReceiveSharingIntent.getInitialMedia().then((List<SharedMediaFile> sharedMediaFiles) {
handleSharedFiles(sharedMediaFiles);
});

final sendUserToServerAck = (UserToServerAck userToServerAck) {
Expand Down
12 changes: 5 additions & 7 deletions pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -499,15 +499,13 @@ packages:
url: "https://pub.dartlang.org"
source: hosted
version: "2.0.5"
receive_file_intent:
receive_sharing_intent:
dependency: "direct main"
description:
path: "."
ref: HEAD
resolved-ref: e8fb7c1e4e4016359fde36ebf12afec1d28510ed
url: "git://github.com/freedomlayer/receive_file_intent.git"
source: git
version: "1.2.0+1"
name: receive_sharing_intent
url: "https://pub.dartlang.org"
source: hosted
version: "1.4.0+2"
share_extend:
dependency: "direct main"
description:
Expand Down
8 changes: 4 additions & 4 deletions pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,10 @@ dependencies:
built_value: ^7.0.6
path: ^1.6.4
path_provider: ^1.4.0
# receive_sharing_intent: ^1.3.2
receive_file_intent:
git:
url: git://github.com/freedomlayer/receive_file_intent.git
receive_sharing_intent: ^1.4.0+2
# receive_file_intent:
# git:
# url: git://github.com/freedomlayer/receive_file_intent.git
file_picker: ^1.5.0+2
barcode_scan: ^2.0.1
qr_flutter: ^3.2.0
Expand Down