Prevents crash + added logs

This commit is contained in:
Sylvain Berfini 2019-12-03 14:25:18 +01:00
parent 82ced1a397
commit 8268b01c99

View file

@ -156,6 +156,7 @@ public class ContactEditorFragment extends Fragment {
true); true);
if (mPhotoToAdd != null) { if (mPhotoToAdd != null) {
Log.i("[Contact Editor] Found picture to set to contact");
mContact.setPhoto(mPhotoToAdd); mContact.setPhoto(mPhotoToAdd);
} }
@ -165,25 +166,26 @@ public class ContactEditorFragment extends Fragment {
if (value == null || value.trim().isEmpty()) { if (value == null || value.trim().isEmpty()) {
if (oldValue != null && !oldValue.isEmpty()) { if (oldValue != null && !oldValue.isEmpty()) {
Log.i("[Contact Editor] Removing number " + oldValue); Log.i("[Contact Editor] Removing number: ", oldValue);
mContact.removeNumberOrAddress(noa); mContact.removeNumberOrAddress(noa);
} }
} else { } else {
if (oldValue != null && oldValue.equals(value)) { if (oldValue != null && oldValue.equals(value)) {
Log.i("[Contact Editor] Keeping existing number " + value); Log.i("[Contact Editor] Keeping existing number: ", value);
continue; continue;
} }
if (noa.isSIPAddress()) { if (noa.isSIPAddress()) {
noa.setValue(LinphoneUtils.getFullAddressFromUsername(value)); noa.setValue(LinphoneUtils.getFullAddressFromUsername(value));
} }
Log.i("[Contact Editor] Adding new number " + value); Log.i("[Contact Editor] Adding new number: ", value);
mContact.addOrUpdateNumberOrAddress(noa); mContact.addOrUpdateNumberOrAddress(noa);
} }
} }
if (!mOrganization.getText().toString().isEmpty() || !mIsNewContact) { if (!mOrganization.getText().toString().isEmpty() || !mIsNewContact) {
Log.i("[Contact Editor] Setting organization field: ", mOrganization);
mContact.setOrganization(mOrganization.getText().toString(), true); mContact.setOrganization(mOrganization.getText().toString(), true);
} }
@ -193,6 +195,8 @@ public class ContactEditorFragment extends Fragment {
// Ensure fetch will be done so the new contact appears in the contacts // Ensure fetch will be done so the new contact appears in the contacts
// list: contacts content observer may not be notified if contacts sync // list: contacts content observer may not be notified if contacts sync
// is disabled at system level // is disabled at system level
Log.i(
"[Contact Editor] New contact created, starting fetch contacts task");
ContactsManager.getInstance().fetchContactsAsync(); ContactsManager.getInstance().fetchContactsAsync();
} }
@ -466,8 +470,21 @@ public class ContactEditorFragment extends Fragment {
private void editContactPicture(String filePath, Bitmap image) { private void editContactPicture(String filePath, Bitmap image) {
if (image == null) { if (image == null) {
Log.i(
"[Contact Editor] Bitmap is null, trying to decode image from file [",
filePath,
"]");
image = BitmapFactory.decodeFile(filePath); image = BitmapFactory.decodeFile(filePath);
} }
if (image == null) {
Log.e(
"[Contact Editor] Couldn't get bitmap from either filePath [",
filePath,
"] nor image [",
image,
"]");
return;
}
ByteArrayOutputStream stream = new ByteArrayOutputStream(); ByteArrayOutputStream stream = new ByteArrayOutputStream();
image.compress(Bitmap.CompressFormat.JPEG, 100, stream); image.compress(Bitmap.CompressFormat.JPEG, 100, stream);