1
0
Fork 0
mirror of https://github.com/M66B/FairEmail.git synced 2025-02-24 07:01:05 +00:00

Added Gmail OAuth check

This commit is contained in:
M66B 2022-03-18 18:19:47 +01:00
parent 477a7996ce
commit 8ed4bb7eb5
3 changed files with 68 additions and 2 deletions

View file

@ -4355,7 +4355,8 @@ public class FragmentMessages extends FragmentBase implements SharedPreferences.
if (!checkDoze()) if (!checkDoze())
if (!checkReporting()) if (!checkReporting())
if (!checkReview()) if (!checkReview())
checkFingerprint(); if (!checkFingerprint())
checkGmail();
prefs.registerOnSharedPreferenceChangeListener(this); prefs.registerOnSharedPreferenceChangeListener(this);
onSharedPreferenceChanged(prefs, "pro"); onSharedPreferenceChanged(prefs, "pro");
@ -4586,6 +4587,67 @@ public class FragmentMessages extends FragmentBase implements SharedPreferences.
return true; return true;
} }
private boolean checkGmail() {
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getContext());
if (prefs.getBoolean("gmail_checked", false))
return false;
new SimpleTask<List<EntityAccount>>() {
@Override
protected List<EntityAccount> onExecute(Context context, Bundle args) throws Throwable {
DB db = DB.getInstance(context);
return db.account().getAccounts();
}
@Override
protected void onExecuted(Bundle args, List<EntityAccount> accounts) {
int oauth = 0;
int passwd = 0;
if (accounts != null)
for (EntityAccount account : accounts)
if (account.isGmail())
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("gmail_checked", true).apply();
return;
}
final int resid = (passwd > 0
? R.string.title_check_gmail_password
: R.string.title_check_gmail_oauth);
final Snackbar snackbar = Snackbar.make(view, resid, Snackbar.LENGTH_INDEFINITE)
.setGestureInsetBottomIgnored(true);
snackbar.setAction(passwd > 0 ? R.string.title_info : android.R.string.ok, new View.OnClickListener() {
@Override
public void onClick(View v) {
snackbar.dismiss();
if (resid == R.string.title_check_gmail_password)
Helper.viewFAQ(v.getContext(), 6);
prefs.edit().putBoolean("gmail_checked", true).apply();
}
});
snackbar.addCallback(new Snackbar.Callback() {
@Override
public void onDismissed(Snackbar transientBottomBar, int event) {
prefs.edit().putBoolean("gmail_checked", true).apply();
}
});
snackbar.show();
}
@Override
protected void onException(Bundle args, Throwable ex) {
Log.e(ex);
}
}.execute(this, new Bundle(), "gmail:check");
return true;
}
@Override @Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) { public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
inflater.inflate(R.menu.menu_messages, menu); inflater.inflate(R.menu.menu_messages, menu);

View file

@ -225,7 +225,8 @@ public class FragmentOptionsMisc extends FragmentBase implements SharedPreferenc
"raw_asked", "all_read_asked", "delete_asked", "raw_asked", "all_read_asked", "delete_asked",
"cc_bcc", "inline_image_hint", "compose_reference", "send_dialog", "cc_bcc", "inline_image_hint", "compose_reference", "send_dialog",
"setup_reminder", "setup_advanced", "setup_reminder", "setup_advanced",
"signature_images_hint" "signature_images_hint",
"gmail_checked"
}; };
@Override @Override

View file

@ -320,6 +320,9 @@
<string name="title_setup_reset_images">Show images</string> <string name="title_setup_reset_images">Show images</string>
<string name="title_setup_reset_links">Confirm links</string> <string name="title_setup_reset_links">Confirm links</string>
<string name="title_check_gmail_oauth">Your Gmail accounts will continue to work after May 30, 2022</string>
<string name="title_check_gmail_password">Some of your Gmail accounts may stop working after May 30, 2022</string>
<string name="title_advanced_hint_title">More advanced options</string> <string name="title_advanced_hint_title">More advanced options</string>
<string name="title_advanced_hint_message"> <string name="title_advanced_hint_message">
You are navigating to the more advanced options. You are navigating to the more advanced options.