Skip to content

Commit 091ab1d

Browse files
Bug fix for country code in reverse geo code
1 parent 054db77 commit 091ab1d

File tree

2 files changed

+16
-11
lines changed

2 files changed

+16
-11
lines changed

app/src/main/java/fr/free/nrw/commons/upload/license/MediaLicenseFragment.java

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -95,14 +95,6 @@ public void onClick(View v) {
9595
@Override
9696
public void onResume() {
9797
super.onResume();
98-
/**
99-
* Show the wlm info message if the upload is a WLM upload
100-
*/
101-
if(callback.isWLMUpload() && presenter.isWLMSupportedForThisPlace()){
102-
llInfoMonumentUpload.setVisibility(View.VISIBLE);
103-
}else{
104-
llInfoMonumentUpload.setVisibility(View.GONE);
105-
}
10698
}
10799

108100
/**
@@ -232,4 +224,16 @@ public void onSubmitButtonClicked() {
232224
callback.onNextButtonClicked(callback.getIndexInViewFlipper(this));
233225
}
234226

227+
@Override
228+
protected void onBecameVisible() {
229+
super.onBecameVisible();
230+
/**
231+
* Show the wlm info message if the upload is a WLM upload
232+
*/
233+
if(callback.isWLMUpload() && presenter.isWLMSupportedForThisPlace()){
234+
llInfoMonumentUpload.setVisibility(View.VISIBLE);
235+
}else{
236+
llInfoMonumentUpload.setVisibility(View.GONE);
237+
}
238+
}
235239
}

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

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ public void receiveImage(final UploadableFile uploadableFile, final Place place)
9393
repository
9494
.preProcessImage(uploadableFile, place, this)
9595
.map(uploadItem -> {
96-
if(place.isMonument()){
96+
if(place!=null && place.isMonument()){
9797
if (place.location != null) {
9898
final String countryCode = reverseGeoCode(place.location);
9999
if (countryCode != null && WLM_SUPPORTED_COUNTRIES
@@ -132,8 +132,9 @@ private String reverseGeoCode(final LatLng latLng){
132132
final List<Address> addresses = geocoder
133133
.getFromLocation(latLng.getLatitude(), latLng.getLongitude(), 1);
134134
for (final Address address : addresses) {
135-
if (address != null && address.getLocale().getISO3Country() != null) {
136-
return address.getLocale().getCountry();
135+
if (address != null && address.getCountryCode() != null) {
136+
String countryCode = address.getCountryCode();
137+
return countryCode;
137138
}
138139
}
139140
} catch (final IOException e) {

0 commit comments

Comments
 (0)