add menu entry to refresh headlines in small screen mode

This commit is contained in:
Andrew Dolgov 2012-09-18 13:16:03 +04:00
parent 94b4aff15f
commit b100fb6ec1
4 changed files with 34 additions and 21 deletions

View File

@ -39,6 +39,12 @@
<group android:id="@+id/menu_group_headlines" > <group android:id="@+id/menu_group_headlines" >
<item
android:id="@+id/update_headlines"
android:icon="@android:drawable/ic_menu_rotate"
android:showAsAction="ifRoom"
android:title="@string/update_headlines"/>
<item <item
android:id="@+id/search" android:id="@+id/search"
android:actionViewClass="android.widget.SearchView" android:actionViewClass="android.widget.SearchView"

View File

@ -24,7 +24,7 @@
<string name="loading_message">Loading, please wait…</string> <string name="loading_message">Loading, please wait…</string>
<string name="menu_unread_feeds">Show unread feeds</string> <string name="menu_unread_feeds">Show unread feeds</string>
<string name="menu_all_feeds">Show all feeds</string> <string name="menu_all_feeds">Show all feeds</string>
<string name="update_feeds">Refresh feeds</string> <string name="update_feeds">Refresh</string>
<string name="share_article">Share article</string> <string name="share_article">Share article</string>
<string name="catchup">Mark read</string> <string name="catchup">Mark read</string>
<string name="sort_feeds_by_unread">Sort feeds by unread count</string> <string name="sort_feeds_by_unread">Sort feeds by unread count</string>
@ -128,4 +128,5 @@
<string name="notify_article_published">Article published</string> <string name="notify_article_published">Article published</string>
<string name="notify_article_unpublished">Article unpublished</string> <string name="notify_article_unpublished">Article unpublished</string>
<string name="notify_article_note_set">Article note saved</string> <string name="notify_article_note_set">Article note saved</string>
<string name="update_headlines">Refresh</string>
</resources> </resources>

View File

@ -121,6 +121,8 @@ public class FeedsActivity extends OnlineActivity implements HeadlinesEventListe
m_menu.setGroupVisible(R.id.menu_group_headlines, hf != null && hf.isAdded() && hf.getSelectedArticles().size() == 0); m_menu.setGroupVisible(R.id.menu_group_headlines, hf != null && hf.isAdded() && hf.getSelectedArticles().size() == 0);
m_menu.setGroupVisible(R.id.menu_group_headlines_selection, hf != null && hf.isAdded() && hf.getSelectedArticles().size() != 0); m_menu.setGroupVisible(R.id.menu_group_headlines_selection, hf != null && hf.isAdded() && hf.getSelectedArticles().size() != 0);
m_menu.findItem(R.id.update_headlines).setVisible(hf != null && hf.isAdded());
MenuItem item = m_menu.findItem(R.id.show_feeds); MenuItem item = m_menu.findItem(R.id.show_feeds);
if (getUnreadOnly()) { if (getUnreadOnly()) {
@ -191,26 +193,6 @@ public class FeedsActivity extends OnlineActivity implements HeadlinesEventListe
onCatSelected(cat, m_prefs.getBoolean("browse_cats_like_feeds", false)); onCatSelected(cat, m_prefs.getBoolean("browse_cats_like_feeds", false));
} }
private void refresh() {
FeedCategoriesFragment cf = (FeedCategoriesFragment) getSupportFragmentManager().findFragmentByTag(FRAG_CATS);
if (cf != null) {
cf.refresh(false);
}
FeedsFragment ff = (FeedsFragment) getSupportFragmentManager().findFragmentByTag(FRAG_FEEDS);
if (ff != null) {
ff.refresh(false);
}
HeadlinesFragment hf = (HeadlinesFragment) getSupportFragmentManager().findFragmentByTag(FRAG_HEADLINES);
if (hf != null) {
hf.refresh(false);
}
}
@Override @Override
public boolean onOptionsItemSelected(MenuItem item) { public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) { switch (item.getItemId()) {
@ -222,6 +204,9 @@ public class FeedsActivity extends OnlineActivity implements HeadlinesEventListe
case R.id.update_feeds: case R.id.update_feeds:
refresh(); refresh();
return true; return true;
case R.id.update_headlines:
refresh();
return true;
default: default:
Log.d(TAG, "onOptionsItemSelected, unhandled id=" + item.getItemId()); Log.d(TAG, "onOptionsItemSelected, unhandled id=" + item.getItemId());
return super.onOptionsItemSelected(item); return super.onOptionsItemSelected(item);

View File

@ -1079,6 +1079,7 @@ public class OnlineActivity extends CommonActivity {
m_menu.findItem(R.id.set_labels).setEnabled(m_apiLevel >= 1); m_menu.findItem(R.id.set_labels).setEnabled(m_apiLevel >= 1);
m_menu.findItem(R.id.article_set_note).setEnabled(m_apiLevel >= 1); m_menu.findItem(R.id.article_set_note).setEnabled(m_apiLevel >= 1);
m_menu.findItem(R.id.update_headlines).setVisible(false);
MenuItem search = m_menu.findItem(R.id.search); MenuItem search = m_menu.findItem(R.id.search);
search.setEnabled(m_apiLevel >= 2); search.setEnabled(m_apiLevel >= 2);
@ -1145,6 +1146,26 @@ public class OnlineActivity extends CommonActivity {
} }
} }
protected void refresh() {
FeedCategoriesFragment cf = (FeedCategoriesFragment) getSupportFragmentManager().findFragmentByTag(FRAG_CATS);
if (cf != null) {
cf.refresh(false);
}
FeedsFragment ff = (FeedsFragment) getSupportFragmentManager().findFragmentByTag(FRAG_FEEDS);
if (ff != null) {
ff.refresh(false);
}
HeadlinesFragment hf = (HeadlinesFragment) getSupportFragmentManager().findFragmentByTag(FRAG_HEADLINES);
if (hf != null) {
hf.refresh(false);
}
}
private class LoginRequest extends ApiRequest { private class LoginRequest extends ApiRequest {
public LoginRequest(Context context) { public LoginRequest(Context context) {
super(context); super(context);