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

Is there any problem with Camera.turnOnFlash(true)? #45

Closed
nikunjbhatt opened this issue Jul 6, 2020 · 9 comments
Closed

Is there any problem with Camera.turnOnFlash(true)? #45

nikunjbhatt opened this issue Jul 6, 2020 · 9 comments

Comments

@nikunjbhatt
Copy link

I am exploring this awesome PHONK project.

In the main.js file, if I write only one line Camera.turnOnFlash(true) and run the PHONK project, then should it turn the flash on? I tried this after looking in the Reference guide, but it is not working. I also tried below lines:
camera.turnOnFlash(true)
device.Camera.turnOnFlash(true)
device.camera.turnOnFlash(true)
But none of these are working. This is the error showing in the Console in the PHONK editor in web browser:
ReferenceError: "Camera" is not defined. (test proj#1)

Am I missing anything? Am I doing any mistake? Or is there any bug?

I tried these in my phone Moto X Play (XT1562) with Android 7.1.1 (Nougat).

@victordiaz
Copy link
Owner

victordiaz commented Jul 6, 2020

Hello @nikunjbhatt

Please check the Media -> Camera example.
The current implementation needs the camera to be active in order to turn on the flash, since it uses an old Android implementation.

I'm aware that is possible to turn on the flash without the camera, I will add that to the TODO list and include it for the next release.

Maybe you can work with the camera example for now :)
Thanks for the report!

@nikunjbhatt
Copy link
Author

Ok. Got it. Thanks for quick reply.

@nikunjbhatt
Copy link
Author

nikunjbhatt commented Jul 6, 2020

I don't have much idea about Android development, but as per you said that old Android implementation needed active camera to work with flash, which means new Android implementation doesn't require active camera then I think the API should be changed to device.turnOnFlash(boolean) instead of camera.turnOnFlash(boolean). Also, I suggest to remove the word On from the function name, or even remove the words turnOn, to make it just device.flash(boolean).

@victordiaz
Copy link
Owner

That's a good idea!
On the other side, there is some devices that have multiple flash lights (front and rear), so I think is good that the camera has its own method to turn on the flash light.
I will check how is turning the flash without the Camera and include it. It makes sense to include it inside the device object.
I like to have an action verb for some methods, so maybe device.activateFlash(boolean) might sound ok?

@nikunjbhatt
Copy link
Author

@victordiaz
Sorry for very late replying, I had completely forgot.

I don't think using verb in methods which are doing toggling things is good. Or there should be 2 different methods for 2 different states, for example: device.activateFlash() and device.deactivateFlash().

@victordiaz
Copy link
Owner

@nikunjbhatt I agree It's better without the verb. Thanks for the suggestion :)

@victordiaz
Copy link
Owner

@nikunjbhatt

You can now turn on/off the flash light using
device.flashLight(boolean)

Feel free to check it and close the issue if it's the expected behaviour. Thanks!

@nikunjbhatt
Copy link
Author

nikunjbhatt commented Aug 6, 2020

@victordiaz
Thanks. It's working!

By the way, in the README.me of the PHONK repo, you have told to contact you by email but I can't find your email anywhere, not in the README.md file, not in your GitHub profile, not on your personal website, not on the phonk.app website!

May I know how the reference documentation is generated? In the reference documentation, it is showing as String for all parameters for ui.addToggle() function (and for many other functions), but actually the text param is an Array (of String) and the other params, w h x y, are of type object. So, how to show them correctly in the reference documentation? Is it a problem of the documentation generator or improper documentation in the code files?

@victordiaz
Copy link
Owner

Hi @nikunjbhatt

Feel free to join this discord server so we can chat https://discord.gg/Rt2mkWp
I'm sorry if there is things missing everywhere, I lack a bit of time to put everything nicely :)

Regarding the documentation. Is it generated with and older version of Java and I had a mess in my system since it updated Java and now the generator does not want to run :/ so the docs are generated some time ago and many methods have changed since then.

It would be nice to dockerize the generator so I can run it easily before a new release and things can be up-to-date

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

No branches or pull requests

2 participants