Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP: AddAddressStreet #1782

Merged
merged 110 commits into from
May 18, 2020
Merged
Show file tree
Hide file tree
Changes from 101 commits
Commits
Show all changes
110 commits
Select commit Hold shift + click to select a range
66a18e5
collecting street data for #213
matkoniecz Nov 15, 2019
581c4dd
reach compilable code
matkoniecz Nov 18, 2019
9a0b6ba
Merge branch 'master' into address
matkoniecz Nov 27, 2019
02e7480
drop no longer needed log
matkoniecz Nov 28, 2019
fb40d59
stop crashes on attempting to open form
matkoniecz Nov 28, 2019
acbab47
larger suggestion distance for addresses
matkoniecz Nov 28, 2019
a9d7c5e
reduce how far away road ca be to be a source of names
matkoniecz Nov 28, 2019
0bdab30
adapt interface strings
matkoniecz Nov 28, 2019
b6186ba
drop duplicated fields
matkoniecz Nov 28, 2019
cae3510
add broken layout switching
matkoniecz Dec 2, 2019
a4b1402
merge in AAddLocalizedNameForm
matkoniecz Dec 3, 2019
981cfba
duplicate AddLocalizedNameAdapter
matkoniecz Dec 3, 2019
caffb38
purge add language button
matkoniecz Dec 3, 2019
28216a3
remove more of unneded code
matkoniecz Dec 3, 2019
92e208b
revert edits to a wrong file
matkoniecz Dec 3, 2019
b7a028b
drop abbreviations code, drop not needed code
matkoniecz Dec 3, 2019
af6b422
have a visible field in addr:place mode
matkoniecz Dec 3, 2019
2de78e9
push hack lower
matkoniecz Dec 3, 2019
c095466
drop dead code
matkoniecz Dec 3, 2019
9957c68
prepare for dropping language codes completely
matkoniecz Dec 3, 2019
9a71935
simplify from list of localized names to a name
matkoniecz Dec 3, 2019
bdfc063
drop dead code
matkoniecz Dec 3, 2019
5592135
futher purge lists
matkoniecz Dec 3, 2019
01beb6f
replace map by list
matkoniecz Dec 3, 2019
d74e0a2
drop dead code
matkoniecz Dec 4, 2019
1e0ab56
add docs how structure works
matkoniecz Dec 4, 2019
95ef2f4
remove no longer needed code
matkoniecz Dec 4, 2019
d55a439
deduplicate names
matkoniecz Dec 4, 2019
e33d99b
add, useless for now, button in the place mode
matkoniecz Dec 4, 2019
2055c70
add dummy suggestion popup
matkoniecz Dec 4, 2019
337c17d
better case for variable name
matkoniecz Dec 4, 2019
c85f8da
fillable text field
matkoniecz Dec 4, 2019
a09f0e1
first version with a working interface
matkoniecz Dec 4, 2019
f4cfcd4
drop dead code
matkoniecz Dec 4, 2019
6652b9a
rename variable, use dummy values for suggestions one level higher
matkoniecz Dec 4, 2019
69c136a
restore class that somehow went missing without triggering a compilat…
matkoniecz Dec 5, 2019
40e088d
show addr:street quest only nearby named roads
matkoniecz Dec 6, 2019
a8fd9d9
fix icon
matkoniecz Dec 7, 2019
aa630d8
new better but not ideal interface for street input
matkoniecz Dec 7, 2019
a395fc3
restore street name
matkoniecz Dec 7, 2019
a75ae0f
first really working input field
matkoniecz Dec 7, 2019
ae7a244
Merge master into address
dbdean Apr 11, 2020
3685252
update AddAddressStreet to match changes in ac6bc710ca587ebace152c504…
dbdean Apr 11, 2020
a00f29c
update AddAddressStreet to match changes in 8c7cced190d335971498edee9…
dbdean Apr 11, 2020
b3286e5
hacked AddAddressStreetForm to use AAddLocalizedNameForm
dbdean Apr 17, 2020
ed70b2e
Make OSM commit message clearer
dbdean Apr 17, 2020
6f53bd5
Make distance for road name suggestion for addresses longer to accoun…
dbdean Apr 17, 2020
c75543f
Added street number to question
dbdean Apr 17, 2020
85e00b1
Remove serializer as it is covered by AAddLocalizedNameForm
dbdean Apr 17, 2020
ef7f451
500 metres was too much, let's try 250
dbdean Apr 17, 2020
8d4778a
AddAddressStreet now remembers last street chosen for quicker surveying
dbdean Apr 17, 2020
8718358
Merge branch 'master' into address
dbdean Apr 17, 2020
e3e68dc
Make street numbers show up a bit earlier in rendering to make street…
dbdean Apr 17, 2020
a46a2e6
Don't ask to discard input if closing AddStreetName dialog with no ch…
dbdean Apr 17, 2020
6e707ed
Improve key-selection code
dbdean Apr 19, 2020
e72d9fa
Remove unneeded logging
dbdean Apr 19, 2020
31813bf
Keep commit message clear
dbdean Apr 19, 2020
a3e9007
Left over from serializer, that is now covered by AAddLocalizedNameForm
dbdean Apr 19, 2020
1aeb2aa
Removed TODO comment related to multi-language addr:street tagging
dbdean Apr 19, 2020
38e6ab1
Try to improve wording of prompts for AddAddressStreet
dbdean Apr 19, 2020
559dcac
AddNameSuggestionAdapter is no longer used
dbdean Apr 19, 2020
0db1d1e
Improvement of strings wording - not all addresses are actually houses
dbdean Apr 20, 2020
6bf0619
Use constant instead of hard-coding distance for named roads
dbdean Apr 25, 2020
1bdb9ec
Merge remote-tracking branch 'upstream/master' into address
dbdean Apr 25, 2020
e4be8b2
AddAddressStreetForm back into kotlin version of ApplicationComponent
dbdean Apr 25, 2020
fe533b8
AddAddressStreet back into kotlin version of QuestModule
dbdean Apr 25, 2020
404029b
Fixed moved references
dbdean Apr 25, 2020
dc3d784
normalize AddAddressStreet and AddRoadName to search for road name su…
dbdean Apr 26, 2020
e682fc7
unneeded imports removed
dbdean Apr 26, 2020
3b54f1a
attempt to make addresses ask for street name immediately when addr:h…
dbdean Apr 26, 2020
d1f71bb
added missing semicolon in overpass query
dbdean Apr 26, 2020
eb25a30
fix tag filter syntax
dbdean Apr 26, 2020
73456ab
Merge remote-tracking branch 'upstream/master' into address
dbdean May 1, 2020
bbc8cf8
Merge remote-tracking branch 'upstream/master' into address
dbdean May 2, 2020
74d9340
Merge remote-tracking branch 'upstream/master' into address
dbdean May 2, 2020
5591b1a
Move putRoadNameSuggestion function into RoadNameSuggestionsDao to sh…
dbdean May 2, 2020
780db1a
Merge remote-tracking branch 'upstream/master' into address
dbdean May 3, 2020
085754c
Merge remote-tracking branch 'upstream/master' into address
dbdean May 6, 2020
63b5c28
Merge remote-tracking branch 'upstream/master' into address
dbdean May 9, 2020
dc781f9
Merge remote-tracking branch 'upstream/master' into address
dbdean May 17, 2020
68d7ec1
Update app/src/main/java/de/westnordost/streetcomplete/quests/address…
dbdean May 17, 2020
05c5c29
Update comment to reflect that we are ok with the current implementat…
dbdean May 17, 2020
aabbb48
Merge branch 'address' of github.com:dbdean/StreetComplete into address
dbdean May 17, 2020
33a3ea8
Update app/src/main/java/de/westnordost/streetcomplete/quests/address…
dbdean May 17, 2020
5fe9985
Update app/src/main/java/de/westnordost/streetcomplete/quests/address…
dbdean May 17, 2020
5ebc6bd
Update app/src/main/java/de/westnordost/streetcomplete/quests/address…
dbdean May 17, 2020
c0fdd89
Update app/src/main/java/de/westnordost/streetcomplete/quests/address…
dbdean May 17, 2020
b1f906a
Apply to all addresses without streets, regardless of the closeness t…
dbdean May 17, 2020
2522e90
Move functions below init
dbdean May 17, 2020
d7f9933
Move companion object to end of class
dbdean May 17, 2020
7bbf0c3
Removed TODO comment, as saving a single name is ok
dbdean May 17, 2020
5fd5672
Remove alert confirmation on switching to place name layout
dbdean May 17, 2020
0e861ba
Add missing )
dbdean May 17, 2020
f923753
Remove const so that trimIndent can be used
dbdean May 17, 2020
51b995c
; not needed in overpass constant
dbdean May 17, 2020
bf2d065
Use same layout for place name as street names
dbdean May 17, 2020
700e10d
Don't offer name suggestions when isPlaceName is true
dbdean May 17, 2020
1ff22fb
remove unused companion object
dbdean May 17, 2020
9f1f245
attempt to persist isPlaceName
dbdean May 17, 2020
87216b9
don't remember names if they are place names
dbdean May 17, 2020
0d21feb
Change to black and white sign for addr:placename instead of blue and…
dbdean May 17, 2020
7efa384
disable in Japan because housenumbers usually have no associated street
westnordost May 17, 2020
aaa2368
indentation
westnordost May 17, 2020
b997e64
indentation
westnordost May 17, 2020
fa1ff52
add a nice picture to the place name form
westnordost May 17, 2020
b03243b
revert introduced overpass syntax error
westnordost May 17, 2020
e6a840b
revert the last-picked-value feature
westnordost May 17, 2020
0b9749b
revert the last-picked-value feature
westnordost May 17, 2020
5676fff
Extend RoadNameSuggestionsDao
westnordost May 18, 2020
0081ab0
change quest so that user can select the street from the map
westnordost May 18, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion app/src/main/assets/map_theme/layers/labels.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ layers:
buildings:
data: { source: mapzen}
address-labels:
filter: { $zoom: { min: 19 }, kind: address }
filter: { $zoom: { min: 18 }, kind: address }
draw:
text:
text_source: addr_housenumber
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import de.westnordost.streetcomplete.notifications.OsmUnreadMessagesFragment
import de.westnordost.streetcomplete.quests.AbstractQuestAnswerFragment
import de.westnordost.streetcomplete.quests.QuestModule
import de.westnordost.streetcomplete.quests.SplitWayFragment
import de.westnordost.streetcomplete.quests.address.AddAddressStreetForm;
import de.westnordost.streetcomplete.quests.building_levels.AddBuildingLevelsForm
import de.westnordost.streetcomplete.quests.localized_name.AAddLocalizedNameForm
import de.westnordost.streetcomplete.quests.localized_name.AddRoadNameForm
Expand Down Expand Up @@ -64,6 +65,7 @@ interface ApplicationComponent {
fun inject(settingsActivity: SettingsActivity)
fun inject(addOpeningHoursForm: AddOpeningHoursForm)
fun inject(addRoadNameForm: AddRoadNameForm)
fun inject(addAddressStreetForm: AddAddressStreetForm)
fun inject(parkingFeeForm: AddParkingFeeForm)
fun inject(addOnewayForm: AddOnewayForm)
fun inject(addCollectionTimesForm: AddCollectionTimesForm)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import de.westnordost.osmfeatures.FeatureDictionary
import de.westnordost.streetcomplete.data.quest.QuestTypeRegistry
import de.westnordost.streetcomplete.data.osm.mapdata.OverpassMapDataAndGeometryApi
import de.westnordost.streetcomplete.data.osmnotes.notequests.OsmNoteQuestType
import de.westnordost.streetcomplete.quests.address.AddAddressStreet;
import de.westnordost.streetcomplete.quests.accepts_cash.AddAcceptsCash
import de.westnordost.streetcomplete.quests.baby_changing_table.AddBabyChangingTable
import de.westnordost.streetcomplete.quests.bike_parking_capacity.AddBikeParkingCapacity
Expand Down Expand Up @@ -69,7 +70,7 @@ import de.westnordost.streetcomplete.quests.toilet_availability.AddToiletAvailab
import de.westnordost.streetcomplete.quests.toilets_fee.AddToiletsFee
import de.westnordost.streetcomplete.quests.tourism_information.AddInformationToTourism
import de.westnordost.streetcomplete.quests.tracktype.AddTracktype
import de.westnordost.streetcomplete.quests.housenumber.AddHousenumber
import de.westnordost.streetcomplete.quests.address.AddHousenumber
import de.westnordost.streetcomplete.quests.max_speed.AddMaxSpeed
import de.westnordost.streetcomplete.quests.opening_hours.AddOpeningHours
import de.westnordost.streetcomplete.quests.localized_name.AddRoadName
Expand Down Expand Up @@ -108,6 +109,7 @@ object QuestModule
AddBusStopName(o),
AddIsBuildingUnderground(o), //to avoid asking AddHousenumber and other for underground buildings
AddHousenumber(o),
AddAddressStreet(o, roadNameSuggestionsDao),
MarkCompletedHighwayConstruction(o),
AddReligionToPlaceOfWorship(o), // icons on maps are different - OSM Carto, mapy.cz, OsmAnd, Sputnik etc
AddParkingAccess(o), //OSM Carto, mapy.cz, OSMand, Sputnik etc
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
package de.westnordost.streetcomplete.quests.address

import de.westnordost.osmapi.map.data.BoundingBox
import de.westnordost.osmapi.map.data.Element
import de.westnordost.streetcomplete.R
import de.westnordost.streetcomplete.data.meta.ALL_ROADS
import de.westnordost.streetcomplete.data.osm.osmquest.OsmElementQuestType
import de.westnordost.streetcomplete.data.osm.changes.StringMapChangesBuilder
import de.westnordost.streetcomplete.data.osm.mapdata.OverpassMapDataAndGeometryApi
import de.westnordost.streetcomplete.data.osm.elementgeometry.ElementGeometry
import de.westnordost.streetcomplete.data.osm.elementgeometry.ElementPolylinesGeometry
import de.westnordost.streetcomplete.data.tagfilters.FiltersParser
import de.westnordost.streetcomplete.data.tagfilters.getQuestPrintStatement
import de.westnordost.streetcomplete.data.tagfilters.toGlobalOverpassBBox
import de.westnordost.streetcomplete.quests.localized_name.data.RoadNameSuggestionsDao
import java.util.regex.Pattern

class AddAddressStreet(
private val overpassApi: OverpassMapDataAndGeometryApi,
private val roadNameSuggestionsDao: RoadNameSuggestionsDao
) : OsmElementQuestType<AddressStreetAnswer> {
override val commitMessage = "Add street/place names to address"
override val icon = R.drawable.ic_quest_housenumber_street

override fun getTitle(tags: Map<String, String>) = R.string.quest_address_street_title

override fun getTitleArgs(tags: Map<String, String>, featureName: Lazy<String?>): Array<String> {
val housenumber = tags["addr:streetnumber"] ?: tags["addr:housenumber"]
return if (housenumber != null) arrayOf(housenumber) else arrayOf()
}

override fun createForm() = AddAddressStreetForm()

override fun isApplicableTo(element: Element): Boolean? =
ADDRESSES_WITHOUT_STREETS_TFE.matches(element)
dbdean marked this conversation as resolved.
Show resolved Hide resolved

override fun download(bbox: BoundingBox, handler: (element: Element, geometry: ElementGeometry?) -> Unit): Boolean {
if (!overpassApi.query(getOverpassQuery(bbox), handler)) return false
if (!overpassApi.query(getStreetNameSuggestionsOverpassQuery(bbox), roadNameSuggestionsDao::putRoadNameSuggestion)) return false
return true
}

private fun getOverpassQuery(bbox: BoundingBox) =
bbox.toGlobalOverpassBBox() + """
relation["type"="associatedStreet"];
> -> .inStreetRelation;

$ADDRESSES_WITHOUT_STREETS -> .missing_data;

(.missing_data; - .inStreetRelation;);""".trimIndent() +
getQuestPrintStatement()

/** return overpass query string to get roads with names around addresses without streets
* */
private fun getStreetNameSuggestionsOverpassQuery(bbox: BoundingBox) =
bbox.toGlobalOverpassBBox() + "\n" + """
$ADDRESSES_WITHOUT_STREETS -> .address_missing_street;
$ROADS_WITH_NAMES -> .named_roads;
way.named_roads(
around.address_missing_street: $MAX_DIST_FOR_ROAD_NAME_SUGGESTION);
out body geom;""".trimIndent()
westnordost marked this conversation as resolved.
Show resolved Hide resolved

override fun applyAnswerTo(answer: AddressStreetAnswer, changes: StringMapChangesBuilder) {
val key = when(answer) {
is StreetName -> "addr:street"
is PlaceName -> "addr:place"
}
for ((languageCode, name) in answer.localizedNames) {
if (languageCode.isEmpty()) {
changes.addOrModify(key, name)
} else {
changes.addOrModify("$key:$languageCode", name)
}
}
}

companion object {
// This only picks up nodes, so street-name suggestions don't appear
// in the middle of a long straight-stretch (longer than 0.5km). This happens rarely
// enough that I don't think it is a concern.
const val MAX_DIST_FOR_ROAD_NAME_SUGGESTION = 250.0

private val ADDRESSES_WITHOUT_STREETS = """
(
nwr["addr:housenumber"][!"addr:street"][!"addr:place"][!"addr:block_number"];
nwr["addr:streetnumber"][!"addr:street"];
)""".trimIndent()
// this must be the same as above but in tag filter expression syntax
private val ADDRESSES_WITHOUT_STREETS_TFE by lazy { FiltersParser().parse("""
nodes, ways, relations with
addr:housenumber and !addr:street and !addr:place and !addr:block_number
or addr:streetnumber and !addr:street
""")}

private val ROADS_WITH_NAMES =
"way[highway ~ \"^(${ALL_ROADS.joinToString("|")})$\"][name]"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,146 @@
package de.westnordost.streetcomplete.quests.address

import android.os.Bundle
import android.view.LayoutInflater
import android.view.Menu
import android.view.View
import android.view.ViewGroup
import android.widget.EditText
import androidx.appcompat.app.AlertDialog
import androidx.appcompat.widget.PopupMenu
import de.westnordost.osmapi.map.data.LatLon
import de.westnordost.streetcomplete.Injector
import de.westnordost.streetcomplete.R
import de.westnordost.streetcomplete.data.meta.AbbreviationsByLocale
import de.westnordost.streetcomplete.data.osm.elementgeometry.ElementGeometry
import de.westnordost.streetcomplete.data.osm.elementgeometry.ElementPointGeometry
import de.westnordost.streetcomplete.data.osm.elementgeometry.ElementPolygonsGeometry
import de.westnordost.streetcomplete.data.osm.elementgeometry.ElementPolylinesGeometry
import de.westnordost.streetcomplete.quests.LastPickedValuesStore
import de.westnordost.streetcomplete.quests.localized_name.AAddLocalizedNameForm
import de.westnordost.streetcomplete.quests.OtherAnswer
import de.westnordost.streetcomplete.quests.localized_name.AddLocalizedNameAdapter
import de.westnordost.streetcomplete.quests.localized_name.LocalizedName
import de.westnordost.streetcomplete.quests.localized_name.data.RoadNameSuggestionsDao
import de.westnordost.streetcomplete.util.TextChangedWatcher
import java.util.*
import javax.inject.Inject

class AddAddressStreetForm : AAddLocalizedNameForm<AddressStreetAnswer>() {
private var isPlaceName = false
private var defaultName = ""

@Inject
internal lateinit var abbreviationsByLocale: AbbreviationsByLocale
@Inject
internal lateinit var roadNameSuggestionsDao: RoadNameSuggestionsDao

@Inject internal lateinit var favs: LastPickedValuesStore<String>

init {
Injector.instance.applicationComponent.inject(this)
val lastPickedNames = favs.get(javaClass.simpleName)
defaultName = if (lastPickedNames.isEmpty()) {""} else {lastPickedNames.first}
}

override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {
val view = super.onCreateView(inflater, container, savedInstanceState)

isPlaceName = savedInstanceState?.getBoolean(IS_PLACENAME) ?: false
if (isPlaceName) {
switchToPlaceNameLayout()
}

return view
}

override fun onSaveInstanceState(outState: Bundle) {
super.onSaveInstanceState(outState)
outState.putBoolean(IS_PLACENAME, isPlaceName)
}

override fun onClickOk(names: List<LocalizedName>) {
dbdean marked this conversation as resolved.
Show resolved Hide resolved
val possibleAbbreviations = LinkedList<String>()
for ((languageCode, name) in adapter.localizedNames) {
val locale = if(languageCode.isEmpty()) countryInfo.locale else Locale(languageCode)
val abbr = abbreviationsByLocale.get(locale)
val containsAbbreviations = abbr?.containsAbbreviations(name) == true

if (name.contains(".") || containsAbbreviations) {
possibleAbbreviations.add(name)
}
}

if (!isPlaceName) {
favs.add(javaClass.simpleName,
names.first().name, max = 1)
}

confirmPossibleAbbreviationsIfAny(possibleAbbreviations) {
if(isPlaceName) {
applyAnswer(PlaceName(names))
} else {
applyAnswer(StreetName(names))
}
}
}

override val otherAnswers = listOf(
OtherAnswer(R.string.quest_address_street_no_named_streets) { switchToPlaceNameLayout() }
)

override fun setupNameAdapter(data: List<LocalizedName>, addLanguageButton: View): AddLocalizedNameAdapter {

return AddLocalizedNameAdapter(
data, activity!!, getPossibleStreetsignLanguages(),
abbreviationsByLocale, getNameSuggestions(), addLanguageButton,
defaultName
)
}

private fun getNameSuggestions(): List<MutableMap<String, String>> {
return if (isPlaceName) {
emptyList<MutableMap<String, String>>()
} else {
roadNameSuggestionsDao.getNames(
geometryToMajorPoints(elementGeometry),
AddAddressStreet.MAX_DIST_FOR_ROAD_NAME_SUGGESTION
)
}
}

private fun geometryToMajorPoints(geometry: ElementGeometry): List<LatLon> {
return when(geometry) {
is ElementPolylinesGeometry -> {
val polyline = geometry.polylines.first()
listOf(polyline.first(), polyline.last())
}
is ElementPolygonsGeometry -> {
// return center and one of nodes from the way constructing area
listOf(geometry.center, geometry.polygons.first().last())
}
is ElementPointGeometry -> {
listOf(geometry.center)
}
}


}

override fun isRejectingClose() : Boolean {
// if the form is complete, we will reject close, unless it is still has only the default name
return isFormComplete() && !(adapter.localizedNames.size == 1 && adapter.localizedNames.first().name == defaultName)
}

private fun switchToPlaceNameLayout() {
isPlaceName = true
changeLayout(resources.getString(R.string.quest_address_street_place_name_label),
R.drawable.background_placename)
defaultName = ""
initLocalizedNameAdapter(null)
}

companion object {
private const val IS_PLACENAME = "is_placename"
}
dbdean marked this conversation as resolved.
Show resolved Hide resolved
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package de.westnordost.streetcomplete.quests.housenumber
package de.westnordost.streetcomplete.quests.address

import android.util.Log

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package de.westnordost.streetcomplete.quests.housenumber
package de.westnordost.streetcomplete.quests.address

import android.os.Bundle
import androidx.appcompat.app.AlertDialog
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package de.westnordost.streetcomplete.quests.address

import de.westnordost.streetcomplete.quests.localized_name.LocalizedName

sealed class AddressStreetAnswer(open val localizedNames: List<LocalizedName>)

data class StreetName(override val localizedNames: List<LocalizedName>) : AddressStreetAnswer(localizedNames)
data class PlaceName(override val localizedNames: List<LocalizedName>) : AddressStreetAnswer(localizedNames)
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package de.westnordost.streetcomplete.quests.housenumber
package de.westnordost.streetcomplete.quests.address

sealed class HousenumberAnswer

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ abstract class AAddLocalizedNameForm<T> : AbstractQuestFormAnswerFragment<T>() {
initLocalizedNameAdapter(savedInstanceState)
}

private fun initLocalizedNameAdapter(savedInstanceState: Bundle?) {
protected fun initLocalizedNameAdapter(savedInstanceState: Bundle?) {
val data: ArrayList<LocalizedName> = if (savedInstanceState != null) {
serializer.toObject(savedInstanceState.getByteArray(LOCALIZED_NAMES_DATA)!!)
} else {
Expand All @@ -57,6 +57,11 @@ abstract class AAddLocalizedNameForm<T> : AbstractQuestFormAnswerFragment<T>() {
checkIsFormComplete()
}

protected fun changeLayout(label : String, background_resource : Int) {
descriptionLabel.setText(label)
namesList.setBackgroundResource(background_resource)
}

protected open fun setupNameAdapter(data: List<LocalizedName>, addLanguageButton: View) =
AddLocalizedNameAdapter(data, activity!!, getPossibleStreetsignLanguages(), null, null, addLanguageButton)

Expand Down
Loading