add open article in web browser to headline context menu

This commit is contained in:
Andrew Dolgov 2014-01-16 16:21:19 +04:00
parent 8f38f2f7a3
commit e3280a06ab
3 changed files with 22 additions and 0 deletions

View File

@ -18,6 +18,10 @@
android:id="@+id/headlines_share_article" android:id="@+id/headlines_share_article"
android:showAsAction="" android:showAsAction=""
android:title="@string/share_article"/> android:title="@string/share_article"/>
<item
android:id="@+id/headlines_article_link_open"
android:showAsAction=""
android:title="@string/open_article_in_web_browser"/>
<item <item
android:id="@+id/headlines_article_link_copy" android:id="@+id/headlines_article_link_copy"
android:showAsAction="" android:showAsAction=""

View File

@ -216,4 +216,5 @@
<string name="unsubscribe">Unsubscribe</string> <string name="unsubscribe">Unsubscribe</string>
<string name="unsubscribe_from_prompt">Unsubscribe from %1$s?</string> <string name="unsubscribe_from_prompt">Unsubscribe from %1$s?</string>
<string name="toggle_sidebar">Toggle sidebar</string> <string name="toggle_sidebar">Toggle sidebar</string>
<string name="open_article_in_web_browser">Open in web browser</string>
</resources> </resources>

View File

@ -17,11 +17,13 @@ import uk.co.senab.actionbarpulltorefresh.library.PullToRefreshAttacher.OnRefres
import android.app.Activity; import android.app.Activity;
import android.content.Context; import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences; import android.content.SharedPreferences;
import android.content.res.Resources.Theme; import android.content.res.Resources.Theme;
import android.graphics.Paint; import android.graphics.Paint;
import android.graphics.drawable.BitmapDrawable; import android.graphics.drawable.BitmapDrawable;
import android.graphics.drawable.Drawable; import android.graphics.drawable.Drawable;
import android.net.Uri;
import android.os.Bundle; import android.os.Bundle;
import android.preference.PreferenceManager; import android.preference.PreferenceManager;
import android.support.v4.app.Fragment; import android.support.v4.app.Fragment;
@ -135,6 +137,21 @@ public class HeadlinesFragment extends Fragment implements OnItemClickListener,
} }
} }
return true; return true;
case R.id.headlines_article_link_open:
if (true) {
Article article = getArticleAtPosition(info.position);
if (article != null) {
Intent browserIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(article.link));
startActivity(browserIntent);
if (article.unread) {
article.unread = false;
m_activity.saveArticleUnread(article);
}
}
}
return true;
case R.id.selection_toggle_marked: case R.id.selection_toggle_marked:
if (true) { if (true) {
ArticleList selected = getSelectedArticles(); ArticleList selected = getSelectedArticles();