Merge pull request #1099 from mozilla/android-implement-share-card

Fix #888 Implement share card.
This commit is contained in:
Danny Coates 2019-01-16 13:26:41 -08:00 committed by GitHub
commit a6a8fa6528
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 50 additions and 7 deletions

View file

@ -35,6 +35,11 @@ class WebAppInterface(private val mContext: MainActivity) {
fun beginOAuthFlow() {
mContext.beginOAuthFlow();
}
@JavascriptInterface
fun shareUrl(url: String) {
mContext.shareUrl(url)
}
}
class MainActivity : AppCompatActivity(), AdvancedWebView.Listener {
@ -94,6 +99,14 @@ class MainActivity : AppCompatActivity(), AdvancedWebView.Listener {
})
}
fun shareUrl(url: String) {
val shareIntent = Intent()
shareIntent.action = Intent.ACTION_SEND
shareIntent.type = "text/plain"
shareIntent.putExtra(Intent.EXTRA_TEXT, url);
startActivity(Intent.createChooser(shareIntent, ""))
}
@SuppressLint("NewApi")
override fun onResume() {
super.onResume()