From 8c923e309f3701039f9591b0d8702e608ed10fb6 Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Tue, 28 May 2013 19:59:33 +0400 Subject: [PATCH] attempt at better reverse navigation --- src/org/fox/ttrss/FeedsActivity.java | 20 ++++++++++++------- .../ttrss/offline/OfflineFeedsActivity.java | 15 +++++++++----- 2 files changed, 23 insertions(+), 12 deletions(-) diff --git a/src/org/fox/ttrss/FeedsActivity.java b/src/org/fox/ttrss/FeedsActivity.java index 0925840a..18c7fcbf 100644 --- a/src/org/fox/ttrss/FeedsActivity.java +++ b/src/org/fox/ttrss/FeedsActivity.java @@ -73,10 +73,11 @@ public class FeedsActivity extends OnlineActivity implements HeadlinesEventListe public void onOpened() { if (m_actionbarRevertDepth == 0) { m_actionbarUpEnabled = false; - m_feedIsSelected = false; getSupportActionBar().setDisplayHomeAsUpEnabled(false); - initMenu(); } + + m_feedIsSelected = false; + initMenu(); } }); } @@ -256,11 +257,15 @@ public class FeedsActivity extends OnlineActivity implements HeadlinesEventListe public void onBackPressed() { if (m_actionbarRevertDepth > 0) { - m_actionbarRevertDepth = m_actionbarRevertDepth - 1; - m_actionbarUpEnabled = m_actionbarRevertDepth > 0; - getSupportActionBar().setDisplayHomeAsUpEnabled(m_actionbarUpEnabled); + if (m_feedIsSelected && m_slidingMenu != null && !m_slidingMenu.isMenuShowing()) { + m_slidingMenu.showMenu(); + } else { + m_actionbarRevertDepth = m_actionbarRevertDepth - 1; + m_actionbarUpEnabled = m_actionbarRevertDepth > 0; + getSupportActionBar().setDisplayHomeAsUpEnabled(m_actionbarUpEnabled); - onBackPressed(); + onBackPressed(); + } } else if (m_slidingMenu != null && !m_slidingMenu.isMenuShowing()) { m_slidingMenu.showMenu(); } else { @@ -272,7 +277,8 @@ public class FeedsActivity extends OnlineActivity implements HeadlinesEventListe public boolean onOptionsItemSelected(MenuItem item) { switch (item.getItemId()) { case android.R.id.home: - onBackPressed(); + if (m_actionbarUpEnabled) + onBackPressed(); return true; case R.id.show_feeds: setUnreadOnly(!getUnreadOnly()); diff --git a/src/org/fox/ttrss/offline/OfflineFeedsActivity.java b/src/org/fox/ttrss/offline/OfflineFeedsActivity.java index 608520cb..097b588e 100644 --- a/src/org/fox/ttrss/offline/OfflineFeedsActivity.java +++ b/src/org/fox/ttrss/offline/OfflineFeedsActivity.java @@ -129,11 +129,15 @@ public class OfflineFeedsActivity extends OfflineActivity implements OfflineHead public void onBackPressed() { if (m_actionbarRevertDepth > 0) { - m_actionbarRevertDepth = m_actionbarRevertDepth - 1; - m_actionbarUpEnabled = m_actionbarRevertDepth > 0; - getSupportActionBar().setDisplayHomeAsUpEnabled(m_actionbarUpEnabled); + if (m_feedIsSelected && m_slidingMenu != null && !m_slidingMenu.isMenuShowing()) { + m_slidingMenu.showMenu(); + } else { + m_actionbarRevertDepth = m_actionbarRevertDepth - 1; + m_actionbarUpEnabled = m_actionbarRevertDepth > 0; + getSupportActionBar().setDisplayHomeAsUpEnabled(m_actionbarUpEnabled); - onBackPressed(); + onBackPressed(); + } } else if (m_slidingMenu != null && !m_slidingMenu.isMenuShowing()) { m_slidingMenu.showMenu(); } else { @@ -145,7 +149,8 @@ public class OfflineFeedsActivity extends OfflineActivity implements OfflineHead public boolean onOptionsItemSelected(MenuItem item) { switch (item.getItemId()) { case android.R.id.home: - onBackPressed(); + if (m_actionbarUpEnabled) + onBackPressed(); return true; case R.id.show_feeds: setUnreadOnly(!getUnreadOnly());