murraycu / android-galaxyzoo

This Android app lets you classify Galaxy Zoo subjects. It is available in the Google Play Store: https://play.google.com/store/apps/details?id=com.murrayc.galaxyzoo.app . Try beta versions early here: https://play.google.com/apps/testing/com.murrayc.galaxyzoo.app . See also the iPhone app for Galaxy Zoo: https://github.com/murraycu/ios-galaxyzoo/
GNU General Public License v3.0
11 stars 13 forks source link

feat: share image directly via share menu item #35

Closed avitaker closed 7 years ago

avitaker commented 7 years ago

Solves issue #30.

Previously, there were permission problems from trying to share the image to image sharing apps, according to the issue tracker. The following changes were made: FileProvider class is defined in AndroidManifest, along with the required meta-data and associated files (a string was added to strings.xml for the provider authority). This is apparently required for sharing streams in Android M and above. Temporary file of the image is written to keep track of exact file location, as well as have a temporary cache of previously shared images. This is done in an AsyncTask that is defined at the bottom of SubjectFragment and executed in the updateShareIntent method. In devices with Android M or above, explicit permission to write and read images is obtained if not already provided. The FileProvider class is used to create the URI that will eventually be sent in the intent. An intent flag is added for purposes of magic (I'm not really sure what it does, but it works).

In the limited use case of trying to share images, this code works. Additional changes might be required to distinguish text from image intents to share, because the code right now will set the share intent to an image type if mUriStandardRemote is not null.

murraycu commented 7 years ago

Thanks. Could you squash these commits into one, please? It looks great.

murraycu commented 7 years ago

Is https://github.com/murraycu/android-galaxyzoo/pull/36 the new version of this?

avitaker commented 7 years ago

Yes, #36 is the new version of this. I fixed the issues you brought up on that one

murraycu commented 7 years ago

OK. Next time, you don't need to create a new issue. You can just force push your changes to your existing branch and they will show up in the existing issue. At least that's how I usually do it.