From 918235592ada25cab9da734b109921dcd7e87a85 Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Wed, 30 Nov 2011 13:43:02 +0300 Subject: [PATCH] handle layout selection by android means --- .../main.xml | 0 .../headlines_row.xml | 0 .../headlines_row_selected.xml | 0 .../headlines_row_unread.xml | 0 res/layout-xlarge/main.xml | 16 +++++ .../headlines_row.xml | 0 .../headlines_row_selected.xml | 0 .../headlines_row_unread.xml | 0 res/layout/main.xml | 70 +++++++++++++++---- res/layout/main_small.xml | 56 --------------- src/org/fox/ttrss/MainActivity.java | 25 +++---- 11 files changed, 79 insertions(+), 88 deletions(-) rename res/{layout-port => layout-xlarge-port}/main.xml (100%) rename res/{layout-land => layout-xlarge}/headlines_row.xml (100%) rename res/{layout-land => layout-xlarge}/headlines_row_selected.xml (100%) rename res/{layout-land => layout-xlarge}/headlines_row_unread.xml (100%) create mode 100644 res/layout-xlarge/main.xml rename res/{layout-large => layout}/headlines_row.xml (100%) rename res/{layout-large => layout}/headlines_row_selected.xml (100%) rename res/{layout-large => layout}/headlines_row_unread.xml (100%) delete mode 100644 res/layout/main_small.xml diff --git a/res/layout-port/main.xml b/res/layout-xlarge-port/main.xml similarity index 100% rename from res/layout-port/main.xml rename to res/layout-xlarge-port/main.xml diff --git a/res/layout-land/headlines_row.xml b/res/layout-xlarge/headlines_row.xml similarity index 100% rename from res/layout-land/headlines_row.xml rename to res/layout-xlarge/headlines_row.xml diff --git a/res/layout-land/headlines_row_selected.xml b/res/layout-xlarge/headlines_row_selected.xml similarity index 100% rename from res/layout-land/headlines_row_selected.xml rename to res/layout-xlarge/headlines_row_selected.xml diff --git a/res/layout-land/headlines_row_unread.xml b/res/layout-xlarge/headlines_row_unread.xml similarity index 100% rename from res/layout-land/headlines_row_unread.xml rename to res/layout-xlarge/headlines_row_unread.xml diff --git a/res/layout-xlarge/main.xml b/res/layout-xlarge/main.xml new file mode 100644 index 00000000..e0a8394c --- /dev/null +++ b/res/layout-xlarge/main.xml @@ -0,0 +1,16 @@ + + + + + + + + + + + + + + \ No newline at end of file diff --git a/res/layout-large/headlines_row.xml b/res/layout/headlines_row.xml similarity index 100% rename from res/layout-large/headlines_row.xml rename to res/layout/headlines_row.xml diff --git a/res/layout-large/headlines_row_selected.xml b/res/layout/headlines_row_selected.xml similarity index 100% rename from res/layout-large/headlines_row_selected.xml rename to res/layout/headlines_row_selected.xml diff --git a/res/layout-large/headlines_row_unread.xml b/res/layout/headlines_row_unread.xml similarity index 100% rename from res/layout-large/headlines_row_unread.xml rename to res/layout/headlines_row_unread.xml diff --git a/res/layout/main.xml b/res/layout/main.xml index e0a8394c..0215f270 100644 --- a/res/layout/main.xml +++ b/res/layout/main.xml @@ -1,16 +1,56 @@ - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/res/layout/main_small.xml b/res/layout/main_small.xml deleted file mode 100644 index 0215f270..00000000 --- a/res/layout/main_small.xml +++ /dev/null @@ -1,56 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/src/org/fox/ttrss/MainActivity.java b/src/org/fox/ttrss/MainActivity.java index f51ef307..ab2f59b1 100644 --- a/src/org/fox/ttrss/MainActivity.java +++ b/src/org/fox/ttrss/MainActivity.java @@ -310,22 +310,17 @@ public class MainActivity extends FragmentActivity implements FeedsFragment.OnFe m_enableCats = m_prefs.getBoolean("enable_cats", false); Display display = getWindowManager().getDefaultDisplay(); - int orientation = display.getOrientation(); - int minWidth = orientation % 2 == 0 ? 1024 : 600; - int minHeight = orientation % 2 == 0 ? 600 : 1024; - if (display.getWidth() > minWidth && display.getHeight() >= minHeight) { - m_smallScreenMode = false; - - setContentView(R.layout.main); - } else { - m_smallScreenMode = true; + int width = display.getWidth(); + int height = display.getHeight(); + + if (height > width) { int tmp = height; width = tmp; height = width; } + + m_smallScreenMode = width < 960 || height < 720; + + setContentView(R.layout.main); - setContentView(R.layout.main_small); - } - Log.d(TAG, "m_smallScreenMode=" + m_smallScreenMode); - Log.d(TAG, "orientation=" + display.getOrientation()); Log.d(TAG, "m_compatMode=" + m_compatMode); if (!m_compatMode) { @@ -1291,8 +1286,4 @@ public class MainActivity extends FragmentActivity implements FeedsFragment.OnFe Log.d(TAG, "onCatSelected"); viewCategory(cat, m_prefs.getBoolean("browse_cats_like_feeds", false)); } - - public boolean getSmallScreenMode() { - return m_smallScreenMode; - } } \ No newline at end of file