From 88ed465232db042eebf1baaa1758bbd0e71d89a9 Mon Sep 17 00:00:00 2001 From: Tobias Zwick Date: Mon, 23 May 2022 19:36:37 +0200 Subject: [PATCH] indicate in create note dialog that a GPX is attached (#3573) --- .../quests/CreateNoteFragment.kt | 20 ++++++++++++++++++ .../note_discussion/AttachPhotoFragment.kt | 3 +++ .../screens/main/MainFragment.kt | 2 +- .../main/res/drawable/ic_attach_gpx_24dp.xml | 10 +++++++++ .../main/res/layout/fragment_attach_photo.xml | 21 +++++++++++++++---- app/src/main/res/raw/changelog.yml | 2 +- res/graphics/note/attach_gpx_24dp.svg | 4 ++++ 7 files changed, 56 insertions(+), 6 deletions(-) create mode 100644 app/src/main/res/drawable/ic_attach_gpx_24dp.xml create mode 100644 res/graphics/note/attach_gpx_24dp.svg diff --git a/app/src/main/java/de/westnordost/streetcomplete/quests/CreateNoteFragment.kt b/app/src/main/java/de/westnordost/streetcomplete/quests/CreateNoteFragment.kt index 22d568b68c..6e66097f10 100644 --- a/app/src/main/java/de/westnordost/streetcomplete/quests/CreateNoteFragment.kt +++ b/app/src/main/java/de/westnordost/streetcomplete/quests/CreateNoteFragment.kt @@ -12,10 +12,13 @@ import android.view.animation.Animation import android.view.animation.AnimationSet import android.view.animation.BounceInterpolator import android.view.animation.TranslateAnimation +import androidx.core.os.bundleOf import androidx.core.view.isGone import de.westnordost.streetcomplete.R import de.westnordost.streetcomplete.databinding.FormLeaveNoteBinding import de.westnordost.streetcomplete.databinding.FragmentCreateNoteBinding +import de.westnordost.streetcomplete.quests.note_discussion.AttachPhotoFragment +import de.westnordost.streetcomplete.util.ktx.childFragmentManagerOrNull import de.westnordost.streetcomplete.util.ktx.getLocationInWindow import de.westnordost.streetcomplete.util.ktx.hideKeyboard import de.westnordost.streetcomplete.util.viewBinding @@ -47,6 +50,15 @@ class CreateNoteFragment : AbstractCreateNoteFragment() { } private val listener: Listener? get() = parentFragment as? Listener ?: activity as? Listener + override fun onCreate(savedInstanceState: Bundle?) { + super.onCreate(savedInstanceState) + childFragmentManagerOrNull?.addFragmentOnAttachListener { fragmentManager, fragment -> + if (fragment is AttachPhotoFragment) { + fragment.hasGpxAttached = arguments?.getBoolean(ARG_HAS_GPX_ATTACHED) ?: false + } + } + } + override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View { _binding = FragmentCreateNoteBinding.inflate(inflater, container, false) inflater.inflate(R.layout.form_leave_note, bottomSheetBinding.content) @@ -118,4 +130,12 @@ class CreateNoteFragment : AbstractCreateNoteFragment() { listener?.onCreatedNote(text, imagePaths, screenPos) } + + companion object { + private const val ARG_HAS_GPX_ATTACHED = "hasGpxAttached" + + fun create(hasGpxAttached: Boolean) = CreateNoteFragment().also { + it.arguments = bundleOf(ARG_HAS_GPX_ATTACHED to hasGpxAttached) + } + } } diff --git a/app/src/main/java/de/westnordost/streetcomplete/quests/note_discussion/AttachPhotoFragment.kt b/app/src/main/java/de/westnordost/streetcomplete/quests/note_discussion/AttachPhotoFragment.kt index 155eb1e8a4..db6f4eb909 100644 --- a/app/src/main/java/de/westnordost/streetcomplete/quests/note_discussion/AttachPhotoFragment.kt +++ b/app/src/main/java/de/westnordost/streetcomplete/quests/note_discussion/AttachPhotoFragment.kt @@ -29,6 +29,7 @@ class AttachPhotoFragment : Fragment(R.layout.fragment_attach_photo) { private lateinit var noteImageAdapter: NoteImageAdapter val imagePaths: List get() = noteImageAdapter.list + var hasGpxAttached = false override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) @@ -46,6 +47,8 @@ class AttachPhotoFragment : Fragment(R.layout.fragment_attach_photo) { binding.photosList.adapter = noteImageAdapter noteImageAdapter.registerAdapterDataObserver(AdapterDataChangedWatcher { updateHintVisibility() }) + binding.attachedGpxView.isGone = !hasGpxAttached + updateHintVisibility() } diff --git a/app/src/main/java/de/westnordost/streetcomplete/screens/main/MainFragment.kt b/app/src/main/java/de/westnordost/streetcomplete/screens/main/MainFragment.kt index afa97f64c2..2eb6a1d467 100644 --- a/app/src/main/java/de/westnordost/streetcomplete/screens/main/MainFragment.kt +++ b/app/src/main/java/de/westnordost/streetcomplete/screens/main/MainFragment.kt @@ -741,7 +741,7 @@ class MainFragment : mapFragment.updateCameraPosition { position = offsetPos } freezeMap() - showInBottomSheet(CreateNoteFragment()) + showInBottomSheet(CreateNoteFragment.create(mapFragment.recordedTracks.isNotEmpty())) } private fun onClickCreateTrack() { diff --git a/app/src/main/res/drawable/ic_attach_gpx_24dp.xml b/app/src/main/res/drawable/ic_attach_gpx_24dp.xml new file mode 100644 index 0000000000..4a5f21dda3 --- /dev/null +++ b/app/src/main/res/drawable/ic_attach_gpx_24dp.xml @@ -0,0 +1,10 @@ + + + diff --git a/app/src/main/res/layout/fragment_attach_photo.xml b/app/src/main/res/layout/fragment_attach_photo.xml index a1feb6a708..25457a4372 100644 --- a/app/src/main/res/layout/fragment_attach_photo.xml +++ b/app/src/main/res/layout/fragment_attach_photo.xml @@ -1,9 +1,9 @@ - + + Enhancements and Fixes
  • Clarify a lot of wordings in American English (#4030) by @ZeLonewolf
  • -
  • Various minor enhancements and fixes (#4015, ...), thanks @Helium314
  • +
  • Various minor enhancements, wording improvements and fixes (#4015, #4042, #4001, #4039, #4032...), thanks @Helium314, @peternewman, @riQQ
v43.2: | diff --git a/res/graphics/note/attach_gpx_24dp.svg b/res/graphics/note/attach_gpx_24dp.svg new file mode 100644 index 0000000000..7c0178bd31 --- /dev/null +++ b/res/graphics/note/attach_gpx_24dp.svg @@ -0,0 +1,4 @@ + + + +