-
-
Notifications
You must be signed in to change notification settings - Fork 394
AllThePlaces quests #6302
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
Draft
matkoniecz
wants to merge
179
commits into
streetcomplete:master
Choose a base branch
from
matkoniecz:atp_renew
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
AllThePlaces quests #6302
Changes from 138 commits
Commits
Show all changes
179 commits
Select commit
Hold shift + click to select a range
41735ab
ATP
matkoniecz f668f7e
+
matkoniecz 00ada70
val var
matkoniecz 7e2cb14
+
matkoniecz f9d1348
+
matkoniecz fdef9e7
+
matkoniecz 3710366
+
matkoniecz 71bb2d1
+
matkoniecz 4512229
+
matkoniecz 1d82d73
finish replacing inferior hack by superior hack
matkoniecz 6937d74
prepare data passing
matkoniecz 6b346d7
+
matkoniecz 400b684
+
matkoniecz 17739f3
DONE
matkoniecz 4dba4bc
also done
matkoniecz aa29ad8
wat, wtf is going on
matkoniecz 27eaf72
layout not needed
matkoniecz 4be48d7
+
matkoniecz cdc0d87
+
matkoniecz d0fb475
try to generify lookup of nearby elements to display
matkoniecz 3539d74
+
matkoniecz 11f242f
+
matkoniecz 07e0efe
+
matkoniecz 6e5a947
+
matkoniecz ed2a5fb
+
matkoniecz e069b3d
+
matkoniecz 838f175
+
matkoniecz 8a3555d
+
matkoniecz 5714b0a
+
matkoniecz 4763359
+
matkoniecz ce5481c
+
matkoniecz 3f507e9
+
matkoniecz 1d87ef9
+
matkoniecz f27bfae
+
matkoniecz 6a565c0
remove opening hours quest atp stuff
matkoniecz 6093d18
drop some TODOs
matkoniecz 6f7ea17
ech, it is fine
matkoniecz 6c66a29
give up on fixing for now
matkoniecz 7071390
purge TODO
matkoniecz 6fdaab2
+
matkoniecz 0a009ad
OH
matkoniecz 7ec8161
OH
matkoniecz 01ee28d
typo
matkoniecz 222e220
+
matkoniecz be3801c
+
matkoniecz 5dad557
fix some
matkoniecz afd43a5
+
matkoniecz 4fd0873
update data for Kraków
matkoniecz a63a73d
done
matkoniecz a9bc507
done
matkoniecz f45857f
done as isThereOsmAtpMatch considers range
matkoniecz 15f8898
+
matkoniecz b9da1e2
+
matkoniecz 0854006
tests :)
matkoniecz d6383c2
add test and fix code
matkoniecz e8239b6
+
matkoniecz 7e2ad82
implemented
matkoniecz b60a6bd
+
matkoniecz df179af
nixed effort for now
matkoniecz 19bdb61
clarify
matkoniecz bac8449
reduce false positive ratio
matkoniecz dd0f248
more tests
matkoniecz 1615502
better tests
matkoniecz 8a4194b
wonderful, more TODOs
matkoniecz 837c0d1
show hiding text
matkoniecz 9a70110
actually add an actual download of external data instead of including…
matkoniecz 8274b16
Merge branch 'master' into atp_renew
matkoniecz 0fbcfd2
these can be done later, does not need to be done now
matkoniecz 2de19bc
remove dead code
matkoniecz 9c9f41f
better comment
matkoniecz 6d03b25
fix test
matkoniecz b395bbb
not needed
matkoniecz 24bb796
done already
matkoniecz 09dc5d2
better name
matkoniecz 57b37df
new TODO
matkoniecz df26aa4
it works
matkoniecz 9841b80
clean unused imports
matkoniecz 722d872
test added
matkoniecz 56c3507
fix test
matkoniecz a2e49dc
done!
matkoniecz af74f70
more main keys
matkoniecz f82359b
more reasonable ones
matkoniecz c1b1403
clarify
matkoniecz 00baf32
change my mind here a bit
matkoniecz b14cf33
support global ATP API now
matkoniecz 7e7116c
drop not needed logging
matkoniecz 90b1060
stop collision with MARKER_NOTE_ID
matkoniecz dd460e4
add grant info
matkoniecz e501b7d
move taginfo parser to dead project section
matkoniecz d22a765
more docs
matkoniecz 75ba597
fix phrasing
matkoniecz 91fe33e
add tests, fix parser
matkoniecz 3facd8e
document value
matkoniecz e53c17d
update TODO
matkoniecz f49f6ef
fix comments
matkoniecz 039fbfb
adapt test
matkoniecz cbaf108
ATP quests are not hidden by nearby notes
matkoniecz ba45e8a
attempt to get tests for AtpApiClient
matkoniecz 1f47de3
fix naming
matkoniecz 0c1ff38
done now
matkoniecz 04a4899
done
matkoniecz 70811ee
looks fine to duplicate
matkoniecz d72fde7
remove ability to leave notes
matkoniecz b375552
done already
matkoniecz d2fbe9b
dead and replaced code
matkoniecz 7c35d60
process TODOs
matkoniecz 483b91b
Merge remote-tracking branch 'upstream/master' into atp_renew
matkoniecz a5c6976
clarify confusion
matkoniecz 302e4d9
progress
matkoniecz f9f5b4f
fix code and found bug
matkoniecz 2614773
fix tests
matkoniecz b144ef3
disable for now
matkoniecz 622d23b
more doubts
matkoniecz 0ab37cd
now documented
matkoniecz 0b3a097
clean ATP in Cleaner
matkoniecz 770a988
space
matkoniecz 42a9ee6
not trivial
matkoniecz 2740c7d
drop not needed code
matkoniecz 028fd0e
nope
matkoniecz 949ca7c
reduce comment
matkoniecz 218e74b
rename to clarify
matkoniecz b0a20c1
confusion is now resolved
matkoniecz dd2def0
commit no-brainer suggestion
westnordost 28cfa73
commit no-brainer suggestion
westnordost 0b00c5f
commit no-brainer suggestion
westnordost 59261e5
we will be never putting new ATP entries into API
matkoniecz 19f6abf
change text as suggested
matkoniecz 8e092a0
remove tests for removed put
matkoniecz fc34ab9
fix test
matkoniecz f55f251
drop some unused imports
matkoniecz c207a33
class to object
matkoniecz 15993cc
fix broken NULL handling
matkoniecz 81e43a4
Merge remote-tracking branch 'upstream/master' into atp_renew
matkoniecz 38673a6
TODO
matkoniecz 118aa4c
code review comment in code comment
matkoniecz 1a1a603
remove unused function
matkoniecz e48e6cc
add some tests
matkoniecz 906533c
move general check to end to get more detailed fail message if anythi…
matkoniecz f6a972b
Fix typo
matkoniecz 4a9bc74
no need to do anything here
matkoniecz 92cf0ac
pinged
matkoniecz 24ebc31
Revert "layout not needed"
matkoniecz 40d4085
split question and guide
matkoniecz 4062463
ATP data download failing should not take down entire download
matkoniecz 36289df
deal with 180th meridian
matkoniecz cbef44e
not notes
matkoniecz f87fa5d
it was based on matching notes code, update to its upgrade
matkoniecz 806c4b9
Merge branch 'master' into atp_renew
matkoniecz 983fc7d
update to changes upstream
matkoniecz e0d8b3c
Merge branch 'master' into atp_renew
matkoniecz 690683c
given context it will be enough, just add StreetComplete to data user…
matkoniecz 1e8fa5d
fix typo
matkoniecz 2e9dc1e
+
matkoniecz 9cb3e97
fixed externally
matkoniecz 3709c94
quests deleted already may be come listed again
matkoniecz b081dab
skip tagless
matkoniecz c5b2b07
specific filter idea
matkoniecz a5babf5
make grepping work
matkoniecz bc8ed2d
lol, I am already calling function supporting smart distance to areas
matkoniecz c0a6af0
mark as to be done on a final approach
matkoniecz 574cfe0
annotate stuck ones
matkoniecz abe9a76
better name as multiple are passed
matkoniecz 2ed9146
add missing test
matkoniecz 094fa17
annotate as TODO for later
matkoniecz cfd2c8e
not needed, enforced by compiler
matkoniecz 19d14b3
I see no reason to really panick if it happens
matkoniecz 4d1a777
mark deferred TODOs
matkoniecz 2bff5de
seems not tested in other cases
matkoniecz 99673f9
Merge remote-tracking branch 'upstream/master' into atp_renew
matkoniecz a3c853f
will come up in testing if needed
matkoniecz 6f2e970
remove wrong comment, mark TODO
matkoniecz 73d134e
clarify interface TODO
matkoniecz ab87b00
Merge remote-tracking branch 'upstream/master' into atp_renew
matkoniecz 4e2acf7
seems ready for removal
matkoniecz 07359f1
also for later
matkoniecz 2194f5f
need finish API first
matkoniecz 1546e7e
Merge branch 'master' into atp_renew
matkoniecz 5924686
Merge remote-tracking branch 'upstream/master' into atp_renew
matkoniecz c7da5c4
this is unfixable
matkoniecz File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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
124 changes: 124 additions & 0 deletions
124
app/src/androidInstrumentedTest/kotlin/de/westnordost/streetcomplete/data/atp/AtpDaoTest.kt
This file contains hidden or 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,124 @@ | ||
| package de.westnordost.streetcomplete.data.atp | ||
|
|
||
| import de.westnordost.streetcomplete.data.ApplicationDbTestCase | ||
| import de.westnordost.streetcomplete.data.osm.mapdata.BoundingBox | ||
| import de.westnordost.streetcomplete.data.osm.mapdata.Element | ||
| import de.westnordost.streetcomplete.data.osm.mapdata.ElementKey | ||
| import de.westnordost.streetcomplete.data.osm.mapdata.ElementType.NODE | ||
| import de.westnordost.streetcomplete.data.osm.mapdata.ElementType.WAY | ||
| import de.westnordost.streetcomplete.data.osm.mapdata.ElementType.RELATION | ||
| import de.westnordost.streetcomplete.data.osm.mapdata.LatLon | ||
| import de.westnordost.streetcomplete.util.ktx.containsExactlyInAnyOrder | ||
| import de.westnordost.streetcomplete.util.ktx.nowAsEpochMilliseconds | ||
| import kotlin.test.BeforeTest | ||
| import kotlin.test.Test | ||
| import kotlin.test.assertEquals | ||
| import kotlin.test.assertFalse | ||
| import kotlin.test.assertNotNull | ||
| import kotlin.test.assertNull | ||
| import kotlin.test.assertTrue | ||
|
|
||
| class AtpDaoTest : ApplicationDbTestCase() { | ||
| private lateinit var dao: AtpDao | ||
|
|
||
| @BeforeTest fun createDao() { | ||
| dao = AtpDao(database) | ||
| } | ||
|
|
||
| @Test fun putGet() { | ||
| val entry = createAtpEntry() | ||
|
|
||
| dao.put(entry) | ||
| val dbAtp = dao.get(entry.id)!! | ||
| assertEquals(entry, dbAtp) | ||
| } | ||
|
|
||
| @Test fun putAll() { | ||
| dao.putAll(listOf(createAtpEntry(1), createAtpEntry(2))) | ||
| assertNotNull(dao.get(1)) | ||
| assertNotNull(dao.get(2)) | ||
| } | ||
|
|
||
|
|
||
| @Test fun deleteButNothingIsThere() { | ||
| assertFalse(dao.delete(1)) | ||
| } | ||
|
|
||
| @Test fun delete() { | ||
| val entry = createAtpEntry() | ||
| dao.put(entry) | ||
| assertTrue(dao.delete(entry.id)) | ||
| assertNull(dao.get(entry.id)) | ||
| assertFalse(dao.delete(entry.id)) | ||
| } | ||
|
|
||
| @Test fun getAllPositions() { | ||
| val thisIsIn = createAtpEntry(1, LatLon(0.5, 0.5)) | ||
| val thisIsOut = createAtpEntry(2, LatLon(-0.5, 0.5)) | ||
| dao.putAll(listOf(thisIsIn, thisIsOut)) | ||
|
|
||
| val positions = dao.getAllPositions(BoundingBox(0.0, 0.0, 1.0, 1.0)) | ||
| assertEquals(LatLon(0.5, 0.5), positions.single()) | ||
| } | ||
|
|
||
| @Test fun getAllByBbox() { | ||
| val thisIsIn = createAtpEntry(1, LatLon(0.5, 0.5)) | ||
| val thisIsOut = createAtpEntry(2, LatLon(-0.5, 0.5)) | ||
| dao.putAll(listOf(thisIsIn, thisIsOut)) | ||
|
|
||
| val entries = dao.getAll(BoundingBox(0.0, 0.0, 1.0, 1.0)) | ||
| assertEquals(thisIsIn, entries.single()) | ||
| } | ||
|
|
||
| @Test fun getAllByIds() { | ||
| val first = createAtpEntry(1) | ||
| val second = createAtpEntry(2) | ||
| val third = createAtpEntry(3) | ||
| dao.putAll(listOf(first, second, third)) | ||
|
|
||
| assertEquals(listOf(first, second), dao.getAll(listOf(1, 2))) | ||
| } | ||
|
|
||
| @Test fun deleteAllByIds() { | ||
| dao.putAll(listOf(createAtpEntry(1), createAtpEntry(2), createAtpEntry(3))) | ||
|
|
||
| assertEquals(2, dao.deleteAll(listOf(1, 2))) | ||
| assertNull(dao.get(1)) | ||
| assertNull(dao.get(2)) | ||
| assertNotNull(dao.get(3)) | ||
| } | ||
|
|
||
| @Test fun getUnusedAndOldIds() { | ||
| dao.putAll(listOf(createAtpEntry(1), createAtpEntry(2), createAtpEntry(3))) | ||
| val unusedIds = dao.getIdsOlderThan(nowAsEpochMilliseconds() + 10) | ||
| assertTrue(unusedIds.containsExactlyInAnyOrder(listOf(1L, 2L, 3L))) | ||
| } | ||
|
|
||
| @Test fun getUnusedAndOldIdsButAtMostX() { | ||
| dao.putAll(listOf(createAtpEntry(1), createAtpEntry(2), createAtpEntry(3))) | ||
| val unusedIds = dao.getIdsOlderThan(nowAsEpochMilliseconds() + 10, 2) | ||
| assertEquals(2, unusedIds.size) | ||
| } | ||
|
|
||
| @Test fun clear() { | ||
| dao.putAll(listOf(createAtpEntry(1), createAtpEntry(2), createAtpEntry(3))) | ||
| dao.clear() | ||
| assertTrue(dao.getAll(listOf(1L, 2L, 3L)).isEmpty()) | ||
| } | ||
| } | ||
|
|
||
| private fun createAtpEntry( | ||
| id: Long = 5, | ||
| position: LatLon = LatLon(1.0, 1.0), | ||
| osmMatch: ElementKey = ElementKey(NODE, 1), | ||
| tagsInATP: Map<String, String> = mapOf(), | ||
| tagsInOSM: Map<String, String> = mapOf(), | ||
| reportType: ReportType = ReportType.OPENING_HOURS_REPORTED_AS_OUTDATED_IN_OPENSTREETMAP, | ||
| ) = AtpEntry( | ||
| position = position, | ||
| id = id, | ||
| osmMatch = osmMatch, | ||
| tagsInATP = tagsInATP, | ||
| tagsInOSM = tagsInOSM, | ||
| reportType = reportType, | ||
| ) | ||
63 changes: 63 additions & 0 deletions
63
...tedTest/kotlin/de/westnordost/streetcomplete/data/atp/atpquests/AtpQuestsHiddenDaoTest.kt
This file contains hidden or 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,63 @@ | ||
| package de.westnordost.streetcomplete.data.atp.atpquests | ||
|
|
||
| import de.westnordost.streetcomplete.data.ApplicationDbTestCase | ||
| import de.westnordost.streetcomplete.util.ktx.nowAsEpochMilliseconds | ||
| import kotlinx.coroutines.delay | ||
| import kotlinx.coroutines.runBlocking | ||
| import kotlin.test.BeforeTest | ||
| import kotlin.test.Test | ||
| import kotlin.test.assertEquals | ||
| import kotlin.test.assertFalse | ||
| import kotlin.test.assertNotNull | ||
| import kotlin.test.assertNull | ||
| import kotlin.test.assertTrue | ||
|
|
||
| class AtpQuestsHiddenDaoTest : ApplicationDbTestCase() { | ||
| private lateinit var dao: AtpQuestsHiddenDao | ||
|
|
||
| @BeforeTest fun createDao() { | ||
| dao = AtpQuestsHiddenDao(database) | ||
| } | ||
|
|
||
| @Test fun addGetDelete() { | ||
| assertFalse(dao.delete(123L)) | ||
| dao.add(123L) | ||
| assertNotNull(dao.getTimestamp(123L)) | ||
| assertTrue(dao.delete(123L)) | ||
| assertFalse(dao.delete(123L)) | ||
| assertNull(dao.getTimestamp(123L)) | ||
| } | ||
|
|
||
| @Test fun getAll() { | ||
| dao.add(1L) | ||
| dao.add(2L) | ||
| assertEquals( | ||
| setOf(1L, 2L), | ||
| dao.getAll().map { it.allThePlacesEntryId }.toSet() | ||
| ) | ||
| } | ||
|
|
||
| @Test fun getNewerThan() = runBlocking { | ||
| dao.add(1L) | ||
| delay(200) | ||
| val time = nowAsEpochMilliseconds() | ||
| dao.add(2L) | ||
| val result = dao.getNewerThan(time - 100).single() | ||
| assertEquals(2L, result.allThePlacesEntryId) | ||
| } | ||
|
|
||
| @Test fun deleteAll() { | ||
| assertEquals(0, dao.deleteAll()) | ||
| dao.add(1L) | ||
| dao.add(2L) | ||
| assertEquals(2, dao.deleteAll()) | ||
| assertNull(dao.getTimestamp(1L)) | ||
| assertNull(dao.getTimestamp(2L)) | ||
| } | ||
|
|
||
| @Test fun countAll() { | ||
| assertEquals(0, dao.countAll()) | ||
| dao.add(3L) | ||
| assertEquals(1, dao.countAll()) | ||
| } | ||
| } |
This file contains hidden or 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 hidden or 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
153 changes: 153 additions & 0 deletions
153
app/src/androidMain/kotlin/de/westnordost/streetcomplete/data/quest/atp/AtpCreateForm.kt
This file contains hidden or 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,153 @@ | ||
| package de.westnordost.streetcomplete.data.quest.atp | ||
|
|
||
| import android.location.Location | ||
| import android.os.Bundle | ||
| import android.view.View | ||
| import androidx.core.os.bundleOf | ||
| import de.westnordost.osmfeatures.FeatureDictionary | ||
| import de.westnordost.streetcomplete.R | ||
| import de.westnordost.streetcomplete.data.atp.AtpEntry | ||
| import de.westnordost.streetcomplete.data.location.SurveyChecker | ||
| import de.westnordost.streetcomplete.data.osm.edits.AddElementEditsController | ||
| import de.westnordost.streetcomplete.data.osm.edits.ElementEditAction | ||
| import de.westnordost.streetcomplete.data.osm.edits.ElementEditType | ||
| import de.westnordost.streetcomplete.data.osm.edits.ElementEditsController | ||
| import de.westnordost.streetcomplete.data.osm.edits.create.CreateNodeAction | ||
| import de.westnordost.streetcomplete.data.osm.geometry.ElementGeometry | ||
| import de.westnordost.streetcomplete.data.osm.mapdata.LatLon | ||
| import de.westnordost.streetcomplete.data.osm.mapdata.Node | ||
| import de.westnordost.streetcomplete.data.quest.QuestKey | ||
| import de.westnordost.streetcomplete.data.visiblequests.HideQuestController | ||
| import de.westnordost.streetcomplete.data.visiblequests.QuestsHiddenController | ||
| import de.westnordost.streetcomplete.quests.AbstractQuestForm | ||
| import de.westnordost.streetcomplete.quests.AnswerItem | ||
| import de.westnordost.streetcomplete.util.getNameAndLocationSpanned | ||
| import de.westnordost.streetcomplete.util.ktx.viewLifecycleScope | ||
| import de.westnordost.streetcomplete.view.confirmIsSurvey | ||
| import kotlinx.coroutines.Dispatchers | ||
| import kotlinx.coroutines.launch | ||
| import kotlinx.coroutines.withContext | ||
| import kotlinx.serialization.json.Json | ||
| import org.koin.android.ext.android.inject | ||
| import org.koin.core.qualifier.named | ||
| import kotlin.getValue | ||
|
|
||
| class AtpCreateForm : AbstractQuestForm() { | ||
| private val hiddenQuestsController: QuestsHiddenController by inject() | ||
| private val featureDictionaryLazy: Lazy<FeatureDictionary> by inject(named("FeatureDictionaryLazy")) | ||
| private val elementEditsController: ElementEditsController by inject() | ||
| private val surveyChecker: SurveyChecker by inject() | ||
|
|
||
| private lateinit var entry: AtpEntry private set | ||
| private val featureDictionary: FeatureDictionary get() = featureDictionaryLazy.value | ||
| var hideQuestController: HideQuestController = hiddenQuestsController | ||
| var selectedLocation: LatLon? = null | ||
| var addElementEditsController: AddElementEditsController = elementEditsController | ||
|
|
||
| override fun onClickMapAt(position: LatLon, clickAreaSizeInMeters: Double): Boolean { | ||
| selectedLocation = position | ||
| checkIsFormComplete() | ||
| return true | ||
| } | ||
|
|
||
| override fun onClickOk() { | ||
| if(selectedLocation == null) { | ||
| return | ||
| } else { | ||
| viewLifecycleScope.launch { // viewLifecycleScope is here via cargo cult - what it is doing and is it needed TODO | ||
| applyEdit(CreateNodeAction(selectedLocation!!, entry.tagsInATP)) | ||
| } | ||
| } | ||
| } | ||
|
|
||
| protected fun applyEdit(answer: ElementEditAction, geometry: ElementGeometry = this.geometry) { | ||
| viewLifecycleScope.launch { | ||
| solve(answer, geometry) | ||
| } | ||
| } | ||
|
|
||
| private suspend fun solve(action: ElementEditAction, geometry: ElementGeometry) { | ||
| setLocked(true) | ||
| val isSurvey = surveyChecker.checkIsSurvey(geometry) | ||
| if (!isSurvey && !confirmIsSurvey(requireContext())) { | ||
| setLocked(false) | ||
| return | ||
| } | ||
|
|
||
| withContext(Dispatchers.IO) { | ||
| addElementEditsController.add(CreatePoiBasedOnAtp, geometry, "survey", action, isSurvey) | ||
| } | ||
| listener?.onEdited(CreatePoiBasedOnAtp, geometry) | ||
| } | ||
| override fun isFormComplete(): Boolean { | ||
| return selectedLocation != null | ||
| } | ||
|
|
||
| override fun onCreate(savedInstanceState: Bundle?) { | ||
| super.onCreate(savedInstanceState) | ||
|
|
||
| val args = requireArguments() | ||
| entry = Json.decodeFromString(args.getString(ATP_ENTRY)!!) | ||
| } | ||
|
|
||
| override fun onViewCreated(view: View, savedInstanceState: Bundle?) { | ||
| super.onViewCreated(view, savedInstanceState) | ||
|
|
||
| // TODO: maybe should be more prominent? | ||
| setTitleHintLabel(getNameAndLocationSpanned(Node( | ||
| 1, | ||
| position = entry.position, | ||
| tags = entry.tagsInATP, | ||
| version = 1, | ||
| timestampEdited = 1, | ||
| ), resources, featureDictionary)) | ||
| } | ||
|
|
||
| override fun onStart() { | ||
| super.onStart() | ||
| updateButtonPanel() | ||
| } | ||
|
|
||
| protected fun updateButtonPanel() { | ||
| // TODO: create answers to send to API, not just hide quests | ||
| val mappedAlready = AnswerItem(R.string.quest_atp_add_missing_poi_mapped_already) { /*applyAnswer(false)*/ hideQuest() } | ||
| val missing = AnswerItem(R.string.quest_atp_add_missing_poi_does_not_exist) { /*applyAnswer(true)*/ hideQuest() } | ||
| val cantSay = AnswerItem(R.string.quest_generic_answer_notApplicable) { hideQuest() /* no option to leave note */ } | ||
|
|
||
| setButtonPanelAnswers(listOf(mappedAlready, missing, cantSay)) | ||
| } | ||
|
|
||
| interface Listener { | ||
| /** The GPS position at which the user is displayed at */ | ||
| val displayedMapLocation: Location? | ||
|
|
||
| /** Called when the user successfully answered the quest */ | ||
| fun onEdited(editType: ElementEditType, geometry: ElementGeometry) | ||
|
|
||
| /** Called when the user successfully answered the quest */ | ||
| // TODO actually use that (or remove, if not needed) | ||
| fun onRejectedAtpEntry(editType: ElementEditType, geometry: ElementGeometry) | ||
|
|
||
| /** Called when the user chose to move the node */ | ||
| fun onMoveNode(editType: ElementEditType, node: Node) | ||
|
|
||
| /** Called when the user chose to hide the quest instead */ | ||
| fun onQuestHidden(questKey: QuestKey) | ||
| } | ||
| private val listener: Listener? get() = parentFragment as? Listener ?: activity as? Listener | ||
|
|
||
| protected fun hideQuest() { | ||
| viewLifecycleScope.launch { | ||
| withContext(Dispatchers.IO) { hideQuestController.hide(questKey) } | ||
| listener?.onQuestHidden(questKey) | ||
| } | ||
| } | ||
|
|
||
| companion object { | ||
| private const val ATP_ENTRY = "atp_entry" | ||
|
|
||
| fun createArguments(entry: AtpEntry) = bundleOf( | ||
| ATP_ENTRY to Json.encodeToString(entry) | ||
| ) | ||
| } | ||
| } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.