Categories

G2Android 1.5.0 is available : major release !

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 :

AndroidManifest.xml

 <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 :

<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 :

UploadPhoto

                                                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 :

UriUtils

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 ;-) !

4 comments to G2Android 1.5.0 is available : major release !

Leave a Reply

  

  

  

You can use these HTML tags

<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre lang="" line="" escaped="" highlight="">