-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
android: request camera permission for inputs #2033
base: master
Are you sure you want to change the base?
android: request camera permission for inputs #2033
Conversation
@@ -126,12 +126,35 @@ public InAppWebViewChromeClient(@NonNull final InAppWebViewFlutterPlugin plugin, | |||
this.inAppBrowserDelegate.getActivityResultListeners().add(this); | |||
} | |||
|
|||
if (plugin.registrar != null) | |||
if (plugin.registrar != null) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Check the brackets
@@ -126,12 +126,35 @@ public InAppWebViewChromeClient(@NonNull final InAppWebViewFlutterPlugin plugin, | |||
this.inAppBrowserDelegate.getActivityResultListeners().add(this); | |||
} | |||
|
|||
if (plugin.registrar != null) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Duplication of line
// Request camera permission first. The picker intent will be started once the | ||
// permission is either granted or denied. | ||
if (captureEnabled && needsCameraPermission() && Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { | ||
getActivity().requestPermissions(new String[]{Manifest.permission.CAMERA}, CAMERA_PICKER); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add permission for gallery and local files.
Can u suggest any solution for this issue? |
This PR tried to implement requesting user permissions on Android when the input field contains
capture
param. Requesting camera permission on app startup is not the best UX. This PR tries to delay the permission request until the user actually requires this action.Testing and Review Notes
You can pass this URL with into the example project WebView: https://12t031.csb.app/
One input is with
capture
while the other one is regular.Clicking on
capture
input should on Android request permissions. When the request is either accepted or denied then the file picker is resumed. When user accepts the permission the file picker contains the option to take a picture with camera.To Do
I don't regularly touch Java code and there is high chance this is not the best approach. However, this feature is important for me. Let me know if there are any changes need so it could be possibly merged and published.
Thank you!