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);
|
||||
}
|
||||
for (AbstractPoiType pf : topVisibleFilters) {
|
||||
if (!phrase.isUnknownSearchWordPresent()
|
||||
if (showTopFiltersOnly
|
||||
|| nm.matches(pf.getTranslation())
|
||||
|| nm.matches(pf.getEnTranslation())
|
||||
|| nm.matches(pf.getSynonyms())) {
|
||||
|
@ -688,7 +688,7 @@ public class SearchCoreFactory {
|
|||
searchWordTypes.add(pf);
|
||||
}
|
||||
}
|
||||
if (phrase.isUnknownSearchWordPresent()) {
|
||||
if (!showTopFiltersOnly) {
|
||||
for (PoiCategory c : categories) {
|
||||
if (!results.contains(c)
|
||||
&& (nm.matches(c.getTranslation())
|
||||
|
@ -740,8 +740,7 @@ public class SearchCoreFactory {
|
|||
if (showTopFiltersOnly) {
|
||||
String stdFilterId = getStandardFilterId(pt);
|
||||
if (filterOrders.containsKey(stdFilterId)) {
|
||||
int p = filterOrders.get(stdFilterId);
|
||||
res.priority = SEARCH_AMENITY_TYPE_PRIORITY + p;
|
||||
res.priority = SEARCH_AMENITY_TYPE_PRIORITY + filterOrders.get(stdFilterId);
|
||||
resultMatcher.publish(res);
|
||||
}
|
||||
} else {
|
||||
|
@ -758,13 +757,11 @@ public class SearchCoreFactory {
|
|||
res.objectType = ObjectType.POI_TYPE;
|
||||
if (showTopFiltersOnly) {
|
||||
if (filterOrders.containsKey(csf.getFilterId())) {
|
||||
int p = filterOrders.get(csf.getFilterId());
|
||||
res.priority = SEARCH_AMENITY_TYPE_PRIORITY + p;
|
||||
res.priority = SEARCH_AMENITY_TYPE_PRIORITY + filterOrders.get(csf.getFilterId());
|
||||
resultMatcher.publish(res);
|
||||
}
|
||||
} else {
|
||||
int p = customPoiFiltersPriorites.get(i);
|
||||
res.priority = SEARCH_AMENITY_TYPE_PRIORITY + p;
|
||||
res.priority = SEARCH_AMENITY_TYPE_PRIORITY + customPoiFiltersPriorites.get(i);
|
||||
resultMatcher.publish(res);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1003,6 +1003,31 @@ public class OsmandSettings {
|
|||
}
|
||||
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> {
|
||||
|
@ -3057,9 +3082,11 @@ public class OsmandSettings {
|
|||
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";
|
||||
|
||||
|
|
|
@ -7,7 +7,6 @@ import net.osmand.osm.MapPoiTypes;
|
|||
import net.osmand.osm.PoiCategory;
|
||||
import net.osmand.osm.PoiType;
|
||||
import net.osmand.plus.OsmandApplication;
|
||||
import net.osmand.plus.OsmandSettings;
|
||||
import net.osmand.plus.R;
|
||||
import net.osmand.plus.api.SQLiteAPI.SQLiteConnection;
|
||||
import net.osmand.plus.api.SQLiteAPI.SQLiteCursor;
|
||||
|
@ -336,15 +335,15 @@ public class PoiFiltersHelper {
|
|||
}
|
||||
|
||||
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) {
|
||||
saveFiltersListToPreference(filterIds, application.getSettings().INACTIVE_POI_FILTERS);
|
||||
application.getSettings().INACTIVE_POI_FILTERS.setStringsList(filterIds);
|
||||
}
|
||||
|
||||
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) {
|
||||
return null;
|
||||
}
|
||||
|
@ -356,36 +355,7 @@ public class PoiFiltersHelper {
|
|||
}
|
||||
|
||||
public List<String> getInactivePoiFiltersIds() {
|
||||
return getPoiFilterIdListFromPreference(application.getSettings().INACTIVE_POI_FILTERS);
|
||||
}
|
||||
|
||||
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());
|
||||
return application.getSettings().INACTIVE_POI_FILTERS.getStringsList();
|
||||
}
|
||||
|
||||
private PoiFilterDbHelper openDbHelperNoPois() {
|
||||
|
|
|
@ -1235,7 +1235,7 @@ public class QuickSearchDialogFragment extends DialogFragment implements OsmAndC
|
|||
@Override
|
||||
public boolean processResult(Boolean changed) {
|
||||
if (changed) {
|
||||
searchUICore.setFilterOrders(app.getPoiFilters().getPoiFilterOrders(true));
|
||||
searchHelper.refreshFilterOrders();
|
||||
reloadCategoriesInternal();
|
||||
}
|
||||
return false;
|
||||
|
|
Loading…
Reference in a new issue