Improved Gmail error handling

This commit is contained in:
M66B 2021-08-09 18:38:53 +02:00
parent c0618b6685
commit b2d0bb64d7
1 changed files with 12 additions and 6 deletions

View File

@ -149,6 +149,8 @@ public class FragmentGmail extends FragmentBase {
@Override @Override
public void onClick(View v) { public void onClick(View v) {
try { try {
etName.clearFocus();
Helper.hideKeyboard(view);
grpError.setVisibility(View.GONE); grpError.setVisibility(View.GONE);
String name = etName.getText().toString().trim(); String name = etName.getText().toString().trim();
@ -270,12 +272,16 @@ public class FragmentGmail extends FragmentBase {
} }
private void onNoAccountSelected(int resultCode, Intent data) { private void onNoAccountSelected(int resultCode, Intent data) {
AccountManager am = AccountManager.get(getContext()); if (resultCode == RESULT_OK) {
Account[] accounts = am.getAccountsByType(TYPE_GOOGLE); AccountManager am = AccountManager.get(getContext());
if (accounts.length == 0) { Account[] accounts = am.getAccountsByType(TYPE_GOOGLE);
Log.e("newChooseAccountIntent without result=" + resultCode + " data=" + data); if (accounts.length == 0)
ToastEx.makeText(getContext(), R.string.title_no_account, Toast.LENGTH_LONG).show(); 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) { private void onAccountSelected(Intent data) {