Преглед на файлове

When starting the app, pass through extras included in the launch intent (#433)

Matt Davies преди 8 години
родител
ревизия
cc393b6cdf

+ 0
- 30
android/app/src/main/java/com/reactnativenavigation/controllers/DeepLinkHandler.java Целия файл

1
-package com.reactnativenavigation.controllers;
2
-
3
-import android.content.Intent;
4
-import android.net.Uri;
5
-
6
-import static android.content.Intent.ACTION_VIEW;
7
-
8
-public class DeepLinkHandler {
9
-    private static Uri deepLink;
10
-
11
-    static void saveDeepLinkData(Uri deepLink) {
12
-        DeepLinkHandler.deepLink = deepLink;
13
-    }
14
-
15
-    static boolean hasDeepLinkData() {
16
-        return deepLink != null;
17
-    }
18
-
19
-    static void setDeepLinkData(Intent intent) {
20
-        if (deepLink != null) {
21
-            intent.setData(deepLink);
22
-            intent.setAction(ACTION_VIEW);
23
-            clear();
24
-        }
25
-    }
26
-
27
-    private static void clear() {
28
-        deepLink = null;
29
-    }
30
-}

+ 30
- 0
android/app/src/main/java/com/reactnativenavigation/controllers/IntentDataHandler.java Целия файл

1
+package com.reactnativenavigation.controllers;
2
+
3
+import android.content.Intent;
4
+
5
+import static android.content.Intent.ACTION_VIEW;
6
+
7
+public class IntentDataHandler {
8
+    private static Intent intent;
9
+
10
+    static void saveIntentData(Intent intent) {
11
+        IntentDataHandler.intent = intent;
12
+    }
13
+
14
+    static boolean hasIntentData() {
15
+        return intent != null;
16
+    }
17
+
18
+    static void setIntentData(Intent intent) {
19
+        if (IntentDataHandler.intent != null) {
20
+            intent.setData(IntentDataHandler.intent.getData());
21
+            intent.putExtras(IntentDataHandler.intent);
22
+            intent.setAction(ACTION_VIEW);
23
+            clear();
24
+        }
25
+    }
26
+
27
+    private static void clear() {
28
+        intent = null;
29
+    }
30
+}

+ 2
- 2
android/app/src/main/java/com/reactnativenavigation/controllers/NavigationActivity.java Целия файл

95
     }
95
     }
96
 
96
 
97
     private void setDeepLinkData() {
97
     private void setDeepLinkData() {
98
-        if (DeepLinkHandler.hasDeepLinkData()) {
99
-            DeepLinkHandler.setDeepLinkData(getIntent());
98
+        if (IntentDataHandler.hasIntentData()) {
99
+            IntentDataHandler.setIntentData(getIntent());
100
         }
100
         }
101
     }
101
     }
102
 
102
 

+ 1
- 1
android/app/src/main/java/com/reactnativenavigation/controllers/NavigationCommandsHandler.java Целия файл

36
         } else {
36
         } else {
37
             intent = new Intent(NavigationApplication.instance, NavigationActivity.class);
37
             intent = new Intent(NavigationApplication.instance, NavigationActivity.class);
38
         }
38
         }
39
-        DeepLinkHandler.setDeepLinkData(intent);
39
+        IntentDataHandler.setIntentData(intent);
40
         intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK | Intent.FLAG_ACTIVITY_NEW_TASK);
40
         intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK | Intent.FLAG_ACTIVITY_NEW_TASK);
41
         intent.putExtra(ACTIVITY_PARAMS_BUNDLE, params);
41
         intent.putExtra(ACTIVITY_PARAMS_BUNDLE, params);
42
         NavigationApplication.instance.startActivity(intent);
42
         NavigationApplication.instance.startActivity(intent);

+ 1
- 1
android/app/src/main/java/com/reactnativenavigation/controllers/SplashActivity.java Целия файл

16
     protected void onCreate(@Nullable Bundle savedInstanceState) {
16
     protected void onCreate(@Nullable Bundle savedInstanceState) {
17
         super.onCreate(savedInstanceState);
17
         super.onCreate(savedInstanceState);
18
         setSplashLayout();
18
         setSplashLayout();
19
-        DeepLinkHandler.saveDeepLinkData(getIntent().getData());
19
+        IntentDataHandler.saveIntentData(getIntent());
20
     }
20
     }
21
 
21
 
22
     @Override
22
     @Override