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

Image preview in Android share sheet (Android 10+ only) #8143

Merged
merged 2 commits into from
May 22, 2022

Conversation

AudricV
Copy link
Member

@AudricV AudricV commented Apr 3, 2022

What is it?

  • Feature (user facing)

Description of the changes in your PR

This PR adds the image preview of contents shared in the Android share sheet, for Android 10+ devices. Note that it may be not shown, depending of the customizations made by your OEM on your Android device.

Images included in the share sheet will be only the ones in the memory image cache used by Picasso (the image library loader), in order to not have to handle network exceptions when sharing contents. If it is not loaded or no image preview is available, no image will be shown in the share sheet (like the current behavior).

The image of the content, before sharing, is compressed in JPEG 90 and saved inside the application cache folder under the name android_share_sheet_image_preview.jpg. The current image shared will be, of course, always overwritten by the next one and deleted when the application cache is cleared.

Before/After Screenshots/Screen Record

Before After
share_sheet_before share_sheet_after

Fixes the following issue(s)

Fixes the TODO (that I added) in ShareUtils:

/* TODO: add the image of the content to Android share sheet with setClipData after
generating a content URI of this image, then use ClipData.newUri(the content resolver,
null, the content URI) and set the ClipData to the share intent with
shareIntent.setClipData(generated ClipData).
if (!imagePreviewUrl.isEmpty()) {
//shareIntent.setFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
}*/

APK testing

The APK can be found by going to the "Checks" tab below the title. On the left pane, click on "CI", scroll down to "artifacts" and click "app" to download the zip file which contains the debug APK of this PR.

Due diligence

@AudricV AudricV added feature request Issue is related to a feature in the app GUI Issue is related to the graphical user interface device/software specific Issues that only happen on some devices or with some specific hardware/software labels Apr 3, 2022
@sonarcloud
Copy link

sonarcloud bot commented Apr 3, 2022

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

0.0% 0.0% Coverage
0.0% 0.0% Duplication

Copy link
Member

@Stypox Stypox left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please create two PRs: one for adding image previews and one for refactoring ShareUtils, please.

*
* @param context the context to use
* @param intent the intent to open
* @param isShareIntent set the title "Open with" to the chooser if true, else not
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
* @param isShareIntent set the title "Open with" to the chooser if true, else not
* @param isShareIntent set the title "Open with" to the chooser if false, else do not set any title

@Stypox Stypox closed this Apr 30, 2022
@AudricV AudricV reopened this May 14, 2022
These previews will be only available for images cached in the cache used by Picasso.
The Bitmap of the content is compressed in JPEG 90 and saved inside the application cache folder under the name android_share_sheet_image_preview.jpg.
The current image will be, of course, always overwritten by the next one and cleared when the application cache is cleared.
@sonarcloud
Copy link

sonarcloud bot commented May 22, 2022

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

0.0% 0.0% Coverage
0.0% 0.0% Duplication

Copy link
Member

@Stypox Stypox left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I pushed a small commit doing some little improvements. I tested many possible configurations on my Android 10 phone and it works as expected. Thank you for the research @TiA4f8R :-)

@Stypox Stypox merged commit 8c870cd into TeamNewPipe:dev May 22, 2022
@Stypox Stypox changed the title Add image preview of the content shared where possible in Android share sheet (for Android 10+ devices only) Image preview in Android share sheet (Android 10+ only) May 22, 2022
@AudricV AudricV deleted the image-preview-sharesheet branch May 22, 2022 20:04
@Stypox Stypox mentioned this pull request Jun 24, 2022
3 tasks
@Fs00 Fs00 mentioned this pull request Jul 26, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
device/software specific Issues that only happen on some devices or with some specific hardware/software feature request Issue is related to a feature in the app GUI Issue is related to the graphical user interface
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants