From c2696936250d96b1df24c79cf1fd08400addd57b Mon Sep 17 00:00:00 2001 From: Pratham Pahariya <54663429+Pratham2305@users.noreply.github.com> Date: Mon, 5 Apr 2021 13:33:11 +0530 Subject: [PATCH] Fixes #4296 - "Is this a picture of ...": Not too clear about which image it is asking me about (#4317) * fix issue 4296 * minor improvements * minor improvement Co-authored-by: Pratham2305 --- .../UploadMediaDetailFragment.java | 44 +++++++++++++++++-- .../main/res/layout/custom_nearby_found.xml | 17 +++++++ app/src/main/res/values/strings.xml | 4 +- 3 files changed, 60 insertions(+), 5 deletions(-) create mode 100644 app/src/main/res/layout/custom_nearby_found.xml diff --git a/app/src/main/java/fr/free/nrw/commons/upload/mediaDetails/UploadMediaDetailFragment.java b/app/src/main/java/fr/free/nrw/commons/upload/mediaDetails/UploadMediaDetailFragment.java index f0be05451..a029db761 100644 --- a/app/src/main/java/fr/free/nrw/commons/upload/mediaDetails/UploadMediaDetailFragment.java +++ b/app/src/main/java/fr/free/nrw/commons/upload/mediaDetails/UploadMediaDetailFragment.java @@ -85,6 +85,19 @@ public class UploadMediaDetailFragment extends UploadBaseFragment implements private boolean isExpanded = true; + /** + * showNearbyFound will be true, if any nearby location found that needs pictures and the nearby popup is yet to be shown + * Used to show and check if the nearby found popup is already shown + */ + private boolean showNearbyFound; + + /** + * nearbyPlace holds the detail of nearby place that need pictures, if any found + */ + private Place nearbyPlace; + private UploadItem uploadItem; + + private UploadMediaDetailFragmentCallback callback; public void setCallback(UploadMediaDetailFragmentCallback callback) { @@ -232,13 +245,30 @@ public class UploadMediaDetailFragment extends UploadBaseFragment implements } /** - * Shows popup if any nearby location needing pictures matches uploadable picture's GPS location + * Sets variables to Show popup if any nearby location needing pictures matches uploadable picture's GPS location * @param uploadItem * @param place */ - @SuppressLint("StringFormatInvalid") @Override public void onNearbyPlaceFound(UploadItem uploadItem, Place place) { + nearbyPlace = place; + this.uploadItem = uploadItem; + showNearbyFound = true; + if(callback.getIndexInViewFlipper(this) == 0) { + showNearbyPlaceFound(nearbyPlace); + showNearbyFound = false; + } + } + + /** + * Shows nearby place found popup + * @param place + */ + @SuppressLint("StringFormatInvalid") // To avoid the unwanted lint warning that string 'upload_nearby_place_found_description' is not of a valid format + private void showNearbyPlaceFound(Place place) { + final View customLayout = getLayoutInflater().inflate(R.layout.custom_nearby_found, null); + ImageView nearbyFoundImage = customLayout.findViewById(R.id.nearbyItemImage); + nearbyFoundImage.setImageURI(uploadItem.getMediaUri()); DialogUtil.showAlertDialog(getActivity(), getString(R.string.upload_nearby_place_found_title), String.format(Locale.getDefault(), @@ -249,7 +279,8 @@ public class UploadMediaDetailFragment extends UploadBaseFragment implements }, () -> { - }); + }, + customLayout, true); } @Override @@ -262,10 +293,17 @@ public class UploadMediaDetailFragment extends UploadBaseFragment implements callback.onNextButtonClicked(callback.getIndexInViewFlipper(this)); } + /** + * This method gets called whenever the next/previous button is pressed + */ @Override protected void onBecameVisible() { super.onBecameVisible(); presenter.fetchTitleAndDescription(callback.getIndexInViewFlipper(this)); + if(showNearbyFound) { + showNearbyPlaceFound(nearbyPlace); + showNearbyFound = false; + } } @Override diff --git a/app/src/main/res/layout/custom_nearby_found.xml b/app/src/main/res/layout/custom_nearby_found.xml new file mode 100644 index 000000000..72dac5dff --- /dev/null +++ b/app/src/main/res/layout/custom_nearby_found.xml @@ -0,0 +1,17 @@ + + + + + + diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index d423e0fa6..a0ec78382 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -460,8 +460,8 @@ Upload your first media by tapping on the add button. Featured pictures are images from highly skilled photographers and illustrators that the Wikimedia Commons community has chosen as some of the highest quality on the site. Images Uploaded via Nearby places are the images which are uploaded by discovering places on the map. This feature allows editors to send a Thank you notification to users who make useful edits – by using a small thank link on the history page or diff page. - Copy to subsequent Media - Copied Successfully + Copy to subsequent media + Copied Examples of good images to upload to Commons Examples of images not to upload Skip this image