Skip to content
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

Open
murraycu opened this issue Mar 9, 2016 · 2 comments
Open

Share the image via the Share menu item #30

murraycu opened this issue Mar 9, 2016 · 2 comments

Comments

@murraycu
Copy link
Owner

murraycu commented Mar 9, 2016

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.

avitaker added a commit to avitaker/android-galaxyzoo that referenced this issue Apr 6, 2017
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.
avitaker added a commit to avitaker/android-galaxyzoo that referenced this issue Apr 7, 2017
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.
avitaker added a commit to avitaker/android-galaxyzoo that referenced this issue Apr 10, 2017
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.
avitaker added a commit to avitaker/android-galaxyzoo that referenced this issue May 13, 2017
commit 88c6d4d
Author: Avinash David <avitaker@gmail.com>
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 <avitaker@gmail.com>
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 <avitaker@gmail.com>
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.
murraycu pushed a commit that referenced this issue May 19, 2017
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.
murraycu pushed a commit that referenced this issue May 19, 2017
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.
@murraycu
Copy link
Owner Author

Fixed by pull request #36 :
#36

murraycu added a commit that referenced this issue Jun 13, 2017
@murraycu
Copy link
Owner Author

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.

@murraycu murraycu reopened this Jun 13, 2017
murraycu added a commit that referenced this issue Mar 18, 2018
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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant