Skip to content

Commit

Permalink
release: v.1.9.3 (#31)
Browse files Browse the repository at this point in the history
## Update

- support compileSDK under 33
- fix typo
  • Loading branch information
wn-na authored Jan 25, 2024
2 parents f2a2f1e + 15db20b commit d11be51
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -118,8 +118,8 @@ private boolean requestStoragePermission() {
// android.permission.DETECT_SCREEN_CAPTURE instead.
}

String requestPermission = Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU
? Manifest.permission.READ_MEDIA_IMAGES
String requestPermission = Build.VERSION.SDK_INT >= 33 // Build.VERSION_CODES.TIRAMISU
? "android.permission.READ_MEDIA_IMAGES" // Manifest.permission.READ_MEDIA_IMAGES
: Manifest.permission.READ_EXTERNAL_STORAGE;

if (ContextCompat.checkSelfPermission(
Expand Down Expand Up @@ -213,6 +213,16 @@ public String getName() {
return NAME;
}

@ReactMethod
public void addListener(String eventName) {
addListener();
}

@ReactMethod
public void removeListeners(Integer count) {
removeListener();
}

@ReactMethod
public void addScreenshotListener() {
addListener();
Expand Down
4 changes: 2 additions & 2 deletions example/android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ buildscript {
ext {
buildToolsVersion = "31.0.0"
minSdkVersion = 21
compileSdkVersion = 31
targetSdkVersion = 31
compileSdkVersion = 32
targetSdkVersion = 32

if (System.properties['os.arch'] == "aarch64") {
// For M1 Users we need to use the NDK 24 which added support for aarch64
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "react-native-capture-protection",
"version": "1.9.2",
"version": "1.9.3",
"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 Expand Up @@ -83,7 +83,7 @@
"engines": {
"node": ">= 16.0.0"
},
"packageManager": "^yarn@1.22.15",
"packageManager": "^yarn@1.22.21",
"jest": {
"preset": "react-native",
"modulePathIgnorePatterns": [
Expand Down
19 changes: 3 additions & 16 deletions src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,8 @@ function addEventListener(callback: CaptureEventListenerCallback): void {
if (Platform.OS !== 'ios' && Platform.OS !== 'android') {
return;
}
addScreenshotListener();
addScreenRecordListener();
CaptureNotificationEmitter?.addListener?.(
CaptureProtectionEventType,
callback
Expand Down Expand Up @@ -210,7 +212,7 @@ const removeScreenshotListener = async (): Promise<void> => {
*
* return listener regist status
*
* if `android`, recording status is always return `false` */
*/
const hasListener = async (): Promise<CaptureEventStatus | undefined> => {
if (Platform.OS === 'android') {
return await CaptureProtectionModule?.hasListener?.();
Expand Down Expand Up @@ -421,25 +423,10 @@ export const CaptureProtection = {
preventScreenshot,
allowScreenRecord,
preventScreenRecord,
/**
* @deprecated
*/
addScreenshotListener,
/**
* @deprecated
*/
removeScreenshotListener,
/**
* @deprecated
*/
addScreenRecordListener,
/**
* @deprecated
*/
removeScreenRecordListener,
/**
* @deprecated
*/
hasListener,
isScreenRecording,
requestPermission,
Expand Down

0 comments on commit d11be51

Please sign in to comment.