From 2b15ba91d4469fbb92b13195785f474bec0b3d3c Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Mon, 28 Nov 2011 21:36:13 +0300 Subject: [PATCH] add category support to tablet UI --- res/layout-port/main.xml | 1 + res/layout/main.xml | 1 + res/menu/main_menu.xml | 7 +++- res/values/strings.xml | 1 + src/org/fox/ttrss/FeedsFragment.java | 5 +++ src/org/fox/ttrss/MainActivity.java | 54 ++++++++++++++++++++-------- 6 files changed, 54 insertions(+), 15 deletions(-) diff --git a/res/layout-port/main.xml b/res/layout-port/main.xml index eb0beb31..571f1ad5 100644 --- a/res/layout-port/main.xml +++ b/res/layout-port/main.xml @@ -7,6 +7,7 @@ + diff --git a/res/layout/main.xml b/res/layout/main.xml index 9973a225..e0a8394c 100644 --- a/res/layout/main.xml +++ b/res/layout/main.xml @@ -7,6 +7,7 @@ + diff --git a/res/menu/main_menu.xml b/res/menu/main_menu.xml index 04bea68e..3c699bf3 100644 --- a/res/menu/main_menu.xml +++ b/res/menu/main_menu.xml @@ -16,7 +16,12 @@ android:icon="@android:drawable/ic_menu_agenda" android:title="@string/menu_all_feeds" android:showAsAction=""/> - + + + URL of your tt-rss installation directory, e.g. http://site.com/tt-rss/ Download and display feed icons Enable feed categories + Close category diff --git a/src/org/fox/ttrss/FeedsFragment.java b/src/org/fox/ttrss/FeedsFragment.java index c3f1f01e..a2438b27 100644 --- a/src/org/fox/ttrss/FeedsFragment.java +++ b/src/org/fox/ttrss/FeedsFragment.java @@ -131,6 +131,11 @@ public class FeedsFragment extends Fragment implements OnItemClickListener, OnSh m_prefs.registerOnSharedPreferenceChangeListener(this); m_feedSelectedListener = (OnFeedSelectedListener) activity; + + Feed activeFeed = ((MainActivity)activity).getActiveFeed(); + + if (activeFeed != null) + m_selectedFeedId = activeFeed.id; } @Override diff --git a/src/org/fox/ttrss/MainActivity.java b/src/org/fox/ttrss/MainActivity.java index 511873b1..6fa372ba 100644 --- a/src/org/fox/ttrss/MainActivity.java +++ b/src/org/fox/ttrss/MainActivity.java @@ -244,10 +244,20 @@ public class MainActivity extends FragmentActivity implements FeedsFragment.OnFe } } } else { - if (m_selectedArticle == null) + if (m_selectedArticle == null) { findViewById(R.id.article_fragment).setVisibility(View.GONE); - else + + if (!m_enableCats || m_activeCategory != null) + findViewById(R.id.cats_fragment).setVisibility(View.GONE); + else + findViewById(R.id.feeds_fragment).setVisibility(View.GONE); + + } else { findViewById(R.id.feeds_fragment).setVisibility(View.GONE); + findViewById(R.id.cats_fragment).setVisibility(View.GONE); + } + + } if (m_sessionId != null) { @@ -375,13 +385,7 @@ public class MainActivity extends FragmentActivity implements FeedsFragment.OnFe findViewById(R.id.main).setAnimation(AnimationUtils.loadAnimation(this, R.anim.slide_right)); } - findViewById(R.id.feeds_fragment).setVisibility(View.GONE); - findViewById(R.id.cats_fragment).setVisibility(View.VISIBLE); - - m_activeCategory = null; - - initMainMenu(); - refreshCategories(); + closeCategory(); } else { finish(); @@ -389,6 +393,14 @@ public class MainActivity extends FragmentActivity implements FeedsFragment.OnFe } else { if (m_selectedArticle != null) { closeArticle(); + } else if (m_activeCategory != null) { + findViewById(R.id.feeds_fragment).setVisibility(View.GONE); + findViewById(R.id.cats_fragment).setVisibility(View.VISIBLE); + + m_activeCategory = null; + + initMainMenu(); + refreshCategories(); } else { finish(); } @@ -399,6 +411,16 @@ public class MainActivity extends FragmentActivity implements FeedsFragment.OnFe return super.onKeyDown(keyCode, event); } + private void closeCategory() { + findViewById(R.id.feeds_fragment).setVisibility(View.GONE); + findViewById(R.id.cats_fragment).setVisibility(View.VISIBLE); + + m_activeCategory = null; + + initMainMenu(); + refreshCategories(); + } + @Override public boolean onOptionsItemSelected(MenuItem item) { switch (item.getItemId()) { @@ -418,6 +440,9 @@ public class MainActivity extends FragmentActivity implements FeedsFragment.OnFe case R.id.close_article: closeArticle(); return true; + case R.id.back_to_categories: + closeCategory(); + return true; case R.id.load_more_articles: viewFeed(m_activeFeed, true); return true; @@ -482,7 +507,7 @@ public class MainActivity extends FragmentActivity implements FeedsFragment.OnFe } } - public void closeArticle() { + private void closeArticle() { if (m_compatMode) { findViewById(R.id.main).setAnimation(AnimationUtils.loadAnimation(this, R.anim.slide_right)); } @@ -547,6 +572,8 @@ public class MainActivity extends FragmentActivity implements FeedsFragment.OnFe m_menu.findItem(R.id.show_all_articles).setVisible(m_activeFeed != null && m_selectedArticle == null); } + m_menu.findItem(R.id.back_to_categories).setVisible(m_activeCategory != null); + } else { m_menu.findItem(R.id.login).setVisible(true); @@ -554,6 +581,7 @@ public class MainActivity extends FragmentActivity implements FeedsFragment.OnFe m_menu.findItem(R.id.close_article).setVisible(false); m_menu.findItem(R.id.share_article).setVisible(false); m_menu.findItem(R.id.load_more_articles).setVisible(false); + m_menu.findItem(R.id.back_to_categories).setVisible(false); m_menu.findItem(R.id.update_feeds).setVisible(false); m_menu.findItem(R.id.show_feeds).setVisible(false); @@ -686,10 +714,8 @@ public class MainActivity extends FragmentActivity implements FeedsFragment.OnFe initMainMenu(); - if (m_smallScreenMode) { - findViewById(R.id.cats_fragment).setVisibility(View.GONE); - findViewById(R.id.feeds_fragment).setVisibility(View.VISIBLE); - } + findViewById(R.id.cats_fragment).setVisibility(View.GONE); + findViewById(R.id.feeds_fragment).setVisibility(View.VISIBLE); FeedsFragment frag = new FeedsFragment();