for sw600dp track whether feed was previously selected to restore

slidingmenu to a proper width, set to full screen width as default
(closes #804)
This commit is contained in:
Andrew Dolgov 2013-11-15 15:38:23 +04:00
parent d7c69cf591
commit 50aa77ebb3
2 changed files with 33 additions and 6 deletions

View File

@ -39,6 +39,7 @@ public class FeedsActivity extends OnlineActivity implements HeadlinesEventListe
private int m_actionbarRevertDepth = 0; private int m_actionbarRevertDepth = 0;
private SlidingMenu m_slidingMenu; private SlidingMenu m_slidingMenu;
private boolean m_feedIsSelected = false; private boolean m_feedIsSelected = false;
private boolean m_feedWasSelected = false;
@SuppressLint("NewApi") @SuppressLint("NewApi")
@Override @Override
@ -53,15 +54,15 @@ public class FeedsActivity extends OnlineActivity implements HeadlinesEventListe
setContentView(R.layout.headlines); setContentView(R.layout.headlines);
setSmallScreen(findViewById(R.id.sw600dp_anchor) == null && setSmallScreen(findViewById(R.id.sw600dp_anchor) == null &&
findViewById(R.id.sw600dp_port_anchor) == null); findViewById(R.id.sw600dp_port_anchor) == null);
GlobalState.getInstance().load(savedInstanceState); GlobalState.getInstance().load(savedInstanceState);
if (isSmallScreen() || findViewById(R.id.sw600dp_port_anchor) != null) { if (isSmallScreen() || findViewById(R.id.sw600dp_port_anchor) != null) {
m_slidingMenu = new SlidingMenu(this); 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.setBehindWidth(getScreenWidthInPixel() * 2/3);
} } */
m_slidingMenu.setMode(SlidingMenu.LEFT); m_slidingMenu.setMode(SlidingMenu.LEFT);
m_slidingMenu.setTouchModeAbove(SlidingMenu.TOUCHMODE_FULLSCREEN); m_slidingMenu.setTouchModeAbove(SlidingMenu.TOUCHMODE_FULLSCREEN);
@ -133,7 +134,12 @@ public class FeedsActivity extends OnlineActivity implements HeadlinesEventListe
m_actionbarUpEnabled = savedInstanceState.getBoolean("actionbarUpEnabled"); m_actionbarUpEnabled = savedInstanceState.getBoolean("actionbarUpEnabled");
m_actionbarRevertDepth = savedInstanceState.getInt("actionbarRevertDepth"); m_actionbarRevertDepth = savedInstanceState.getInt("actionbarRevertDepth");
m_feedIsSelected = savedInstanceState.getBoolean("feedIsSelected"); 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) { if (m_slidingMenu != null && m_feedIsSelected == false) {
m_slidingMenu.showMenu(); m_slidingMenu.showMenu();
} else if (m_slidingMenu != null) { } else if (m_slidingMenu != null) {
@ -153,6 +159,7 @@ public class FeedsActivity extends OnlineActivity implements HeadlinesEventListe
if (container != null) if (container != null)
container.setWeightSum(3f); container.setWeightSum(3f);
} }
} }
/* if (!isCompatMode() && !isSmallScreen()) { /* if (!isCompatMode() && !isSmallScreen()) {
@ -228,11 +235,17 @@ public class FeedsActivity extends OnlineActivity implements HeadlinesEventListe
ft.commit(); ft.commit();
m_feedIsSelected = true; 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(); m_slidingMenu.showContent();
getSupportActionBar().setDisplayHomeAsUpEnabled(true); getSupportActionBar().setDisplayHomeAsUpEnabled(true);
m_actionbarUpEnabled = true; m_actionbarUpEnabled = true;
} }
} }
}, 10); }, 10);
@ -344,6 +357,7 @@ public class FeedsActivity extends OnlineActivity implements HeadlinesEventListe
out.putBoolean("actionbarUpEnabled", m_actionbarUpEnabled); out.putBoolean("actionbarUpEnabled", m_actionbarUpEnabled);
out.putInt("actionbarRevertDepth", m_actionbarRevertDepth); out.putInt("actionbarRevertDepth", m_actionbarRevertDepth);
out.putBoolean("feedIsSelected", m_feedIsSelected); out.putBoolean("feedIsSelected", m_feedIsSelected);
out.putBoolean("feedWasSelected", m_feedWasSelected);
//if (m_slidingMenu != null ) //if (m_slidingMenu != null )
// out.putBoolean("slidingMenuVisible", m_slidingMenu.isMenuShowing()); // out.putBoolean("slidingMenuVisible", m_slidingMenu.isMenuShowing());

View File

@ -27,6 +27,7 @@ public class OfflineFeedsActivity extends OfflineActivity implements OfflineHead
private int m_actionbarRevertDepth = 0; private int m_actionbarRevertDepth = 0;
private SlidingMenu m_slidingMenu; private SlidingMenu m_slidingMenu;
private boolean m_feedIsSelected = false; private boolean m_feedIsSelected = false;
private boolean m_feedWasSelected = false;
@SuppressLint("NewApi") @SuppressLint("NewApi")
@Override @Override
@ -47,9 +48,9 @@ public class OfflineFeedsActivity extends OfflineActivity implements OfflineHead
if (isSmallScreen() || findViewById(R.id.sw600dp_port_anchor) != null) { if (isSmallScreen() || findViewById(R.id.sw600dp_port_anchor) != null) {
m_slidingMenu = new SlidingMenu(this); 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.setBehindWidth(getScreenWidthInPixel() * 2/3);
} } */
m_slidingMenu.setMode(SlidingMenu.LEFT); m_slidingMenu.setMode(SlidingMenu.LEFT);
m_slidingMenu.setTouchModeAbove(SlidingMenu.TOUCHMODE_FULLSCREEN); m_slidingMenu.setTouchModeAbove(SlidingMenu.TOUCHMODE_FULLSCREEN);
@ -77,6 +78,11 @@ public class OfflineFeedsActivity extends OfflineActivity implements OfflineHead
m_actionbarUpEnabled = savedInstanceState.getBoolean("actionbarUpEnabled"); m_actionbarUpEnabled = savedInstanceState.getBoolean("actionbarUpEnabled");
m_actionbarRevertDepth = savedInstanceState.getInt("actionbarRevertDepth"); m_actionbarRevertDepth = savedInstanceState.getInt("actionbarRevertDepth");
m_feedIsSelected = savedInstanceState.getBoolean("feedIsSelected"); 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) { if (m_slidingMenu != null && m_feedIsSelected == false) {
m_slidingMenu.showMenu(); m_slidingMenu.showMenu();
@ -171,6 +177,8 @@ public class OfflineFeedsActivity extends OfflineActivity implements OfflineHead
out.putBoolean("actionbarUpEnabled", m_actionbarUpEnabled); out.putBoolean("actionbarUpEnabled", m_actionbarUpEnabled);
out.putInt("actionbarRevertDepth", m_actionbarRevertDepth); out.putInt("actionbarRevertDepth", m_actionbarRevertDepth);
out.putBoolean("feedIsSelected", m_feedIsSelected); out.putBoolean("feedIsSelected", m_feedIsSelected);
out.putBoolean("feedWasSelected", m_feedWasSelected);
//if (m_slidingMenu != null ) //if (m_slidingMenu != null )
// out.putBoolean("slidingMenuVisible", m_slidingMenu.isMenuShowing()); // out.putBoolean("slidingMenuVisible", m_slidingMenu.isMenuShowing());
@ -266,8 +274,13 @@ public class OfflineFeedsActivity extends OfflineActivity implements OfflineHead
ft.commit(); ft.commit();
m_feedIsSelected = true; 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(); m_slidingMenu.showContent();
getSupportActionBar().setDisplayHomeAsUpEnabled(true); getSupportActionBar().setDisplayHomeAsUpEnabled(true);
m_actionbarUpEnabled = true; m_actionbarUpEnabled = true;