-
Notifications
You must be signed in to change notification settings - Fork 18
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
Add more context menu options to media gallery screen #350
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks really good! Just few concerns regarding how we copy the image to clipboard.
|
||
val inputStream = connection.getInputStream() | ||
val file = File( | ||
context.getExternalFilesDir(Environment.DIRECTORY_PICTURES), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should put in a cache folder instead. This will make it visible in the gallery app when you copy something.
val inputStream = connection.getInputStream() | ||
val file = File( | ||
context.getExternalFilesDir(Environment.DIRECTORY_PICTURES), | ||
"copied_image.png", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe we should not use an extension here since you don't know if it's going to be a png or something else.
@@ -13,3 +24,45 @@ fun copyText( | |||
val clip = ClipData.newPlainText(label, text) | |||
clipboard.setPrimaryClip(clip) | |||
} | |||
|
|||
suspend fun copyImageToClipboard(context: Context, imageUrl: String) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure if this is the best way to handle this situation. We already have a loaded image through Coil.
Maybe we can take the already rendered Bitmap
and store it in a cache folder of the app. Then use that file to expose Uri with FileProvider.getUriForFile
as you did below.
@@ -162,6 +167,16 @@ fun MediaGalleryScreen( | |||
onSaveClick = { | |||
currentImage()?.let { eventPublisher(MediaGalleryContract.UiEvent.SaveMedia(it)) } | |||
}, | |||
onMediaUrlCopyClick = { | |||
currentImage()?.url?.let { copyText(context = context, text = it) } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should probably copy the original url of the image and not the primal cdn.
To which url is currentImage()?.url
pointing to? Is it original or cdn link?
No description provided.