Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

release: v1.9.13 #56

Merged
merged 3 commits into from
Nov 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ private Method getScreenCaptureCallback() {
if (Build.VERSION.SDK_INT < 34) {
return null;
}
return Utils.getMethod(getCurrentActivity().getClass(), "registerScreenCaptureCallback");
return Utils.getMethod(getReactCurrentActivity().getClass(), "registerScreenCaptureCallback");
}

public void createCaptureCallback() {
Expand Down Expand Up @@ -177,7 +177,7 @@ public void onHostResume() {
createCaptureCallback();
}
registerScreenCaptureCallback.invoke(
getCurrentActivity(),
getReactCurrentActivity(),
Utils.MainExecutor.INSTANCE,
(Object) screenCaptureCallback);
}
Expand All @@ -195,10 +195,10 @@ public void onHostDestroy() {
try {
if (Build.VERSION.SDK_INT >= 34) {
Method method = Utils.getMethod(
getCurrentActivity().getClass(),
getReactCurrentActivity().getClass(),
"unregisterScreenCaptureCallback");
if (method != null && screenCaptureCallback != null) {
method.invoke(getCurrentActivity(), (Object) screenCaptureCallback);
method.invoke(getReactCurrentActivity(), (Object) screenCaptureCallback);
}
}
} catch (Exception e) {
Expand Down
13 changes: 9 additions & 4 deletions ios/CaptureProtection.mm
Original file line number Diff line number Diff line change
Expand Up @@ -135,9 +135,13 @@ - (void)createRecordProtectionScreen {
UIWindow *window = [[[UIApplication sharedApplication] delegate] window];
UIViewController *captureProtectScreenController = (UIViewController *)[[window viewWithTag:TAG_RECORD_PROTECTION_SCREEN] nextResponder];
if (captureProtectScreenController == nil) {
if(self->protecterViewController == nil) {
[self createRecordProtectionScreenWithText:@"record Detected"];
if(self->protecterViewController != nil) {
[self->protecterViewController willMoveToParentViewController:nil];
[self->protecterViewController.view removeFromSuperview];
[self->protecterViewController removeFromParentViewController];
}
[self createRecordProtectionScreenWithText:@"record Detected"];


[window.rootViewController addChildViewController:self->protecterViewController];
[window.rootViewController.view addSubview:self->protecterViewController.view];
Expand Down Expand Up @@ -207,7 +211,7 @@ - (void)secureBackgroundView: (BOOL)show {
viewController.view.window.windowLevel = UIWindowLevelAlert;
self->protecterScreenViewController = viewController;
viewController.view.backgroundColor = UIColor.whiteColor;
UIWindow *window = [UIApplication sharedApplication].keyWindow;
UIWindow *window = [[UIApplication sharedApplication] delegate].window;

[window makeKeyAndVisible];

Expand All @@ -232,12 +236,13 @@ - (void)secureScreenshotView: (BOOL)isSecure {
self->secureTextField = [[UITextField alloc] init];
self->secureTextField.userInteractionEnabled = false;
self->secureTextField.tag = TAG_SCREEN_PROTECTION;
UIWindow *window = [UIApplication sharedApplication].keyWindow;
UIWindow *window = [[UIApplication sharedApplication] delegate].window;

[window makeKeyAndVisible];

[window.layer.superlayer addSublayer:self->secureTextField.layer];
[self->secureTextField.layer.sublayers.firstObject addSublayer:window.layer];
[self->secureTextField.layer.sublayers.lastObject addSublayer:window.layer];
}
[self->secureTextField setSecureTextEntry:isSecure];
});
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "react-native-capture-protection",
"version": "1.9.12",
"version": "1.9.13",
"description": "It’s a library for React Native to control simple capture events(i.e. Screenshot or Screen record)",
"main": "lib/commonjs/index",
"module": "lib/module/index",
Expand Down