mirror of
https://gitlab.linphone.org/BC/public/linphone-android.git
synced 2026-01-18 03:48:08 +00:00
Add avatar in notif
This commit is contained in:
parent
ca09f4971b
commit
6b8bc034c1
2 changed files with 36 additions and 16 deletions
|
|
@ -33,11 +33,13 @@ import org.linphone.contacts.LinphoneContact;
|
|||
import org.linphone.core.Address;
|
||||
import org.linphone.core.Call;
|
||||
import org.linphone.core.Call.State;
|
||||
import org.linphone.core.ChatRoomSecurityLevel;
|
||||
import org.linphone.core.Core;
|
||||
import org.linphone.core.GlobalState;
|
||||
import org.linphone.core.LogLevel;
|
||||
import org.linphone.core.LoggingService;
|
||||
import org.linphone.core.LoggingServiceListener;
|
||||
import org.linphone.core.PresenceModel;
|
||||
import org.linphone.core.RegistrationState;
|
||||
import org.linphone.core.Factory;
|
||||
import org.linphone.core.LogCollectionState;
|
||||
|
|
@ -73,6 +75,9 @@ import android.provider.MediaStore;
|
|||
import android.util.ArrayMap;
|
||||
import android.view.WindowManager;
|
||||
|
||||
import static org.linphone.LinphoneUtils.getSecurityLevelForChatRoom;
|
||||
import static org.linphone.LinphoneUtils.getSecurityLevelForSipUri;
|
||||
|
||||
/**
|
||||
* Linphone service, reacting to Incoming calls, ...<br />
|
||||
*
|
||||
|
|
@ -639,16 +644,18 @@ public final class LinphoneService extends Service {
|
|||
mChatNotifMap.put(conferenceAddress, notif);
|
||||
}
|
||||
|
||||
Bitmap bm = null;
|
||||
if (fromPictureUri != null) {
|
||||
try {
|
||||
bm = MediaStore.Images.Media.getBitmap(getContentResolver(), fromPictureUri);
|
||||
} catch (Exception e) {
|
||||
bm = BitmapFactory.decodeResource(getResources(), R.drawable.avatar_group_small_secure1);
|
||||
}
|
||||
} else {
|
||||
Bitmap bm;
|
||||
ChatRoomSecurityLevel securityLevel = getSecurityLevelForChatRoom(LinphoneManager.getLc(), conferenceAddress);
|
||||
if (securityLevel == ChatRoomSecurityLevel.Safe) {
|
||||
bm = BitmapFactory.decodeResource(getResources(), R.drawable.avatar_group_small_secure2);
|
||||
} else if (securityLevel == ChatRoomSecurityLevel.Unsafe) {
|
||||
bm = BitmapFactory.decodeResource(getResources(), R.drawable.avatar_group_small_unsecure);
|
||||
} else if (securityLevel == ChatRoomSecurityLevel.Encrypted) {
|
||||
bm = BitmapFactory.decodeResource(getResources(), R.drawable.avatar_group_small_secure1);
|
||||
} else {
|
||||
bm = BitmapFactory.decodeResource(getResources(), R.drawable.avatar_group_small_unregistered);
|
||||
}
|
||||
|
||||
Notification notification = Compatibility.createMessageNotification(getApplicationContext(), notif.numberOfUnreadMessage, subject,
|
||||
getString(R.string.group_chat_notif).replace("%1", fromName).replace("%2", message), bm, notifContentIntent);
|
||||
|
||||
|
|
@ -677,15 +684,16 @@ public final class LinphoneService extends Service {
|
|||
mChatNotifMap.put(fromSipUri, notif);
|
||||
}
|
||||
|
||||
Bitmap bm = null;
|
||||
if (fromPictureUri != null) {
|
||||
try {
|
||||
bm = MediaStore.Images.Media.getBitmap(getContentResolver(), fromPictureUri);
|
||||
} catch (Exception e) {
|
||||
bm = BitmapFactory.decodeResource(getResources(), R.drawable.avatar_small_secure1);
|
||||
}
|
||||
} else {
|
||||
Bitmap bm;
|
||||
ChatRoomSecurityLevel securityLevel = getSecurityLevelForChatRoom(LinphoneManager.getLc(), fromSipUri);
|
||||
if (securityLevel == ChatRoomSecurityLevel.Safe) {
|
||||
bm = BitmapFactory.decodeResource(getResources(), R.drawable.avatar_small_secure2);
|
||||
} else if (securityLevel == ChatRoomSecurityLevel.Unsafe) {
|
||||
bm = BitmapFactory.decodeResource(getResources(), R.drawable.avatar_small_unsecure);
|
||||
} else if (securityLevel == ChatRoomSecurityLevel.Encrypted) {
|
||||
bm = BitmapFactory.decodeResource(getResources(), R.drawable.avatar_small_secure1);
|
||||
} else {
|
||||
bm = BitmapFactory.decodeResource(getResources(), R.drawable.avatar_small_unregistered);
|
||||
}
|
||||
Notification notification = Compatibility.createMessageNotification(getApplicationContext(), notif.numberOfUnreadMessage, fromName, message, bm, notifContentIntent);
|
||||
|
||||
|
|
|
|||
|
|
@ -809,6 +809,18 @@ public final class LinphoneUtils {
|
|||
return ChatRoomSecurityLevel.ClearText;
|
||||
}
|
||||
|
||||
public static ChatRoomSecurityLevel getSecurityLevelForChatRoom(Core lc, String chatUri) {
|
||||
if (chatUri == null) return ChatRoomSecurityLevel.ClearText;
|
||||
|
||||
for (ChatRoom cr : lc.getChatRooms()) {
|
||||
if (cr != null && cr.getConferenceAddress().asStringUriOnly().equalsIgnoreCase(chatUri)) {
|
||||
return cr.getSecurityLevel();
|
||||
}
|
||||
}
|
||||
|
||||
return ChatRoomSecurityLevel.ClearText;
|
||||
}
|
||||
|
||||
public static boolean hasContentFileSharing(Content[] contents) {
|
||||
if (contents == null) return false;
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue