Refactoring

pull/215/head
M66B 7 months ago
parent d21d766cf1
commit 15ecc61a29

@ -700,8 +700,9 @@ public class ActivityEML extends ActivityBase {
@Override
protected void onException(Bundle args, @NonNull Throwable ex) {
if (ex instanceof IllegalArgumentException)
Snackbar.make(findViewById(android.R.id.content), new ThrowableWrapper(ex).getSafeMessage(), Snackbar.LENGTH_LONG)
.setGestureInsetBottomIgnored(true).show();
Helper.setSnackbarOptions(
Snackbar.make(findViewById(android.R.id.content), new ThrowableWrapper(ex).getSafeMessage(), Snackbar.LENGTH_LONG))
.show();
else
Log.unexpectedError(getSupportFragmentManager(), ex);
}

@ -1455,8 +1455,8 @@ public class ActivityView extends ActivityBilling implements FragmentManager.OnB
final View content = drawerLayout.getChildAt(0);
final Snackbar snackbar = Snackbar.make(content, title, Snackbar.LENGTH_INDEFINITE)
.setGestureInsetBottomIgnored(true);
final Snackbar snackbar = Helper.setSnackbarOptions(
Snackbar.make(content, title, Snackbar.LENGTH_INDEFINITE));
Helper.setSnackbarLines(snackbar, 7);
lastSnackbar = snackbar;

@ -913,8 +913,8 @@ public class AdapterFolder extends RecyclerView.Adapter<AdapterFolder.ViewHolder
@Override
protected void onException(Bundle args, Throwable ex) {
if (ex instanceof IllegalStateException) {
Snackbar snackbar = Snackbar.make(parentFragment.getView(), new ThrowableWrapper(ex).getSafeMessage(), Snackbar.LENGTH_LONG)
.setGestureInsetBottomIgnored(true);
Snackbar snackbar = Helper.setSnackbarOptions(
Snackbar.make(parentFragment.getView(), new ThrowableWrapper(ex).getSafeMessage(), Snackbar.LENGTH_LONG));
snackbar.setAction(R.string.title_fix, new View.OnClickListener() {
@Override
public void onClick(View v) {
@ -925,8 +925,9 @@ public class AdapterFolder extends RecyclerView.Adapter<AdapterFolder.ViewHolder
});
snackbar.show();
} else if (ex instanceof IllegalArgumentException)
Snackbar.make(view, new ThrowableWrapper(ex).getSafeMessage(), Snackbar.LENGTH_LONG)
.setGestureInsetBottomIgnored(true).show();
Helper.setSnackbarOptions(
Snackbar.make(view, new ThrowableWrapper(ex).getSafeMessage(), Snackbar.LENGTH_LONG))
.show();
else
Log.unexpectedError(parentFragment.getParentFragmentManager(), ex);
}

@ -3537,8 +3537,9 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
@Override
protected void onException(Bundle args, Throwable ex) {
if (ex instanceof OutOfMemoryError)
Snackbar.make(parentFragment.getView(), new ThrowableWrapper(ex).getSafeMessage(), Snackbar.LENGTH_LONG)
.setGestureInsetBottomIgnored(true).show();
Helper.setSnackbarOptions(
Snackbar.make(parentFragment.getView(), new ThrowableWrapper(ex).getSafeMessage(), Snackbar.LENGTH_LONG))
.show();
else
Log.unexpectedError(parentFragment.getParentFragmentManager(), ex);
}

@ -719,8 +719,9 @@ public class FragmentAccount extends FragmentBase {
(ex instanceof UnknownHostException ||
ex instanceof FileNotFoundException ||
ex instanceof IllegalArgumentException))
Snackbar.make(view, new ThrowableWrapper(ex).getSafeMessage(), Snackbar.LENGTH_LONG)
.setGestureInsetBottomIgnored(true).show();
Helper.setSnackbarOptions(
Snackbar.make(view, new ThrowableWrapper(ex).getSafeMessage(), Snackbar.LENGTH_LONG))
.show();
else
Log.unexpectedError(getParentFragmentManager(), ex);
}
@ -883,8 +884,9 @@ public class FragmentAccount extends FragmentBase {
cbIdentity.setVisibility(View.GONE);
if (ex instanceof IllegalArgumentException)
Snackbar.make(view, new ThrowableWrapper(ex).getSafeMessage(), Snackbar.LENGTH_LONG)
.setGestureInsetBottomIgnored(true).show();
Helper.setSnackbarOptions(
Snackbar.make(view, new ThrowableWrapper(ex).getSafeMessage(), Snackbar.LENGTH_LONG))
.show();
else
showError(ex);
}
@ -1518,8 +1520,9 @@ public class FragmentAccount extends FragmentBase {
@Override
protected void onException(Bundle args, Throwable ex) {
if (ex instanceof IllegalArgumentException)
Snackbar.make(view, new ThrowableWrapper(ex).getSafeMessage(), Snackbar.LENGTH_LONG)
.setGestureInsetBottomIgnored(true).show();
Helper.setSnackbarOptions(
Snackbar.make(view, new ThrowableWrapper(ex).getSafeMessage(), Snackbar.LENGTH_LONG))
.show();
else
showError(ex);
}

@ -669,8 +669,8 @@ public class FragmentAccounts extends FragmentBase {
@Override
protected void onException(Bundle args, Throwable ex) {
if (ex instanceof IllegalStateException) {
Snackbar snackbar = Snackbar.make(view, new ThrowableWrapper(ex).getSafeMessage(), Snackbar.LENGTH_LONG)
.setGestureInsetBottomIgnored(true);
Snackbar snackbar = Helper.setSnackbarOptions(
Snackbar.make(view, new ThrowableWrapper(ex).getSafeMessage(), Snackbar.LENGTH_LONG));
snackbar.setAction(R.string.title_fix, new View.OnClickListener() {
@Override
public void onClick(View v) {
@ -681,8 +681,9 @@ public class FragmentAccounts extends FragmentBase {
});
snackbar.show();
} else if (ex instanceof IllegalArgumentException)
Snackbar.make(view, new ThrowableWrapper(ex).getSafeMessage(), Snackbar.LENGTH_LONG)
.setGestureInsetBottomIgnored(true).show();
Helper.setSnackbarOptions(
Snackbar.make(view, new ThrowableWrapper(ex).getSafeMessage(), Snackbar.LENGTH_LONG))
.show();
else
Log.unexpectedError(getParentFragmentManager(), ex);
}

@ -542,8 +542,9 @@ public class FragmentAnswer extends FragmentBase {
@Override
protected void onException(Bundle args, Throwable ex) {
if (ex instanceof IllegalArgumentException)
Snackbar.make(view, new ThrowableWrapper(ex).getSafeMessage(), Snackbar.LENGTH_LONG)
.setGestureInsetBottomIgnored(true).show();
Helper.setSnackbarOptions(
Snackbar.make(view, new ThrowableWrapper(ex).getSafeMessage(), Snackbar.LENGTH_LONG))
.show();
else
Log.unexpectedError(getParentFragmentManager(), ex);
}

@ -3087,8 +3087,8 @@ public class FragmentCompose extends FragmentBase {
PackageManager pm = getContext().getPackageManager();
Intent intent = new Intent(MediaStore.Audio.Media.RECORD_SOUND_ACTION);
if (intent.resolveActivity(pm) == null) { // action whitelisted
Snackbar snackbar = Snackbar.make(view, getString(R.string.title_no_recorder), Snackbar.LENGTH_INDEFINITE)
.setGestureInsetBottomIgnored(true);
Snackbar snackbar = Helper.setSnackbarOptions(
Snackbar.make(view, getString(R.string.title_no_recorder), Snackbar.LENGTH_INDEFINITE));
snackbar.setAction(R.string.title_fix, new View.OnClickListener() {
@Override
public void onClick(View v) {
@ -3137,8 +3137,7 @@ public class FragmentCompose extends FragmentBase {
}
private void noStorageAccessFramework() {
Snackbar snackbar = Snackbar.make(view, R.string.title_no_saf, Snackbar.LENGTH_LONG)
.setGestureInsetBottomIgnored(true);
Snackbar snackbar = Helper.setSnackbarOptions(Snackbar.make(view, R.string.title_no_saf, Snackbar.LENGTH_LONG));
snackbar.setAction(R.string.title_fix, new View.OnClickListener() {
@Override
public void onClick(View v) {
@ -3222,8 +3221,7 @@ public class FragmentCompose extends FragmentBase {
@Override
public void onNothingSelected() {
Snackbar snackbar = Snackbar.make(view, R.string.title_no_key, Snackbar.LENGTH_LONG)
.setGestureInsetBottomIgnored(true);
Snackbar snackbar = Helper.setSnackbarOptions(Snackbar.make(view, R.string.title_no_key, Snackbar.LENGTH_LONG));
final Intent intent = (Build.VERSION.SDK_INT < Build.VERSION_CODES.R
? KeyChain.createInstallIntent()
: new Intent(Settings.ACTION_SECURITY_SETTINGS));
@ -3290,8 +3288,9 @@ public class FragmentCompose extends FragmentBase {
onPgp(intent);
} catch (Throwable ex) {
if (ex instanceof IllegalArgumentException)
Snackbar.make(view, new ThrowableWrapper(ex).getSafeMessage(), Snackbar.LENGTH_LONG)
.setGestureInsetBottomIgnored(true).show();
Helper.setSnackbarOptions(
Snackbar.make(view, new ThrowableWrapper(ex).getSafeMessage(), Snackbar.LENGTH_LONG))
.show();
else {
Log.e(ex);
Log.unexpectedError(FragmentCompose.this, ex);
@ -3619,8 +3618,8 @@ public class FragmentCompose extends FragmentBase {
// https://developer.android.com/training/camera/photobasics
Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
if (intent.resolveActivity(pm) == null) { // action whitelisted
Snackbar snackbar = Snackbar.make(view, getString(R.string.title_no_camera), Snackbar.LENGTH_LONG)
.setGestureInsetBottomIgnored(true);
Snackbar snackbar = Helper.setSnackbarOptions(
Snackbar.make(view, getString(R.string.title_no_camera), Snackbar.LENGTH_LONG));
snackbar.setAction(R.string.title_fix, new View.OnClickListener() {
@Override
public void onClick(View v) {
@ -4269,11 +4268,11 @@ public class FragmentCompose extends FragmentBase {
if (ex instanceof IllegalArgumentException
|| ex instanceof GeneralSecurityException /* InvalidKeyException */) {
Log.i(ex);
Snackbar.make(view, new ThrowableWrapper(ex).getSafeMessage(), Snackbar.LENGTH_LONG)
.setGestureInsetBottomIgnored(true).show();
Helper.setSnackbarOptions(
Snackbar.make(view, new ThrowableWrapper(ex).getSafeMessage(), Snackbar.LENGTH_LONG))
.show();
} else if (ex instanceof OperationCanceledException) {
Snackbar snackbar = Snackbar.make(view, R.string.title_no_openpgp, Snackbar.LENGTH_INDEFINITE)
.setGestureInsetBottomIgnored(true);
Snackbar snackbar = Helper.setSnackbarOptions(Snackbar.make(view, R.string.title_no_openpgp, Snackbar.LENGTH_INDEFINITE));
snackbar.setAction(R.string.title_fix, new View.OnClickListener() {
@Override
public void onClick(View v) {
@ -4630,8 +4629,8 @@ public class FragmentCompose extends FragmentBase {
protected void onException(Bundle args, Throwable ex) {
if (ex instanceof IllegalArgumentException) {
Log.i(ex);
Snackbar snackbar = Snackbar.make(view, new ThrowableWrapper(ex).getSafeMessage(), Snackbar.LENGTH_INDEFINITE)
.setGestureInsetBottomIgnored(true);
Snackbar snackbar = Helper.setSnackbarOptions(
Snackbar.make(view, new ThrowableWrapper(ex).getSafeMessage(), Snackbar.LENGTH_INDEFINITE));
Helper.setSnackbarLines(snackbar, 7);
snackbar.setAction(R.string.title_fix, new View.OnClickListener() {
@Override
@ -6359,9 +6358,8 @@ public class FragmentCompose extends FragmentBase {
bottom_navigation.getMenu().findItem(R.id.action_redo).setVisible(data.draft.revision < data.draft.revisions);
if (args.getBoolean("noreply")) {
final Snackbar snackbar = Snackbar.make(
view, R.string.title_noreply_reminder, Snackbar.LENGTH_INDEFINITE)
.setGestureInsetBottomIgnored(true);
final Snackbar snackbar = Helper.setSnackbarOptions(Snackbar.make(
view, R.string.title_noreply_reminder, Snackbar.LENGTH_INDEFINITE));
snackbar.setAction(android.R.string.ok, new View.OnClickListener() {
@Override
public void onClick(View view) {
@ -6370,9 +6368,8 @@ public class FragmentCompose extends FragmentBase {
});
snackbar.show();
} else if (args.getBoolean("incomplete")) {
final Snackbar snackbar = Snackbar.make(
view, R.string.title_attachments_incomplete, Snackbar.LENGTH_INDEFINITE)
.setGestureInsetBottomIgnored(true);
final Snackbar snackbar = Helper.setSnackbarOptions(Snackbar.make(
view, R.string.title_attachments_incomplete, Snackbar.LENGTH_INDEFINITE));
snackbar.setAction(android.R.string.ok, new View.OnClickListener() {
@Override
public void onClick(View view) {
@ -6631,8 +6628,8 @@ public class FragmentCompose extends FragmentBase {
String msg = getResources().getQuantityString(
R.plurals.title_notification_unseen, diff, diff);
Snackbar snackbar = Snackbar.make(view, msg, Snackbar.LENGTH_INDEFINITE)
.setGestureInsetBottomIgnored(true);
Snackbar snackbar = Helper.setSnackbarOptions(
Snackbar.make(view, msg, Snackbar.LENGTH_INDEFINITE));
snackbar.setAction(R.string.title_show, new View.OnClickListener() {
@Override
public void onClick(View v) {
@ -6696,8 +6693,8 @@ public class FragmentCompose extends FragmentBase {
if (ex instanceof MessageRemovedException)
finish();
else if (ex instanceof OperationCanceledException) {
Snackbar snackbar = Snackbar.make(view, ex.getMessage(), Snackbar.LENGTH_INDEFINITE)
.setGestureInsetBottomIgnored(true);
Snackbar snackbar = Helper.setSnackbarOptions(
Snackbar.make(view, ex.getMessage(), Snackbar.LENGTH_INDEFINITE));
snackbar.setAction(R.string.title_fix, new View.OnClickListener() {
@Override
public void onClick(View v) {
@ -6732,8 +6729,9 @@ public class FragmentCompose extends FragmentBase {
at android.content.ContentResolver.openInputStream(ContentResolver.java:1187)
at eu.faircode.email.FragmentCompose.addAttachment(SourceFile:27)
*/
Snackbar.make(view, new ThrowableWrapper(ex).toSafeString(), Snackbar.LENGTH_LONG)
.setGestureInsetBottomIgnored(true).show();
Helper.setSnackbarOptions(
Snackbar.make(view, new ThrowableWrapper(ex).toSafeString(), Snackbar.LENGTH_LONG))
.show();
} else {
if (ex instanceof IOException &&
ex.getCause() instanceof ErrnoException &&
@ -7631,8 +7629,9 @@ public class FragmentCompose extends FragmentBase {
else {
setBusy(false);
if (ex instanceof IllegalArgumentException)
Snackbar.make(view, ex.getMessage(), Snackbar.LENGTH_LONG)
.setGestureInsetBottomIgnored(true).show();
Helper.setSnackbarOptions(
Snackbar.make(view, ex.getMessage(), Snackbar.LENGTH_LONG))
.show();
else
Log.unexpectedError(getParentFragmentManager(), ex);
}

@ -718,8 +718,9 @@ public class FragmentFolder extends FragmentBase {
@Override
protected void onException(Bundle args, Throwable ex) {
if (ex instanceof IllegalArgumentException)
Snackbar.make(view, new ThrowableWrapper(ex).getSafeMessage(), Snackbar.LENGTH_LONG)
.setGestureInsetBottomIgnored(true).show();
Helper.setSnackbarOptions(
Snackbar.make(view, new ThrowableWrapper(ex).getSafeMessage(), Snackbar.LENGTH_LONG))
.show();
else
Log.unexpectedError(getParentFragmentManager(), ex, !(ex instanceof SQLiteConstraintException));
}
@ -777,8 +778,9 @@ public class FragmentFolder extends FragmentBase {
pbSave.setVisibility(View.GONE);
if (ex instanceof IllegalArgumentException)
Snackbar.make(view, new ThrowableWrapper(ex).getSafeMessage(), Snackbar.LENGTH_LONG)
.setGestureInsetBottomIgnored(true).show();
Helper.setSnackbarOptions(
Snackbar.make(view, new ThrowableWrapper(ex).getSafeMessage(), Snackbar.LENGTH_LONG))
.show();
else
Log.unexpectedError(getParentFragmentManager(), ex);
}

@ -585,8 +585,8 @@ public class FragmentFolders extends FragmentBase {
@Override
protected void onException(Bundle args, Throwable ex) {
if (ex instanceof IllegalStateException) {
Snackbar snackbar = Snackbar.make(view, new ThrowableWrapper(ex).getSafeMessage(), Snackbar.LENGTH_LONG)
.setGestureInsetBottomIgnored(true);
Snackbar snackbar = Helper.setSnackbarOptions(
Snackbar.make(view, new ThrowableWrapper(ex).getSafeMessage(), Snackbar.LENGTH_LONG));
snackbar.setAction(R.string.title_fix, new View.OnClickListener() {
@Override
public void onClick(View v) {
@ -597,8 +597,9 @@ public class FragmentFolders extends FragmentBase {
});
snackbar.show();
} else if (ex instanceof IllegalArgumentException)
Snackbar.make(view, new ThrowableWrapper(ex).getSafeMessage(), Snackbar.LENGTH_LONG)
.setGestureInsetBottomIgnored(true).show();
Helper.setSnackbarOptions(
Snackbar.make(view, new ThrowableWrapper(ex).getSafeMessage(), Snackbar.LENGTH_LONG))
.show();
else
Log.unexpectedError(getParentFragmentManager(), ex);
}

@ -734,8 +734,9 @@ public class FragmentIdentity extends FragmentBase {
(ex instanceof UnknownHostException ||
ex instanceof FileNotFoundException ||
ex instanceof IllegalArgumentException))
Snackbar.make(view, new ThrowableWrapper(ex).getSafeMessage(), Snackbar.LENGTH_LONG)
.setGestureInsetBottomIgnored(true).show();
Helper.setSnackbarOptions(
Snackbar.make(view, new ThrowableWrapper(ex).getSafeMessage(), Snackbar.LENGTH_LONG))
.show();
else
Log.unexpectedError(getParentFragmentManager(), ex);
}
@ -1244,8 +1245,9 @@ public class FragmentIdentity extends FragmentBase {
@Override
protected void onException(Bundle args, Throwable ex) {
if (ex instanceof IllegalArgumentException)
Snackbar.make(view, new ThrowableWrapper(ex).getSafeMessage(), Snackbar.LENGTH_LONG)
.setGestureInsetBottomIgnored(true).show();
Helper.setSnackbarOptions(
Snackbar.make(view, new ThrowableWrapper(ex).getSafeMessage(), Snackbar.LENGTH_LONG))
.show();
else
showError(ex);
}

@ -2424,8 +2424,8 @@ public class FragmentMessages extends FragmentBase
@Override
protected void onException(Bundle args, Throwable ex) {
if (ex instanceof IllegalStateException) {
Snackbar snackbar = Snackbar.make(view, new ThrowableWrapper(ex).getSafeMessage(), Snackbar.LENGTH_LONG)
.setGestureInsetBottomIgnored(true);
Snackbar snackbar = Helper.setSnackbarOptions(
Snackbar.make(view, new ThrowableWrapper(ex).getSafeMessage(), Snackbar.LENGTH_LONG));
snackbar.setAction(R.string.title_fix, new View.OnClickListener() {
@Override
public void onClick(View v) {
@ -2436,8 +2436,9 @@ public class FragmentMessages extends FragmentBase
});
snackbar.show();
} else if (ex instanceof IllegalArgumentException)
Snackbar.make(view, new ThrowableWrapper(ex).getSafeMessage(), Snackbar.LENGTH_LONG)
.setGestureInsetBottomIgnored(true).show();
Helper.setSnackbarOptions(
Snackbar.make(view, new ThrowableWrapper(ex).getSafeMessage(), Snackbar.LENGTH_LONG))
.show();
else
Log.unexpectedError(getParentFragmentManager(), ex);
}
@ -3749,8 +3750,9 @@ public class FragmentMessages extends FragmentBase
@Override
protected void onException(Bundle args, Throwable ex) {
if (ex instanceof IllegalArgumentException)
Snackbar.make(view, new ThrowableWrapper(ex).getSafeMessage(), Snackbar.LENGTH_LONG)
.setGestureInsetBottomIgnored(true).show();
Helper.setSnackbarOptions(
Snackbar.make(view, new ThrowableWrapper(ex).getSafeMessage(), Snackbar.LENGTH_LONG))
.show();
else
Log.unexpectedError(getParentFragmentManager(), ex);
}
@ -4177,8 +4179,7 @@ public class FragmentMessages extends FragmentBase
protected void onExecuted(Bundle args, List<EntityAnswer> answers) {
final Context context = getContext();
if (answers == null || answers.size() == 0) {
Snackbar snackbar = Snackbar.make(view, R.string.title_no_answers, Snackbar.LENGTH_LONG)
.setGestureInsetBottomIgnored(true);
Snackbar snackbar = Helper.setSnackbarOptions(Snackbar.make(view, R.string.title_no_answers, Snackbar.LENGTH_LONG));
snackbar.setAction(R.string.title_fix, new View.OnClickListener() {
@Override
public void onClick(View v) {
@ -5635,8 +5636,7 @@ public class FragmentMessages extends FragmentBase
if (!redmi_note)
return false;
final Snackbar snackbar = Snackbar.make(view, R.string.app_data_loss, Snackbar.LENGTH_INDEFINITE)
.setGestureInsetBottomIgnored(true);
final Snackbar snackbar = Helper.setSnackbarOptions(Snackbar.make(view, R.string.app_data_loss, Snackbar.LENGTH_INDEFINITE));
snackbar.setAction(R.string.title_info, new View.OnClickListener() {
@Override
public void onClick(View v) {
@ -5666,10 +5666,9 @@ public class FragmentMessages extends FragmentBase
if (AlarmManagerCompatEx.canScheduleExactAlarms(context))
return false;
final Snackbar snackbar = Snackbar.make(view,
R.string.title_setup_alarm_12,
Snackbar.LENGTH_INDEFINITE)
.setGestureInsetBottomIgnored(true);
final Snackbar snackbar = Helper.setSnackbarOptions(Snackbar.make(view,
R.string.title_setup_alarm_12,
Snackbar.LENGTH_INDEFINITE));
snackbar.setAction(R.string.title_fix, new View.OnClickListener() {
@Override
public void onClick(View v) {
@ -5691,8 +5690,7 @@ public class FragmentMessages extends FragmentBase
prefs.getBoolean("crash_reports_asked", false))
return false;
final Snackbar snackbar = Snackbar.make(view, R.string.title_ask_help, Snackbar.LENGTH_INDEFINITE)
.setGestureInsetBottomIgnored(true);
final Snackbar snackbar = Helper.setSnackbarOptions(Snackbar.make(view, R.string.title_ask_help, Snackbar.LENGTH_INDEFINITE));
snackbar.setAction(R.string.title_info, new View.OnClickListener() {
@Override
public void onClick(View v) {
@ -5739,8 +5737,7 @@ public class FragmentMessages extends FragmentBase
return false;
}
final Snackbar snackbar = Snackbar.make(view, R.string.title_ask_review, Snackbar.LENGTH_INDEFINITE)
.setGestureInsetBottomIgnored(true);
final Snackbar snackbar = Helper.setSnackbarOptions(Snackbar.make(view, R.string.title_ask_review, Snackbar.LENGTH_INDEFINITE));
snackbar.setAction(R.string.title_info, new View.OnClickListener() {
@Override
public void onClick(View v) {
@ -5767,8 +5764,7 @@ public class FragmentMessages extends FragmentBase
if (prefs.getBoolean("third_party_notified", false))
return false;
final Snackbar snackbar = Snackbar.make(view, R.string.title_third_party, Snackbar.LENGTH_INDEFINITE)
.setGestureInsetBottomIgnored(true);
final Snackbar snackbar = Helper.setSnackbarOptions(Snackbar.make(view, R.string.title_third_party, Snackbar.LENGTH_INDEFINITE));
snackbar.setAction(R.string.title_info, new View.OnClickListener() {
@Override
public void onClick(View v) {
@ -5846,8 +5842,7 @@ public class FragmentMessages extends FragmentBase
final int resid = (passwd > 0
? R.string.title_check_gmail_password
: R.string.title_check_gmail_oauth);
final Snackbar snackbar = Snackbar.make(view, resid, Snackbar.LENGTH_INDEFINITE)
.setGestureInsetBottomIgnored(true);
final Snackbar snackbar = Helper.setSnackbarOptions(Snackbar.make(view, resid, Snackbar.LENGTH_INDEFINITE));
snackbar.setAction(R.string.title_info, new View.OnClickListener() {
@Override
public void onClick(View v) {
@ -5936,8 +5931,7 @@ public class FragmentMessages extends FragmentBase
final int resid = (passwd > 0
? R.string.title_check_outlook_password
: R.string.title_check_outlook_oauth);
final Snackbar snackbar = Snackbar.make(view, resid, Snackbar.LENGTH_INDEFINITE)
.setGestureInsetBottomIgnored(true);
final Snackbar snackbar = Helper.setSnackbarOptions(Snackbar.make(view, resid, Snackbar.LENGTH_INDEFINITE));
snackbar.setAction(R.string.title_info, new View.OnClickListener() {
@Override
public void onClick(View v) {
@ -7259,8 +7253,8 @@ public class FragmentMessages extends FragmentBase
if (getLifecycle().getCurrentState().isAtLeast(Lifecycle.State.STARTED))
if (ex instanceof IllegalStateException) {
// No internet connection
Snackbar snackbar = Snackbar.make(view, ex.getMessage(), Snackbar.LENGTH_LONG)
.setGestureInsetBottomIgnored(true);
Snackbar snackbar = Helper.setSnackbarOptions(
Snackbar.make(view, ex.getMessage(), Snackbar.LENGTH_LONG));
snackbar.setAction(R.string.title_fix, new View.OnClickListener() {
@Override
public void onClick(View v) {
@ -8193,8 +8187,9 @@ public class FragmentMessages extends FragmentBase
@Override
protected void onException(Bundle args, Throwable ex) {
if (ex instanceof IllegalArgumentException)
Snackbar.make(view, ex.getMessage(), Snackbar.LENGTH_LONG)
.setGestureInsetBottomIgnored(true).show();
Helper.setSnackbarOptions(
Snackbar.make(view, ex.getMessage(), Snackbar.LENGTH_LONG))
.show();
else
Log.unexpectedError(getParentFragmentManager(), ex);
}
@ -8851,8 +8846,8 @@ public class FragmentMessages extends FragmentBase
Helper.openAdvanced(context, create);
PackageManager pm = context.getPackageManager();
if (create.resolveActivity(pm) == null) // system whitelisted
Snackbar.make(view, R.string.title_no_saf, Snackbar.LENGTH_LONG)
.setGestureInsetBottomIgnored(true).show();
Helper.setSnackbarOptions(Snackbar.make(view, R.string.title_no_saf, Snackbar.LENGTH_LONG))
.show();
else
startActivityForResult(Helper.getChooser(context, create), REQUEST_RAW);
}
@ -8910,8 +8905,7 @@ public class FragmentMessages extends FragmentBase
@Override
public void onNothingSelected() {
Snackbar snackbar = Snackbar.make(view, R.string.title_no_key, Snackbar.LENGTH_LONG)
.setGestureInsetBottomIgnored(true);
Snackbar snackbar = Helper.setSnackbarOptions(Snackbar.make(view, R.string.title_no_key, Snackbar.LENGTH_LONG));
final Intent intent = (Build.VERSION.SDK_INT < Build.VERSION_CODES.R
? KeyChain.createInstallIntent()
: new Intent(Settings.ACTION_SECURITY_SETTINGS));
@ -9156,15 +9150,16 @@ public class FragmentMessages extends FragmentBase
@Override
protected void onExecuted(Bundle args, Void data) {
Snackbar.make(view, R.string.title_raw_saved, Snackbar.LENGTH_LONG)
.setGestureInsetBottomIgnored(true).show();
Helper.setSnackbarOptions(Snackbar.make(view, R.string.title_raw_saved, Snackbar.LENGTH_LONG))
.show();
}
@Override
protected void onException(Bundle args, Throwable ex) {
if (ex instanceof IllegalArgumentException || ex instanceof FileNotFoundException)
Snackbar.make(view, ex.getMessage(), Snackbar.LENGTH_LONG)
.setGestureInsetBottomIgnored(true).show();
Helper.setSnackbarOptions(
Snackbar.make(view, ex.getMessage(), Snackbar.LENGTH_LONG))
.show();
else if (!(ex instanceof MessageRemovedException))
Log.unexpectedError(getParentFragmentManager(), ex);
}
@ -9495,8 +9490,8 @@ public class FragmentMessages extends FragmentBase
protected void onExecuted(Bundle args, PendingIntent pi) {
if (args.containsKey("sigresult")) {
String text = args.getString("sigresult");
Snackbar sb = Snackbar.make(view, text, Snackbar.LENGTH_LONG)
.setGestureInsetBottomIgnored(true);
Snackbar sb = Helper.setSnackbarOptions(
Snackbar.make(view, text, Snackbar.LENGTH_LONG));
Helper.setSnackbarLines(sb, 7);
sb.show();
}
@ -9523,11 +9518,11 @@ public class FragmentMessages extends FragmentBase
if (ex instanceof IllegalArgumentException) {
Log.i(ex);
Snackbar.make(view, ex.getMessage(), Snackbar.LENGTH_LONG)
.setGestureInsetBottomIgnored(true).show();
Helper.setSnackbarOptions(
Snackbar.make(view, ex.getMessage(), Snackbar.LENGTH_LONG))
.show();
} else if (ex instanceof OperationCanceledException) {
Snackbar snackbar = Snackbar.make(view, R.string.title_no_openpgp, Snackbar.LENGTH_INDEFINITE)
.setGestureInsetBottomIgnored(true);
Snackbar snackbar = Helper.setSnackbarOptions(Snackbar.make(view, R.string.title_no_openpgp, Snackbar.LENGTH_INDEFINITE));
snackbar.setAction(R.string.title_fix, new View.OnClickListener() {
@Override
public void onClick(View v) {
@ -9906,8 +9901,9 @@ public class FragmentMessages extends FragmentBase
message = getString(R.string.title_signature_invalid);
else
message = getString(R.string.title_signature_invalid_reason, reason);
Snackbar.make(view, message, Snackbar.LENGTH_LONG)
.setGestureInsetBottomIgnored(true).show();
Helper.setSnackbarOptions(
Snackbar.make(view, message, Snackbar.LENGTH_LONG))
.show();
} else
try {
boolean auto = args.getBoolean("auto");
@ -9932,8 +9928,8 @@ public class FragmentMessages extends FragmentBase
}
if (known && !record.isExpired(time) && match && valid)
Snackbar.make(view, R.string.title_signature_valid, Snackbar.LENGTH_LONG)
.setGestureInsetBottomIgnored(true).show();
Helper.setSnackbarOptions(Snackbar.make(view, R.string.title_signature_valid, Snackbar.LENGTH_LONG))
.show();
else if (!auto) {
LayoutInflater inflator = LayoutInflater.from(getContext());
View dview = inflator.inflate(R.layout.dialog_certificate, null);
@ -10043,14 +10039,16 @@ public class FragmentMessages extends FragmentBase
builder.show();
}
} catch (Throwable ex) {
Snackbar.make(view, Log.formatThrowable(ex), Snackbar.LENGTH_LONG)
.setGestureInsetBottomIgnored(true).show();
Helper.setSnackbarOptions(
Snackbar.make(view, Log.formatThrowable(ex), Snackbar.LENGTH_LONG))
.show();
}
} else if (EntityMessage.SMIME_SIGNENCRYPT.equals(type)) {
String algo = args.getString("algo");
if (!TextUtils.isEmpty(algo))
Snackbar.make(view, algo, Snackbar.LENGTH_LONG)
.setGestureInsetBottomIgnored(true).show();
Helper.setSnackbarOptions(
Snackbar.make(view, algo, Snackbar.LENGTH_LONG))
.show();
}
}
@ -10062,8 +10060,9 @@ public class FragmentMessages extends FragmentBase
if (ex instanceof IllegalArgumentException ||
ex instanceof CMSException || ex instanceof KeyChainException)
Snackbar.make(view, ex.getMessage(), Snackbar.LENGTH_LONG)
.setGestureInsetBottomIgnored(true).show();
Helper.setSnackbarOptions(
Snackbar.make(view, ex.getMessage(), Snackbar.LENGTH_LONG))
.show();
else
Log.unexpectedError(getParentFragmentManager(), ex);
}
@ -10444,8 +10443,8 @@ public class FragmentMessages extends FragmentBase
@Override
protected void onException(Bundle args, Throwable ex) {
if (ex instanceof IllegalArgumentException) {
Snackbar snackbar = Snackbar.make(view, ex.getMessage(), Snackbar.LENGTH_INDEFINITE)
.setGestureInsetBottomIgnored(true);
Snackbar snackbar = Helper.setSnackbarOptions(
Snackbar.make(view, ex.getMessage(), Snackbar.LENGTH_INDEFINITE));
snackbar.setAction(R.string.title_fix, new View.OnClickListener() {
@Override
public void onClick(View v) {

@ -792,8 +792,9 @@ public class FragmentPop extends FragmentBase {
@Override
protected void onException(Bundle args, Throwable ex) {
if (ex instanceof IllegalArgumentException)
Snackbar.make(view, new ThrowableWrapper(ex).getSafeMessage(), Snackbar.LENGTH_LONG)
.setGestureInsetBottomIgnored(true).show();
Helper.setSnackbarOptions(
Snackbar.make(view, new ThrowableWrapper(ex).getSafeMessage(), Snackbar.LENGTH_LONG))
.show();
else {
tvError.setText(Log.formatThrowable(ex, false));
grpError.setVisibility(View.VISIBLE);

@ -303,8 +303,8 @@ public class FragmentPro extends FragmentBase implements SharedPreferences.OnSha
if (view == null)
return;
Snackbar snackbar = Snackbar.make(view, message, Snackbar.LENGTH_INDEFINITE)
.setGestureInsetBottomIgnored(true);
Snackbar snackbar = Helper.setSnackbarOptions(
Snackbar.make(view, message, Snackbar.LENGTH_INDEFINITE));
snackbar.setAction(R.string.title_setup_help, new View.OnClickListener() {
@Override
public void onClick(View view) {

@ -1629,8 +1629,9 @@ public class FragmentRule extends FragmentBase {
@Override
protected void onException(Bundle args, Throwable ex) {
if (ex instanceof IllegalArgumentException)
Snackbar.make(view, new ThrowableWrapper(ex).getSafeMessage(), Snackbar.LENGTH_LONG)
.setGestureInsetBottomIgnored(true).show();
Helper.setSnackbarOptions(
Snackbar.make(view, new ThrowableWrapper(ex).getSafeMessage(), Snackbar.LENGTH_LONG))
.show();
else
Log.unexpectedError(getParentFragmentManager(), ex);
}

@ -1453,8 +1453,8 @@ public class FragmentSetup extends FragmentBase implements SharedPreferences.OnS
NumberFormat NF = NumberFormat.getInstance();
String msg = getString(R.string.title_setup_import_graph_new, NF.format(count));
final Snackbar snackbar = Snackbar.make(view, msg, Snackbar.LENGTH_INDEFINITE)
.setGestureInsetBottomIgnored(true);
final Snackbar snackbar = Helper.setSnackbarOptions(
Snackbar.make(view, msg, Snackbar.LENGTH_INDEFINITE));
snackbar.setAction(R.string.title_check, new View.OnClickListener() {
@Override
public void onClick(View v) {

@ -2067,6 +2067,11 @@ public class Helper {
view.setLayoutParams(lparam);
}
static Snackbar setSnackbarOptions(Snackbar snackbar) {
snackbar.setGestureInsetBottomIgnored(true);
return snackbar;
}
static void setSnackbarLines(Snackbar snackbar, int lines) {
View sv = snackbar.getView();
if (sv == null)

Loading…
Cancel
Save