From 1469ff7b8f0a01e14a8a80a741c2ec1df84ca645 Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Thu, 24 Nov 2011 19:11:10 +0300 Subject: [PATCH] reorganize actionbar --- res/menu/main_menu.xml | 27 ++++++++++++------------ res/values/strings.xml | 2 +- src/org/fox/ttrss/HeadlinesFragment.java | 22 ++++++++++++++++++- src/org/fox/ttrss/MainActivity.java | 19 +++++++++++------ 4 files changed, 49 insertions(+), 21 deletions(-) diff --git a/res/menu/main_menu.xml b/res/menu/main_menu.xml index ab463bef..97e713e4 100644 --- a/res/menu/main_menu.xml +++ b/res/menu/main_menu.xml @@ -9,7 +9,7 @@ @@ -21,23 +21,24 @@ android:showAsAction="ifRoom|withText"/> - - - - + android:icon="@android:drawable/ic_menu_rotate" + android:title="@string/update_feeds" + android:showAsAction=""/> + + android:showAsAction=""/> + + + Loading, please wait... Show unread feeds Show all feeds - Update + Refresh feeds Close article Share article diff --git a/src/org/fox/ttrss/HeadlinesFragment.java b/src/org/fox/ttrss/HeadlinesFragment.java index 65cf2c6f..2055e6ae 100644 --- a/src/org/fox/ttrss/HeadlinesFragment.java +++ b/src/org/fox/ttrss/HeadlinesFragment.java @@ -26,6 +26,7 @@ import android.widget.AdapterView.OnItemClickListener; import android.widget.ArrayAdapter; import android.widget.CheckBox; import android.widget.CompoundButton; +import android.widget.ToggleButton; import android.widget.CompoundButton.OnCheckedChangeListener; import android.widget.ImageView; import android.widget.ListView; @@ -214,6 +215,24 @@ public class HeadlinesFragment extends Fragment implements OnItemClickListener { ar.execute(map); } + public void setArticleMarked(final Article article) { + ApiRequest ar = new ApiRequest(); + ar.setApi(m_prefs.getString("ttrss_url", null)); + + final String sessionId = ((MainActivity)getActivity()).getSessionId(); + + HashMap map = new HashMap() { + { + put("sid", sessionId); + put("op", "updateArticle"); + put("article_ids", String.valueOf(article.id)); + put("mode", article.marked ? "1" : "0"); + put("field", "0"); + } + }; + + ar.execute(map); + } private class ArticleListAdapter extends ArrayAdapter
{ private ArrayList
items; @@ -296,9 +315,10 @@ public class HeadlinesFragment extends Fragment implements OnItemClickListener { @Override public void onClick(View v) { - Log.d(TAG, "Marked image clicked " + v + " / " + article.id + "/" + article.marked); article.marked = !article.marked; m_adapter.notifyDataSetChanged(); + + setArticleMarked(article); } }); } diff --git a/src/org/fox/ttrss/MainActivity.java b/src/org/fox/ttrss/MainActivity.java index 8ef91d39..c7dd18c9 100644 --- a/src/org/fox/ttrss/MainActivity.java +++ b/src/org/fox/ttrss/MainActivity.java @@ -182,7 +182,7 @@ public class MainActivity extends Activity implements FeedsFragment.OnFeedSelect Intent intent = new Intent(this, PreferencesActivity.class); startActivityForResult(intent, 0); return true; - case R.id.update: + case R.id.update_feeds: refreshFeeds(); return true; case R.id.logout: @@ -245,9 +245,11 @@ public class MainActivity extends Activity implements FeedsFragment.OnFeedSelect ft.commit(); m_menu.findItem(R.id.login).setVisible(false); + m_menu.findItem(R.id.logout).setVisible(true); - m_menu.findItem(R.id.update).setVisible(true); - m_menu.findItem(R.id.show_feeds).setVisible(true); + + m_menu.findItem(R.id.update_feeds).setEnabled(true); + m_menu.findItem(R.id.show_feeds).setEnabled(true); if (m_refreshTask != null) { m_refreshTask.cancel(); @@ -329,8 +331,10 @@ public class MainActivity extends Activity implements FeedsFragment.OnFeedSelect findViewById(R.id.feeds_fragment).setVisibility(View.GONE); findViewById(R.id.article_fragment).setVisibility(View.VISIBLE); - if (m_menu != null) + if (m_menu != null) { m_menu.findItem(R.id.close_article).setVisible(true); + m_menu.findItem(R.id.share_article).setVisible(true); + } } @@ -344,10 +348,13 @@ public class MainActivity extends Activity implements FeedsFragment.OnFeedSelect if (m_menu != null) { m_menu.findItem(R.id.login).setVisible(true); + m_menu.findItem(R.id.logout).setVisible(false); - m_menu.findItem(R.id.update).setVisible(false); - m_menu.findItem(R.id.show_feeds).setVisible(false); m_menu.findItem(R.id.close_article).setVisible(false); + m_menu.findItem(R.id.share_article).setVisible(false); + + m_menu.findItem(R.id.update_feeds).setEnabled(false); + m_menu.findItem(R.id.show_feeds).setEnabled(false); } if (m_refreshTask != null) {