cordova-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "ASF GitHub Bot (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (CB-8777) add android option to only display gallery type apps on getImage
Date Wed, 14 Mar 2018 23:50:00 GMT

    [ https://issues.apache.org/jira/browse/CB-8777?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16399622#comment-16399622
] 

ASF GitHub Bot commented on CB-8777:
------------------------------------

infil00p closed pull request #80: feature CB-8777 Add option onlyGalleries
URL: https://github.com/apache/cordova-plugin-camera/pull/80
 
 
   

This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:

As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):

diff --git a/README.md b/README.md
index f2b45625..55944f30 100644
--- a/README.md
+++ b/README.md
@@ -263,7 +263,8 @@ Optional parameters to customize the camera settings.
 | correctOrientation | <code>Boolean</code> |  | Rotate the image to correct
for the orientation of the device during capture. |
 | saveToPhotoAlbum | <code>Boolean</code> |  | Save the image to the photo album
on the device after capture. |
 | popoverOptions | <code>[CameraPopoverOptions](#module_CameraPopoverOptions)</code>
|  | iOS-only options that specify popover location in iPad. |
-| cameraDirection | <code>[Direction](#module_Camera.Direction)</code> | <code>BACK</code>
| Choose the camera to use (front- or back-facing). |
+| cameraDirection | <code>[Direction](#module_Camera.Direction)</code> | <code>BACK</code>
| Choose the camera to use (front- or back-facing). | 
+| onlyGalleries | <code>Boolean</code> |  | Android-only option to allow getImage
to only get from gallery apps, excluding dropbox, drive, onedrive and filesystem explorers.
|
 
 ---
 
@@ -512,6 +513,7 @@ Tizen only supports a `destinationType` of
 
 ## `CameraOptions` Errata <a name="CameraOptions-quirks"></a>
 
+
 #### Amazon Fire OS Quirks
 
 - Any `cameraDirection` value results in a back-facing photo.
diff --git a/src/android/CameraLauncher.java b/src/android/CameraLauncher.java
index b10f40f3..e9a917f3 100644
--- a/src/android/CameraLauncher.java
+++ b/src/android/CameraLauncher.java
@@ -112,6 +112,9 @@ Licensed to the Apache Software Foundation (ASF) under one
     private boolean correctOrientation;     // Should the pictures orientation be corrected
     private boolean orientationCorrected;   // Has the picture's orientation been corrected
     private boolean allowEdit;              // Should we allow the user to crop the image.
+    private JSONObject popoverOptions;      // not used on android
+    private int cameraDirection;            // not used on android
+    private boolean onlyGalleries;          // Should we force the user to only be able to
select images from the gallery apps on the device.
 
     protected final static String[] permissions = { Manifest.permission.CAMERA, Manifest.permission.READ_EXTERNAL_STORAGE
};
 
@@ -151,17 +154,22 @@ public boolean execute(String action, JSONArray args, CallbackContext
callbackCo
             this.mediaType = PICTURE;
             this.mQuality = 50;
 
-            //Take the values from the arguments if they're not already defined (this is
tricky)
-            this.destType = args.getInt(1);
-            this.srcType = args.getInt(2);
-            this.mQuality = args.getInt(0);
-            this.targetWidth = args.getInt(3);
-            this.targetHeight = args.getInt(4);
-            this.encodingType = args.getInt(5);
-            this.mediaType = args.getInt(6);
-            this.allowEdit = args.getBoolean(7);
-            this.correctOrientation = args.getBoolean(8);
-            this.saveToPhotoAlbum = args.getBoolean(9);
+            this.mQuality = args.optInt(0);
+            destType = args.optInt(1);
+            srcType = args.optInt(2);
+            this.targetWidth = args.optInt(3);
+            this.targetHeight = args.optInt(4);
+            this.encodingType = args.optInt(5);
+            this.mediaType = args.optInt(6);
+            this.allowEdit = args.optBoolean(7);
+            this.correctOrientation = args.optBoolean(8);
+            this.saveToPhotoAlbum = args.optBoolean(9);
+            this.popoverOptions = args.optJSONObject(10);
+            this.cameraDirection = args.optInt(11);
+            this.onlyGalleries = args.optBoolean(12);
+            if (this.allowEdit){
+                this.onlyGalleries = true;
+            }
 
             // If the user specifies a 0 or smaller width/height
             // make it -1 so later comparisons succeed
@@ -366,18 +374,20 @@ public void getImage(int srcType, int returnType, int encodingType)
{
         croppedUri = null;
         if (this.mediaType == PICTURE) {
             intent.setType("image/*");
-            if (this.allowEdit) {
+            if (this.onlyGalleries) {
                 intent.setAction(Intent.ACTION_PICK);
-                intent.putExtra("crop", "true");
-                if (targetWidth > 0) {
-                    intent.putExtra("outputX", targetWidth);
-                }
-                if (targetHeight > 0) {
-                    intent.putExtra("outputY", targetHeight);
-                }
-                if (targetHeight > 0 && targetWidth > 0 && targetWidth
== targetHeight) {
-                    intent.putExtra("aspectX", 1);
-                    intent.putExtra("aspectY", 1);
+                if (this.allowEdit) {
+                    intent.putExtra("crop", "true");
+                    if (targetWidth > 0) {
+                        intent.putExtra("outputX", targetWidth);
+                    }
+                    if (targetHeight > 0) {
+                        intent.putExtra("outputY", targetHeight);
+                    }
+                    if (targetHeight > 0 && targetWidth > 0 && targetWidth
== targetHeight) {
+                        intent.putExtra("aspectX", 1);
+                        intent.putExtra("aspectY", 1);
+                    }
                 }
                 File photo = createCaptureFile(JPEG);
                 croppedUri = Uri.fromFile(photo);
diff --git a/www/Camera.js b/www/Camera.js
index d0067870..1ec51bbc 100644
--- a/www/Camera.js
+++ b/www/Camera.js
@@ -148,9 +148,10 @@ cameraExport.getPicture = function(successCallback, errorCallback, options)
{
     var saveToPhotoAlbum = !!options.saveToPhotoAlbum;
     var popoverOptions = getValue(options.popoverOptions, null);
     var cameraDirection = getValue(options.cameraDirection, Camera.Direction.BACK);
+    var onlyGalleries = !!options.onlyGalleries;
 
     var args = [quality, destinationType, sourceType, targetWidth, targetHeight, encodingType,
-                mediaType, allowEdit, correctOrientation, saveToPhotoAlbum, popoverOptions,
cameraDirection];
+                mediaType, allowEdit, correctOrientation, saveToPhotoAlbum, popoverOptions,
cameraDirection, onlyGalleries];
 
     exec(successCallback, errorCallback, "Camera", "takePicture", args);
     // XXX: commented out


 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


> add android option to only display gallery type apps on getImage
> ----------------------------------------------------------------
>
>                 Key: CB-8777
>                 URL: https://issues.apache.org/jira/browse/CB-8777
>             Project: Apache Cordova
>          Issue Type: New Feature
>          Components: cordova-plugin-camera
>         Environment: Android
>            Reporter: Serge Huijben
>            Priority: Minor
>              Labels: Triaged, android, features
>   Original Estimate: 24h
>  Remaining Estimate: 24h
>
> Add an option to allow only Gallery type apps to launch on getImage.
> current behaviour would launch an activity that allows the use to select files from filesystem,
remote filesystem (drive, dropbox, onedrive, etc) and galleries.
> I would like to add a switch option onlyGalleries that if set to true would allow the
user to only get images from gallery type apps on the device.  



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@cordova.apache.org
For additional commands, e-mail: issues-help@cordova.apache.org


Mime
View raw message