sarriaroman / photoviewer Goto Github PK
View Code? Open in Web Editor NEWPhotoViewer Cordova Plugin
License: MIT License
PhotoViewer Cordova Plugin
License: MIT License
Not an error, but an enhancement for performance. iOS only
Logs from Xcode: THREAD WARNING: ['PhotoViewer'] took '25.724854' ms. Plugin should use a background thread.
Hey,
first of all thanks for the plugin.
I've a question: Is there a way to cancel PhotoViewer once PhotoViewer.show()
is called? I've the problem that some images take very long to load and I'd like to implement a timeout handler.
Github releases not reflecting in npm. Please publish the latest minor release (1.1.5) to npm as we have dependency on this.
Test: Android 7.1.1 -> Nexus 5X
01-25 15:25:29.900: E/ActivityThread(3953): Failed to find provider info for
01-25 15:25:29.901: W/ImageView(3953): Unable to open content: content:///storage/emulated/0/Android/data/com.donde.djmix/cache/pexels12.jpg
01-25 15:25:29.901: W/ImageView(3953): java.io.FileNotFoundException: No content provider: content:///storage/emulated/0/Android/data/com.donde.djmix/cache/pexels12.jpg
Is it possible to retrieve click coordinates when showing an image?
After adding the plugin, when I try to cordova run android
, I get:
[javac] /Users/jules/Documents/workspace/groupahead-mvp/platforms/android/src/com/speryans/PhotoViewer/PhotoActivity/PhotoActivity.java:12: error: package com.speryans.palmira does not exist [javac] import com.speryans.palmira.R; [javac] ^ [javac] /Users/jules/Documents/workspace/groupahead-mvp/platforms/android/src/com/speryans/PhotoViewer/PhotoActivity/PhotoActivity.java:24: error: package R does not exist [javac] setContentView(R.layout.activity_photo); [javac] ^ [javac] /Users/jules/Documents/workspace/groupahead-mvp/platforms/android/src/com/speryans/PhotoViewer/PhotoActivity/PhotoActivity.java:28: error: package R does not exist [javac] photo = (ImageView) findViewById(R.id.photoView); [javac] ^ [javac] /Users/jules/Documents/workspace/groupahead-mvp/platforms/android/src/com/speryans/PhotoViewer/PhotoActivity/PhotoActivity.java:36: error: package R does not exist [javac] ((LinearLayout) this.findViewById(R.id.fullscreen_content_controls)).setVisibility(View.GONE);
sarriaroman/PhotoViewer/PhotoViewer.java:37: error: cannot find symbol
if (cordova.hasPermission(READ) && cordova.hasPermission(WRITE)) {
^
looks like its missing the permission helper to work with older cordova 5 versions.
-compile:
[javac] Compiling 55 source files to /project/bin/classes
[javac] /project/src/com/sarriaroman/PhotoViewer/PhotoActivity.java:3: error: package uk.co.senab.photoview does not exist
[javac] import uk.co.senab.photoview.PhotoViewAttacher;
[javac] ^
[javac] /project/src/com/sarriaroman/PhotoViewer/PhotoActivity.java:21: error: package com.squareup.picasso does not exist
[javac] import com.squareup.picasso.Picasso;
[javac] ^
[javac] /project/src/com/sarriaroman/PhotoViewer/PhotoActivity.java:31: error: cannot find symbol
[javac] private PhotoViewAttacher mAttacher;
[javac] ^
[javac] symbol: class PhotoViewAttacher
[javac] location: class PhotoActivity
[javac] /project/src/com/sarriaroman/PhotoViewer/PhotoActivity.java:107: error: cannot find symbol
[javac] mAttacher = new PhotoViewAttacher(photo);
[javac] ^
[javac] symbol: class PhotoViewAttacher
[javac] location: class PhotoActivity
[javac] /project/src/com/sarriaroman/PhotoViewer/PhotoActivity.java:141: error: package com.squareup.picasso does not exist
[javac] .into(photo, new com.squareup.picasso.Callback() {
[javac] ^
[javac] /project/src/com/sarriaroman/PhotoViewer/PhotoActivity.java:139: error: cannot find symbol
[javac] Picasso.with(this)
[javac] ^
[javac] symbol: variable Picasso
[javac] location: class PhotoActivity
[javac] Note: Some input files use or override a deprecated API.
[javac] Note: Recompile with -Xlint:deprecation for details.
[javac] Note: Some input files use unchecked or unsafe operations.
[javac] Note: Recompile with -Xlint:unchecked for details.
[javac] 6 errors
If image does not exist, app will crash. Please add additional checks.
iOS's new UIDocumentController has a built-in flick to dismiss (when swiping down, without zoom)
Would be nice if this could be added also to android (only when not zoomed)
Finally someone managed to develop a working solution for both iOS and Android with Remote Image support. And no picture intent on android. 👍 👍 💯 You can't imagine how thankful I am!
Just two small things:
Title for image and Gallery modus (array of images)
UIDocumentController support title, just a small adjustment, but I don't know if Andorid support's title
Error: Plugin PhotoViewer cannot be added. The plugin contains Gradle scripts.
I was build with Intel XDK, please help me fix it
I tried to use it with file path i.e. native URL i.e. 'file:///storage/emulated/0/Pictures...' but its not displaying anything.
I've active AdMob banner that resize the total view automatically.
But when I open and close a photo with the plugin photoviewer, the height of the view change and the bottom of the page goes under the AdMob banner.
There is a solution?
The sharing feature does not work. When clicking on the share icon, nothing happens.
Any help?
I tried only in my Moto G third generation with Android 6.
Trying to open image in PhotoViewer with high dimension image & size of every image is more than 100 KB but it's not opening in PhotoViewer.
It's giving me an below error in android studio monitor,
THREAD WARNING: exec() call to PhotoViewer.show blocked the main thread for 62ms. Plugin should use CordovaInterface.getThreadPool().
There is a error in saving photos to photo library, and causes app to exit.
There is no prompt for users to grant permission either.
It seems that PhotoViewer doesn't work with large images. E.g.:
PhotoViewer.show('http://alarp.works-organiser.com/urt/system/photos/photos/000/000/244/original/DSC00051.JPG?1452406132', 'DSC00051.JPG');
The files size is 7468422 Bytes, the image resolution 5152x3864.
It returns immediately with "Error loading image" on an Android Virtual Device (AVD) with 1GB RAM and Android 4.4.2. On a Samsung S4 mini also with Android 4.4.2 and 1.5 GB RAM it sometimes returns immediately sometimes "spins" forever.
An other, smaller (2 MB, 3088x3088) works but very slow (and even the orientation is ignored):
PhotoViewer.show('http://alarp.works-organiser.com/urt/system/photos/photos/000/000/054/original/20151014_152321.jpg?1444906627', 'DSC01165.JPG');
Much smaller images are working perfectly.
Hi, thanks for your excellent plugin and your effort.
I have a problem (IOS - 10). The viewer hangs (stuck permanently) if the image is missing o the server returns 404 error. It shows only the spinner and i don’t have an option to go back or cancel the request. For example: www.404errorpages.com/error.jpg
In Android shows “Error loading image”
Thanks!!
If you try loading an image above 200kb in base64, the app completely crashes. This is repeatable.
This shouldn't happen as that's not a large image.
Is this a known bug or what?
I'm testing with Ionic 2 RC3 and Android 7 on a Nexus 5, 5x and 6.
When I try to view local URI my application crashes with
I have fixed the problem locally the following:
src/android/PhotoActivity.java | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/android/PhotoActivity.java b/src/android/PhotoActivity.java
index 9a17c0c..dd6d8a8 100644
--- a/src/android/PhotoActivity.java
+++ b/src/android/PhotoActivity.java
@@ -135,7 +135,7 @@ public class PhotoActivity extends Activity {
*
*/
private void loadImage() {
if( imageUrl.startsWith("http") ) {
if( imageUrl.startsWith("http") || imageUrl.startsWith("file") ) {
Picasso.with(this)
.load(imageUrl)
.fit()
Because of Gradle it is not compatible with intel XDK. Is there a way to remove the Gradle?
Hi, i want to use with local image like: PhotoViewer.show('img/plan.jpg', 'Plan');
It's possible?
Thanks!
Is this plugin still in active development? I would love to implement it but when looking at the issues this doesn't seem to be a good idea at this point.
When can we expect some prioritising of open issues and bug fixes? :)
to make this one here more public. you deserve it!
As suggested in #3, own issue for that:
Ability to pass more than 1 image (like a gallery)
var images =
{
url: 'http....',
title: 'My nice title', // or empty
saveAble: true/false (just an idea)
},
{
url:
...
...
}
But I'm not sure if UIDocumentController can handle multiple images..
After having read the code, there seems to be no reason for requiring external storage permissions except wanting to write to the downloads folder?
Couldn't this just as easily use getDownloadCacheDirectory
or getDataDirectory
to get a folder that does not require these permissions? I am not an Android developer, so I don't know the specifics of what requires permission, but these seem to be safe.
if so, it's another good way for presenting image faster.
-pre-compile:
-compile:
[javac] Compiling 13 source files to /project/bin/classes
[javac] /project/src/com/sarriaroman/PhotoViewer/PhotoActivity.java:3: error: package uk.co.senab.photoview does not exist
[javac] import uk.co.senab.photoview.PhotoViewAttacher;
[javac] ^
[javac] /project/src/com/sarriaroman/PhotoViewer/PhotoActivity.java:19: error: package com.squareup.picasso does not exist
[javac] import com.squareup.picasso.Picasso;
[javac] ^
[javac] /project/src/com/sarriaroman/PhotoViewer/PhotoActivity.java:26: error: cannot find symbol
[javac] private PhotoViewAttacher mAttacher;
[javac] ^
[javac] symbol: class PhotoViewAttacher
[javac] location: class PhotoActivity
[javac] /project/src/com/sarriaroman/PhotoViewer/PhotoActivity.java:94: error: cannot find symbol
[javac] mAttacher = new PhotoViewAttacher(photo);
[javac] ^
[javac] symbol: class PhotoViewAttacher
[javac] location: class PhotoActivity
[javac] /project/src/com/sarriaroman/PhotoViewer/PhotoActivity.java:127: error: package com.squareup.picasso does not exist
[javac] .into(photo, new com.squareup.picasso.Callback() {
[javac] ^
[javac] /project/src/com/sarriaroman/PhotoViewer/PhotoActivity.java:125: error: cannot find symbol
[javac] Picasso.with(this)
[javac] ^
[javac] symbol: variable Picasso
[javac] location: class PhotoActivity
[javac] Note: /project/src/org/apache/cordova/splashscreen/SplashScreen.java uses or overrides a deprecated API.
[javac] Note: Recompile with -Xlint:deprecation for details.
[javac] 6 errors
BUILD FAILED
/android-sdk/tools/ant/build.xml:716: The following error occurred while executing this line:
/android-sdk/tools/ant/build.xml:730: Compile failed; see the compiler error output for details.
Option to hide and show share button on Android is added and it works fine and if possible can you provide solution for IOS also to disable share and download the image via java script flag. Thanks
I view the photo from url. but it will need to get the internal photo permission.
please consider to disable getPermission() when get photo from url.
As a user. i believe they may feel suspicious and delete the app because of the unnecessary popup permission.
Hi @sarriaroman,
when I open an image on iOS with a title, and the next time, I open one without a title, it will show the last title (I guess you need to reset some var on re-open)
I have tried to open gif image with it's url but the result is not animated.
It could be great to support gif.
Thank you for your plugin anyway !
After I add the plugin, I cant make any Ajax calls to my end points which returns JSON. All Ajax calls fails with timeout or is stuck with pending for a long time. Once I remove this plugin everything works again without any changes. I don't see any logs in my console and also I am not even using the methods exposed by this plugin anywhere in my source.
I'm using this plugin in a ionic project. I'm calling a function on ng-click event triggered on a element. The function calls "PhotoViewer.show(url);":
<a ng-click="openImage(attachment.path)">
<img src="{{attachment.thumbnail}}"/>
</a>
$scope.openImage = function(url)
{
PhotoViewer.show(url);
};
The first time I click the link the image is loaded successfully. The second and subsequent times I got a toast that says "Error loading image.". After that, any other link I click I got the same error message, so I need to restart my app.
I tried change the event from "ng-click" to "on-touch" and add a random GET parameter to my URL to avoid any cache. No success.
I also alerted the url that is sended to "openImage()" function and it is correct.
I'm running:
Cordova CLI 6.3.1
Ionic: 1.3
Ionic cli: 2.1.0
Android 4.4.2
Hi there,
I've followed a few posts and Ionic docs in using PhotoViewer, below is my code so far. The URL is passed okay but after tapping on the image - it will get stuck permanently with a loading spinner with no way of getting out. Any hints or clues as to why this might be happening?
Any help would be greatly appreciated.
`
import { PhotoViewer } from 'ionic-native';
@component({
selector: 'hero-image',
template: <div class="show-detail-image" [style.background-image]="'url(' + model.item.image + ')'" tappable> <img class="show-detail-image" [src]="model.item.image" (click)="viewFullScreenImage('url(' + model.item.image + ')', 'Detail View')"/> <ion-row class="hero-image-header-container"> <ion-col> <h6 class="hero-image-content-header"> {{model.item.name}} </h6> </ion-col> </ion-row> </div>
,
directives: [ ProtectedDirective ]
})
export class HeroImageComponent {
@input() public model:Param;
public PhotoViewer: any;
constructor(
private _platform: Platform
) {
}
viewFullScreenImage(image: string, title?: string): void {
console.log('View Image in Fullscreen clicked');
this._platform.ready()
.then(() => {
if (PhotoViewer)
PhotoViewer.show(image, title);
})
console.log('Image', image);
}
`
Here is the log..
`:dexDebug
UNEXPECTED TOP-LEVEL EXCEPTION:
com.android.dex.DexException: Multiple dex files define Landroid/support/v4/accessibilityservice/AccessibilityServiceInfoCompat$AccessibilityServiceInfoVersionImpl;
at com.android.dx.merge.DexMerger.readSortableTypes(DexMerger.java:579)
at com.android.dx.merge.DexMerger.getSortedTypes(DexMerger.java:535)
at com.android.dx.merge.DexMerger.mergeClassDefs(DexMerger.java:517)
at com.android.dx.merge.DexMerger.mergeDexes(DexMerger.java:164)
at com.android.dx.merge.DexMerger.merge(DexMerger.java:188)
at com.android.dx.command.dexer.Main.mergeLibraryDexBuffers(Main.java:504)
at com.android.dx.command.dexer.Main.runMonoDex(Main.java:334)
at com.android.dx.command.dexer.Main.run(Main.java:277)
at com.android.dx.command.dexer.Main.main(Main.java:245)
at com.android.dx.command.Main.main(Main.java:106)
FAILED
FAILURE: Build failed with an exception.
What went wrong:
Execution failed for task ':dexDebug'.
com.android.ide.common.internal.LoggedErrorException: Failed to run command:
/Users/yaoxingtang/Library/Android/sdk/build-tools/23.0.2/dx --dex --no-optimize --output /Users/yaoxingtang/maybi/maybi-ionic/platforms/android/build/intermediates/dex/debug --input-list=/Users/yaoxingtang/maybi/maybi-ionic/platforms/android/build/intermediates/tmp/dex/debug/inputList.txt
Error Code:
2
Output:
UNEXPECTED TOP-LEVEL EXCEPTION:
com.android.dex.DexException: Multiple dex files define Landroid/support/v4/accessibilityservice/AccessibilityServiceInfoCompat$AccessibilityServiceInfoVersionImpl;
at com.android.dx.merge.DexMerger.readSortableTypes(DexMerger.java:579)
at com.android.dx.merge.DexMerger.getSortedTypes(DexMerger.java:535)
at com.android.dx.merge.DexMerger.mergeClassDefs(DexMerger.java:517)
at com.android.dx.merge.DexMerger.mergeDexes(DexMerger.java:164)
at com.android.dx.merge.DexMerger.merge(DexMerger.java:188)
at com.android.dx.command.dexer.Main.mergeLibraryDexBuffers(Main.java:504)
at com.android.dx.command.dexer.Main.runMonoDex(Main.java:334)
at com.android.dx.command.dexer.Main.run(Main.java:277)
at com.android.dx.command.dexer.Main.main(Main.java:245)
at com.android.dx.command.Main.main(Main.java:106)
Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
BUILD FAILED
Total time: 27.942 secs
/Users/yaoxingtang/maybi/maybi-ionic/platforms/android/cordova/node_modules/q/q.js:126
throw e;
^
Error code 1 for command: /Users/yaoxingtang/maybi/maybi-ionic/platforms/android/gradlew with args: cdvBuildDebug,-b,/Users/yaoxingtang/maybi/maybi-ionic/platforms/android/build.gradle,-Dorg.gradle.daemon=true
ERROR building one of the platforms: Error: /Users/yaoxingtang/maybi/maybi-ionic/platforms/android/cordova/build: Command failed with exit code 1
You may not have the required environment or OS to build this project
Error: /Users/yaoxingtang/maybi/maybi-ionic/platforms/android/cordova/build: Command failed with exit code 1`
Help
I have been trying to get rid of the share-image button, as it does makes no sense to share an image in my application. I tried to delete the ImageButton tag in the activity_photo.xml, but this does not change anything.
Could somebody help me with this?
Thank you!
which is not suitable for retrieving from network urls - it caused hard crashes in my app when there were network failures
not a big deal - it's easy enough to use cordova-file-transfer to retrieve a remote-url and then photoviewer to view the local file:///
url
this should be mentioned in the README i think
First of all, thanks for the Plugin.
I wonder if it is possible to preserve the aspect ratio of the image - the image always stretches over the whole width and height of the screen.
Is this possible?
Thanks.
Hello,
I have installed photoviewer ionic-native extension. But i am getting below error, please check.
TypeScript error: /Users/AdityaBatra/Documents/ionic/sidemenuapp/app/pages/placeinfo/placeinfo.ts(4,10): Error TS2305: Module '"/Users/AdityaBatra/Documents/ionic/sidemenuapp/node_modules/ionic-native/dist/index"' has no exported member 'PhotoViewer'.
When I use the file-uri resource from cordova file plugin, the image will not load. It works fine on iOS, but not on android. Path is something like this:
content://media/external/images/media/...
navigator.camera.getPicture(function( imgdata )
{
//console.log(imgdata);
if (imgdata.substring(0,21)=="content://com.android") {
photo_split=imgdata.split("%3A");
imgdata = "content://media/external/images/media/"+photo_split[1];
}
Src of my image is "imagedata", which works perfectly fine. But sadly it does not show in the PhotoViewer. Seems like iOS UIDocumentationController will automatically handle internal urls
Is it possible to have a download button on Android as well?
I'm using this plugin in a ionic project that uses https://github.com/shprink/ionic-native-transitions.
After I open and close an image using Photoviewer, the first time I click on an back button in my app results in crash. If I uninstall NativePageTransitions plugin, everything goes ok.
I'm running:
Cordova CLI 6.3.1
Ionic: 1.3
Ionic cli: 2.1.0
Android 4.4.2
Hi! I'm using the plugin in an Ionic 2 app, and I'm building now an PWA.
When the app tries to use the Photo Viewer, the browser outputs the following:
Error: exec proxy not found for :: PhotoViewer :: show
Is there any way to use it in the browser, or it depends on cordova (and the best is check which is the environment, and if it is browser, don't use the Photo Viewer)?
Thanks in advance!
Since the iOS source requires the use of Cocoapods, the Cordova CLI tool cannot compile:
ld: library not found for -lPods-AFNetworking clang: error: linker command failed with exit code 1 (use -v to see invocation)
As a result I have to fork this project and strip out the iOS code.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.