From a75b6373cacb60b246470339e627a6560411a971 Mon Sep 17 00:00:00 2001 From: Kai Michael Poppe Date: Thu, 3 Oct 2024 22:55:10 +0200 Subject: [PATCH] Display object note above quest and overlay answers (#5889) * Display object note in hint - v1 If it exists, the `note` tag for an object is shown in the QuestHint. * Display object note for BusStopName Adding Bus Stop Name in the mix also. * Revert "Display object note for BusStopName" This reverts commit c6ee10d1aa84b6e22d04a2e1e9230f6426516d72. * Revert "Display object note in hint - v1" This reverts commit bacbfdbec8e62e2a3696ba9650234f5d3425dc58. * Refactor - v2 Added labels to fragment_quest_answer and made it display a note whenever a quest will be answered. * Display note as a separate bubble * Quest Fragement Layout Removed Nested Scroll View (https://github.com/streetcomplete/StreetComplete/pull/5889#discussion_r1753909412) and TextStyles (https://github.com/streetcomplete/StreetComplete/pull/5889#discussion_r1753926539), made `note` text selectabled (copyable) as web links clickable (as per https://github.com/streetcomplete/StreetComplete/pull/5889#issuecomment-2343589663) and * Quest Fragment update Simplifications * Overlays now also display notes * Swap postion of TitleHint and SpeechBubbleNote as per https://github.com/streetcomplete/StreetComplete/pull/5889#issuecomment-2346519764 * Simplyfy addRule and rename variable to what it actually does --- .../overlays/AbstractOverlayForm.kt | 17 ++++++- .../quests/AbstractOsmQuestForm.kt | 1 + .../quests/AbstractQuestForm.kt | 5 ++ app/src/main/res/layout/fragment_overlay.xml | 45 +++++++++++++++++ .../main/res/layout/fragment_quest_answer.xml | 49 +++++++++++++++++++ app/src/main/res/values/strings.xml | 1 + 6 files changed, 117 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/de/westnordost/streetcomplete/overlays/AbstractOverlayForm.kt b/app/src/main/java/de/westnordost/streetcomplete/overlays/AbstractOverlayForm.kt index ac90ebcff9..4f8ab0b53e 100644 --- a/app/src/main/java/de/westnordost/streetcomplete/overlays/AbstractOverlayForm.kt +++ b/app/src/main/java/de/westnordost/streetcomplete/overlays/AbstractOverlayForm.kt @@ -10,6 +10,7 @@ import android.view.Menu import android.view.View import android.view.ViewGroup import android.widget.PopupMenu +import android.widget.RelativeLayout import androidx.annotation.UiThread import androidx.appcompat.app.AlertDialog import androidx.core.os.bundleOf @@ -202,6 +203,7 @@ abstract class AbstractOverlayForm : setTitleHintLabel( element?.let { getNameAndLocationSpanned(it, resources, featureDictionary) } ) + setObjNote(element?.tags?.get("note")) binding.moreButton.setOnClickListener { showOtherAnswers() @@ -250,6 +252,19 @@ abstract class AbstractOverlayForm : _binding = null } + protected fun setObjNote(text: CharSequence?) { + binding.noteLabel.text = text + val titleHintLayout = (binding.titleHintLabelContainer.layoutParams as? RelativeLayout.LayoutParams) + titleHintLayout?.removeRule(RelativeLayout.ABOVE) + titleHintLayout?.addRule(RelativeLayout.ABOVE, + if (binding.noteLabel.text.isEmpty()) + binding.speechbubbleContentContainer.id + else + binding.speechbubbleNoteContainer.id + ) + binding.speechbubbleNoteContainer.isGone = binding.noteLabel.text.isEmpty() + } + /* --------------------------------- IsCloseableBottomSheet ------------------------------- */ @UiThread override fun onClickMapAt(position: LatLon, clickAreaSizeInMeters: Double): Boolean = false @@ -347,7 +362,7 @@ abstract class AbstractOverlayForm : protected abstract fun onClickOk() protected inline fun contentViewBinding( - noinline viewBinder: (View) -> T + noinline viewBinder: (View) -> T, ) = FragmentViewBindingPropertyDelegate(this, viewBinder, R.id.content) /* -------------------------------------- ...-Button -----------------------------------------*/ diff --git a/app/src/main/java/de/westnordost/streetcomplete/quests/AbstractOsmQuestForm.kt b/app/src/main/java/de/westnordost/streetcomplete/quests/AbstractOsmQuestForm.kt index 5138f0592b..d252b3a2ae 100644 --- a/app/src/main/java/de/westnordost/streetcomplete/quests/AbstractOsmQuestForm.kt +++ b/app/src/main/java/de/westnordost/streetcomplete/quests/AbstractOsmQuestForm.kt @@ -119,6 +119,7 @@ abstract class AbstractOsmQuestForm : AbstractQuestForm(), IsShowingQuestDeta setTitle(getString(osmElementQuestType.getTitle(element.tags))) setTitleHintLabel(getNameAndLocationSpanned(element, resources, featureDictionary)) + setObjNote(element.tags["note"]) } override fun onStart() { diff --git a/app/src/main/java/de/westnordost/streetcomplete/quests/AbstractQuestForm.kt b/app/src/main/java/de/westnordost/streetcomplete/quests/AbstractQuestForm.kt index ff6e95b808..55a35b1bd4 100644 --- a/app/src/main/java/de/westnordost/streetcomplete/quests/AbstractQuestForm.kt +++ b/app/src/main/java/de/westnordost/streetcomplete/quests/AbstractQuestForm.kt @@ -2,6 +2,7 @@ package de.westnordost.streetcomplete.quests import android.graphics.drawable.Drawable import android.os.Bundle +import android.text.Editable import android.view.LayoutInflater import android.view.View import android.view.ViewGroup @@ -169,6 +170,10 @@ abstract class AbstractQuestForm : updateInfoButtonVisibility() } + protected fun setObjNote(text: CharSequence?) { + binding.noteLabel.text = text + binding.speechbubbleNoteContainer.isGone = binding.noteLabel.text.isEmpty() + } protected fun setHintImages(images: List) { binding.infoPictures.isGone = images.isEmpty() binding.infoPictures.removeAllViews() diff --git a/app/src/main/res/layout/fragment_overlay.xml b/app/src/main/res/layout/fragment_overlay.xml index cf37f269a5..70388e7c91 100644 --- a/app/src/main/res/layout/fragment_overlay.xml +++ b/app/src/main/res/layout/fragment_overlay.xml @@ -20,6 +20,51 @@ android:id="@+id/bottomSheetContainer" tools:ignore="RtlHardcoded"> + + + + + + + + + + + + + + + + + + + + + + + + + + "Are you sure that it does not exist, not even at a slightly different location? If you’re not sure, leave a note instead. It does not exist Leave note + Another person noted: "Differs along the way…" If it differs along the way, the first step is to split up the way. After that, the quest can be answered for each part separately.\nSplit it now?