Skip to content

Commit

Permalink
Display object note above quest and overlay answers (#5889)
Browse files Browse the repository at this point in the history
* 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 c6ee10d.

* Revert "Display object note in hint - v1"

This reverts commit bacbfdb.

* 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 (#5889 (comment)) and TextStyles (#5889 (comment)), made `note` text selectabled (copyable) as web links clickable (as per #5889 (comment)) and

* Quest Fragment update

Simplifications

* Overlays now also display notes

* Swap postion of TitleHint and SpeechBubbleNote

as per #5889 (comment)

* Simplyfy addRule and rename variable to what it actually does
  • Loading branch information
kmpoppe authored Oct 3, 2024
1 parent 846070c commit a75b637
Show file tree
Hide file tree
Showing 6 changed files with 117 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -202,6 +203,7 @@ abstract class AbstractOverlayForm :
setTitleHintLabel(
element?.let { getNameAndLocationSpanned(it, resources, featureDictionary) }
)
setObjNote(element?.tags?.get("note"))

binding.moreButton.setOnClickListener {
showOtherAnswers()
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -347,7 +362,7 @@ abstract class AbstractOverlayForm :
protected abstract fun onClickOk()

protected inline fun <reified T : ViewBinding> contentViewBinding(
noinline viewBinder: (View) -> T
noinline viewBinder: (View) -> T,
) = FragmentViewBindingPropertyDelegate(this, viewBinder, R.id.content)

/* -------------------------------------- ...-Button -----------------------------------------*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@ abstract class AbstractOsmQuestForm<T> : AbstractQuestForm(), IsShowingQuestDeta

setTitle(getString(osmElementQuestType.getTitle(element.tags)))
setTitleHintLabel(getNameAndLocationSpanned(element, resources, featureDictionary))
setObjNote(element.tags["note"])
}

override fun onStart() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package de.westnordost.streetcomplete.quests

import android.graphics.drawable.Drawable
import android.os.Bundle
import android.text.Editable

Check failure on line 5 in app/src/main/java/de/westnordost/streetcomplete/quests/AbstractQuestForm.kt

View workflow job for this annotation

GitHub Actions / Kotlin

Unused import
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
Expand Down Expand Up @@ -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<Drawable>) {
binding.infoPictures.isGone = images.isEmpty()
binding.infoPictures.removeAllViews()
Expand Down
45 changes: 45 additions & 0 deletions app/src/main/res/layout/fragment_overlay.xml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,51 @@
android:id="@+id/bottomSheetContainer"
tools:ignore="RtlHardcoded">

<de.westnordost.streetcomplete.view.MaskSpeechbubbleCornersFrameLayout
android:id="@+id/speechbubbleNoteContainer"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@drawable/speech_bubble_none"
android:layout_above="@id/speechbubbleContentContainer"
android:layout_marginStart="@dimen/horizontal_speech_bubble_margin"
android:layout_marginEnd="@dimen/horizontal_speech_bubble_margin"
android:layout_marginBottom="4dp"
android:showDividers="middle"
android:paddingStart="22dp"
android:paddingEnd="22dp"
android:paddingTop="16dp"
android:paddingBottom="16dp"
android:divider="@drawable/space_16dp"
android:elevation="@dimen/speech_bubble_elevation"
android:visibility="gone">

<LinearLayout
android:id="@+id/noteArea"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:showDividers="middle">

<TextView
android:id="@+id/titleNoteLabel"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textAppearance="@style/TextAppearance.TitleMedium"
android:text="@string/note_for_object" />

<TextView
android:id="@+id/noteLabel"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textAppearance="@style/TextAppearance.Body"
android:textStyle="italic"
android:textColor="@color/hint_text"
android:autoLink="web"
android:textIsSelectable="true" />

</LinearLayout>

</de.westnordost.streetcomplete.view.MaskSpeechbubbleCornersFrameLayout>

<de.westnordost.streetcomplete.view.MaskSpeechbubbleCornersFrameLayout
android:id="@+id/titleHintLabelContainer"
Expand Down
49 changes: 49 additions & 0 deletions app/src/main/res/layout/fragment_quest_answer.xml
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,55 @@

</LinearLayout>


<LinearLayout
android:id="@+id/speechbubbleNoteContainer"
android:background="@drawable/speech_bubble_none"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:layout_marginStart="@dimen/horizontal_speech_bubble_margin"
android:layout_marginEnd="@dimen/horizontal_speech_bubble_margin"
android:layout_marginBottom="4dp"
android:showDividers="middle"
android:paddingStart="22dp"
android:paddingEnd="22dp"
android:paddingTop="16dp"
android:paddingBottom="16dp"
android:divider="@drawable/space_16dp"
android:elevation="@dimen/speech_bubble_elevation"
android:visibility="gone">

<LinearLayout
android:id="@+id/noteArea"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:showDividers="middle">

<TextView
android:id="@+id/titleNoteLabel"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textAppearance="@style/TextAppearance.TitleMedium"
android:text="@string/note_for_object" />

<TextView
android:id="@+id/noteLabel"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textAppearance="@style/TextAppearance.Body"
android:textStyle="italic"
android:textColor="@color/hint_text"
android:autoLink="web"
android:textIsSelectable="true" />

</LinearLayout>


</LinearLayout>


<!-- Necessary because even if the bottom sheet is already expanded, the content might
be still too large to fit onto the screen without scrolling (it often is) -->
<androidx.core.widget.NestedScrollView
Expand Down
1 change: 1 addition & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,7 @@ The info you enter is directly added to OpenStreetMap in your name, without the
<string name="osm_element_gone_description">"Are you sure that it does not exist, not even at a slightly different location? If you’re not sure, leave a note instead.</string>
<string name="osm_element_gone_confirmation">It does not exist</string>
<string name="leave_note">Leave note</string>
<string name="note_for_object">Another person noted:</string>

<string name="quest_generic_answer_differs_along_the_way">"Differs along the way…"</string>
<string name="quest_split_way_description">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?</string>
Expand Down

0 comments on commit a75b637

Please sign in to comment.