Improving search UI
This commit is contained in:
parent
193faa4799
commit
8e03bb33fe
11 changed files with 102 additions and 37 deletions
|
@ -15,9 +15,6 @@ import java.util.zip.ZipInputStream;
|
|||
import org.apache.commons.logging.Log;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.graphics.drawable.Drawable.Callback;
|
||||
import android.os.AsyncTask;
|
||||
import android.widget.Toast;
|
||||
|
||||
import net.osmand.IProgress;
|
||||
import net.osmand.LogUtil;
|
||||
|
|
|
@ -454,6 +454,9 @@ public class MapActivity extends Activity implements IMapLocationListener, Senso
|
|||
@Override
|
||||
public void onClick(View v) {
|
||||
final Intent search = new Intent(MapActivity.this, SearchActivity.class);
|
||||
LatLon loc = getMapLocation();
|
||||
search.putExtra(SearchActivity.SEARCH_LAT, loc.getLatitude());
|
||||
search.putExtra(SearchActivity.SEARCH_LON, loc.getLongitude());
|
||||
search.setFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
|
||||
MapActivity.this.startActivity(search);
|
||||
dlg.dismiss();
|
||||
|
@ -478,6 +481,9 @@ public class MapActivity extends Activity implements IMapLocationListener, Senso
|
|||
if (keyCode == KeyEvent.KEYCODE_SEARCH && event.getRepeatCount() == 0) {
|
||||
Intent newIntent = new Intent(MapActivity.this, SearchActivity.class);
|
||||
newIntent.setFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
|
||||
LatLon loc = getMapLocation();
|
||||
newIntent.putExtra(SearchActivity.SEARCH_LAT, loc.getLatitude());
|
||||
newIntent.putExtra(SearchActivity.SEARCH_LON, loc.getLongitude());
|
||||
startActivity(newIntent);
|
||||
return true;
|
||||
} else if (!routingHelper.isFollowingMode()) {
|
||||
|
@ -1012,6 +1018,9 @@ public class MapActivity extends Activity implements IMapLocationListener, Senso
|
|||
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);
|
||||
LatLon mapLoc = getMapLocation();
|
||||
newIntent.putExtra(SearchActivity.SEARCH_LAT, mapLoc.getLatitude());
|
||||
newIntent.putExtra(SearchActivity.SEARCH_LON, mapLoc.getLongitude());
|
||||
startActivity(newIntent);
|
||||
return true;
|
||||
case R.id.map_mute:
|
||||
|
@ -1151,8 +1160,8 @@ public class MapActivity extends Activity implements IMapLocationListener, Senso
|
|||
startActivity(intent);
|
||||
} else if(standardId == R.string.context_menu_item_search_transport){
|
||||
Intent intent = new Intent(MapActivity.this, SearchTransportActivity.class);
|
||||
intent.putExtra(SearchTransportActivity.LAT_KEY, latitude);
|
||||
intent.putExtra(SearchTransportActivity.LON_KEY, longitude);
|
||||
intent.putExtra(SearchTransportActivity.SEARCH_LAT, latitude);
|
||||
intent.putExtra(SearchTransportActivity.SEARCH_LON, longitude);
|
||||
startActivity(intent);
|
||||
} else if(standardId == R.string.context_menu_item_add_favorite){
|
||||
mapActions.addFavouritePoint(latitude, longitude);
|
||||
|
|
|
@ -11,9 +11,11 @@ import net.osmand.osm.LatLon;
|
|||
import net.osmand.osm.MapUtils;
|
||||
import net.osmand.plus.OsmandSettings;
|
||||
import net.osmand.plus.R;
|
||||
import net.osmand.plus.activities.search.SearchActivity;
|
||||
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;
|
||||
|
@ -28,6 +30,9 @@ public class NavigatePointActivity extends Activity {
|
|||
MapActivity activity;
|
||||
int currentFormat = Location.FORMAT_DEGREES;
|
||||
|
||||
public static final String SEARCH_LAT = SearchActivity.SEARCH_LAT;
|
||||
public static final String SEARCH_LON = SearchActivity.SEARCH_LON;
|
||||
|
||||
// dialog constructor
|
||||
public NavigatePointActivity(MapActivity activity){
|
||||
this.activity = activity;
|
||||
|
@ -48,13 +53,30 @@ public class NavigatePointActivity extends Activity {
|
|||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
LatLon loc = OsmandSettings.getOsmandSettings(this).getLastKnownMapLocation();
|
||||
|
||||
setContentView(R.layout.navigate_point);
|
||||
setTitle(R.string.map_specify_point);
|
||||
initUI(loc.getLatitude(), loc.getLongitude());
|
||||
((Button) findViewById(R.id.Cancel)).setText(getString(R.string.navigate_to));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onResume() {
|
||||
super.onResume();
|
||||
LatLon loc = null;
|
||||
Intent intent = getIntent();
|
||||
if(intent != null){
|
||||
float lat = intent.getFloatExtra(SEARCH_LAT, 0);
|
||||
float lon = intent.getFloatExtra(SEARCH_LON, 0);
|
||||
if(lat != 0 || lon != 0){
|
||||
loc = new LatLon(lat, lon);
|
||||
}
|
||||
}
|
||||
if (loc == null) {
|
||||
loc = OsmandSettings.getOsmandSettings(this).getLastKnownMapLocation();
|
||||
}
|
||||
initUI(loc.getLatitude(), loc.getLongitude());
|
||||
}
|
||||
|
||||
@Override
|
||||
public View findViewById(int id) {
|
||||
if(dlg != null){
|
||||
|
|
|
@ -7,9 +7,6 @@ import java.util.List;
|
|||
import net.osmand.LogUtil;
|
||||
import net.osmand.OsmAndFormatter;
|
||||
import net.osmand.GPXUtilities.GPXFile;
|
||||
import net.osmand.GPXUtilities.Track;
|
||||
import net.osmand.GPXUtilities.TrkSegment;
|
||||
import net.osmand.GPXUtilities.WptPt;
|
||||
import net.osmand.osm.LatLon;
|
||||
import net.osmand.osm.MapUtils;
|
||||
import net.osmand.plus.OsmandSettings;
|
||||
|
|
|
@ -13,7 +13,6 @@ import net.osmand.plus.activities.RoutingHelper.RouteDirectionInfo;
|
|||
import net.osmand.plus.activities.RoutingHelper.TurnType;
|
||||
import net.osmand.plus.views.MapInfoLayer;
|
||||
import android.app.ListActivity;
|
||||
import android.content.Intent;
|
||||
import android.graphics.Canvas;
|
||||
import android.graphics.Color;
|
||||
import android.graphics.ColorFilter;
|
||||
|
|
|
@ -3,6 +3,7 @@ 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.Activity;
|
||||
import android.app.TabActivity;
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
|
@ -18,9 +19,13 @@ public class SearchActivity extends TabActivity {
|
|||
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";
|
||||
|
||||
public static final String SEARCH_LAT = "net.osmand.search_lat"; //$NON-NLS-1$
|
||||
public static final String SEARCH_LON = "net.osmand.search_lon"; //$NON-NLS-1$
|
||||
|
||||
Button searchPOIButton;
|
||||
private TabSpec addressSpec;
|
||||
private LatLon searchPoint = null;
|
||||
|
||||
private static boolean searchOnLine = false;
|
||||
|
||||
|
@ -28,45 +33,66 @@ public class SearchActivity extends TabActivity {
|
|||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onResume() {
|
||||
super.onResume();
|
||||
Intent intent = getIntent();
|
||||
// LatLon latLon = null;
|
||||
int tabIndex = 0;
|
||||
if(intent != null){
|
||||
tabIndex = intent.getIntExtra(TAB_INDEX_EXTRA, POI_TAB_INDEX);
|
||||
float lat = intent.getFloatExtra(SEARCH_LAT, 0);
|
||||
float lon = intent.getFloatExtra(SEARCH_LON, 0);
|
||||
if(lat != 0 || lon != 0){
|
||||
searchPoint = new LatLon(lat, lon);
|
||||
}
|
||||
}
|
||||
|
||||
TabHost host = getTabHost();
|
||||
// TODO investigate proper intent with lat/lon ?
|
||||
host.addTab(host.newTabSpec("Search_POI").setIndicator(getString(R.string.poi)).setContent(new Intent(this, SearchPoiFilterActivity.class))); //$NON-NLS-1$
|
||||
|
||||
addressSpec = host.newTabSpec("Search_Address").setIndicator(getString(R.string.address));
|
||||
setAddressSpecContent();
|
||||
setAddressSpecContent(searchPoint);
|
||||
|
||||
host.addTab(addressSpec);
|
||||
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.addTab(host.newTabSpec("Search_Location").setIndicator(getString(R.string.search_tabs_location)).setContent(createIntent(NavigatePointActivity.class))); //$NON-NLS-1$
|
||||
if (searchPoint != null) {
|
||||
host.addTab(host.newTabSpec("Search_Transport").setIndicator(getString(R.string.transport)).setContent(createIntent(SearchTransportActivity.class))); //$NON-NLS-1$
|
||||
}
|
||||
host.addTab(host.newTabSpec("Search_History").setIndicator(getString(R.string.history)).setContent(createIntent(SearchHistoryActivity.class))); //$NON-NLS-1$
|
||||
host.setCurrentTab(tabIndex);
|
||||
}
|
||||
|
||||
private Intent createIntent(Class<? extends Activity> cl){
|
||||
Intent intent = new Intent(this, cl);
|
||||
if(searchPoint != null){
|
||||
intent.putExtra(SearchActivity.SEARCH_LAT, searchPoint.getLatitude());
|
||||
intent.putExtra(SearchActivity.SEARCH_LON, searchPoint.getLongitude());
|
||||
}
|
||||
return intent;
|
||||
}
|
||||
|
||||
public void startSearchAddressOffline(){
|
||||
searchOnLine = false;
|
||||
getTabHost().setCurrentTab(0);
|
||||
setAddressSpecContent();
|
||||
setAddressSpecContent(searchPoint);
|
||||
getTabHost().setCurrentTab(1);
|
||||
}
|
||||
|
||||
public void startSearchAddressOnline(){
|
||||
searchOnLine = true;
|
||||
getTabHost().setCurrentTab(0);
|
||||
setAddressSpecContent();
|
||||
setAddressSpecContent(searchPoint);
|
||||
getTabHost().setCurrentTab(1);
|
||||
}
|
||||
|
||||
public void setAddressSpecContent() {
|
||||
public void setAddressSpecContent(LatLon latLon) {
|
||||
if (searchOnLine) {
|
||||
addressSpec.setContent(new Intent(this, SearchAddressOnlineActivity.class));
|
||||
addressSpec.setContent(createIntent(SearchAddressOnlineActivity.class));
|
||||
} else {
|
||||
addressSpec.setContent(new Intent(this, SearchAddressActivity.class));
|
||||
addressSpec.setContent(createIntent(SearchAddressOnlineActivity.class));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
package net.osmand.plus.activities.search;
|
||||
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import net.osmand.OsmAndFormatter;
|
||||
|
@ -28,6 +29,8 @@ public class SearchHistoryActivity extends ListActivity {
|
|||
private LatLon location;
|
||||
private SearchHistoryHelper helper;
|
||||
private Button clearButton;
|
||||
public static final String SEARCH_LAT = SearchActivity.SEARCH_LAT;
|
||||
public static final String SEARCH_LON = SearchActivity.SEARCH_LON;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
|
@ -36,7 +39,17 @@ public class SearchHistoryActivity extends ListActivity {
|
|||
lv.setId(android.R.id.list);
|
||||
|
||||
setContentView(lv);
|
||||
location = OsmandSettings.getOsmandSettings(this).getLastKnownMapLocation();
|
||||
Intent intent = getIntent();
|
||||
if(intent != null){
|
||||
float lat = intent.getFloatExtra(SEARCH_LAT, 0);
|
||||
float lon = intent.getFloatExtra(SEARCH_LON, 0);
|
||||
if(lat != 0 || lon != 0){
|
||||
location = new LatLon(lat, lon);
|
||||
}
|
||||
}
|
||||
if (location == null) {
|
||||
location = OsmandSettings.getOsmandSettings(this).getLastKnownMapLocation();
|
||||
}
|
||||
helper = SearchHistoryHelper.getInstance();
|
||||
|
||||
|
||||
|
|
|
@ -24,7 +24,6 @@ import net.osmand.plus.activities.OsmandApplication;
|
|||
import android.app.AlertDialog;
|
||||
import android.app.ListActivity;
|
||||
import android.content.DialogInterface;
|
||||
import android.content.Intent;
|
||||
import android.content.pm.ActivityInfo;
|
||||
import android.graphics.Canvas;
|
||||
import android.graphics.Color;
|
||||
|
@ -71,8 +70,8 @@ import android.widget.Toast;
|
|||
public class SearchPOIActivity extends ListActivity implements SensorEventListener {
|
||||
|
||||
public static final String AMENITY_FILTER = "net.osmand.amenity_filter"; //$NON-NLS-1$
|
||||
public static final String SEARCH_LAT = "net.osmand.am_search_lat"; //$NON-NLS-1$
|
||||
public static final String SEARCH_LON = "net.osmand.am_search_lon"; //$NON-NLS-1$
|
||||
public static final String SEARCH_LAT = SearchActivity.SEARCH_LAT; //$NON-NLS-1$
|
||||
public static final String SEARCH_LON = SearchActivity.SEARCH_LON; //$NON-NLS-1$
|
||||
private static final int GPS_TIMEOUT_REQUEST = 1000;
|
||||
private static final int GPS_DIST_REQUEST = 5;
|
||||
private static final int MIN_DISTANCE_TO_RESEARCH = 70;
|
||||
|
|
|
@ -36,8 +36,8 @@ import android.widget.TextView;
|
|||
public class SearchPoiFilterActivity extends ListActivity {
|
||||
|
||||
private Typeface typeFace;
|
||||
public final static String SEARCH_LAT = "search_lat"; //$NON-NLS-1$
|
||||
public final static String SEARCH_LON = "search_lon"; //$NON-NLS-1$
|
||||
public static final String SEARCH_LAT = SearchActivity.SEARCH_LAT;
|
||||
public static final String SEARCH_LON = SearchActivity.SEARCH_LON;
|
||||
|
||||
private boolean searchNearBy = true;
|
||||
private double latitude = 0;
|
||||
|
|
|
@ -23,6 +23,7 @@ import android.app.AlertDialog;
|
|||
import android.app.ListActivity;
|
||||
import android.app.AlertDialog.Builder;
|
||||
import android.content.DialogInterface;
|
||||
import android.content.Intent;
|
||||
import android.graphics.Typeface;
|
||||
import android.os.Bundle;
|
||||
import android.view.LayoutInflater;
|
||||
|
@ -43,8 +44,8 @@ import android.widget.TextView;
|
|||
*/
|
||||
public class SearchTransportActivity extends ListActivity {
|
||||
|
||||
public static final String LAT_KEY = "lat"; //$NON-NLS-1$
|
||||
public static final String LON_KEY = "lon"; //$NON-NLS-1$
|
||||
public static final String SEARCH_LAT = SearchActivity.SEARCH_LAT;
|
||||
public static final String SEARCH_LON = SearchActivity.SEARCH_LON;
|
||||
|
||||
private Button searchTransportLevel;
|
||||
|
||||
|
@ -68,17 +69,20 @@ public class SearchTransportActivity extends ListActivity {
|
|||
private OsmandSettings settings;
|
||||
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle icicle) {
|
||||
super.onCreate(icicle);
|
||||
settings = OsmandSettings.getOsmandSettings(this);
|
||||
Bundle extras = getIntent().getExtras();
|
||||
if(extras != null && extras.containsKey(LAT_KEY) && extras.containsKey(LON_KEY)){
|
||||
lastKnownMapLocation = new LatLon(extras.getDouble(LAT_KEY), extras.getDouble(LON_KEY));
|
||||
} else {
|
||||
lastKnownMapLocation = settings.getLastKnownMapLocation();
|
||||
Intent intent = getIntent();
|
||||
if(intent != null){
|
||||
float lat = intent.getFloatExtra(SEARCH_LAT, 0);
|
||||
float lon = intent.getFloatExtra(SEARCH_LON, 0);
|
||||
if(lat != 0 || lon != 0){
|
||||
lastKnownMapLocation = new LatLon(lat, lon);
|
||||
}
|
||||
}
|
||||
if (lastKnownMapLocation == null) {
|
||||
lastKnownMapLocation = OsmandSettings.getOsmandSettings(this).getLastKnownMapLocation();
|
||||
}
|
||||
setContentView(R.layout.search_transport);
|
||||
searchTransportLevel = (Button) findViewById(R.id.SearchTransportLevelButton);
|
||||
|
|
|
@ -2,7 +2,6 @@ package net.osmand.plus.views;
|
|||
|
||||
import android.graphics.Canvas;
|
||||
import android.graphics.RectF;
|
||||
import net.osmand.map.ITileSource;
|
||||
|
||||
/**
|
||||
* This class is designed to represent adapter for specific map sources
|
||||
|
|
Loading…
Reference in a new issue