-
-
Notifications
You must be signed in to change notification settings - Fork 245
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
🖼️ ISSUE-119 Share Note as image #269
🖼️ ISSUE-119 Share Note as image #269
Conversation
Thanks for adding output media @ch8n 😃 |
<provider | ||
android:name="androidx.core.content.FileProvider" | ||
android:authorities="com.ch8n.fileprovider" | ||
android:exported="false" | ||
android:grantUriPermissions="true"> | ||
<meta-data | ||
android:name="android.support.FILE_PROVIDER_PATHS" | ||
android:resource="@xml/provider_paths" /> | ||
</provider> |
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.
@ch8n I guess we don't need a provider since we are just sharing images from intent.
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.
means in simpleapp module, we didn't use this. So can we make it common across both?
<?xml version="1.0" encoding="UTF-8"?> | ||
<module type="JAVA_MODULE" version="4"> | ||
<component name="NewModuleRootManager" inherit-compiler-output="true"> | ||
<exclude-output /> | ||
<content url="file://$MODULE_DIR$" /> | ||
<orderEntry type="inheritedJdk" /> | ||
<orderEntry type="sourceFolder" forTests="false" /> | ||
</component> | ||
</module> |
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.
Can you just remove this file change from git?
suspend fun saveImage(image: Bitmap, context: Context): Uri? = | ||
withContext(Dispatchers.IO) { | ||
val imagesFolder = File(context.cacheDir, "images") | ||
var uri: Uri? = null | ||
try { | ||
imagesFolder.mkdirs() | ||
val file = File(imagesFolder, "shared_image.png") | ||
val stream = FileOutputStream(file) | ||
image.compress(Bitmap.CompressFormat.PNG, 90, stream) | ||
stream.flush() | ||
stream.close() | ||
uri = FileProvider.getUriForFile(context, "com.ch8n.fileprovider", file) | ||
} catch (e: IOException) { | ||
Log.d("Error", "IOException while trying to write file for sharing: " + e.message) | ||
} | ||
uri | ||
} |
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.
@ch8n we have common utility for this
https://github.com/PatilShreyas/NotyKT/blob/master/noty-android/app/src/main/java/dev/shreyaspatil/noty/utils/FileUtils.kt
So we can remove this. Also, we need to handle storage permission
|
||
<provider | ||
android:name="androidx.core.content.FileProvider" | ||
android:authorities="com.ch8n.fileprovider" |
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.
Let's make it app-specific:
android:authorities="com.ch8n.fileprovider" | |
android:authorities="${applicationId}.FileProvider" |
@Composable | ||
fun CaptureBitmap( | ||
content: @Composable () -> Unit, | ||
): () -> Bitmap { |
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.
Generally composable function (especially when holding UI) should not return a value but this is an exceptional case I guess where we need action based returned value. Nice! 😃
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.
LGTM 😃 @ch8n. Thank you so much for this awesome PR. Merging this in feature branch, will do some small improvements and refactoring. Will be targetting this change for upcoming release. Feel free to contribute again 😉
Summary
Added share Note as Image feature #119
Description for the changelog
latest
composable bitmapPreview
WhatsApp.Video.2021-10-16.at.2.27.55.PM.mp4
Checklist