sarriaroman / photoviewer

PhotoViewer Cordova Plugin
MIT License
157 stars 216 forks source link

Multiple Images #95

Open Muneem opened 7 years ago

Muneem commented 7 years ago

is it possible to pass images array in photoviewer and it shows in gallery?

deepakrokz commented 7 years ago

Please reply on this

troyanskiy commented 7 years ago

It's nice to have!

budko1989 commented 7 years ago

subscribe

JoxC commented 6 years ago

+1

vadimwe commented 6 years ago

Please add this feature. It's very useful.

Maxim-Mazurok commented 6 years ago

I'm interested in this feature too.

Boldonglen commented 6 years ago

+1. Is this on the roadmap or should i look for an alternate plugin?

deepakrokz commented 6 years ago

I have fixed this in the Android version, also asked to merge in this repository. Till then you guys can check with this link

jayzyaj commented 6 years ago

+1 on this. I had an issue if the photo is landscape when I view the image it auto zooms on the center. Any thoughts on this? Thanks.

cedricfleury commented 6 years ago

@deepakrokz I download the files that you create for multiple images and copy them to the android folder. If i well understood what you coded the images must be sent in an array in the options. So i tried to put an array called "img_array" like on your file but that's not that easy or i don't really understood. Did you have an example to how to use it ? Thanks because this plugin could be so much better with this feature

deepakrokz commented 6 years ago

Sorry, currently I can't help you with that, I have updated lib only, for implementation as you are saying need to pass an array, that's what you need to do yourself.

cedricfleury commented 6 years ago

@deepakrokz Thanks for the answer that's what i did pass the array like i said. I was just wondering how the plugin know when it have to use the new files your added whithout modifying the original files. When i tried to use these files the debugger stop and say me "PhotoMultipleActivity.java:170: error: cannot find symbol View itemView = mLayoutInflater.inflate(R.layout.activity_photo, container, false); " If with your files we can propose a solution to everyone want to open multiple images on cordova it could be very useful.

deepakrokz commented 6 years ago

@cedricfleury , sorry for the delay, If you check PhotoViewer.java file it's all there.

`public class PhotoViewer extends CordovaPlugin {

public static final int PERMISSION_DENIED_ERROR = 20;

public static final String WRITE = Manifest.permission.WRITE_EXTERNAL_STORAGE;
public static final String READ = Manifest.permission.READ_EXTERNAL_STORAGE;

public static final int REQ_CODE = 0;

protected JSONArray args;
protected CallbackContext callbackContext;

@Override
public boolean execute(String action, JSONArray args, CallbackContext callbackContext) throws JSONException {
    if (action.equals("show")) {
        this.args = args;
        this.callbackContext = callbackContext;

// if (cordova.hasPermission(READ) && cordova.hasPermission(WRITE)) { this.launchActivity(); // } else { // this.getPermission(); // } return true; } else if (action.equals("showmultiple")) { this.args = args; this.callbackContext = callbackContext;

// if (cordova.hasPermission(READ) && cordova.hasPermission(WRITE)) { this.launchMulActivity(); // } else { // this.getPermission(); // } return true; } return false; }

protected void getPermission() {
    cordova.requestPermissions(this, REQ_CODE, new String[]{WRITE, READ});
}

protected void launchActivity() throws JSONException {
    Intent i = new Intent(this.cordova.getActivity(), com.sarriaroman.PhotoViewer.PhotoActivity.class);

    i.putExtra("url", this.args.getString(0));
    i.putExtra("title", this.args.getString(1));
    i.putExtra("options", this.args.optJSONObject(2).toString());

    this.cordova.getActivity().startActivity(i);
    this.callbackContext.success("");
}
protected void launchMulActivity() throws JSONException {
    Intent i = new Intent(this.cordova.getActivity(), com.sarriaroman.PhotoViewer.PhotoMultipleActivity.class);

    i.putExtra("url", this.args.getString(0));
    i.putExtra("title", this.args.getString(1));
    i.putExtra("options", this.args.optJSONObject(2).toString());

    this.cordova.getActivity().startActivity(i);
    this.callbackContext.success("");
}

@Override
public void onRequestPermissionResult(int requestCode, String[] permissions,
                                      int[] grantResults) throws JSONException {
    for(int r:grantResults) {
        if(r == PackageManager.PERMISSION_DENIED) {
            this.callbackContext.sendPluginResult(new PluginResult(PluginResult.Status.ERROR, PERMISSION_DENIED_ERROR));
            return;
        }
    }

    switch(requestCode) {
        case REQ_CODE:
            launchActivity();
            break;
    }

}

} `

cedricfleury commented 6 years ago

Thanks for the answer, this code seems far more logic to use differents activity files but i don't have this file, your branch only concern the multiplephotoactivity file and the layout file. I edit the PhotoViewer.java with what you gave me, if i execute only with that it doesn't find the multipleActivity file so i add <source-file src="src/android/PhotoMultipleActivity.java" target-dir="src/com/sarriaroman/PhotoViewer" /> to plugin.xml and this message came back again

"PhotoMultipleActivity.java:170: error: cannot find symbol View itemView = mLayoutInflater.inflate(R.layout.activity_photo, container, false); " i tried multiple changes but without success