mirror of
https://github.com/commons-app/apps-android-commons.git
synced 2025-10-28 21:33:53 +01:00
Merge pull request #1573 from seannemann21/show-block-status
Show Block Status if use is blocked
This commit is contained in:
commit
b4d556a648
6 changed files with 145 additions and 0 deletions
|
|
@ -4,8 +4,13 @@ import android.os.Bundle;
|
|||
|
||||
import javax.inject.Inject;
|
||||
|
||||
import fr.free.nrw.commons.R;
|
||||
import fr.free.nrw.commons.mwapi.MediaWikiApi;
|
||||
import fr.free.nrw.commons.theme.NavigationBaseActivity;
|
||||
import fr.free.nrw.commons.utils.ViewUtil;
|
||||
import io.reactivex.Observable;
|
||||
import io.reactivex.android.schedulers.AndroidSchedulers;
|
||||
import io.reactivex.schedulers.Schedulers;
|
||||
|
||||
import static fr.free.nrw.commons.auth.AccountUtil.AUTH_COOKIE;
|
||||
|
||||
|
|
@ -34,6 +39,8 @@ public abstract class AuthenticatedActivity extends NavigationBaseActivity {
|
|||
if (savedInstanceState != null) {
|
||||
authCookie = savedInstanceState.getString(AUTH_COOKIE);
|
||||
}
|
||||
|
||||
showBlockStatus();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -45,4 +52,20 @@ public abstract class AuthenticatedActivity extends NavigationBaseActivity {
|
|||
protected abstract void onAuthCookieAcquired(String authCookie);
|
||||
|
||||
protected abstract void onAuthFailure();
|
||||
|
||||
/**
|
||||
* Makes API call to check if user is blocked from Commons. If the user is blocked, a snackbar
|
||||
* is created to notify the user
|
||||
*/
|
||||
protected void showBlockStatus()
|
||||
{
|
||||
Observable.fromCallable(() -> mediaWikiApi.isUserBlockedFromCommons())
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.filter(result -> result)
|
||||
.subscribe(result -> {
|
||||
ViewUtil.showSnackbar(findViewById(android.R.id.content), R.string.block_notification);
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -166,6 +166,7 @@ public class LoginActivity extends AccountAuthenticatorActivity {
|
|||
if (sessionManager.getCurrentAccount() != null
|
||||
&& sessionManager.isUserLoggedIn()
|
||||
&& sessionManager.getCachedAuthCookie() != null) {
|
||||
sessionManager.revalidateAuthToken();
|
||||
startMainActivity();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue