Skip to content

Commit

Permalink
add motorcycle parking capacity and motorcycle parking covered quest (f…
Browse files Browse the repository at this point in the history
…ixes #1181)
  • Loading branch information
westnordost committed Dec 2, 2018
1 parent 19756b0 commit 29082af
Show file tree
Hide file tree
Showing 15 changed files with 719 additions and 33 deletions.
Expand Up @@ -30,6 +30,8 @@
import de.westnordost.streetcomplete.quests.fire_hydrant.AddFireHydrantType;
import de.westnordost.streetcomplete.quests.internet_access.AddInternetAccess;
import de.westnordost.streetcomplete.quests.max_height.AddMaxHeight;
import de.westnordost.streetcomplete.quests.motorcycle_parking_capacity.AddMotorcycleParkingCapacity;
import de.westnordost.streetcomplete.quests.motorcycle_parking_cover.AddMotorcycleParkingCover;
import de.westnordost.streetcomplete.quests.oneway.AddOneway;
import de.westnordost.streetcomplete.quests.oneway.TrafficFlowSegmentsDao;
import de.westnordost.streetcomplete.quests.oneway.WayTrafficFlowDao;
Expand Down Expand Up @@ -111,6 +113,7 @@ public class QuestModule
new AddInternetAccess(o),
new AddParkingAccess(o),
new AddParkingFee(o),
new AddMotorcycleParkingCapacity(o),
new AddBusStopName(o),
new AddPathSurface(o),
new AddTracktype(o),
Expand Down Expand Up @@ -143,6 +146,7 @@ public class QuestModule
// ↓ 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
new AddBikeParkingCover(o),
new AddMotorcycleParkingCover(o),
new AddToiletsFee(o),
new AddBabyChangingTable(o),
new AddFireHydrantType(o),
Expand Down
@@ -0,0 +1,35 @@
package de.westnordost.streetcomplete.quests;

import android.os.Bundle;
import android.support.annotation.Nullable;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.EditText;

import de.westnordost.streetcomplete.R;
import de.westnordost.streetcomplete.util.TextChangedWatcher;

public abstract class TextInputQuestAnswerFragment extends AbstractQuestFormAnswerFragment
{
public static final String INPUT = "input";

@Override public void onViewCreated(View view, @Nullable Bundle savedInstanceState)
{
super.onViewCreated(view, savedInstanceState);
getEditText().addTextChangedListener(new TextChangedWatcher(this::checkIsFormComplete));
}

@Override protected void onClickOk()
{
Bundle answer = new Bundle();
answer.putString(INPUT, getInputString());
applyAnswer(answer);
}

@Override public boolean isFormComplete() { return !getInputString().isEmpty(); }

private String getInputString() { return getEditText().getText().toString(); }

protected abstract EditText getEditText();
}
Expand Up @@ -22,7 +22,7 @@ public class AddBikeParkingCapacity extends SimpleOverpassQuestType

@Override protected String getTagFilters()
{
return "nodes, ways with amenity=bicycle_parking and !capacity and (access !~ private|no)";
return "nodes, ways with amenity=bicycle_parking and !capacity and access !~ private|no";
}

public AbstractQuestAnswerFragment createForm()
Expand All @@ -32,7 +32,7 @@ public AbstractQuestAnswerFragment createForm()

public void applyAnswerTo(Bundle answer, StringMapChangesBuilder changes)
{
changes.add("capacity", ""+answer.getInt(AddBikeParkingCapacityForm.BIKE_PARKING_CAPACITY));
changes.add("capacity", ""+Integer.parseInt(answer.getString(AddBikeParkingCapacityForm.INPUT)));
}

@Override public String getCommitMessage() { return "Add bicycle parking capacities"; }
Expand Down
Expand Up @@ -8,34 +8,21 @@

import de.westnordost.streetcomplete.R;
import de.westnordost.streetcomplete.quests.AbstractQuestFormAnswerFragment;
import de.westnordost.streetcomplete.quests.TextInputQuestAnswerFragment;
import de.westnordost.streetcomplete.util.TextChangedWatcher;

public class AddBikeParkingCapacityForm extends AbstractQuestFormAnswerFragment
public class AddBikeParkingCapacityForm extends TextInputQuestAnswerFragment
{
public static final String BIKE_PARKING_CAPACITY = "bike_parking_capacity";

private EditText capacityInput;

@Override public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState)
{
View view = super.onCreateView(inflater, container, savedInstanceState);
View contentView = setContentView(R.layout.quest_bike_parking_capacity);

capacityInput = contentView.findViewById(R.id.capacityInput);
capacityInput.addTextChangedListener(new TextChangedWatcher(this::checkIsFormComplete));

setContentView(R.layout.quest_bike_parking_capacity);
return view;
}

@Override protected void onClickOk()
@Override protected EditText getEditText()
{
Bundle answer = new Bundle();
answer.putInt(BIKE_PARKING_CAPACITY, Integer.parseInt(getBikeCapacity()));
applyAnswer(answer);
return getView().findViewById(R.id.capacityInput);
}

@Override public boolean isFormComplete() { return !getBikeCapacity().isEmpty(); }

private String getBikeCapacity() { return capacityInput.getText().toString(); }
}
Expand Up @@ -20,7 +20,7 @@ public class AddBikeParkingCover extends SimpleOverpassQuestType

