mirror of
https://github.com/commons-app/apps-android-commons.git
synced 2025-10-27 21:03:54 +01:00
Create Revision class
This commit is contained in:
parent
44567627d0
commit
77c28f646f
4 changed files with 22 additions and 10 deletions
|
|
@ -607,16 +607,16 @@ public class ApacheHttpClientMediaWikiApi implements MediaWikiApi {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Nullable
|
@Nullable
|
||||||
public String firstRevisionOfFile(String filename) throws IOException {
|
public Revision firstRevisionOfFile(String filename) throws IOException {
|
||||||
String res = api.action("query")
|
ApiResult res = api.action("query")
|
||||||
.param("prop", "revisions")
|
.param("prop", "revisions")
|
||||||
.param("rvprop", "timestamp|ids")
|
.param("rvprop", "timestamp|ids|user")
|
||||||
.param("titles", filename)
|
.param("titles", filename)
|
||||||
.param("rvdir", "newer")
|
.param("rvdir", "newer")
|
||||||
.param("rvlimit", "1")
|
.param("rvlimit", "1")
|
||||||
.get()
|
.get();
|
||||||
.getString("/api/query/pages/page/revisions/rev/@revid");
|
return new Revision(res.getString("/api/query/pages/page/revisions/rev/@revid"),
|
||||||
return res;
|
res.getString("/api/query/pages/page/revisions/rev/@user"));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
||||||
|
|
@ -110,7 +110,7 @@ public interface MediaWikiApi {
|
||||||
|
|
||||||
boolean thank(String editToken, String revision) throws IOException;
|
boolean thank(String editToken, String revision) throws IOException;
|
||||||
|
|
||||||
String firstRevisionOfFile(String filename) throws IOException;
|
Revision firstRevisionOfFile(String filename) throws IOException;
|
||||||
|
|
||||||
interface ProgressListener {
|
interface ProgressListener {
|
||||||
void onProgress(long transferred, long total);
|
void onProgress(long transferred, long total);
|
||||||
|
|
|
||||||
11
app/src/main/java/fr/free/nrw/commons/mwapi/Revision.java
Normal file
11
app/src/main/java/fr/free/nrw/commons/mwapi/Revision.java
Normal file
|
|
@ -0,0 +1,11 @@
|
||||||
|
package fr.free.nrw.commons.mwapi;
|
||||||
|
|
||||||
|
public class Revision {
|
||||||
|
public String revisionId;
|
||||||
|
public String username;
|
||||||
|
|
||||||
|
public Revision(String revisionId, String username) {
|
||||||
|
this.revisionId = revisionId;
|
||||||
|
this.username = username;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -16,6 +16,7 @@ import fr.free.nrw.commons.R;
|
||||||
import fr.free.nrw.commons.auth.SessionManager;
|
import fr.free.nrw.commons.auth.SessionManager;
|
||||||
import fr.free.nrw.commons.di.ApplicationlessInjection;
|
import fr.free.nrw.commons.di.ApplicationlessInjection;
|
||||||
import fr.free.nrw.commons.mwapi.MediaWikiApi;
|
import fr.free.nrw.commons.mwapi.MediaWikiApi;
|
||||||
|
import fr.free.nrw.commons.mwapi.Revision;
|
||||||
import timber.log.Timber;
|
import timber.log.Timber;
|
||||||
|
|
||||||
import static android.support.v4.app.NotificationCompat.DEFAULT_ALL;
|
import static android.support.v4.app.NotificationCompat.DEFAULT_ALL;
|
||||||
|
|
@ -45,7 +46,7 @@ public class SendThankTask extends AsyncTask<Void, Integer, Boolean> {
|
||||||
private NotificationCompat.Builder notificationBuilder;
|
private NotificationCompat.Builder notificationBuilder;
|
||||||
private Context context;
|
private Context context;
|
||||||
private Media media;
|
private Media media;
|
||||||
private String revision;
|
private Revision revision;
|
||||||
|
|
||||||
public SendThankTask(Context context, Media media){
|
public SendThankTask(Context context, Media media){
|
||||||
this.context = context;
|
this.context = context;
|
||||||
|
|
@ -79,14 +80,14 @@ public class SendThankTask extends AsyncTask<Void, Integer, Boolean> {
|
||||||
mwApi.setAuthCookie(authCookie);
|
mwApi.setAuthCookie(authCookie);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
this.revision = mwApi.firstRevisionOfFile(media.getFilename());
|
revision = mwApi.firstRevisionOfFile(media.getFilename());
|
||||||
editToken = mwApi.getEditToken();
|
editToken = mwApi.getEditToken();
|
||||||
if (editToken.equals("+\\")) {
|
if (editToken.equals("+\\")) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
publishProgress(1);
|
publishProgress(1);
|
||||||
|
|
||||||
mwApi.thank(editToken, revision);
|
mwApi.thank(editToken, revision.revisionId);
|
||||||
|
|
||||||
publishProgress(2);
|
publishProgress(2);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue