diff --git a/OsmAnd/res/layout/search_by_name.xml b/OsmAnd/res/layout/search_by_name.xml
index f006669e65..c38d4553ed 100644
--- a/OsmAnd/res/layout/search_by_name.xml
+++ b/OsmAnd/res/layout/search_by_name.xml
@@ -3,11 +3,17 @@
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent" android:orientation="vertical">
-
+
+
+
+
-
+
+
diff --git a/OsmAnd/src/net/osmand/plus/activities/search/SearchAddressOnlineActivity.java b/OsmAnd/src/net/osmand/plus/activities/search/SearchAddressOnlineActivity.java
index e91510c601..1d93061619 100644
--- a/OsmAnd/src/net/osmand/plus/activities/search/SearchAddressOnlineActivity.java
+++ b/OsmAnd/src/net/osmand/plus/activities/search/SearchAddressOnlineActivity.java
@@ -8,6 +8,7 @@ import java.util.ArrayList;
import java.util.List;
import java.util.Locale;
+import net.londatiga.android.QuickAction;
import net.osmand.Algoritms;
import net.osmand.LogUtil;
import net.osmand.OsmAndFormatter;
@@ -18,7 +19,7 @@ import net.osmand.osm.MapUtils;
import net.osmand.plus.OsmandApplication;
import net.osmand.plus.OsmandSettings;
import net.osmand.plus.R;
-import net.osmand.plus.activities.MapActivity;
+import net.osmand.plus.activities.MapActivityActions;
import net.osmand.plus.activities.OsmandListActivity;
import net.osmand.plus.activities.search.SearchActivity.SearchActivityChild;
@@ -214,9 +215,11 @@ public class SearchAddressOnlineActivity extends OsmandListActivity implements S
protected void onListItemClick(ListView l, View v, int position, long id) {
super.onListItemClick(l, v, position, id);
Place item = ((PlacesAdapter) getListAdapter()).getItem(position);
- settings.setMapLocationToShow(item.lat, item.lon,
- Math.max(15, settings.getLastKnownMapZoom()), getString(R.string.address)+ " : " + item.displayName); //$NON-NLS-1$
- MapActivity.launchMapActivityMoveToTop(this);
+ QuickAction qa = new QuickAction(v);
+ MapActivityActions.createDirectionsActions(qa, new LatLon(item.lat, item.lon), item,
+ getString(R.string.address)+ " : " + item.displayName, Math.max(15, settings.getLastKnownMapZoom()),
+ this, true, null);
+ qa.show();
}
private static class Place {
diff --git a/OsmAnd/src/net/osmand/plus/activities/search/SearchByNameAbstractActivity.java b/OsmAnd/src/net/osmand/plus/activities/search/SearchByNameAbstractActivity.java
index b1350f096b..c6b9849468 100644
--- a/OsmAnd/src/net/osmand/plus/activities/search/SearchByNameAbstractActivity.java
+++ b/OsmAnd/src/net/osmand/plus/activities/search/SearchByNameAbstractActivity.java
@@ -5,21 +5,28 @@ import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.Comparator;
+import java.util.HashSet;
import java.util.List;
import java.util.Locale;
+import java.util.Set;
+import net.londatiga.android.QuickAction;
import net.osmand.CollatorStringMatcher;
import net.osmand.CollatorStringMatcher.StringMatcherMode;
import net.osmand.LogUtil;
+import net.osmand.data.MapObject;
import net.osmand.osm.LatLon;
import net.osmand.plus.OsmandApplication;
import net.osmand.plus.OsmandSettings;
import net.osmand.plus.R;
+import net.osmand.plus.activities.CustomTitleBar;
+import net.osmand.plus.activities.MapActivityActions;
import net.osmand.plus.activities.OsmandListActivity;
import org.apache.commons.logging.Log;
import android.content.Intent;
+import android.location.Location;
import android.os.AsyncTask;
import android.os.AsyncTask.Status;
import android.os.Bundle;
@@ -29,12 +36,15 @@ import android.text.Editable;
import android.text.TextWatcher;
import android.view.LayoutInflater;
import android.view.View;
+import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.view.Window;
import android.view.WindowManager;
import android.widget.ArrayAdapter;
+import android.widget.Button;
import android.widget.EditText;
import android.widget.Filter;
+import android.widget.Filter.FilterListener;
import android.widget.ListView;
import android.widget.ProgressBar;
import android.widget.TextView;
@@ -56,19 +66,23 @@ public abstract class SearchByNameAbstractActivity extends OsmandListActivity
protected Collator collator;
protected NamesFilter namesFilter;
private String currentFilter = "";
+ private Button endingButton;
+ private Set endingSet = new HashSet();
+ private T endingObject;
private static final Log log = LogUtil.getLog(SearchByNameAbstractActivity.class);
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
settings = ((OsmandApplication) getApplication()).getSettings();
- requestWindowFeature(Window.FEATURE_NO_TITLE);
+ CustomTitleBar titleBar = new CustomTitleBar(this, R.string.search_activity, R.drawable.tab_search_address_icon);
setContentView(R.layout.search_by_name);
+ titleBar.afterSetContentView();
initializeTask = getInitializeTask();
uiHandler = new UIUpdateHandler();
namesFilter = new NamesFilter();
- NamesAdapter namesAdapter = new NamesAdapter(new ArrayList(),createComparator()); //$NON-NLS-1$
+ final NamesAdapter namesAdapter = new NamesAdapter(new ArrayList(), createComparator()); //$NON-NLS-1$
setListAdapter(namesAdapter);
collator = Collator.getInstance(Locale.US);
@@ -76,6 +90,24 @@ public abstract class SearchByNameAbstractActivity extends OsmandListActivity
progress = (ProgressBar) findViewById(R.id.ProgressBar);
+ endingButton = (Button) findViewById(R.id.EndingButton);
+ endingButton.setOnClickListener(new OnClickListener() {
+
+ @Override
+ public void onClick(View v) {
+ T obj = endingObject;
+ LatLon loc = getLocation(obj);
+ if (obj != null && loc != null) {
+ QuickAction qa = new QuickAction(v);
+ // TODO more granular description and text message!
+ MapActivityActions.createDirectionsActions(qa, loc,
+ obj, getText(obj), getZoomToDisplay(endingObject),
+ SearchByNameAbstractActivity.this, true, null);
+ qa.show();
+ }
+
+ }
+ });
searchText = (EditText) findViewById(R.id.SearchText);
searchText.addTextChangedListener(new TextWatcher(){
@@ -98,7 +130,6 @@ public abstract class SearchByNameAbstractActivity extends OsmandListActivity
public void onClick(View v) {
searchText.setText("");
}
-
});
getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_VISIBLE);
if(initializeTask != null){
@@ -106,6 +137,17 @@ public abstract class SearchByNameAbstractActivity extends OsmandListActivity
}
}
+ protected int getZoomToDisplay(T item){
+ return 15;
+ }
+
+ protected LatLon getLocation(T item) {
+ if (item instanceof MapObject) {
+ return ((MapObject) item).getLocation();
+ }
+ return null;
+ }
+
public AsyncTask