mirror of
https://github.com/M66B/FairEmail.git
synced 2026-01-03 19:34:15 +01:00
Unexpected error handling
This commit is contained in:
@@ -12,7 +12,6 @@ import android.preference.PreferenceManager;
|
||||
import android.provider.Settings;
|
||||
import android.util.Log;
|
||||
import android.view.View;
|
||||
import android.widget.Toast;
|
||||
|
||||
import com.android.billingclient.api.BillingClient;
|
||||
import com.android.billingclient.api.BillingClientStateListener;
|
||||
@@ -144,7 +143,7 @@ abstract class ActivityBilling extends ActivityBase implements PurchasesUpdatedL
|
||||
setIntent(intent);
|
||||
} catch (NoSuchAlgorithmException ex) {
|
||||
Log.e(Helper.TAG, Log.getStackTraceString(ex));
|
||||
Toast.makeText(this, ex.getMessage(), Toast.LENGTH_LONG).show();
|
||||
Helper.unexpectedError(this, ex);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -466,7 +466,7 @@ public class ActivityView extends ActivityBilling implements FragmentManager.OnB
|
||||
|
||||
@Override
|
||||
protected void onException(Bundle args, Throwable ex) {
|
||||
Toast.makeText(ActivityView.this, ex.toString(), Toast.LENGTH_LONG).show();
|
||||
Helper.unexpectedError(ActivityView.this, ex);
|
||||
}
|
||||
}.load(this, args);
|
||||
}
|
||||
@@ -553,7 +553,7 @@ public class ActivityView extends ActivityBilling implements FragmentManager.OnB
|
||||
@Override
|
||||
protected void onException(Bundle args, Throwable ex) {
|
||||
if (BuildConfig.DEBUG)
|
||||
Toast.makeText(ActivityView.this, ex.toString(), Toast.LENGTH_LONG).show();
|
||||
Helper.unexpectedError(ActivityView.this, ex);
|
||||
}
|
||||
}.load(this, new Bundle());
|
||||
}
|
||||
@@ -783,7 +783,7 @@ public class ActivityView extends ActivityBilling implements FragmentManager.OnB
|
||||
|
||||
@Override
|
||||
protected void onException(Bundle args, Throwable ex) {
|
||||
Toast.makeText(ActivityView.this, ex.toString(), Toast.LENGTH_LONG).show();
|
||||
Helper.unexpectedError(ActivityView.this, ex);
|
||||
}
|
||||
}.load(ActivityView.this, intent.getExtras());
|
||||
}
|
||||
@@ -874,7 +874,7 @@ public class ActivityView extends ActivityBilling implements FragmentManager.OnB
|
||||
@Override
|
||||
protected void onException(Bundle args, Throwable ex) {
|
||||
Log.e(Helper.TAG, ex + "\n" + Log.getStackTraceString(ex));
|
||||
Toast.makeText(ActivityView.this, ex.toString(), Toast.LENGTH_LONG).show();
|
||||
Helper.unexpectedError(ActivityView.this, ex);
|
||||
}
|
||||
}.load(this, args);
|
||||
}
|
||||
|
||||
@@ -31,7 +31,6 @@ import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
|
||||
import java.text.Collator;
|
||||
import java.util.ArrayList;
|
||||
@@ -204,7 +203,7 @@ public class AdapterFolder extends RecyclerView.Adapter<AdapterFolder.ViewHolder
|
||||
|
||||
@Override
|
||||
public void onException(Bundle args, Throwable ex) {
|
||||
Toast.makeText(context, ex.toString(), Toast.LENGTH_LONG).show();
|
||||
Helper.unexpectedError(context, ex);
|
||||
}
|
||||
}.load(context, owner, args);
|
||||
|
||||
|
||||
@@ -44,7 +44,6 @@ import android.view.ViewGroup;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.ProgressBar;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
|
||||
import java.io.InputStream;
|
||||
import java.text.DateFormat;
|
||||
@@ -328,7 +327,7 @@ public class AdapterMessage extends PagedListAdapter<TupleMessageEx, AdapterMess
|
||||
|
||||
@Override
|
||||
public void onException(Bundle args, Throwable ex) {
|
||||
Toast.makeText(context, ex.toString(), Toast.LENGTH_LONG).show();
|
||||
Helper.unexpectedError(context, ex);
|
||||
}
|
||||
}.load(context, owner, args);
|
||||
|
||||
|
||||
@@ -29,7 +29,6 @@ import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.Button;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
|
||||
import java.io.BufferedOutputStream;
|
||||
import java.io.BufferedReader;
|
||||
@@ -242,7 +241,7 @@ public class FragmentAbout extends FragmentEx {
|
||||
@Override
|
||||
protected void onException(Bundle args, Throwable ex) {
|
||||
btnDebugInfo.setEnabled(true);
|
||||
Toast.makeText(getContext(), ex.toString(), Toast.LENGTH_LONG).show();
|
||||
Helper.unexpectedError(getContext(), ex);
|
||||
}
|
||||
}.load(FragmentAbout.this, new Bundle());
|
||||
}
|
||||
|
||||
@@ -54,7 +54,6 @@ import android.widget.ImageView;
|
||||
import android.widget.ProgressBar;
|
||||
import android.widget.ScrollView;
|
||||
import android.widget.Spinner;
|
||||
import android.widget.Toast;
|
||||
|
||||
import com.android.colorpicker.ColorPickerDialog;
|
||||
import com.android.colorpicker.ColorPickerSwatch;
|
||||
@@ -492,7 +491,7 @@ public class FragmentAccount extends FragmentEx {
|
||||
|
||||
new AlertDialog.Builder(getContext())
|
||||
.setMessage(Helper.formatThrowable(ex))
|
||||
.setPositiveButton(android.R.string.ok, null)
|
||||
.setPositiveButton(android.R.string.cancel, null)
|
||||
.create()
|
||||
.show();
|
||||
}
|
||||
@@ -697,7 +696,7 @@ public class FragmentAccount extends FragmentEx {
|
||||
|
||||
new AlertDialog.Builder(getContext())
|
||||
.setMessage(Helper.formatThrowable(ex))
|
||||
.setPositiveButton(android.R.string.ok, null)
|
||||
.setPositiveButton(android.R.string.cancel, null)
|
||||
.create()
|
||||
.show();
|
||||
}
|
||||
@@ -738,7 +737,7 @@ public class FragmentAccount extends FragmentEx {
|
||||
|
||||
@Override
|
||||
protected void onException(Bundle args, Throwable ex) {
|
||||
Toast.makeText(getContext(), ex.toString(), Toast.LENGTH_LONG).show();
|
||||
Helper.unexpectedError(getContext(), ex);
|
||||
}
|
||||
}.load(FragmentAccount.this, args);
|
||||
}
|
||||
@@ -936,7 +935,7 @@ public class FragmentAccount extends FragmentEx {
|
||||
tilPassword.getEditText().setText(token);
|
||||
} catch (Throwable ex) {
|
||||
Log.e(Helper.TAG, ex + "\n" + Log.getStackTraceString(ex));
|
||||
Toast.makeText(getContext(), ex.toString(), Toast.LENGTH_LONG).show();
|
||||
Helper.unexpectedError(getContext(), ex);
|
||||
} finally {
|
||||
snackbar.dismiss();
|
||||
}
|
||||
|
||||
@@ -28,7 +28,6 @@ import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.EditText;
|
||||
import android.widget.ProgressBar;
|
||||
import android.widget.Toast;
|
||||
|
||||
import com.google.android.material.bottomnavigation.BottomNavigationView;
|
||||
|
||||
@@ -130,7 +129,7 @@ public class FragmentAnswer extends FragmentEx {
|
||||
@Override
|
||||
protected void onException(Bundle args, Throwable ex) {
|
||||
Helper.setViewsEnabled(view, true);
|
||||
Toast.makeText(getContext(), ex.toString(), Toast.LENGTH_LONG).show();
|
||||
Helper.unexpectedError(getContext(), ex);
|
||||
}
|
||||
}.load(this, args);
|
||||
}
|
||||
@@ -174,7 +173,7 @@ public class FragmentAnswer extends FragmentEx {
|
||||
@Override
|
||||
protected void onException(Bundle args, Throwable ex) {
|
||||
Helper.setViewsEnabled(view, true);
|
||||
Toast.makeText(getContext(), ex.toString(), Toast.LENGTH_LONG).show();
|
||||
Helper.unexpectedError(getContext(), ex);
|
||||
}
|
||||
}.load(this, args);
|
||||
}
|
||||
|
||||
@@ -541,7 +541,7 @@ public class FragmentCompose extends FragmentEx {
|
||||
}
|
||||
} catch (Throwable ex) {
|
||||
Log.e(Helper.TAG, ex + "\n" + Log.getStackTraceString(ex));
|
||||
Toast.makeText(getContext(), ex.toString(), Toast.LENGTH_LONG).show();
|
||||
Helper.unexpectedError(getContext(), ex);
|
||||
} finally {
|
||||
if (cursor != null)
|
||||
cursor.close();
|
||||
@@ -586,7 +586,7 @@ public class FragmentCompose extends FragmentEx {
|
||||
|
||||
@Override
|
||||
protected void onException(Bundle args, Throwable ex) {
|
||||
Toast.makeText(getContext(), ex.toString(), Toast.LENGTH_LONG).show();
|
||||
Helper.unexpectedError(getContext(), ex);
|
||||
}
|
||||
}.load(this, args);
|
||||
}
|
||||
@@ -1058,7 +1058,7 @@ public class FragmentCompose extends FragmentEx {
|
||||
|
||||
@Override
|
||||
protected void onException(Bundle args, Throwable ex) {
|
||||
Toast.makeText(getContext(), ex.toString(), Toast.LENGTH_LONG).show();
|
||||
Helper.unexpectedError(getContext(), ex);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -1209,7 +1209,7 @@ public class FragmentCompose extends FragmentEx {
|
||||
if (ex instanceof IllegalArgumentException)
|
||||
Snackbar.make(view, ex.getMessage(), Snackbar.LENGTH_LONG).show();
|
||||
else
|
||||
Toast.makeText(getContext(), ex.toString(), Toast.LENGTH_LONG).show();
|
||||
Helper.unexpectedError(getContext(), ex);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -32,7 +32,6 @@ import android.widget.CheckBox;
|
||||
import android.widget.EditText;
|
||||
import android.widget.ImageButton;
|
||||
import android.widget.ProgressBar;
|
||||
import android.widget.Toast;
|
||||
|
||||
import com.google.android.material.snackbar.Snackbar;
|
||||
import com.sun.mail.imap.IMAPFolder;
|
||||
@@ -193,7 +192,7 @@ public class FragmentFolder extends FragmentEx {
|
||||
if (ex instanceof IllegalArgumentException)
|
||||
Snackbar.make(view, ex.getMessage(), Snackbar.LENGTH_LONG).show();
|
||||
else
|
||||
Toast.makeText(getContext(), ex.toString(), Toast.LENGTH_LONG).show();
|
||||
Helper.unexpectedError(getContext(), ex);
|
||||
}
|
||||
}.load(FragmentFolder.this, args);
|
||||
}
|
||||
@@ -266,7 +265,7 @@ public class FragmentFolder extends FragmentEx {
|
||||
if (ex instanceof IllegalArgumentException)
|
||||
Snackbar.make(view, ex.getMessage(), Snackbar.LENGTH_LONG).show();
|
||||
else
|
||||
Toast.makeText(getContext(), ex.toString(), Toast.LENGTH_LONG).show();
|
||||
Helper.unexpectedError(getContext(), ex);
|
||||
}
|
||||
}.load(FragmentFolder.this, args);
|
||||
}
|
||||
|
||||
@@ -35,7 +35,6 @@ import android.widget.EditText;
|
||||
import android.widget.ImageButton;
|
||||
import android.widget.ProgressBar;
|
||||
import android.widget.Spinner;
|
||||
import android.widget.Toast;
|
||||
|
||||
import com.google.android.material.textfield.TextInputLayout;
|
||||
|
||||
@@ -340,7 +339,7 @@ public class FragmentIdentity extends FragmentEx {
|
||||
|
||||
new AlertDialog.Builder(getContext())
|
||||
.setMessage(Helper.formatThrowable(ex))
|
||||
.setPositiveButton(android.R.string.ok, null)
|
||||
.setPositiveButton(android.R.string.cancel, null)
|
||||
.create()
|
||||
.show();
|
||||
}
|
||||
@@ -379,7 +378,7 @@ public class FragmentIdentity extends FragmentEx {
|
||||
|
||||
@Override
|
||||
protected void onException(Bundle args, Throwable ex) {
|
||||
Toast.makeText(getContext(), ex.toString(), Toast.LENGTH_LONG).show();
|
||||
Helper.unexpectedError(getContext(), ex);
|
||||
}
|
||||
}.load(FragmentIdentity.this, args);
|
||||
}
|
||||
|
||||
@@ -852,7 +852,7 @@ public class FragmentMessage extends FragmentEx {
|
||||
@Override
|
||||
protected void onException(Bundle args, Throwable ex) {
|
||||
Helper.setViewsEnabled(view, true);
|
||||
Toast.makeText(getContext(), ex.toString(), Toast.LENGTH_LONG).show();
|
||||
Helper.unexpectedError(getContext(), ex);
|
||||
}
|
||||
}.load(FragmentMessage.this, args);
|
||||
}
|
||||
@@ -910,7 +910,7 @@ public class FragmentMessage extends FragmentEx {
|
||||
@Override
|
||||
protected void onException(Bundle args, Throwable ex) {
|
||||
Helper.setViewsEnabled(view, true);
|
||||
Toast.makeText(getContext(), ex.toString(), Toast.LENGTH_LONG).show();
|
||||
Helper.unexpectedError(getContext(), ex);
|
||||
}
|
||||
}.load(FragmentMessage.this, args);
|
||||
}
|
||||
@@ -955,7 +955,7 @@ public class FragmentMessage extends FragmentEx {
|
||||
@Override
|
||||
protected void onException(Bundle args, Throwable ex) {
|
||||
Helper.setViewsEnabled(view, true);
|
||||
Toast.makeText(getContext(), ex.toString(), Toast.LENGTH_LONG).show();
|
||||
Helper.unexpectedError(getContext(), ex);
|
||||
}
|
||||
}.load(FragmentMessage.this, args);
|
||||
}
|
||||
@@ -1068,7 +1068,7 @@ public class FragmentMessage extends FragmentEx {
|
||||
@Override
|
||||
protected void onException(Bundle args, Throwable ex) {
|
||||
Helper.setViewsEnabled(view, true);
|
||||
Toast.makeText(getContext(), ex.toString(), Toast.LENGTH_LONG).show();
|
||||
Helper.unexpectedError(getContext(), ex);
|
||||
}
|
||||
}.load(FragmentMessage.this, args);
|
||||
|
||||
@@ -1121,7 +1121,7 @@ public class FragmentMessage extends FragmentEx {
|
||||
@Override
|
||||
protected void onException(Bundle args, Throwable ex) {
|
||||
Helper.setViewsEnabled(view, true);
|
||||
Toast.makeText(getContext(), ex.toString(), Toast.LENGTH_LONG).show();
|
||||
Helper.unexpectedError(getContext(), ex);
|
||||
}
|
||||
}.load(FragmentMessage.this, args);
|
||||
}
|
||||
|
||||
@@ -38,7 +38,6 @@ import android.view.ViewGroup;
|
||||
import android.widget.ImageButton;
|
||||
import android.widget.ProgressBar;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
|
||||
import com.google.android.material.floatingactionbutton.FloatingActionButton;
|
||||
import com.google.android.material.snackbar.Snackbar;
|
||||
@@ -363,7 +362,7 @@ public class FragmentMessages extends FragmentEx {
|
||||
|
||||
@Override
|
||||
protected void onException(Bundle args, Throwable ex) {
|
||||
Toast.makeText(getContext(), ex.toString(), Toast.LENGTH_LONG).show();
|
||||
Helper.unexpectedError(getContext(), ex);
|
||||
}
|
||||
}.load(FragmentMessages.this, args);
|
||||
}
|
||||
@@ -495,7 +494,7 @@ public class FragmentMessages extends FragmentEx {
|
||||
|
||||
@Override
|
||||
protected void onException(Bundle args, Throwable ex) {
|
||||
Toast.makeText(getContext(), ex.toString(), Toast.LENGTH_LONG).show();
|
||||
Helper.unexpectedError(getContext(), ex);
|
||||
}
|
||||
}.load(this, args);
|
||||
}
|
||||
@@ -680,7 +679,7 @@ public class FragmentMessages extends FragmentEx {
|
||||
|
||||
@Override
|
||||
public void onError(Context context, Throwable ex) {
|
||||
Toast.makeText(context, ex.toString(), Toast.LENGTH_LONG).show();
|
||||
Helper.unexpectedError(context, ex);
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
@@ -46,7 +46,6 @@ import android.view.ViewGroup;
|
||||
import android.widget.Button;
|
||||
import android.widget.CompoundButton;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
import android.widget.ToggleButton;
|
||||
|
||||
import com.google.android.material.snackbar.Snackbar;
|
||||
@@ -273,7 +272,7 @@ public class FragmentSetup extends FragmentEx {
|
||||
|
||||
@Override
|
||||
protected void onException(Bundle args, Throwable ex) {
|
||||
Toast.makeText(getContext(), ex.toString(), Toast.LENGTH_LONG).show();
|
||||
Helper.unexpectedError(getContext(), ex);
|
||||
}
|
||||
}.load(this, new Bundle());
|
||||
|
||||
@@ -480,7 +479,7 @@ public class FragmentSetup extends FragmentEx {
|
||||
|
||||
@Override
|
||||
protected void onException(Bundle args, Throwable ex) {
|
||||
Toast.makeText(getContext(), ex.toString(), Toast.LENGTH_LONG).show();
|
||||
Helper.unexpectedError(getContext(), ex);
|
||||
}
|
||||
}.load(this, args);
|
||||
}
|
||||
@@ -590,7 +589,7 @@ public class FragmentSetup extends FragmentEx {
|
||||
|
||||
@Override
|
||||
protected void onException(Bundle args, Throwable ex) {
|
||||
Toast.makeText(getContext(), ex.toString(), Toast.LENGTH_LONG).show();
|
||||
Helper.unexpectedError(getContext(), ex);
|
||||
}
|
||||
}.load(this, args);
|
||||
}
|
||||
|
||||
@@ -52,6 +52,8 @@ import javax.mail.Address;
|
||||
import javax.mail.FolderClosedException;
|
||||
import javax.mail.internet.InternetAddress;
|
||||
|
||||
import androidx.appcompat.app.AlertDialog;
|
||||
|
||||
import static android.os.Process.THREAD_PRIORITY_BACKGROUND;
|
||||
|
||||
public class Helper {
|
||||
@@ -122,6 +124,14 @@ public class Helper {
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
static void unexpectedError(Context context, Throwable ex) {
|
||||
new AlertDialog.Builder(context)
|
||||
.setTitle(R.string.title_unexpected_error)
|
||||
.setMessage(ex.toString())
|
||||
.setPositiveButton(android.R.string.cancel, null)
|
||||
.show();
|
||||
}
|
||||
|
||||
static String humanReadableByteCount(long bytes, boolean si) {
|
||||
int unit = si ? 1000 : 1024;
|
||||
if (bytes < unit) return bytes + " B";
|
||||
|
||||
@@ -253,6 +253,7 @@
|
||||
<string name="title_pro_invalid">Invalid response</string>
|
||||
<string name="title_pro_support">FairEmail needs your help. Tap to purchase pro features to keep the project going.</string>
|
||||
|
||||
<string name="title_unexpected_error">Unexpected error</string>
|
||||
<string name="title_log">Log</string>
|
||||
<string name="title_debug_info">Debug info</string>
|
||||
<string name="title_debug_info_remark">Please describe the problem and indicate the time of the problem:</string>
|
||||
|
||||
Reference in New Issue
Block a user