-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
[share_plus] Fix types, lower Android minSDK #797
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
Changes from all commits
3466bea
2e33bd8
029b93d
5c65831
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,71 +5,74 @@ import io.flutter.plugin.common.MethodChannel | |
import java.io.IOException | ||
|
||
/** Handles the method calls for the plugin. */ | ||
internal class MethodCallHandler(private val share: Share, private val manager: ShareSuccessManager) : MethodChannel.MethodCallHandler { | ||
internal class MethodCallHandler( | ||
private val share: Share, | ||
private val manager: ShareSuccessManager | ||
) : MethodChannel.MethodCallHandler { | ||
|
||
override fun onMethodCall(call: MethodCall, result: MethodChannel.Result) { | ||
when (call.method) { | ||
"share" -> { | ||
expectMapArguments(call) | ||
// Android does not support showing the share sheet at a particular point on screen. | ||
share.share( | ||
call.argument<Any>("text") as String, | ||
call.argument<Any>("subject") as String?, | ||
false, | ||
) | ||
result.success(null) | ||
} | ||
"shareFiles" -> { | ||
expectMapArguments(call) | ||
override fun onMethodCall(call: MethodCall, result: MethodChannel.Result) { | ||
when (call.method) { | ||
"share" -> { | ||
expectMapArguments(call) | ||
// Android does not support showing the share sheet at a particular point on screen. | ||
share.share( | ||
call.argument<Any>("text") as String, | ||
call.argument<Any>("subject") as String?, | ||
false, | ||
) | ||
result.success(null) | ||
} | ||
"shareFiles" -> { | ||
expectMapArguments(call) | ||
|
||
// Android does not support showing the share sheet at a particular point on screen. | ||
try { | ||
share.shareFiles( | ||
call.argument<List<String>>("paths")!!, | ||
call.argument<List<String>?>("mimeTypes"), | ||
call.argument<String?>("text"), | ||
call.argument<String?>("subject"), | ||
false, | ||
) | ||
result.success(null) | ||
} catch (e: IOException) { | ||
result.error(e.message, null, null) | ||
} | ||
} | ||
"shareWithResult" -> { | ||
expectMapArguments(call) | ||
if(!manager.setCallback(result)) return | ||
// Android does not support showing the share sheet at a particular point on screen. | ||
try { | ||
share.shareFiles( | ||
call.argument<List<String>>("paths")!!, | ||
call.argument<List<String>?>("mimeTypes"), | ||
call.argument<String?>("text"), | ||
call.argument<String?>("subject"), | ||
false, | ||
) | ||
result.success(null) | ||
} catch (e: IOException) { | ||
result.error("Share failed", e.message, null) | ||
} | ||
} | ||
"shareWithResult" -> { | ||
expectMapArguments(call) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. could these
Then it won't be necessary to bump the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think so. If anyone can submit a separated PR with a that change, that would be awesome! |
||
if (!manager.setCallback(result)) return | ||
|
||
// Android does not support showing the share sheet at a particular point on screen. | ||
share.share( | ||
call.argument<Any>("text") as String, | ||
call.argument<Any>("subject") as String?, | ||
true, | ||
) | ||
} | ||
"shareFilesWithResult" -> { | ||
expectMapArguments(call) | ||
if(!manager.setCallback(result)) return | ||
// Android does not support showing the share sheet at a particular point on screen. | ||
share.share( | ||
call.argument<Any>("text") as String, | ||
call.argument<Any>("subject") as String?, | ||
true, | ||
) | ||
} | ||
"shareFilesWithResult" -> { | ||
expectMapArguments(call) | ||
if (!manager.setCallback(result)) return | ||
|
||
// Android does not support showing the share sheet at a particular point on screen. | ||
try { | ||
share.shareFiles( | ||
call.argument<List<String>>("paths")!!, | ||
call.argument<List<String>?>("mimeTypes"), | ||
call.argument<String?>("text"), | ||
call.argument<String?>("subject"), | ||
true, | ||
) | ||
} catch (e: IOException) { | ||
result.error(e.message, null, null) | ||
// Android does not support showing the share sheet at a particular point on screen. | ||
try { | ||
share.shareFiles( | ||
call.argument<List<String>>("paths")!!, | ||
call.argument<List<String>?>("mimeTypes"), | ||
call.argument<String?>("text"), | ||
call.argument<String?>("subject"), | ||
true, | ||
) | ||
} catch (e: IOException) { | ||
result.error("Share failed", e.message, null) | ||
} | ||
} | ||
else -> result.notImplemented() | ||
} | ||
} | ||
else -> result.notImplemented() | ||
} | ||
} | ||
|
||
@Throws(IllegalArgumentException::class) | ||
private fun expectMapArguments(call: MethodCall) { | ||
require(call.arguments is Map<*, *>) { "Map arguments expected" } | ||
} | ||
@Throws(IllegalArgumentException::class) | ||
private fun expectMapArguments(call: MethodCall) { | ||
require(call.arguments is Map<*, *>) { "Map arguments expected" } | ||
} | ||
} |
Uh oh!
There was an error while loading. Please reload this page.