diff --git a/app/src/main/java/eu/faircode/email/FragmentMessages.java b/app/src/main/java/eu/faircode/email/FragmentMessages.java index f602eb5c54..ea3f29ad1a 100644 --- a/app/src/main/java/eu/faircode/email/FragmentMessages.java +++ b/app/src/main/java/eu/faircode/email/FragmentMessages.java @@ -4488,7 +4488,8 @@ public class FragmentMessages extends FragmentBase implements SharedPreferences. if (!checkReporting()) if (!checkReview()) if (!checkFingerprint()) - checkGmail(); + if (!checkGmail()) + checkOutlook(); prefs.registerOnSharedPreferenceChangeListener(this); onSharedPreferenceChanged(prefs, "pro"); @@ -4772,7 +4773,7 @@ public class FragmentMessages extends FragmentBase implements SharedPreferences. if (accounts != null) for (EntityAccount account : accounts) if (account.isGmail()) - if (account.auth_type == ServiceAuthenticator.AUTH_TYPE_OAUTH) + if (account.auth_type == ServiceAuthenticator.AUTH_TYPE_GMAIL) oauth++; else if (account.auth_type == ServiceAuthenticator.AUTH_TYPE_PASSWORD) passwd++; @@ -4813,6 +4814,83 @@ public class FragmentMessages extends FragmentBase implements SharedPreferences. return true; } + private boolean checkOutlook() { + SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getContext()); + if (prefs.getBoolean("outlook_checked", false)) + return false; + + Calendar cal = Calendar.getInstance(); + cal.set(Calendar.MILLISECOND, 0); + cal.set(Calendar.SECOND, 0); + cal.set(Calendar.MINUTE, 0); + cal.set(Calendar.HOUR, 0); + cal.set(Calendar.DAY_OF_MONTH, 1); + cal.set(Calendar.MONTH, Calendar.OCTOBER); + cal.set(Calendar.YEAR, 2022); + + cal.add(Calendar.MONTH, 2); + + long now = new Date().getTime(); + if (now > cal.getTimeInMillis()) { + prefs.edit().putBoolean("outlook_checked", true).apply(); + return false; + } + + new SimpleTask>() { + @Override + protected List onExecute(Context context, Bundle args) throws Throwable { + DB db = DB.getInstance(context); + return db.account().getAccounts(); + } + + @Override + protected void onExecuted(Bundle args, List accounts) { + int oauth = 0; + int passwd = 0; + if (accounts != null) + for (EntityAccount account : accounts) + if (account.isOutlook()) + if (account.auth_type == ServiceAuthenticator.AUTH_TYPE_OAUTH) + oauth++; + else if (account.auth_type == ServiceAuthenticator.AUTH_TYPE_PASSWORD) + passwd++; + + if (oauth + passwd == 0) { + prefs.edit().putBoolean("outlook_checked", true).apply(); + return; + } + + final int resid = (passwd > 0 + ? R.string.title_check_outlook_password + : R.string.title_check_outlook_oauth); + final Snackbar snackbar = Snackbar.make(view, resid, Snackbar.LENGTH_INDEFINITE) + .setGestureInsetBottomIgnored(true); + snackbar.setAction(R.string.title_info, new View.OnClickListener() { + @Override + public void onClick(View v) { + snackbar.dismiss(); + Helper.viewFAQ(v.getContext(), 14); + prefs.edit().putBoolean("outlook_checked", true).apply(); + } + }); + snackbar.addCallback(new Snackbar.Callback() { + @Override + public void onDismissed(Snackbar transientBottomBar, int event) { + prefs.edit().putBoolean("outlook_checked", true).apply(); + } + }); + snackbar.show(); + } + + @Override + protected void onException(Bundle args, Throwable ex) { + Log.e(ex); + } + }.execute(this, new Bundle(), "outlook:check"); + + return true; + } + @Override public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) { inflater.inflate(R.menu.menu_messages, menu); diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 447df09e83..2b54c87d90 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -330,6 +330,9 @@ Your Gmail accounts will continue to work after May 30, 2022 Some of your Gmail accounts may stop working after May 30, 2022 + Your Outlook accounts will continue to work after October 1, 2022 + Some of your Outlook accounts may stop working after October 1, 2022 + More advanced options You are navigating to the more advanced options.