-
Notifications
You must be signed in to change notification settings - Fork 13
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Share the image via the Share menu item #30
Comments
Solves issue murraycu#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 mUriImageRemote is not null.
Solves issue murraycu#30. Now added some documentation, removed some generated files and hardcoded strings. 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 mUriImageRemote is not null.
Solves issue murraycu#30. Now added some documentation, removed some generated files and hardcoded strings. 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 mUriImageRemote is not null.
commit 88c6d4d Author: Avinash David <[email protected]> Date: Sun Apr 9 23:44:16 2017 -0500 feat: share image directly via share menu item Solves issue murraycu#30. Now added some documentation, removed some generated files and hardcoded strings. 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 mUriImageRemote is not null. commit 8d31c99 Author: Avinash David <[email protected]> Date: Fri Apr 7 10:17:09 2017 -0500 feat: share image directly via share menu item Solves issue murraycu#30. Now added some documentation, removed some generated files and hardcoded strings. 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 mUriImageRemote is not null. commit 6c52efc Author: Avinash David <[email protected]> Date: Thu Apr 6 15:41:45 2017 -0500 feat: share image directly via share menu item Solves issue murraycu#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 mUriImageRemote is not null.
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.
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.
Unfortunately, SubjectFragment.updateShareActionIntent() is always called from onCreateOptionsMenu(), and updateShareActionIntent() always executes the GetImageBitmapAsyncTask, getting the image just in case the user wants to share it. That's unnecessary work in most cases and it causes us to ask the user for photos/files permission. We really should delay that permission request (and the actual downloading) until the user actually tries to share something. If I can't fix that, I'll have to revert this for now. Sorry. |
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.
The app now has a Share menu item, but it just shares the URI of the discussion page.
This branch tries to share the image itself, but it isn't working.
https://github.com/murraycu/android-galaxyzoo/commits/share-image
With that code, the Share menu item does nothing. If we comment out the intent.setData() line then we can share to other apps, but they then fail with errors or crashes, presumably due to lack of permission, though we are granting them permission.
The text was updated successfully, but these errors were encountered: