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

Implement stop() to close CAMERA or PHOTOLIBRARY #873

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

Conversation

NityaSantosh26
Copy link

Platforms affected

Android and iOS

Motivation and Context

I have an usecase where user opens camera and if there's an high priority push notification is received, when user clicks, it doesn't close the camera, User has to manually close the camera. Now using the navigator.camera.stop(). I can achieve this behavior.
And there are other instances which needs closing of camera or photo library from the code.

Description

Added a new method stop() which handles the closing of CAMERA or PHOTOLIBRARY for both Android and iOS.

Testing

I have verified the usecase I have mentioned above, when a push notification is clicked that closes the camera and takes to the destination page in the module by calling the stop() method.

Checklist

  • I've run the tests to see all new and existing tests pass
  • I added automated test coverage as appropriate for this change
  • Commit is prefixed with (platform) if this change only applies to one platform (e.g. (android))
  • If this Pull Request resolves an issue, I linked to the issue in the text above (and used the correct keyword to close issues using keywords)
  • I've updated the documentation if necessary

@breautek
Copy link
Contributor

breautek commented Dec 8, 2023

This PR doesn't compile on android:

> Task :app:compileDebugJavaWithJavac FAILED
/private/var/folders/3s/vfzpb5r51gs6y328rmlgzm7c0000gn/T/tmp-6830-P1sEoh8XyXcJ/platforms/android/app/src/main/java/org/apache/cordova/camera/CameraLauncher.java:361: error: cannot find symbol
            this.cordova.getActivity().finishActivity((CAMERA + 1) * 16 + returnType + 1);
                                                                          ^
  symbol:   variable returnType
  location: class CameraLauncher
/private/var/folders/3s/vfzpb5r51gs6y328rmlgzm7c0000gn/T/tmp-6830-P1sEoh8XyXcJ/platforms/android/app/src/main/java/org/apache/cordova/camera/CameraLauncher.java:[362](https://github.com/apache/cordova-plugin-camera/actions/runs/7110255438/job/19459961261?pr=873#step:9:366): error: cannot find symbol
            this.cordova.getActivity().finishActivity((PHOTOLIBRARY + 1) * 16 + returnType + 1);
                                                                                ^
  symbol:   variable returnType
  location: class CameraLauncher
Note: Some input files use or override a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
2 errors

Additionally there are lint issues present in this PR:

/home/runner/work/cordova-plugin-camera/cordova-plugin-camera/www/Camera.js
Error:   158:1  error  Unexpected tab character                          no-tabs
Error:   158:1  error  Expected indentation of 4 spaces but found 1 tab  indent

@NityaSantosh26
Copy link
Author

NityaSantosh26 commented Dec 11, 2023

@breautek, My bad. I had an incomplete commit. Let me update my commit.
Can you review the PR. It's complete now.

@breautek breautek closed this Jul 16, 2024
@breautek breautek reopened this Jul 16, 2024
@breautek breautek added this to the 8.0.0 milestone Jul 26, 2024
@NityaSantosh26
Copy link
Author

Hey @breautek , Can I expect this PR also to be part of v8?

@breautek breautek modified the milestones: 8.0.0, 8.1.0 Oct 30, 2024
@breautek
Copy link
Contributor

Hey @breautek , Can I expect this PR also to be part of v8?

Sorry I was pre-occupied with more important changes that needed to make it's way through in v8 and I don't want to delay the release any further due to Android's October 31st deadline (the voting process takes minimum 48 hours so it is already behind) so I'll be beginning the vote process without this feature.

I bumped the milestone so that we can take a look for maybe an 8.1 release.

Copy link
Contributor

@breautek breautek left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Our browser implementation for the camera I would say is barely usable but to make this feature complete, it would be nice to also have a browser implementation to hide the form input or whatever what the browser implementation does to show the camera/dialog.

@@ -213,6 +213,9 @@ else if ((this.srcType == PHOTOLIBRARY) || (this.srcType == SAVEDPHOTOALBUM)) {
r.setKeepCallback(true);
callbackContext.sendPluginResult(r);

return true;
} if (action.equals("stop")) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe this is intended to be an else if

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

Successfully merging this pull request may close these issues.

2 participants