From d5f17058c4c2446b925c289bdd2f572263bac6cd Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Thu, 24 Nov 2011 08:59:11 +0300 Subject: [PATCH] add show unread/show all menu item --- res/layout/main.xml | 17 ++++++------ res/menu/main_menu.xml | 5 ++++ res/values/strings.xml | 3 +++ res/values/style.xml | 2 +- src/org/fox/ttrss/ArticleFragment.java | 4 ++- src/org/fox/ttrss/FeedsFragment.java | 9 ++++--- src/org/fox/ttrss/MainActivity.java | 36 +++++++++++++++++++++++--- 7 files changed, 58 insertions(+), 18 deletions(-) diff --git a/res/layout/main.xml b/res/layout/main.xml index fcac33d5..ee05766b 100644 --- a/res/layout/main.xml +++ b/res/layout/main.xml @@ -1,17 +1,16 @@ - - - - + + + + - - - - - + + + + diff --git a/res/menu/main_menu.xml b/res/menu/main_menu.xml index 42ec20e9..ac7423c4 100644 --- a/res/menu/main_menu.xml +++ b/res/menu/main_menu.xml @@ -1,5 +1,10 @@ + + No unread feeds. No unread headlines. Loading, please wait... + Unread feeds + All feeds + diff --git a/res/values/style.xml b/res/values/style.xml index 84a40558..4bc343e1 100644 --- a/res/values/style.xml +++ b/res/values/style.xml @@ -5,7 +5,7 @@ #0000ff #ffffff #f0f0f0 - #ffffff + #E8F2FF " + + "" + m_article.content + "").replace('+', ' '); web.loadData(content, "text/html", "utf-8"); } diff --git a/src/org/fox/ttrss/FeedsFragment.java b/src/org/fox/ttrss/FeedsFragment.java index 9898e10d..ad2bd2ef 100644 --- a/src/org/fox/ttrss/FeedsFragment.java +++ b/src/org/fox/ttrss/FeedsFragment.java @@ -32,8 +32,6 @@ import com.google.gson.reflect.TypeToken; public class FeedsFragment extends Fragment implements OnItemClickListener { private final String TAG = this.getClass().getSimpleName(); private SharedPreferences m_prefs; - //private String m_sessionId; - //private int m_activeFeedId; private FeedListAdapter m_adapter; private List m_feeds = new ArrayList(); private OnFeedSelectedListener m_feedSelectedListener; @@ -41,7 +39,7 @@ public class FeedsFragment extends Fragment implements OnItemClickListener { public interface OnFeedSelectedListener { public void onFeedSelected(Feed feed); } - + public void showLoading(boolean show) { View v = getView(); @@ -115,6 +113,7 @@ public class FeedsFragment extends Fragment implements OnItemClickListener { fr.setApi(m_prefs.getString("ttrss_url", null)); final String sessionId = ((MainActivity)getActivity()).getSessionId(); + final boolean unreadOnly = ((MainActivity)getActivity()).getUnreadOnly(); if (sessionId != null) { @@ -123,7 +122,9 @@ public class FeedsFragment extends Fragment implements OnItemClickListener { put("op", "getFeeds"); put("sid", sessionId); put("cat_id", "-3"); - put("unread_only", "true"); + if (unreadOnly) { + put("unread_only", String.valueOf(unreadOnly)); + } } }; diff --git a/src/org/fox/ttrss/MainActivity.java b/src/org/fox/ttrss/MainActivity.java index f46ea80a..09d94620 100644 --- a/src/org/fox/ttrss/MainActivity.java +++ b/src/org/fox/ttrss/MainActivity.java @@ -32,8 +32,8 @@ public class MainActivity extends Activity implements FeedsFragment.OnFeedSelect private Feed m_activeFeed; private Timer m_refreshTimer; private RefreshTask m_refreshTask; - - protected MenuItem m_syncStatus; + private Menu m_menu; + private boolean m_unreadOnly = true; private class RefreshTask extends TimerTask { @@ -53,6 +53,17 @@ public class MainActivity extends Activity implements FeedsFragment.OnFeedSelect } } + + public void setUnreadOnly(boolean unread) { + m_unreadOnly = unread; + refreshFeeds(); + } + + public boolean getUnreadOnly() { + return m_unreadOnly; + } + + public String getSessionId() { return m_sessionId; } @@ -97,7 +108,7 @@ public class MainActivity extends Activity implements FeedsFragment.OnFeedSelect ft.commit(); findViewById(R.id.article_fragment).setVisibility(View.GONE); - findViewById(R.id.headlines_fragment).setVisibility(View.GONE); + //findViewById(R.id.headlines_fragment).setVisibility(View.GONE); LoginRequest ar = new LoginRequest(); ar.setApi(m_prefs.getString("ttrss_url", null)); @@ -167,10 +178,20 @@ public class MainActivity extends Activity implements FeedsFragment.OnFeedSelect public boolean onCreateOptionsMenu(Menu menu) { MenuInflater inflater = getMenuInflater(); inflater.inflate(R.menu.main_menu, menu); + + m_menu = menu; return true; } + public void setMenuLabel(int id, int labelId) { + MenuItem mi = m_menu.findItem(id); + + if (mi != null) { + mi.setTitle(labelId); + } + } + @Override public boolean onOptionsItemSelected(MenuItem item) { switch (item.getItemId()) { @@ -178,6 +199,15 @@ public class MainActivity extends Activity implements FeedsFragment.OnFeedSelect Intent intent = new Intent(this, PreferencesActivity.class); startActivityForResult(intent, 0); return true; + case R.id.show_feeds: + if (getUnreadOnly()) { + item.setTitle(R.string.menu_all_feeds); + } else { + item.setTitle(R.string.menu_unread_feeds); + } + + setUnreadOnly(!getUnreadOnly()); + return true; default: return super.onOptionsItemSelected(item); }