@exodus/react-native-screenshot-detector 1.2.2 → 1.2.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
|
|
2
2
|
package com.reactlibrary;
|
|
3
3
|
|
|
4
|
+
import android.app.Activity;
|
|
4
5
|
import android.view.Window;
|
|
5
6
|
import android.view.WindowManager;
|
|
6
7
|
|
|
@@ -25,25 +26,38 @@ public class RNScreenshotDetectorModule extends ReactContextBaseJavaModule {
|
|
|
25
26
|
|
|
26
27
|
@ReactMethod
|
|
27
28
|
public void disableScreenshots() {
|
|
28
|
-
getCurrentActivity()
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
29
|
+
Activity currentActivity = getCurrentActivity();
|
|
30
|
+
if (currentActivity != null) {
|
|
31
|
+
currentActivity.runOnUiThread(new Runnable() {
|
|
32
|
+
@Override
|
|
33
|
+
public void run() {
|
|
34
|
+
Window window = getWindow();
|
|
35
|
+
if (window != null) {
|
|
36
|
+
window.setFlags(WindowManager.LayoutParams.FLAG_SECURE, WindowManager.LayoutParams.FLAG_SECURE);
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
});
|
|
40
|
+
}
|
|
34
41
|
}
|
|
35
42
|
|
|
36
43
|
@ReactMethod
|
|
37
44
|
public void enableScreenshots() {
|
|
38
|
-
getCurrentActivity()
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
45
|
+
Activity currentActivity = getCurrentActivity();
|
|
46
|
+
if (currentActivity != null) {
|
|
47
|
+
currentActivity.runOnUiThread(new Runnable() {
|
|
48
|
+
@Override
|
|
49
|
+
public void run() {
|
|
50
|
+
Window window = getWindow();
|
|
51
|
+
if (window != null) {
|
|
52
|
+
window.clearFlags(WindowManager.LayoutParams.FLAG_SECURE);
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
});
|
|
56
|
+
}
|
|
44
57
|
}
|
|
45
58
|
|
|
46
59
|
private Window getWindow() {
|
|
47
|
-
|
|
60
|
+
Activity currentActivity = getCurrentActivity();
|
|
61
|
+
return currentActivity != null ? currentActivity.getWindow() : null;
|
|
48
62
|
}
|
|
49
63
|
}
|