Skip to content

Commit

Permalink
if note "quest" is shown in frame of overlay and already hidden, prov…
Browse files Browse the repository at this point in the history
…ide ability to just close it
  • Loading branch information
westnordost committed Oct 21, 2022
1 parent bd68112 commit 92b2734
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -66,14 +66,18 @@ class NoteDiscussionForm : AbstractQuestForm() {
interface Listener {
/** Called when the user successfully answered the quest */
fun onNoteQuestSolved(questType: QuestType, noteId: Long, position: LatLon)
/** Called when the user did not answer the quest but also did not hide it */
fun onNoteQuestClosed()
}
private val listener: Listener? get() = parentFragment as? Listener ?: activity as? Listener

override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)

val alreadyHidden = osmNoteQuestController.getVisible(noteId) == null
setButtonPanelAnswers(listOf(
AnswerItem(R.string.quest_noteDiscussion_no) { hideQuest() }
if (alreadyHidden) AnswerItem(R.string.short_no_answer_on_button) { closeQuest() }
else AnswerItem(R.string.quest_noteDiscussion_no) { hideQuest() }
))

binding.noteInput.doAfterTextChanged { checkIsFormComplete() }
Expand Down Expand Up @@ -115,6 +119,10 @@ class NoteDiscussionForm : AbstractQuestForm() {
}
}

private fun closeQuest() {
listener?.onNoteQuestClosed()
}

private fun hideQuest() {
viewLifecycleScope.launch {
withContext(Dispatchers.IO) { osmNoteQuestController.hide(noteId) }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -498,6 +498,10 @@ class MainFragment :
closeBottomSheet()
}

override fun onNoteQuestClosed() {
closeBottomSheet()
}

/* ------------------------------- CreateNoteFragment.Listener ------------------------------ */

override fun onCreatedNote(position: LatLon) {
Expand Down

0 comments on commit 92b2734

Please sign in to comment.