Improved error dialog

pull/213/head
M66B 1 year ago
parent 33c8576a84
commit 0f95b82e7f

@ -71,7 +71,6 @@ public class ActivityError extends ActivityBase {
long identity = intent.getLongExtra("identity", -1L);
int protocol = intent.getIntExtra("protocol", -1);
int auth_type = intent.getIntExtra("auth_type", -1);
boolean authorize = intent.getBooleanExtra("authorize", false);
String personal = intent.getStringExtra("personal");
String address = intent.getStringExtra("address");
int faq = intent.getIntExtra("faq", -1);
@ -80,16 +79,42 @@ public class ActivityError extends ActivityBase {
tvMessage.setMovementMethod(LinkMovementMethod.getInstance());
tvMessage.setText(message);
btnPassword.setText(authorize ? R.string.title_setup_oauth_authorize : R.string.title_password);
boolean password = (auth_type == ServiceAuthenticator.AUTH_TYPE_PASSWORD);
btnPassword.setText(password ? R.string.title_password : R.string.title_setup_oauth_authorize);
btnPassword.setCompoundDrawablesRelativeWithIntrinsicBounds(
0, 0,
authorize ? R.drawable.twotone_check_24 : R.drawable.twotone_edit_24, 0);
password ? R.drawable.twotone_edit_24 : R.drawable.twotone_check_24, 0);
btnPassword.setVisibility(account < 0 ? View.GONE : View.VISIBLE);
btnPassword.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
if (authorize)
if (auth_type == ServiceAuthenticator.AUTH_TYPE_GMAIL)
startActivity(new Intent(ActivityError.this, ActivitySetup.class)
.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK)
.putExtra("target", "gmail")
.putExtra("personal", personal)
.putExtra("address", address));
else if (auth_type == ServiceAuthenticator.AUTH_TYPE_OAUTH) {
try {
EmailProvider eprovider = EmailProvider.getProvider(ActivityError.this, provider);
startActivity(new Intent(ActivityError.this, ActivitySetup.class)
.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK)
.putExtra("target", "oauth")
.putExtra("id", eprovider.id)
.putExtra("name", eprovider.description)
.putExtra("privacy", eprovider.oauth.privacy)
.putExtra("askAccount", eprovider.oauth.askAccount)
.putExtra("askTenant", eprovider.oauth.askTenant())
.putExtra("personal", personal)
.putExtra("address", address));
} catch (Throwable ex) {
Log.e(ex);
startActivity(new Intent(ActivityError.this, ActivitySetup.class)
.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK));
}
} else if (auth_type == ServiceAuthenticator.AUTH_TYPE_GRAPH)
startActivity(new Intent(ActivityError.this, ActivitySetup.class)
.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK)
.putExtra("target", "oauth")

@ -267,13 +267,11 @@ public class ActivitySetup extends ActivityBase implements FragmentManager.OnBac
onEditAccount(intent);
else if ("identities".equals(target) && id > 0)
onEditIdentity(intent);
else if ("oauth".equals(target)) {
FragmentOAuth fragment = new FragmentOAuth();
fragment.setArguments(intent.getExtras());
FragmentTransaction fragmentTransaction = getSupportFragmentManager().beginTransaction();
fragmentTransaction.replace(R.id.content_frame, fragment).addToBackStack("quick");
fragmentTransaction.commit();
} else {
else if ("gmail".equals(target))
onGmail(intent);
else if ("oauth".equals(target))
onOAuth(intent);
else {
FragmentTransaction fragmentTransaction = getSupportFragmentManager().beginTransaction();
if ("accounts".equals(target))
fragmentTransaction.replace(R.id.content_frame, new FragmentAccounts()).addToBackStack("accounts");

@ -420,8 +420,10 @@ public class AdapterAccount extends RecyclerView.Adapter<AdapterAccount.ViewHold
popupMenu.getMenu().add(Menu.NONE, R.string.title_log, order++, R.string.title_log);
}
if (debug)
if (debug || BuildConfig.DEBUG) {
popupMenu.getMenu().add(Menu.NONE, R.string.title_reset, order++, R.string.title_reset);
popupMenu.getMenu().add(Menu.NONE, R.string.title_setup_oauth_authorize, order++, R.string.title_setup_oauth_authorize);
}
popupMenu.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() {
@Override
@ -460,6 +462,9 @@ public class AdapterAccount extends RecyclerView.Adapter<AdapterAccount.ViewHold
} else if (itemId == R.string.title_reset) {
onActionReset();
return true;
} else if (itemId == R.string.title_setup_oauth_authorize) {
onActionAuthorize();
return true;
}
return false;
}
@ -684,6 +689,20 @@ public class AdapterAccount extends RecyclerView.Adapter<AdapterAccount.ViewHold
}.execute(context, owner, args, "account:reset");
}
private void onActionAuthorize() {
Intent intent = new Intent(context, ActivityError.class);
intent.putExtra("title", "Test");
intent.putExtra("message", account.error);
intent.putExtra("provider", account.provider);
intent.putExtra("account", account.id);
intent.putExtra("protocol", account.protocol);
intent.putExtra("auth_type", account.auth_type);
intent.putExtra("personal", "personal");
intent.putExtra("address", "address");
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
context.startActivity(intent);
}
private void onDelete() {
Bundle args = new Bundle();
args.putLong("id", account.id);

@ -4932,8 +4932,8 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
intent.putExtra("provider", "outlookgraph");
intent.putExtra("account", message.account);
intent.putExtra("protocol", message.accountProtocol);
intent.putExtra("auth_type", ServiceAuthenticator.AUTH_TYPE_GRAPH);
intent.putExtra("identity", message.identity);
intent.putExtra("authorize", true);
intent.putExtra("personal", message.identityName);
intent.putExtra("address", message.identityEmail);
intent.putExtra("faq", 14);

@ -491,8 +491,8 @@ public class ServiceSend extends ServiceBase implements SharedPreferences.OnShar
intent.putExtra("provider", "outlookgraph");
intent.putExtra("account", identity.account);
intent.putExtra("protocol", protocol);
intent.putExtra("auth_type", AUTH_TYPE_GRAPH);
intent.putExtra("identity", identity.id);
intent.putExtra("authorize", true);
intent.putExtra("personal", identity.name);
intent.putExtra("address", identity.user);
intent.putExtra("faq", 14);

Loading…
Cancel
Save