Prevent crash

pull/158/head
M66B 6 years ago
parent 930663ff76
commit 269bd11d87

@ -361,11 +361,21 @@ public class ActivitySetup extends ActivityBase implements FragmentManager.OnBac
@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
if (resultCode == RESULT_OK && data != null)
if (requestCode == REQUEST_EXPORT)
handleExport(data, this.password);
else if (requestCode == REQUEST_IMPORT)
handleImport(data, this.password);
try {
switch (requestCode) {
case REQUEST_EXPORT:
if (resultCode == RESULT_OK && data != null)
handleExport(data, this.password);
break;
case REQUEST_IMPORT:
if (resultCode == RESULT_OK && data != null)
handleImport(data, this.password);
break;
}
} catch (Throwable ex) {
Log.e(ex);
}
}
private void onMenuExport() {

@ -1293,32 +1293,36 @@ public class FragmentAccount extends FragmentBase {
public void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) {
super.onActivityResult(requestCode, resultCode, data);
switch (requestCode) {
case REQUEST_COLOR:
if (resultCode == RESULT_OK && data != null) {
if (Helper.isPro(getContext())) {
Bundle args = data.getBundleExtra("args");
setColor(args.getInt("color"));
} else
ToastEx.makeText(getContext(), R.string.title_pro_feature, Toast.LENGTH_LONG).show();
}
break;
case REQUEST_SAVE:
if (resultCode == RESULT_OK) {
new Handler().post(new Runnable() {
@Override
public void run() {
scroll.smoothScrollTo(0, btnSave.getBottom());
}
});
onSave(false);
} else if (getLifecycle().getCurrentState().isAtLeast(Lifecycle.State.RESUMED))
getFragmentManager().popBackStack();
break;
case REQUEST_DELETE:
if (resultCode == RESULT_OK)
onDelete();
break;
try {
switch (requestCode) {
case REQUEST_COLOR:
if (resultCode == RESULT_OK && data != null) {
if (Helper.isPro(getContext())) {
Bundle args = data.getBundleExtra("args");
setColor(args.getInt("color"));
} else
ToastEx.makeText(getContext(), R.string.title_pro_feature, Toast.LENGTH_LONG).show();
}
break;
case REQUEST_SAVE:
if (resultCode == RESULT_OK) {
new Handler().post(new Runnable() {
@Override
public void run() {
scroll.smoothScrollTo(0, btnSave.getBottom());
}
});
onSave(false);
} else if (getLifecycle().getCurrentState().isAtLeast(Lifecycle.State.RESUMED))
getFragmentManager().popBackStack();
break;
case REQUEST_DELETE:
if (resultCode == RESULT_OK)
onDelete();
break;
}
} catch (Throwable ex) {
Log.e(ex);
}
}

@ -214,11 +214,15 @@ public class FragmentAnswer extends FragmentBase {
public void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) {
super.onActivityResult(requestCode, resultCode, data);
switch (requestCode) {
case REQUEST_DELETE:
if (resultCode == RESULT_OK)
onDelete();
break;
try {
switch (requestCode) {
case REQUEST_DELETE:
if (resultCode == RESULT_OK)
onDelete();
break;
}
} catch (Throwable ex) {
Log.e(ex);
}
}

@ -1108,70 +1108,74 @@ public class FragmentCompose extends FragmentBase {
public void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
switch (requestCode) {
case REQUEST_CONTACT_TO:
case REQUEST_CONTACT_CC:
case REQUEST_CONTACT_BCC:
if (resultCode == RESULT_OK && data != null)
onPickContact(requestCode, data);
break;
case REQUEST_IMAGE:
if (resultCode == RESULT_OK && data != null) {
Uri uri = data.getData();
if (uri != null)
onAddAttachment(uri, true);
}
break;
case REQUEST_ATTACHMENT:
case REQUEST_RECORD_AUDIO:
case REQUEST_TAKE_PHOTO:
if (resultCode == RESULT_OK)
if (requestCode == REQUEST_TAKE_PHOTO)
onAddMedia(new Intent().setData(photoURI));
else if (data != null)
onAddMedia(data);
break;
case REQUEST_ENCRYPT:
if (resultCode == RESULT_OK && data != null) {
if (BuildConfig.DEBUG || BuildConfig.BETA_RELEASE)
Log.logExtras(data);
onPgp(data);
}
break;
case REQUEST_COLOR:
if (resultCode == RESULT_OK && data != null)
onColorSelected(data.getBundleExtra("args"));
break;
case REQUEST_SEND_AFTER:
if (resultCode == RESULT_OK && data != null) {
Bundle args = data.getBundleExtra("args");
onSendAfter(args.getLong("time"));
}
break;
case REQUEST_REF_EDIT:
if (resultCode == RESULT_OK)
onReferenceEditConfirmed();
break;
case REQUEST_CONTACT_GROUP:
if (resultCode == RESULT_OK && data != null)
onContactGroupSelected(data.getBundleExtra("args"));
break;
case REQUEST_ANSWER:
if (resultCode == RESULT_OK && data != null)
onAnswerSelected(data.getBundleExtra("args"));
break;
case REQUEST_LINK:
if (resultCode == RESULT_OK && data != null)
onLinkSelected(data.getBundleExtra("args"));
break;
case REQUEST_DISCARD:
if (resultCode == RESULT_OK)
onAction(R.id.action_delete);
break;
case REQUEST_SEND:
if (resultCode == RESULT_OK)
onActionSendConfirmed();
break;
try {
switch (requestCode) {
case REQUEST_CONTACT_TO:
case REQUEST_CONTACT_CC:
case REQUEST_CONTACT_BCC:
if (resultCode == RESULT_OK && data != null)
onPickContact(requestCode, data);
break;
case REQUEST_IMAGE:
if (resultCode == RESULT_OK && data != null) {
Uri uri = data.getData();
if (uri != null)
onAddAttachment(uri, true);
}
break;
case REQUEST_ATTACHMENT:
case REQUEST_RECORD_AUDIO:
case REQUEST_TAKE_PHOTO:
if (resultCode == RESULT_OK)
if (requestCode == REQUEST_TAKE_PHOTO)
onAddMedia(new Intent().setData(photoURI));
else if (data != null)
onAddMedia(data);
break;
case REQUEST_ENCRYPT:
if (resultCode == RESULT_OK && data != null) {
if (BuildConfig.DEBUG || BuildConfig.BETA_RELEASE)
Log.logExtras(data);
onPgp(data);
}
break;
case REQUEST_COLOR:
if (resultCode == RESULT_OK && data != null)
onColorSelected(data.getBundleExtra("args"));
break;
case REQUEST_SEND_AFTER:
if (resultCode == RESULT_OK && data != null) {
Bundle args = data.getBundleExtra("args");
onSendAfter(args.getLong("time"));
}
break;
case REQUEST_REF_EDIT:
if (resultCode == RESULT_OK)
onReferenceEditConfirmed();
break;
case REQUEST_CONTACT_GROUP:
if (resultCode == RESULT_OK && data != null)
onContactGroupSelected(data.getBundleExtra("args"));
break;
case REQUEST_ANSWER:
if (resultCode == RESULT_OK && data != null)
onAnswerSelected(data.getBundleExtra("args"));
break;
case REQUEST_LINK:
if (resultCode == RESULT_OK && data != null)
onLinkSelected(data.getBundleExtra("args"));
break;
case REQUEST_DISCARD:
if (resultCode == RESULT_OK)
onAction(R.id.action_delete);
break;
case REQUEST_SEND:
if (resultCode == RESULT_OK)
onActionSendConfirmed();
break;
}
} catch (Throwable ex) {
Log.e(ex);
}
}

@ -244,24 +244,28 @@ public class FragmentFolder extends FragmentBase {
public void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) {
super.onActivityResult(requestCode, resultCode, data);
switch (requestCode) {
case REQUEST_SAVE_CHANGES:
if (resultCode == RESULT_OK) {
new Handler().post(new Runnable() {
@Override
public void run() {
scroll.smoothScrollTo(0, btnSave.getBottom());
}
});
onSave(false);
} else if (getLifecycle().getCurrentState().isAtLeast(Lifecycle.State.RESUMED))
getFragmentManager().popBackStack();
break;
case REQUEST_DELETE_FOLDER:
if (resultCode == RESULT_OK)
onDelete();
break;
try {
switch (requestCode) {
case REQUEST_SAVE_CHANGES:
if (resultCode == RESULT_OK) {
new Handler().post(new Runnable() {
@Override
public void run() {
scroll.smoothScrollTo(0, btnSave.getBottom());
}
});
onSave(false);
} else if (getLifecycle().getCurrentState().isAtLeast(Lifecycle.State.RESUMED))
getFragmentManager().popBackStack();
break;
case REQUEST_DELETE_FOLDER:
if (resultCode == RESULT_OK)
onDelete();
break;
}
} catch (Throwable ex) {
Log.e(ex);
}
}

@ -429,25 +429,29 @@ public class FragmentFolders extends FragmentBase {
public void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) {
super.onActivityResult(requestCode, resultCode, data);
switch (requestCode) {
case REQUEST_SYNC:
if (resultCode == RESULT_OK && data != null) {
Bundle args = data.getBundleExtra("args");
onSync(args.getLong("folder"), args.getBoolean("all"));
}
break;
case REQUEST_DELETE_LOCAL:
if (resultCode == RESULT_OK && data != null) {
Bundle args = data.getBundleExtra("args");
onDeleteLocal(args.getLong("folder"), args.getBoolean("browsed"));
}
break;
case REQUEST_EMPTY_TRASH:
if (resultCode == RESULT_OK && data != null) {
Bundle args = data.getBundleExtra("args");
onEmptyTrash(args.getLong("folder"));
}
break;
try {
switch (requestCode) {
case REQUEST_SYNC:
if (resultCode == RESULT_OK && data != null) {
Bundle args = data.getBundleExtra("args");
onSync(args.getLong("folder"), args.getBoolean("all"));
}
break;
case REQUEST_DELETE_LOCAL:
if (resultCode == RESULT_OK && data != null) {
Bundle args = data.getBundleExtra("args");
onDeleteLocal(args.getLong("folder"), args.getBoolean("browsed"));
}
break;
case REQUEST_EMPTY_TRASH:
if (resultCode == RESULT_OK && data != null) {
Bundle args = data.getBundleExtra("args");
onEmptyTrash(args.getLong("folder"));
}
break;
}
} catch (Throwable ex) {
Log.e(ex);
}
}

@ -1030,36 +1030,40 @@ public class FragmentIdentity extends FragmentBase {
public void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) {
super.onActivityResult(requestCode, resultCode, data);
switch (requestCode) {
case REQUEST_COLOR:
if (resultCode == RESULT_OK && data != null) {
if (Helper.isPro(getContext())) {
Bundle args = data.getBundleExtra("args");
setColor(args.getInt("color"));
} else
ToastEx.makeText(getContext(), R.string.title_pro_feature, Toast.LENGTH_LONG).show();
}
break;
case REQUEST_SAVE:
if (resultCode == RESULT_OK) {
new Handler().post(new Runnable() {
@Override
public void run() {
scroll.smoothScrollTo(0, btnSave.getBottom());
}
});
onSave(false);
} else if (getLifecycle().getCurrentState().isAtLeast(Lifecycle.State.RESUMED))
getFragmentManager().popBackStack();
break;
case REQUEST_DELETE:
if (resultCode == RESULT_OK)
onDelete();
break;
case REQUEST_HTML:
if (resultCode == RESULT_OK && data != null)
onHtml(data.getBundleExtra("args"));
break;
try {
switch (requestCode) {
case REQUEST_COLOR:
if (resultCode == RESULT_OK && data != null) {
if (Helper.isPro(getContext())) {
Bundle args = data.getBundleExtra("args");
setColor(args.getInt("color"));
} else
ToastEx.makeText(getContext(), R.string.title_pro_feature, Toast.LENGTH_LONG).show();
}
break;
case REQUEST_SAVE:
if (resultCode == RESULT_OK) {
new Handler().post(new Runnable() {
@Override
public void run() {
scroll.smoothScrollTo(0, btnSave.getBottom());
}
});
onSave(false);
} else if (getLifecycle().getCurrentState().isAtLeast(Lifecycle.State.RESUMED))
getFragmentManager().popBackStack();
break;
case REQUEST_DELETE:
if (resultCode == RESULT_OK)
onDelete();
break;
case REQUEST_HTML:
if (resultCode == RESULT_OK && data != null)
onHtml(data.getBundleExtra("args"));
break;
}
} catch (Throwable ex) {
Log.e(ex);
}
}

@ -3338,105 +3338,109 @@ public class FragmentMessages extends FragmentBase implements SharedPreferences.
public void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
switch (requestCode) {
case REQUEST_RAW:
if (resultCode == RESULT_OK && data != null)
onSaveRaw(data);
break;
case REQUEST_ATTACHMENT:
if (resultCode == RESULT_OK && data != null)
onSaveAttachment(data);
break;
case REQUEST_ATTACHMENTS:
if (resultCode == RESULT_OK && data != null)
onSaveAttachments(data);
break;
case REQUEST_DECRYPT:
if (resultCode == RESULT_OK && data != null)
onDecrypt(data, message);
break;
case REQUEST_MESSAGE_DELETE:
if (resultCode == RESULT_OK && data != null)
onDelete(data.getBundleExtra("args").getLong("id"));
break;
case REQUEST_MESSAGES_DELETE:
if (resultCode == RESULT_OK && data != null)
onDelete(data.getBundleExtra("args").getLongArray("ids"));
break;
case REQUEST_MESSAGE_JUNK:
if (resultCode == RESULT_OK && data != null)
onJunk(data.getBundleExtra("args").getLong("id"));
break;
case REQUEST_MESSAGES_JUNK:
if (resultCode == RESULT_OK)
onActionMoveSelection(EntityFolder.JUNK);
break;
case REQUEST_ASKED_MOVE:
if (resultCode == RESULT_OK && data != null)
onMoveAskAcross(data.getBundleExtra("args").<MessageTarget>getParcelableArrayList("result"));
break;
case REQUEST_ASKED_MOVE_ACROSS:
if (resultCode == RESULT_OK && data != null)
moveAskConfirmed(data.getBundleExtra("args").<MessageTarget>getParcelableArrayList("result"));
break;
case REQUEST_MESSAGE_COLOR:
if (resultCode == RESULT_OK && data != null) {
Bundle args = data.getBundleExtra("args");
onColor(args.getLong("id"), args.getInt("color"));
}
break;
case REQUEST_MESSAGES_COLOR:
if (resultCode == RESULT_OK && data != null) {
if (!Helper.isPro(getContext())) {
LocalBroadcastManager lbm = LocalBroadcastManager.getInstance(getContext());
lbm.sendBroadcast(new Intent(ActivityView.ACTION_SHOW_PRO));
return;
try {
switch (requestCode) {
case REQUEST_RAW:
if (resultCode == RESULT_OK && data != null)
onSaveRaw(data);
break;
case REQUEST_ATTACHMENT:
if (resultCode == RESULT_OK && data != null)
onSaveAttachment(data);
break;
case REQUEST_ATTACHMENTS:
if (resultCode == RESULT_OK && data != null)
onSaveAttachments(data);
break;
case REQUEST_DECRYPT:
if (resultCode == RESULT_OK && data != null)
onDecrypt(data, message);
break;
case REQUEST_MESSAGE_DELETE:
if (resultCode == RESULT_OK && data != null)
onDelete(data.getBundleExtra("args").getLong("id"));
break;
case REQUEST_MESSAGES_DELETE:
if (resultCode == RESULT_OK && data != null)
onDelete(data.getBundleExtra("args").getLongArray("ids"));
break;
case REQUEST_MESSAGE_JUNK:
if (resultCode == RESULT_OK && data != null)
onJunk(data.getBundleExtra("args").getLong("id"));
break;
case REQUEST_MESSAGES_JUNK:
if (resultCode == RESULT_OK)
onActionMoveSelection(EntityFolder.JUNK);
break;
case REQUEST_ASKED_MOVE:
if (resultCode == RESULT_OK && data != null)
onMoveAskAcross(data.getBundleExtra("args").<MessageTarget>getParcelableArrayList("result"));
break;
case REQUEST_ASKED_MOVE_ACROSS:
if (resultCode == RESULT_OK && data != null)
moveAskConfirmed(data.getBundleExtra("args").<MessageTarget>getParcelableArrayList("result"));
break;
case REQUEST_MESSAGE_COLOR:
if (resultCode == RESULT_OK && data != null) {
Bundle args = data.getBundleExtra("args");
onColor(args.getLong("id"), args.getInt("color"));
}
break;
case REQUEST_MESSAGES_COLOR:
if (resultCode == RESULT_OK && data != null) {
if (!Helper.isPro(getContext())) {
LocalBroadcastManager lbm = LocalBroadcastManager.getInstance(getContext());
lbm.sendBroadcast(new Intent(ActivityView.ACTION_SHOW_PRO));
return;
}
Bundle args = data.getBundleExtra("args");
onActionFlagSelection(true, args.getInt("color"));
}
break;
case REQUEST_MESSAGE_SNOOZE:
if (resultCode == RESULT_OK && data != null)
onSnooze(data.getBundleExtra("args"));
break;
case REQUEST_MESSAGES_SNOOZE:
if (resultCode == RESULT_OK && data != null)
onSnoozeSelection(data.getBundleExtra("args"));
break;
case REQUEST_MESSAGE_MOVE:
if (resultCode == RESULT_OK && data != null)
onMove(data.getBundleExtra("args"));
break;
case REQUEST_MESSAGES_MOVE:
if (resultCode == RESULT_OK && data != null) {
Bundle args = data.getBundleExtra("args");
onActionMoveSelection(args.getLong("folder"));
}
break;
case REQUEST_PRINT:
if (resultCode == RESULT_OK && data != null)
onPrint(data.getBundleExtra("args"));
break;
case REQUEST_SEARCH:
if (resultCode == RESULT_OK && data != null) {
Bundle args = data.getBundleExtra("args");
search(
getContext(), getViewLifecycleOwner(), getFragmentManager(),
args.getLong("folder"), true, args.getString("query"));
}
break;
case REQUEST_ACCOUNT:
if (resultCode == RESULT_OK && data != null) {
Bundle args = data.getBundleExtra("args");
onMenuFolders(args.getLong("account"));
}
break;
case REQUEST_MESSAGE_PROPERTY:
if (resultCode == RESULT_OK)
onPropertySet(data.getBundleExtra("args"));
break;
Bundle args = data.getBundleExtra("args");
onActionFlagSelection(true, args.getInt("color"));
}
break;
case REQUEST_MESSAGE_SNOOZE:
if (resultCode == RESULT_OK && data != null)
onSnooze(data.getBundleExtra("args"));
break;
case REQUEST_MESSAGES_SNOOZE:
if (resultCode == RESULT_OK && data != null)
onSnoozeSelection(data.getBundleExtra("args"));
break;
case REQUEST_MESSAGE_MOVE:
if (resultCode == RESULT_OK && data != null)
onMove(data.getBundleExtra("args"));
break;
case REQUEST_MESSAGES_MOVE:
if (resultCode == RESULT_OK && data != null) {
Bundle args = data.getBundleExtra("args");
onActionMoveSelection(args.getLong("folder"));
}
break;
case REQUEST_PRINT:
if (resultCode == RESULT_OK && data != null)
onPrint(data.getBundleExtra("args"));
break;
case REQUEST_SEARCH:
if (resultCode == RESULT_OK && data != null) {
Bundle args = data.getBundleExtra("args");
search(
getContext(), getViewLifecycleOwner(), getFragmentManager(),
args.getLong("folder"), true, args.getString("query"));
}
break;
case REQUEST_ACCOUNT:
if (resultCode == RESULT_OK && data != null) {
Bundle args = data.getBundleExtra("args");
onMenuFolders(args.getLong("account"));
}
break;
case REQUEST_MESSAGE_PROPERTY:
if (resultCode == RESULT_OK)
onPropertySet(data.getBundleExtra("args"));
break;
}
} catch (Throwable ex) {
Log.e(ex);
}
}

@ -258,19 +258,28 @@ public class FragmentOptionsNotifications extends FragmentBase implements Shared
public void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
if (requestCode == ActivitySetup.REQUEST_SOUND)
if (resultCode == RESULT_OK) {
Uri uri = data.getParcelableExtra(RingtoneManager.EXTRA_RINGTONE_PICKED_URI);
Log.i("Selected ringtone=" + uri);
if (uri != null && "file".equals(uri.getScheme()))
uri = null;
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getContext());
if (uri == null)
prefs.edit().remove("sound").apply();
else
prefs.edit().putString("sound", uri.toString()).apply();
try {
switch (requestCode) {
case ActivitySetup.REQUEST_SOUND:
if (resultCode == RESULT_OK && data != null)
onSelectSound((Uri) data.getParcelableExtra(RingtoneManager.EXTRA_RINGTONE_PICKED_URI));
break;
}
} catch (Throwable ex) {
Log.e(ex);
}
}
private void onSelectSound(Uri uri) {
Log.i("Selected ringtone=" + uri);
if (uri != null && "file".equals(uri.getScheme()))
uri = null;
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getContext());
if (uri == null)
prefs.edit().remove("sound").apply();
else
prefs.edit().putString("sound", uri.toString()).apply();
}
private static Intent getIntentNotifications(Context context) {

@ -441,10 +441,14 @@ public class FragmentQuickSetup extends FragmentBase {
public void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) {
super.onActivityResult(requestCode, resultCode, data);
switch (requestCode) {
case REQUEST_DONE:
finish();
break;
try {
switch (requestCode) {
case REQUEST_DONE:
finish();
break;
}
} catch (Throwable ex) {
Log.e(ex);
}
}

@ -417,31 +417,35 @@ public class FragmentRule extends FragmentBase {
public void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
switch (requestCode) {
case REQUEST_SENDER:
if (resultCode == RESULT_OK && data != null)
onPickContact(data, true);
break;
case REQUEST_RECIPIENT:
if (resultCode == RESULT_OK && data != null)
onPickContact(data, true);
break;
case REQUEST_COLOR:
if (resultCode == RESULT_OK && data != null) {
if (!Helper.isPro(getContext())) {
LocalBroadcastManager lbm = LocalBroadcastManager.getInstance(getContext());
lbm.sendBroadcast(new Intent(ActivityView.ACTION_SHOW_PRO));
return;
}
try {
switch (requestCode) {
case REQUEST_SENDER:
if (resultCode == RESULT_OK && data != null)
onPickContact(data, true);
break;
case REQUEST_RECIPIENT:
if (resultCode == RESULT_OK && data != null)
onPickContact(data, true);
break;
case REQUEST_COLOR:
if (resultCode == RESULT_OK && data != null) {
if (!Helper.isPro(getContext())) {
LocalBroadcastManager lbm = LocalBroadcastManager.getInstance(getContext());
lbm.sendBroadcast(new Intent(ActivityView.ACTION_SHOW_PRO));
return;
}
Bundle args = data.getBundleExtra("args");
onSelectColor(args.getInt("color"));
}
break;
case REQUEST_DELETE:
if (resultCode == RESULT_OK)
onDelete();
break;
Bundle args = data.getBundleExtra("args");
onSelectColor(args.getInt("color"));
}
break;
case REQUEST_DELETE:
if (resultCode == RESULT_OK)
onDelete();
break;
}
} catch (Throwable ex) {
Log.e(ex);
}
}

Loading…
Cancel
Save