Skip to content

Commit

Permalink
fix(android): handle nullable imagePath in enableSecureView
Browse files Browse the repository at this point in the history
  • Loading branch information
batuhanoztrk committed Sep 21, 2024
1 parent 9a7d085 commit 419cd5a
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ class ScreenshotPreventModule internal constructor(context: ReactApplicationCont
}

@ReactMethod
override fun enableSecureView(imagePath: String) {
override fun enableSecureView(imagePath: String?) {
currentActivity?.let {
if (overlayLayout == null) {
createOverlayLayout(it, imagePath)
Expand Down Expand Up @@ -116,7 +116,7 @@ class ScreenshotPreventModule internal constructor(context: ReactApplicationCont
}
}

private fun createOverlayLayout(activity: Activity, imagePath: String) {
private fun createOverlayLayout(activity: Activity, imagePath: String?) {
overlayLayout = RelativeLayout(activity).apply {
setBackgroundColor(Color.parseColor("#FFFFFF"))

Expand All @@ -128,7 +128,7 @@ class ScreenshotPreventModule internal constructor(context: ReactApplicationCont
imageParams.addRule(RelativeLayout.CENTER_IN_PARENT, RelativeLayout.TRUE)
imageView.layoutParams = imageParams

val bitmap = decodeImageUri(imagePath)
val bitmap = imagePath?.let { decodeImageUri(it) }

if (bitmap != null) {
val imageHeight =
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": "rn-screenshot-prevent",
"version": "0.0.2",
"version": "0.0.3",
"description": "A React Native package to block screenshots and screen recordings, providing protection for sensitive app content. Supports both Android and iOS platforms.",
"main": "lib/commonjs/index",
"module": "lib/module/index",
Expand Down

0 comments on commit 419cd5a

Please sign in to comment.