-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Correct sharing of image via share menu item.
Solves issue #30: #30 Previously, there were permission problems from trying to share the image to image sharing apps. * AndroidManifest: Define FileProvider class, 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. * SubjectFragment: Add a GetImageBitmapAsyncTask inner class to download the image in the background asynchronously. A temporary file of the image is written to keep track of exact file location, as well as to have a temporary cache of previously shared images. The FileProvider class is used to create the URI that will eventually be sent in the intent. A FLAG_GRANT_READ_URI_PERMISSION intent flag is added for purposes of magic (I'm not really sure what it does, but it works). * SubjectFragment.updateShareActionIntent(): Create the GetImageBitmapAsyncTask. In devices with Android M or above, explicit permission to write and read images is obtained if not already provided. 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 mUriImageRemote is not null.
- Loading branch information
Showing
5 changed files
with
115 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<paths xmlns:android="http://schemas.android.com/apk/res/android"> | ||
<!--The FileProvider class will draw from the root directory of the app's external storage area (specified by path="."), | ||
and the generated content URI will indicate that this directory is called "external_files" for security reasons.--> | ||
<external-path name="external_files" path="."/> | ||
</paths> |
This (my change) shouldn't have been in this commit, but that was my fault when cleaning up the commit before pushing.