Clear access token of not valid anymore

This commit is contained in:
jannis 2020-01-08 12:37:45 +01:00
parent 59c1781dd4
commit 832f6441cb
2 changed files with 9 additions and 5 deletions

View File

@ -118,12 +118,12 @@ public class OAuthAuthentication {
.putBoolean("authenticated", true).apply();
}
public void clearAccessToken(){
void clearAccessToken() {
preferences.edit().putBoolean("authenticated", false).apply();
}
private void retrieveAccessToken(String verificationCode){
handler.post(() -> dialogController.show());
handler.post(dialogController::show);
try{
oAuthProvider.retrieveAccessToken(oAuthConsumer, verificationCode);
handler.post(() -> {

View File

@ -93,8 +93,12 @@ public class OsmTraceUploader {
}catch (Exception e){
e.printStackTrace();
handler.post(() -> {
@StringRes int textRes= e instanceof OsmAuthorizationException ?
R.string.uploadFailedOsmNotAuthorized : R.string.uploadFailed;
@StringRes int textRes = R.string.uploadFailed;
if (e instanceof OsmAuthorizationException) {
textRes = R.string.uploadFailedOsmNotAuthorized;
new OAuthAuthentication(handler, activity, null).clearAccessToken();
}
Toast.makeText(activity, textRes, Toast.LENGTH_LONG).show();
dialogController.cancel();
@ -104,7 +108,7 @@ public class OsmTraceUploader {
}
private void executeTask(){
handler.post(() -> dialogController.show());
handler.post(dialogController::show);
setProgress(0);
if(cut){ cut(); }
setProgress(20);