implement article sharing

This commit is contained in:
Andrew Dolgov 2011-11-25 13:46:11 +03:00
parent e9d4211c3d
commit 8ace49fb71

View File

@ -218,6 +218,9 @@ public class MainActivity extends Activity implements FeedsFragment.OnFeedSelect
case R.id.close_article: case R.id.close_article:
closeArticle(); closeArticle();
return true; return true;
case R.id.share_article:
shareArticle(m_selectedArticle);
return true;
case R.id.show_feeds: case R.id.show_feeds:
if (getUnreadOnly()) { if (getUnreadOnly()) {
item.setTitle(R.string.menu_unread_feeds); item.setTitle(R.string.menu_unread_feeds);
@ -232,6 +235,18 @@ public class MainActivity extends Activity implements FeedsFragment.OnFeedSelect
} }
} }
public void shareArticle(Article article) {
if (article != null) {
Intent intent = new Intent(Intent.ACTION_SEND);
intent.setType("text/plain");
intent.putExtra(Intent.EXTRA_SUBJECT, article.title);
intent.putExtra(Intent.EXTRA_TEXT, article.link);
startActivity(Intent.createChooser(intent, getString(R.id.share_article)));
}
}
public void closeArticle() { public void closeArticle() {
findViewById(R.id.article_fragment).setVisibility(View.GONE); findViewById(R.id.article_fragment).setVisibility(View.GONE);
findViewById(R.id.feeds_fragment).setVisibility(View.VISIBLE); findViewById(R.id.feeds_fragment).setVisibility(View.VISIBLE);