diff --git a/app/src/main/java/io/legado/app/ui/rss/read/ReadRssActivity.kt b/app/src/main/java/io/legado/app/ui/rss/read/ReadRssActivity.kt index 9fc29878b..037364296 100644 --- a/app/src/main/java/io/legado/app/ui/rss/read/ReadRssActivity.kt +++ b/app/src/main/java/io/legado/app/ui/rss/read/ReadRssActivity.kt @@ -1,6 +1,7 @@ package io.legado.app.ui.rss.read import android.annotation.SuppressLint +import android.content.Intent import android.os.Bundle import android.view.KeyEvent import android.view.Menu @@ -15,6 +16,7 @@ import io.legado.app.lib.theme.primaryTextColor import io.legado.app.utils.NetworkUtils import io.legado.app.utils.getViewModel import kotlinx.android.synthetic.main.activity_rss_read.* +import org.jetbrains.anko.toast class ReadRssActivity : VMBaseActivity(R.layout.activity_rss_read), ReadRssViewModel.CallBack { @@ -42,6 +44,9 @@ class ReadRssActivity : VMBaseActivity(R.layout.activity_rss_r override fun onCompatOptionsItemSelected(item: MenuItem): Boolean { when (item.itemId) { R.id.menu_rss_star -> viewModel.star() + R.id.menu_share_it -> viewModel.rssArticle?.let { + shareText("链接分享", it.link) + } } return super.onCompatOptionsItemSelected(item) } @@ -115,4 +120,15 @@ class ReadRssActivity : VMBaseActivity(R.layout.activity_rss_r } return super.onKeyUp(keyCode, event) } + + private fun shareText(title: String, text: String) { + try { + val textIntent = Intent(Intent.ACTION_SEND) + textIntent.type = "text/plain" + textIntent.putExtra(Intent.EXTRA_TEXT, text) + startActivity(Intent.createChooser(textIntent, title)) + } catch (e: Exception) { + toast(R.string.can_not_share) + } + } } \ No newline at end of file diff --git a/app/src/main/res/menu/rss_read.xml b/app/src/main/res/menu/rss_read.xml index 29f3087ba..15463f64d 100644 --- a/app/src/main/res/menu/rss_read.xml +++ b/app/src/main/res/menu/rss_read.xml @@ -8,4 +8,10 @@ android:icon="@drawable/ic_star_border" app:showAsAction="always" /> + + \ No newline at end of file