diff --git a/res/layout-sw600dp/headlines.xml b/res/layout-sw600dp-land/headlines.xml similarity index 90% rename from res/layout-sw600dp/headlines.xml rename to res/layout-sw600dp-land/headlines.xml index 7e7f0e52..93324ebb 100644 --- a/res/layout-sw600dp/headlines.xml +++ b/res/layout-sw600dp-land/headlines.xml @@ -32,14 +32,14 @@ android:layout_width="match_parent" android:layout_height="match_parent" android:baselineAligned="false" - android:weightSum="1.3" + android:weightSum="1.1" android:orientation="horizontal" > @@ -47,7 +47,7 @@ android:id="@+id/headlines_fragment" android:layout_width="0dp" android:layout_height="match_parent" - android:layout_weight="1.9" + android:layout_weight="2" android:background="?headlinesBackground" > diff --git a/res/layout-sw600dp/headlines_articles.xml b/res/layout-sw600dp-land/headlines_articles.xml similarity index 100% rename from res/layout-sw600dp/headlines_articles.xml rename to res/layout-sw600dp-land/headlines_articles.xml diff --git a/res/layout-sw600dp-port/headlines.xml b/res/layout-sw600dp-port/headlines.xml new file mode 100644 index 00000000..866c31a6 --- /dev/null +++ b/res/layout-sw600dp-port/headlines.xml @@ -0,0 +1,35 @@ + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/res/layout-sw700dp/headlines.xml b/res/layout-sw700dp/headlines.xml new file mode 100644 index 00000000..93324ebb --- /dev/null +++ b/res/layout-sw700dp/headlines.xml @@ -0,0 +1,55 @@ + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/res/layout-sw700dp/headlines_articles.xml b/res/layout-sw700dp/headlines_articles.xml new file mode 100644 index 00000000..b6cb1c38 --- /dev/null +++ b/res/layout-sw700dp/headlines_articles.xml @@ -0,0 +1,49 @@ + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/org/fox/ttrss/CommonActivity.java b/src/org/fox/ttrss/CommonActivity.java index 78d1937c..0b41e3ab 100644 --- a/src/org/fox/ttrss/CommonActivity.java +++ b/src/org/fox/ttrss/CommonActivity.java @@ -7,6 +7,7 @@ import com.actionbarsherlock.app.SherlockFragmentActivity; import android.annotation.SuppressLint; import android.content.SharedPreferences; import android.database.sqlite.SQLiteDatabase; +import android.graphics.Point; import android.os.Build; import android.os.Bundle; import android.preference.PreferenceManager; @@ -151,7 +152,7 @@ public class CommonActivity extends SherlockFragmentActivity { return width < height; } - @SuppressLint("NewApi") + @SuppressLint({ "NewApi", "ServiceCast" }) @SuppressWarnings("deprecation") public void copyToClipboard(String str) { if (android.os.Build.VERSION.SDK_INT < 11) { @@ -186,4 +187,19 @@ public class CommonActivity extends SherlockFragmentActivity { setTheme(R.style.LightTheme); } } + + @SuppressWarnings("deprecation") + @SuppressLint("NewApi") + protected int getScreenWidthInPixel() { + Display display = getWindowManager().getDefaultDisplay(); + + if (android.os.Build.VERSION.SDK_INT >= 13) { + Point size = new Point(); + display.getSize(size); + int width = size.x; + return width; + } else { + return display.getWidth(); + } + } } diff --git a/src/org/fox/ttrss/FeedsActivity.java b/src/org/fox/ttrss/FeedsActivity.java index 3ba96c4f..47781cce 100644 --- a/src/org/fox/ttrss/FeedsActivity.java +++ b/src/org/fox/ttrss/FeedsActivity.java @@ -37,6 +37,7 @@ public class FeedsActivity extends OnlineActivity implements HeadlinesEventListe private boolean m_actionbarUpEnabled = false; private int m_actionbarRevertDepth = 0; private SlidingMenu m_slidingMenu; + private boolean m_feedIsSelected = false; @SuppressLint("NewApi") @Override @@ -49,18 +50,23 @@ public class FeedsActivity extends OnlineActivity implements HeadlinesEventListe super.onCreate(savedInstanceState); 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); GlobalState.getInstance().load(savedInstanceState); - if (isSmallScreen()) { + if (isSmallScreen() || findViewById(R.id.sw600dp_port_anchor) != null) { m_slidingMenu = new SlidingMenu(this); - + + 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); m_slidingMenu.attachToActivity(this, SlidingMenu.SLIDING_CONTENT); - m_slidingMenu.setSlidingEnabled(true); m_slidingMenu.setMenu(R.layout.feeds); + m_slidingMenu.setSlidingEnabled(true); m_slidingMenu.setOnOpenedListener(new SlidingMenu.OnOpenedListener() { @Override @@ -94,14 +100,17 @@ public class FeedsActivity extends OnlineActivity implements HeadlinesEventListe } else { // savedInstanceState != null m_actionbarUpEnabled = savedInstanceState.getBoolean("actionbarUpEnabled"); m_actionbarRevertDepth = savedInstanceState.getInt("actionbarRevertDepth"); + m_feedIsSelected = savedInstanceState.getBoolean("feedIsSelected"); - if (m_slidingMenu != null && savedInstanceState.getBoolean("slidingMenuVisible")) + if (m_slidingMenu != null && m_feedIsSelected == false) m_slidingMenu.showMenu(); if (!isSmallScreen()) { // temporary hack because FeedsActivity doesn't track whether active feed is open LinearLayout container = (LinearLayout) findViewById(R.id.fragment_container); - container.setWeightSum(3f); + + if (container != null) + container.setWeightSum(3f); } if (m_actionbarUpEnabled) { @@ -109,10 +118,10 @@ public class FeedsActivity extends OnlineActivity implements HeadlinesEventListe } } - if (!isCompatMode() && !isSmallScreen()) { + /* if (!isCompatMode() && !isSmallScreen()) { ((ViewGroup)findViewById(R.id.headlines_fragment)).setLayoutTransition(new LayoutTransition()); ((ViewGroup)findViewById(R.id.feeds_fragment)).setLayoutTransition(new LayoutTransition()); - } + } */ } @@ -156,11 +165,13 @@ public class FeedsActivity extends OnlineActivity implements HeadlinesEventListe if (!isCompatMode() && !isSmallScreen()) { LinearLayout container = (LinearLayout) findViewById(R.id.fragment_container); - float wSum = container.getWeightSum(); - if (wSum <= 2.0f) { - ObjectAnimator anim = ObjectAnimator.ofFloat(container, "weightSum", wSum, 3.0f); - anim.setDuration(200); - anim.start(); + if (container != null) { + float wSum = container.getWeightSum(); + if (wSum <= 2.0f) { + ObjectAnimator anim = ObjectAnimator.ofFloat(container, "weightSum", wSum, 3.0f); + anim.setDuration(200); + anim.start(); + } } } @@ -177,6 +188,8 @@ public class FeedsActivity extends OnlineActivity implements HeadlinesEventListe ft.replace(R.id.headlines_fragment, hf, FRAG_HEADLINES); ft.commit(); + + m_feedIsSelected = true; if (m_slidingMenu != null) { m_slidingMenu.showContent(); @@ -284,9 +297,10 @@ public class FeedsActivity extends OnlineActivity implements HeadlinesEventListe out.putBoolean("actionbarUpEnabled", m_actionbarUpEnabled); out.putInt("actionbarRevertDepth", m_actionbarRevertDepth); + out.putBoolean("feedIsSelected", m_feedIsSelected); - if (m_slidingMenu != null ) - out.putBoolean("slidingMenuVisible", m_slidingMenu.isMenuShowing()); + //if (m_slidingMenu != null ) + // out.putBoolean("slidingMenuVisible", m_slidingMenu.isMenuShowing()); GlobalState.getInstance().save(out); } diff --git a/src/org/fox/ttrss/offline/OfflineFeedsActivity.java b/src/org/fox/ttrss/offline/OfflineFeedsActivity.java index bfc4485d..507e08ef 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 boolean m_actionbarUpEnabled = false; private int m_actionbarRevertDepth = 0; private SlidingMenu m_slidingMenu; + private boolean m_feedIsSelected = false; @SuppressLint("NewApi") @Override @@ -39,13 +40,18 @@ public class OfflineFeedsActivity extends OfflineActivity implements OfflineHead super.onCreate(savedInstanceState); 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); GlobalState.getInstance().load(savedInstanceState); - if (isSmallScreen()) { + if (isSmallScreen() || findViewById(R.id.sw600dp_port_anchor) != null) { m_slidingMenu = new SlidingMenu(this); - + + 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); m_slidingMenu.attachToActivity(this, SlidingMenu.SLIDING_CONTENT); @@ -68,6 +74,10 @@ public class OfflineFeedsActivity extends OfflineActivity implements OfflineHead m_actionbarUpEnabled = savedInstanceState.getBoolean("actionbarUpEnabled"); m_actionbarRevertDepth = savedInstanceState.getInt("actionbarRevertDepth"); + m_feedIsSelected = savedInstanceState.getBoolean("feedIsSelected"); + + if (!m_feedIsSelected && m_slidingMenu != null) + m_slidingMenu.showMenu(); if (m_actionbarUpEnabled) { getSupportActionBar().setDisplayHomeAsUpEnabled(true); @@ -148,6 +158,10 @@ public class OfflineFeedsActivity extends OfflineActivity implements OfflineHead out.putBoolean("actionbarUpEnabled", m_actionbarUpEnabled); out.putInt("actionbarRevertDepth", m_actionbarRevertDepth); + out.putBoolean("feedIsSelected", m_feedIsSelected); + + //if (m_slidingMenu != null ) + // out.putBoolean("slidingMenuVisible", m_slidingMenu.isMenuShowing()); GlobalState.getInstance().save(out); } @@ -222,7 +236,9 @@ public class OfflineFeedsActivity extends OfflineActivity implements OfflineHead if (open) { if (!isSmallScreen()) { LinearLayout container = (LinearLayout) findViewById(R.id.fragment_container); - container.setWeightSum(3f); + if (container != null) { + container.setWeightSum(3f); + } } new Handler().postDelayed(new Runnable() { @@ -236,7 +252,9 @@ public class OfflineFeedsActivity extends OfflineActivity implements OfflineHead ft.replace(R.id.headlines_fragment, hf, FRAG_HEADLINES); ft.commit(); - + + m_feedIsSelected = true; + if (m_slidingMenu != null) { m_slidingMenu.showContent(); getSupportActionBar().setDisplayHomeAsUpEnabled(true);