Merge pull request #3889 from deltachat/adb/issue-3688

avoid superfluous error message when user cancel configuration
This commit is contained in:
adb 2025-08-18 15:12:16 +02:00 committed by GitHub
commit 700d11f600
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 25 additions and 12 deletions

View file

@ -5,6 +5,7 @@
* target Android 15
* improve readability of info messages in dark mode
* fix Direct Share shortcuts
* fix: don't show error message when cancelling profile creation
## v2.11.0
2025-08

View file

@ -87,7 +87,10 @@ public class InstantOnboardingActivity extends BaseActionBarActivity implements
private AttachmentManager attachmentManager;
private Bitmap avatarBmp;
private @Nullable ProgressDialog progressDialog;
private boolean cancelled;
private DcContext dcContext;
@Override
@ -433,7 +436,6 @@ public class InstantOnboardingActivity extends BaseActionBarActivity implements
}
private void progressSuccess() {
DcHelper.getEventCenter(this).endCaptureNextError();
if (progressDialog != null) {
progressDialog.dismiss();
}
@ -492,11 +494,14 @@ public class InstantOnboardingActivity extends BaseActionBarActivity implements
progressDialog = null;
}
cancelled = false;
progressDialog = new ProgressDialog(this);
progressDialog.setMessage(getResources().getString(R.string.one_moment));
progressDialog.setCanceledOnTouchOutside(false);
progressDialog.setCancelable(false);
progressDialog.setButton(DialogInterface.BUTTON_NEGATIVE, getResources().getString(android.R.string.cancel), (dialog, which) -> {
cancelled = true;
dcContext.stopOngoingProcess();
});
progressDialog.show();
@ -507,9 +512,13 @@ public class InstantOnboardingActivity extends BaseActionBarActivity implements
Rpc rpc = DcHelper.getRpc(this);
try {
rpc.addTransportFromQr(dcContext.getAccountId(), qrCode);
DcHelper.getEventCenter(this).endCaptureNextError();
progressSuccess();
} catch (RpcException e) {
Util.runOnMain(() -> progressError(e.getMessage()));
DcHelper.getEventCenter(this).endCaptureNextError();
if (!cancelled) {
Util.runOnMain(() -> progressError(e.getMessage()));
}
}
}).start();
}

View file

@ -87,6 +87,7 @@ public class RegistrationActivity extends BaseActionBarActivity implements DcEve
private Group advancedGroup;
private ImageView advancedIcon;
private ProgressDialog progressDialog;
private boolean cancelled = false;
Spinner imapSecurity;
Spinner smtpSecurity;
@ -563,6 +564,7 @@ public class RegistrationActivity extends BaseActionBarActivity implements DcEve
return;
}
cancelled = false;
setupConfig();
if (progressDialog != null) {
@ -574,7 +576,10 @@ public class RegistrationActivity extends BaseActionBarActivity implements DcEve
progressDialog.setMessage(getString(R.string.one_moment));
progressDialog.setCanceledOnTouchOutside(false);
progressDialog.setCancelable(false);
progressDialog.setButton(DialogInterface.BUTTON_NEGATIVE, getString(android.R.string.cancel), (dialog, which) -> stopLoginProcess());
progressDialog.setButton(DialogInterface.BUTTON_NEGATIVE, getString(android.R.string.cancel), (dialog, which) -> {
cancelled = true;
DcHelper.getContext(this).stopOngoingProcess();
});
progressDialog.show();
}
@ -613,11 +618,13 @@ public class RegistrationActivity extends BaseActionBarActivity implements DcEve
startActivity(conversationList);
finish();
} catch (RpcException e) {
Util.runOnMain(() -> {
DcHelper.getEventCenter(this).endCaptureNextError();
progressDialog.dismiss();
WelcomeActivity.maybeShowConfigurationError(this, e.getMessage());
});
DcHelper.getEventCenter(this).endCaptureNextError();
if (!cancelled) {
Util.runOnMain(() -> {
progressDialog.dismiss();
WelcomeActivity.maybeShowConfigurationError(this, e.getMessage());
});
}
}
}).start();
}
@ -631,10 +638,6 @@ public class RegistrationActivity extends BaseActionBarActivity implements DcEve
return value.isEmpty()? null : value;
}
private void stopLoginProcess() {
DcHelper.getContext(this).stopOngoingProcess();
}
@Override
public void handleEvent(@NonNull DcEvent event) {
if (event.getId()==DcContext.DC_EVENT_CONFIGURE_PROGRESS) {