Merge remote-tracking branch 'origin/master'

This commit is contained in:
Weblate 2016-07-16 11:10:50 +02:00
commit d5827ef499
4 changed files with 67 additions and 14 deletions

View file

@ -14,6 +14,7 @@ import net.osmand.binary.BinaryMapIndexReader;
import net.osmand.binary.BinaryMapIndexReader.SearchRequest;
import net.osmand.data.LatLon;
import net.osmand.data.QuadRect;
import net.osmand.util.Algorithms;
import net.osmand.util.MapUtils;
//immutable object
@ -267,7 +268,19 @@ public class SearchPhrase {
}
return sb.toString();
}
public String getTextWithoutLastWord() {
StringBuilder sb = new StringBuilder();
List<SearchWord> words = new ArrayList<>(this.words);
if(Algorithms.isEmpty(lastWordTrim) && words.size() > 0) {
words.remove(words.size() - 1);
}
for(SearchWord s : words) {
sb.append(s.getWord()).append(", ");
}
return sb.toString();
}
public String getStringRerpresentation() {
StringBuilder sb = new StringBuilder();
for(SearchWord s : words) {

View file

@ -9,6 +9,9 @@
3. All your modified/created strings are in the top of the file (to make easier find what\'s translated).
PLEASE: Have a look at http://code.google.com/p/osmand/wiki/UIConsistency, it may really improve your and our work :-) Thx - Hardy
-->
<string name="shared_string_from">from</string>
<string name="city_type_district">District</string>
<string name="city_type_neighbourhood">Neighbourhood</string>
<string name="map_widget_search">Search</string>
<string name="shared_string_is_open_24_7">Open 24/7</string>
<string name="storage_directory_card">Memory card</string>

View file

@ -158,10 +158,10 @@ public class QuickSearchDialogFragment extends DialogFragment {
clearButton.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
if (searchEditText.getText().length() == 0) {
dismiss();
} else {
searchEditText.setText("");
if (searchEditText.getText().length() > 0) {
String newText = searchUICore.getPhrase().getTextWithoutLastWord();
searchEditText.setText(newText);
searchEditText.setSelection(newText.length());
}
}
});

View file

@ -2,8 +2,10 @@ package net.osmand.plus.search;
import android.graphics.drawable.Drawable;
import net.osmand.binary.BinaryMapIndexReader;
import net.osmand.data.Amenity;
import net.osmand.data.City;
import net.osmand.data.City.CityType;
import net.osmand.data.FavouritePoint;
import net.osmand.data.Street;
import net.osmand.osm.AbstractPoiType;
@ -35,6 +37,27 @@ public class SearchListItem {
return searchResult;
}
private String getCityTypeStr(CityType type) {
switch (type) {
case CITY:
return app.getString(R.string.city_type_city);
case TOWN:
return app.getString(R.string.city_type_town);
case VILLAGE:
return app.getString(R.string.city_type_village);
case HAMLET:
return app.getString(R.string.city_type_hamlet);
case SUBURB:
return app.getString(R.string.city_type_suburb);
case DISTRICT:
return app.getString(R.string.city_type_district);
case NEIGHBOURHOOD:
return app.getString(R.string.city_type_neighbourhood);
default:
return app.getString(R.string.city_type_city);
}
}
public String getName() {
return searchResult.localeName;
}
@ -44,25 +67,37 @@ public class SearchListItem {
case CITY:
case POSTCODE:
City city = (City) searchResult.object;
return Algorithms.capitalizeFirstLetterAndLowercase(city.getType().toString());
return getCityTypeStr(city.getType());
case VILLAGE:
city = (City) searchResult.object;
if (!Algorithms.isEmpty(searchResult.localeRelatedObjectName)) {
return Algorithms.capitalizeFirstLetterAndLowercase(city.getType().toString())
+ " near "
+ searchResult.localeRelatedObjectName
+ (searchResult.distRelatedObjectName > 0 ? " (" + OsmAndFormatter.getFormattedDistance((float)searchResult.distRelatedObjectName, app) + ")" : "");
if (searchResult.distRelatedObjectName > 0) {
return getCityTypeStr(city.getType())
+ ", "
+ OsmAndFormatter.getFormattedDistance((float) searchResult.distRelatedObjectName, app)
+ " " + app.getString(R.string.shared_string_from) + " "
+ searchResult.localeRelatedObjectName;
} else {
return getCityTypeStr(city.getType())
+ ", "
+ searchResult.localeRelatedObjectName;
}
} else {
return Algorithms.capitalizeFirstLetterAndLowercase(city.getType().toString());
return getCityTypeStr(city.getType());
}
case STREET:
Street street = (Street) searchResult.object;
City streetCity = street.getCity();
if (!Algorithms.isEmpty(searchResult.localeRelatedObjectName)) {
return searchResult.localeRelatedObjectName
+ (searchResult.distRelatedObjectName > 0 ? " (" + OsmAndFormatter.getFormattedDistance((float)searchResult.distRelatedObjectName, app) + ")" : "");
if (searchResult.distRelatedObjectName > 0) {
return OsmAndFormatter.getFormattedDistance((float) searchResult.distRelatedObjectName, app)
+ " " + app.getString(R.string.shared_string_from) + " "
+ searchResult.localeRelatedObjectName;
} else {
return searchResult.localeRelatedObjectName;
}
} else {
return streetCity.getName() + " - " + Algorithms.capitalizeFirstLetterAndLowercase(streetCity.getType().name());
return getCityTypeStr(streetCity.getType()) + ", " + streetCity.getName();
}
case HOUSE:
return "";
@ -108,6 +143,8 @@ public class SearchListItem {
return fav.getCategory().length() == 0 ?
app.getString(R.string.shared_string_favorites) : fav.getCategory();
case REGION:
BinaryMapIndexReader binaryMapIndexReader = (BinaryMapIndexReader) searchResult.object;
System.out.println(binaryMapIndexReader.getFile().getAbsolutePath() + " " + binaryMapIndexReader.getCountryName());
break;
case RECENT_OBJ:
HistoryEntry entry = (HistoryEntry) searchResult.object;