implement special options menu for selected headlines

This commit is contained in:
Andrew Dolgov 2011-11-30 10:22:27 +03:00
parent 042885888a
commit 2f10a4a88e
5 changed files with 110 additions and 38 deletions

View File

@ -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"/>
<item
android:id="@+id/selection_toggle_marked"
android:icon="@android:drawable/star_off"
android:showAsAction=""
android:title="@string/selection_toggle_marked"/>
android:title="@string/context_selection_toggle_marked"/>
<item
android:id="@+id/selection_toggle_published"
android:icon="@drawable/ic_menu_rss"
android:showAsAction=""
android:title="@string/selection_toggle_published"/>
android:title="@string/context_selection_toggle_published"/>
</menu>

View File

@ -1,11 +1,5 @@
<menu xmlns:android="http://schemas.android.com/apk/res/android" >
<item
android:id="@+id/preferences"
android:icon="@android:drawable/ic_menu_preferences"
android:showAsAction=""
android:title="@string/preferences"/>
<group android:id="@+id/menu_group_logged_in" >
<group android:id="@+id/menu_group_feeds" >
@ -27,6 +21,11 @@
android:icon="@android:drawable/ic_menu_rotate"
android:showAsAction=""
android:title="@string/update_feeds"/>
<item
android:id="@+id/logout"
android:showAsAction=""
android:title="@string/logout"/>
</group>
<group android:id="@+id/menu_group_headlines" >
@ -54,6 +53,27 @@
android:title="@string/headlines_select"/>
</group>
<group android:id="@+id/menu_group_headlines_selection" >
<item
android:id="@+id/selection_mark_as_read"
android:icon="@android:drawable/ic_menu_close_clear_cancel"
android:showAsAction=""
android:title="@string/selection_mark_as_read"/>
<item
android:id="@+id/selection_toggle_marked"
android:icon="@android:drawable/star_off"
android:showAsAction=""
android:title="@string/selection_toggle_marked"/>
<item
android:id="@+id/selection_toggle_published"
android:icon="@drawable/ic_menu_rss"
android:showAsAction=""
android:title="@string/selection_toggle_published"/>
</group>
<group android:id="@+id/menu_group_article" >
<item
@ -86,13 +106,14 @@
android:showAsAction="ifRoom|withText"
android:title="@string/close_article"/>
</group>
<item
android:id="@+id/logout"
android:showAsAction=""
android:title="@string/logout"/>
</group>
<item
android:id="@+id/preferences"
android:icon="@android:drawable/ic_menu_preferences"
android:showAsAction=""
android:title="@string/preferences"/>
<group android:id="@+id/menu_group_logged_out" >
<item

View File

@ -1,8 +1,9 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="login_session_error">Login session refused by server</string>
<string name="login_in_progress">Logging in...</string>
<string name="login_failed">Login failed.</string>
<string name="login_failed">Login failed.</string>
<string name="app_name">Tiny Tiny RSS</string>
<string name="login_need_configure">Please configure the application first.</string>
<string name="login_ready">Ready to login.</string>
@ -32,7 +33,7 @@
<string name="menu_unread_feeds">Show unread feeds</string>
<string name="menu_all_feeds">Show all feeds</string>
<string name="update_feeds">Refresh feeds</string>
<string name="close_article">Close article</string>
<string name="close_article">Close article</string>
<string name="share_article">Share article</string>
<string name="catchup">Mark as read</string>
<string name="sort_feeds_by_unread">Sort feeds by unread count</string>
@ -50,10 +51,13 @@
<string name="headlines_select_dialog">Select articles</string>
<string name="headlines_select_all">All articles</string>
<string name="headlines_select_unread">Unread articles</string>
<string name="headlines_select_none">None</string>
<string name="selection_toggle_marked">Starred</string>
<string name="selection_toggle_published">Published</string>
<string name="selection_toggle_unread">Unread</string>
<string name="headlines_select_none">Deselect all</string>
<string name="selection_toggle_marked">Toggle starred</string>
<string name="selection_toggle_published">Toggle published</string>
<string name="selection_mark_as_read">Mark as read</string>
<string name="context_selection_toggle_marked">Starred</string>
<string name="context_selection_toggle_published">Published</string>
<string name="context_selection_toggle_unread">Unread</string>
<string name="article_set_unread">Mark unread</string>
<string name="http_login_summary">Optional. Fill this if your tt-rss installation is protected by HTTP Basic authentication</string>
<string name="login_summary">Your tt-rss login. Not needed for single user mode</string>
@ -68,10 +72,9 @@
<string name="browse_cats_like_feeds">Browse categories like feeds</string>
<string name="browse_cats_like_feeds_summary">You can long-tap on a category to override this setting</string>
<string name="catchup_and_load">Catchup</string>
<string name="error_no_error">No error</string>
<string name="error_unknown">Error: Unknown error (see log)</string>
<string name="error_http_unauthorized">Error: 401 unauthorized</string>
<string name="error_no_error">No error</string>
<string name="error_unknown">Error: Unknown error (see log)</string>
<string name="error_http_unauthorized">Error: 401 unauthorized</string>
<string name="error_http_forbidden">Error: 403 forbidden</string>
<string name="error_http_not_found">Error: 404 not found</string>
<string name="error_http_server_error">Error: 500 server error</string>
@ -83,5 +86,5 @@
<string name="error_api_disabled">Error: API disabled for this user</string>
<string name="error_api_unknown">Error: unknown API error (see log)</string>
<string name="error_login_failed">Error: username or password incorrect</string>
</resources>
</resources>

View File

@ -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());
}
});

View File

@ -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 {