Fix issue where Wikidata edits were not happening (#1682)

* Added logs to debug wikidata edits

* Minor changes in logs
This commit is contained in:
Vivek Maskara 2018-07-05 15:43:37 +05:30 committed by Josephine Lim
parent 306f23d1e2
commit b2a150a3ae
10 changed files with 55 additions and 9 deletions

View file

@ -35,6 +35,7 @@ import timber.log.Timber;
import static android.app.Activity.RESULT_OK;
import static android.content.pm.PackageManager.PERMISSION_GRANTED;
import static fr.free.nrw.commons.wikidata.WikidataConstants.WIKIDATA_ENTITY_ID_PREF;
public class NearbyListFragment extends DaggerFragment {
private Bundle bundleForUpdates; // Carry information from activity about changed nearby places and current location
@ -146,7 +147,7 @@ public class NearbyListFragment extends DaggerFragment {
if (resultCode == RESULT_OK) {
Timber.d("OnActivityResult() parameters: Req code: %d Result code: %d Data: %s",
requestCode, resultCode, data);
controller.handleImagePicked(requestCode, data, true, directPrefs.getString("WikiDataEntityId", null));
controller.handleImagePicked(requestCode, data, true, directPrefs.getString(WIKIDATA_ENTITY_ID_PREF, null));
} else {
Timber.e("OnActivityResult() parameters: Req code: %d Result code: %d Data: %s",
requestCode, resultCode, data);

View file

@ -63,6 +63,7 @@ import uk.co.deanwild.materialshowcaseview.MaterialShowcaseView;
import static android.app.Activity.RESULT_OK;
import static android.content.pm.PackageManager.PERMISSION_GRANTED;
import static fr.free.nrw.commons.wikidata.WikidataConstants.WIKIDATA_ENTITY_ID_PREF;
public class NearbyMapFragment extends DaggerFragment {
@ -711,7 +712,7 @@ public class NearbyMapFragment extends DaggerFragment {
fabCamera.setOnClickListener(view -> {
if (fabCamera.isShown()) {
Timber.d("Camera button tapped. Image title: " + place.getName() + "Image desc: " + place.getLongDescription());
Timber.d("Camera button tapped. Place: %s", place.toString());
storeSharedPrefs();
directUpload.initiateCameraUpload();
}
@ -719,7 +720,7 @@ public class NearbyMapFragment extends DaggerFragment {
fabGallery.setOnClickListener(view -> {
if (fabGallery.isShown()) {
Timber.d("Gallery button tapped. Image title: " + place.getName() + "Image desc: " + place.getLongDescription());
Timber.d("Gallery button tapped. Place: %s", place.toString());
storeSharedPrefs();
directUpload.initiateGalleryUpload();
}
@ -731,7 +732,7 @@ public class NearbyMapFragment extends DaggerFragment {
editor.putString("Title", place.getName());
editor.putString("Desc", place.getLongDescription());
editor.putString("Category", place.getCategory());
editor.putString("WikiDataEntityId", place.getWikiDataEntityId());
editor.putString(WIKIDATA_ENTITY_ID_PREF, place.getWikiDataEntityId());
editor.apply();
}
@ -767,7 +768,7 @@ public class NearbyMapFragment extends DaggerFragment {
if (resultCode == RESULT_OK) {
Timber.d("OnActivityResult() parameters: Req code: %d Result code: %d Data: %s",
requestCode, resultCode, data);
controller.handleImagePicked(requestCode, data, true, directPrefs.getString("WikiDataEntityId", null));
controller.handleImagePicked(requestCode, data, true, directPrefs.getString(WIKIDATA_ENTITY_ID_PREF, null));
} else {
Timber.e("OnActivityResult() parameters: Req code: %d Result code: %d Data: %s",
requestCode, resultCode, data);

View file

@ -10,6 +10,7 @@ import java.util.Map;
import fr.free.nrw.commons.R;
import fr.free.nrw.commons.location.LatLng;
import timber.log.Timber;
public class Place {
@ -58,10 +59,12 @@ public class Place {
@Nullable
public String getWikiDataEntityId() {
if (!hasWikidataLink()) {
Timber.d("Wikidata entity ID is null for place with sitelink %s", siteLinks.toString());
return null;
}
String wikiDataLink = siteLinks.getWikidataLink().toString();
Timber.d("Wikidata entity is %s", wikiDataLink);
return wikiDataLink.replace("http://www.wikidata.org/entity/", "");
}
@ -94,7 +97,18 @@ public class Place {
@Override
public String toString() {
return String.format("Place(%s@%s)", name, location);
return "Place{" +
"name='" + name + '\'' +
", label='" + label + '\'' +
", longDescription='" + longDescription + '\'' +
", secondaryImageUrl='" + secondaryImageUrl + '\'' +
", location='" + location + '\'' +
", category='" + category + '\'' +
", image='" + image + '\'' +
", secondaryImage=" + secondaryImage +
", distance='" + distance + '\'' +
", siteLinks='" + siteLinks.toString() + '\'' +
'}';
}
/**

View file

@ -58,6 +58,15 @@ public class Sitelinks implements Parcelable {
return Uri.parse(sanitisedStringUrl);
}
@Override
public String toString() {
return "Sitelinks{" +
"wikipediaLink='" + wikipediaLink + '\'' +
", commonsLink='" + commonsLink + '\'' +
", wikidataLink='" + wikidataLink + '\'' +
'}';
}
private Sitelinks(Sitelinks.Builder builder) {
this.wikidataLink = builder.wikidataLink;
this.wikipediaLink = builder.wikipediaLink;