Skip to content

Commit 50261ce

Browse files
committed
#3529 Captions/depictions are not saved to Commons - remove unused model fields
1 parent 6d19e75 commit 50261ce

File tree

3 files changed

+13
-80
lines changed

3 files changed

+13
-80
lines changed

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

Lines changed: 2 additions & 78 deletions
Original file line numberDiff line numberDiff line change
@@ -43,11 +43,9 @@ public class Media implements Parcelable {
4343
private String caption;
4444
public String description; // monolingual description on input...
4545
public String discussion;
46-
long dataLength;
46+
private long dataLength;
4747
public Date dateCreated;
4848
@Nullable public Date dateUploaded;
49-
public int width;
50-
public int height;
5149
public String license;
5250
public String licenseUrl;
5351
public String creator;
@@ -61,11 +59,6 @@ public class Media implements Parcelable {
6159
* However unlike categories depictions is multi-lingual
6260
*/
6361
public ArrayList<Map<String, String>> depictionList;
64-
/**
65-
* The above hashmap is fetched from API and to diplay in Explore
66-
* However this list of depictions is for storing and retrieving depictions from local storage or cache
67-
*/
68-
public ArrayList<String> depictions;
6962
public boolean requestedDeletion;
7063
public HashMap<String, String> descriptions; // multilingual descriptions as loaded
7164
/**
@@ -75,15 +68,13 @@ public class Media implements Parcelable {
7568
* key = "de" , value: "<caption in german>"
7669
*/
7770
public Map<String, String> captions;
78-
public HashMap<String, String> tags = new HashMap<>();
7971
@Nullable public LatLng coordinates;
8072

8173
/**
8274
* Provides local constructor
8375
*/
8476
protected Media() {
8577
this.categories = new ArrayList<>();
86-
this.depictions = new ArrayList<>();
8778
this.descriptions = new HashMap<>();
8879
this.captions = new HashMap<>();
8980
}
@@ -124,7 +115,6 @@ public Media(Uri localUri, String imageUrl, String filename, Map<String, String>
124115
this.dateUploaded = dateUploaded;
125116
this.creator = creator;
126117
this.categories = new ArrayList<>();
127-
this.depictions = new ArrayList<>();
128118
this.descriptions = new HashMap<>();
129119
}
130120

@@ -215,28 +205,11 @@ public String getPageId() {
215205
private void setPageId(String pageId) {
216206
this.pageId = pageId;
217207
}
208+
218209
public String getThumbUrl() {
219210
return thumbUrl;
220211
}
221212

222-
/**
223-
* Gets tag of media
224-
* @param key Media key
225-
* @return Media tag
226-
*/
227-
public Object getTag(String key) {
228-
return tags.get(key);
229-
}
230-
231-
/**
232-
* Modifies( or creates a) tag of media
233-
* @param key Media key
234-
* @param value Media value
235-
*/
236-
public void setTag(String key, String value) {
237-
tags.put(key, value);
238-
}
239-
240213
/**
241214
* Gets media display title
242215
* @return Media title
@@ -423,38 +396,6 @@ public void setCreator(String creator) {
423396
this.creator = creator;
424397
}
425398

426-
/**
427-
* Gets the width of the media.
428-
* @return file width as an int
429-
*/
430-
public int getWidth() {
431-
return width;
432-
}
433-
434-
/**
435-
* Sets the width of the media.
436-
* @param width file width as an int
437-
*/
438-
public void setWidth(int width) {
439-
this.width = width;
440-
}
441-
442-
/**
443-
* Gets the height of the media.
444-
* @return file height as an int
445-
*/
446-
public int getHeight() {
447-
return height;
448-
}
449-
450-
/**
451-
* Sets the height of the media.
452-
* @param height file height as an int
453-
*/
454-
public void setHeight(int height) {
455-
this.height = height;
456-
}
457-
458399
/**
459400
* Gets the license name of the file.
460401
* @return license as a String
@@ -510,12 +451,6 @@ public ArrayList<String> getCategories() {
510451
return (ArrayList<String>) categories.clone(); // feels dirty
511452
}
512453

513-
/**
514-
* @return array list of depictions associated with the current media
515-
*/
516-
public ArrayList<String> getDepictions() {
517-
return (ArrayList<String>) depictions.clone();
518-
}
519454

520455
/**
521456
* Sets the categories the file falls under.
@@ -529,11 +464,6 @@ public void setCategories(List<String> categories) {
529464
this.categories.addAll(categories);
530465
}
531466

532-
public void setDepictions(List<String> depictions) {
533-
this.depictions.clear();
534-
this.depictions.addAll(depictions);
535-
}
536-
537467
/**
538468
* Modifies (or sets) media descriptions
539469
* @param descriptions Media descriptions
@@ -645,8 +575,6 @@ public void writeToParcel(Parcel dest, int flags) {
645575
dest.writeLong(this.dataLength);
646576
dest.writeLong(this.dateCreated != null ? this.dateCreated.getTime() : -1);
647577
dest.writeLong(this.dateUploaded != null ? this.dateUploaded.getTime() : -1);
648-
dest.writeInt(this.width);
649-
dest.writeInt(this.height);
650578
dest.writeString(this.license);
651579
dest.writeString(this.licenseUrl);
652580
dest.writeString(this.creator);
@@ -655,7 +583,6 @@ public void writeToParcel(Parcel dest, int flags) {
655583
dest.writeList(this.depictionList);
656584
dest.writeByte(this.requestedDeletion ? (byte) 1 : (byte) 0);
657585
dest.writeSerializable(this.descriptions);
658-
dest.writeSerializable(this.tags);
659586
dest.writeParcelable(this.coordinates, flags);
660587
}
661588

@@ -673,8 +600,6 @@ protected Media(Parcel in) {
673600
this.dateCreated = tmpDateCreated == -1 ? null : new Date(tmpDateCreated);
674601
long tmpDateUploaded = in.readLong();
675602
this.dateUploaded = tmpDateUploaded == -1 ? null : new Date(tmpDateUploaded);
676-
this.width = in.readInt();
677-
this.height = in.readInt();
678603
this.license = in.readString();
679604
this.licenseUrl = in.readString();
680605
this.creator = in.readString();
@@ -685,7 +610,6 @@ protected Media(Parcel in) {
685610
in.readList(depictionList,null);
686611
this.requestedDeletion = in.readByte() != 0;
687612
this.descriptions = (HashMap<String, String>) in.readSerializable();
688-
this.tags = (HashMap<String, String>) in.readSerializable();
689613
this.coordinates = in.readParcelable(LatLng.class.getClassLoader());
690614
}
691615

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

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ public class Contribution extends Media {
3737
* this Id is in turn used to upload depictions to wikibase
3838
*/
3939
private List<DepictedItem> depictedItems = new ArrayList<>();
40+
private String mimeType;
4041

4142
public Contribution() {
4243
}
@@ -166,4 +167,12 @@ public Contribution[] newArray(final int size) {
166167
return new Contribution[size];
167168
}
168169
};
170+
171+
public void setMimeType(String mimeType) {
172+
this.mimeType = mimeType;
173+
}
174+
175+
public String getMimeType() {
176+
return mimeType;
177+
}
169178
}

app/src/main/java/fr/free/nrw/commons/upload/UploadController.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ private Contribution buildUpload(final Contribution contribution) {
152152

153153
if (mimeType != null) {
154154
Timber.d("MimeType is: %s", mimeType);
155-
contribution.setTag("mimeType", mimeType);
155+
contribution.setMimeType(mimeType);
156156
if(mimeType.startsWith("image/") && contribution.getDateCreated() == null){
157157
contribution.setDateCreated(resolveDateTakenOrNow(contentResolver, contribution));
158158
}
@@ -162,7 +162,7 @@ private Contribution buildUpload(final Contribution contribution) {
162162
}
163163

164164
private String resolveMimeType(final ContentResolver contentResolver, final Contribution contribution) {
165-
final String mimeType = (String) contribution.getTag("mimeType");
165+
final String mimeType = contribution.getMimeType();
166166
if (mimeType == null || TextUtils.isEmpty(mimeType) || mimeType.endsWith("*")) {
167167
return contentResolver.getType(contribution.getLocalUri());
168168
}

0 commit comments

Comments
 (0)