From b2d0bb64d782d5080748f0021faac8a9884f7a4a Mon Sep 17 00:00:00 2001 From: M66B Date: Mon, 9 Aug 2021 18:38:53 +0200 Subject: [PATCH] Improved Gmail error handling --- .../java/eu/faircode/email/FragmentGmail.java | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/app/src/main/java/eu/faircode/email/FragmentGmail.java b/app/src/main/java/eu/faircode/email/FragmentGmail.java index c8c8b3ee90..efbffe47f0 100644 --- a/app/src/main/java/eu/faircode/email/FragmentGmail.java +++ b/app/src/main/java/eu/faircode/email/FragmentGmail.java @@ -149,6 +149,8 @@ public class FragmentGmail extends FragmentBase { @Override public void onClick(View v) { try { + etName.clearFocus(); + Helper.hideKeyboard(view); grpError.setVisibility(View.GONE); String name = etName.getText().toString().trim(); @@ -270,12 +272,16 @@ public class FragmentGmail extends FragmentBase { } private void onNoAccountSelected(int resultCode, Intent data) { - AccountManager am = AccountManager.get(getContext()); - Account[] accounts = am.getAccountsByType(TYPE_GOOGLE); - if (accounts.length == 0) { - Log.e("newChooseAccountIntent without result=" + resultCode + " data=" + data); - ToastEx.makeText(getContext(), R.string.title_no_account, Toast.LENGTH_LONG).show(); - } + if (resultCode == RESULT_OK) { + AccountManager am = AccountManager.get(getContext()); + Account[] accounts = am.getAccountsByType(TYPE_GOOGLE); + if (accounts.length == 0) + Log.e("newChooseAccountIntent without result=" + resultCode + " data=" + data); + + tvError.setText(getString(R.string.title_no_account) + " (" + accounts.length + ")"); + grpError.setVisibility(View.VISIBLE); + } else + ToastEx.makeText(getContext(), android.R.string.cancel, Toast.LENGTH_SHORT).show(); } private void onAccountSelected(Intent data) {