Discussion Forums  >  Plugins, Customizing, Source Code

Replies: 59    Views: 532

Paul Rogers
Android Fan
Profile
Posts: 2524
Reg: May 30, 2011
UK
35,740
11/22/12 11:18 AM (11 years ago)

Android Image Gallery html5/css/javascript

*EDIT - Just been reminded by @ictguy that BTMods have an Android Image Gallery (https://www.buzztouchmods.com/downloads.php?cat_id=1&download_id=28). I recommend using the native plugin, but if you have problems with it, this is still a pretty nifty alternative. Download: https://dl.dropbox.com/u/56760890/gallery.zip unzip it and add the whole gallery folder to your projects assets folder. To use it with a customURL, the url will be file:///android_asset/gallery/gallery/gallery.html Use your favourite code editor to add image urls to the gallery.html file. If you scroll to the bottom of that file, it's pretty self explanatory, it's just a simple unordered list. To make it all offline add an 'images' folder to the same directory as the gallery.html file and put all your images in it. In this case, the urls you add to the gallery.html file will look like /images/image1.jpg You can add as many images as you like and there's no need to resize them, although the thumbnail screen looks better if the images are all the same height. Because it's html, you don't need to add the gallery to the assets folder, it can be hosted anywhere, but it's light enough (under 400kb) to be used in the assets folder for offline use. The code isn't mine, but it's licensed for any sort of use, please retain the copyrights in the files. All I've done is a bunch of minifying and modifying to make it work well in an app. Here's an example, click a thumbnail to enter the gallery (you can see how it doesn't look so good if image heights are different): https://dl.dropbox.com/u/56760890/gallery/gallery/gallery.html The gallery images are left/right swipable and it also has left/right buttons, a slideshow button and close button. Enjoy!
 
GoNorthWest
buzztouch Evangelist
Profile
Posts: 8197
Reg: Jun 24, 2011
Oro Valley, AZ
1,000,000
like
11/22/12 11:19 AM (11 years ago)
That rocks! Thanks, @raveyd!
 
Paul Rogers
Android Fan
Profile
Posts: 2524
Reg: May 30, 2011
UK
35,740
like
11/22/12 11:20 AM (11 years ago)
How'd you reply so soon! Thanks Mark, hope it's useful.
 
Paul Rogers
Android Fan
Profile
Posts: 2524
Reg: May 30, 2011
UK
35,740
like
11/22/12 11:37 AM (11 years ago)
I forgot to mention, you can further improve performance on newer devices by updating the customURL manifest entry. To add hardware acceleration, change it to: <activity android:name=".BT_screen_customURL" android:label="@string/app_name" android:configChanges="keyboardHidden|orientation" android:hardwareAccelerated="true"></activity>
 
kmobile
Code is Art
Profile
Posts: 56
Reg: Jun 19, 2012
Kingston
7,960
like
11/22/12 11:47 AM (11 years ago)
Dude you're awesome! I was just about to come on the forum to shout out to all the real coders (not me LOL) about how there is definitely a need for an image gallery plugin for android and this is the first post I see! Gonna try it out right now, thanks a heap
 
Paul Rogers
Android Fan
Profile
Posts: 2524
Reg: May 30, 2011
UK
35,740
like
11/22/12 11:53 AM (11 years ago)
Excellent! You should find it pretty straightforward @kmobile, but if you have any problems post in the thread and I'll attempt to help.
 
Sandeep
Android Fan
Profile
Posts: 1260
Reg: Feb 01, 2012
Miraj, India
25,250
like
11/22/12 11:56 AM (11 years ago)
Amazing. I use photoswipe in some of my projects as gallery option since we dont have a photo gallery plugin yet for android. You have bundled all the files of photoswipe which would be easy to use and save a lot of time. Thanks a ton.
 
Paul Rogers
Android Fan
Profile
Posts: 2524
Reg: May 30, 2011
UK
35,740
like
11/22/12 12:02 PM (11 years ago)
Thanks Sandeep! That's the one! I was using it 'out of the box' but performance wasn't great in an app and it was over 1mb. I've minified quite a lot of it and performance is greatly improved. It can be minified further but I started to lose track of the changes and thought I'd better stop before breaking it!
 
Sandeep
Android Fan
Profile
Posts: 1260
Reg: Feb 01, 2012
Miraj, India
25,250
like
11/22/12 12:05 PM (11 years ago)
Cool. I noticed that there were few files and all the relevant code relating to those .js files were integrated in the html file itself. You really rock.
 
mysps
Code is Art
Profile
Posts: 2082
Reg: May 14, 2011
Palma
33,320
like
11/22/12 12:07 PM (11 years ago)
Good stuff @raveyd!! thanks
 
Paul Rogers
Android Fan
Profile
Posts: 2524
Reg: May 30, 2011
UK
35,740
like
11/22/12 12:12 PM (11 years ago)
yeah, the ultimate aim was to get every file into a single file, but when javascripts start referencing other javascripts and css it gets too complicated for me! Thanks @mysps!
 
coderx
Veteran developer
Profile
Posts: 433
Reg: Oct 29, 2011
Ontario, Canada
8,680
like
11/22/12 01:56 PM (11 years ago)
Very creative. Good stuff!!
 
LA
Aspiring developer
Profile
Posts: 3278
Reg: Aug 16, 2012
Jerseyville, IL
42,880
like
11/22/12 03:16 PM (11 years ago)
Thank you so much @raveyd! LA
 
buzzbt
Android Fan
Profile
Posts: 233
Reg: Nov 14, 2011
las vegas
6,530
like
11/22/12 10:09 PM (11 years ago)
Thanks raveyd!
 
ictguy
Aspiring developer
Profile
Posts: 564
Reg: Jun 17, 2011
Mildura, Austra...
15,840
like
11/23/12 03:13 AM (11 years ago)
Thanks @raveyd, I was using the BTMods image gallery for android but it was causing a few crashes on various devices and emulators. Just installed your code, added images and everything works. Perfect timing :) Thanks again. Cheers Darrel
 
