mirror of
https://github.com/commons-app/apps-android-commons.git
synced 2025-10-29 22:03:55 +01:00
Upon creating AuthenticatedActivity, now checking if the user is blocked via api call and notifying the user if they are blocked via snackbar
This commit is contained in:
parent
8cd8baf49c
commit
39096cf30b
5 changed files with 43 additions and 0 deletions
|
|
@ -615,6 +615,26 @@ public class ApacheHttpClientMediaWikiApi implements MediaWikiApi {
|
|||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isUserBlocked() {
|
||||
boolean userBlocked = false;
|
||||
try {
|
||||
ApiResult result = api.action("query")
|
||||
.param("action", "query")
|
||||
.param("format", "xml")
|
||||
.param("meta", "userinfo")
|
||||
.param("uiprop", "blockinfo")
|
||||
.get();
|
||||
if(result != null) {
|
||||
userBlocked = !result.getString("/api/query/userinfo/@blockexpiry").isEmpty();
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
return userBlocked;
|
||||
}
|
||||
|
||||
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
|
||||
try {
|
||||
|
|
|
|||
|
|
@ -75,6 +75,8 @@ public interface MediaWikiApi {
|
|||
@NonNull
|
||||
Single<Integer> getUploadCount(String userName);
|
||||
|
||||
boolean isUserBlocked();
|
||||
|
||||
interface ProgressListener {
|
||||
void onProgress(long transferred, long total);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue