forked from streetcomplete/StreetComplete
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ask about detailing surface=paved/unpaved
fixes streetcomplete#279
- Loading branch information
1 parent
f5484d8
commit 7c5dcc1
Showing
9 changed files
with
259 additions
and
103 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
114 changes: 24 additions & 90 deletions
114
app/src/main/java/de/westnordost/streetcomplete/quests/road_surface/AddRoadSurfaceForm.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,97 +1,31 @@ | ||
package de.westnordost.streetcomplete.quests.road_surface; | ||
|
||
import android.os.Bundle; | ||
import android.support.v7.widget.RecyclerView; | ||
import android.view.LayoutInflater; | ||
import android.view.View; | ||
import android.view.ViewGroup; | ||
|
||
import java.util.Arrays; | ||
|
||
import de.westnordost.streetcomplete.R; | ||
import de.westnordost.streetcomplete.quests.AbstractQuestFormAnswerFragment; | ||
import de.westnordost.streetcomplete.view.GroupedImageSelectAdapter; | ||
|
||
public class AddRoadSurfaceForm extends AbstractQuestFormAnswerFragment | ||
{ | ||
public static final String SURFACE = "surface"; | ||
|
||
private final Surface[] SURFACES = new Surface[] { | ||
new Surface("paved", R.drawable.panorama_surface_paved, R.string.quest_surface_value_paved, new Surface[]{ | ||
new Surface("asphalt", R.drawable.surface_asphalt, R.string.quest_surface_value_asphalt), | ||
new Surface("concrete", R.drawable.surface_concrete, R.string.quest_surface_value_concrete), | ||
new Surface("sett", R.drawable.surface_sett, R.string.quest_surface_value_sett), | ||
new Surface("paving_stones", R.drawable.surface_paving_stones, R.string.quest_surface_value_paving_stones), | ||
new Surface("cobblestone", R.drawable.surface_cobblestone, R.string.quest_surface_value_cobblestone), | ||
new Surface("wood", R.drawable.surface_wood, R.string.quest_surface_value_wood), | ||
}), | ||
new Surface("unpaved", R.drawable.panorama_surface_unpaved, R.string.quest_surface_value_unpaved, new Surface[]{ | ||
new Surface("compacted", R.drawable.surface_compacted, R.string.quest_surface_value_compacted), | ||
new Surface("gravel", R.drawable.surface_gravel, R.string.quest_surface_value_gravel), | ||
new Surface("fine_gravel", R.drawable.surface_fine_gravel, R.string.quest_surface_value_fine_gravel), | ||
new Surface("pebblestone", R.drawable.surface_pebblestone, R.string.quest_surface_value_pebblestone), | ||
new Surface("grass_paver", R.drawable.surface_grass_paver, R.string.quest_surface_value_grass_paver), | ||
}), | ||
new Surface("ground", R.drawable.panorama_surface_ground, R.string.quest_surface_value_ground, new Surface[]{ | ||
new Surface("dirt", R.drawable.surface_dirt, R.string.quest_surface_value_dirt), | ||
new Surface("grass", R.drawable.surface_grass, R.string.quest_surface_value_grass), | ||
new Surface("sand", R.drawable.surface_sand, R.string.quest_surface_value_sand), | ||
}), | ||
}; | ||
|
||
private GroupedImageSelectAdapter imageSelector; | ||
|
||
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, | ||
Bundle savedInstanceState) | ||
{ | ||
View view = super.onCreateView(inflater, container, savedInstanceState); | ||
|
||
setTitle(R.string.quest_streetSurface_title); | ||
|
||
View contentView = setContentView(R.layout.quest_street_surface); | ||
|
||
RecyclerView surfaceSelect = (RecyclerView) contentView.findViewById(R.id.surfaceSelect); | ||
imageSelector = new GroupedImageSelectAdapter(Arrays.<GroupedImageSelectAdapter.Item>asList(SURFACES)); | ||
surfaceSelect.setAdapter(imageSelector); | ||
surfaceSelect.setNestedScrollingEnabled(false); | ||
|
||
return view; | ||
} | ||
|
||
@Override protected void onClickOk() | ||
public class AddRoadSurfaceForm extends RoadSurfaceForm { | ||
RoadSurfaceForm.Surface[] GetSurfaceMenuStructure() | ||
{ | ||
Bundle answer = new Bundle(); | ||
if(getSelectedSurface() != null) | ||
{ | ||
answer.putString(SURFACE, getSelectedSurface().value); | ||
} | ||
applyFormAnswer(answer); | ||
} | ||
|
||
@Override public boolean hasChanges() | ||
{ | ||
return getSelectedSurface() != null; | ||
} | ||
|
||
private Surface getSelectedSurface() | ||
{ | ||
return (Surface) imageSelector.getSelectedItem(); | ||
} | ||
|
||
private static class Surface extends GroupedImageSelectAdapter.Item | ||
{ | ||
public final String value; | ||
|
||
public Surface(String value, int drawableId, int titleId) | ||
{ | ||
super(drawableId, titleId); | ||
this.value = value; | ||
} | ||
|
||
public Surface(String value, int drawableId, int titleId, GroupedImageSelectAdapter.Item[] items) | ||
{ | ||
super(drawableId, titleId, items); | ||
this.value = value; | ||
} | ||
return new RoadSurfaceForm.Surface[]{ | ||
new RoadSurfaceForm.Surface("paved", R.drawable.panorama_surface_paved, R.string.quest_surface_value_paved, new RoadSurfaceForm.Surface[]{ | ||
new RoadSurfaceForm.Surface("asphalt", R.drawable.surface_asphalt, R.string.quest_surface_value_asphalt), | ||
new RoadSurfaceForm.Surface("concrete", R.drawable.surface_concrete, R.string.quest_surface_value_concrete), | ||
new RoadSurfaceForm.Surface("sett", R.drawable.surface_sett, R.string.quest_surface_value_sett), | ||
new RoadSurfaceForm.Surface("paving_stones", R.drawable.surface_paving_stones, R.string.quest_surface_value_paving_stones), | ||
new RoadSurfaceForm.Surface("cobblestone", R.drawable.surface_cobblestone, R.string.quest_surface_value_cobblestone), | ||
new RoadSurfaceForm.Surface("wood", R.drawable.surface_wood, R.string.quest_surface_value_wood), | ||
}), | ||
new RoadSurfaceForm.Surface("unpaved", R.drawable.panorama_surface_unpaved, R.string.quest_surface_value_unpaved, new RoadSurfaceForm.Surface[]{ | ||
new RoadSurfaceForm.Surface("compacted", R.drawable.surface_compacted, R.string.quest_surface_value_compacted), | ||
new RoadSurfaceForm.Surface("gravel", R.drawable.surface_gravel, R.string.quest_surface_value_gravel), | ||
new RoadSurfaceForm.Surface("fine_gravel", R.drawable.surface_fine_gravel, R.string.quest_surface_value_fine_gravel), | ||
new RoadSurfaceForm.Surface("pebblestone", R.drawable.surface_pebblestone, R.string.quest_surface_value_pebblestone), | ||
new RoadSurfaceForm.Surface("grass_paver", R.drawable.surface_grass_paver, R.string.quest_surface_value_grass_paver), | ||
}), | ||
new RoadSurfaceForm.Surface("ground", R.drawable.panorama_surface_ground, R.string.quest_surface_value_ground, new RoadSurfaceForm.Surface[]{ | ||
new RoadSurfaceForm.Surface("dirt", R.drawable.surface_dirt, R.string.quest_surface_value_dirt), | ||
new RoadSurfaceForm.Surface("grass", R.drawable.surface_grass, R.string.quest_surface_value_grass), | ||
new RoadSurfaceForm.Surface("sand", R.drawable.surface_sand, R.string.quest_surface_value_sand), | ||
}), | ||
}; | ||
} | ||
} |
52 changes: 52 additions & 0 deletions
52
...c/main/java/de/westnordost/streetcomplete/quests/road_surface/DetailPavedRoadSurface.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
package de.westnordost.streetcomplete.quests.road_surface; | ||
|
||
import android.os.Bundle; | ||
import android.text.TextUtils; | ||
|
||
import javax.inject.Inject; | ||
|
||
import de.westnordost.streetcomplete.data.QuestImportance; | ||
import de.westnordost.streetcomplete.data.osm.SimpleOverpassQuestType; | ||
import de.westnordost.streetcomplete.data.osm.changes.StringMapChangesBuilder; | ||
import de.westnordost.streetcomplete.data.osm.download.OverpassMapDataDao; | ||
import de.westnordost.streetcomplete.quests.AbstractQuestAnswerFragment; | ||
|
||
public class DetailPavedRoadSurface extends SimpleOverpassQuestType { | ||
@Inject public DetailPavedRoadSurface(OverpassMapDataDao overpassServer) | ||
{ | ||
super(overpassServer); | ||
} | ||
|
||
@Override | ||
protected String getTagFilters() | ||
{ | ||
return " ways with ( highway ~ " + TextUtils.join("|", RoadSurfaceConfig.ROADS_WITH_SURFACES) + " and" + | ||
" surface=paved)"; | ||
} | ||
|
||
@Override | ||
public int importance() | ||
{ | ||
return QuestImportance.MINOR; | ||
} | ||
|
||
public AbstractQuestAnswerFragment createForm() | ||
{ | ||
return new DetailPavedRoadSurfaceForm(); | ||
} | ||
|
||
public void applyAnswerTo(Bundle answer, StringMapChangesBuilder changes) | ||
{ | ||
changes.modify("surface", answer.getString(DetailPavedRoadSurfaceForm.SURFACE)); | ||
} | ||
|
||
@Override public String getCommitMessage() | ||
{ | ||
return "Detail road surfaces"; | ||
} | ||
|
||
@Override public String getIconName() | ||
{ | ||
return "street_surface"; | ||
} | ||
} |
17 changes: 17 additions & 0 deletions
17
...in/java/de/westnordost/streetcomplete/quests/road_surface/DetailPavedRoadSurfaceForm.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
package de.westnordost.streetcomplete.quests.road_surface; | ||
|
||
import de.westnordost.streetcomplete.R; | ||
|
||
public class DetailPavedRoadSurfaceForm extends RoadSurfaceForm { | ||
RoadSurfaceForm.Surface[] GetSurfaceMenuStructure() | ||
{ | ||
return new RoadSurfaceForm.Surface[]{ | ||
new RoadSurfaceForm.Surface("asphalt", R.drawable.surface_asphalt, R.string.quest_surface_value_asphalt), | ||
new RoadSurfaceForm.Surface("concrete", R.drawable.surface_concrete, R.string.quest_surface_value_concrete), | ||
new RoadSurfaceForm.Surface("sett", R.drawable.surface_sett, R.string.quest_surface_value_sett), | ||
new RoadSurfaceForm.Surface("paving_stones", R.drawable.surface_paving_stones, R.string.quest_surface_value_paving_stones), | ||
new RoadSurfaceForm.Surface("cobblestone", R.drawable.surface_cobblestone, R.string.quest_surface_value_cobblestone), | ||
new RoadSurfaceForm.Surface("wood", R.drawable.surface_wood, R.string.quest_surface_value_wood), | ||
}; | ||
} | ||
} |
53 changes: 53 additions & 0 deletions
53
...main/java/de/westnordost/streetcomplete/quests/road_surface/DetailUnpavedRoadSurface.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
package de.westnordost.streetcomplete.quests.road_surface; | ||
|
||
import android.os.Bundle; | ||
import android.text.TextUtils; | ||
|
||
import javax.inject.Inject; | ||
|
||
import de.westnordost.streetcomplete.data.QuestImportance; | ||
import de.westnordost.streetcomplete.data.osm.SimpleOverpassQuestType; | ||
import de.westnordost.streetcomplete.data.osm.changes.StringMapChangesBuilder; | ||
import de.westnordost.streetcomplete.data.osm.download.OverpassMapDataDao; | ||
import de.westnordost.streetcomplete.quests.AbstractQuestAnswerFragment; | ||
|
||
public class DetailUnpavedRoadSurface extends SimpleOverpassQuestType { | ||
@Inject public DetailUnpavedRoadSurface(OverpassMapDataDao overpassServer) | ||
{ | ||
super(overpassServer); | ||
} | ||
|
||
@Override | ||
protected String getTagFilters() | ||
{ | ||
return " ways with ( highway ~ " + TextUtils.join("|", RoadSurfaceConfig.ROADS_WITH_SURFACES) + " and" + | ||
" surface=unpaved)"; | ||
} | ||
|
||
@Override | ||
public int importance() | ||
{ | ||
return QuestImportance.MINOR; | ||
} | ||
|
||
public AbstractQuestAnswerFragment createForm() | ||
{ | ||
return new DetailUnpavedRoadSurfaceForm(); | ||
} | ||
|
||
public void applyAnswerTo(Bundle answer, StringMapChangesBuilder changes) | ||
{ | ||
changes.modify("surface", answer.getString(DetailUnpavedRoadSurfaceForm.SURFACE)); | ||
} | ||
|
||
@Override | ||
public String getCommitMessage() | ||
{ | ||
return "Detail road surfaces"; | ||
} | ||
|
||
@Override | ||
public String getIconName() { | ||
return "street_surface"; | ||
} | ||
} |
19 changes: 19 additions & 0 deletions
19
.../java/de/westnordost/streetcomplete/quests/road_surface/DetailUnpavedRoadSurfaceForm.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
package de.westnordost.streetcomplete.quests.road_surface; | ||
|
||
import de.westnordost.streetcomplete.R; | ||
|
||
public class DetailUnpavedRoadSurfaceForm extends RoadSurfaceForm { | ||
Surface[] GetSurfaceMenuStructure() | ||
{ | ||
return new Surface[]{ | ||
new RoadSurfaceForm.Surface("compacted", R.drawable.surface_compacted, R.string.quest_surface_value_compacted), | ||
new RoadSurfaceForm.Surface("gravel", R.drawable.surface_gravel, R.string.quest_surface_value_gravel), | ||
new RoadSurfaceForm.Surface("fine_gravel", R.drawable.surface_fine_gravel, R.string.quest_surface_value_fine_gravel), | ||
new RoadSurfaceForm.Surface("pebblestone", R.drawable.surface_pebblestone, R.string.quest_surface_value_pebblestone), | ||
new RoadSurfaceForm.Surface("grass_paver", R.drawable.surface_grass_paver, R.string.quest_surface_value_grass_paver), | ||
new RoadSurfaceForm.Surface("dirt", R.drawable.surface_dirt, R.string.quest_surface_value_dirt), | ||
new RoadSurfaceForm.Surface("grass", R.drawable.surface_grass, R.string.quest_surface_value_grass), | ||
new RoadSurfaceForm.Surface("sand", R.drawable.surface_sand, R.string.quest_surface_value_sand), | ||
}; | ||
} | ||
} |
13 changes: 13 additions & 0 deletions
13
app/src/main/java/de/westnordost/streetcomplete/quests/road_surface/RoadSurfaceConfig.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
package de.westnordost.streetcomplete.quests.road_surface; | ||
|
||
public class RoadSurfaceConfig { | ||
// well, all roads have surfaces, what I mean is that not all ways with highway key are | ||
// "something with a surface" | ||
static final String[] ROADS_WITH_SURFACES = { | ||
// "trunk","trunk_link","motorway","motorway_link", // too much, motorways are almost by definition asphalt (or concrete) | ||
"primary", "primary_link", "secondary", "secondary_link", "tertiary", "tertiary_link", | ||
"unclassified", "residential", "bicycle_road", "living_street", "pedestrian", | ||
"track", "road", | ||
/*"service", */ // this is too much, and the information value is very low | ||
}; | ||
} |
Oops, something went wrong.