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

Tactile pavings quest #303

Merged
merged 3 commits into from
Jun 7, 2017
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,5 @@ public enum QuestStatus
/** user chose to hide the quest */
HIDDEN,
/** the system (decided that it) doesn't show the quest. They may become visible again (-> NEW) */
INVISIBLE;
INVISIBLE
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
import de.westnordost.streetcomplete.quests.bike_parking_capacity.AddBikeParkingCapacity;
import de.westnordost.streetcomplete.quests.building_levels.AddBuildingLevels;
import de.westnordost.streetcomplete.quests.bus_stop_shelter.AddBusStopShelter;
import de.westnordost.streetcomplete.quests.tactile_paving.AddTactilePavingBusStop;
import de.westnordost.streetcomplete.quests.tactile_paving.AddTactilePavingCrosswalk;
import de.westnordost.streetcomplete.quests.toilets_fee.AddToiletsFee;
import de.westnordost.streetcomplete.quests.housenumber.AddHousenumber;
import de.westnordost.streetcomplete.quests.opening_hours.AddOpeningHours;
Expand All @@ -36,7 +38,9 @@ public class QuestModule
new AddToiletsFee(o),
new AddHousenumber(o),
new AddBikeParkingCapacity(o),
new AddSport(o)
new AddSport(o),
new AddTactilePavingBusStop(o),
new AddTactilePavingCrosswalk(o)
};

return new QuestTypes(Arrays.asList(questTypes));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,10 +83,9 @@ public class AddHousenumber implements OsmElementQuestType
handler.handle(element, geometry);
}
});
if(!success) return false;

return true;
}
return success;
}

@Override public void applyAnswerTo(Bundle answer, StringMapChangesBuilder changes)
{
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
package de.westnordost.streetcomplete.quests.tactile_paving;

import android.os.Bundle;

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

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

@Override
protected String getTagFilters()
{
return "nodes with (public_transport=platform or (highway=bus_stop and public_transport!=stop_position)) and !tactile_paving";
}

@Override
public int importance()
{
return QuestImportance.MINOR;
}

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

public void applyAnswerTo(Bundle answer, StringMapChangesBuilder changes)
{
String yesno = answer.getBoolean(YesNoQuestAnswerFragment.ANSWER) ? "yes" : "no";
changes.add("tactile_paving", yesno);
}

@Override public String getCommitMessage()
{
return "Add tactile pavings on bus stops";
}

@Override public String getIconName() {
return "bus_stop";
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
package de.westnordost.streetcomplete.quests.tactile_paving;

import android.os.Bundle;

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

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

@Override
protected String getTagFilters()
{
return "nodes with highway=crossing and !tactile_paving";
}

@Override
public int importance()
{
return QuestImportance.MINOR;
}

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

public void applyAnswerTo(Bundle answer, StringMapChangesBuilder changes)
{
String yesno = answer.getBoolean(YesNoQuestAnswerFragment.ANSWER) ? "yes" : "no";
changes.add("tactile_paving", yesno);
}

@Override public String getCommitMessage()
{
return "Add tactile pavings on crosswalks";
}

@Override public String getIconName() {
return "pedestrian_crossing";
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
package de.westnordost.streetcomplete.quests.tactile_paving;

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

import de.westnordost.osmapi.map.data.OsmElement;
import de.westnordost.streetcomplete.R;
import de.westnordost.streetcomplete.quests.YesNoQuestAnswerFragment;

public class TactilePavingBusStopForm extends YesNoQuestAnswerFragment
{
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
{
View view = super.onCreateView(inflater, container, savedInstanceState);
setContentView(R.layout.quest_tactile_paving);
setTitle();
return view;
}

private void setTitle()
{
OsmElement element = getOsmElement();
String name = element != null && element.getTags() != null ? element.getTags().get("name") : null;
if(name != null && !name.trim().isEmpty())
{
setTitle(getResources().getString(R.string.quest_tactilePaving_title_name_bus, name));
}
else
{
setTitle(R.string.quest_tactilePaving_title_bus);
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package de.westnordost.streetcomplete.quests.tactile_paving;

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

import de.westnordost.osmapi.map.data.OsmElement;
import de.westnordost.streetcomplete.R;
import de.westnordost.streetcomplete.quests.YesNoQuestAnswerFragment;

public class TactilePavingCrosswalkForm extends YesNoQuestAnswerFragment
{
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
{
View view = super.onCreateView(inflater, container, savedInstanceState);
setContentView(R.layout.quest_tactile_paving);
setTitle(R.string.quest_tactilePaving_title_crosswalk);
return view;
}
}
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
16 changes: 16 additions & 0 deletions app/src/main/res/layout/quest_tactile_paving.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="bottom">

<ImageView
android:id="@+id/tactilePavingImage"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:adjustViewBounds="true"
android:cropToPadding="false"
android:src="@drawable/tactile_paving_illustration" />

</RelativeLayout>
3 changes: 3 additions & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -266,4 +266,7 @@ The info you enter is then directly added to the OpenStreetMap in your name, wit
<string name="quest_leave_new_note_in_response_to">"In reply to \"%1$s\":
%2$s"</string>
<string name="quest_toiletsFee_title">"Do these toilets require a fee?"</string>
<string name="quest_tactilePaving_title_bus">"Does this bus stop have tactile pavings?"</string>
<string name="quest_tactilePaving_title_crosswalk">"Does this crosswalk have tactile pavings?"</string>
<string name="quest_tactilePaving_title_name_bus">"Does the bus stop \"%s\" have tactile pavings?"</string>
</resources>