diff --git a/android/app/src/main/AndroidManifest.xml b/android/app/src/main/AndroidManifest.xml
index d23cce259..42165b202 100644
--- a/android/app/src/main/AndroidManifest.xml
+++ b/android/app/src/main/AndroidManifest.xml
@@ -38,13 +38,6 @@
android:host="matrix.to"/>
-
-
-
-
-
-
-
diff --git a/lib/views/chat_list.dart b/lib/views/chat_list.dart
index ec7301271..b2581c17d 100644
--- a/lib/views/chat_list.dart
+++ b/lib/views/chat_list.dart
@@ -13,8 +13,10 @@ import 'package:fluffychat/views/new_private_chat.dart';
import 'package:fluffychat/views/settings.dart';
import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
+import 'package:flutter/services.dart';
import 'package:flutter_speed_dial/flutter_speed_dial.dart';
-import 'package:receive_sharing_intent/receive_sharing_intent.dart';
+import 'package:toast/toast.dart';
+import 'package:uni_links/uni_links.dart';
enum SelectMode { normal, multi_select, share }
@@ -62,32 +64,31 @@ class _ChatListState extends State {
searchController.addListener(
() => setState(() => null),
);
- if (kIsWeb) {
- getSharedData();
- }
+ initUniLinks();
super.initState();
}
StreamSubscription _intentDataStreamSubscription;
- void processSharedText(String text) {
- if (text?.isEmpty ?? true) return;
- if (text.startsWith("https://matrix.to/#/")) {
- UrlLauncher(context, text).openMatrixToUrl();
- } else {
- setState(() => Matrix.of(context).shareContent = {
- "msgtype": "m.text",
- "body": text,
- });
- }
- }
+ StreamSubscription _onUniLinksub;
- void getSharedData() {
- // For sharing or opening urls/text coming from outside the app while the app is in the memory
- _intentDataStreamSubscription = ReceiveSharingIntent.getTextStream()
- .listen(processSharedText, onError: (err) {});
- // For sharing or opening urls/text coming from outside the app while the app is closed
- ReceiveSharingIntent.getInitialText().then(processSharedText);
+ Future initUniLinks() async {
+ if (kIsWeb) return;
+ _onUniLinksub ??= getLinksStream().listen(
+ (String initialLink) {
+ try {
+ if (initialLink?.isEmpty ?? true) return;
+ if (initialLink.startsWith("https://matrix.to/#/")) {
+ UrlLauncher(context, initialLink).openMatrixToUrl();
+ }
+ } on PlatformException {
+ debugPrint("initUniLinks failed during platform exception");
+ }
+ },
+ onError: (error) => Toast.show(
+ I18n.of(context).oopsSomethingWentWrong + " " + error.toString(), context,
+ duration: 5),
+ );
}
@override
@@ -97,6 +98,7 @@ class _ChatListState extends State {
() => setState(() => null),
);
_intentDataStreamSubscription?.cancel();
+ _onUniLinksub?.cancel();
super.dispose();
}
diff --git a/pubspec.lock b/pubspec.lock
index 0e043ffdc..8f32ee575 100644
--- a/pubspec.lock
+++ b/pubspec.lock
@@ -366,13 +366,6 @@ packages:
url: "https://pub.dartlang.org"
source: hosted
version: "2.0.5"
- receive_sharing_intent:
- dependency: "direct main"
- description:
- name: receive_sharing_intent
- url: "https://pub.dartlang.org"
- source: hosted
- version: "1.3.2"
share:
dependency: "direct main"
description:
@@ -455,6 +448,13 @@ packages:
url: "https://pub.dartlang.org"
source: hosted
version: "1.1.6"
+ uni_links:
+ dependency: "direct main"
+ description:
+ name: uni_links
+ url: "https://pub.dartlang.org"
+ source: hosted
+ version: "0.2.0"
universal_html:
dependency: "direct main"
description:
diff --git a/pubspec.yaml b/pubspec.yaml
index f167e6799..abd65dd48 100644
--- a/pubspec.yaml
+++ b/pubspec.yaml
@@ -45,10 +45,10 @@ dependencies:
path_provider: ^1.5.1
webview_flutter: ^0.3.19+4
share: ^0.6.3+5
- receive_sharing_intent: ^1.3.2
flutter_secure_storage: ^3.3.1+1
http: ^0.12.0+4
universal_html: ^1.1.12
+ uni_links: ^0.2.0
intl: ^0.16.0
intl_translation: ^0.17.9