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 <Pratham2305@users.noreply.github.com>
This commit is contained in:
Pratham Pahariya 2021-04-05 13:33:11 +05:30 committed by GitHub
parent 24f61a1142
commit c269693625
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 60 additions and 5 deletions

View file

@ -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