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.
new quest: wayside shrine, fixes streetcomplete#799
- Loading branch information
1 parent
4f779eb
commit 7a36468
Showing
6 changed files
with
154 additions
and
0 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
50 changes: 50 additions & 0 deletions
50
...c/main/java/de/westnordost/streetcomplete/quests/religion/AddReligionToWaysideShrine.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,50 @@ | ||
package de.westnordost.streetcomplete.quests.religion; | ||
|
||
import android.os.Bundle; | ||
import android.text.TextUtils; | ||
|
||
import java.util.ArrayList; | ||
import java.util.Map; | ||
|
||
import javax.inject.Inject; | ||
|
||
import de.westnordost.streetcomplete.R; | ||
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 AddReligionToWaysideShrine extends SimpleOverpassQuestType | ||
{ | ||
@Inject public AddReligionToWaysideShrine(OverpassMapDataDao overpassServer) { super(overpassServer); } | ||
|
||
@Override | ||
protected String getTagFilters() | ||
{ | ||
return "nodes, ways, relations with historic=wayside_shrine and" + | ||
" !religion and" + | ||
" (access !~ private|no)"; // exclude ones without access to general public | ||
} | ||
|
||
public AbstractQuestAnswerFragment createForm() | ||
{ | ||
return new AddReligionToWaysideShrineForm(); | ||
} | ||
|
||
public void applyAnswerTo(Bundle answer, StringMapChangesBuilder changes) | ||
{ | ||
ArrayList<String> values = answer.getStringArrayList(AddReligionToWaysideShrineForm.OSM_VALUES); | ||
if(values != null && !values.isEmpty()) | ||
{ | ||
String religionValueStr = values.get(0); | ||
changes.add("religion", religionValueStr); | ||
} | ||
} | ||
|
||
@Override public String getCommitMessage() { return "Add religion for historic=wayside_shrine"; } | ||
@Override public int getIcon() { return R.drawable.ic_quest_religion; } | ||
@Override public int getTitle(Map<String,String> tags) | ||
{ | ||
return R.string.quest_religion_for_wayside_shrine_title; | ||
} | ||
} |
84 changes: 84 additions & 0 deletions
84
...in/java/de/westnordost/streetcomplete/quests/religion/AddReligionToWaysideShrineForm.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,84 @@ | ||
package de.westnordost.streetcomplete.quests.religion; | ||
|
||
import android.os.Bundle; | ||
import android.view.LayoutInflater; | ||
import android.view.View; | ||
import android.view.ViewGroup; | ||
|
||
import java.util.ArrayList; | ||
import java.util.Arrays; | ||
import java.util.List; | ||
|
||
import de.westnordost.streetcomplete.R; | ||
import de.westnordost.streetcomplete.quests.ImageListQuestAnswerFragment; | ||
import de.westnordost.streetcomplete.quests.PriorityList; | ||
import de.westnordost.streetcomplete.view.Item; | ||
|
||
public class AddReligionToWaysideShrineForm extends ImageListQuestAnswerFragment | ||
{ | ||
private static final int INITIALLY_DISPLAYED_ITEMS = 8; | ||
|
||
private static final Item[] ALL_RELIGION_VALUES = new Item[]{ | ||
// worldwide usage, values covering vast majority of used tags | ||
new Item("christian", R.drawable.ic_religion_christian, R.string.quest_religion_christian), | ||
new Item("shinto", R.drawable.ic_religion_shinto, R.string.quest_religion_shinto), | ||
new Item("buddhist", R.drawable.ic_religion_buddhist, R.string.quest_religion_buddhist), | ||
new Item("bahai", R.drawable.ic_religion_bahai, R.string.quest_religion_bahai), | ||
new Item("caodaism", R.drawable.ic_religion_caodaist, R.string.quest_religion_caodaist), | ||
new Item("confucian", R.drawable.ic_religion_confucian, R.string.quest_religion_confucian), | ||
new Item("hindu", R.drawable.ic_religion_hindu, R.string.quest_religion_hindu), | ||
new Item("jain", R.drawable.ic_religion_jain, R.string.quest_religion_jain), | ||
new Item("jewish", R.drawable.ic_religion_jewish, R.string.quest_religion_jewish), | ||
new Item("muslim", R.drawable.ic_religion_muslim, R.string.quest_religion_muslim), | ||
new Item("sikh", R.drawable.ic_religion_sikh, R.string.quest_religion_sikh), | ||
new Item("taoist", R.drawable.ic_religion_taoist, R.string.quest_religion_taoist), | ||
}; | ||
|
||
private Item[] actualReligionsValues; | ||
|
||
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, | ||
Bundle savedInstanceState) | ||
{ | ||
View view = super.onCreateView(inflater, container, savedInstanceState); | ||
actualReligionsValues = createItems(); | ||
imageSelector.setCellLayout(R.layout.cell_icon_select_with_label_below); | ||
|
||
addOtherAnswer(R.string.quest_religion_for_place_of_worship_answer_multi, this::applyMultiAnswer); | ||
|
||
return view; | ||
} | ||
|
||
private Item[] createItems() | ||
{ | ||
List<Item> religionsList = new ArrayList<>(Arrays.asList(ALL_RELIGION_VALUES)); | ||
List<String> popularReligionsNames = getCountryInfo().getPopularReligionsForWaysideShrines(); | ||
|
||
religionsList = PriorityList.BuildList(religionsList, popularReligionsNames); | ||
|
||
return religionsList.toArray(new Item[religionsList.size()]); | ||
} | ||
|
||
@Override protected int getMaxSelectableItems() | ||
{ | ||
return 1; | ||
} | ||
|
||
@Override protected int getMaxNumberOfInitiallyShownItems() | ||
{ | ||
return INITIALLY_DISPLAYED_ITEMS; | ||
} | ||
|
||
@Override protected Item[] getItems() | ||
{ | ||
return actualReligionsValues; | ||
} | ||
|
||
private void applyMultiAnswer() | ||
{ | ||
Bundle answer = new Bundle(); | ||
ArrayList<String> strings = new ArrayList<>(1); | ||
strings.add("multifaith"); | ||
answer.putStringArrayList(OSM_VALUES, strings); | ||
applyImmediateAnswer(answer); | ||
} | ||
} |
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
10 changes: 10 additions & 0 deletions
10
res/country_metadata/popularReligionsForWaysideShrines.yml
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,10 @@ | ||
# religions that should be shown first before the order defined in the form. | ||
# no total order required. Just mention the religions that should show within the first few entries | ||
default: [] | ||
CN: [buddhist] | ||
JP: [shinto, buddhist] | ||
LK: [christian, buddhist] | ||
MM: [buddhist] | ||
MN: [buddhist] | ||
TH: [buddhist] | ||
TW: [taoist] |