Paul Rogers
Android Fan
Profile
Posts: 2524
Reg: May 30, 2011
UK
35,740
like
11/23/12 04:59 AM (11 years ago)
Ah, I'd forgotten about the BTMods image gallery - sorry @MRDavid! I tried it ages ago and couldn't get it to work on Android. OP updated. Thanks for reminding me @ictguy! Thanks to everyone for replying! :)
 
Intrege
Veteran developer
Profile
Posts: 196
Reg: Sep 12, 2011
Philadelphia, P...
3,160
like
11/23/12 09:12 AM (11 years ago)
Thanks raveyd! Good one.
 
stonesfan71
Aspiring developer
Profile
Posts: 15
Reg: Nov 23, 2012
Voorhees, NJ
4,750
like
12/11/12 08:14 AM (11 years ago)
Guys I'm trying to make this an offline image gallery as it is instructed. I'm setting it up so when you tap one of the menu options it loads the gallery. When I created my menu list, I set the menu option so it would go to the custom html/text file of that name. The problem I'm having is in the emulator when I tap the menu option it loads the custom html/text screen. All that I see is the "html" text in text format and not the images. I think I'm running into a configuration issue. Any suggestions? Thanks Marc
 
Paul Rogers
Android Fan
Profile
Posts: 2524
Reg: May 30, 2011
UK
35,740
like
12/11/12 09:14 AM (11 years ago)
You're using customHTML plugin? It should be customURL plugin. The url to enter in the customURL plugin is: file:///android_asset/gallery/gallery/gallery.html, if you've dropped the whole downloaded folder into the assets folder of your project.
 
stonesfan71
Aspiring developer
Profile
Posts: 15
Reg: Nov 23, 2012
Voorhees, NJ
4,750
like
12/11/12 10:34 AM (11 years ago)
OK. Let me modify tonight and I will let you know how I make out. Thanks Marc
 
stonesfan71
Aspiring developer
Profile
Posts: 15
Reg: Nov 23, 2012
Voorhees, NJ
4,750
like
12/12/12 07:58 PM (11 years ago)
raveyd, I made the change from customHTML to customURL and when I run the emulator I see all of the images that the file path points to. I don't see image one by one or any any of the left/right swipable or left/right buttons etc. The gallery file is just dropped into the assets folder as you described. Anything I'm missing to get this to work? Thanks Marc
 
Paul Rogers
Android Fan
Profile
Posts: 2524
Reg: May 30, 2011
UK
35,740
like
12/13/12 05:58 AM (11 years ago)
Have you clicked an image?
 
stonesfan71
Aspiring developer
Profile
Posts: 15
Reg: Nov 23, 2012
Voorhees, NJ
4,750
like
12/13/12 08:14 PM (11 years ago)
raveyd Got it now. I was missing h ref tags to the images. Working great now. Love this plug in!!!! Thanks Marc
 
Paul Rogers
Android Fan
Profile
Posts: 2524
Reg: May 30, 2011
UK
35,740
like
12/14/12 05:53 AM (11 years ago)
Excellent! Glad you got it sorted, I was beginning to think I'd messed it up somehow!
 
