Skip to content

Commit

Permalink
Merge pull request #1135 from matkoniecz/segregated
Browse files Browse the repository at this point in the history
Segregated [change layout]
  • Loading branch information
westnordost authored Aug 15, 2018
2 parents 551f015 + 23973aa commit 616e93d
Show file tree
Hide file tree
Showing 9 changed files with 141 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,12 @@ public class OsmTaggings
"ground","earth","dirt","grass","sand","mud","ice","salt","snow","woodchips"
};

public static final String[] ANYTHING_PAVED = {
"paved", "asphalt", "cobblestone", "cobblestone:flattened", "sett",
"concrete", "concrete:lanes", "concrete:plates", "paving_stones",
"metal", "wood", "unhewn_cobblestone"
};

public static final String[] ALL_ROADS = {
"motorway", "motorway_link", "trunk", "trunk_link", "primary", "primary_link",
"secondary", "secondary_link", "tertiary", "tertiary_link",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
import de.westnordost.streetcomplete.quests.religion.AddReligionToWaysideShrine;
import de.westnordost.streetcomplete.quests.localized_name.data.PutRoadNameSuggestionsHandler;
import de.westnordost.streetcomplete.quests.localized_name.data.RoadNameSuggestionsDao;
import de.westnordost.streetcomplete.quests.segregated.AddCyclewaySegregation;
import de.westnordost.streetcomplete.quests.surface.AddPathSurface;
import de.westnordost.streetcomplete.quests.tactile_paving.AddTactilePavingBusStop;
import de.westnordost.streetcomplete.quests.tactile_paving.AddTactilePavingCrosswalk;
Expand Down Expand Up @@ -125,6 +126,7 @@ public class QuestModule
new AddBridgeStructure(o),
new AddWheelChairAccessToilets(o),
new AddReligionToWaysideShrine(o),
new AddCyclewaySegregation(o),
new MarkCompletedBuildingConstruction(o),

// ↓ 8. defined in the wiki, but not really used by anyone yet. Just collected for
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
package de.westnordost.streetcomplete.quests.segregated;

import android.os.Bundle;
import android.support.annotation.NonNull;
import android.text.TextUtils;

import java.util.List;
import java.util.Map;

import javax.inject.Inject;

import de.westnordost.streetcomplete.R;
import de.westnordost.streetcomplete.data.meta.OsmTaggings;
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 AddCyclewaySegregation extends SimpleOverpassQuestType {

@Inject
public AddCyclewaySegregation(OverpassMapDataDao overpassServer) {
super(overpassServer);
}

@Override
protected String getTagFilters() {
return
"ways with " +
"(" +
"(highway = path and bicycle = designated and foot = designated)" +
" or (highway = footway and bicycle = designated)" +
" or (highway = cycleway and foot = designated)" +
")" +
" and surface ~" + TextUtils.join("|", OsmTaggings.ANYTHING_PAVED) +
" and !segregated";
}

@Override
public AbstractQuestAnswerFragment createForm() {
return new AddCyclewaySegregationForm();
}

@Override
public void applyAnswerTo(Bundle answer, StringMapChangesBuilder changes) {
List<String> values = answer.getStringArrayList(AddCyclewaySegregationForm.OSM_VALUES);
if (values != null && values.size() == 1) {
changes.add("segregated", values.get(0));
}
}

@Override
public String getCommitMessage() {
return "Add segregated status for combined footway with cycleway";
}

@Override
public int getIcon() {
return R.drawable.ic_quest_path_segregation;
}

@Override
public int getTitle(@NonNull Map<String, String> tags) {
return R.string.quest_segregated_title;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
package de.westnordost.streetcomplete.quests.segregated;

import android.os.Bundle;
import android.support.annotation.Nullable;
import android.view.View;

import de.westnordost.streetcomplete.R;
import de.westnordost.streetcomplete.quests.ImageListQuestAnswerFragment;
import de.westnordost.streetcomplete.view.Item;

public class AddCyclewaySegregationForm extends ImageListQuestAnswerFragment {
@Override protected Item[] getItems() {
return new Item[]{
new Item("yes", getCountryInfo().isLeftHandTraffic() ?
R.drawable.ic_path_segregated_l : R.drawable.ic_path_segregated, R.string.quest_segregated_separated),
new Item("no", R.drawable.ic_path_segregated_no, R.string.quest_segregated_mixed),
};
}

@Override public void onViewCreated(View view, @Nullable Bundle savedInstanceState)
{
super.onViewCreated(view, savedInstanceState);
imageSelector.setCellLayout(R.layout.cell_labeled_icon_select_right);
}

@Override protected int getItemsPerRow() { return 2; }
}
4 changes: 2 additions & 2 deletions app/src/main/res/drawable/ic_path_segregated.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="128dp"
android:height="128dp"
android:width="64dp"
android:height="64dp"
android:viewportWidth="128"
android:viewportHeight="128">
<path
Expand Down
4 changes: 2 additions & 2 deletions app/src/main/res/drawable/ic_path_segregated_l.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="128dp"
android:height="128dp"
android:width="64dp"
android:height="64dp"
android:viewportWidth="128"
android:viewportHeight="128">
<path
Expand Down
4 changes: 2 additions & 2 deletions app/src/main/res/drawable/ic_path_segregated_no.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="128dp"
android:height="128dp"
android:width="64dp"
android:height="64dp"
android:viewportWidth="128"
android:viewportHeight="128">
<path
Expand Down
31 changes: 31 additions & 0 deletions app/src/main/res/layout/cell_labeled_icon_select_right.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="wrap_content"
tools:layout_width="180dp"
android:padding="6dp"
android:background="@drawable/image_select_cell">

<ImageView
android:id="@+id/imageView"
android:layout_alignParentStart="true"
android:layout_centerVertical="true"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="6dp"
android:scaleType="fitCenter"
tools:src="@drawable/ic_path_segregated_no"
/>

<TextView
android:id="@+id/textView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_toEndOf="@id/imageView"
android:layout_centerVertical="true"
style="@style/ImageSelectDescription"
tools:text="@string/quest_segregated_mixed" />

</RelativeLayout>
4 changes: 3 additions & 1 deletion app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -613,8 +613,10 @@ Otherwise, you can download another keyboard in the app store. Popular keyboards

<string name="notification_channel_download">"Download"</string>
<string name="quest_playground_access_title">Is this playground publicly accessible?</string>
<string name="quest_segregated_title">How are the footway and cycleway laid out here?</string>
<string name="dialog_tutorial_upload">To upload your changes manually, use the button in the toolbar that looks like this.</string>

<string name="quest_segregated_separated">Segregated from one another</string>
<string name="quest_segregated_mixed">Cyclists and pedestrians share same space</string>
<string name="quest_maxheight_title">"What is the height limit here?"</string>
<string name="quest_maxheight_parking_entrance_title">What is the height limit of this parking entrance?</string>
<string name="quest_maxheight_height_restrictor_title">What is the height limit of this height restrictor?</string>
Expand Down

0 comments on commit 616e93d

Please sign in to comment.