Skip to content

Commit e4190f3

Browse files
authored
With option for associating image with wikipedia article (commons-app#3783)
1 parent a4379fd commit e4190f3

28 files changed

+999
-499
lines changed

app/src/main/java/fr/free/nrw/commons/Media.java

+8
Original file line numberDiff line numberDiff line change
@@ -518,6 +518,14 @@ public void setCoordinates(@Nullable final LatLng coordinates) {
518518
this.coordinates = coordinates;
519519
}
520520

521+
/**
522+
* Returns wikicode to use the media file on a MediaWiki site
523+
* @return
524+
*/
525+
public String getWikiCode() {
526+
return String.format("[[%s|thumb|%s]]", filename, thumbnailTitle);
527+
}
528+
521529
/**
522530
* Sets the categories the file falls under.
523531
* </p>

app/src/main/java/fr/free/nrw/commons/contributions/Contribution.java

+5-5
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ public class Contribution extends Media {
3939
* and value is the caption in the corresponding language Ex: key = "en", value: "<caption in
4040
* short in English>" key = "de" , value: "<caption in german>"
4141
*/
42-
private Map<String, String> captions = new HashMap<>();
42+
private HashMap<String, String> captions = new HashMap<>();
4343

4444
public Contribution() {
4545
}
@@ -51,7 +51,7 @@ public Contribution(final UploadItem item, final SessionManager sessionManager,
5151
UploadMediaDetail.formatList(item.getUploadMediaDetails()),
5252
sessionManager.getAuthorName(),
5353
categories);
54-
captions = UploadMediaDetail.formatCaptions(item.getUploadMediaDetails());
54+
captions = new HashMap<>(UploadMediaDetail.formatCaptions(item.getUploadMediaDetails()));
5555
decimalCoords = item.getGpsCoords().getDecimalCoords();
5656
dateCreatedSource = "";
5757
this.depictedItems = depictedItems;
@@ -127,11 +127,11 @@ public void setMimeType(final String mimeType) {
127127
* <p>
128128
* returns list of captions stored in hashmap
129129
*/
130-
public Map<String, String> getCaptions() {
130+
public HashMap<String, String> getCaptions() {
131131
return captions;
132132
}
133133

134-
public void setCaptions(Map<String, String> captions) {
134+
public void setCaptions(HashMap<String, String> captions) {
135135
this.captions = captions;
136136
}
137137

@@ -147,7 +147,7 @@ public void writeToParcel(final Parcel dest, final int flags) {
147147
dest.writeLong(transferred);
148148
dest.writeString(decimalCoords);
149149
dest.writeString(dateCreatedSource);
150-
dest.writeSerializable((HashMap) captions);
150+
dest.writeSerializable(captions);
151151
}
152152

153153
/**

app/src/main/java/fr/free/nrw/commons/contributions/ContributionDao.java

+3
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,9 @@ public Completable delete(final Contribution contribution) {
5353
@Query("SELECT * from contribution WHERE filename=:fileName")
5454
public abstract List<Contribution> getContributionWithTitle(String fileName);
5555

56+
@Query("SELECT * from contribution WHERE pageId=:pageId")
57+
public abstract Contribution getContribution(String pageId);
58+
5659
@Query("UPDATE contribution SET state=:state WHERE state in (:toUpdateStates)")
5760
public abstract Single<Integer> updateStates(int state, int[] toUpdateStates);
5861

0 commit comments

Comments
 (0)