Aaron636r
Aspiring developer
Profile
Posts: 246
Reg: Mar 08, 2011
California
3,160
like
12/19/12 10:48 AM (11 years ago)
Question on this. My company makes rear seat entertainment products for vehicles (tv's). I want to be able to use customer images that are emailed to us of our product installed on their car. On this setup I would have to update the APK every time I add an image...correct? Which isn't a feasible option as id have many images to throw into it on a weekly basis. Suggestions?
 
Sandeep
Android Fan
Profile
Posts: 1260
Reg: Feb 01, 2012
Miraj, India
25,250
like
12/19/12 10:54 AM (11 years ago)
NO need to update the apk all the time you add a new image ti the gallery. You jaust have to make the index html file online (get it hosted on some server or dropbox) instead of adding it locally, thats it.
 
Paul Rogers
Android Fan
Profile
Posts: 2524
Reg: May 30, 2011
UK
35,740
like
12/19/12 11:09 AM (11 years ago)
Thanks @Sandeep! Yes @Aaron636r, just drop the whole folder into a server or dropbox and put the url in the customURL. Update the gallery.html whenever you have new images. The users won't even need to refresh the app to get new images.
 
Aaron636r
Aspiring developer
Profile
Posts: 246
Reg: Mar 08, 2011
California
3,160
like
12/19/12 12:04 PM (11 years ago)
Awesome!!!!!!
 
photoserge
Aspiring developer
Profile
Posts: 146
Reg: Jan 01, 2012
paris
5,410
like
03/16/13 06:10 AM (11 years ago)
Hello guys, this seems to be a great plug in, but I must be doing something wrong as my image don't show up I have a questions mark instead. I dont want the image to be hosted on the web, I want them to be local so i did the following step : 1. I copied the gallery zip file into assest (and not BT_docs) 2. in the same folder that have the gallery.html I have a gal folder with all my photos and they are filed named photo1.jpg photo2.jpg 3. Here is how I ref them in the galery.html file : <div id="MainContent"> <ul id="Gallery" class="gallery"> <li><a href="/gal/photo1.jpg"><img src="/gal/photo1.jpg" /></a></li> <li><a href="/gal/photo2.jpg"><img src="/gal/photo2.jpg" /></a></li> <li><a href="/gal/photo3.jpg"><img src="/gal/photo3.jpg" /></a></li> <li><a href="/gal/photo4.jpg"><img src="/gal/photo4.jpg" /></a></li> <li><a href="/gal/photo5.jpg"><img src="/gal/photo5.jpg" /></a></li> <li><a href="/gal/photo6.jpg"><img src="/gal/photo6.jpg" /></a></li> <li><a href="/gal/photo7.jpg"><img src="/gal/photo7.jpg" /></a></li> <li><a href="/gal/photo8.jpg"><img src="/gal/photo8.jpg" /></a></li> <li><a href="/gal/photo9.jpg"><img src="/gal/photo9.jpg" /></a></li> <li><a href="/gal/photo10.jpg"><img src="/gal/photo10.jpg" /></a></li> <li><a href="/gal/photo11.jpg"><img src="/gal/photo11.jpg" /></a></li> <li><a href="/gal/photo12.jpg"><img src="/gal/photo12.jpg" /></a></li> <li><a href="/gal/photo13.jpg"><img src="/gal/photo13.jpg" /></a></li> <li><a href="/gal/photo14.jpg"><img src="/gal/photo14.jpg" /></a></li> <li><a href="/gal/photo15.jpg"><img src="/gal/photo15.jpg" /></a></li> </ul> but it doesn't work, I'm sure Im doing something wrong, but what ? tks so much Serge
 
Paul Rogers
Android Fan
Profile
Posts: 2524
Reg: May 30, 2011
UK
35,740
like
03/16/13 07:25 AM (11 years ago)
A question mark usually means the path to the image is wrong, but you've got the correct path if the 'gal' folder is in the same folder as the gallery.html... I think it will work if you remove the first forward slash - gal/photo1.jpg instead of /gal/photo1.jpg for both the link and the source.
 
photoserge
Aspiring developer
Profile
Posts: 146
Reg: Jan 01, 2012
paris
5,410
like
03/16/13 07:41 AM (11 years ago)
Hey tks so much raveryd, it works that was simple ! one more question I have a similar problem with photos in another screen, this time it is a custom html. In that screen I refer photos like that : <a href="https://www.youtube.com/cmoeu"> <img height="100px" src="youtube.png" width="220px" /></a> <br /> and the youtube.png is in the BT_docs folder, same things no image, where should I put my images ? tks ! Serge
 
Paul Rogers
Android Fan
Profile
Posts: 2524
Reg: May 30, 2011
UK
35,740
like
03/16/13 08:02 AM (11 years ago)
Great news Serge, I like simple! Where do you have the custom html document? Is it in the assets folder? If it is, you can treat the assets folder as you would a regular website directory. So if the html document is in the assets folder you could add an 'images' folder to the same directory, put the images in there and the path would be images/youtube.png Or... leave the images in the BT_docs folder and make the paths: BT_docs/youtube.png (I do it the first way because I always delete the BT folders in assets).
 
photoserge
Aspiring developer
Profile
Posts: 146
Reg: Jan 01, 2012
paris
5,410
like
03/16/13 08:20 AM (11 years ago)
Tks, that worked perfect ! merci :-) Serge
 
