diff --git a/app/src/main/java/eu/faircode/email/EmailService.java b/app/src/main/java/eu/faircode/email/EmailService.java index a9de8e181b..8cf581c425 100644 --- a/app/src/main/java/eu/faircode/email/EmailService.java +++ b/app/src/main/java/eu/faircode/email/EmailService.java @@ -19,6 +19,9 @@ package eu.faircode.email; Copyright 2018-2021 by Marcel Bokhorst (M66B) */ +import static eu.faircode.email.ServiceAuthenticator.AUTH_TYPE_GMAIL; +import static eu.faircode.email.ServiceAuthenticator.AUTH_TYPE_OAUTH; + import android.content.Context; import android.content.SharedPreferences; import android.os.ParcelFileDescriptor; @@ -93,9 +96,6 @@ import javax.net.ssl.TrustManager; import javax.net.ssl.TrustManagerFactory; import javax.net.ssl.X509TrustManager; -import static eu.faircode.email.ServiceAuthenticator.AUTH_TYPE_GMAIL; -import static eu.faircode.email.ServiceAuthenticator.AUTH_TYPE_OAUTH; - // IMAP standards: https://imapwiki.org/Specs public class EmailService implements AutoCloseable { @@ -313,7 +313,7 @@ public class EmailService implements AutoCloseable { account.user, account.password, new ServiceAuthenticator.IAuthenticated() { @Override - public void onPasswordChanged(String newPassword) { + public void onPasswordChanged(Context context, String newPassword) { DB db = DB.getInstance(context); int accounts = db.account().setAccountPassword(account.id, newPassword); int identities = db.identity().setIdentityPassword(account.id, account.user, newPassword, account.auth_type); @@ -330,7 +330,7 @@ public class EmailService implements AutoCloseable { identity.user, identity.password, new ServiceAuthenticator.IAuthenticated() { @Override - public void onPasswordChanged(String newPassword) { + public void onPasswordChanged(Context context, String newPassword) { DB db = DB.getInstance(context); int count = db.identity().setIdentityPassword(identity.id, newPassword); EntityLog.log(context, identity.email + " token refreshed=" + count); diff --git a/app/src/main/java/eu/faircode/email/ServiceAuthenticator.java b/app/src/main/java/eu/faircode/email/ServiceAuthenticator.java index acf2646ce8..164b49af6f 100644 --- a/app/src/main/java/eu/faircode/email/ServiceAuthenticator.java +++ b/app/src/main/java/eu/faircode/email/ServiceAuthenticator.java @@ -19,6 +19,8 @@ package eu.faircode.email; Copyright 2018-2021 by Marcel Bokhorst (M66B) */ +import static eu.faircode.email.GmailState.TYPE_GOOGLE; + import android.accounts.AuthenticatorException; import android.accounts.OperationCanceledException; import android.content.Context; @@ -41,8 +43,6 @@ import javax.mail.Authenticator; import javax.mail.MessagingException; import javax.mail.PasswordAuthentication; -import static eu.faircode.email.GmailState.TYPE_GOOGLE; - public class ServiceAuthenticator extends Authenticator { private Context context; private int auth; @@ -98,7 +98,7 @@ public class ServiceAuthenticator extends Authenticator { if (!Objects.equals(password, newPassword)) { password = newPassword; if (intf != null) - intf.onPasswordChanged(password); + intf.onPasswordChanged(context, password); } return authState.getAccessToken(); @@ -113,7 +113,7 @@ public class ServiceAuthenticator extends Authenticator { if (!Objects.equals(password, newPassword)) { password = newPassword; if (intf != null) - intf.onPasswordChanged(password); + intf.onPasswordChanged(context, password); } return authState.getAccessToken(); @@ -122,7 +122,7 @@ public class ServiceAuthenticator extends Authenticator { } interface IAuthenticated { - void onPasswordChanged(String newPassword); + void onPasswordChanged(Context context, String newPassword); } private static void OAuthRefresh(Context context, String id, AuthState authState, boolean expire, long keep_alive)