Merge remote-tracking branch 'origin/master'
This commit is contained in:
commit
26f80f18d5
6 changed files with 162 additions and 7 deletions
|
@ -31,7 +31,6 @@
|
||||||
android:gravity="center_vertical"
|
android:gravity="center_vertical"
|
||||||
android:textColor="?attr/color_dialog_buttons"
|
android:textColor="?attr/color_dialog_buttons"
|
||||||
android:textSize="@dimen/default_sub_text_size"
|
android:textSize="@dimen/default_sub_text_size"
|
||||||
osmand:textAllCapsCompat="true"
|
|
||||||
osmand:typeface="@string/font_roboto_medium"/>
|
osmand:typeface="@string/font_roboto_medium"/>
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
|
@ -9,6 +9,8 @@
|
||||||
3. All your modified/created strings are in the top of the file (to make easier find what\'s translated).
|
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
|
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="select_streets">Select streets</string>
|
||||||
|
<string name="shared_string_in_name">in %1$s</string>
|
||||||
<string name="type_address">Type address</string>
|
<string name="type_address">Type address</string>
|
||||||
<string name="type_city_town">Type city or town</string>
|
<string name="type_city_town">Type city or town</string>
|
||||||
<string name="type_postcode">Type postcode</string>
|
<string name="type_postcode">Type postcode</string>
|
||||||
|
|
|
@ -20,7 +20,10 @@ import android.support.v4.view.ViewPager;
|
||||||
import android.support.v7.app.AlertDialog;
|
import android.support.v7.app.AlertDialog;
|
||||||
import android.support.v7.widget.Toolbar;
|
import android.support.v7.widget.Toolbar;
|
||||||
import android.text.Editable;
|
import android.text.Editable;
|
||||||
|
import android.text.Spannable;
|
||||||
|
import android.text.SpannableString;
|
||||||
import android.text.TextWatcher;
|
import android.text.TextWatcher;
|
||||||
|
import android.text.style.ForegroundColorSpan;
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.View.OnClickListener;
|
import android.view.View.OnClickListener;
|
||||||
|
@ -41,6 +44,8 @@ import net.osmand.Location;
|
||||||
import net.osmand.ResultMatcher;
|
import net.osmand.ResultMatcher;
|
||||||
import net.osmand.access.AccessibilityAssistant;
|
import net.osmand.access.AccessibilityAssistant;
|
||||||
import net.osmand.access.NavigationInfo;
|
import net.osmand.access.NavigationInfo;
|
||||||
|
import net.osmand.binary.BinaryMapIndexReader;
|
||||||
|
import net.osmand.data.City;
|
||||||
import net.osmand.data.LatLon;
|
import net.osmand.data.LatLon;
|
||||||
import net.osmand.data.PointDescription;
|
import net.osmand.data.PointDescription;
|
||||||
import net.osmand.osm.AbstractPoiType;
|
import net.osmand.osm.AbstractPoiType;
|
||||||
|
@ -63,6 +68,7 @@ import net.osmand.plus.activities.MapActivity.ShowQuickSearchMode;
|
||||||
import net.osmand.plus.helpers.SearchHistoryHelper;
|
import net.osmand.plus.helpers.SearchHistoryHelper;
|
||||||
import net.osmand.plus.helpers.SearchHistoryHelper.HistoryEntry;
|
import net.osmand.plus.helpers.SearchHistoryHelper.HistoryEntry;
|
||||||
import net.osmand.plus.poi.PoiUIFilter;
|
import net.osmand.plus.poi.PoiUIFilter;
|
||||||
|
import net.osmand.plus.resources.RegionAddressRepository;
|
||||||
import net.osmand.plus.search.QuickSearchHelper.SearchHistoryAPI;
|
import net.osmand.plus.search.QuickSearchHelper.SearchHistoryAPI;
|
||||||
import net.osmand.plus.search.listitems.QuickSearchButtonListItem;
|
import net.osmand.plus.search.listitems.QuickSearchButtonListItem;
|
||||||
import net.osmand.plus.search.listitems.QuickSearchHeaderListItem;
|
import net.osmand.plus.search.listitems.QuickSearchHeaderListItem;
|
||||||
|
@ -1064,7 +1070,29 @@ public class QuickSearchDialogFragment extends DialogFragment implements OsmAndC
|
||||||
stopAddressSearch();
|
stopAddressSearch();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
OsmandSettings settings = app.getSettings();
|
||||||
List<QuickSearchListItem> rows = new ArrayList<>();
|
List<QuickSearchListItem> rows = new ArrayList<>();
|
||||||
|
|
||||||
|
final SearchResult lastCityResult = getLastCityResult();
|
||||||
|
if (lastCityResult != null) {
|
||||||
|
String selectStreets = app.getString(R.string.select_streets);
|
||||||
|
String inCityName = app.getString(R.string.shared_string_in_name, settings.getLastSearchedCityName());
|
||||||
|
Spannable spannable = new SpannableString(selectStreets + " " + inCityName);
|
||||||
|
boolean light = settings.isLightContent();
|
||||||
|
spannable.setSpan(new ForegroundColorSpan(getResources().getColor(light ? R.color.icon_color : R.color.color_white)),
|
||||||
|
selectStreets.length() + 1, spannable.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
|
||||||
|
|
||||||
|
rows.add(new QuickSearchButtonListItem(app, R.drawable.ic_action_street_name,
|
||||||
|
spannable, new OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(View v) {
|
||||||
|
completeQueryWithObject(lastCityResult);
|
||||||
|
|
||||||
|
searchEditText.requestFocus();
|
||||||
|
AndroidUtils.softKeyboardDelayed(searchEditText);
|
||||||
|
}
|
||||||
|
}));
|
||||||
|
}
|
||||||
rows.add(new QuickSearchButtonListItem(app, R.drawable.ic_action_building_number,
|
rows.add(new QuickSearchButtonListItem(app, R.drawable.ic_action_building_number,
|
||||||
app.getString(R.string.select_city), new OnClickListener() {
|
app.getString(R.string.select_city), new OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
|
@ -1073,6 +1101,7 @@ public class QuickSearchDialogFragment extends DialogFragment implements OsmAndC
|
||||||
startCitySearch();
|
startCitySearch();
|
||||||
updateTabbarVisibility(false);
|
updateTabbarVisibility(false);
|
||||||
runCoreSearch("", false, false);
|
runCoreSearch("", false, false);
|
||||||
|
|
||||||
searchEditText.requestFocus();
|
searchEditText.requestFocus();
|
||||||
AndroidUtils.softKeyboardDelayed(searchEditText);
|
AndroidUtils.softKeyboardDelayed(searchEditText);
|
||||||
}
|
}
|
||||||
|
@ -1114,6 +1143,53 @@ public class QuickSearchDialogFragment extends DialogFragment implements OsmAndC
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private SearchResult getLastCityResult() throws IOException {
|
||||||
|
OsmandSettings settings = app.getSettings();
|
||||||
|
final long lastCityId = settings.getLastSearchedCity();
|
||||||
|
final LatLon lastPoint = settings.getLastSearchedPoint();
|
||||||
|
if (lastCityId != -1 && lastPoint != null) {
|
||||||
|
final String lastCityName = settings.getLastSearchedCityName();
|
||||||
|
LatLon prevLatLon = startLastCitySearch(lastPoint);
|
||||||
|
SearchResultCollection lastCity = searchUICore.shallowSearch(SearchAddressByNameAPI.class, lastCityName, new ResultMatcher<SearchResult>() {
|
||||||
|
|
||||||
|
boolean cityFound = false;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean publish(SearchResult object) {
|
||||||
|
if (object.objectType == ObjectType.CITY && ((City) object.object).getId() == lastCityId) {
|
||||||
|
cityFound = true;
|
||||||
|
return true;
|
||||||
|
} else {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isCancelled() {
|
||||||
|
return cityFound;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
if (addressSearch) {
|
||||||
|
startAddressSearch();
|
||||||
|
} else {
|
||||||
|
stopAddressSearch();
|
||||||
|
}
|
||||||
|
// Restore previous search location
|
||||||
|
searchUICore.updateSettings(searchUICore.getSearchSettings().setOriginalLocation(prevLatLon));
|
||||||
|
|
||||||
|
if (lastCity != null) {
|
||||||
|
List<SearchResult> results = lastCity.getCurrentSearchResults();
|
||||||
|
if (results.size() > 0) {
|
||||||
|
final SearchResult sr = results.get(0);
|
||||||
|
if (sr.objectType == ObjectType.CITY) {
|
||||||
|
return sr;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
public void reloadHistory() {
|
public void reloadHistory() {
|
||||||
if (app.isApplicationInitializing()) {
|
if (app.isApplicationInitializing()) {
|
||||||
showProgressBar();
|
showProgressBar();
|
||||||
|
@ -1194,6 +1270,20 @@ public class QuickSearchDialogFragment extends DialogFragment implements OsmAndC
|
||||||
searchUICore.updateSettings(settings);
|
searchUICore.updateSettings(settings);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private LatLon startLastCitySearch(LatLon latLon) {
|
||||||
|
SearchSettings settings = searchUICore.getSearchSettings();
|
||||||
|
LatLon prevLatLon = settings.getOriginalLocation();
|
||||||
|
settings = settings.setEmptyQueryAllowed(true)
|
||||||
|
.setAddressSearch(true)
|
||||||
|
.setSortByName(false)
|
||||||
|
.setSearchTypes(ObjectType.CITY)
|
||||||
|
.setOriginalLocation(latLon)
|
||||||
|
.setRadiusLevel(1);
|
||||||
|
|
||||||
|
searchUICore.updateSettings(settings);
|
||||||
|
return prevLatLon;
|
||||||
|
}
|
||||||
|
|
||||||
private void startPostcodeSearch() {
|
private void startPostcodeSearch() {
|
||||||
SearchSettings settings = searchUICore.getSearchSettings()
|
SearchSettings settings = searchUICore.getSearchSettings()
|
||||||
.setSearchTypes(ObjectType.POSTCODE)
|
.setSearchTypes(ObjectType.POSTCODE)
|
||||||
|
@ -1395,6 +1485,19 @@ public class QuickSearchDialogFragment extends DialogFragment implements OsmAndC
|
||||||
searchUICore.selectSearchResult(sr);
|
searchUICore.selectSearchResult(sr);
|
||||||
if (addressSearch) {
|
if (addressSearch) {
|
||||||
startAddressSearch();
|
startAddressSearch();
|
||||||
|
if (sr.objectType == ObjectType.CITY) {
|
||||||
|
if (sr.relatedObject != null && sr.relatedObject instanceof BinaryMapIndexReader) {
|
||||||
|
File f = ((BinaryMapIndexReader) sr.relatedObject).getFile();
|
||||||
|
if (f != null) {
|
||||||
|
RegionAddressRepository region = app.getResourceManager().getRegionRepository(f.getName());
|
||||||
|
if (region != null) {
|
||||||
|
app.getSettings().setLastSearchedRegion(region.getFileName(), region.getEstimatedRegionCenter());
|
||||||
|
City city = (City) sr.object;
|
||||||
|
app.getSettings().setLastSearchedCity(city.getId(), sr.localeName, city.getLocation());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
String txt = searchUICore.getPhrase().getText(true);
|
String txt = searchUICore.getPhrase().getText(true);
|
||||||
searchQuery = txt;
|
searchQuery = txt;
|
||||||
|
|
|
@ -220,7 +220,11 @@ public class QuickSearchListAdapter extends ArrayAdapter<QuickSearchListItem> {
|
||||||
view = (LinearLayout) convertView;
|
view = (LinearLayout) convertView;
|
||||||
}
|
}
|
||||||
|
|
||||||
((TextView) view.findViewById(R.id.title)).setText(listItem.getName());
|
if (listItem.getSpannableName() != null) {
|
||||||
|
((TextView) view.findViewById(R.id.title)).setText(listItem.getSpannableName());
|
||||||
|
} else {
|
||||||
|
((TextView) view.findViewById(R.id.title)).setText(listItem.getName());
|
||||||
|
}
|
||||||
} else if (type == QuickSearchListItemType.BUTTON) {
|
} else if (type == QuickSearchListItemType.BUTTON) {
|
||||||
if (convertView == null) {
|
if (convertView == null) {
|
||||||
LayoutInflater inflater = (LayoutInflater) app
|
LayoutInflater inflater = (LayoutInflater) app
|
||||||
|
@ -231,7 +235,11 @@ public class QuickSearchListAdapter extends ArrayAdapter<QuickSearchListItem> {
|
||||||
view = (LinearLayout) convertView;
|
view = (LinearLayout) convertView;
|
||||||
}
|
}
|
||||||
((ImageView) view.findViewById(R.id.imageView)).setImageDrawable(listItem.getIcon());
|
((ImageView) view.findViewById(R.id.imageView)).setImageDrawable(listItem.getIcon());
|
||||||
((TextView) view.findViewById(R.id.title)).setText(listItem.getName());
|
if (listItem.getSpannableName() != null) {
|
||||||
|
((TextView) view.findViewById(R.id.title)).setText(listItem.getSpannableName());
|
||||||
|
} else {
|
||||||
|
((TextView) view.findViewById(R.id.title)).setText(listItem.getName());
|
||||||
|
}
|
||||||
} else if (type == QuickSearchListItemType.SELECT_ALL) {
|
} else if (type == QuickSearchListItemType.SELECT_ALL) {
|
||||||
if (convertView == null) {
|
if (convertView == null) {
|
||||||
LayoutInflater inflater = (LayoutInflater) app
|
LayoutInflater inflater = (LayoutInflater) app
|
||||||
|
@ -262,7 +270,11 @@ public class QuickSearchListAdapter extends ArrayAdapter<QuickSearchListItem> {
|
||||||
}
|
}
|
||||||
view.findViewById(R.id.top_divider)
|
view.findViewById(R.id.top_divider)
|
||||||
.setVisibility(((QuickSearchHeaderListItem)listItem).isShowTopDivider() ? View.VISIBLE : View.GONE);
|
.setVisibility(((QuickSearchHeaderListItem)listItem).isShowTopDivider() ? View.VISIBLE : View.GONE);
|
||||||
((TextView) view.findViewById(R.id.title)).setText(listItem.getName());
|
if (listItem.getSpannableName() != null) {
|
||||||
|
((TextView) view.findViewById(R.id.title)).setText(listItem.getSpannableName());
|
||||||
|
} else {
|
||||||
|
((TextView) view.findViewById(R.id.title)).setText(listItem.getName());
|
||||||
|
}
|
||||||
} else if (type == QuickSearchListItemType.TOP_SHADOW) {
|
} else if (type == QuickSearchListItemType.TOP_SHADOW) {
|
||||||
if (convertView == null) {
|
if (convertView == null) {
|
||||||
LayoutInflater inflater = (LayoutInflater) app
|
LayoutInflater inflater = (LayoutInflater) app
|
||||||
|
@ -314,7 +326,11 @@ public class QuickSearchListAdapter extends ArrayAdapter<QuickSearchListItem> {
|
||||||
|
|
||||||
imageView.setImageDrawable(listItem.getIcon());
|
imageView.setImageDrawable(listItem.getIcon());
|
||||||
String name = listItem.getName();
|
String name = listItem.getName();
|
||||||
title.setText(name);
|
if (listItem.getSpannableName() != null) {
|
||||||
|
title.setText(listItem.getSpannableName());
|
||||||
|
} else {
|
||||||
|
title.setText(name);
|
||||||
|
}
|
||||||
|
|
||||||
String desc = listItem.getTypeName();
|
String desc = listItem.getTypeName();
|
||||||
boolean hasDesc = false;
|
boolean hasDesc = false;
|
||||||
|
|
|
@ -1,6 +1,10 @@
|
||||||
package net.osmand.plus.search.listitems;
|
package net.osmand.plus.search.listitems;
|
||||||
|
|
||||||
import android.graphics.drawable.Drawable;
|
import android.graphics.drawable.Drawable;
|
||||||
|
import android.support.annotation.NonNull;
|
||||||
|
import android.text.Spannable;
|
||||||
|
import android.text.SpannableString;
|
||||||
|
import android.text.Spanned;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
|
|
||||||
import net.osmand.plus.OsmandApplication;
|
import net.osmand.plus.OsmandApplication;
|
||||||
|
@ -10,13 +14,22 @@ public class QuickSearchButtonListItem extends QuickSearchListItem {
|
||||||
|
|
||||||
private int iconId;
|
private int iconId;
|
||||||
private String title;
|
private String title;
|
||||||
|
private Spannable spannableTitle;
|
||||||
private View.OnClickListener onClickListener;
|
private View.OnClickListener onClickListener;
|
||||||
private int colorId;
|
private int colorId;
|
||||||
|
|
||||||
public QuickSearchButtonListItem(OsmandApplication app, int iconId, String title, View.OnClickListener onClickListener) {
|
public QuickSearchButtonListItem(OsmandApplication app, int iconId, @NonNull String title, View.OnClickListener onClickListener) {
|
||||||
super(app, null);
|
super(app, null);
|
||||||
this.iconId = iconId;
|
this.iconId = iconId;
|
||||||
this.title = title;
|
this.title = title.toUpperCase();
|
||||||
|
this.onClickListener = onClickListener;
|
||||||
|
this.colorId = app.getSettings().isLightContent() ? R.color.color_dialog_buttons_light : R.color.color_dialog_buttons_dark;
|
||||||
|
}
|
||||||
|
|
||||||
|
public QuickSearchButtonListItem(OsmandApplication app, int iconId, @NonNull Spannable title, View.OnClickListener onClickListener) {
|
||||||
|
super(app, null);
|
||||||
|
this.iconId = iconId;
|
||||||
|
this.spannableTitle = spannedToUpperCase(title);
|
||||||
this.onClickListener = onClickListener;
|
this.onClickListener = onClickListener;
|
||||||
this.colorId = app.getSettings().isLightContent() ? R.color.color_dialog_buttons_light : R.color.color_dialog_buttons_dark;
|
this.colorId = app.getSettings().isLightContent() ? R.color.color_dialog_buttons_light : R.color.color_dialog_buttons_dark;
|
||||||
}
|
}
|
||||||
|
@ -39,7 +52,23 @@ public class QuickSearchButtonListItem extends QuickSearchListItem {
|
||||||
return title;
|
return title;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Spannable getSpannableName() {
|
||||||
|
return spannableTitle;
|
||||||
|
}
|
||||||
|
|
||||||
public View.OnClickListener getOnClickListener() {
|
public View.OnClickListener getOnClickListener() {
|
||||||
return onClickListener;
|
return onClickListener;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static Spannable spannedToUpperCase(@NonNull Spanned s) {
|
||||||
|
Object[] spans = s.getSpans(0, s.length(), Object.class);
|
||||||
|
SpannableString spannableString = new SpannableString(s.toString().toUpperCase());
|
||||||
|
|
||||||
|
// reapply the spans to the now uppercase string
|
||||||
|
for (Object span : spans) {
|
||||||
|
spannableString.setSpan(span, s.getSpanStart(span), s.getSpanEnd(span), s.getSpanFlags(span));
|
||||||
|
}
|
||||||
|
return spannableString;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,6 +2,8 @@ package net.osmand.plus.search.listitems;
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.graphics.drawable.Drawable;
|
import android.graphics.drawable.Drawable;
|
||||||
|
import android.text.Spannable;
|
||||||
|
|
||||||
import net.osmand.binary.BinaryMapIndexReader;
|
import net.osmand.binary.BinaryMapIndexReader;
|
||||||
import net.osmand.data.Amenity;
|
import net.osmand.data.Amenity;
|
||||||
import net.osmand.data.City;
|
import net.osmand.data.City;
|
||||||
|
@ -73,6 +75,10 @@ public class QuickSearchListItem {
|
||||||
return getName(app, searchResult);
|
return getName(app, searchResult);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Spannable getSpannableName() {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
public static String getName(OsmandApplication app, SearchResult searchResult) {
|
public static String getName(OsmandApplication app, SearchResult searchResult) {
|
||||||
switch (searchResult.objectType) {
|
switch (searchResult.objectType) {
|
||||||
case STREET:
|
case STREET:
|
||||||
|
|
Loading…
Reference in a new issue