Merge remote-tracking branch 'origin/master'

This commit is contained in:
Weblate 2015-07-02 20:20:13 +02:00
commit e92e10fb2d
6 changed files with 33 additions and 13 deletions

View file

@ -28,6 +28,7 @@ public class MapPoiTypes {
private String resourceName; private String resourceName;
private List<PoiCategory> categories = new ArrayList<PoiCategory>(); private List<PoiCategory> categories = new ArrayList<PoiCategory>();
private PoiCategory otherCategory; private PoiCategory otherCategory;
private PoiCategory otherMapCategory;
static final String OSM_WIKI_CATEGORY = "osmwiki"; static final String OSM_WIKI_CATEGORY = "osmwiki";
private PoiTranslator poiTranslator = null; private PoiTranslator poiTranslator = null;
@ -67,6 +68,13 @@ public class MapPoiTypes {
return otherCategory; return otherCategory;
} }
public PoiCategory getOtherMapCategory() {
if(otherMapCategory == null) {
otherMapCategory = getPoiCategoryByName("Other", true);
}
return otherMapCategory;
}
public List<PoiFilter> getTopVisibleFilters() { public List<PoiFilter> getTopVisibleFilters() {
List<PoiFilter> lf = new ArrayList<PoiFilter>(); List<PoiFilter> lf = new ArrayList<PoiFilter>();
for(PoiCategory pc : categories) { for(PoiCategory pc : categories) {
@ -143,6 +151,9 @@ public class MapPoiTypes {
public Map<String, AbstractPoiType> getAllTypesTranslatedNames(StringMatcher matcher) { public Map<String, AbstractPoiType> getAllTypesTranslatedNames(StringMatcher matcher) {
TreeMap<String, AbstractPoiType> tm = new TreeMap<String, AbstractPoiType>(Collator.getInstance()); TreeMap<String, AbstractPoiType> tm = new TreeMap<String, AbstractPoiType>(Collator.getInstance());
for (PoiCategory pc : categories) { for (PoiCategory pc : categories) {
if(pc == otherMapCategory) {
continue;
}
addIf(tm, pc, matcher); addIf(tm, pc, matcher);
for (PoiFilter pt : pc.getPoiFilters()) { for (PoiFilter pt : pc.getPoiFilters()) {
addIf(tm, pt, matcher); addIf(tm, pt, matcher);
@ -290,6 +301,9 @@ public class MapPoiTypes {
lastFilter.addPoiType(tp); lastFilter.addPoiType(tp);
} }
allTypes.put(tp.getKeyName(), tp); allTypes.put(tp.getKeyName(), tp);
if(lastCategory == null) {
lastCategory = getOtherMapCategory();
}
lastCategory.addPoiType(tp); lastCategory.addPoiType(tp);
} }
} else if (tok == XmlPullParser.END_TAG) { } else if (tok == XmlPullParser.END_TAG) {
@ -298,6 +312,8 @@ public class MapPoiTypes {
lastFilter = null; lastFilter = null;
} else if (name.equals("poi_type")) { } else if (name.equals("poi_type")) {
lastType = null; lastType = null;
} else if (name.equals("poi_category")) {
lastCategory = null;
} }
} }
} }
@ -336,13 +352,17 @@ public class MapPoiTypes {
otherCategory = pc; otherCategory = pc;
} }
public List<PoiCategory> getCategories() { public List<PoiCategory> getCategories(boolean includeMapCategory) {
return categories; ArrayList<PoiCategory> lst = new ArrayList<PoiCategory>(categories);
if(!includeMapCategory) {
lst.remove(getOtherMapCategory());
}
return lst;
} }
private static void print(MapPoiTypes df) { private static void print(MapPoiTypes df) {
List<PoiCategory> pc = df.getCategories(); List<PoiCategory> pc = df.getCategories(true);
for(PoiCategory p : pc) { for(PoiCategory p : pc) {
System.out.println("Category " + p.getKeyName()); System.out.println("Category " + p.getKeyName());
for(PoiFilter f : p.getPoiFilters()) { for(PoiFilter f : p.getPoiFilters()) {

View file

@ -74,7 +74,7 @@ public class EditPOIFilterActivity extends OsmandListActivity {
if (filter != null) { if (filter != null) {
getSupportActionBar().setSubtitle(filter.getName()); getSupportActionBar().setSubtitle(filter.getName());
setListAdapter(new AmenityAdapter( ((OsmandApplication) getApplication()).getPoiTypes().getCategories())); setListAdapter(new AmenityAdapter( ((OsmandApplication) getApplication()).getPoiTypes().getCategories(false)));
} else { } else {
setListAdapter(new AmenityAdapter(new ArrayList<PoiCategory>())); setListAdapter(new AmenityAdapter(new ArrayList<PoiCategory>()));
} }
@ -197,7 +197,7 @@ public class EditPOIFilterActivity extends OsmandListActivity {
helper.editPoiFilter(filter); helper.editPoiFilter(filter);
ListView lv = this.getListView(); ListView lv = this.getListView();
AmenityAdapter la = this.getListAdapter(); AmenityAdapter la = this.getListAdapter();
la.notifyDataSetInvalidated(); la.notifyDataSetChanged();
return lv; return lv;
} }
@ -207,6 +207,7 @@ public class EditPOIFilterActivity extends OsmandListActivity {
for (int i = 0; i < count; i++) { for (int i = 0; i < count; i++) {
selectAllFromCategory(adapter.getItem(i)); selectAllFromCategory(adapter.getItem(i));
} }
adapter.notifyDataSetChanged();
} }
private void deselectAll(){ private void deselectAll(){

View file

@ -345,7 +345,7 @@ public class SearchPOIActivity extends OsmandListActivity implements OsmAndCompa
@Override @Override
public boolean onMenuItemClick(MenuItem item) { public boolean onMenuItemClick(MenuItem item) {
PoiUIFilter custom = getMyApplication().getPoiFilters().getCustomPOIFilter(); PoiUIFilter custom = getMyApplication().getPoiFilters().getCustomPOIFilter();
custom.updateTypesToAccept(f); custom.replaceWithPoiFilter(f);
showEditActivity(custom); showEditActivity(custom);
return true; return true;
} }
@ -410,7 +410,7 @@ public class SearchPOIActivity extends OsmandListActivity implements OsmAndCompa
this.filter.setFilterByName(null); this.filter.setFilterByName(null);
} }
} else { } else {
this.filter.updateTypesToAccept(custom); this.filter.replaceWithPoiFilter(custom);
} }
filter.clearPreviousZoom(); filter.clearPreviousZoom();
// run query again // run query again

View file

@ -194,6 +194,7 @@ public class SearchPoiFilterFragment extends OsmAndListFragment implements Searc
} else { } else {
custom.setFilterByName(null); custom.setFilterByName(null);
} }
custom.clearFilter();
custom.updateTypesToAccept(((AbstractPoiType) item)); custom.updateTypesToAccept(((AbstractPoiType) item));
showFilterActivity(custom.getFilterId()); showFilterActivity(custom.getFilterId());
} }

View file

@ -731,7 +731,7 @@ public class EditingPOIDialogProvider implements DialogProvider {
case DIALOG_POI_TYPES: { case DIALOG_POI_TYPES: {
final Amenity a = (Amenity) args.getSerializable(KEY_AMENITY); final Amenity a = (Amenity) args.getSerializable(KEY_AMENITY);
Builder builder = new AlertDialog.Builder(activity); Builder builder = new AlertDialog.Builder(activity);
final List<PoiCategory> categories = poiTypes.getCategories(); final List<PoiCategory> categories = poiTypes.getCategories(true);
String[] vals = new String[categories.size()]; String[] vals = new String[categories.size()];
for (int i = 0; i < vals.length; i++) { for (int i = 0; i < vals.length; i++) {
vals[i] = categories.get(i).getTranslation(); vals[i] = categories.get(i).getTranslation();

View file

@ -167,7 +167,7 @@ public class PoiUIFilter implements SearchPoiTypeFilter {
} }
private void initSearchAll(){ private void initSearchAll(){
for(PoiCategory t : poiTypes.getCategories()){ for(PoiCategory t : poiTypes.getCategories(false)){
acceptedTypes.put(t, null); acceptedTypes.put(t, null);
} }
distanceToSearchValues = new double[] {0.5, 1, 2, 5, 10, 20, 50, 100}; distanceToSearchValues = new double[] {0.5, 1, 2, 5, 10, 20, 50, 100};
@ -436,7 +436,7 @@ public class PoiUIFilter implements SearchPoiTypeFilter {
} }
public boolean areAllTypesAccepted(){ public boolean areAllTypesAccepted(){
if(poiTypes.getCategories().size() == acceptedTypes.size()){ if(poiTypes.getCategories(false).size() == acceptedTypes.size()){
for(PoiCategory a : acceptedTypes.keySet()){ for(PoiCategory a : acceptedTypes.keySet()){
if(acceptedTypes.get(a) != null){ if(acceptedTypes.get(a) != null){
return false; return false;
@ -449,9 +449,7 @@ public class PoiUIFilter implements SearchPoiTypeFilter {
public void updateTypesToAccept(AbstractPoiType pt) { public void updateTypesToAccept(AbstractPoiType pt) {
acceptedTypes.clear();
pt.putTypes(acceptedTypes); pt.putTypes(acceptedTypes);
poiAdditionals.clear();
if (pt instanceof PoiType && ((PoiType) pt).isAdditional() && ((PoiType) pt).getParentType() != null) { if (pt instanceof PoiType && ((PoiType) pt).isAdditional() && ((PoiType) pt).getParentType() != null) {
fillPoiAdditionals(((PoiType) pt).getParentType()); fillPoiAdditionals(((PoiType) pt).getParentType());
} else { } else {
@ -488,7 +486,7 @@ public class PoiUIFilter implements SearchPoiTypeFilter {
} }
} }
public void updateTypesToAccept(PoiUIFilter f) { public void replaceWithPoiFilter(PoiUIFilter f) {
acceptedTypes.clear(); acceptedTypes.clear();
acceptedTypes.putAll(f.acceptedTypes); acceptedTypes.putAll(f.acceptedTypes);
poiAdditionals.clear(); poiAdditionals.clear();