From 0702083fb2e7aada55f7a240d0d728e1efea3120 Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Tue, 26 Jun 2012 13:29:35 +0400 Subject: [PATCH] add menu options to close active feed and article panels --- res/menu/main_menu.xml | 14 ++++++ res/menu/offline_menu.xml | 10 ++++ res/values/strings.xml | 2 + src/org/fox/ttrss/MainActivity.java | 28 +++++++++++ .../fox/ttrss/offline/OfflineActivity.java | 48 +++++++++++++++---- 5 files changed, 93 insertions(+), 9 deletions(-) diff --git a/res/menu/main_menu.xml b/res/menu/main_menu.xml index dee31211..5b6f34a8 100644 --- a/res/menu/main_menu.xml +++ b/res/menu/main_menu.xml @@ -62,6 +62,13 @@ android:icon="@drawable/ic_menu_database" android:showAsAction="ifRoom" android:title="@string/headlines_select"/> + + + @@ -132,6 +139,13 @@ android:id="@+id/article_set_note" android:showAsAction="" android:title="@string/article_set_note"/> + + + diff --git a/res/menu/offline_menu.xml b/res/menu/offline_menu.xml index 7b3c8225..26444ef8 100644 --- a/res/menu/offline_menu.xml +++ b/res/menu/offline_menu.xml @@ -43,6 +43,11 @@ android:icon="@drawable/ic_menu_database" android:showAsAction="ifRoom" android:title="@string/headlines_select"/> + + Stop syncing Continue Publish with note + Close feed + Close article \ No newline at end of file diff --git a/src/org/fox/ttrss/MainActivity.java b/src/org/fox/ttrss/MainActivity.java index b40cd959..ae79bebe 100644 --- a/src/org/fox/ttrss/MainActivity.java +++ b/src/org/fox/ttrss/MainActivity.java @@ -1014,6 +1014,28 @@ public class MainActivity extends CommonActivity implements OnlineServices { .findFragmentByTag(FRAG_HEADLINES); switch (item.getItemId()) { + case R.id.close_feed: + if (m_activeFeed != null) { + FragmentTransaction ft = getSupportFragmentManager().beginTransaction(); + ft.replace(R.id.headlines_fragment, new DummyFragment(), ""); + ft.commit(); + + if (m_activeFeed.is_cat) { + FeedCategoriesFragment cats = (FeedCategoriesFragment) getSupportFragmentManager().findFragmentByTag(FRAG_CATS); + cats.setSelectedCategory(null); + } else { + FeedsFragment feeds = (FeedsFragment) getSupportFragmentManager().findFragmentByTag(FRAG_FEEDS); + feeds.setSelectedFeed(null); + } + + m_activeFeed = null; + + initMainMenu(); + } + return true; + case R.id.close_article: + closeArticle(); + return true; case R.id.donate: if (true) { CharSequence[] items = { "Silver Donation ($2)", "Gold Donation ($5)", "Platinum Donation ($10)" }; @@ -1504,6 +1526,7 @@ public class MainActivity extends CommonActivity implements OnlineServices { } else if (m_selectedArticle != null) { m_menu.setGroupVisible(R.id.menu_group_article, true); + m_menu.findItem(R.id.close_article).setVisible(!isSmallScreen()); if (android.os.Build.VERSION.SDK_INT >= 14) { ShareActionProvider shareProvider = (ShareActionProvider) m_menu.findItem(R.id.share_article).getActionProvider(); @@ -1511,11 +1534,16 @@ public class MainActivity extends CommonActivity implements OnlineServices { if (m_selectedArticle != null) { Log.d(TAG, "setting up share provider"); shareProvider.setShareIntent(getShareIntent(m_selectedArticle)); + + if (!m_prefs.getBoolean("tablet_article_swipe", false) && !isSmallScreen()) { + m_menu.findItem(R.id.share_article).setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM); + } } } } else if (m_activeFeed != null) { m_menu.setGroupVisible(R.id.menu_group_headlines, true); + m_menu.findItem(R.id.close_feed).setVisible(!isSmallScreen()); MenuItem search = m_menu.findItem(R.id.search); diff --git a/src/org/fox/ttrss/offline/OfflineActivity.java b/src/org/fox/ttrss/offline/OfflineActivity.java index 45642f20..daef78e6 100644 --- a/src/org/fox/ttrss/offline/OfflineActivity.java +++ b/src/org/fox/ttrss/offline/OfflineActivity.java @@ -4,6 +4,8 @@ import java.util.ArrayList; import org.fox.ttrss.CommonActivity; import org.fox.ttrss.DummyFragment; +import org.fox.ttrss.FeedCategoriesFragment; +import org.fox.ttrss.FeedsFragment; import org.fox.ttrss.MainActivity; import org.fox.ttrss.OnlineServices; import org.fox.ttrss.OnlineServices.RelativeArticle; @@ -604,6 +606,28 @@ public class OfflineActivity extends CommonActivity implements .findFragmentByTag(FRAG_HEADLINES); switch (item.getItemId()) { + case R.id.close_feed: + if (m_activeFeedId != 0 || m_activeFeedIsCat) { + FragmentTransaction ft = getSupportFragmentManager().beginTransaction(); + ft.replace(R.id.headlines_fragment, new DummyFragment(), ""); + ft.commit(); + + if (m_activeFeedIsCat) { + OfflineFeedCategoriesFragment cats = (OfflineFeedCategoriesFragment) getSupportFragmentManager().findFragmentByTag(FRAG_CATS); + cats.setSelectedFeedId(-1); + } else { + OfflineFeedsFragment feeds = (OfflineFeedsFragment) getSupportFragmentManager().findFragmentByTag(FRAG_FEEDS); + feeds.setSelectedFeedId(0); + } + + m_activeFeedId = 0; + + initMainMenu(); + } + return true; + case R.id.close_article: + closeArticle(); + return true; case android.R.id.home: goBack(false); return true; @@ -882,8 +906,23 @@ public class OfflineActivity extends CommonActivity implements } } else if (m_selectedArticleId != 0) { m_menu.setGroupVisible(R.id.menu_group_article, true); + m_menu.findItem(R.id.close_article).setVisible(!isSmallScreen()); + + if (android.os.Build.VERSION.SDK_INT >= 14) { + ShareActionProvider shareProvider = (ShareActionProvider) m_menu.findItem(R.id.share_article).getActionProvider(); + + if (m_selectedArticleId != 0) { + Log.d(TAG, "setting up share provider"); + shareProvider.setShareIntent(getShareIntent(getArticleById(m_selectedArticleId))); + + if (!m_prefs.getBoolean("tablet_article_swipe", false) && !isSmallScreen()) { + m_menu.findItem(R.id.share_article).setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM); + } + } + } } else if (m_activeFeedId != 0) { m_menu.setGroupVisible(R.id.menu_group_headlines, true); + m_menu.findItem(R.id.close_feed).setVisible(!isSmallScreen()); MenuItem search = m_menu.findItem(R.id.search); @@ -929,15 +968,6 @@ public class OfflineActivity extends CommonActivity implements if (numSelected == 0 && m_headlinesActionMode != null) { m_headlinesActionMode.finish(); } - - if (android.os.Build.VERSION.SDK_INT >= 14) { - ShareActionProvider shareProvider = (ShareActionProvider) m_menu.findItem(R.id.share_article).getActionProvider(); - - if (m_selectedArticleId != 0) { - Log.d(TAG, "setting up share provider"); - shareProvider.setShareIntent(getShareIntent(getArticleById(m_selectedArticleId))); - } - } } updateTitle();