Browse Source

Add isRootLaunched implementation on Android

returns true if NavigationActivity is resumed (startApp was called)
Guy Carmeli 7 years ago
parent
commit
6f4aca32a6

+ 5
- 0
android/app/src/main/java/com/reactnativenavigation/bridge/NavigationReactModule.java View File

264
         NavigationCommandsHandler.isAppLaunched(promise);
264
         NavigationCommandsHandler.isAppLaunched(promise);
265
     }
265
     }
266
 
266
 
267
+    @ReactMethod
268
+    public void isRootLaunched(Promise promise) {
269
+        NavigationCommandsHandler.isRootLaunched(promise);
270
+    }
271
+
267
     @ReactMethod
272
     @ReactMethod
268
     public void getCurrentlyVisibleScreenId(Promise promise) {
273
     public void getCurrentlyVisibleScreenId(Promise promise) {
269
         NavigationCommandsHandler.getCurrentlyVisibleScreenId(promise);
274
         NavigationCommandsHandler.getCurrentlyVisibleScreenId(promise);

+ 4
- 0
android/app/src/main/java/com/reactnativenavigation/controllers/NavigationCommandsHandler.java View File

543
         promise.resolve(isAppLaunched);
543
         promise.resolve(isAppLaunched);
544
     }
544
     }
545
 
545
 
546
+    public static void isRootLaunched(Promise promise) {
547
+        promise.resolve(NavigationActivity.currentActivity != null);
548
+    }
549
+
546
     public static void getCurrentlyVisibleScreenId(final Promise promise) {
550
     public static void getCurrentlyVisibleScreenId(final Promise promise) {
547
         final NavigationActivity currentActivity = NavigationActivity.currentActivity;
551
         final NavigationActivity currentActivity = NavigationActivity.currentActivity;
548
         if (currentActivity == null) {
552
         if (currentActivity == null) {

+ 6
- 1
src/Navigation.js View File

166
   return await platformSpecific.isAppLaunched();
166
   return await platformSpecific.isAppLaunched();
167
 }
167
 }
168
 
168
 
169
+async function isRootLaunched() {
170
+  return await platformSpecific.isRootLaunched();
171
+}
172
+
169
 function getCurrentlyVisibleScreenId() {
173
 function getCurrentlyVisibleScreenId() {
170
   return platformSpecific.getCurrentlyVisibleScreenId();
174
   return platformSpecific.getCurrentlyVisibleScreenId();
171
 }
175
 }
187
   setEventHandler: setEventHandler,
191
   setEventHandler: setEventHandler,
188
   clearEventHandler: clearEventHandler,
192
   clearEventHandler: clearEventHandler,
189
   handleDeepLink: handleDeepLink,
193
   handleDeepLink: handleDeepLink,
190
-  isAppLaunched: isAppLaunched
194
+  isAppLaunched: isAppLaunched,
195
+  isRootLaunched: isRootLaunched
191
 };
196
 };

+ 5
- 0
src/deprecated/platformSpecificDeprecated.android.js View File

689
   return await newPlatformSpecific.isAppLaunched();
689
   return await newPlatformSpecific.isAppLaunched();
690
 }
690
 }
691
 
691
 
692
+async function isRootLaunched() {
693
+  return await newPlatformSpecific.isRootLaunched();
694
+}
695
+
692
 async function getCurrentlyVisibleScreenId() {
696
 async function getCurrentlyVisibleScreenId() {
693
   return await newPlatformSpecific.getCurrentlyVisibleScreenId();
697
   return await newPlatformSpecific.getCurrentlyVisibleScreenId();
694
 }
698
 }
724
   showContextualMenu,
728
   showContextualMenu,
725
   dismissContextualMenu,
729
   dismissContextualMenu,
726
   isAppLaunched,
730
   isAppLaunched,
731
+  isRootLaunched,
727
   getCurrentlyVisibleScreenId
732
   getCurrentlyVisibleScreenId
728
 };
733
 };

+ 5
- 0
src/platformSpecific.android.js View File

181
   return await NativeReactModule.isAppLaunched();
181
   return await NativeReactModule.isAppLaunched();
182
 }
182
 }
183
 
183
 
184
+async function isRootLaunched() {
185
+  return await NativeReactModule.isRootLaunched();
186
+}
187
+
184
 async function getCurrentlyVisibleScreenId() {
188
 async function getCurrentlyVisibleScreenId() {
185
   return await NativeReactModule.getCurrentlyVisibleScreenId();
189
   return await NativeReactModule.getCurrentlyVisibleScreenId();
186
 }
190
 }
220
   dismissContextualMenu,
224
   dismissContextualMenu,
221
   setScreenStyle,
225
   setScreenStyle,
222
   isAppLaunched,
226
   isAppLaunched,
227
+  isRootLaunched,
223
   getCurrentlyVisibleScreenId
228
   getCurrentlyVisibleScreenId
224
 };
229
 };