From 50aa77ebb3354923645b29d40726fad520824ea5 Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Fri, 15 Nov 2013 15:38:23 +0400 Subject: [PATCH] for sw600dp track whether feed was previously selected to restore slidingmenu to a proper width, set to full screen width as default (closes #804) --- src/org/fox/ttrss/FeedsActivity.java | 22 +++++++++++++++---- .../ttrss/offline/OfflineFeedsActivity.java | 17 ++++++++++++-- 2 files changed, 33 insertions(+), 6 deletions(-) diff --git a/src/org/fox/ttrss/FeedsActivity.java b/src/org/fox/ttrss/FeedsActivity.java index 2a49fff0..242ca1cf 100644 --- a/src/org/fox/ttrss/FeedsActivity.java +++ b/src/org/fox/ttrss/FeedsActivity.java @@ -39,6 +39,7 @@ public class FeedsActivity extends OnlineActivity implements HeadlinesEventListe private int m_actionbarRevertDepth = 0; private SlidingMenu m_slidingMenu; private boolean m_feedIsSelected = false; + private boolean m_feedWasSelected = false; @SuppressLint("NewApi") @Override @@ -53,15 +54,15 @@ public class FeedsActivity extends OnlineActivity implements HeadlinesEventListe setContentView(R.layout.headlines); setSmallScreen(findViewById(R.id.sw600dp_anchor) == null && findViewById(R.id.sw600dp_port_anchor) == null); - + GlobalState.getInstance().load(savedInstanceState); if (isSmallScreen() || findViewById(R.id.sw600dp_port_anchor) != null) { m_slidingMenu = new SlidingMenu(this); - if (findViewById(R.id.sw600dp_port_anchor) != null) { +/* if (findViewById(R.id.sw600dp_port_anchor) != null) { m_slidingMenu.setBehindWidth(getScreenWidthInPixel() * 2/3); - } + } */ m_slidingMenu.setMode(SlidingMenu.LEFT); m_slidingMenu.setTouchModeAbove(SlidingMenu.TOUCHMODE_FULLSCREEN); @@ -133,7 +134,12 @@ public class FeedsActivity extends OnlineActivity implements HeadlinesEventListe m_actionbarUpEnabled = savedInstanceState.getBoolean("actionbarUpEnabled"); m_actionbarRevertDepth = savedInstanceState.getInt("actionbarRevertDepth"); m_feedIsSelected = savedInstanceState.getBoolean("feedIsSelected"); + m_feedWasSelected = savedInstanceState.getBoolean("feedWasSelected"); + if (findViewById(R.id.sw600dp_port_anchor) != null && m_feedWasSelected && m_slidingMenu != null) { + m_slidingMenu.setBehindWidth(getScreenWidthInPixel() * 2/3); + } + if (m_slidingMenu != null && m_feedIsSelected == false) { m_slidingMenu.showMenu(); } else if (m_slidingMenu != null) { @@ -153,6 +159,7 @@ public class FeedsActivity extends OnlineActivity implements HeadlinesEventListe if (container != null) container.setWeightSum(3f); } + } /* if (!isCompatMode() && !isSmallScreen()) { @@ -228,11 +235,17 @@ public class FeedsActivity extends OnlineActivity implements HeadlinesEventListe ft.commit(); m_feedIsSelected = true; + m_feedWasSelected = true; - if (m_slidingMenu != null) { + if (m_slidingMenu != null) { + if (findViewById(R.id.sw600dp_port_anchor) != null) { + m_slidingMenu.setBehindWidth(getScreenWidthInPixel() * 2/3); + } + m_slidingMenu.showContent(); getSupportActionBar().setDisplayHomeAsUpEnabled(true); m_actionbarUpEnabled = true; + } } }, 10); @@ -344,6 +357,7 @@ public class FeedsActivity extends OnlineActivity implements HeadlinesEventListe out.putBoolean("actionbarUpEnabled", m_actionbarUpEnabled); out.putInt("actionbarRevertDepth", m_actionbarRevertDepth); out.putBoolean("feedIsSelected", m_feedIsSelected); + out.putBoolean("feedWasSelected", m_feedWasSelected); //if (m_slidingMenu != null ) // out.putBoolean("slidingMenuVisible", m_slidingMenu.isMenuShowing()); diff --git a/src/org/fox/ttrss/offline/OfflineFeedsActivity.java b/src/org/fox/ttrss/offline/OfflineFeedsActivity.java index cc14bded..694095dc 100644 --- a/src/org/fox/ttrss/offline/OfflineFeedsActivity.java +++ b/src/org/fox/ttrss/offline/OfflineFeedsActivity.java @@ -27,6 +27,7 @@ public class OfflineFeedsActivity extends OfflineActivity implements OfflineHead private int m_actionbarRevertDepth = 0; private SlidingMenu m_slidingMenu; private boolean m_feedIsSelected = false; + private boolean m_feedWasSelected = false; @SuppressLint("NewApi") @Override @@ -47,9 +48,9 @@ public class OfflineFeedsActivity extends OfflineActivity implements OfflineHead if (isSmallScreen() || findViewById(R.id.sw600dp_port_anchor) != null) { m_slidingMenu = new SlidingMenu(this); - if (findViewById(R.id.sw600dp_port_anchor) != null) { + /* if (findViewById(R.id.sw600dp_port_anchor) != null) { m_slidingMenu.setBehindWidth(getScreenWidthInPixel() * 2/3); - } + } */ m_slidingMenu.setMode(SlidingMenu.LEFT); m_slidingMenu.setTouchModeAbove(SlidingMenu.TOUCHMODE_FULLSCREEN); @@ -77,6 +78,11 @@ public class OfflineFeedsActivity extends OfflineActivity implements OfflineHead m_actionbarUpEnabled = savedInstanceState.getBoolean("actionbarUpEnabled"); m_actionbarRevertDepth = savedInstanceState.getInt("actionbarRevertDepth"); m_feedIsSelected = savedInstanceState.getBoolean("feedIsSelected"); + m_feedWasSelected = savedInstanceState.getBoolean("feedWasSelected"); + + if (findViewById(R.id.sw600dp_port_anchor) != null && m_feedWasSelected && m_slidingMenu != null) { + m_slidingMenu.setBehindWidth(getScreenWidthInPixel() * 2/3); + } if (m_slidingMenu != null && m_feedIsSelected == false) { m_slidingMenu.showMenu(); @@ -171,6 +177,8 @@ public class OfflineFeedsActivity extends OfflineActivity implements OfflineHead out.putBoolean("actionbarUpEnabled", m_actionbarUpEnabled); out.putInt("actionbarRevertDepth", m_actionbarRevertDepth); out.putBoolean("feedIsSelected", m_feedIsSelected); + out.putBoolean("feedWasSelected", m_feedWasSelected); + //if (m_slidingMenu != null ) // out.putBoolean("slidingMenuVisible", m_slidingMenu.isMenuShowing()); @@ -266,8 +274,13 @@ public class OfflineFeedsActivity extends OfflineActivity implements OfflineHead ft.commit(); m_feedIsSelected = true; + m_feedWasSelected = true; if (m_slidingMenu != null) { + if (findViewById(R.id.sw600dp_port_anchor) != null) { + m_slidingMenu.setBehindWidth(getScreenWidthInPixel() * 2/3); + } + m_slidingMenu.showContent(); getSupportActionBar().setDisplayHomeAsUpEnabled(true); m_actionbarUpEnabled = true;