mirror of
https://github.com/commons-app/apps-android-commons.git
synced 2025-10-26 20:33:53 +01:00
Create AccountUtil class
This commit is contained in:
parent
a1d8008901
commit
eb58a847b1
8 changed files with 77 additions and 46 deletions
|
|
@ -19,6 +19,7 @@ import com.nostra13.universalimageloader.core.ImageLoader;
|
|||
import com.nostra13.universalimageloader.core.ImageLoaderConfiguration;
|
||||
import com.nostra13.universalimageloader.utils.StorageUtils;
|
||||
|
||||
import fr.free.nrw.commons.auth.AccountUtil;
|
||||
import org.acra.ACRA;
|
||||
import org.acra.ReportingInteractionMode;
|
||||
import org.acra.annotation.ReportsCrashes;
|
||||
|
|
@ -35,7 +36,6 @@ import org.apache.http.params.CoreProtocolPNames;
|
|||
|
||||
import java.io.IOException;
|
||||
|
||||
import fr.free.nrw.commons.auth.WikiAccountAuthenticator;
|
||||
import fr.free.nrw.commons.caching.CacheController;
|
||||
import timber.log.Timber;
|
||||
|
||||
|
|
@ -73,6 +73,8 @@ public class CommonsApplication extends Application {
|
|||
|
||||
public CacheController cacheData;
|
||||
|
||||
public static CommonsApplication app;
|
||||
|
||||
public static AbstractHttpClient createHttpClient() {
|
||||
BasicHttpParams params = new BasicHttpParams();
|
||||
SchemeRegistry schemeRegistry = new SchemeRegistry();
|
||||
|
|
@ -91,6 +93,7 @@ public class CommonsApplication extends Application {
|
|||
@Override
|
||||
public void onCreate() {
|
||||
super.onCreate();
|
||||
app = this;
|
||||
|
||||
Timber.plant(new Timber.DebugTree());
|
||||
|
||||
|
|
@ -167,7 +170,7 @@ public class CommonsApplication extends Application {
|
|||
public Account getCurrentAccount() {
|
||||
if(currentAccount == null) {
|
||||
AccountManager accountManager = AccountManager.get(this);
|
||||
Account[] allAccounts = accountManager.getAccountsByType(WikiAccountAuthenticator.COMMONS_ACCOUNT_TYPE);
|
||||
Account[] allAccounts = accountManager.getAccountsByType(AccountUtil.accountType());
|
||||
if(allAccounts.length != 0) {
|
||||
currentAccount = allAccounts[0];
|
||||
}
|
||||
|
|
@ -183,7 +186,7 @@ public class CommonsApplication extends Application {
|
|||
return false; // This should never happen
|
||||
}
|
||||
|
||||
accountManager.invalidateAuthToken(WikiAccountAuthenticator.COMMONS_ACCOUNT_TYPE, api.getAuthCookie());
|
||||
accountManager.invalidateAuthToken(AccountUtil.accountType(), api.getAuthCookie());
|
||||
try {
|
||||
String authCookie = accountManager.blockingGetAuthToken(curAccount, "", false);
|
||||
api.setAuthCookie(authCookie);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue