|
@@ -1,7 +1,11 @@
|
1
|
1
|
package com.reactnativenavigation;
|
2
|
2
|
|
|
3
|
+import android.annotation.TargetApi;
|
|
4
|
+import android.support.annotation.NonNull;
|
|
5
|
+
|
3
|
6
|
import android.content.Intent;
|
4
|
7
|
import android.os.Bundle;
|
|
8
|
+import android.os.Build;
|
5
|
9
|
import android.support.annotation.Nullable;
|
6
|
10
|
import android.support.v7.app.AppCompatActivity;
|
7
|
11
|
import android.view.KeyEvent;
|
|
@@ -14,7 +18,13 @@ import com.reactnativenavigation.utils.CommandListenerAdapter;
|
14
|
18
|
import com.reactnativenavigation.viewcontrollers.ChildControllersRegistry;
|
15
|
19
|
import com.reactnativenavigation.viewcontrollers.Navigator;
|
16
|
20
|
|
17
|
|
-public class NavigationActivity extends AppCompatActivity implements DefaultHardwareBackBtnHandler {
|
|
21
|
+import com.facebook.react.modules.core.PermissionAwareActivity;
|
|
22
|
+import com.facebook.react.modules.core.PermissionListener;
|
|
23
|
+
|
|
24
|
+public class NavigationActivity extends AppCompatActivity implements DefaultHardwareBackBtnHandler, PermissionAwareActivity {
|
|
25
|
+ @Nullable
|
|
26
|
+ private PermissionListener mPermissionListener;
|
|
27
|
+
|
18
|
28
|
protected Navigator navigator;
|
19
|
29
|
|
20
|
30
|
@Override
|
|
@@ -81,4 +91,18 @@ public class NavigationActivity extends AppCompatActivity implements DefaultHard
|
81
|
91
|
public Navigator getNavigator() {
|
82
|
92
|
return navigator;
|
83
|
93
|
}
|
|
94
|
+
|
|
95
|
+ @TargetApi(Build.VERSION_CODES.M)
|
|
96
|
+ public void requestPermissions(String[] permissions, int requestCode, PermissionListener listener) {
|
|
97
|
+ mPermissionListener = listener;
|
|
98
|
+ requestPermissions(permissions, requestCode);
|
|
99
|
+ }
|
|
100
|
+
|
|
101
|
+ @Override
|
|
102
|
+ public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) {
|
|
103
|
+ NavigationApplication.instance.onRequestPermissionsResult(requestCode, permissions, grantResults);
|
|
104
|
+ if (mPermissionListener != null && mPermissionListener.onRequestPermissionsResult(requestCode, permissions, grantResults)) {
|
|
105
|
+ mPermissionListener = null;
|
|
106
|
+ }
|
|
107
|
+ }
|
84
|
108
|
}
|