|
@@ -1,7 +1,7 @@
|
1
|
1
|
package com.reactnativenavigation.react;
|
2
|
2
|
|
3
|
3
|
import android.annotation.TargetApi;
|
4
|
|
-import android.app.Application;
|
|
4
|
+import android.app.Activity;
|
5
|
5
|
import android.content.Intent;
|
6
|
6
|
import android.os.Build;
|
7
|
7
|
import android.provider.Settings;
|
|
@@ -12,31 +12,29 @@ import com.facebook.react.common.ReactConstants;
|
12
|
12
|
|
13
|
13
|
public class DevPermissionRequest {
|
14
|
14
|
|
15
|
|
- private final Application application;
|
16
|
15
|
private final boolean isDebug;
|
17
|
16
|
|
18
|
|
- public DevPermissionRequest(Application application, boolean isDebug) {
|
19
|
|
- this.application = application;
|
|
17
|
+ public DevPermissionRequest(boolean isDebug) {
|
20
|
18
|
this.isDebug = isDebug;
|
21
|
19
|
}
|
22
|
20
|
|
23
|
|
- public boolean shouldAskPermission() {
|
|
21
|
+ public boolean shouldAskPermission(Activity activity) {
|
24
|
22
|
return isDebug &&
|
25
|
23
|
Build.VERSION.SDK_INT >= 23 &&
|
26
|
|
- !Settings.canDrawOverlays(application);
|
|
24
|
+ !Settings.canDrawOverlays(activity);
|
27
|
25
|
}
|
28
|
26
|
|
29
|
27
|
@TargetApi(23)
|
30
|
|
- public void askPermission() {
|
31
|
|
- if (shouldAskPermission()) {
|
|
28
|
+ public void askPermission(Activity activity) {
|
|
29
|
+ if (shouldAskPermission(activity)) {
|
32
|
30
|
Intent serviceIntent = new Intent(Settings.ACTION_MANAGE_OVERLAY_PERMISSION);
|
33
|
31
|
serviceIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
34
|
|
- application.startActivity(serviceIntent);
|
|
32
|
+ activity.startActivity(serviceIntent);
|
35
|
33
|
String msg = "Overlay permissions needs to be granted in order for react native apps to run in dev mode";
|
36
|
34
|
Log.w(ReactConstants.TAG, "======================================\n\n");
|
37
|
35
|
Log.w(ReactConstants.TAG, msg);
|
38
|
36
|
Log.w(ReactConstants.TAG, "\n\n======================================");
|
39
|
|
- Toast.makeText(application, msg, Toast.LENGTH_LONG).show();
|
|
37
|
+ Toast.makeText(activity, msg, Toast.LENGTH_LONG).show();
|
40
|
38
|
}
|
41
|
39
|
}
|
42
|
40
|
}
|