Skip to content

Commit

Permalink
new quest: wayside shrine, fixes streetcomplete#799
Browse files Browse the repository at this point in the history
  • Loading branch information
matkoniecz committed Jan 27, 2018
1 parent a6791cd commit 5e703a4
Show file tree
Hide file tree
Showing 6 changed files with 154 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ public class CountryInfo implements Serializable, Cloneable
List<String> speedUnit;
List<String> popularSports;
List<String> popularReligions;
List<String> popularReligionsForWaysideShrines;
String firstDayOfWorkweek;
Integer regularShoppingDays;
String additionalValidHousenumberRegex;
Expand Down Expand Up @@ -50,6 +51,12 @@ public List<String> getPopularReligions()
return Collections.unmodifiableList(popularReligions);
}

public List<String> getPopularReligionsForWaysideShrines()
{
if(popularReligionsForWaysideShrines == null) return new ArrayList<>(1);
return Collections.unmodifiableList(popularReligionsForWaysideShrines);
}

public String getFirstDayOfWorkweek()
{
return firstDayOfWorkweek;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
import de.westnordost.streetcomplete.quests.orchard_produce.AddOrchardProduce;
import de.westnordost.streetcomplete.quests.recycling.AddRecyclingType;
import de.westnordost.streetcomplete.quests.religion.AddReligionToPlaceOfWorship;
import de.westnordost.streetcomplete.quests.religion.AddReligionToWaysideShrine;
import de.westnordost.streetcomplete.quests.road_name.data.PutRoadNameSuggestionsHandler;
import de.westnordost.streetcomplete.quests.road_name.data.RoadNameSuggestionsDao;
import de.westnordost.streetcomplete.quests.tactile_paving.AddTactilePavingBusStop;
Expand Down Expand Up @@ -92,6 +93,7 @@ public class QuestModule
new AddWheelchairAccessBusiness(o),
new AddToiletAvailability(o),
new AddWheelChairAccessToilets(o),
new AddReligionToWaysideShrine(o),

// ↓ 8. defined in the wiki, but not really used by anyone yet. Just collected for
// the sake of mapping it in case it makes sense later
Expand Down
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;
}
}
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);
}
}
1 change: 1 addition & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -470,4 +470,5 @@ Otherwise, you can download another keyboard in the app store. Popular keyboards
<string name="quest_religion_bahai">Bahá\'í Faith</string>
<string name="quest_religion_caodaist">Caodaism</string>
<string name="quest_religion_confucian">Confucianism</string>
<string name="quest_religion_for_wayside_shrine_title">What religion is represented at this shrine?</string>
</resources>
10 changes: 10 additions & 0 deletions res/country_metadata/popularReligionsForWaysideShrines.yml
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]

0 comments on commit 5e703a4

Please sign in to comment.