godot
godot copied to clipboard
Add support for iOS mobile share API
Recreating https://github.com/godotengine/godot/pull/90429 ability to share text and added rate in app option
Also I can add android version for share and rate, but seems like I have to add few functions into platform/android/display_server_android.cpp for it
class GodotShare(godot: Godot) : GodotPlugin(godot) {
private val logTag = "godot::GodotShare"
private val mimeTypeText = "text/plain"
private val mimeTypeImage = "image/*"
private val fileProvider = ".sharefileprovider"
override fun getPluginName() = "GodotShare"
@UsedByGodot
fun share(text: String, subject: String, title: String, path: String) {
//Log.d(logTag, "share() called with path $path")
val shareIntent = Intent(Intent.ACTION_SEND)
shareIntent.setType(mimeTypeImage)
shareIntent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION)
if (text.isNotEmpty()) {
shareIntent.putExtra(Intent.EXTRA_TEXT, text)
}
if (subject.isNotEmpty()) {
shareIntent.putExtra(Intent.EXTRA_SUBJECT, subject)
}
if (path.isNotEmpty()) {
val f = File(path)
val uri: Uri = try {
FileProvider.getUriForFile(activity!!, activity!!.packageName+fileProvider, f)
} catch (e: IllegalArgumentException) {
Log.e(logTag, "The selected file can't be shared: $path", e)
return
}
shareIntent.clipData = ClipData.newRawUri("", uri)
shareIntent.putExtra(Intent.EXTRA_STREAM, uri)
}
activity?.startActivity(Intent.createChooser(shareIntent, title))
}
}
Is it right approach to implement this Kotlin code as godot_java wrapper?
The last action on this PR was 7 months ago. Would be great to get this into the 4.5 Release. Why is there no action on this anymore? I cant see any comments with a reason why this cant be merged.
I cant see any comments with a reason why this cant be merged.
To me this feels like something that should be an iOS plugin. Or, at the very least, it should add a clearly iOS-only API, rather than a singleton with a very generic name (GodotShare) that only works on iOS.
On the Android side, I don't think we have anything like this built into Godot, it would be something done in an Android plugin, or now with JavaClassWrapper.
I have java Android plugin, we can discuss how it can be integrated into JavaClassWrapper