wn-na / react-native-capture-protection

It’s a library for React Native to control simple capture events(i.e. Screenshot or Screen record)
https://www.npmjs.com/package/react-native-capture-protection
MIT License
102 stars 10 forks source link

Feature Request: Android Support for addScreenshotListener and addScreenRecordListener #27

Closed rokkoo closed 9 months ago

rokkoo commented 1 year ago

Hi there!

Firstly, kudos on maintaining such an awesome library!

I'm reaching out with a feature request that I believe could enhance the functionality of your library on Android. I'm wondering if there are any plans to introduce the addScreenshotListener and addScreenRecordListener methods for Android. This addition would be incredibly valuable for controlling on the app this flow.

Alternatively, if you've encountered any challenges or obstacles while considering or implementing these features, I'd love to understand more about them.

Thanks for the help :)

wn-na commented 12 months ago

hi @rokkoo

I want to add for addScreenshotListener, addScreenRecordListener for android. But, There's a reason i want to create it, but can't. First, I know that Android doesn't provide events like iOS for this part. This is related to not being able to resolve the issue #9 .

If you know of any, please let me know and I will add them as soon as possible

rokkoo commented 12 months ago

Hi @0xlethe thanks for the response!

Im checking other libraries like expo screenshot and they use content observables approach, I don't know if this can be a solution for us.

This solution need of READ_EXTERNAL_STORAGE permission on android and its always listening to changes on MediaStore.Images.Media.EXTERNAL_CONTENT_URI.

Expo repo Link

Let me know what do you think about this, this is by far the unique approach that I saw to detect changes on android :(

wn-na commented 11 months ago

@rokkoo Thanks to response!

Personally, it's a good idea However, I wouldn't implement it in this library for the following reasons.

  1. detecting unnecessary files & require READ_EXTERNAL_STORAGE
  2. it's impossible to detect perfectly (maybe?)
rokkoo commented 11 months ago

Hi @0xlethe !

I think this approach is not perfect, because the user can change the name of the screenshot or add another prefix to it, so we lose the precision for some cases, but I don't figure another way to control screenshot event on android.

wn-na commented 11 months ago

@rokkoo After thinking about it for a few days, this seems to be the best way to go at this point. I plan to release a new version with this approach in the near future.

Thanks!

rokkoo commented 11 months ago

Hi @0xlethe! That's awesome mate! If you need some help, or I can help you testing let me know!

wn-na commented 10 months ago

hi @rokkoo, happy new year!!

i update v1.9.2 for android can detect screenshot file. so can you test it?

rokkoo commented 10 months ago

Hey! happy new year @0xlethe !! This is nice mate! thanks! Im gonna test it, by te way, the pipeline of the PR is not passing, can you check it?

Thanks, nice job!

wn-na commented 10 months ago

@rokkoo hi, pr pipeline is broken for yarn version. You can ignore it and just do it

rokkoo commented 10 months ago

@rokkoo hi, pr pipeline is broken for yarn version. You can ignore it and just do it

Nice, I will let you know my feedback soon!

rokkoo commented 10 months ago

Hi @0xlethe sorry for the delay on this.. I was be able to test it on android, and work like a charm 🎉

GREAT job @0xlethe !!

I have a few notes to share with you, I can propose some PR to improve it.

Nice to have

wn-na commented 10 months ago

@rokkoo Thanks for testing and sharing your findings.

For RN 0.73, I meant to say that it also supports version 0.73, but I think I wrote it wrong and will fix it. The addScreenshotListener and removeScreenshotListener will be released in 1.9.3, along with the wiki fixes

rokkoo commented 10 months ago

@0xlethe That's amazing! Thanks you! Ping me if you need anything for me, I will glad to help :)

wn-na commented 9 months ago

this issue is release for >= 1.9.2, so closed this issue