Skip to content

Commit

Permalink
brand suggestions for the place name form (fixes #2290)
Browse files Browse the repository at this point in the history
  • Loading branch information
westnordost committed Dec 2, 2020
1 parent fec4f78 commit dd80aec
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,8 @@ abstract class AbstractQuestAnswerFragment<T> : AbstractBottomSheetFragment(), I
}
protected val countryInfo get() = _countryInfo!!

protected val featureDictionary: FeatureDictionary get() = featureDictionaryFuture.get()

// views
private lateinit var content: ViewGroup
private lateinit var buttonPanel: FlexboxLayout
Expand Down Expand Up @@ -368,7 +370,7 @@ abstract class AbstractQuestAnswerFragment<T> : AbstractBottomSheetFragment(), I
ctx,
element.geometryType,
isoCountryCode,
featureDictionaryFuture.get(),
featureDictionary,
onSelectedFeature = { tags -> listener?.onReplaceShopElement(questId, tags) },
onLeaveNote = this::composeNote
).show()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,10 @@ import androidx.appcompat.app.AlertDialog
import android.view.View

import de.westnordost.streetcomplete.R
import de.westnordost.streetcomplete.ktx.geometryType
import de.westnordost.streetcomplete.quests.AbstractQuestFormAnswerFragment
import de.westnordost.streetcomplete.quests.OtherAnswer
import de.westnordost.streetcomplete.quests.shop_gone.SearchAdapter
import de.westnordost.streetcomplete.util.TextChangedWatcher
import kotlinx.android.synthetic.main.quest_placename.*

Expand All @@ -24,6 +26,15 @@ class AddPlaceNameForm : AbstractQuestFormAnswerFragment<PlaceNameAnswer>() {
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)

nameInput.setAdapter(SearchAdapter(requireContext()) { term ->
featureDictionary
.byTerm(term)
.forGeometry(osmElement!!.geometryType)
.inCountry(countryInfo.countryCode)
.isSuggestion(true)
.find()
.map { it.name }
})
nameInput.addTextChangedListener(TextChangedWatcher { checkIsFormComplete() })
}

Expand Down
3 changes: 2 additions & 1 deletion app/src/main/res/layout/quest_placename.xml
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
<?xml version="1.0" encoding="utf-8"?>
<EditText
<AutoCompleteTextView
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/nameInput"
android:textSize="40sp"
android:completionThreshold="2"
tools:text="Bürger König"
android:layout_width="match_parent"
android:layout_height="wrap_content"/>

0 comments on commit dd80aec

Please sign in to comment.