Skip to content

Commit ba7348f

Browse files
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 <[email protected]>
1 parent 7b0b604 commit ba7348f

File tree

4 files changed

+119
-0
lines changed

4 files changed

+119
-0
lines changed

app/src/main/java/fr/free/nrw/commons/nearby/fragments/NearbyParentFragment.java

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@
4343
import android.view.ViewGroup.LayoutParams;
4444
import android.view.animation.Animation;
4545
import android.view.animation.AnimationUtils;
46+
import android.widget.Button;
4647
import android.widget.Toast;
4748
import androidx.activity.result.ActivityResultCallback;
4849
import androidx.activity.result.ActivityResultLauncher;
@@ -52,6 +53,7 @@
5253
import androidx.annotation.NonNull;
5354
import androidx.annotation.Nullable;
5455
import androidx.appcompat.app.AlertDialog.Builder;
56+
import androidx.constraintlayout.widget.ConstraintLayout;
5557
import androidx.core.content.ContextCompat;
5658
import androidx.core.content.FileProvider;
5759
import androidx.recyclerview.widget.DividerItemDecoration;
@@ -218,6 +220,8 @@ public class NearbyParentFragment extends CommonsDaggerSupportFragment
218220
private LatLng updatedLatLng;
219221
private boolean searchable;
220222

