Prevent crash

pull/201/head
M66B 3 years ago
parent 5d0c651a9a
commit d561cd7d7a

@ -1480,7 +1480,7 @@ public class FragmentCompose extends FragmentBase {
}); });
menu.findItem(R.id.menu_translate).setActionView(R.layout.action_button); menu.findItem(R.id.menu_translate).setActionView(R.layout.action_button);
ImageButton ibTranslate = (ImageButton)menu.findItem(R.id.menu_translate).getActionView(); ImageButton ibTranslate = (ImageButton) menu.findItem(R.id.menu_translate).getActionView();
ibTranslate.setImageResource(R.drawable.twotone_translate_24); ibTranslate.setImageResource(R.drawable.twotone_translate_24);
ibTranslate.setOnClickListener(new View.OnClickListener() { ibTranslate.setOnClickListener(new View.OnClickListener() {
@Override @Override
@ -1490,7 +1490,7 @@ public class FragmentCompose extends FragmentBase {
}); });
menu.findItem(R.id.menu_zoom).setActionView(R.layout.action_button); menu.findItem(R.id.menu_zoom).setActionView(R.layout.action_button);
ImageButton ibZoom = (ImageButton)menu.findItem(R.id.menu_zoom).getActionView(); ImageButton ibZoom = (ImageButton) menu.findItem(R.id.menu_zoom).getActionView();
ibZoom.setImageResource(R.drawable.twotone_format_size_24); ibZoom.setImageResource(R.drawable.twotone_format_size_24);
ibZoom.setOnClickListener(new View.OnClickListener() { ibZoom.setOnClickListener(new View.OnClickListener() {
@Override @Override
@ -2524,42 +2524,44 @@ public class FragmentCompose extends FragmentBase {
if (cursor != null && cursor.moveToFirst()) { if (cursor != null && cursor.moveToFirst()) {
int colEmail = cursor.getColumnIndex(ContactsContract.CommonDataKinds.Email.ADDRESS); int colEmail = cursor.getColumnIndex(ContactsContract.CommonDataKinds.Email.ADDRESS);
int colName = cursor.getColumnIndex(ContactsContract.Contacts.DISPLAY_NAME); int colName = cursor.getColumnIndex(ContactsContract.Contacts.DISPLAY_NAME);
String email = MessageHelper.sanitizeEmail(cursor.getString(colEmail)); if (colEmail >= 0 && colName >= 0) {
String name = cursor.getString(colName); String email = MessageHelper.sanitizeEmail(cursor.getString(colEmail));
String name = cursor.getString(colName);
try { try {
db.beginTransaction(); db.beginTransaction();
draft = db.message().getMessage(id); draft = db.message().getMessage(id);
if (draft == null) if (draft == null)
return null; return null;
Address[] address = null; Address[] address = null;
if (requestCode == REQUEST_CONTACT_TO) if (requestCode == REQUEST_CONTACT_TO)
address = draft.to; address = draft.to;
else if (requestCode == REQUEST_CONTACT_CC) else if (requestCode == REQUEST_CONTACT_CC)
address = draft.cc; address = draft.cc;
else if (requestCode == REQUEST_CONTACT_BCC) else if (requestCode == REQUEST_CONTACT_BCC)
address = draft.bcc; address = draft.bcc;
List<Address> list = new ArrayList<>(); List<Address> list = new ArrayList<>();
if (address != null) if (address != null)
list.addAll(Arrays.asList(address)); list.addAll(Arrays.asList(address));
list.add(new InternetAddress(email, suggest_names ? name : null, StandardCharsets.UTF_8.name())); list.add(new InternetAddress(email, suggest_names ? name : null, StandardCharsets.UTF_8.name()));
if (requestCode == REQUEST_CONTACT_TO) if (requestCode == REQUEST_CONTACT_TO)
draft.to = list.toArray(new Address[0]); draft.to = list.toArray(new Address[0]);
else if (requestCode == REQUEST_CONTACT_CC) else if (requestCode == REQUEST_CONTACT_CC)
draft.cc = list.toArray(new Address[0]); draft.cc = list.toArray(new Address[0]);
else if (requestCode == REQUEST_CONTACT_BCC) else if (requestCode == REQUEST_CONTACT_BCC)
draft.bcc = list.toArray(new Address[0]); draft.bcc = list.toArray(new Address[0]);
db.message().updateMessage(draft); db.message().updateMessage(draft);
db.setTransactionSuccessful(); db.setTransactionSuccessful();
} finally { } finally {
db.endTransaction(); db.endTransaction();
}
} }
} }
} }

Loading…
Cancel
Save