From 7f554adba5c35bf3fdf2d5e61c657073f9321845 Mon Sep 17 00:00:00 2001 From: Binnette Date: Sat, 17 Nov 2018 18:07:38 +0100 Subject: [PATCH] Add EXTRA_SUBJECT when sharing link --- .../amine/bou/readerforselfoss/adapters/ItemCardAdapter.kt | 3 ++- .../amine/bou/readerforselfoss/fragments/ArticleFragment.kt | 2 +- .../java/apps/amine/bou/readerforselfoss/utils/AppUtils.kt | 3 ++- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/app/src/main/java/apps/amine/bou/readerforselfoss/adapters/ItemCardAdapter.kt b/app/src/main/java/apps/amine/bou/readerforselfoss/adapters/ItemCardAdapter.kt index b45b9e6..0f24582 100644 --- a/app/src/main/java/apps/amine/bou/readerforselfoss/adapters/ItemCardAdapter.kt +++ b/app/src/main/java/apps/amine/bou/readerforselfoss/adapters/ItemCardAdapter.kt @@ -179,7 +179,8 @@ class ItemCardAdapter( }) mView.shareBtn.setOnClickListener { - c.shareLink(items[adapterPosition].getLinkDecoded()) + val item = items[adapterPosition] + c.shareLink(item.getLinkDecoded(), item.title) } mView.browserBtn.setOnClickListener { diff --git a/app/src/main/java/apps/amine/bou/readerforselfoss/fragments/ArticleFragment.kt b/app/src/main/java/apps/amine/bou/readerforselfoss/fragments/ArticleFragment.kt index 021ac35..6f998c4 100644 --- a/app/src/main/java/apps/amine/bou/readerforselfoss/fragments/ArticleFragment.kt +++ b/app/src/main/java/apps/amine/bou/readerforselfoss/fragments/ArticleFragment.kt @@ -139,7 +139,7 @@ class ArticleFragment : Fragment() { override fun onItemClick(item: MenuItem) { when (item.itemId) { 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( allItems, pageNumber.toInt(), diff --git a/app/src/main/java/apps/amine/bou/readerforselfoss/utils/AppUtils.kt b/app/src/main/java/apps/amine/bou/readerforselfoss/utils/AppUtils.kt index 10ee17e..35e5a72 100644 --- a/app/src/main/java/apps/amine/bou/readerforselfoss/utils/AppUtils.kt +++ b/app/src/main/java/apps/amine/bou/readerforselfoss/utils/AppUtils.kt @@ -25,11 +25,12 @@ fun String.toStringUriWithHttp(): String = this } -fun Context.shareLink(itemUrl: String) { +fun Context.shareLink(itemUrl: String, itemTitle: String) { val sendIntent = Intent() sendIntent.flags = Intent.FLAG_ACTIVITY_NEW_TASK sendIntent.action = Intent.ACTION_SEND sendIntent.putExtra(Intent.EXTRA_TEXT, itemUrl.toStringUriWithHttp()) + sendIntent.putExtra(Intent.EXTRA_SUBJECT, itemTitle) sendIntent.type = "text/plain" startActivity( Intent.createChooser(