mozilla-b2g/gaia — pull request #6157 by davidflanagan (2012-11-02 23:19:20+00:00)
Title: Bug 796729: convert open activity to use blobs

This pull request modifies the gallery's open activity so that it expects to receive a blob rather than a device storage filename. This allows gallery to display an image using a separate entry point and without every starting up the mediadb library, and so in addition to just being a better way to do it, it should improve the responsiveness of the activity.

The code to handle open has been moved from gallery.js into open.js, and this PR also creates open.html and open.css file as well. Also, the PhotoState class has moved from gallery.js into a file of its own so that both index.html and open.html can include it.

This PR also modifies the camera and email apps to pass blobs instead of filenames.

A few other modifications to the camera app were necessary as well:

1) It didn't seem to be shutting off the preview stream while the open activity was in progress, so I added explicit code to do that.

2) The thumbnails in the filmstrip were too hard for me to tap at 40x40, so I made them bigger and reduced the padding around them.

3) There were a couple of bugs in the filmstrip code that was preventing the click event handler from firing correctly.

There is a hack in this code because the camera and email apps want to use the open activity differently. The camera/gallery UX specs say that the preview of a photo should include a button to go back to the camera and another button to delete the photo. But the email app doesn't want either of those buttons.

By default, therefore, the open activity just displays a back button in a header at the top of the screen. If the activity includes the property show_delete_button: true, then we assume that we're invoked by the camera and display the two buttons that the camera wants.

Its kind of ironic to attach a PR with that kind of hack to the "Sanitize Web Activities" bug... I could easily convert this to hang the special behavior off of a different activity name if we want... It could be "open-from-camera" or something, if anyone has an opinion.