From ba7348f83f68ec52fc93e22086b04bc57ee18d28 Mon Sep 17 00:00:00 2001 From: Hanna Truong Date: Tue, 22 Oct 2024 23:27:40 +1100 Subject: [PATCH] Fixes issue #5841: Nearby pins: Make it easier to understand what the colors mean (#5881) * UI design for legend to explain the colors of the nearby pins * Add listener for the button to toggle the visibility of the legend (make it hideable) * Change wording for legend and make text localizable * Fixed typo * Fixed typo --------- Co-authored-by: Nicolas Raoul --- .../fragments/NearbyParentFragment.java | 15 ++++ .../res/layout/fragment_nearby_parent.xml | 27 +++++++ app/src/main/res/layout/nearby_legend.xml | 74 +++++++++++++++++++ app/src/main/res/values/strings.xml | 3 + 4 files changed, 119 insertions(+) create mode 100644 app/src/main/res/layout/nearby_legend.xml diff --git a/app/src/main/java/fr/free/nrw/commons/nearby/fragments/NearbyParentFragment.java b/app/src/main/java/fr/free/nrw/commons/nearby/fragments/NearbyParentFragment.java index 8a3c0c330..f578afc25 100644 --- a/app/src/main/java/fr/free/nrw/commons/nearby/fragments/NearbyParentFragment.java +++ b/app/src/main/java/fr/free/nrw/commons/nearby/fragments/NearbyParentFragment.java @@ -43,6 +43,7 @@ import android.view.ViewGroup; import android.view.ViewGroup.LayoutParams; import android.view.animation.Animation; import android.view.animation.AnimationUtils; +import android.widget.Button; import android.widget.Toast; import androidx.activity.result.ActivityResultCallback; import androidx.activity.result.ActivityResultLauncher; @@ -52,6 +53,7 @@ import androidx.annotation.DrawableRes; import androidx.annotation.NonNull; import androidx.annotation.Nullable; import androidx.appcompat.app.AlertDialog.Builder; +import androidx.constraintlayout.widget.ConstraintLayout; import androidx.core.content.ContextCompat; import androidx.core.content.FileProvider; import androidx.recyclerview.widget.DividerItemDecoration; @@ -218,6 +220,8 @@ public class NearbyParentFragment extends CommonsDaggerSupportFragment private LatLng updatedLatLng; private boolean searchable; + private ConstraintLayout nearbyLegend; + private GridLayoutManager gridLayoutManager; private List dataList; private BottomSheetAdapter bottomSheetAdapter; @@ -302,6 +306,7 @@ public class NearbyParentFragment extends CommonsDaggerSupportFragment progressDialog.setCancelable(false); progressDialog.setMessage("Saving in progress..."); setHasOptionsMenu(true); + // Inflate the layout for this fragment return view; @@ -362,6 +367,16 @@ public class NearbyParentFragment extends CommonsDaggerSupportFragment } locationPermissionsHelper = new LocationPermissionsHelper(getActivity(), locationManager, this); + + // Set up the floating activity button to toggle the visibility of the legend + binding.fabLegend.setOnClickListener(v -> { + if (binding.nearbyLegendLayout.getRoot().getVisibility() == View.VISIBLE) { + binding.nearbyLegendLayout.getRoot().setVisibility(View.GONE); + } else { + binding.nearbyLegendLayout.getRoot().setVisibility(View.VISIBLE); + } + }); + presenter.attachView(this); isPermissionDenied = false; recenterToUserLocation = false; diff --git a/app/src/main/res/layout/fragment_nearby_parent.xml b/app/src/main/res/layout/fragment_nearby_parent.xml index e5002fe11..e1d82e6e7 100644 --- a/app/src/main/res/layout/fragment_nearby_parent.xml +++ b/app/src/main/res/layout/fragment_nearby_parent.xml @@ -124,6 +124,33 @@ app:srcCompat="@drawable/ic_my_location_black_24dp" app:useCompatPadding="true" /> + + + + + + + + + + + + + + + + + + + diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index b5c2dc529..f9de8e051 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -832,4 +832,7 @@ Upload your first media by tapping on the add button. Pending Failed Could not load place data + This place has no picture yet, go take one! + This place has a picture already. + Now checking whether this place has a picture.