Fixes #4281 "Wrong language pre-selected in Nearby upload" (#4285)

* location added

* tests

* changes requested

* comments

* Test fixed, minor improvement
This commit is contained in:
Aditya-Srivastav 2021-03-04 18:21:28 +05:30 committed by GitHub
parent 91a5aa1abe
commit 7a5774e479
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
9 changed files with 88 additions and 33 deletions

View file

@ -18,6 +18,7 @@ import timber.log.Timber;
*/
public class Place implements Parcelable {
public final String language;
public final String name;
private final Label label;
private final String longDescription;
@ -30,7 +31,8 @@ public class Place implements Parcelable {
public final Sitelinks siteLinks;
public Place(String name, Label label, String longDescription, LatLng location, String category, Sitelinks siteLinks, String pic, String destroyed) {
public Place(String language,String name, Label label, String longDescription, LatLng location, String category, Sitelinks siteLinks, String pic, String destroyed) {
this.language = language;
this.name = name;
this.label = label;
this.longDescription = longDescription;
@ -40,8 +42,8 @@ public class Place implements Parcelable {
this.pic = (pic == null) ? "":pic;
this.destroyed = (destroyed == null) ? "":destroyed;
}
public Place(Parcel in) {
this.language = in.readString();
this.name = in.readString();
this.label = (Label) in.readSerializable();
this.longDescription = in.readString();
@ -53,7 +55,6 @@ public class Place implements Parcelable {
String destroyedString = in.readString();
this.destroyed = (destroyedString == null) ? "":destroyedString;
}
public static Place from(NearbyResultItem item) {
String itemClass = item.getClassName().getValue();
String classEntityId = "";
@ -61,6 +62,7 @@ public class Place implements Parcelable {
classEntityId = itemClass.replace("http://www.wikidata.org/entity/", "");
}
return new Place(
item.getLabel().getLanguage(),
item.getLabel().getValue(),
Label.fromText(classEntityId), // list
item.getClassLabel().getValue(), // details
@ -75,6 +77,14 @@ public class Place implements Parcelable {
item.getDestroyed().getValue());
}
/**
* Gets the language of the caption ie name.
* @return language
*/
public String getLanguage() {
return language;
}
/**
* Gets the name of the place
* @return name
@ -176,6 +186,7 @@ public class Place implements Parcelable {
public String toString() {
return "Place{" +
"name='" + name + '\'' +
", lang='" + language + '\'' +
", label='" + label + '\'' +
", longDescription='" + longDescription + '\'' +
", location='" + location + '\'' +
@ -194,6 +205,7 @@ public class Place implements Parcelable {
@Override
public void writeToParcel(Parcel dest, int flags) {
dest.writeString(language);
dest.writeString(name);
dest.writeSerializable(label);
dest.writeString(longDescription);

View file

@ -1,15 +1,21 @@
package fr.free.nrw.commons.nearby.model
import com.google.gson.annotations.SerializedName
class ResultTuple {
@SerializedName("xml:lang")
val language: String
val type: String
val value: String
constructor(type: String, value: String) {
constructor(lang: String, type: String, value: String) {
this.language = lang
this.type = type
this.value = value
}
constructor() {
language = ""
type = ""
value = ""
}