Merge pull request #1319 from misaochan/category-suggestions-new

Category suggestions for direct nearby uploads
This commit is contained in:
neslihanturan 2018-03-19 13:10:03 +02:00 committed by GitHub
commit 4c192e48e0
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
9 changed files with 59 additions and 15 deletions

View file

@ -623,6 +623,7 @@ public class NearbyMapFragment extends DaggerFragment {
SharedPreferences.Editor editor = directPrefs.edit();
editor.putString("Title", place.getName());
editor.putString("Desc", place.getLongDescription());
editor.putString("Category", place.getCategory());
editor.apply();
}

View file

@ -8,6 +8,7 @@ import java.io.InputStreamReader;
import java.net.URL;
import java.net.URLConnection;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.Locale;
@ -100,13 +101,17 @@ public class NearbyPlaces {
}
String[] fields = line.split("\t");
Timber.v("Fields: " + Arrays.toString(fields));
String point = fields[0];
String wikiDataLink = Utils.stripLocalizedString(fields[1]);
String name = Utils.stripLocalizedString(fields[2]);
String type = Utils.stripLocalizedString(fields[4]);
String icon = fields[5];
String wikipediaSitelink = Utils.stripLocalizedString(fields[7]);
String commonsSitelink = Utils.stripLocalizedString(fields[8]);
String wikiDataLink = Utils.stripLocalizedString(fields[1]);
String icon = fields[5];
String category = Utils.stripLocalizedString(fields[9]);
Timber.v("Name: " + name + ", type: " + type + ", category: " + category + ", wikipediaSitelink: " + wikipediaSitelink + ", commonsSitelink: " + commonsSitelink);
double latitude;
double longitude;
@ -128,6 +133,7 @@ public class NearbyPlaces {
type, // details
Uri.parse(icon),
new LatLng(latitude, longitude, 0),
category,
new Sitelinks.Builder()
.setWikipediaLink(wikipediaSitelink)
.setCommonsLink(commonsSitelink)

View file

@ -17,6 +17,7 @@ public class Place {
private final String longDescription;
private final Uri secondaryImageUrl;
public final LatLng location;
private final String category;
public Bitmap image;
public Bitmap secondaryImage;
@ -25,12 +26,13 @@ public class Place {
public Place(String name, Label label, String longDescription,
Uri secondaryImageUrl, LatLng location, Sitelinks siteLinks) {
Uri secondaryImageUrl, LatLng location, String category, Sitelinks siteLinks) {
this.name = name;
this.label = label;
this.longDescription = longDescription;
this.secondaryImageUrl = secondaryImageUrl;
this.location = location;
this.category = category;
this.siteLinks = siteLinks;
}
@ -42,6 +44,8 @@ public class Place {
public String getLongDescription() { return longDescription; }
public String getCategory() {return category; }
public void setDistance(String distance) {
this.distance = distance;
}

View file

@ -28,6 +28,7 @@ import butterknife.ButterKnife;
import fr.free.nrw.commons.CommonsApplication;
import fr.free.nrw.commons.R;
import fr.free.nrw.commons.contributions.ContributionController;
import fr.free.nrw.commons.di.ApplicationlessInjection;
import timber.log.Timber;
public class PlaceRenderer extends Renderer<Place> {
@ -124,8 +125,8 @@ public class PlaceRenderer extends Renderer<Place> {
Timber.d("directPrefs stored");
editor.putString("Title", place.getName());
editor.putString("Desc", place.getLongDescription());
editor.putString("Category", place.getCategory());
editor.apply();
}
private void closeLayout(LinearLayout buttonLayout){
@ -138,7 +139,8 @@ public class PlaceRenderer extends Renderer<Place> {
@Override
public void render() {
ApplicationlessInjection.getInstance(getContext().getApplicationContext())
.getCommonsApplicationComponent().inject(this);
place = getContent();
tvName.setText(place.name);
String descriptionText = place.getLongDescription();