mirror of
https://github.com/deltachat/deltachat-android.git
synced 2025-10-03 17:59:39 +02:00
adapt to new dc_configure() error handling
errors that should be shown to the user come from DC_EVENT_CONFIGURE_PROGRESS(data1=0) as data2 now; there is no need to show the captured error any longer (which was unreliable and hard to handle from core site). there is some capturing-code left as needed for other parts, but it is not used for configuration anymore.
This commit is contained in:
parent
4c9f336071
commit
b51cbfce1d
4 changed files with 28 additions and 25 deletions
|
@ -374,6 +374,8 @@
|
|||
<string name="delete_account">Delete account</string>
|
||||
<string name="delete_account_ask">Are you sure you want to delete your account data?</string>
|
||||
<string name="switching_account">Switching account…</string>
|
||||
<!-- Translations: %1$s will be replaced by a more detailed error message -->
|
||||
<string name="configuration_failed_with_error">Configuration failed. Error: %1$s</string>
|
||||
|
||||
<!-- share and forward messages -->
|
||||
<!-- Translators: Title shown above a chat/contact list; the user selects the recipient of the messages he wants to forward to -->
|
||||
|
|
|
@ -20,7 +20,6 @@ import androidx.appcompat.app.AlertDialog;
|
|||
import android.text.Editable;
|
||||
import android.text.TextUtils;
|
||||
import android.text.TextWatcher;
|
||||
import android.text.util.Linkify;
|
||||
import android.util.Patterns;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuInflater;
|
||||
|
@ -555,19 +554,7 @@ public class RegistrationActivity extends BaseActionBarActivity implements DcEve
|
|||
dcContext.maybeStartIo(); // start-io is also needed on errors to make previous config work in case of changes
|
||||
dcContext.endCaptureNextError();
|
||||
progressDialog.dismiss();
|
||||
if (dcContext.hasCapturedError()) {
|
||||
AlertDialog d = new AlertDialog.Builder(this)
|
||||
.setMessage(dcContext.getCapturedError())
|
||||
.setPositiveButton(android.R.string.ok, null)
|
||||
.create();
|
||||
d.show();
|
||||
try {
|
||||
//noinspection ConstantConditions
|
||||
Linkify.addLinks((TextView) d.findViewById(android.R.id.message), Linkify.WEB_URLS | Linkify.EMAIL_ADDRESSES);
|
||||
} catch(NullPointerException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
WelcomeActivity.maybeShowConfigurationError(this, data2);
|
||||
}
|
||||
else if (progress<1000/*progress in permille*/) {
|
||||
int percent = (int)progress / 10;
|
||||
|
|
|
@ -2,11 +2,14 @@ package org.thoughtcrime.securesms;
|
|||
|
||||
import android.Manifest;
|
||||
import android.annotation.SuppressLint;
|
||||
import android.app.Activity;
|
||||
import android.content.DialogInterface;
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.text.util.Linkify;
|
||||
import android.view.View;
|
||||
import android.widget.Button;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.appcompat.app.AlertDialog;
|
||||
|
@ -159,7 +162,7 @@ public class WelcomeActivity extends BaseActionBarActivity implements DcEventCen
|
|||
dcContext.captureNextError();
|
||||
|
||||
if (!dcContext.setConfigFromQr(qrCode)) {
|
||||
progressError();
|
||||
progressError(dcContext.getCapturedError());
|
||||
}
|
||||
|
||||
// calling configure() results in
|
||||
|
@ -168,15 +171,9 @@ public class WelcomeActivity extends BaseActionBarActivity implements DcEventCen
|
|||
dcContext.configure();
|
||||
}
|
||||
|
||||
private void progressError() {
|
||||
dcContext.endCaptureNextError();
|
||||
private void progressError(Object data2) {
|
||||
progressDialog.dismiss();
|
||||
if (dcContext.hasCapturedError()) {
|
||||
new AlertDialog.Builder(this)
|
||||
.setMessage(dcContext.getCapturedError())
|
||||
.setPositiveButton(android.R.string.ok, null)
|
||||
.show();
|
||||
}
|
||||
maybeShowConfigurationError(this, data2);
|
||||
}
|
||||
|
||||
private void progressUpdate(int progress) {
|
||||
|
@ -198,12 +195,28 @@ public class WelcomeActivity extends BaseActionBarActivity implements DcEventCen
|
|||
finish();
|
||||
}
|
||||
|
||||
public static void maybeShowConfigurationError(Activity activity, Object data2) {
|
||||
if (data2 instanceof String && !((String) data2).isEmpty()) {
|
||||
AlertDialog d = new AlertDialog.Builder(activity)
|
||||
.setMessage(((String) data2))
|
||||
.setPositiveButton(android.R.string.ok, null)
|
||||
.create();
|
||||
d.show();
|
||||
try {
|
||||
//noinspection ConstantConditions
|
||||
Linkify.addLinks((TextView) d.findViewById(android.R.id.message), Linkify.WEB_URLS | Linkify.EMAIL_ADDRESSES);
|
||||
} catch(NullPointerException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleEvent(int eventId, Object data1, Object data2) {
|
||||
if (eventId== DcContext.DC_EVENT_IMEX_PROGRESS ) {
|
||||
long progress = (Long)data1;
|
||||
if (progress==0/*error/aborted*/) {
|
||||
progressError();
|
||||
progressError(dcContext.getCapturedError());
|
||||
notificationController.close();
|
||||
}
|
||||
else if (progress<1000/*progress in permille*/) {
|
||||
|
@ -226,7 +239,7 @@ public class WelcomeActivity extends BaseActionBarActivity implements DcEventCen
|
|||
else if (!manualConfigure && eventId==DcContext.DC_EVENT_CONFIGURE_PROGRESS) {
|
||||
long progress = (Long)data1;
|
||||
if (progress==0/*error/aborted*/) {
|
||||
progressError();
|
||||
progressError(data2);
|
||||
}
|
||||
else if (progress<1000/*progress in permille*/) {
|
||||
progressUpdate((int)progress);
|
||||
|
|
|
@ -135,6 +135,7 @@ public class ApplicationDcContext extends DcContext {
|
|||
setStockTranslation(81, context.getString(R.string.systemmsg_ephemeral_timer_four_weeks));
|
||||
setStockTranslation(82, context.getString(R.string.videochat_invitation));
|
||||
setStockTranslation(83, context.getString(R.string.videochat_invitation_body));
|
||||
setStockTranslation(84, context.getString(R.string.configuration_failed_with_error));
|
||||
}
|
||||
|
||||
public File getImexDir() {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue