Fixes copy to subsequent media functionality for nearby uploaded images (#5326)

This commit is contained in:
Srishti Rohatgi 2023-10-07 03:40:28 +05:30 committed by GitHub
parent fd6ba00fbd
commit 8aee7a680d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -7,6 +7,7 @@ import static fr.free.nrw.commons.utils.ImageUtils.getErrorMessageForResult;
import android.annotation.SuppressLint; import android.annotation.SuppressLint;
import android.content.Intent; import android.content.Intent;
import android.os.Bundle; import android.os.Bundle;
import android.text.TextUtils;
import android.view.LayoutInflater; import android.view.LayoutInflater;
import android.view.View; import android.view.View;
import android.view.View.OnClickListener; import android.view.View.OnClickListener;
@ -546,6 +547,29 @@ public class UploadMediaDetailFragment extends UploadBaseFragment implements
@Override @Override
public void updateMediaDetails(List<UploadMediaDetail> uploadMediaDetails) { public void updateMediaDetails(List<UploadMediaDetail> uploadMediaDetails) {
uploadMediaDetailAdapter.setItems(uploadMediaDetails); uploadMediaDetailAdapter.setItems(uploadMediaDetails);
showNearbyFound =
showNearbyFound && (
uploadMediaDetails == null || uploadMediaDetails.isEmpty() || listContainsEmptyDetails(
uploadMediaDetails));
}
/**
* if the media details that come in here are empty
* (empty caption AND empty description, with caption being the decider here)
* this method allows usage of nearby place caption and description if any
* else it takes the media details saved in prior for this picture
* @param uploadMediaDetails saved media details,
* ex: in case when "copy to subsequent media" button is clicked
* for a previous image
* @return boolean whether the details are empty or not
*/
private boolean listContainsEmptyDetails(List<UploadMediaDetail> uploadMediaDetails) {
for (UploadMediaDetail uploadDetail: uploadMediaDetails) {
if (!TextUtils.isEmpty(uploadDetail.getCaptionText()) && !TextUtils.isEmpty(uploadDetail.getDescriptionText())) {
return false;
}
}
return true;
} }
/** /**