OAuth behavior improvement

pull/212/head
M66B 2 years ago
parent aac99e0182
commit ef906c1be0

@ -336,13 +336,7 @@ public class FragmentOAuth extends FragmentBase {
etTenant.clearFocus(); etTenant.clearFocus();
Helper.hideKeyboard(view); Helper.hideKeyboard(view);
etName.setEnabled(false); setEnabled(false);
etEmail.setEnabled(false);
etTenant.setEnabled(false);
cbInboundOnly.setEnabled(false);
cbPop.setEnabled(false);
cbRecent.setEnabled(false);
cbUpdate.setEnabled(false);
btnOAuth.setEnabled(false); btnOAuth.setEnabled(false);
pbOAuth.setVisibility(View.VISIBLE); pbOAuth.setVisibility(View.VISIBLE);
hideError(); hideError();
@ -494,13 +488,7 @@ public class FragmentOAuth extends FragmentBase {
private void onHandleOAuth(@NonNull Intent data) { private void onHandleOAuth(@NonNull Intent data) {
try { try {
etName.setEnabled(true); setEnabled(true);
etEmail.setEnabled(true);
etTenant.setEnabled(true);
cbInboundOnly.setEnabled(true);
cbPop.setEnabled(true);
cbRecent.setEnabled(true);
cbUpdate.setEnabled(true);
Log.breadcrumb("onHandleOAuth", "id", id); Log.breadcrumb("onHandleOAuth", "id", id);
@ -517,6 +505,11 @@ public class FragmentOAuth extends FragmentBase {
final EmailProvider provider = EmailProvider.getProvider(getContext(), id); final EmailProvider provider = EmailProvider.getProvider(getContext(), id);
EmailProvider.OAuth oauth = (auth.state.endsWith(":graph") ? provider.graph : provider.oauth); EmailProvider.OAuth oauth = (auth.state.endsWith(":graph") ? provider.graph : provider.oauth);
if (provider.graph != null &&
provider.graph.enabled &&
!auth.state.endsWith(":graph"))
setEnabled(false);
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getContext()); SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getContext());
String json = prefs.getString("oauth." + auth.state, null); String json = prefs.getString("oauth." + auth.state, null);
prefs.edit().remove("oauth." + auth.state).apply(); prefs.edit().remove("oauth." + auth.state).apply();
@ -1034,17 +1027,21 @@ public class FragmentOAuth extends FragmentBase {
} }
private void onHandleCancel() { private void onHandleCancel() {
etName.setEnabled(true); setEnabled(true);
etEmail.setEnabled(true);
etTenant.setEnabled(true);
cbInboundOnly.setEnabled(true);
cbPop.setEnabled(true);
cbRecent.setEnabled(true);
cbUpdate.setEnabled(true);
btnOAuth.setEnabled(true); btnOAuth.setEnabled(true);
pbOAuth.setVisibility(View.GONE); pbOAuth.setVisibility(View.GONE);
} }
private void setEnabled(boolean enabled) {
etName.setEnabled(enabled);
etEmail.setEnabled(enabled);
etTenant.setEnabled(enabled);
cbInboundOnly.setEnabled(enabled);
cbPop.setEnabled(enabled);
cbRecent.setEnabled(enabled);
cbUpdate.setEnabled(enabled);
}
private void showError(Throwable ex) { private void showError(Throwable ex) {
Log.e(ex); Log.e(ex);
@ -1079,13 +1076,7 @@ public class FragmentOAuth extends FragmentBase {
btnHelp.setVisibility(provider != null && provider.link != null ? View.VISIBLE : View.GONE); btnHelp.setVisibility(provider != null && provider.link != null ? View.VISIBLE : View.GONE);
etName.setEnabled(true); setEnabled(true);
etEmail.setEnabled(true);
etTenant.setEnabled(true);
cbInboundOnly.setEnabled(true);
cbPop.setEnabled(true);
cbRecent.setEnabled(true);
cbUpdate.setEnabled(true);
btnOAuth.setEnabled(true); btnOAuth.setEnabled(true);
pbOAuth.setVisibility(View.GONE); pbOAuth.setVisibility(View.GONE);

Loading…
Cancel
Save