@Override protected String getTagFilters()
{
return "nodes, ways with amenity=bicycle_parking and access!=private and !covered and bicycle_parking !~ shed|lockers|building";
return "nodes, ways with amenity=bicycle_parking and access !~ private|no and !covered and bicycle_parking !~ shed|lockers|building";
}

public AbstractQuestAnswerFragment createForm() { return new YesNoQuestAnswerFragment(); }
Expand All @@ -37,4 +37,4 @@ public void applyAnswerTo(Bundle answer, StringMapChangesBuilder changes)
{
return R.string.quest_bicycleParkingCoveredStatus_title;
}
}
}
@@ -0,0 +1,45 @@
package de.westnordost.streetcomplete.quests.motorcycle_parking_capacity;

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

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.bike_parking_capacity.AddBikeParkingCapacityForm;

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

@Override protected String getTagFilters()
{
return "nodes, ways with amenity=motorcycle_parking and !capacity and access !~ private|no";
}

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

public void applyAnswerTo(Bundle answer, StringMapChangesBuilder changes)
{
changes.add("capacity", ""+Integer.parseInt(answer.getString(AddMotorcycleParkingCapacityForm.INPUT)));
}

@Override public String getCommitMessage() { return "Add motorcycle parking capacities"; }
@Override public int getIcon() { return R.drawable.ic_quest_motorcycle_parking_capacity; }
@Override public int getTitle(@NonNull Map<String, String> tags)
{
return R.string.quest_motorcycleParkingCapacity_title;
}
}
@@ -0,0 +1,26 @@
package de.westnordost.streetcomplete.quests.motorcycle_parking_capacity;

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

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

public class AddMotorcycleParkingCapacityForm extends TextInputQuestAnswerFragment
{
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState)
{
View view = super.onCreateView(inflater, container, savedInstanceState);
setContentView(R.layout.quest_motorcycle_parking_capacity);
return view;
}

