Search favorites
This commit is contained in:
parent
320d1d93de
commit
1f807756ee
12 changed files with 278 additions and 27 deletions
|
@ -27,6 +27,7 @@
|
|||
<activity android:name=".activities.NavigatePointActivity"></activity>
|
||||
<activity android:name=".activities.DownloadIndexActivity" android:configChanges="keyboardHidden|orientation" android:label="@string/local_index_download"></activity>
|
||||
<activity android:name=".activities.ShowRouteInfoActivity"></activity>
|
||||
<activity android:name=".activities.FavouritesListActivity"></activity>
|
||||
<activity android:name=".activities.FavouritesActivity" android:label="@string/favourites_activity"></activity>
|
||||
<activity android:name=".activities.ContributionVersionActivity" android:label="@string/contribution_activity"></activity>
|
||||
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
|
||||
<TextView android:id="@+id/favouritedistance_label"
|
||||
android:layout_width="wrap_content" android:layout_height="wrap_content" android:gravity="center"
|
||||
android:textSize="23sp" android:maxWidth="150dp" android:minWidth="100dp"/>
|
||||
android:textSize="23sp" android:maxWidth="150dp" android:minWidth="90dp"/>
|
||||
<TextView android:id="@+id/favourite_label" android:layout_width="wrap_content" android:layout_marginLeft="10dp"
|
||||
android:layout_height="wrap_content" android:textSize="23sp" />
|
||||
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
|
||||
<item android:id="@+id/map_get_directions" android:title="@string/get_directions" android:icon="@android:drawable/ic_menu_directions"></item>
|
||||
<item android:id="@+id/map_save_directions" android:title="@string/menu_save_directions" android:icon="@android:drawable/ic_menu_save" visible="false"></item>
|
||||
<item android:title="@string/map_specify_point" android:id="@+id/map_specify_point" android:icon="@android:drawable/ic_menu_search"></item>
|
||||
<item android:title="@string/context_menu_item_search" android:id="@+id/map_specify_point" android:icon="@android:drawable/ic_menu_search"></item>
|
||||
|
||||
<item android:title="@string/show_gps_status" android:id="@+id/map_show_gps_status" android:icon="@android:drawable/ic_menu_compass"></item>
|
||||
<item android:title="@string/map_route_by_gpx" android:id="@+id/map_gpx_routing"></item>
|
||||
|
|
|
@ -46,7 +46,7 @@
|
|||
<string name="local_index_no_items_to_do">Нет объектов, чтобы %1$s</string>
|
||||
<string name="local_index_action_do">Вы собириаетесь %1$s %2$s объектов. Вы уверены?</string>
|
||||
<string name="local_index_descr_title">Менеджер офлайн данных:</string>
|
||||
<string name="local_index_description">Офлайн данные доступные на SD карточке. Вы можете загрузить новые, архивировать и удалить данные.</string>
|
||||
<string name="local_index_description">Офлайн данные доступные на SD карточке. Вы можете загрузить новые, архивировать и удалить данные. Доступно %1$s.</string>
|
||||
<string name="local_index_mi_restore">Восстановить</string>
|
||||
<string name="local_index_mi_backup">Архив</string>
|
||||
<string name="local_index_mi_delete">Удалить</string>
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
<?xml version="1.0" encoding="utf-8" standalone="no"?>
|
||||
<resources>
|
||||
<string name="local_index_description">Download new, or move to backup or delete existing data. \nCurrent offline data on device (%1$s is available):</string>
|
||||
<string name="search_position_current_location_search">Search location...</string>
|
||||
<string name="search_position_current_location_found">Location [Found]</string>
|
||||
<string name="search_position_address">Address...</string>
|
||||
|
@ -10,7 +11,7 @@
|
|||
<string name="search_position_map_view">Last map view</string>
|
||||
|
||||
<string name="select_search_position">Search around :</string>
|
||||
<string name="context_menu_item_search">Search around</string>
|
||||
<string name="context_menu_item_search">Search</string>
|
||||
<string name="tip_recent_changes_0_6_7_t">Recent changes for 0.6.7 :
|
||||
\n\t- Offline data manager (download, delete, backup offline data directly in Osmand)
|
||||
\n\t- Favorite points and groups (categorize, delete, manage favorites)
|
||||
|
@ -57,7 +58,7 @@
|
|||
<string name="local_index_no_items_to_do">No items to %1$s</string>
|
||||
<string name="local_index_action_do">You are about to %1$s %2$s item(s). Continue?</string>
|
||||
<string name="local_index_descr_title">Offline Data Manager:</string>
|
||||
<string name="local_index_description">Download new, or move to backup or delete existing data.\nCurrent offline data on device:</string>
|
||||
|
||||
<string name="local_index_mi_restore">Restore...</string>
|
||||
<string name="local_index_mi_backup">Backup...</string>
|
||||
<string name="local_index_mi_delete">Delete...</string>
|
||||
|
|
|
@ -1,6 +1,9 @@
|
|||
package net.osmand;
|
||||
|
||||
public class FavouritePoint {
|
||||
import java.io.Serializable;
|
||||
|
||||
public class FavouritePoint implements Serializable {
|
||||
private static final long serialVersionUID = 729654300829771466L;
|
||||
private String name;
|
||||
private String category = "";
|
||||
private double latitude;
|
||||
|
|
|
@ -0,0 +1,203 @@
|
|||
/**
|
||||
*
|
||||
*/
|
||||
package net.osmand.plus.activities;
|
||||
|
||||
import java.util.Comparator;
|
||||
import java.util.List;
|
||||
|
||||
import net.osmand.FavouritePoint;
|
||||
import net.osmand.OsmAndFormatter;
|
||||
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.activities.search.SearchActivity.SearchActivityChild;
|
||||
import android.app.AlertDialog;
|
||||
import android.app.ListActivity;
|
||||
import android.content.DialogInterface;
|
||||
import android.content.Intent;
|
||||
import android.content.DialogInterface.OnClickListener;
|
||||
import android.os.Bundle;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.AdapterView;
|
||||
import android.widget.ArrayAdapter;
|
||||
import android.widget.CheckBox;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.ListView;
|
||||
import android.widget.TextView;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public class FavouritesListActivity extends ListActivity implements SearchActivityChild {
|
||||
|
||||
public static final String SELECT_FAVORITE_POINT_INTENT_KEY = "SELECT_FAVORITE_POINT_INTENT_KEY";
|
||||
public static final int SELECT_FAVORITE_POINT_RESULT_OK = 1;
|
||||
|
||||
private FavouritesAdapter favouritesAdapter;
|
||||
private LatLon location;
|
||||
|
||||
private boolean selectFavoriteMode;
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle icicle) {
|
||||
super.onCreate(icicle);
|
||||
ListView lv = new ListView(this);
|
||||
lv.setId(android.R.id.list);
|
||||
setContentView(lv);
|
||||
|
||||
favouritesAdapter = new FavouritesAdapter(((OsmandApplication) getApplication()).getFavorites().getFavouritePoints());
|
||||
setListAdapter(favouritesAdapter);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected void onResume() {
|
||||
super.onResume();
|
||||
Intent intent = getIntent();
|
||||
if (intent != null) {
|
||||
selectFavoriteMode = intent.hasExtra(SELECT_FAVORITE_POINT_INTENT_KEY);
|
||||
if (intent.hasExtra(SearchActivity.SEARCH_LAT) && intent.hasExtra(SearchActivity.SEARCH_LON)) {
|
||||
double lat = intent.getDoubleExtra(SearchActivity.SEARCH_LAT, 0);
|
||||
double lon = intent.getDoubleExtra(SearchActivity.SEARCH_LON, 0);
|
||||
if (lat != 0 || lon != 0) {
|
||||
location = new LatLon(lat, lon);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!isSelectFavoriteMode()) {
|
||||
if (location == null && getParent() instanceof SearchActivity) {
|
||||
location = ((SearchActivity) getParent()).getSearchPoint();
|
||||
}
|
||||
if (location == null) {
|
||||
location = OsmandSettings.getOsmandSettings(this).getLastKnownMapLocation();
|
||||
}
|
||||
}
|
||||
locationUpdate(location);
|
||||
|
||||
if (!isSelectFavoriteMode()) {
|
||||
getListView().setOnItemLongClickListener(new AdapterView.OnItemLongClickListener() {
|
||||
@Override
|
||||
public boolean onItemLongClick(AdapterView<?> parent, View view, int position, long id) {
|
||||
return FavouritesListActivity.this.onItemLongClick(position);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void locationUpdate(LatLon l) {
|
||||
location = l;
|
||||
favouritesAdapter.sort(new Comparator<FavouritePoint>() {
|
||||
@Override
|
||||
public int compare(FavouritePoint object1, FavouritePoint object2) {
|
||||
if (location != null) {
|
||||
double d1 = MapUtils.getDistance(location, object1.getLatitude(), object1.getLongitude());
|
||||
double d2 = MapUtils.getDistance(location, object2.getLatitude(), object2.getLongitude());
|
||||
if (d1 == d2) {
|
||||
return 0;
|
||||
} else if (d1 > d2) {
|
||||
return 1;
|
||||
}
|
||||
return -1;
|
||||
} else {
|
||||
return favouritesAdapter.getName(object1).compareTo(favouritesAdapter.getName(object2));
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public boolean isSelectFavoriteMode(){
|
||||
return selectFavoriteMode;
|
||||
}
|
||||
|
||||
|
||||
private boolean onItemLongClick(int pos) {
|
||||
final FavouritePoint entry = favouritesAdapter.getItem(pos);
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(FavouritesListActivity.this);
|
||||
builder.setTitle(entry.getName());
|
||||
OnClickListener onClickListener = new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
if (which == 0) {
|
||||
OsmandSettings.getOsmandSettings(FavouritesListActivity.this).setMapLocationToShow(entry.getLatitude(),
|
||||
entry.getLongitude());
|
||||
} else if (which == 1) {
|
||||
OsmandSettings.getOsmandSettings(FavouritesListActivity.this).setPointToNavigate(entry.getLatitude(),
|
||||
entry.getLongitude(), getString(R.string.favorite) + " : " + entry.getName());
|
||||
}
|
||||
MapActivity.launchMapActivityMoveToTop(FavouritesListActivity.this);
|
||||
}
|
||||
};
|
||||
builder.setItems(new String[] { getString(R.string.show_poi_on_map), getString(R.string.navigate_to) }, onClickListener);
|
||||
builder.show();
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onListItemClick(ListView l, View v, int position, long id) {
|
||||
if(!isSelectFavoriteMode()) {
|
||||
FavouritePoint point = favouritesAdapter.getItem(position);
|
||||
OsmandSettings.getOsmandSettings(this).SHOW_FAVORITES.set( true);
|
||||
OsmandSettings.getOsmandSettings(this).setMapLocationToShow(point.getLatitude(), point.getLongitude(), getString(R.string.favorite)+" : " + point.getName()); //$NON-NLS-1$
|
||||
MapActivity.launchMapActivityMoveToTop(FavouritesListActivity.this);
|
||||
} else {
|
||||
Intent intent = getIntent();
|
||||
intent.putExtra(SELECT_FAVORITE_POINT_INTENT_KEY, favouritesAdapter.getItem(position));
|
||||
setResult(SELECT_FAVORITE_POINT_RESULT_OK, intent);
|
||||
finish();
|
||||
}
|
||||
}
|
||||
|
||||
class FavouritesAdapter extends ArrayAdapter<FavouritePoint> {
|
||||
|
||||
|
||||
public FavouritesAdapter(List<FavouritePoint> list) {
|
||||
super(FavouritesListActivity.this, R.layout.favourites_list_item, list);
|
||||
}
|
||||
|
||||
public String getName(FavouritePoint model){
|
||||
return model.getCategory() + " : " + model.getName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public View getView(int position, View convertView, ViewGroup parent) {
|
||||
View row = convertView;
|
||||
if (row == null) {
|
||||
LayoutInflater inflater = getLayoutInflater();
|
||||
row = inflater.inflate(R.layout.favourites_list_item, parent, false);
|
||||
}
|
||||
|
||||
TextView label = (TextView) row.findViewById(R.id.favourite_label);
|
||||
TextView distanceLabel = (TextView) row.findViewById(R.id.favouritedistance_label);
|
||||
ImageView icon = (ImageView) row.findViewById(R.id.favourite_icon);
|
||||
final FavouritePoint model = getItem(position);
|
||||
if (model.isStored()) {
|
||||
icon.setImageResource(R.drawable.favorites);
|
||||
} else {
|
||||
icon.setImageResource(R.drawable.opened_poi);
|
||||
}
|
||||
if (location != null) {
|
||||
int dist = (int) (MapUtils.getDistance(model.getLatitude(), model.getLongitude(), location.getLatitude(), location
|
||||
.getLongitude()));
|
||||
distanceLabel.setText(OsmAndFormatter.getFormattedDistance(dist, FavouritesListActivity.this));
|
||||
distanceLabel.setVisibility(View.VISIBLE);
|
||||
} else {
|
||||
distanceLabel.setVisibility(View.GONE);
|
||||
}
|
||||
|
||||
label.setText(getName(model));
|
||||
final CheckBox ch = (CheckBox) row.findViewById(R.id.check_item);
|
||||
row.findViewById(R.id.favourite_icon).setVisibility(View.VISIBLE);
|
||||
ch.setVisibility(View.GONE);
|
||||
return row;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -30,6 +30,7 @@ import android.graphics.Color;
|
|||
import android.graphics.Typeface;
|
||||
import android.os.AsyncTask;
|
||||
import android.os.Bundle;
|
||||
import android.os.StatFs;
|
||||
import android.os.AsyncTask.Status;
|
||||
import android.view.ContextMenu;
|
||||
import android.view.LayoutInflater;
|
||||
|
@ -63,6 +64,9 @@ public class LocalIndexesActivity extends ExpandableListActivity {
|
|||
protected static int BACKUP_OPERATION = 2;
|
||||
protected static int RESTORE_OPERATION = 3;
|
||||
|
||||
MessageFormat formatMb = new MessageFormat("{0, number,##.#} MB", Locale.US);
|
||||
MessageFormat formatGb = new MessageFormat("{0, number,#.##} GB", Locale.US);
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
|
@ -110,6 +114,7 @@ public class LocalIndexesActivity extends ExpandableListActivity {
|
|||
});
|
||||
|
||||
setListAdapter(listAdapter);
|
||||
updateDescriptionTextWithSize();
|
||||
}
|
||||
|
||||
public class LoadLocalIndexTask extends AsyncTask<Activity, LocalIndexInfo, List<LocalIndexInfo>> {
|
||||
|
@ -515,6 +520,17 @@ public class LocalIndexesActivity extends ExpandableListActivity {
|
|||
listAdapter.notifyDataSetChanged();
|
||||
}
|
||||
|
||||
private void updateDescriptionTextWithSize(){
|
||||
File dir = OsmandSettings.getOsmandSettings(this).extendOsmandPath("");
|
||||
String size = formatGb.format(new Object[]{0});
|
||||
if(dir.canRead()){
|
||||
StatFs fs = new StatFs(dir.getAbsolutePath());
|
||||
size = formatGb.format(new Object[]{(float) (fs.getAvailableBlocks()) * fs.getBlockSize() / (1 << 30) });
|
||||
}
|
||||
((TextView) findViewById(R.id.DescriptionText)).setText(
|
||||
getString(R.string.local_index_description, size));
|
||||
}
|
||||
|
||||
private void closeSelectionMode(){
|
||||
selectionMode = false;
|
||||
findViewById(R.id.DownloadButton).setVisibility(View.VISIBLE);
|
||||
|
@ -524,7 +540,10 @@ public class LocalIndexesActivity extends ExpandableListActivity {
|
|||
findViewById(R.id.CancelButton).setVisibility(View.GONE);
|
||||
findViewById(R.id.ActionButton).setVisibility(View.GONE);
|
||||
((TextView) findViewById(R.id.DescriptionTextTop)).setVisibility(View.GONE);
|
||||
((TextView) findViewById(R.id.DescriptionText)).setText(R.string.local_index_description);
|
||||
|
||||
|
||||
;
|
||||
updateDescriptionTextWithSize();
|
||||
listAdapter.cancelFilter();
|
||||
collapseAllGroups();
|
||||
listAdapter.notifyDataSetChanged();
|
||||
|
@ -596,10 +615,8 @@ public class LocalIndexesActivity extends ExpandableListActivity {
|
|||
List<LocalIndexInfo> category = new ArrayList<LocalIndexInfo>();
|
||||
List<LocalIndexInfo> filterCategory = null;
|
||||
|
||||
private MessageFormat formatMb;
|
||||
|
||||
public LocalIndexesAdapter() {
|
||||
formatMb = new MessageFormat("{0, number,##.#} MB", Locale.US);
|
||||
}
|
||||
|
||||
public void clear() {
|
||||
|
|
|
@ -21,7 +21,6 @@ import net.osmand.plus.R;
|
|||
import net.osmand.plus.ResourceManager;
|
||||
import net.osmand.plus.activities.RouteProvider.GPXRouteParams;
|
||||
import net.osmand.plus.activities.search.SearchActivity;
|
||||
import net.osmand.plus.activities.search.SearchPoiFilterActivity;
|
||||
import net.osmand.plus.views.AnimateDraggingMapThread;
|
||||
import net.osmand.plus.views.MapTileLayer;
|
||||
import net.osmand.plus.views.OsmandMapTileView;
|
||||
|
|
|
@ -1,13 +1,16 @@
|
|||
package net.osmand.plus.activities.search;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.text.MessageFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Locale;
|
||||
|
||||
import net.osmand.FavouritePoint;
|
||||
import net.osmand.osm.LatLon;
|
||||
import net.osmand.plus.OsmandSettings;
|
||||
import net.osmand.plus.R;
|
||||
import net.osmand.plus.activities.FavouritesListActivity;
|
||||
import net.osmand.plus.activities.NavigatePointActivity;
|
||||
import android.app.Activity;
|
||||
import android.app.TabActivity;
|
||||
|
@ -36,13 +39,15 @@ public class SearchActivity extends TabActivity {
|
|||
|
||||
protected static final int POSITION_CURRENT_LOCATION = 1;
|
||||
protected static final int POSITION_LAST_MAP_VIEW = 2;
|
||||
protected static final int POSITION_ADDRESS = 3;
|
||||
protected static final int POSITION_FAVORITES = 4;
|
||||
protected static final int POSITION_FAVORITES = 3;
|
||||
protected static final int POSITION_ADDRESS = 4;
|
||||
|
||||
private static final int GPS_TIMEOUT_REQUEST = 1000;
|
||||
private static final int GPS_DIST_REQUEST = 5;
|
||||
private static final int GPS_ACCURACY = 50;
|
||||
|
||||
private static final int REQUEST_FAVORITE_SELECT = 1;
|
||||
|
||||
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$
|
||||
|
||||
|
@ -76,7 +81,8 @@ public class SearchActivity extends TabActivity {
|
|||
getString(R.string.search_position_current_location),
|
||||
getString(R.string.search_position_map_view),
|
||||
getString(R.string.search_position_favorites),
|
||||
getString(R.string.search_position_address)
|
||||
// Address is not yet implemented
|
||||
// getString(R.string.search_position_address)
|
||||
}))
|
||||
);
|
||||
|
||||
|
@ -90,9 +96,8 @@ public class SearchActivity extends TabActivity {
|
|||
host.addTab(addressSpec);
|
||||
host.addTab(host.newTabSpec("Search_Location").setIndicator(getString(R.string.search_tabs_location)).setContent(createIntent(NavigatePointActivity.class))); //$NON-NLS-1$
|
||||
TabSpec transportTab = host.newTabSpec("Search_Transport").setIndicator(getString(R.string.transport)).setContent(createIntent(SearchTransportActivity.class));
|
||||
//if (searchPoint != null) {
|
||||
host.addTab(transportTab); //$NON-NLS-1$
|
||||
//}
|
||||
host.addTab(host.newTabSpec("Search_Favorites").setIndicator(getString(R.string.favorite)).setContent(createIntent(FavouritesListActivity.class))); //$NON-NLS-1$
|
||||
host.addTab(host.newTabSpec("Search_History").setIndicator(getString(R.string.history)).setContent(createIntent(SearchHistoryActivity.class))); //$NON-NLS-1$
|
||||
host.setCurrentTab(POI_TAB_INDEX);
|
||||
|
||||
|
@ -112,6 +117,11 @@ public class SearchActivity extends TabActivity {
|
|||
if (position == POSITION_LAST_MAP_VIEW) {
|
||||
OsmandSettings settings = OsmandSettings.getOsmandSettings(SearchActivity.this);
|
||||
updateSearchPoint(settings.getLastKnownMapLocation(), getString(R.string.search_position_fixed), true);
|
||||
} else if (position == POSITION_FAVORITES) {
|
||||
Intent intent = new Intent(SearchActivity.this, FavouritesListActivity.class);
|
||||
intent.setFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
|
||||
intent.putExtra(FavouritesListActivity.SELECT_FAVORITE_POINT_INTENT_KEY, (Serializable) null);
|
||||
startActivityForResult(intent, REQUEST_FAVORITE_SELECT);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -123,6 +133,18 @@ public class SearchActivity extends TabActivity {
|
|||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
|
||||
super.onActivityResult(requestCode, resultCode, data);
|
||||
if(requestCode == REQUEST_FAVORITE_SELECT && resultCode == FavouritesListActivity.SELECT_FAVORITE_POINT_RESULT_OK){
|
||||
FavouritePoint p = (FavouritePoint) data.getSerializableExtra(FavouritesListActivity.SELECT_FAVORITE_POINT_INTENT_KEY);
|
||||
if (p != null) {
|
||||
LatLon latLon = new LatLon(p.getLatitude(), p.getLongitude());
|
||||
updateSearchPoint(latLon, p.getName(), false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
public void startSearchCurrentLocation(){
|
||||
|
@ -177,10 +199,13 @@ public class SearchActivity extends TabActivity {
|
|||
double lat = intent.getDoubleExtra(SEARCH_LAT, 0);
|
||||
double lon = intent.getDoubleExtra(SEARCH_LON, 0);
|
||||
if (lat != 0 || lon != 0) {
|
||||
LatLon searchPoint = new LatLon(lat, lon);
|
||||
updateSearchPoint(searchPoint, getString(R.string.search_position_fixed), true);
|
||||
updateSearchPoint(new LatLon(lat, lon), getString(R.string.search_position_fixed), true);
|
||||
}
|
||||
}
|
||||
if(searchPoint == null){
|
||||
LatLon last = OsmandSettings.getOsmandSettings(this).getLastKnownMapLocation();
|
||||
updateSearchPoint(last, getString(R.string.search_position_fixed), true);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -189,12 +214,16 @@ public class SearchActivity extends TabActivity {
|
|||
endSearchCurrentLocation();
|
||||
}
|
||||
|
||||
private String formatLatLon(LatLon searchPoint){
|
||||
MessageFormat format = new MessageFormat(" ({0,number,#.##};{1,number,#.##})", Locale.US);
|
||||
return format.format(new Object[]{searchPoint.getLatitude(), searchPoint.getLongitude()});
|
||||
}
|
||||
|
||||
public void updateSearchPoint(LatLon searchPoint, String message, boolean showLoc){
|
||||
spinnerAdapter.remove(spinnerAdapter.getItem(0));
|
||||
String suffix = "";
|
||||
if(showLoc && searchPoint != null){
|
||||
MessageFormat format = new MessageFormat(" ({0,number,#.##};{1,number,#.##})", Locale.US);
|
||||
suffix = format.format(new Object[]{searchPoint.getLatitude(), searchPoint.getLongitude()});
|
||||
suffix = formatLatLon(searchPoint);
|
||||
}
|
||||
spinnerAdapter.insert(message + suffix, 0);
|
||||
this.searchPoint = searchPoint;
|
||||
|
|
|
@ -104,13 +104,13 @@ public class SearchHistoryActivity extends ListActivity implements SearchActivit
|
|||
@Override
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
if (which == 0) {
|
||||
OsmandSettings.getOsmandSettings(SearchHistoryActivity.this).setMapLocationToShow(entry.getLat(), entry.getLon());
|
||||
OsmandSettings.getOsmandSettings(SearchHistoryActivity.this).setMapLocationToShow(entry.getLat(),
|
||||
entry.getLon());
|
||||
} else if (which == 1) {
|
||||
OsmandSettings.getOsmandSettings(SearchHistoryActivity.this).setPointToNavigate(entry.getLat(), entry.getLon(), null);
|
||||
OsmandSettings.getOsmandSettings(SearchHistoryActivity.this).setPointToNavigate(entry.getLat(), entry.getLon(),
|
||||
null);
|
||||
}
|
||||
|
||||
MapActivity.launchMapActivityMoveToTop(SearchHistoryActivity.this);
|
||||
|
||||
}
|
||||
|
||||
});
|
||||
|
|
|
@ -48,8 +48,6 @@ import android.text.Editable;
|
|||
import android.text.TextWatcher;
|
||||
import android.util.Log;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuItem;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.view.View.OnClickListener;
|
||||
|
|
Loading…
Reference in a new issue