From c1fce826e21e8608a3d4adf5b204d90ca03ca8af Mon Sep 17 00:00:00 2001 From: Denis Date: Mon, 15 Dec 2014 12:05:44 +0200 Subject: [PATCH] Added layout for tablet --- OsmAnd/res/layout-large-land/dashboard.xml | 59 +++++++++++++++++++ .../plus/activities/MainMenuActivity.java | 21 ++++++- 2 files changed, 77 insertions(+), 3 deletions(-) create mode 100644 OsmAnd/res/layout-large-land/dashboard.xml diff --git a/OsmAnd/res/layout-large-land/dashboard.xml b/OsmAnd/res/layout-large-land/dashboard.xml new file mode 100644 index 0000000000..f65699da38 --- /dev/null +++ b/OsmAnd/res/layout-large-land/dashboard.xml @@ -0,0 +1,59 @@ + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/OsmAnd/src/net/osmand/plus/activities/MainMenuActivity.java b/OsmAnd/src/net/osmand/plus/activities/MainMenuActivity.java index 585239d98d..e09c795af1 100644 --- a/OsmAnd/src/net/osmand/plus/activities/MainMenuActivity.java +++ b/OsmAnd/src/net/osmand/plus/activities/MainMenuActivity.java @@ -171,6 +171,7 @@ public class MainMenuActivity extends BaseDownloadActivity { public void addFragments(boolean firstTime) { android.support.v4.app.FragmentManager manager = getSupportFragmentManager(); android.support.v4.app.FragmentTransaction fragmentTransaction = manager.beginTransaction(); + boolean tablet = findViewById(R.id.content_land) != null; //after rotation list of fragments in fragment transaction is not cleared //so we need to check whether some fragments are already existing if (manager.findFragmentByTag(DashMapFragment.TAG) == null){ @@ -182,7 +183,11 @@ public class MainMenuActivity extends BaseDownloadActivity { } if (manager.findFragmentByTag(DashSearchFragment.TAG) == null){ DashSearchFragment searchFragment = new DashSearchFragment(); - fragmentTransaction.add(R.id.content, searchFragment, DashSearchFragment.TAG); + if (tablet) { + fragmentTransaction.add(R.id.content_land, searchFragment, DashSearchFragment.TAG); + } else { + fragmentTransaction.add(R.id.content, searchFragment, DashSearchFragment.TAG); + } } if (manager.findFragmentByTag(DashFavoritesFragment.TAG) == null){ DashFavoritesFragment favoritesFragment = new DashFavoritesFragment(); @@ -194,11 +199,21 @@ public class MainMenuActivity extends BaseDownloadActivity { } if (manager.findFragmentByTag(DashDownloadMapsFragment.TAG) == null){ DashDownloadMapsFragment fragment = new DashDownloadMapsFragment(); - fragmentTransaction.add(R.id.content, fragment, DashDownloadMapsFragment.TAG); + if (tablet) { + fragmentTransaction.add(R.id.content_land, fragment, DashDownloadMapsFragment.TAG); + } else { + fragmentTransaction.add(R.id.content, fragment, DashDownloadMapsFragment.TAG); + } + } if (manager.findFragmentByTag(DashPluginsFragment.TAG) == null){ DashPluginsFragment pluginsFragment = new DashPluginsFragment(); - fragmentTransaction.add(R.id.content, pluginsFragment, DashPluginsFragment.TAG).commit(); + if (tablet) { + fragmentTransaction.add(R.id.content_land, pluginsFragment, DashPluginsFragment.TAG).commit(); + } else { + fragmentTransaction.add(R.id.content, pluginsFragment, DashPluginsFragment.TAG).commit(); + } + } setupContributionVersion(); }