|
@@ -2,23 +2,18 @@ package com.reactnativenavigation.controllers;
|
2
|
2
|
|
3
|
3
|
import android.app.Activity;
|
4
|
4
|
import android.content.Intent;
|
5
|
|
-import android.os.Build;
|
6
|
5
|
import android.os.Bundle;
|
7
|
|
-import android.provider.Settings;
|
8
|
6
|
import android.support.v7.app.AppCompatActivity;
|
9
|
|
-import android.util.Log;
|
10
|
7
|
import android.view.KeyEvent;
|
11
|
|
-import android.widget.Toast;
|
12
|
8
|
|
13
|
9
|
import com.facebook.react.ReactPackage;
|
14
|
|
-import com.facebook.react.common.ReactConstants;
|
15
|
10
|
import com.facebook.react.modules.core.DefaultHardwareBackBtnHandler;
|
16
|
11
|
import com.facebook.react.shell.MainReactPackage;
|
17
|
|
-import com.reactnativenavigation.BuildConfig;
|
18
|
12
|
import com.reactnativenavigation.bridge.NavigationReactPackage;
|
19
|
|
-import com.reactnativenavigation.controllers.ModalController;
|
|
13
|
+import com.reactnativenavigation.layouts.Layout;
|
20
|
14
|
import com.reactnativenavigation.react.JsDevReloadHandler;
|
21
|
15
|
import com.reactnativenavigation.react.NavigationReactInstance;
|
|
16
|
+import com.reactnativenavigation.react.RedboxPermission;
|
22
|
17
|
|
23
|
18
|
import java.util.Arrays;
|
24
|
19
|
import java.util.List;
|
|
@@ -26,7 +21,6 @@ import java.util.List;
|
26
|
21
|
|
27
|
22
|
public class NavigationActivity extends AppCompatActivity implements NavigationReactInstance.ReactContextCreator, DefaultHardwareBackBtnHandler {
|
28
|
23
|
|
29
|
|
- private NavigationReactInstance navigationReactInstance;
|
30
|
24
|
/**
|
31
|
25
|
* Although we start multiple activities, we make sure to pass Intent.CLEAR_TASK | Intent.NEW_TASK
|
32
|
26
|
* So that we actually have only 1 instance of the activity running at one time.
|
|
@@ -34,8 +28,9 @@ public class NavigationActivity extends AppCompatActivity implements NavigationR
|
34
|
28
|
* This is somewhat weird, and in the future either fully support multiple activities, OR a single activity with changing contentView ala ReactNative impl.
|
35
|
29
|
*/
|
36
|
30
|
private static Activity currentActivity;
|
|
31
|
+ private NavigationReactInstance navigationReactInstance;
|
37
|
32
|
private ModalController modalController;
|
38
|
|
-
|
|
33
|
+ private Layout layout;
|
39
|
34
|
|
40
|
35
|
@Override
|
41
|
36
|
protected void onCreate(Bundle savedInstanceState) {
|
|
@@ -43,7 +38,7 @@ public class NavigationActivity extends AppCompatActivity implements NavigationR
|
43
|
38
|
modalController = new ModalController();
|
44
|
39
|
navigationReactInstance = new NavigationReactInstance(this);
|
45
|
40
|
navigationReactInstance.startReactContextOnceInBackgroundAndExecuteJS();
|
46
|
|
- permissionToShowRedboxIfNeeded();
|
|
41
|
+ RedboxPermission.permissionToShowRedboxIfNeeded(this);
|
47
|
42
|
}
|
48
|
43
|
|
49
|
44
|
@Override
|
|
@@ -70,15 +65,6 @@ public class NavigationActivity extends AppCompatActivity implements NavigationR
|
70
|
65
|
}
|
71
|
66
|
}
|
72
|
67
|
|
73
|
|
- private void permissionToShowRedboxIfNeeded() {
|
74
|
|
- if (BuildConfig.DEBUG && Build.VERSION.SDK_INT >= 23 && !Settings.canDrawOverlays(this)) {
|
75
|
|
- Intent serviceIntent = new Intent(Settings.ACTION_MANAGE_OVERLAY_PERMISSION);
|
76
|
|
- startActivity(serviceIntent);
|
77
|
|
- String msg = "Overlay permissions needs to be granted in order for react native apps to run in dev mode";
|
78
|
|
- Log.w(ReactConstants.TAG, msg);
|
79
|
|
- Toast.makeText(this, msg, Toast.LENGTH_LONG).show();
|
80
|
|
- }
|
81
|
|
- }
|
82
|
68
|
|
83
|
69
|
private NavigationReactInstance getNavigationReactInstance() {
|
84
|
70
|
return navigationReactInstance;
|
|
@@ -102,7 +88,6 @@ public class NavigationActivity extends AppCompatActivity implements NavigationR
|
102
|
88
|
super.onBackPressed();
|
103
|
89
|
}
|
104
|
90
|
|
105
|
|
-
|
106
|
91
|
@Override
|
107
|
92
|
public void onBackPressed() {
|
108
|
93
|
if (modalController.onBackPressed()) {
|