Finally !
During a long period of calm, I finally released a new version (with new features) of the Android client for remote galleries Gallery2 (your photos on your website), G2Android.
If you have a look at the G2Android project homepage, you will see that the following issues (bug and enhancements) have been closed :
Version 1.5.0, 19th of July 2010 Major release
- issue #33 Enable uploaded photo title modification
- issue #41 Malformed Gallery 2 URL leads to G2Android forced close
- issue #37 Uploaded photo looses .jpg file extension
- issue #42 Feature Suggestion: Provide automatic login when started
- issue #20 Share via camera app?
- issue #15 Enhancement: Add multiple photo uploading
The major new feature is clearly the « add photo to gallery » feature : I created a new Activity, UploadPhoto , which can be called from 2 external intents :
1 2 3 4 5 6 7 8 |
<activity android:name=".activity.UploadPhoto" android:label="@string/upload_photo_title" > <intent -filter> <action android:name="android.intent.action.SEND" /> <action android:name="android.intent.action.SEND_MULTIPLE" /> <category android:name="android.intent.category.DEFAULT" /> <data android:mimeType="image/*" /> </intent> </activity> |
So now the user can send a new photo or a batch of photos from another application, the android gallery app for example; the big work was then to decode the URIs of the photos to find the photo file on the phone, and then send it to the gallery; also I had to make sure that the user is still connected to the gallery, if not, he must login again.
Also, the user is now able to take a picture and send it to his gallery, without leaving g2android; this has been done adding the camera permission in the AndroidManifest.xml :
1 |
<uses -permission android:name="android.permission.CAMERA"></uses> |
This is the easy part
Then, when your app receive a photo from the Camera, it does not receive an URI pointing to a photo file; nope, you get a Bitmap object you have transform into a file, to be able to send it to the remote gallery :
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
Bundle extras = intent.getExtras(); Bitmap bm = null; Object o = extras.get("data"); if (o != null && o instanceof Bitmap) { bm = (Bitmap) o; try { StringBuilder stringBuilder = new StringBuilder(); stringBuilder.append(Settings .getG2AndroidPath(this)); stringBuilder.append("/"); StringBuilder stringBuilderFileName = new StringBuilder(); stringBuilderFileName.append(fileName); stringBuilderFileName .append(System.currentTimeMillis()); stringBuilderFileName.append(".jpg"); stringBuilder.append(stringBuilderFileName); imageFromCamera = new File( stringBuilder.toString()); FileOutputStream fos = new FileOutputStream( imageFromCamera); bm.compress(CompressFormat.JPEG, 100, fos); fos.flush(); fos.close(); mImageUri=Uri.fromFile(imageFromCamera); fileName = stringBuilderFileName.toString(); } catch (FileNotFoundException e) { ShowUtils.getInstance().alertFileProblem(e.getMessage(),this); } catch (IOException e) { ShowUtils.getInstance().alertFileProblem(e.getMessage(),this); } } |
I also optimized the application, issue #37 (Uploaded photo looses .jpg file extension) was in fact due to the fact that I re created the photo file before sending it; instead of using a projection of the URI to get its path on the phone :
1 2 3 4 5 6 7 8 9 |
public static String getFileNameFromUri(Uri uri, Activity activity) { String[] projection = { MediaStore.Images.ImageColumns.DISPLAY_NAME }; String fileName=null; Cursor c = activity.managedQuery(uri, projection, null, null, null); if (c != null && c.moveToFirst()) { fileName = c.getString(0); } return fileName; } |
Also shipping with this new version, Chinese i18n thanks to the chinese android market, GoAPK and also new art from Dan, who just posted a comment to the blog proposing to add new art; thanks again to you both ! You make the application richer !
So now, what remains to be done ? well, the compatibility with Gallery3, as the G3 remote API is almost stable now, thanks to the work of Bharat, Tim, and many others; a java implementation is already under work, I will check if I can use it instead of… re inventing the wheel !
More details to come, for sure !
You can download G2Android from the Android Market, SlideMe, Applibs, etc.. and also from the G2Android project homepage
.
Enjoy this app as much as I enjoy working on it, and if you like it, don’t forget to flattr me !
great app
thanks
Love the upload/share capabilities with the new version.
Any chance for zooming in/out when browsing the gallery?
This release is fantastic. Great App!
can’t wait for G3 support. oh please