@Override protected EditText getEditText()
{
return getView().findViewById(R.id.capacityInput);
}
}
@@ -0,0 +1,40 @@
package de.westnordost.streetcomplete.quests.motorcycle_parking_cover;

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

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 AddMotorcycleParkingCover extends SimpleOverpassQuestType
{
@Inject public AddMotorcycleParkingCover(OverpassMapDataDao overpassServer) { super(overpassServer); }

@Override protected String getTagFilters()
{
return "nodes, ways with amenity=motorcycle_parking and access !~ private|no and !covered and motorcycle_parking !~ shed|garage_boxes|building";
}

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

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

@Override public String getCommitMessage() { return "Add motorcycle parkings cover"; }
@Override public int getIcon() { return R.drawable.ic_quest_motorcycle_parking_cover; }
@Override public int getTitle(@NonNull Map<String,String> tags)
{
return R.string.quest_motorcycleParkingCoveredStatus_title;
}
}
105 changes: 105 additions & 0 deletions app/src/main/res/drawable/ic_motorcycle.xml
@@ -0,0 +1,105 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="92dp"
android:height="62dp"
android:viewportWidth="101"
android:viewportHeight="68">
<path
android:pathData="m54.08,4a3,3 0,1 0,0 6h9.986l3.275,8.008c-1.504,-0.137 -3.314,0.144 -5.4,0.887 -5.537,2.625 -11.347,6.622 -12.686,12.106h-5.479c-3.48,-3.68 -7.596,-5.88 -11.758,-6.908 -4.732,-1.169 -9.46,-1.126 -13.971,-1.092a4,4 0,0 0,-3.605 5.756c-0.251,0.095 -0.502,0.19 -0.754,0.295C7.86,31.482 2.265,36.968 0,46.029l5.945,1.486c-0.237,1.125 -0.365,2.291 -0.365,3.484 0,9.348 7.651,17 17,17 8.324,0 15.287,-6.071 16.717,-14h18.783a3,3 0,0 0,2.557 -1.43l3.693,-6.008 3.158,0.789c-0.26,1.177 -0.408,2.396 -0.408,3.648 0,9.348 7.651,17 17,17 9.349,0 17,-7.652 17,-17 0,-6.144 -3.316,-11.54 -8.236,-14.527l3.809,-4.537c-3.459,-2.903 -8.226,-4.048 -13.289,-3.619 -1.631,0.138 -3.292,0.443 -4.951,0.902l-2.391,-5.842c2.827,1.498 6.87,2.447 8.902,2.447v-12c-2.656,0 -8.748,1.834 -11.064,4.267l-5.002,-12.229a3,3 0,0 0,-2.777 -1.863zM22.58,40.801c4.627,0 8.49,3.011 9.758,7.199L22.08,48a3,3 0,1 0,0 6h10.258c-1.269,4.187 -5.131,7.199 -9.758,7.199 -5.674,0 -10.199,-4.526 -10.199,-10.199 0,-5.674 4.526,-10.199 10.199,-10.199zM84.08,40.801c5.674,0 10.199,4.526 10.199,10.199 0,5.673 -4.526,10.199 -10.199,10.199 -5.674,0 -10.199,-4.526 -10.199,-10.199 0,-3.204 1.444,-6.043 3.723,-7.906l3.699,9.043a3.001,3.001 0,1 0,5.555 -2.273l-3.689,-9.017c0.301,-0.026 0.604,-0.045 0.912,-0.045z"
android:strokeAlpha="1"
android:strokeLineJoin="miter"
android:strokeWidth="6.79999971"
android:fillColor="#000000"
android:strokeColor="#00000000"
android:fillType="nonZero"
android:fillAlpha="0.2"
android:strokeLineCap="butt"/>
<path
android:pathData="M84.09,47m-13.6,0a13.6,13.6 0,1 1,27.2 0a13.6,13.6 0,1 1,-27.2 0"
android:strokeAlpha="1"
android:strokeLineJoin="miter"
android:strokeWidth="6.79999971"
android:fillColor="#00000000"
android:strokeColor="#555555"
android:fillAlpha="1"
android:strokeLineCap="butt"/>
<path
android:pathData="M22.59,47m-13.6,0a13.6,13.6 0,1 1,27.2 0a13.6,13.6 0,1 1,-27.2 0"
android:strokeAlpha="1"
android:strokeLineJoin="miter"
android:strokeWidth="6.79999971"
android:fillColor="#00000000"
android:strokeColor="#555555"
android:fillAlpha="1"
android:strokeLineCap="butt"/>
<path
android:pathData="m66.09,43c4,-16 22,-17.036 28,-12"
android:strokeAlpha="1"
android:strokeLineJoin="miter"
android:strokeWidth="8"
android:fillColor="#00000000"
android:strokeColor="#cd584c"
android:strokeLineCap="butt"/>
<path
android:pathData="m84.09,47 l-18,-44h-12"
android:strokeAlpha="1"
android:strokeLineJoin="round"
android:strokeWidth="6"
android:fillColor="#00000000"
android:strokeColor="#d5d5d5"
android:fillAlpha="1"
android:strokeLineCap="round"/>
<path
android:pathData="m38.09,44.898h20l10.349,-19.843 -30.349,5.945z"
android:strokeAlpha="1"
android:strokeLineJoin="miter"
android:strokeWidth="1"
android:fillColor="#8c8c8c"
android:strokeColor="#00000000"
android:fillAlpha="1"
android:strokeLineCap="butt"/>
<path
android:pathData="m3.89,43c4,-16 18.198,-17.018 24.2,-15 6.002,2.018 14,8.853 14,19"
android:strokeAlpha="1"
android:strokeLineJoin="miter"
android:strokeWidth="8"
android:fillColor="#00000000"
android:strokeColor="#cd584c"
android:strokeLineCap="butt"/>
<path
android:pathData="m22.09,47h36l14.751,-24"
android:strokeAlpha="1"
android:strokeLineJoin="round"
android:strokeWidth="6"
android:fillColor="#00000000"
android:strokeColor="#d5d5d5"
android:fillAlpha="1"
android:strokeLineCap="round"/>
<path
android:pathData="m72.946,15.991c0,-3.314 8.675,-6.165 11.988,-6.165v12c-3.314,0 -11.988,-2.521 -11.988,-5.835z"
android:strokeAlpha="1"
android:strokeLineJoin="round"
android:strokeWidth="18"
android:fillColor="#cd584c"
android:strokeColor="#00000000"
android:fillAlpha="1"
android:strokeLineCap="round"/>
<path
android:pathData="m18.09,23c8.981,-0.068 17.631,0 24,8h8"
android:strokeAlpha="1"
android:strokeLineJoin="miter"
android:strokeWidth="8"
android:fillColor="#555555"
android:strokeColor="#555555"
android:fillAlpha="1"
android:strokeLineCap="round"/>
<path
android:pathData="m61.952,14.896c-6.527,3.094 -13.46,8.088 -12.964,15.186 0.489,2.337 2.077,4.828 4.559,4.213 4.264,-0.7 17.075,-4.269 18.143,-8.977 2.4,-9.318 -1.6,-13.318 -9.738,-10.422z"
android:strokeAlpha="1"
android:strokeLineJoin="round"
android:strokeWidth="6"
android:fillColor="#cd584c"
android:strokeColor="#00000000"
android:fillType="nonZero"
android:fillAlpha="1"
android:strokeLineCap="round"/>
</vector>

0 comments on commit 29082af

Please sign in to comment.