mirror of
https://github.com/deltachat/deltachat-android.git
synced 2025-10-03 09:49:21 +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">Delete account</string>
|
||||||
<string name="delete_account_ask">Are you sure you want to delete your account data?</string>
|
<string name="delete_account_ask">Are you sure you want to delete your account data?</string>
|
||||||
<string name="switching_account">Switching account…</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 -->
|
<!-- 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 -->
|
<!-- 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.Editable;
|
||||||
import android.text.TextUtils;
|
import android.text.TextUtils;
|
||||||
import android.text.TextWatcher;
|
import android.text.TextWatcher;
|
||||||
import android.text.util.Linkify;
|
|
||||||
import android.util.Patterns;
|
import android.util.Patterns;
|
||||||
import android.view.Menu;
|
import android.view.Menu;
|
||||||
import android.view.MenuInflater;
|
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.maybeStartIo(); // start-io is also needed on errors to make previous config work in case of changes
|
||||||
dcContext.endCaptureNextError();
|
dcContext.endCaptureNextError();
|
||||||
progressDialog.dismiss();
|
progressDialog.dismiss();
|
||||||
if (dcContext.hasCapturedError()) {
|
WelcomeActivity.maybeShowConfigurationError(this, data2);
|
||||||
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();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else if (progress<1000/*progress in permille*/) {
|
else if (progress<1000/*progress in permille*/) {
|
||||||
int percent = (int)progress / 10;
|
int percent = (int)progress / 10;
|
||||||
|
|
|
@ -2,11 +2,14 @@ package org.thoughtcrime.securesms;
|
||||||
|
|
||||||
import android.Manifest;
|
import android.Manifest;
|
||||||
import android.annotation.SuppressLint;
|
import android.annotation.SuppressLint;
|
||||||
|
import android.app.Activity;
|
||||||
import android.content.DialogInterface;
|
import android.content.DialogInterface;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
|
import android.text.util.Linkify;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.widget.Button;
|
import android.widget.Button;
|
||||||
|
import android.widget.TextView;
|
||||||
|
|
||||||
import androidx.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
import androidx.appcompat.app.AlertDialog;
|
import androidx.appcompat.app.AlertDialog;
|
||||||
|
@ -159,7 +162,7 @@ public class WelcomeActivity extends BaseActionBarActivity implements DcEventCen
|
||||||
dcContext.captureNextError();
|
dcContext.captureNextError();
|
||||||
|
|
||||||
if (!dcContext.setConfigFromQr(qrCode)) {
|
if (!dcContext.setConfigFromQr(qrCode)) {
|
||||||
progressError();
|
progressError(dcContext.getCapturedError());
|
||||||
}
|
}
|
||||||
|
|
||||||
// calling configure() results in
|
// calling configure() results in
|
||||||
|
@ -168,15 +171,9 @@ public class WelcomeActivity extends BaseActionBarActivity implements DcEventCen
|
||||||
dcContext.configure();
|
dcContext.configure();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void progressError() {
|
private void progressError(Object data2) {
|
||||||
dcContext.endCaptureNextError();
|
|
||||||
progressDialog.dismiss();
|
progressDialog.dismiss();
|
||||||
if (dcContext.hasCapturedError()) {
|
maybeShowConfigurationError(this, data2);
|
||||||
new AlertDialog.Builder(this)
|
|
||||||
.setMessage(dcContext.getCapturedError())
|
|
||||||
.setPositiveButton(android.R.string.ok, null)
|
|
||||||
.show();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void progressUpdate(int progress) {
|
private void progressUpdate(int progress) {
|
||||||
|
@ -198,12 +195,28 @@ public class WelcomeActivity extends BaseActionBarActivity implements DcEventCen
|
||||||
finish();
|
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
|
@Override
|
||||||
public void handleEvent(int eventId, Object data1, Object data2) {
|
public void handleEvent(int eventId, Object data1, Object data2) {
|
||||||
if (eventId== DcContext.DC_EVENT_IMEX_PROGRESS ) {
|
if (eventId== DcContext.DC_EVENT_IMEX_PROGRESS ) {
|
||||||
long progress = (Long)data1;
|
long progress = (Long)data1;
|
||||||
if (progress==0/*error/aborted*/) {
|
if (progress==0/*error/aborted*/) {
|
||||||
progressError();
|
progressError(dcContext.getCapturedError());
|
||||||
notificationController.close();
|
notificationController.close();
|
||||||
}
|
}
|
||||||
else if (progress<1000/*progress in permille*/) {
|
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) {
|
else if (!manualConfigure && eventId==DcContext.DC_EVENT_CONFIGURE_PROGRESS) {
|
||||||
long progress = (Long)data1;
|
long progress = (Long)data1;
|
||||||
if (progress==0/*error/aborted*/) {
|
if (progress==0/*error/aborted*/) {
|
||||||
progressError();
|
progressError(data2);
|
||||||
}
|
}
|
||||||
else if (progress<1000/*progress in permille*/) {
|
else if (progress<1000/*progress in permille*/) {
|
||||||
progressUpdate((int)progress);
|
progressUpdate((int)progress);
|
||||||
|
|
|
@ -135,6 +135,7 @@ public class ApplicationDcContext extends DcContext {
|
||||||
setStockTranslation(81, context.getString(R.string.systemmsg_ephemeral_timer_four_weeks));
|
setStockTranslation(81, context.getString(R.string.systemmsg_ephemeral_timer_four_weeks));
|
||||||
setStockTranslation(82, context.getString(R.string.videochat_invitation));
|
setStockTranslation(82, context.getString(R.string.videochat_invitation));
|
||||||
setStockTranslation(83, context.getString(R.string.videochat_invitation_body));
|
setStockTranslation(83, context.getString(R.string.videochat_invitation_body));
|
||||||
|
setStockTranslation(84, context.getString(R.string.configuration_failed_with_error));
|
||||||
}
|
}
|
||||||
|
|
||||||
public File getImexDir() {
|
public File getImexDir() {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue