Skip to content

Commit 8aee7a6

Browse files
authored
Fixes copy to subsequent media functionality for nearby uploaded images (commons-app#5326)
1 parent fd6ba00 commit 8aee7a6

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

app/src/main/java/fr/free/nrw/commons/upload/mediaDetails/UploadMediaDetailFragment.java

+24
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
import android.annotation.SuppressLint;
88
import android.content.Intent;
99
import android.os.Bundle;
10+
import android.text.TextUtils;
1011
import android.view.LayoutInflater;
1112
import android.view.View;
1213
import android.view.View.OnClickListener;
@@ -546,6 +547,29 @@ public void editLocation(final String latitude, final String longitude, final do
546547
@Override
547548
public void updateMediaDetails(List<UploadMediaDetail> uploadMediaDetails) {
548549
uploadMediaDetailAdapter.setItems(uploadMediaDetails);
550+
showNearbyFound =
551+
showNearbyFound && (
552+
uploadMediaDetails == null || uploadMediaDetails.isEmpty() || listContainsEmptyDetails(
553+
uploadMediaDetails));
554+
}
555+
556+
/**
557+
* if the media details that come in here are empty
558+
* (empty caption AND empty description, with caption being the decider here)
559+
* this method allows usage of nearby place caption and description if any
560+
* else it takes the media details saved in prior for this picture
561+
* @param uploadMediaDetails saved media details,
562+
* ex: in case when "copy to subsequent media" button is clicked
563+
* for a previous image
564+
* @return boolean whether the details are empty or not
565+
*/
566+
private boolean listContainsEmptyDetails(List<UploadMediaDetail> uploadMediaDetails) {
567+
for (UploadMediaDetail uploadDetail: uploadMediaDetails) {
568+
if (!TextUtils.isEmpty(uploadDetail.getCaptionText()) && !TextUtils.isEmpty(uploadDetail.getDescriptionText())) {
569+
return false;
570+
}
571+
}
572+
return true;
549573
}
550574

551575
/**

0 commit comments

Comments
 (0)