From 9611c7f2619e854104331c8cad8113a4462940c6 Mon Sep 17 00:00:00 2001 From: Victor Shcherb Date: Tue, 26 Jul 2011 00:35:56 +0200 Subject: [PATCH] Select specific tab for search activity --- .../osmand/plus/activities/MapActivity.java | 1 + .../activities/NavigatePointActivity.java | 1 - .../activities/search/SearchActivity.java | 23 +++++++++++++------ 3 files changed, 17 insertions(+), 8 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/activities/MapActivity.java b/OsmAnd/src/net/osmand/plus/activities/MapActivity.java index 4a630b9463..72e3635000 100644 --- a/OsmAnd/src/net/osmand/plus/activities/MapActivity.java +++ b/OsmAnd/src/net/osmand/plus/activities/MapActivity.java @@ -1009,6 +1009,7 @@ public class MapActivity extends Activity implements IMapLocationListener, Senso // dlg.showDialog(); Intent newIntent = new Intent(MapActivity.this, SearchActivity.class); newIntent.setFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT); + newIntent.putExtra(SearchActivity.TAB_INDEX_EXTRA, SearchActivity.LOCATION_TAB_INDEX); startActivity(newIntent); return true; case R.id.map_mute: diff --git a/OsmAnd/src/net/osmand/plus/activities/NavigatePointActivity.java b/OsmAnd/src/net/osmand/plus/activities/NavigatePointActivity.java index c0b5a62694..6867f6d7f3 100644 --- a/OsmAnd/src/net/osmand/plus/activities/NavigatePointActivity.java +++ b/OsmAnd/src/net/osmand/plus/activities/NavigatePointActivity.java @@ -14,7 +14,6 @@ import net.osmand.plus.R; import net.osmand.plus.views.OsmandMapTileView; import android.app.Activity; import android.app.Dialog; -import android.content.Intent; import android.location.Location; import android.os.Bundle; import android.util.Log; diff --git a/OsmAnd/src/net/osmand/plus/activities/search/SearchActivity.java b/OsmAnd/src/net/osmand/plus/activities/search/SearchActivity.java index 878ec2e8a6..cb7347eddf 100644 --- a/OsmAnd/src/net/osmand/plus/activities/search/SearchActivity.java +++ b/OsmAnd/src/net/osmand/plus/activities/search/SearchActivity.java @@ -1,8 +1,6 @@ -/** - * - */ package net.osmand.plus.activities.search; +import net.osmand.osm.LatLon; import net.osmand.plus.R; import net.osmand.plus.activities.NavigatePointActivity; import android.app.TabActivity; @@ -13,20 +11,30 @@ import android.widget.TabHost; import android.widget.TabHost.TabSpec; -/** - * @author Maxim Frolov - * - */ public class SearchActivity extends TabActivity { + public static final int POI_TAB_INDEX = 0; + public static final int ADDRESS_TAB_INDEX = 1; + public static final int LOCATION_TAB_INDEX = 2; + public static final int TRANSPORT_TAB_INDEX = 3; + public static final int HISTORY_TAB_INDEX = 4; + public static final String TAB_INDEX_EXTRA = "TAB_INDEX_EXTRA"; Button searchPOIButton; private TabSpec addressSpec; private static boolean searchOnLine = false; + @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); + Intent intent = getIntent(); +// LatLon latLon = null; + int tabIndex = 0; + if(intent != null){ + tabIndex = intent.getIntExtra(TAB_INDEX_EXTRA, POI_TAB_INDEX); + } + TabHost host = getTabHost(); host.addTab(host.newTabSpec("Search_POI").setIndicator(getString(R.string.poi)).setContent(new Intent(this, SearchPoiFilterActivity.class))); //$NON-NLS-1$ @@ -37,6 +45,7 @@ public class SearchActivity extends TabActivity { host.addTab(host.newTabSpec("Search_Location").setIndicator(getString(R.string.search_tabs_location)).setContent(new Intent(this, NavigatePointActivity.class))); //$NON-NLS-1$ // host.addTab(host.newTabSpec("Search_Transport").setIndicator(getString(R.string.transport)).setContent(new Intent(this, SearchTransportActivity.class))); //$NON-NLS-1$ host.addTab(host.newTabSpec("Search_History").setIndicator(getString(R.string.history)).setContent(new Intent(this, SearchHistoryActivity.class))); //$NON-NLS-1$ + host.setCurrentTab(tabIndex); } public void startSearchAddressOffline(){