Fixes p.3
This commit is contained in:
parent
6234b77135
commit
d54419d70d
4 changed files with 39 additions and 45 deletions
|
@ -680,7 +680,7 @@ public class SearchCoreFactory {
|
||||||
nm = new NameStringMatcher(unknownSearchPhrase, StringMatcherMode.CHECK_STARTS_FROM_SPACE);
|
nm = new NameStringMatcher(unknownSearchPhrase, StringMatcherMode.CHECK_STARTS_FROM_SPACE);
|
||||||
}
|
}
|
||||||
for (AbstractPoiType pf : topVisibleFilters) {
|
for (AbstractPoiType pf : topVisibleFilters) {
|
||||||
if (!phrase.isUnknownSearchWordPresent()
|
if (showTopFiltersOnly
|
||||||
|| nm.matches(pf.getTranslation())
|
|| nm.matches(pf.getTranslation())
|
||||||
|| nm.matches(pf.getEnTranslation())
|
|| nm.matches(pf.getEnTranslation())
|
||||||
|| nm.matches(pf.getSynonyms())) {
|
|| nm.matches(pf.getSynonyms())) {
|
||||||
|
@ -688,7 +688,7 @@ public class SearchCoreFactory {
|
||||||
searchWordTypes.add(pf);
|
searchWordTypes.add(pf);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (phrase.isUnknownSearchWordPresent()) {
|
if (!showTopFiltersOnly) {
|
||||||
for (PoiCategory c : categories) {
|
for (PoiCategory c : categories) {
|
||||||
if (!results.contains(c)
|
if (!results.contains(c)
|
||||||
&& (nm.matches(c.getTranslation())
|
&& (nm.matches(c.getTranslation())
|
||||||
|
@ -740,8 +740,7 @@ public class SearchCoreFactory {
|
||||||
if (showTopFiltersOnly) {
|
if (showTopFiltersOnly) {
|
||||||
String stdFilterId = getStandardFilterId(pt);
|
String stdFilterId = getStandardFilterId(pt);
|
||||||
if (filterOrders.containsKey(stdFilterId)) {
|
if (filterOrders.containsKey(stdFilterId)) {
|
||||||
int p = filterOrders.get(stdFilterId);
|
res.priority = SEARCH_AMENITY_TYPE_PRIORITY + filterOrders.get(stdFilterId);
|
||||||
res.priority = SEARCH_AMENITY_TYPE_PRIORITY + p;
|
|
||||||
resultMatcher.publish(res);
|
resultMatcher.publish(res);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
@ -758,13 +757,11 @@ public class SearchCoreFactory {
|
||||||
res.objectType = ObjectType.POI_TYPE;
|
res.objectType = ObjectType.POI_TYPE;
|
||||||
if (showTopFiltersOnly) {
|
if (showTopFiltersOnly) {
|
||||||
if (filterOrders.containsKey(csf.getFilterId())) {
|
if (filterOrders.containsKey(csf.getFilterId())) {
|
||||||
int p = filterOrders.get(csf.getFilterId());
|
res.priority = SEARCH_AMENITY_TYPE_PRIORITY + filterOrders.get(csf.getFilterId());
|
||||||
res.priority = SEARCH_AMENITY_TYPE_PRIORITY + p;
|
|
||||||
resultMatcher.publish(res);
|
resultMatcher.publish(res);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
int p = customPoiFiltersPriorites.get(i);
|
res.priority = SEARCH_AMENITY_TYPE_PRIORITY + customPoiFiltersPriorites.get(i);
|
||||||
res.priority = SEARCH_AMENITY_TYPE_PRIORITY + p;
|
|
||||||
resultMatcher.publish(res);
|
resultMatcher.publish(res);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1003,6 +1003,31 @@ public class OsmandSettings {
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public List<String> getStringsList() {
|
||||||
|
final String listAsString = get();
|
||||||
|
if (listAsString != null) {
|
||||||
|
if (listAsString.contains(delimiter)) {
|
||||||
|
return Arrays.asList(listAsString.split(delimiter));
|
||||||
|
} else {
|
||||||
|
return new ArrayList<String>() {
|
||||||
|
{add(listAsString);}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setStringsList(List<String> values) {
|
||||||
|
if (values == null || values.size() == 0) {
|
||||||
|
set(null);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
clearAll();
|
||||||
|
for (String value : values) {
|
||||||
|
addValue(value);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public class EnumIntPreference<E extends Enum<E>> extends CommonPreference<E> {
|
public class EnumIntPreference<E extends Enum<E>> extends CommonPreference<E> {
|
||||||
|
@ -3057,9 +3082,11 @@ public class OsmandSettings {
|
||||||
SELECTED_POI_FILTER_FOR_MAP.set(android.text.TextUtils.join(",", poiFilters));
|
SELECTED_POI_FILTER_FOR_MAP.set(android.text.TextUtils.join(",", poiFilters));
|
||||||
}
|
}
|
||||||
|
|
||||||
public final OsmandPreference<String> POI_FILTERS_ORDER = new StringPreference("poi_filters_order", null).makeProfile().cache();
|
public final ListStringPreference POI_FILTERS_ORDER = (ListStringPreference)
|
||||||
|
new ListStringPreference("poi_filters_order", null, ",,").makeProfile().cache();
|
||||||
|
|
||||||
public final OsmandPreference<String> INACTIVE_POI_FILTERS = new StringPreference("inactive_poi_filters", null).makeProfile().cache();
|
public final ListStringPreference INACTIVE_POI_FILTERS = (ListStringPreference)
|
||||||
|
new ListStringPreference("inactive_poi_filters", null, ",,").makeProfile().cache();
|
||||||
|
|
||||||
public static final String VOICE_PROVIDER_NOT_USE = "VOICE_PROVIDER_NOT_USE";
|
public static final String VOICE_PROVIDER_NOT_USE = "VOICE_PROVIDER_NOT_USE";
|
||||||
|
|
||||||
|
|
|
@ -7,7 +7,6 @@ import net.osmand.osm.MapPoiTypes;
|
||||||
import net.osmand.osm.PoiCategory;
|
import net.osmand.osm.PoiCategory;
|
||||||
import net.osmand.osm.PoiType;
|
import net.osmand.osm.PoiType;
|
||||||
import net.osmand.plus.OsmandApplication;
|
import net.osmand.plus.OsmandApplication;
|
||||||
import net.osmand.plus.OsmandSettings;
|
|
||||||
import net.osmand.plus.R;
|
import net.osmand.plus.R;
|
||||||
import net.osmand.plus.api.SQLiteAPI.SQLiteConnection;
|
import net.osmand.plus.api.SQLiteAPI.SQLiteConnection;
|
||||||
import net.osmand.plus.api.SQLiteAPI.SQLiteCursor;
|
import net.osmand.plus.api.SQLiteAPI.SQLiteCursor;
|
||||||
|
@ -336,15 +335,15 @@ public class PoiFiltersHelper {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void saveFiltersOrder(List<String> filterIds) {
|
public void saveFiltersOrder(List<String> filterIds) {
|
||||||
saveFiltersListToPreference(filterIds, application.getSettings().POI_FILTERS_ORDER);
|
application.getSettings().POI_FILTERS_ORDER.setStringsList(filterIds);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void saveInactiveFilters(List<String> filterIds) {
|
public void saveInactiveFilters(List<String> filterIds) {
|
||||||
saveFiltersListToPreference(filterIds, application.getSettings().INACTIVE_POI_FILTERS);
|
application.getSettings().INACTIVE_POI_FILTERS.setStringsList(filterIds);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Map<String, Integer> getPoiFiltersOrder() {
|
public Map<String, Integer> getPoiFiltersOrder() {
|
||||||
List<String> ids = getPoiFilterIdListFromPreference(application.getSettings().POI_FILTERS_ORDER);
|
List<String> ids = application.getSettings().POI_FILTERS_ORDER.getStringsList();
|
||||||
if (ids == null) {
|
if (ids == null) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
@ -356,36 +355,7 @@ public class PoiFiltersHelper {
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<String> getInactivePoiFiltersIds() {
|
public List<String> getInactivePoiFiltersIds() {
|
||||||
return getPoiFilterIdListFromPreference(application.getSettings().INACTIVE_POI_FILTERS);
|
return application.getSettings().INACTIVE_POI_FILTERS.getStringsList();
|
||||||
}
|
|
||||||
|
|
||||||
private List<String> getPoiFilterIdListFromPreference(OsmandSettings.OsmandPreference<String> preference) {
|
|
||||||
final String filterIdListAsString = preference.get();
|
|
||||||
if (filterIdListAsString != null) {
|
|
||||||
if (filterIdListAsString.contains("|")) {
|
|
||||||
return Arrays.asList(filterIdListAsString.split("\\|"));
|
|
||||||
} else {
|
|
||||||
return new ArrayList<String>() {
|
|
||||||
{add(filterIdListAsString);}
|
|
||||||
};
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void saveFiltersListToPreference(List<String> filterIds, OsmandSettings.OsmandPreference<String> preference) {
|
|
||||||
if (filterIds == null || filterIds.size() == 0) {
|
|
||||||
preference.set(null);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
String filterId = filterIds.get(0);
|
|
||||||
StringBuilder filtersAsString = new StringBuilder(filterId);
|
|
||||||
for (int i = 1; i < filterIds.size(); i++) {
|
|
||||||
filterId = filterIds.get(i);
|
|
||||||
filtersAsString.append('|');
|
|
||||||
filtersAsString.append(filterId);
|
|
||||||
}
|
|
||||||
preference.set(filtersAsString.toString());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private PoiFilterDbHelper openDbHelperNoPois() {
|
private PoiFilterDbHelper openDbHelperNoPois() {
|
||||||
|
|
|
@ -1235,7 +1235,7 @@ public class QuickSearchDialogFragment extends DialogFragment implements OsmAndC
|
||||||
@Override
|
@Override
|
||||||
public boolean processResult(Boolean changed) {
|
public boolean processResult(Boolean changed) {
|
||||||
if (changed) {
|
if (changed) {
|
||||||
searchUICore.setFilterOrders(app.getPoiFilters().getPoiFilterOrders(true));
|
searchHelper.refreshFilterOrders();
|
||||||
reloadCategoriesInternal();
|
reloadCategoriesInternal();
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
|
Loading…
Reference in a new issue