Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement bench backrest quest #830

Merged
merged 4 commits into from
Feb 6, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@
import de.westnordost.streetcomplete.quests.wheelchair_access.AddWheelChairAccessPublicTransport;
import de.westnordost.streetcomplete.quests.wheelchair_access.AddWheelChairAccessToilets;
import de.westnordost.streetcomplete.quests.wheelchair_access.AddWheelchairAccessBusiness;
import de.westnordost.streetcomplete.quests.bench_backrest.AddBenchBackrest;

@Module
public class QuestModule
Expand Down Expand Up @@ -108,6 +109,7 @@ public class QuestModule
new AddParkingType(o),
new AddPowerPolesMaterial(o),
new AddCarWashType(o),
new AddBenchBackrest(o),
};

return new QuestTypeRegistry(Arrays.asList(questTypesOrderedByImportance));
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
/*
* This quest was generated by the StreetComplete QuestCreator (https://github.com/ENT8R/StreetCompleteQuestCreator)
*/

package de.westnordost.streetcomplete.quests.bench_backrest;

import android.os.Bundle;

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;
import de.westnordost.streetcomplete.quests.YesNoQuestAnswerFragment;

public class AddBenchBackrest extends SimpleOverpassQuestType
{
@Inject public AddBenchBackrest(OverpassMapDataDao overpassServer) { super(overpassServer); }

@Override protected String getTagFilters() { return "nodes with amenity=bench and !backrest"; }

public AbstractQuestAnswerFragment createForm() { return new AddBenchBackrestForm(); }

public void applyAnswerTo(Bundle answer, StringMapChangesBuilder changes)
{
boolean isPicnicTable = answer.getBoolean(AddBenchBackrestForm.PICNIC_TABLE);

if (isPicnicTable)
{
changes.add("leisure", "picnic_table");
changes.delete("amenity");
} else {
String yesno = answer.getBoolean(YesNoQuestAnswerFragment.ANSWER) ? "yes" : "no";
changes.add("backrest", yesno);
}
}

@Override public String getCommitMessage() { return "Add backrest information to benches"; }
@Override public int getIcon() { return R.drawable.ic_quest_bench; }
@Override public int getTitle(Map<String, String> tags) { return R.string.quest_bench_backrest_title; }
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
package de.westnordost.streetcomplete.quests.bench_backrest;

import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import de.westnordost.streetcomplete.R;
import de.westnordost.streetcomplete.quests.YesNoQuestAnswerFragment;

public class AddBenchBackrestForm extends YesNoQuestAnswerFragment {
public static final String PICNIC_TABLE = "picnic_table";

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
{
View view = super.onCreateView(inflater, container, savedInstanceState);
addOtherAnswers();
return view;
}

private void addOtherAnswers()
{
addOtherAnswer(R.string.quest_bench_answer_picnic_table, () -> {
Bundle answer = new Bundle();
answer.putBoolean(PICNIC_TABLE, true);
applyImmediateAnswer(answer);
});
}
}

2 changes: 2 additions & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -463,6 +463,8 @@ Otherwise, you can download another keyboard in the app store. Popular keyboards
<string name="quest_internet_access_no">No connection</string>
<string name="quest_busStopShelter_tram_name_title">"Does the tram stop \"%s\" have a shelter?"</string>
<string name="quest_busStopShelter_tram_title">"Does this tram stop have a shelter?"</string>
<string name="quest_bench_backrest_title">Does this bench have a backrest?</string>
<string name="quest_bench_answer_picnic_table">It\'s a picnic table</string>
<string name="quest_religion_for_place_of_worship_title">What religion is practised at “%s”?</string>
<string name="quest_religion_christian">Christianity</string>
<string name="quest_religion_muslim">Islam</string>
Expand Down