From 2f10a4a88ebeaf79385276e6b06b1308040ee7d1 Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Wed, 30 Nov 2011 10:22:27 +0300 Subject: [PATCH] implement special options menu for selected headlines --- res/menu/headlines_menu.xml | 6 +- res/menu/main_menu.xml | 43 +++++++++++---- res/values/strings.xml | 27 +++++---- src/org/fox/ttrss/HeadlinesFragment.java | 2 + src/org/fox/ttrss/MainActivity.java | 70 ++++++++++++++++++++---- 5 files changed, 110 insertions(+), 38 deletions(-) diff --git a/res/menu/headlines_menu.xml b/res/menu/headlines_menu.xml index ac614810..32ecae81 100644 --- a/res/menu/headlines_menu.xml +++ b/res/menu/headlines_menu.xml @@ -4,18 +4,18 @@ android:id="@+id/selection_toggle_unread" android:icon="@android:drawable/ic_menu_recent_history" android:showAsAction="" - android:title="@string/selection_toggle_unread"/> + android:title="@string/context_selection_toggle_unread"/> + android:title="@string/context_selection_toggle_marked"/> + android:title="@string/context_selection_toggle_published"/> \ No newline at end of file diff --git a/res/menu/main_menu.xml b/res/menu/main_menu.xml index 584b896b..719f004c 100644 --- a/res/menu/main_menu.xml +++ b/res/menu/main_menu.xml @@ -1,11 +1,5 @@ - - @@ -27,6 +21,11 @@ android:icon="@android:drawable/ic_menu_rotate" android:showAsAction="" android:title="@string/update_feeds"/> + + @@ -54,6 +53,27 @@ android:title="@string/headlines_select"/> + + + + + + + + + - - + + + Login session refused by server Logging in... - Login failed. + Login failed. Tiny Tiny RSS Please configure the application first. Ready to login. @@ -32,7 +33,7 @@ Show unread feeds Show all feeds Refresh feeds - Close article + Close article Share article Mark as read Sort feeds by unread count @@ -50,10 +51,13 @@ Select articles All articles Unread articles - None - Starred - Published - Unread + Deselect all + Toggle starred + Toggle published + Mark as read + Starred + Published + Unread Mark unread Optional. Fill this if your tt-rss installation is protected by HTTP Basic authentication Your tt-rss login. Not needed for single user mode @@ -68,10 +72,9 @@ Browse categories like feeds You can long-tap on a category to override this setting Catchup - - No error - Error: Unknown error (see log) - Error: 401 unauthorized + No error + Error: Unknown error (see log) + Error: 401 unauthorized Error: 403 forbidden Error: 404 not found Error: 500 server error @@ -83,5 +86,5 @@ Error: API disabled for this user Error: unknown API error (see log) Error: username or password incorrect - - + + \ No newline at end of file diff --git a/src/org/fox/ttrss/HeadlinesFragment.java b/src/org/fox/ttrss/HeadlinesFragment.java index 79ce8dd6..beb86a5f 100644 --- a/src/org/fox/ttrss/HeadlinesFragment.java +++ b/src/org/fox/ttrss/HeadlinesFragment.java @@ -385,6 +385,8 @@ public class HeadlinesFragment extends Fragment implements OnItemClickListener { m_selectedArticles.remove(article); } + ((MainActivity)getActivity()).initMainMenu(); + Log.d(TAG, "num selected: " + m_selectedArticles.size()); } }); diff --git a/src/org/fox/ttrss/MainActivity.java b/src/org/fox/ttrss/MainActivity.java index e772611d..d445e4fb 100644 --- a/src/org/fox/ttrss/MainActivity.java +++ b/src/org/fox/ttrss/MainActivity.java @@ -632,6 +632,34 @@ public class MainActivity extends FragmentActivity implements FeedsFragment.OnFe updateHeadlines(); } return true; + case R.id.selection_mark_as_read: + return true; + case R.id.selection_toggle_marked: + if (hf != null) { + ArticleList selected = hf.getSelectedArticles(); + + if (selected.size() > 0) { + for (Article a : selected) + a.marked = !a.marked; + + toggleArticlesMarked(selected); + hf.notifyUpdated(); + } + } + return true; + case R.id.selection_toggle_published: + if (hf != null) { + ArticleList selected = hf.getSelectedArticles(); + + if (selected.size() > 0) { + for (Article a : selected) + a.published = !a.published; + + toggleArticlesPublished(selected); + hf.notifyUpdated(); + } + } + return true; case R.id.toggle_published: if (m_selectedArticle != null) { m_selectedArticle.published = !m_selectedArticle.published; @@ -719,37 +747,55 @@ public class MainActivity extends FragmentActivity implements FeedsFragment.OnFe m_menu.findItem(R.id.show_all_articles).setVisible(true); } else { m_menu.setGroupVisible(R.id.menu_group_headlines, false); + m_menu.setGroupVisible(R.id.menu_group_headlines_selection, false); } if (m_selectedArticle != null) { m_menu.setGroupVisible(R.id.menu_group_article, true); - m_menu.findItem(R.id.update_feeds).setVisible(false); - m_menu.findItem(R.id.show_feeds).setVisible(false); - m_menu.findItem(R.id.back_to_categories).setVisible(false); + m_menu.setGroupVisible(R.id.menu_group_feeds, false); if (m_smallScreenMode) { - m_menu.setGroupVisible(R.id.menu_group_headlines, false); + m_menu.setGroupVisible(R.id.menu_group_headlines, false); + m_menu.setGroupVisible(R.id.menu_group_headlines_selection, false); } else { m_menu.setGroupVisible(R.id.menu_group_headlines, true); } } else { m_menu.setGroupVisible(R.id.menu_group_article, false); - + + if (m_activeFeed != null) { + + HeadlinesFragment hf = (HeadlinesFragment)getSupportFragmentManager().findFragmentById(R.id.headlines_fragment); + + if (hf != null) { + int numSelected = hf.getSelectedArticles().size(); + + if (numSelected != 0) { + m_menu.setGroupVisible(R.id.menu_group_headlines, false); + m_menu.setGroupVisible(R.id.menu_group_headlines_selection, true); + } else { + m_menu.setGroupVisible(R.id.menu_group_headlines, true); + m_menu.setGroupVisible(R.id.menu_group_headlines_selection, false); + } + + } else { + m_menu.setGroupVisible(R.id.menu_group_headlines, true); + m_menu.setGroupVisible(R.id.menu_group_headlines_selection, false); + } + + m_menu.setGroupVisible(R.id.menu_group_feeds, false); + } else { + m_menu.setGroupVisible(R.id.menu_group_feeds, true); + } + if (!m_smallScreenMode || m_activeFeed == null) { m_menu.findItem(R.id.show_feeds).setVisible(true); m_menu.findItem(R.id.update_feeds).setVisible(true); - } else { - m_menu.findItem(R.id.show_feeds).setVisible(false); - m_menu.findItem(R.id.update_feeds).setVisible(false); } m_menu.findItem(R.id.back_to_categories).setVisible(m_activeCategory != null); - - if (m_activeFeed != null) { - m_menu.setGroupVisible(R.id.menu_group_headlines, true); - } } } else {