mirror of
https://github.com/commons-app/apps-android-commons.git
synced 2025-10-29 22:03:55 +01:00
Feedback module (#1742)
* Implemented Statistics * Basic Structure Implemented * Layout made screen independent and menu inflated * Share Screenshot using cache * Improved the Image Bound and added strings * Improved the quality of Pr * Wired to navigation drawer * Changed the bounds of the image * Added Info icon * Removed the unecessary functionality * Updated JavaDocs and fetch the username * Fetch JsonObject from the api using JavaRx and OkHttp * Added JavaDocs and improved quality * fixed strings file * Improved the quality of pr * Render thanks , images used in articles on screen * fetch and rendered the upload count * FeaturedImages statistics rendered and Javadocs added * added ProgressBar * Added Class for calculating level * added level info and returned level info * level up info rendered on achievement activity * Inflated Level Number * Added the structure for badge * Added LevelUpInfo Programmetically on Drawable * aligned the text * changed the text * Implemented the structure for changing colour of drawable * Added functionality to change colours of badge during runtime * Added custom alert for share option * Improved the UI of screen * Added the alertDialog for info button * Improved the quality of PR * Added Builder model * Added Enum Model and increased levels to 15 * removed redundant class * Changed strings and added subtext * Feedback Module: Add reverts rate parameter (#1649) * Fetched Revert Count * Refactored Achievements class and display the fetched results * Refactored the levelController to include revert as parameter * Fixed error * Fixed bug * Added information for parameters and improved code quality * Javadocs added * Added null check and javadocs * Removed extra spaces
This commit is contained in:
parent
86878fb62d
commit
e9c0aa22ea
25 changed files with 2456 additions and 17 deletions
|
|
@ -23,6 +23,7 @@ import org.apache.http.impl.conn.tsccm.ThreadSafeClientConnManager;
|
|||
import org.apache.http.params.BasicHttpParams;
|
||||
import org.apache.http.params.CoreProtocolPNames;
|
||||
import org.apache.http.util.EntityUtils;
|
||||
import org.json.JSONObject;
|
||||
import org.mediawiki.api.ApiResult;
|
||||
import org.mediawiki.api.MWApi;
|
||||
import org.w3c.dom.Element;
|
||||
|
|
@ -53,6 +54,10 @@ import fr.free.nrw.commons.notification.NotificationUtils;
|
|||
import in.yuvi.http.fluent.Http;
|
||||
import io.reactivex.Observable;
|
||||
import io.reactivex.Single;
|
||||
import okhttp3.HttpUrl;
|
||||
import okhttp3.OkHttpClient;
|
||||
import okhttp3.Request;
|
||||
import okhttp3.Response;
|
||||
import timber.log.Timber;
|
||||
|
||||
import static fr.free.nrw.commons.utils.ContinueUtils.getQueryContinue;
|
||||
|
|
@ -902,13 +907,11 @@ public class ApacheHttpClientMediaWikiApi implements MediaWikiApi {
|
|||
.param("meta", "userinfo")
|
||||
.param("uiprop", "blockinfo")
|
||||
.get();
|
||||
if(result != null) {
|
||||
if (result != null) {
|
||||
String blockEnd = result.getString("/api/query/userinfo/@blockexpiry");
|
||||
if(blockEnd.equals("infinite"))
|
||||
{
|
||||
if (blockEnd.equals("infinite")) {
|
||||
userBlocked = true;
|
||||
}
|
||||
else if (!blockEnd.isEmpty()) {
|
||||
} else if (!blockEnd.isEmpty()) {
|
||||
Date endDate = parseMWDate(blockEnd);
|
||||
Date current = new Date();
|
||||
userBlocked = endDate.after(current);
|
||||
|
|
@ -922,6 +925,68 @@ public class ApacheHttpClientMediaWikiApi implements MediaWikiApi {
|
|||
return userBlocked;
|
||||
}
|
||||
|
||||
/**
|
||||
* This takes userName as input, which is then used to fetch the feedback/achievements
|
||||
* statistics using OkHttp and JavaRx. This function return JSONObject
|
||||
* @param userName
|
||||
* @return
|
||||
*/
|
||||
@NonNull
|
||||
@Override
|
||||
public Single<JSONObject> getAchievements(String userName) {
|
||||
final String fetchAchievementUrlTemplate =
|
||||
wikiMediaToolforgeUrl + "urbanecmbot/commonsmisc/feedback.py";
|
||||
return Single.fromCallable(() -> {
|
||||
String url = String.format(
|
||||
Locale.ENGLISH,
|
||||
fetchAchievementUrlTemplate,
|
||||
new PageTitle(userName).getText());
|
||||
HttpUrl.Builder urlBuilder = HttpUrl.parse(url).newBuilder();
|
||||
urlBuilder.addQueryParameter("user", userName);
|
||||
Log.i("url", urlBuilder.toString());
|
||||
Request request = new Request.Builder()
|
||||
.url(urlBuilder.toString())
|
||||
.build();
|
||||
OkHttpClient client = new OkHttpClient();
|
||||
Response response = client.newCall(request).execute();
|
||||
String jsonData = response.body().string();
|
||||
JSONObject jsonObject = new JSONObject(jsonData);
|
||||
return jsonObject;
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* This takes userName as input, which is then used to fetch the no of images deleted
|
||||
* using OkHttp and JavaRx. This function return JSONObject
|
||||
* @param userName
|
||||
* @return
|
||||
*/
|
||||
@NonNull
|
||||
@Override
|
||||
public Single<JSONObject> getRevertCount(String userName){
|
||||
final String fetchRevertCountUrlTemplate =
|
||||
wikiMediaToolforgeUrl + "urbanecmbot/commonsmisc/feedback.py";
|
||||
return Single.fromCallable(() -> {
|
||||
String url = String.format(
|
||||
Locale.ENGLISH,
|
||||
fetchRevertCountUrlTemplate,
|
||||
new PageTitle(userName).getText());
|
||||
HttpUrl.Builder urlBuilder = HttpUrl.parse(url).newBuilder();
|
||||
urlBuilder.addQueryParameter("user", userName);
|
||||
urlBuilder.addQueryParameter("fetch","deletedUploads");
|
||||
Log.i("url", urlBuilder.toString());
|
||||
Request request = new Request.Builder()
|
||||
.url(urlBuilder.toString())
|
||||
.build();
|
||||
OkHttpClient client = new OkHttpClient();
|
||||
Response response = client.newCall(request).execute();
|
||||
String jsonData = response.body().string();
|
||||
JSONObject jsonRevertObject = new JSONObject(jsonData);
|
||||
return jsonRevertObject;
|
||||
});
|
||||
}
|
||||
|
||||
private Date parseMWDate(String mwDate) {
|
||||
SimpleDateFormat isoFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'Z'", Locale.ENGLISH); // Assuming MW always gives me UTC
|
||||
isoFormat.setTimeZone(TimeZone.getTimeZone("UTC"));
|
||||
|
|
|
|||
|
|
@ -3,6 +3,8 @@ package fr.free.nrw.commons.mwapi;
|
|||
import android.support.annotation.NonNull;
|
||||
import android.support.annotation.Nullable;
|
||||
|
||||
import org.json.JSONObject;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.util.List;
|
||||
|
|
@ -97,6 +99,12 @@ public interface MediaWikiApi {
|
|||
|
||||
boolean isUserBlockedFromCommons();
|
||||
|
||||
@NonNull
|
||||
Single<JSONObject> getAchievements(String userName);
|
||||
|
||||
@NonNull
|
||||
Single<JSONObject> getRevertCount(String userName);
|
||||
|
||||
interface ProgressListener {
|
||||
void onProgress(long transferred, long total);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue