Merge pull request #245 from Binnette/ExtraSubject

Add EXTRA_SUBJECT when sharing link
This commit is contained in:
Amine Bou 2018-11-17 19:46:51 +01:00 committed by GitHub
commit b59c3bcb23
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 5 additions and 3 deletions

View File

@ -179,7 +179,8 @@ class ItemCardAdapter(
}) })
mView.shareBtn.setOnClickListener { mView.shareBtn.setOnClickListener {
c.shareLink(items[adapterPosition].getLinkDecoded()) val item = items[adapterPosition]
c.shareLink(item.getLinkDecoded(), item.title)
} }
mView.browserBtn.setOnClickListener { mView.browserBtn.setOnClickListener {

View File

@ -139,7 +139,7 @@ class ArticleFragment : Fragment() {
override fun onItemClick(item: MenuItem) { override fun onItemClick(item: MenuItem) {
when (item.itemId) { when (item.itemId) {
R.id.more_action -> getContentFromMercury(customTabsIntent, prefs) R.id.more_action -> getContentFromMercury(customTabsIntent, prefs)
R.id.share_action -> activity!!.shareLink(url) R.id.share_action -> activity!!.shareLink(url, contentTitle)
R.id.open_action -> activity!!.openItemUrl( R.id.open_action -> activity!!.openItemUrl(
allItems, allItems,
pageNumber.toInt(), pageNumber.toInt(),

View File

@ -25,11 +25,12 @@ fun String.toStringUriWithHttp(): String =
this this
} }
fun Context.shareLink(itemUrl: String) { fun Context.shareLink(itemUrl: String, itemTitle: String) {
val sendIntent = Intent() val sendIntent = Intent()
sendIntent.flags = Intent.FLAG_ACTIVITY_NEW_TASK sendIntent.flags = Intent.FLAG_ACTIVITY_NEW_TASK
sendIntent.action = Intent.ACTION_SEND sendIntent.action = Intent.ACTION_SEND
sendIntent.putExtra(Intent.EXTRA_TEXT, itemUrl.toStringUriWithHttp()) sendIntent.putExtra(Intent.EXTRA_TEXT, itemUrl.toStringUriWithHttp())
sendIntent.putExtra(Intent.EXTRA_SUBJECT, itemTitle)
sendIntent.type = "text/plain" sendIntent.type = "text/plain"
startActivity( startActivity(
Intent.createChooser( Intent.createChooser(