Prevent crash if icon is null

This commit is contained in:
Sylvain Berfini 2019-05-27 17:29:48 +02:00
parent cf0f88e71e
commit 11b223c0dc
3 changed files with 19 additions and 7 deletions

View file

@ -42,9 +42,17 @@ class ApiTwentyEightPlus {
Person me = new Person.Builder().setName(notif.getMyself()).build(); Person me = new Person.Builder().setName(notif.getMyself()).build();
Notification.MessagingStyle style = new Notification.MessagingStyle(me); Notification.MessagingStyle style = new Notification.MessagingStyle(me);
for (NotifiableMessage message : notif.getMessages()) { for (NotifiableMessage message : notif.getMessages()) {
Icon userIcon = Icon.createWithBitmap(message.getSenderBitmap()); Icon userIcon = null;
Person user = if (message.getSenderBitmap() != null) {
new Person.Builder().setName(message.getSender()).setIcon(userIcon).build(); userIcon = Icon.createWithBitmap(message.getSenderBitmap());
}
Person.Builder builder = new Person.Builder().setName(message.getSender());
if (userIcon != null) {
builder.setIcon(userIcon);
}
Person user = builder.build();
Notification.MessagingStyle.Message msg = Notification.MessagingStyle.Message msg =
new Notification.MessagingStyle.Message( new Notification.MessagingStyle.Message(
message.getMessage(), message.getTime(), user); message.getMessage(), message.getTime(), user);

View file

@ -2,7 +2,7 @@ package org.linphone.contacts;
/* /*
ContactsManager.java ContactsManager.java
Copyright (C) 2017 Belledonne Communications, Grenoble, France Copyright (C) 2017 Belledonne Communications, Grenoble, France
This program is free software; you can redistribute it and/or This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License modify it under the terms of the GNU General Public License
@ -370,7 +370,11 @@ public class ContactsManager extends ContentObserver implements FriendListListen
String normalized = lpc.normalizePhoneNumber(phoneNumber); String normalized = lpc.normalizePhoneNumber(phoneNumber);
if (normalized == null) { if (normalized == null) {
Log.w("[Contacts Manager] Couldn't normalize phone number " + phoneNumber + ", default proxy config prefix is " + lpc.getDialPrefix()); Log.w(
"[Contacts Manager] Couldn't normalize phone number "
+ phoneNumber
+ ", default proxy config prefix is "
+ lpc.getDialPrefix());
normalized = phoneNumber; normalized = phoneNumber;
} }

View file

@ -106,7 +106,7 @@ public class ConfigureAccountActivity extends Activity {
} }
// This will automatically create the proxy config and auth info and add them to the Core // This will automatically create the proxy config and auth info and add them to the Core
ProxyConfig cfg = mAccountCreator.configure(); ProxyConfig cfg = mAccountCreator.createProxyConfig();
// Make sure the newly created one is the default // Make sure the newly created one is the default
LinphoneService.getCore().setDefaultProxyConfig(cfg); LinphoneService.getCore().setDefaultProxyConfig(cfg);
} }