From dd80aec06d36204a834f14da72fb9a13424c0788 Mon Sep 17 00:00:00 2001 From: Tobias Zwick Date: Wed, 2 Dec 2020 17:44:04 +0100 Subject: [PATCH] brand suggestions for the place name form (fixes #2290) --- .../quests/AbstractQuestAnswerFragment.kt | 4 +++- .../quests/place_name/AddPlaceNameForm.kt | 11 +++++++++++ app/src/main/res/layout/quest_placename.xml | 3 ++- 3 files changed, 16 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/de/westnordost/streetcomplete/quests/AbstractQuestAnswerFragment.kt b/app/src/main/java/de/westnordost/streetcomplete/quests/AbstractQuestAnswerFragment.kt index ffbb8401f4..17dca18569 100644 --- a/app/src/main/java/de/westnordost/streetcomplete/quests/AbstractQuestAnswerFragment.kt +++ b/app/src/main/java/de/westnordost/streetcomplete/quests/AbstractQuestAnswerFragment.kt @@ -59,6 +59,8 @@ abstract class AbstractQuestAnswerFragment : 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 @@ -368,7 +370,7 @@ abstract class AbstractQuestAnswerFragment : AbstractBottomSheetFragment(), I ctx, element.geometryType, isoCountryCode, - featureDictionaryFuture.get(), + featureDictionary, onSelectedFeature = { tags -> listener?.onReplaceShopElement(questId, tags) }, onLeaveNote = this::composeNote ).show() diff --git a/app/src/main/java/de/westnordost/streetcomplete/quests/place_name/AddPlaceNameForm.kt b/app/src/main/java/de/westnordost/streetcomplete/quests/place_name/AddPlaceNameForm.kt index 2a94176547..735415e873 100644 --- a/app/src/main/java/de/westnordost/streetcomplete/quests/place_name/AddPlaceNameForm.kt +++ b/app/src/main/java/de/westnordost/streetcomplete/quests/place_name/AddPlaceNameForm.kt @@ -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.* @@ -24,6 +26,15 @@ class AddPlaceNameForm : AbstractQuestFormAnswerFragment() { 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() }) } diff --git a/app/src/main/res/layout/quest_placename.xml b/app/src/main/res/layout/quest_placename.xml index 942ec22e96..338222b69d 100644 --- a/app/src/main/res/layout/quest_placename.xml +++ b/app/src/main/res/layout/quest_placename.xml @@ -1,9 +1,10 @@ -