223+
private ConstraintLayout nearbyLegend;
224+
221225
private GridLayoutManager gridLayoutManager;
222226
private List<BottomSheetItem> dataList;
223227
private BottomSheetAdapter bottomSheetAdapter;
@@ -302,6 +306,7 @@ public View onCreateView(@NonNull final LayoutInflater inflater, final ViewGroup
302306
progressDialog.setCancelable(false);
303307
progressDialog.setMessage("Saving in progress...");
304308
setHasOptionsMenu(true);
309+
305310
// Inflate the layout for this fragment
306311
return view;
307312

@@ -362,6 +367,16 @@ public void onViewCreated(@NonNull final View view, @Nullable final Bundle saved
362367
}
363368
locationPermissionsHelper = new LocationPermissionsHelper(getActivity(), locationManager,
364369
this);
370+
371+
// Set up the floating activity button to toggle the visibility of the legend
372+
binding.fabLegend.setOnClickListener(v -> {
373+
if (binding.nearbyLegendLayout.getRoot().getVisibility() == View.VISIBLE) {
374+
binding.nearbyLegendLayout.getRoot().setVisibility(View.GONE);
375+
} else {
376+
binding.nearbyLegendLayout.getRoot().setVisibility(View.VISIBLE);
377+
}
378+
});
379+
365380
presenter.attachView(this);
366381
isPermissionDenied = false;
367382
recenterToUserLocation = false;

app/src/main/res/layout/fragment_nearby_parent.xml

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,33 @@
124124
app:srcCompat="@drawable/ic_my_location_black_24dp"
125125
app:useCompatPadding="true" />
126126

127+
<com.google.android.material.floatingactionbutton.FloatingActionButton
128+
android:id="@+id/fab_legend"
129+
android:layout_width="wrap_content"
130+
android:layout_height="wrap_content"
131+
android:layout_below="@id/fab_recenter"
132+
android:layout_alignParentEnd="true"
133+
android:layout_alignParentRight="true"
134+
android:clickable="true"
135+
android:visibility="visible"
136+
app:backgroundTint="@color/main_background_light"
137+
app:elevation="@dimen/dimen_6"
138+
app:fabSize="normal"
139+
app:layout_anchorGravity="top|right|end"
140+
app:srcCompat="@drawable/ic_info_outline_24dp"
141+
app:useCompatPadding="true" />
142+
143+
<include
144+
android:id="@+id/nearby_legend_layout"
145+
layout="@layout/nearby_legend"
146+
android:layout_width="wrap_content"
147+
android:layout_height="wrap_content"
148+
android:layout_below="@id/rl_container_wlm_month_message"
149+
android:visibility="gone"
150+
android:layout_marginTop="30dp"
151+
android:layout_marginStart="5dp"
152+
/>
153+
127154
</RelativeLayout>
128155

129156
<FrameLayout
Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
3+
xmlns:app="http://schemas.android.com/apk/res-auto"
4+
xmlns:tools="http://schemas.android.com/tools"
5+
android:layout_width="wrap_content"
6+
android:layout_height="wrap_content"
7+
android:background="#BFFFFFFF"
8+
android:orientation="vertical">
9+
10+
<ImageView
11+
android:id="@+id/imageRed"
12+
android:layout_width="wrap_content"
13+
android:layout_height="wrap_content"
14+
android:layout_marginBottom="0dp"
15+
app:layout_constraintBottom_toTopOf="@+id/imageGreen"
16+
app:layout_constraintEnd_toEndOf="@+id/imageGreen"
17+
app:layout_constraintStart_toStartOf="@+id/imageGreen"
18+
app:srcCompat="@drawable/ic_custom_map_marker_red" />
19+
20+
<TextView
21+
android:id="@+id/textRed"
22+
android:layout_width="wrap_content"
23+
android:layout_height="wrap_content"
24+
android:layout_marginStart="0dp"
25+
android:text="@string/red_pin"
26+
android:textColor="#F74D4D"
27+
android:textSize="12sp"
28+
app:layout_constraintBottom_toBottomOf="@+id/imageRed"
29+
app:layout_constraintStart_toEndOf="@+id/imageRed"
30+
app:layout_constraintTop_toTopOf="@+id/imageRed" />
31+
32+
<ImageView
33+
android:id="@+id/imageGreen"
34+
android:layout_width="wrap_content"
35+
android:layout_height="wrap_content"
36+
android:layout_marginBottom="0dp"
37+
app:layout_constraintBottom_toTopOf="@+id/imageGrey"
38+
app:layout_constraintEnd_toEndOf="@+id/imageGrey"
39+
app:layout_constraintStart_toStartOf="@+id/imageGrey"
40+
app:srcCompat="@drawable/ic_custom_map_marker_green" />
41+
42+
<TextView
43+
android:id="@+id/textGreen"
44+
android:layout_width="wrap_content"
45+
android:layout_height="wrap_content"
46+
android:layout_marginStart="0dp"
47+
android:text="@string/green_pin"
48+
android:textColor="#1F7123"
49+
android:textSize="12sp"
50+
app:layout_constraintBottom_toBottomOf="@+id/imageGreen"
51+
app:layout_constraintStart_toEndOf="@+id/imageGreen"
52+
app:layout_constraintTop_toTopOf="@+id/imageGreen" />
53+
54+
<ImageView
55+
android:id="@+id/imageGrey"
56+
android:layout_width="wrap_content"
57+
android:layout_height="wrap_content"
58+
android:layout_marginStart="0dp"
59+
app:layout_constraintBottom_toBottomOf="parent"
60+
app:layout_constraintStart_toStartOf="parent"
61+
app:srcCompat="@drawable/ic_custom_map_marker_grey" />
62+
63+
<TextView
64+
android:id="@+id/textGrey"
65+
android:layout_width="wrap_content"
66+
android:layout_height="wrap_content"
67+
android:text="@string/grey_pin"
68+
android:textColor="#454547"
69+
android:textSize="12sp"
70+
app:layout_constraintBottom_toBottomOf="@+id/imageGrey"
71+
app:layout_constraintStart_toEndOf="@+id/imageGrey"
72+
app:layout_constraintTop_toTopOf="@+id/imageGrey" />
73+
74+
</androidx.constraintlayout.widget.ConstraintLayout>

app/src/main/res/values/strings.xml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -832,4 +832,7 @@ Upload your first media by tapping on the add button.</string>
832832
<string name="pending">Pending</string>
833833
<string name="failed">Failed</string>
834834
<string name="could_not_load_place_data">Could not load place data</string>
835+
<string name="red_pin">This place has no picture yet, go take one!</string>
836+
<string name="green_pin">This place has a picture already.</string>
837+
<string name="grey_pin">Now checking whether this place has a picture.</string>
835838
</resources>

0 commit comments

Comments
 (0)