Account switcher

This commit is contained in:
Grishka
2022-02-28 10:18:01 +03:00
parent a5cd675c17
commit bb9cf5f5df
4 changed files with 79 additions and 0 deletions

View File

@@ -0,0 +1,25 @@
package org.joinmastodon.android.api.requests.oauth;
import org.joinmastodon.android.api.MastodonAPIRequest;
public class RevokeOauthToken extends MastodonAPIRequest<Object>{
public RevokeOauthToken(String clientID, String clientSecret, String token){
super(HttpMethod.POST, "/oauth/revoke", Object.class);
setRequestBody(new Body(clientID, clientSecret, token));
}
@Override
protected String getPathPrefix(){
return "";
}
private static class Body{
public String clientId, clientSecret, token;
public Body(String clientId, String clientSecret, String token){
this.clientId=clientId;
this.clientSecret=clientSecret;
this.token=token;
}
}
}

View File

@@ -131,6 +131,13 @@ public class AccountSessionManager{
return lastActiveAccountID;
}
public void setLastActiveAccountID(String id){
if(!sessions.containsKey(id))
throw new IllegalStateException("Account session "+id+" not found");
lastActiveAccountID=id;
prefs.edit().putString("lastActiveAccount", id).apply();
}
public void removeAccount(String id){
AccountSession session=getAccount(id);
sessions.remove(id);