Paul Rogers
Android Fan
Profile
Posts: 2524
Reg: May 30, 2011
UK
35,740
like
03/16/13 08:37 AM (11 years ago)
No problem Serge, glad it worked! :)
 
RiverSteve
Android Fan
Profile
Posts: 43
Reg: Jun 01, 2013
Whanganui, New ...
11,080
like
06/15/13 01:19 AM (10 years ago)
Thanks pics
 
Cyrus_8888
I hate code!
Profile
Posts: 151
Reg: Dec 24, 2011
Sydney
1,610
like
06/16/13 04:35 AM (10 years ago)
Hi raveyd, this is awesome. Thank you so much for sharing. Regards, Cyrus
 
Paul Rogers
Android Fan
Profile
Posts: 2524
Reg: May 30, 2011
UK
35,740
like
06/16/13 07:10 AM (10 years ago)
Thanks Cyrus, nice to see some people using it. Would prefer to see a native plugin in the marketplace though!
 
Alex@TM
Apple Fan
Profile
Posts: 956
Reg: Dec 20, 2011
London, UK
10,560
like
07/10/13 03:51 PM (10 years ago)
Tried to get this to work with Copy, no joy, any advice please? Please see both screenshots if you are able, much obliged :) https://copy.com/EDTZH7ZVglEp https://copy.com/Jb1mIQEyYgbR Cheers
 
ictguy
Aspiring developer
Profile
Posts: 564
Reg: Jun 17, 2011
Mildura, Austra...
15,840
like
07/10/13 04:04 PM (10 years ago)
Hi, You need the URL to end in an image source like .jpg or .png Try to changing that URL to something like this https://www.copy.com/s/EDTZH7ZVglEp/Screen%20Shot%202013-07-10%20at%2023.47.08.png and see if it works. cheers
 
Alex@TM
Apple Fan
Profile
Posts: 956
Reg: Dec 20, 2011
London, UK
10,560
like
07/10/13 04:06 PM (10 years ago)
Wow, tremendously swift reply, thanks :) Just off to bed, will try in the morning and report back. Thanks again :)
 
Mosco
Apple Fan
Profile
Posts: 12
Reg: Dec 27, 2011
Virginia
120
like
07/10/13 04:38 PM (10 years ago)
edit
 
Alex@TM
Apple Fan
Profile
Posts: 956
Reg: Dec 20, 2011
London, UK
10,560
like
07/11/13 07:39 AM (10 years ago)
Is there a way of adding a save button for wallpaper creation? All the best.
 
Alex@TM
Apple Fan
Profile
Posts: 956
Reg: Dec 20, 2011
London, UK
10,560
like
07/11/13 12:03 PM (10 years ago)
@ictguy, Added .jpg to end of url and didnt work :( Tried the url you posted, didnt work. Any idea of the issue please? Cheers
 
Alex@TM
Apple Fan
Profile
Posts: 956
Reg: Dec 20, 2011
London, UK
10,560
like
07/11/13 12:17 PM (10 years ago)
@ictguy, Must be a copy.com issue, dropbox works :)
 
mysps
Code is Art
Profile
Posts: 2082
Reg: May 14, 2011
Palma
33,320
like
07/11/13 12:20 PM (10 years ago)
@Alex i have this working with flickr! pulling from the same like in iOS
 
Alex@TM
Apple Fan
Profile
Posts: 956
Reg: Dec 20, 2011
London, UK
10,560
like
07/11/13 12:21 PM (10 years ago)
I'll use flickr, thanks. This will get immense traffic so best start properly :) Any idea how to add a svae button? Cheers
 
mysps
Code is Art
Profile
Posts: 2082
Reg: May 14, 2011
Palma
33,320
like
07/11/13 12:35 PM (10 years ago)
nope i don't know unfortunately.. MGOBLUE had a solution for android to make it native but i could never figure it out.
 
Alex@TM
Apple Fan
Profile
Posts: 956
Reg: Dec 20, 2011
London, UK
10,560
like
07/11/13 12:43 PM (10 years ago)
Was that an adaption of this or something different? Cheers
 
Paul Rogers
Android Fan
Profile
Posts: 2524
Reg: May 30, 2011
UK
35,740
like
07/11/13 12:49 PM (10 years ago)
Hi Alex, I was hoping a native solution would be out by now, it's been 7 months! lol! A failing with photoswipe is that you can't long click an image to save it. There's a transparent layer over the image to allow swiping, but it also prevents long clicking. It was reported as an issue a long time ago, I haven't seen a resolution yet.. https://github.com/codecomputerlove/PhotoSwipe/issues/365
 
Alex@TM
Apple Fan
Profile
Posts: 956
Reg: Dec 20, 2011
London, UK
10,560
like
07/11/13 12:53 PM (10 years ago)
I cant get it working with flickr, maybe because the url doesnt end with .png/.jpg? Hope a solution is made, are android users able to screen grab? Not ideal but a way out I suppose :)
 
mysps
Code is Art
Profile
Posts: 2082
Reg: May 14, 2011
Palma
33,320
like
07/11/13 12:58 PM (10 years ago)
you have to add the flickr javascript files and the same flickr api json url that you use for the iOS gallery. when i have time i will add a tutorial. But it is based on the script that raveyd provided above and also a mix of what MGOblue posted. @raveyd.. i too have been waiting :( something native would be awesome i think its gonna be a longer wait until we get the new Android updates I'm afraid :/
 
Alex@TM
Apple Fan
Profile
Posts: 956
Reg: Dec 20, 2011
London, UK
10,560
like
07/11/13 01:02 PM (10 years ago)
I'm cool getting the flickr api json, i'll look for the javascript files, thanks.
 
Alex@TM
Apple Fan
Profile
Posts: 956
Reg: Dec 20, 2011
London, UK
10,560
like
07/11/13 01:03 PM (10 years ago)
Is there much to it?
 
mysps
Code is Art
Profile
Posts: 2082
Reg: May 14, 2011
Palma
33,320
like
07/11/13 01:05 PM (10 years ago)
not really here is the post that mgoblue made: http://www.buzztouch.com/forum/thread.php?fid=0F89F7DF868EC9CB7A8A2EF&tid=0F89F7DF868EC9CB7A8A2EF mix this code above with the js scripts provided in mgoblues zip and you'll get it.
 
Alex@TM
Apple Fan
Profile
Posts: 956
Reg: Dec 20, 2011
London, UK
10,560
like
07/11/13 01:10 PM (10 years ago)
Thanks :)
 
Alex@TM
Apple Fan
Profile
Posts: 956
Reg: Dec 20, 2011
London, UK
10,560
like
07/11/13 01:29 PM (10 years ago)
@mysps - No BT_Screen_images in my android project!! GRRRRRRRRRR
 
Alex@TM
Apple Fan
Profile
Posts: 956
Reg: Dec 20, 2011
London, UK
10,560
like
07/11/13 01:30 PM (10 years ago)
Would that be BT_image.java?
 
Alex@TM
Apple Fan
Profile
Posts: 956
Reg: Dec 20, 2011
London, UK
10,560
like
07/11/13 01:32 PM (10 years ago)
Actually, there is no BT_Screen_image or BT_image .xml Balls.
 
mysps
Code is Art
Profile
Posts: 2082
Reg: May 14, 2011
Palma
33,320
like
07/11/13 02:28 PM (10 years ago)
I didn't do the entire mgoblue tutorial. I'm using a simple HTML screen. I'm not in front of the computer but either custom HTML or HTML doc.
 
Akshay
I hate code!
Profile
Posts: 193
Reg: Mar 07, 2013
Pune ,India
1,930
like
08/20/13 07:16 AM (10 years ago)
limitation of photoswipe:cant save pics i found solution for this in psmdannys post. http://tympanus.net/Tutorials/ResponsiveImageGallery/ by using this you can create swipable photo gallery with ability to save image and apply wallpaper.i accessed the above url from my tablet and it worked. but when i downloaded the folder containg html file,images,javascript,css...i put the whole folder into my tablet but it dint work . first i will have to get to work after putting the files in my tablet. after that i will have to put all together in bt project. help needed hope everything is clear akshay
 

Login + Screen Name Required to Post

pointerLogin to participate so you can start earning points. Once you're logged in (and have a screen name entered in your profile), you can subscribe to topics, follow users, and start learning how to make apps like the pros.