-
-
Notifications
You must be signed in to change notification settings - Fork 358
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1135 from matkoniecz/segregated
Segregated [change layout]
- Loading branch information
Showing
9 changed files
with
141 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
66 changes: 66 additions & 0 deletions
66
...src/main/java/de/westnordost/streetcomplete/quests/segregated/AddCyclewaySegregation.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} | ||
} |
27 changes: 27 additions & 0 deletions
27
...main/java/de/westnordost/streetcomplete/quests/segregated/AddCyclewaySegregationForm.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; } | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
31 changes: 31 additions & 0 deletions
31
app/src/main/res/layout/cell_labeled_icon_select_right.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters