Content-Length: 389548 | pFad | http://github.com/react-native-sensors/react-native-sensors/pull/464

C7 Add in light sensor for Android by fahadhaque007 · Pull Request #464 · react-native-sensors/react-native-sensors · GitHub
Skip to content

Add in light sensor for Android #464

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

Open
wants to merge 21 commits into
base: master
Choose a base branch
from

Conversation

fahadhaque007
Copy link

@fahadhaque007 fahadhaque007 commented Jul 17, 2024

We aim to integrate a sensor for ambient light capture on Android devices. This PR will enable us to detect the availability of the sensor on the device and allow users to capture and record the lux levels in their environment. Additionally, we have added the following functions:

  • stopLightSensor
  • startLightSensor
  • hasLightSensor

@DanielMSchmidt we would appreciate your feedback on incorporating this into your codebase.

@fahadhaque007 fahadhaque007 marked this pull request as draft July 17, 2024 05:06
@fahadhaque007 fahadhaque007 marked this pull request as ready for review July 17, 2024 05:22
@DanielMSchmidt
Copy link
Member

This seems to be Android only, for react native sensors we want to build a common interface for sensors across all platforms. We would need to add an iOS implementation if it exists. Otherwise I would suggest making this our own project, I'm happy to add a link to it in our Readme / Docs.

@fahadhaque007
Copy link
Author

@DanielMSchmidt iOS does not have a direct equivalent to Android's Sensor.TYPE_LIGHT for ambient light detection, and there is no public API to access the ambient light sensor directly. Therefore, setting this up for iOS is challenging.

However, we can achieve similar functionality on iOS using the UIScreen class, which provides the screen brightness. Although it doesn't measure ambient light directly, it can offer some insight into the room's brightness. This method works best if the device's auto-brightness feature is enabled, allowing us to infer environmental lighting changes. Let me know your thought on this. Thanks, Fahad

@DanielMSchmidt
Copy link
Member

I'd encourage you to make it a separate library. I know there is some demand for this since we get PRs like this once in a while, but I would like this library to be both very low level and universal across all platforms we support. We could add this library to the react-native sensor org and use a similar API like the one for this project if you like :)

fahadhaque007 and others added 18 commits July 22, 2024 11:16
Co-authored-by: Brendan O'Brien <titaniumcranium@icloud.com>
Co-authored-by: Brendan O'Brien <titaniumcranium@icloud.com>
Co-authored-by: Brendan O'Brien <titaniumcranium@icloud.com>
Co-authored-by: Brendan O'Brien <titaniumcranium@icloud.com>
Co-authored-by: Brendan O'Brien <titaniumcranium@icloud.com>
Co-authored-by: Brendan O'Brien <titaniumcranium@icloud.com>
Co-authored-by: Brendan O'Brien <titaniumcranium@icloud.com>
Co-authored-by: Brendan O'Brien <titaniumcranium@icloud.com>
Co-authored-by: Brendan O'Brien <titaniumcranium@icloud.com>
Co-authored-by: Brendan O'Brien <titaniumcranium@icloud.com>
Co-authored-by: Brendan O'Brien <titaniumcranium@icloud.com>
Co-authored-by: Brendan O'Brien <titaniumcranium@icloud.com>
Co-authored-by: Brendan O'Brien <titaniumcranium@icloud.com>
Co-authored-by: Brendan O'Brien <titaniumcranium@icloud.com>
Co-authored-by: Brendan O'Brien <titaniumcranium@icloud.com>
Co-authored-by: Brendan O'Brien <titaniumcranium@icloud.com>
Co-authored-by: Brendan O'Brien <titaniumcranium@icloud.com>
Co-authored-by: Brendan O'Brien <titaniumcranium@icloud.com>
@srivastava9
Copy link

Hey @fahadhaque007 Can you use SRAmbientLightSensor for the iOS side ? Let me know if you will be working on this

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants








ApplySandwichStrip

pFad - (p)hone/(F)rame/(a)nonymizer/(d)eclutterfier!      Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

Fetched URL: http://github.com/react-native-sensors/react-native-sensors/pull/464

Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy