mirror of
https://github.com/commons-app/apps-android-commons.git
synced 2025-10-26 12:23:58 +01:00
Remove unused code
This commit is contained in:
parent
6664f7f324
commit
41d6abdf40
17 changed files with 0 additions and 653 deletions
|
|
@ -46,9 +46,6 @@ dependencies {
|
|||
|
||||
implementation 'com.facebook.fresco:fresco:1.5.0'
|
||||
implementation 'com.facebook.stetho:stetho:1.5.0'
|
||||
implementation "com.squareup.retrofit2:retrofit:$RETROFIT_VERSION"
|
||||
implementation "com.squareup.retrofit2:converter-gson:$RETROFIT_VERSION"
|
||||
implementation 'org.apache.commons:commons-lang3:3.5'
|
||||
|
||||
implementation "com.google.dagger:dagger:$DAGGER_VERSION"
|
||||
implementation "com.google.dagger:dagger-android-support:$DAGGER_VERSION"
|
||||
|
|
@ -121,7 +118,6 @@ android {
|
|||
productFlavors {
|
||||
prod {
|
||||
buildConfigField "String", "WIKIMEDIA_API_HOST", "\"https://commons.wikimedia.org/w/api.php\""
|
||||
buildConfigField "String", "COMMONS_BASE_URL", "\"https://commons.wikimedia.org\""
|
||||
buildConfigField "String", "WIKIMEDIA_FORGE_API_HOST", "\"https://tools.wmflabs.org/\""
|
||||
buildConfigField "String", "IMAGE_URL_BASE", "\"https://upload.wikimedia.org/wikipedia/commons\""
|
||||
buildConfigField "String", "HOME_URL", "\"https://commons.wikimedia.org/wiki/\""
|
||||
|
|
@ -136,7 +132,6 @@ android {
|
|||
beta {
|
||||
// What values do we need to hit the BETA versions of the site / api ?
|
||||
buildConfigField "String", "WIKIMEDIA_API_HOST", "\"https://commons.wikimedia.beta.wmflabs.org/w/api.php\""
|
||||
buildConfigField "String", "COMMONS_BASE_URL", "\"https://commons.wikimedia.beta.wmflabs.org\""
|
||||
buildConfigField "String", "WIKIMEDIA_FORGE_API_HOST", "\"https://tools.wmflabs.org/\""
|
||||
buildConfigField "String", "IMAGE_URL_BASE", "\"https://upload.beta.wmflabs.org/wikipedia/commons\""
|
||||
buildConfigField "String", "HOME_URL", "\"https://commons.wikimedia.beta.wmflabs.org/wiki/\""
|
||||
|
|
|
|||
|
|
@ -9,7 +9,6 @@ import android.support.v4.util.LruCache;
|
|||
import javax.inject.Named;
|
||||
import javax.inject.Singleton;
|
||||
|
||||
import dagger.Binds;
|
||||
import dagger.Module;
|
||||
import dagger.Provides;
|
||||
import fr.free.nrw.commons.BuildConfig;
|
||||
|
|
@ -22,7 +21,6 @@ import fr.free.nrw.commons.location.LocationServiceManager;
|
|||
import fr.free.nrw.commons.mwapi.ApacheHttpClientMediaWikiApi;
|
||||
import fr.free.nrw.commons.mwapi.MediaWikiApi;
|
||||
import fr.free.nrw.commons.nearby.NearbyPlaces;
|
||||
import fr.free.nrw.commons.notification.NotificationClient;
|
||||
import fr.free.nrw.commons.upload.UploadController;
|
||||
|
||||
import static android.content.Context.MODE_PRIVATE;
|
||||
|
|
@ -137,10 +135,4 @@ public class CommonsApplicationModule {
|
|||
public LruCache<String, String> provideLruCache() {
|
||||
return new LruCache<>(1024);
|
||||
}
|
||||
|
||||
@Provides
|
||||
@Singleton
|
||||
public NotificationClient provideNotificationClient() {
|
||||
return new NotificationClient(BuildConfig.COMMONS_BASE_URL);
|
||||
}
|
||||
}
|
||||
|
|
@ -1,20 +0,0 @@
|
|||
package fr.free.nrw.commons.json;
|
||||
|
||||
import android.support.annotation.NonNull;
|
||||
import android.support.annotation.Nullable;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
|
||||
import fr.free.nrw.commons.network.GsonUtil;
|
||||
|
||||
public final class GsonMarshaller {
|
||||
public static String marshal(@Nullable Object object) {
|
||||
return marshal(GsonUtil.getDefaultGson(), object);
|
||||
}
|
||||
|
||||
public static String marshal(@NonNull Gson gson, @Nullable Object object) {
|
||||
return gson.toJson(object);
|
||||
}
|
||||
|
||||
private GsonMarshaller() { }
|
||||
}
|
||||
|
|
@ -1,36 +0,0 @@
|
|||
package fr.free.nrw.commons.json;
|
||||
|
||||
import android.support.annotation.NonNull;
|
||||
import android.support.annotation.Nullable;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.reflect.TypeToken;
|
||||
|
||||
import fr.free.nrw.commons.network.GsonUtil;
|
||||
|
||||
public final class GsonUnmarshaller {
|
||||
/** @return Unmarshalled object. */
|
||||
public static <T> T unmarshal(Class<T> clazz, @Nullable String json) {
|
||||
return unmarshal(GsonUtil.getDefaultGson(), clazz, json);
|
||||
}
|
||||
|
||||
/** @return Unmarshalled collection of objects. */
|
||||
public static <T> T unmarshal(TypeToken<T> typeToken, @Nullable String json) {
|
||||
return unmarshal(GsonUtil.getDefaultGson(), typeToken, json);
|
||||
}
|
||||
|
||||
/** @return Unmarshalled object. */
|
||||
public static <T> T unmarshal(@NonNull Gson gson, Class<T> clazz, @Nullable String json) {
|
||||
return gson.fromJson(json, clazz);
|
||||
}
|
||||
|
||||
/** @return Unmarshalled collection of objects. */
|
||||
public static <T> T unmarshal(@NonNull Gson gson, TypeToken<T> typeToken, @Nullable String json) {
|
||||
// From the manual: "Fairly hideous... Unfortunately, no way to get around this in Java".
|
||||
return gson.fromJson(json, typeToken.getType());
|
||||
}
|
||||
|
||||
private GsonUnmarshaller() { }
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -1,95 +0,0 @@
|
|||
package fr.free.nrw.commons.json;
|
||||
|
||||
import android.support.annotation.NonNull;
|
||||
import android.support.annotation.Nullable;
|
||||
import android.support.v4.util.ArraySet;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.JsonParseException;
|
||||
import com.google.gson.TypeAdapter;
|
||||
import com.google.gson.TypeAdapterFactory;
|
||||
import com.google.gson.reflect.TypeToken;
|
||||
import com.google.gson.stream.JsonReader;
|
||||
import com.google.gson.stream.JsonWriter;
|
||||
|
||||
|
||||
import java.io.IOException;
|
||||
import java.lang.reflect.Field;
|
||||
import java.util.Collections;
|
||||
import java.util.Set;
|
||||
|
||||
import fr.free.nrw.commons.json.annotations.Required;
|
||||
|
||||
/**
|
||||
* TypeAdapterFactory that provides TypeAdapters that return null values for objects that are
|
||||
* missing fields annotated with @Required.
|
||||
*
|
||||
* BEWARE: This means that a List or other Collection of objects that have @Required fields can
|
||||
* contain null elements after deserialization!
|
||||
*
|
||||
* TODO: Handle null values in lists during deserialization, perhaps with a new @RequiredElements
|
||||
* annotation and another corresponding TypeAdapter(Factory).
|
||||
*/
|
||||
class RequiredFieldsCheckOnReadTypeAdapterFactory implements TypeAdapterFactory {
|
||||
@Nullable @Override public final <T> TypeAdapter<T> create(@NonNull Gson gson, @NonNull TypeToken<T> typeToken) {
|
||||
Class<?> rawType = typeToken.getRawType();
|
||||
Set<Field> requiredFields = collectRequiredFields(rawType);
|
||||
|
||||
if (requiredFields.isEmpty()) {
|
||||
return null;
|
||||
}
|
||||
|
||||
setFieldsAccessible(requiredFields, true);
|
||||
return new Adapter<>(gson.getDelegateAdapter(this, typeToken), requiredFields);
|
||||
}
|
||||
|
||||
@NonNull private Set<Field> collectRequiredFields(@NonNull Class<?> clazz) {
|
||||
Field[] fields = clazz.getDeclaredFields();
|
||||
Set<Field> required = new ArraySet<>();
|
||||
for (Field field : fields) {
|
||||
if (field.isAnnotationPresent(Required.class)) {
|
||||
required.add(field);
|
||||
}
|
||||
}
|
||||
return Collections.unmodifiableSet(required);
|
||||
}
|
||||
|
||||
private void setFieldsAccessible(Iterable<Field> fields, boolean accessible) {
|
||||
for (Field field : fields) {
|
||||
field.setAccessible(accessible);
|
||||
}
|
||||
}
|
||||
|
||||
private static final class Adapter<T> extends TypeAdapter<T> {
|
||||
@NonNull private final TypeAdapter<T> delegate;
|
||||
@NonNull private final Set<Field> requiredFields;
|
||||
|
||||
private Adapter(@NonNull TypeAdapter<T> delegate, @NonNull final Set<Field> requiredFields) {
|
||||
this.delegate = delegate;
|
||||
this.requiredFields = requiredFields;
|
||||
}
|
||||
|
||||
@Override public void write(JsonWriter out, T value) throws IOException {
|
||||
delegate.write(out, value);
|
||||
}
|
||||
|
||||
@Override @Nullable public T read(JsonReader in) throws IOException {
|
||||
T deserialized = delegate.read(in);
|
||||
return allRequiredFieldsPresent(deserialized, requiredFields) ? deserialized : null;
|
||||
}
|
||||
|
||||
private boolean allRequiredFieldsPresent(@NonNull T deserialized,
|
||||
@NonNull Set<Field> required) {
|
||||
for (Field field : required) {
|
||||
try {
|
||||
if (field.get(deserialized) == null) {
|
||||
return false;
|
||||
}
|
||||
} catch (IllegalArgumentException | IllegalAccessException e) {
|
||||
throw new JsonParseException(e);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,22 +0,0 @@
|
|||
package fr.free.nrw.commons.json;
|
||||
|
||||
import android.net.Uri;
|
||||
|
||||
import com.google.gson.TypeAdapter;
|
||||
import com.google.gson.stream.JsonReader;
|
||||
import com.google.gson.stream.JsonWriter;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
public class UriTypeAdapter extends TypeAdapter<Uri> {
|
||||
@Override
|
||||
public void write(JsonWriter out, Uri value) throws IOException {
|
||||
out.value(value.toString());
|
||||
}
|
||||
|
||||
@Override
|
||||
public Uri read(JsonReader in) throws IOException {
|
||||
String url = in.nextString();
|
||||
return Uri.parse(url);
|
||||
}
|
||||
}
|
||||
|
|
@ -1,21 +0,0 @@
|
|||
package fr.free.nrw.commons.json.annotations;
|
||||
|
||||
import java.lang.annotation.Documented;
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
import java.lang.annotation.Target;
|
||||
|
||||
import static java.lang.annotation.ElementType.FIELD;
|
||||
|
||||
/**
|
||||
* Annotate fields in Retrofit POJO classes with this to enforce their presence in order to return
|
||||
* an instantiated object.
|
||||
*
|
||||
* E.g.: @NonNull @Required private String title;
|
||||
*/
|
||||
@Documented
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Target(FIELD)
|
||||
public @interface Required {
|
||||
}
|
||||
|
||||
|
|
@ -1,20 +0,0 @@
|
|||
package fr.free.nrw.commons.mwapi;
|
||||
|
||||
import org.apache.commons.lang3.builder.EqualsBuilder;
|
||||
import org.apache.commons.lang3.builder.HashCodeBuilder;
|
||||
import org.apache.commons.lang3.builder.ToStringBuilder;
|
||||
|
||||
public abstract class BaseModel {
|
||||
@Override public String toString() {
|
||||
return ToStringBuilder.reflectionToString(this);
|
||||
}
|
||||
|
||||
@Override public int hashCode() {
|
||||
return HashCodeBuilder.reflectionHashCode(this);
|
||||
}
|
||||
|
||||
@SuppressWarnings("EqualsWhichDoesntCheckParameterClass")
|
||||
@Override public boolean equals(Object other) {
|
||||
return EqualsBuilder.reflectionEquals(this, other);
|
||||
}
|
||||
}
|
||||
|
|
@ -1,40 +0,0 @@
|
|||
package fr.free.nrw.commons.mwapi;
|
||||
|
||||
import android.support.annotation.Nullable;
|
||||
import android.support.annotation.VisibleForTesting;
|
||||
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public class MwQueryResponse<T> extends MwResponse {
|
||||
|
||||
@SuppressWarnings("unused") @SerializedName("batchcomplete") private boolean batchComplete;
|
||||
|
||||
@SuppressWarnings("unused") @SerializedName("continue") @Nullable
|
||||
private Map<String, String> continuation;
|
||||
|
||||
@Nullable private T query;
|
||||
|
||||
public boolean batchComplete() {
|
||||
return batchComplete;
|
||||
}
|
||||
|
||||
@Nullable public Map<String, String> continuation() {
|
||||
return continuation;
|
||||
}
|
||||
|
||||
@Nullable public T query() {
|
||||
return query;
|
||||
}
|
||||
|
||||
@Override public boolean success() {
|
||||
return super.success() && query != null;
|
||||
}
|
||||
|
||||
@VisibleForTesting
|
||||
protected void setQuery(@Nullable T query) {
|
||||
this.query = query;
|
||||
}
|
||||
}
|
||||
|
|
@ -1,46 +0,0 @@
|
|||
package fr.free.nrw.commons.mwapi;
|
||||
|
||||
import android.support.annotation.NonNull;
|
||||
import android.support.annotation.Nullable;
|
||||
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
public abstract class MwResponse extends BaseModel {
|
||||
@SuppressWarnings("unused") @Nullable
|
||||
private MwServiceError error;
|
||||
|
||||
@SuppressWarnings("unused") @Nullable private Map<String, Warning> warnings;
|
||||
|
||||
@SuppressWarnings("unused,NullableProblems") @SerializedName("servedby") @NonNull
|
||||
private String servedBy;
|
||||
|
||||
@Nullable public MwServiceError getError() {
|
||||
return error;
|
||||
}
|
||||
|
||||
public boolean hasError() {
|
||||
return error != null;
|
||||
}
|
||||
|
||||
public boolean success() {
|
||||
return error == null;
|
||||
}
|
||||
|
||||
@Nullable public String code() {
|
||||
return error != null ? error.getTitle() : null;
|
||||
}
|
||||
|
||||
@Nullable public String info() {
|
||||
return error != null ? error.getDetails() : null;
|
||||
}
|
||||
|
||||
public boolean badToken() {
|
||||
return error != null && error.badToken();
|
||||
}
|
||||
|
||||
private class Warning {
|
||||
@SuppressWarnings("unused,NullableProblems") @NonNull private String warnings;
|
||||
}
|
||||
}
|
||||
|
|
@ -1,72 +0,0 @@
|
|||
package fr.free.nrw.commons.mwapi;
|
||||
|
||||
import android.support.annotation.NonNull;
|
||||
import android.support.annotation.Nullable;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Gson POJO for a MediaWiki API error.
|
||||
*/
|
||||
public class MwServiceError implements ServiceError {
|
||||
@SuppressWarnings("unused") @Nullable
|
||||
private String code;
|
||||
@SuppressWarnings("unused") @Nullable private String info;
|
||||
@SuppressWarnings("unused") @Nullable private String docref;
|
||||
@SuppressWarnings("unused") @NonNull
|
||||
private List<Message> messages = Collections.emptyList();
|
||||
|
||||
@Override @Nullable public String getTitle() {
|
||||
return code;
|
||||
}
|
||||
|
||||
@Override @Nullable public String getDetails() {
|
||||
return info;
|
||||
}
|
||||
|
||||
@Nullable public String getDocRef() {
|
||||
return docref;
|
||||
}
|
||||
|
||||
public boolean badToken() {
|
||||
return "badtoken".equals(code);
|
||||
}
|
||||
|
||||
public boolean hasMessageName(@NonNull String messageName) {
|
||||
for (Message msg : messages) {
|
||||
if (messageName.equals(msg.name)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Nullable public String getMessageHtml(@NonNull String messageName) {
|
||||
for (Message msg : messages) {
|
||||
if (messageName.equals(msg.name)) {
|
||||
return msg.html();
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override public String toString() {
|
||||
return "MwServiceError{"
|
||||
+ "code='" + code + '\''
|
||||
+ ", info='" + info + '\''
|
||||
+ ", docref='" + docref + '\''
|
||||
+ '}';
|
||||
}
|
||||
|
||||
private static final class Message {
|
||||
@SuppressWarnings("unused") @Nullable private String name;
|
||||
@SuppressWarnings("unused") @Nullable private String html;
|
||||
|
||||
@NonNull private String html() {
|
||||
return StringUtils.defaultString(html);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,7 +0,0 @@
|
|||
package fr.free.nrw.commons.mwapi;
|
||||
|
||||
public interface ServiceError {
|
||||
String getTitle();
|
||||
|
||||
String getDetails();
|
||||
}
|
||||
|
|
@ -1,31 +0,0 @@
|
|||
package fr.free.nrw.commons.network;
|
||||
|
||||
import android.net.Uri;
|
||||
import android.support.annotation.VisibleForTesting;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.GsonBuilder;
|
||||
|
||||
import fr.free.nrw.commons.json.UriTypeAdapter;
|
||||
|
||||
public final class GsonUtil {
|
||||
private static final String DATE_FORMAT = "MMM dd, yyyy HH:mm:ss";
|
||||
|
||||
private static final GsonBuilder DEFAULT_GSON_BUILDER = new GsonBuilder()
|
||||
.setDateFormat(DATE_FORMAT)
|
||||
.registerTypeHierarchyAdapter(Uri.class, new UriTypeAdapter().nullSafe());
|
||||
|
||||
private static final Gson DEFAULT_GSON = DEFAULT_GSON_BUILDER.create();
|
||||
|
||||
public static Gson getDefaultGson() {
|
||||
return DEFAULT_GSON;
|
||||
}
|
||||
|
||||
@VisibleForTesting
|
||||
public static GsonBuilder getDefaultGsonBuilder() {
|
||||
return DEFAULT_GSON_BUILDER;
|
||||
}
|
||||
|
||||
private GsonUtil() {
|
||||
}
|
||||
}
|
||||
|
|
@ -1,22 +0,0 @@
|
|||
package fr.free.nrw.commons.network;
|
||||
|
||||
import android.support.annotation.NonNull;
|
||||
|
||||
import okhttp3.OkHttpClient;
|
||||
import retrofit2.Retrofit;
|
||||
import retrofit2.converter.gson.GsonConverterFactory;
|
||||
|
||||
public final class RetrofitFactory {
|
||||
|
||||
public static Retrofit newInstance(@NonNull String endpoint) {
|
||||
return new Retrofit.Builder()
|
||||
.client(new OkHttpClient())
|
||||
.baseUrl(endpoint)
|
||||
.addConverterFactory(GsonConverterFactory.create(GsonUtil.getDefaultGson()))
|
||||
.build();
|
||||
}
|
||||
|
||||
private RetrofitFactory() {
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -1,101 +0,0 @@
|
|||
package fr.free.nrw.commons.notification;
|
||||
|
||||
import android.support.annotation.NonNull;
|
||||
import android.support.annotation.VisibleForTesting;
|
||||
import android.text.TextUtils;
|
||||
|
||||
import com.google.gson.JsonParseException;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import fr.free.nrw.commons.mwapi.MwQueryResponse;
|
||||
import fr.free.nrw.commons.network.RetrofitFactory;
|
||||
import retrofit2.Call;
|
||||
import retrofit2.Response;
|
||||
import retrofit2.http.Field;
|
||||
import retrofit2.http.FormUrlEncoded;
|
||||
import retrofit2.http.GET;
|
||||
import retrofit2.http.POST;
|
||||
import retrofit2.http.Query;
|
||||
import timber.log.Timber;
|
||||
|
||||
public final class NotificationClient {
|
||||
@NonNull
|
||||
private final Service service;
|
||||
|
||||
public interface Callback {
|
||||
void success(@NonNull List<Notification> notifications);
|
||||
|
||||
void failure(Throwable t);
|
||||
}
|
||||
|
||||
public NotificationClient(@NonNull String endpoint) {
|
||||
service = RetrofitFactory.newInstance(endpoint).create(Service.class);
|
||||
}
|
||||
|
||||
@VisibleForTesting
|
||||
static class CallbackAdapter implements retrofit2.Callback<MwQueryResponse<NotificationObject.QueryNotifications>> {
|
||||
@NonNull
|
||||
private final Callback callback;
|
||||
|
||||
CallbackAdapter(@NonNull Callback callback) {
|
||||
this.callback = callback;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onResponse(Call<MwQueryResponse<NotificationObject.QueryNotifications>> call,
|
||||
Response<MwQueryResponse<NotificationObject.QueryNotifications>> response) {
|
||||
Timber.d("Resonse is %s", response);
|
||||
if (response.body() != null && response.body().query() != null) {
|
||||
callback.success(response.body().query().get());
|
||||
} else {
|
||||
callback.failure(new JsonParseException("Notification response is malformed."));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(Call<MwQueryResponse<NotificationObject.QueryNotifications>> call, Throwable caught) {
|
||||
Timber.e(caught, "Error occurred while fetching notifications");
|
||||
callback.failure(caught);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Obrain a list of unread notifications for the user who is currently logged in.
|
||||
*
|
||||
* @param callback Callback that will receive the list of notifications.
|
||||
* @param wikis List of wiki names for which notifications should be received. These must be
|
||||
* in the "DB name" format, as in "enwiki", "zhwiki", "wikidatawiki", etc.
|
||||
*/
|
||||
public void getNotifications(@NonNull final Callback callback, @NonNull String... wikis) {
|
||||
String wikiList = TextUtils.join("|", wikis);
|
||||
requestNotifications(service, wikiList).enqueue(new CallbackAdapter(callback));
|
||||
}
|
||||
|
||||
@VisibleForTesting
|
||||
@NonNull
|
||||
Call<MwQueryResponse<NotificationObject.QueryNotifications>> requestNotifications(@NonNull Service service, @NonNull String wikiList) {
|
||||
return service.getNotifications(wikiList);
|
||||
}
|
||||
|
||||
@VisibleForTesting
|
||||
@NonNull
|
||||
Call<MwQueryResponse<MarkReadResponse.QueryMarkReadResponse>> requestMarkRead(@NonNull Service service, @NonNull String token, @NonNull String idList) {
|
||||
return service.markRead(token, idList);
|
||||
}
|
||||
|
||||
@VisibleForTesting
|
||||
interface Service {
|
||||
String ACTION = "w/api.php?format=json&formatversion=2&action=";
|
||||
|
||||
@GET(ACTION + "query&meta=notifications¬filter=!read¬prop=list")
|
||||
@NonNull
|
||||
Call<MwQueryResponse<NotificationObject.QueryNotifications>> getNotifications(@Query("notwikis") @NonNull String wikiList);
|
||||
|
||||
@FormUrlEncoded
|
||||
@POST(ACTION + "echomarkread")
|
||||
@NonNull
|
||||
Call<MwQueryResponse<MarkReadResponse.QueryMarkReadResponse>> markRead(@Field("token") @NonNull String token,
|
||||
@Field("list") @NonNull String idList);
|
||||
}
|
||||
}
|
||||
|
|
@ -1,106 +0,0 @@
|
|||
package fr.free.nrw.commons.notification;
|
||||
|
||||
import android.support.annotation.NonNull;
|
||||
import android.support.annotation.Nullable;
|
||||
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class NotificationObject {
|
||||
public static final String TYPE_EDIT_USER_TALK = "edit-user-talk";
|
||||
public static final String TYPE_REVERTED = "reverted";
|
||||
public static final String TYPE_EDIT_THANK = "edit-thank";
|
||||
public static final String WIKIDATA_WIKI = "wikidatawiki";
|
||||
|
||||
@SuppressWarnings("unused,NullableProblems") @NonNull
|
||||
private String wiki;
|
||||
@SuppressWarnings("unused") private int id;
|
||||
@SuppressWarnings("unused,NullableProblems") @NonNull private String type;
|
||||
@SuppressWarnings("unused,NullableProblems") @NonNull private String category;
|
||||
@SuppressWarnings("unused") private int revid;
|
||||
|
||||
@SuppressWarnings("unused,NullableProblems") @NonNull private Title title;
|
||||
@SuppressWarnings("unused,NullableProblems") @NonNull private Agent agent;
|
||||
|
||||
@NonNull public String wiki() {
|
||||
return wiki;
|
||||
}
|
||||
|
||||
public int id() {
|
||||
return id;
|
||||
}
|
||||
|
||||
@NonNull public String type() {
|
||||
return type;
|
||||
}
|
||||
|
||||
@NonNull public Agent agent() {
|
||||
return agent;
|
||||
}
|
||||
|
||||
@NonNull public Title title() {
|
||||
return title;
|
||||
}
|
||||
|
||||
public int revID() {
|
||||
return revid;
|
||||
}
|
||||
|
||||
public boolean isFromWikidata() {
|
||||
return wiki.equals(WIKIDATA_WIKI);
|
||||
}
|
||||
|
||||
@Override public String toString() {
|
||||
return Integer.toString(id);
|
||||
}
|
||||
|
||||
public static class Title {
|
||||
@SuppressWarnings("unused,NullableProblems") @NonNull private String full;
|
||||
@SuppressWarnings("unused,NullableProblems") @NonNull private String text;
|
||||
@SuppressWarnings("unused") @Nullable
|
||||
private String namespace;
|
||||
@SuppressWarnings("unused") @SerializedName("namespace-key") private int namespaceKey;
|
||||
|
||||
@NonNull public String text() {
|
||||
return text;
|
||||
}
|
||||
|
||||
@NonNull public String full() {
|
||||
return full;
|
||||
}
|
||||
|
||||
public boolean isMainNamespace() {
|
||||
return namespaceKey == 0;
|
||||
}
|
||||
|
||||
public void setFull(@NonNull String title) {
|
||||
full = title;
|
||||
}
|
||||
}
|
||||
|
||||
public static class Agent {
|
||||
@SuppressWarnings("unused,NullableProblems") @NonNull private String id;
|
||||
@SuppressWarnings("unused,NullableProblems") @NonNull private String name;
|
||||
|
||||
@NonNull public String name() {
|
||||
return name;
|
||||
}
|
||||
}
|
||||
|
||||
public static class NotificationList {
|
||||
@SuppressWarnings("unused,NullableProblems") @NonNull private List<Notification> list;
|
||||
|
||||
@NonNull public List<Notification> getNotifications() {
|
||||
return list;
|
||||
}
|
||||
}
|
||||
|
||||
public static class QueryNotifications {
|
||||
@SuppressWarnings("unused,NullableProblems") @NonNull private NotificationList notifications;
|
||||
|
||||
@NonNull public List<Notification> get() {
|
||||
return notifications.getNotifications();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -14,7 +14,6 @@ android.useDeprecatedNdk=true
|
|||
BUTTERKNIFE_VERSION=8.6.0
|
||||
DAGGER_VERSION=2.13
|
||||
LEAK_CANARY=1.5.4
|
||||
RETROFIT_VERSION=2.3.0
|
||||
org.gradle.jvmargs=-Xmx1536M
|
||||
|
||||
#TODO: Temporary disabled. https://developer.android.com/studio/build/gradle-plugin-3-0-0-migration.html#aapt2
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue