Skip to content

Commit 645bc8f

Browse files
committed
Convert Kotlin code to Java, fix temporary file name
1 parent 1c1b57a commit 645bc8f

File tree

4 files changed

+73
-11
lines changed

4 files changed

+73
-11
lines changed

app/src/main/java/fr/free/nrw/commons/mwapi/ApacheHttpClientMediaWikiApi.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -860,10 +860,10 @@ public Single<UploadStash> uploadFile(
860860
if (errorCode.equals(ERROR_CODE_BAD_TOKEN)) {
861861
ViewUtil.showLongToast(context, R.string.bad_token_error_proposed_solution);
862862
}
863-
return new UploadStash(resultStatus, errorCode, filename, "");
863+
return new UploadStash(errorCode, resultStatus, filename, "");
864864
} else {
865865
String filekey = result.getString("/api/upload/@filekey");
866-
return new UploadStash(resultStatus, "Success", filename, filekey);
866+
return new UploadStash("", resultStatus, filename, filekey);
867867
}
868868
});
869869
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
package fr.free.nrw.commons.mwapi;
2+
3+
import android.support.annotation.NonNull;
4+
import android.support.annotation.Nullable;
5+
6+
public class UploadStash {
7+
@NonNull
8+
private String errorCode;
9+
@NonNull
10+
private String resultStatus;
11+
@NonNull
12+
private String filename;
13+
@NonNull
14+
private String filekey;
15+
16+
@NonNull
17+
public final String getErrorCode() {
18+
return this.errorCode;
19+
}
20+
21+
@NonNull
22+
public final String getResultStatus() {
23+
return this.resultStatus;
24+
}
25+
26+
@NonNull
27+
public final String getFilename() {
28+
return this.filename;
29+
}
30+
31+
@NonNull
32+
public final String getFilekey() {
33+
return this.filekey;
34+
}
35+
36+
public UploadStash(@NonNull String errorCode, @NonNull String resultStatus, @NonNull String filename, @NonNull String filekey) {
37+
this.errorCode = errorCode;
38+
this.resultStatus = resultStatus;
39+
this.filename = filename;
40+
this.filekey = filekey;
41+
}
42+
43+
public String toString() {
44+
return "UploadStash(errorCode=" + this.errorCode + ", resultStatus=" + this.resultStatus + ", filename=" + this.filename + ", filekey=" + this.filekey + ")";
45+
}
46+
47+
public int hashCode() {
48+
return ((this.errorCode.hashCode() * 31 + this.resultStatus.hashCode()
49+
) * 31 + this.filename.hashCode()
50+
) * 31 + this.filekey.hashCode();
51+
}
52+
53+
public boolean equals(@Nullable Object obj) {
54+
if (this != obj) {
55+
if (obj instanceof UploadStash) {
56+
UploadStash that = (UploadStash)obj;
57+
if (this.errorCode.equals(that.errorCode)
58+
&& this.resultStatus.equals(that.resultStatus)
59+
&& this.filename.equals(that.filename)
60+
&& this.filekey.equals(that.filekey)) {
61+
return true;
62+
}
63+
}
64+
65+
return false;
66+
} else {
67+
return true;
68+
}
69+
}
70+
}

app/src/main/java/fr/free/nrw/commons/mwapi/UploadStash.kt

-8
This file was deleted.

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -254,7 +254,7 @@ private void uploadContribution(Contribution contribution) {
254254
getString(R.string.upload_progress_notification_title_finishing, contribution.getDisplayTitle()),
255255
contribution
256256
);
257-
String stashFilename = filename + contribution.hashCode();
257+
String stashFilename = "Temp_" + contribution.hashCode() + filename;
258258
mwApi.uploadFile(
259259
stashFilename, fileInputStream, contribution.getDataLength(),
260260
localUri, contribution.getContentProviderUri(), notificationUpdater)

0 commit comments

Comments
 (0)