Check the selected account and use it when posting
This commit is contained in:
parent
5cccd03e2f
commit
38eaf4e25f
|
@ -62,8 +62,14 @@ public class MainActivity extends AppCompatActivity {
|
||||||
Account[] accounts = accountManager.getAccountsByType(accountType);
|
Account[] accounts = accountManager.getAccountsByType(accountType);
|
||||||
if (accounts.length == 0)
|
if (accounts.length == 0)
|
||||||
return;
|
return;
|
||||||
selectedAccount = accounts[0];
|
for (int i = 0; i < accounts.length; i++) {
|
||||||
authToken = token;
|
Log.i("micropub", "accounts["+i+"] = " + accounts[i].name + " " + accounts[i].type);
|
||||||
|
if (accounts[i].type.equals(accountType)&&accounts[i].name.equals(accountName)) {
|
||||||
|
selectedAccount = accounts[i];
|
||||||
|
authToken = token;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
String micropubBackend = accountManager.getUserData(selectedAccount, "micropub");
|
String micropubBackend = accountManager.getUserData(selectedAccount, "micropub");
|
||||||
if (micropubBackend == null) return;
|
if (micropubBackend == null) return;
|
||||||
|
@ -202,7 +208,11 @@ public class MainActivity extends AppCompatActivity {
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
accountManager.getAuthTokenByFeatures("Indieauth", "token", null, this, options, null, new OnTokenAcquired(this, callback, onError), null);
|
if (selectedAccount == null || authToken == null) {
|
||||||
|
accountManager.getAuthTokenByFeatures("Indieauth", "token", null, this, options, null, new OnTokenAcquired(this, callback, onError), null);
|
||||||
|
} else {
|
||||||
|
callback.tokenReady(selectedAccount.type, selectedAccount.name, authToken);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void galleryIntent(View view) {
|
public void galleryIntent(View view) {
|
||||||
|
|
|
@ -99,6 +99,7 @@ public class Authenticator extends AbstractAccountAuthenticator {
|
||||||
JsonParser parser = new JsonParser();
|
JsonParser parser = new JsonParser();
|
||||||
JsonObject element = parser.parse(body.string()).getAsJsonObject();
|
JsonObject element = parser.parse(body.string()).getAsJsonObject();
|
||||||
authToken = element.get("access_token").getAsString();
|
authToken = element.get("access_token").getAsString();
|
||||||
|
am.setAuthToken(account, authTokenType, authToken);
|
||||||
}
|
}
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
Log.e("micropub", "Failed getting token response", e);
|
Log.e("micropub", "Failed getting token response", e);
|
||||||
|
|
Loading…
Reference in New Issue
Block a user