add (un)read to headline context menu

This commit is contained in:
Andrew Dolgov 2015-12-01 14:56:49 +03:00
parent c85269aeb7
commit 655b3e873e
3 changed files with 37 additions and 31 deletions

View File

@ -81,7 +81,7 @@ import java.util.List;
import java.util.TimeZone;
public class HeadlinesFragment extends Fragment implements OnItemClickListener, OnScrollListener {
public static enum ArticlesSelection { ALL, NONE, UNREAD }
public enum ArticlesSelection { ALL, NONE, UNREAD }
public static final int FLAVOR_IMG_MIN_SIZE = 128;
public static final int THUMB_IMG_MIN_SIZE = 32;
@ -155,6 +155,11 @@ public class HeadlinesFragment extends Fragment implements OnItemClickListener,
case R.id.article_set_note:
m_activity.editArticleNote(article);
return true;
case R.id.headlines_article_unread:
article.unread = !article.unread;
m_activity.saveArticleUnread(article);
m_adapter.notifyDataSetChanged();
return true;
case R.id.headlines_article_link_copy:
m_activity.copyToClipboard(article.link);
return true;
@ -456,7 +461,7 @@ public class HeadlinesFragment extends Fragment implements OnItemClickListener,
m_activity.getResources().getDimensionPixelSize(R.dimen.abc_action_bar_default_padding_end_material));
}
m_adapter = new ArticleListAdapter(getActivity(), R.layout.headlines_row, (ArrayList<Article>)m_articles);
m_adapter = new ArticleListAdapter(getActivity(), R.layout.headlines_row, m_articles);
m_animationAdapter = new SwingBottomInAnimationAdapter(m_adapter);
m_animationAdapter.setAbsListView(m_list);
@ -1289,11 +1294,7 @@ public class HeadlinesFragment extends Fragment implements OnItemClickListener,
public void onClick(View view) {
CheckBox cb = (CheckBox)view;
if (cb.isChecked()) {
article.selected = true;
} else {
article.selected = false;
}
article.selected = cb.isChecked();
m_listener.onArticleListSelectionChange(getSelectedArticles());

View File

@ -56,7 +56,7 @@ import java.util.Date;
import java.util.TimeZone;
public class OfflineHeadlinesFragment extends Fragment implements OnItemClickListener, AbsListView.OnScrollListener {
public static enum ArticlesSelection { ALL, NONE, UNREAD }
public enum ArticlesSelection { ALL, NONE, UNREAD }
private final String TAG = this.getClass().getSimpleName();
@ -712,6 +712,7 @@ public class OfflineHeadlinesFragment extends Fragment implements OnItemClickLis
popup.getMenu().findItem(R.id.set_labels).setVisible(false);
popup.getMenu().findItem(R.id.article_set_note).setVisible(false);
popup.getMenu().findItem(R.id.headlines_article_unread).setVisible(false); // TODO: implement
popup.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() {
@Override

View File

@ -1,28 +1,32 @@
<menu xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto">
<item
android:id="@+id/headlines_article_link_open"
app:showAsAction=""
android:title="@string/open_with"/>
<item
android:id="@+id/headlines_share_article"
app:showAsAction=""
android:title="@string/share_article"/>
<item
android:id="@+id/headlines_article_link_open"
app:showAsAction=""
android:title="@string/open_with"/>
<item
android:id="@+id/headlines_share_article"
app:showAsAction=""
android:title="@string/share_article"/>
<item
android:id="@+id/headlines_article_link_copy"
app:showAsAction=""
android:title="@string/article_link_copy"/>
<item
android:id="@+id/catchup_above"
app:showAsAction=""
android:title="@string/article_mark_read_above"/>
<item
android:id="@+id/set_labels"
android:title="@string/article_set_labels"/>
<item
android:id="@+id/article_set_note"
app:showAsAction=""
android:title="@string/article_set_note"/>
<item
android:id="@+id/headlines_article_link_copy"
app:showAsAction=""
android:title="@string/article_link_copy"/>
<item
android:id="@+id/catchup_above"
app:showAsAction=""
android:title="@string/article_mark_read_above"/>
<item
android:id="@+id/set_labels"
android:title="@string/article_set_labels"/>
<item
android:id="@+id/article_set_note"
app:showAsAction=""
android:title="@string/article_set_note"/>
<item
android:id="@+id/headlines_article_unread"
app:showAsAction=""
android:title="@string/context_selection_toggle_unread"/>
</menu>