Skip to content

Commit

Permalink
move "differs for each side" option to main UI (fixes #2350)
Browse files Browse the repository at this point in the history
  • Loading branch information
westnordost committed Dec 17, 2020
1 parent 744b7bb commit 1cb7cd2
Show file tree
Hide file tree
Showing 9 changed files with 81 additions and 23 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import android.graphics.Color
import android.os.Bundle
import android.view.View
import androidx.annotation.AnyThread
import androidx.core.view.isGone
import de.westnordost.streetcomplete.R
import de.westnordost.streetcomplete.data.osm.elementgeometry.ElementPolylinesGeometry
import de.westnordost.streetcomplete.quests.AbstractQuestFormAnswerFragment
Expand Down Expand Up @@ -50,12 +51,6 @@ class AddLanesForm : AbstractQuestFormAnswerFragment<LanesAnswer>(),
override val otherAnswers: List<OtherAnswer> get() {
val answers = mutableListOf<OtherAnswer>()

if (!isOneway) {
answers.add(OtherAnswer(R.string.quest_lanes_answer_lanes_odd) {
selectedLanesType = MARKED_SIDES
setStreetSideLayout()
})
}
if (!isOneway && countryInfo.isCenterLeftTurnLaneKnown) {
answers.add(OtherAnswer(R.string.quest_lanes_answer_lanes_center_left_turn_lane) {
selectedLanesType = MARKED_SIDES
Expand Down Expand Up @@ -149,6 +144,13 @@ class AddLanesForm : AbstractQuestFormAnswerFragment<LanesAnswer>(),
checkIsFormComplete()
askLanesAndSwitchToStreetSideLayout()
}
view.markedLanesOddButton.isGone = isOneway

view.markedLanesOddButton.setOnClickListener {
selectedLanesType = MARKED_SIDES
unmarkedLanesButton.isSelected = false
setStreetSideLayout()
}
}

private fun askLanesAndSwitchToStreetSideLayout() { launch {
Expand Down
8 changes: 4 additions & 4 deletions app/src/main/res/drawable/ic_lanes_marked.xml
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="160dp"
android:width="96dp"
android:height="96dp"
android:viewportWidth="160"
android:viewportWidth="96"
android:viewportHeight="96">
<path
android:pathData="m0,0 l160,0.001 -0.001,95.999 -160,-0.001z"
android:pathData="m0.0004,0.0003 l96,0.0007 -0.0006,95.999 -96,-0.0007z"
android:strokeWidth="2.582"
android:fillColor="#808080"/>
<path
android:pathData="m8,0v96h8v-96zM144,0v96h8v-96zM76,8 L76,24h8v-16zM76,40v16h8v-16zM76,72 L76,88h8v-16z"
android:pathData="m4,0v96h4v-96zM88,0v96h4v-96zM46,8 L46,24h4v-16zM46,40v16h4v-16zM46,72 L46,88h4v-16z"
android:strokeWidth="2.5"
android:fillColor="#fff"/>
</vector>
22 changes: 22 additions & 0 deletions app/src/main/res/drawable/ic_lanes_marked_odd.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="96dp"
android:height="96dp"
android:viewportWidth="96"
android:viewportHeight="96">
<path
android:pathData="m0.0004,0.0003 l96,0.0007 -0.0006,95.999 -96,-0.0007z"
android:strokeWidth="2.582"
android:fillColor="#808080"/>
<path
android:pathData="m4,0v96h4v-96zM88,0v96h4v-96z"
android:strokeWidth="2.5"
android:fillColor="#fff"/>
<path
android:pathData="m60,8 l-0,16h4v-16zM60,40v16h4v-16zM60,72 L60,88h4v-16z"
android:strokeWidth="2.5"
android:fillColor="#fff"/>
<path
android:pathData="m32,0v96h4v-96z"
android:strokeWidth="2.5"
android:fillColor="#fff"/>
</vector>
8 changes: 4 additions & 4 deletions app/src/main/res/drawable/ic_lanes_unmarked.xml
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="160dp"
android:width="96dp"
android:height="96dp"
android:viewportWidth="160"
android:viewportWidth="96"
android:viewportHeight="96">
<path
android:pathData="m-0,96 l160,-0 0.001,-96 -160,0z"
android:pathData="m-0.0003,96 l96,-0.0002 0.0006,-96 -96,0.0002z"
android:strokeWidth="1.5649"
android:fillColor="#808080"/>
<path
android:pathData="m8,96v-96h8v96zM144,96v-96l8,0v96z"
android:pathData="m4,96v-96h4v96zM88,96v-96l4.0002,0.0004v96z"
android:strokeWidth="2.4595"
android:fillColor="#fff"/>
</vector>
31 changes: 29 additions & 2 deletions app/src/main/res/layout/quest_lanes_select_type.xml
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,7 @@
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:weightSum="2">
android:orientation="horizontal">

<LinearLayout
android:id="@+id/markedLanesButton"
Expand Down Expand Up @@ -75,6 +74,34 @@

</LinearLayout>

<LinearLayout
android:id="@+id/markedLanesOddButton"
android:layout_width="0dp"
android:layout_weight="1"
android:layout_height="wrap_content"
android:layout_margin="2dp"
android:orientation="vertical"
android:gravity="center_horizontal"
android:background="@drawable/image_select_cell_rounded">

<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingStart="6dp"
android:paddingEnd="6dp"
android:paddingTop="6dp"
android:scaleType="fitCenter"
android:src="@drawable/ic_lanes_marked_odd"
android:adjustViewBounds="true"/>

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
style="@style/ImageSelectLabelBelow"
android:text="@string/quest_lanes_answer_lanes_odd2"/>

</LinearLayout>

</LinearLayout>

</LinearLayout>
2 changes: 1 addition & 1 deletion app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -246,12 +246,12 @@ If there are no signs along the whole street which apply for the highlighted sec
<string name="quest_serviceType_title">"What kind of service road is this?"</string>
<string name="quest_lanes_title">"How many lanes for cars does this road have?"</string>
<string name="quest_lanes_answer_lanes">"Marked lanes"</string>
<string name="quest_lanes_answer_lanes_odd2">"Lane count differs for each side"</string>
<string name="quest_lanes_answer_lanes_description2">"Specify the total number of marked lanes (both directions) usable by car traffic. So, bike and dedicated parking lanes don't count.
If any lanes are reserved for buses, please leave a note instead."</string>
<string name="quest_lanes_answer_lanes_description_one_side2">"Specify the number of marked lanes usable by car traffic here. So, bike and dedicated parking lanes don't count.
If any lanes are reserved for buses, please leave a note instead."</string>
<string name="quest_lanes_answer_noLanes">"No marked lanes"</string>
<string name="quest_lanes_answer_lanes_odd">"Differs for each side"</string>
<string name="quest_lanes_answer_lanes_center_left_turn_lane">"It has a two-way left turn lane"</string>
<string name="quest_oneway_title">"Is this a one-way street?"</string>
<string name="quest_oneway2_title">"Is this a one-way street? In which direction?"</string>
Expand Down
6 changes: 3 additions & 3 deletions res/graphics/lanes graphics/lanes_marked.svg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
7 changes: 7 additions & 0 deletions res/graphics/lanes graphics/lanes_marked_odd.svg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 3 additions & 3 deletions res/graphics/lanes graphics/lanes_unmarked.svg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 1cb7cd2

Please sign in to comment.