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

Display object note above quest and overlay answers #5889

Merged
merged 12 commits into from
Oct 3, 2024
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
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