Fixed warnings

This commit is contained in:
Sylvain Berfini 2021-01-27 10:59:41 +01:00
parent 947c6faa53
commit f028e26e82
6 changed files with 21 additions and 15 deletions

View file

@ -240,7 +240,7 @@ class ChatRoomViewModel(val chatRoom: ChatRoom) : ViewModel(), ContactViewModelI
var body = "" var body = ""
for (content in msg.contents) { for (content in msg.contents) {
if (content.isFile || content.isFileTransfer) body += content.name + " " if (content.isFile || content.isFileTransfer) body += content.name + " "
else if (content.isText) body += content.stringBuffer + " " else if (content.isText) body += content.utf8Text + " "
} }
return "$sender: $body" return "$sender: $body"

View file

@ -71,7 +71,7 @@ class GroupInfoViewModel(val chatRoom: ChatRoom?) : ErrorReportingViewModel() {
} }
override fun onSubjectChanged(chatRoom: ChatRoom, eventLog: EventLog) { override fun onSubjectChanged(chatRoom: ChatRoom, eventLog: EventLog) {
subject.value = chatRoom?.subject subject.value = chatRoom.subject
} }
override fun onParticipantAdded(chatRoom: ChatRoom, eventLog: EventLog) { override fun onParticipantAdded(chatRoom: ChatRoom, eventLog: EventLog) {
@ -83,7 +83,7 @@ class GroupInfoViewModel(val chatRoom: ChatRoom?) : ErrorReportingViewModel() {
} }
override fun onParticipantAdminStatusChanged(chatRoom: ChatRoom, eventLog: EventLog) { override fun onParticipantAdminStatusChanged(chatRoom: ChatRoom, eventLog: EventLog) {
val admin = chatRoom?.me?.isAdmin ?: false val admin = chatRoom.me?.isAdmin ?: false
isMeAdmin.value = admin isMeAdmin.value = admin
meAdminChangedEvent.value = Event(admin) meAdminChangedEvent.value = Event(admin)
updateParticipants() updateParticipants()

View file

@ -51,10 +51,10 @@ open class StatusViewModel : ViewModel() {
body: Content body: Content
) { ) {
if (body.type == "application" && body.subtype == "simple-message-summary" && body.size > 0) { if (body.type == "application" && body.subtype == "simple-message-summary" && body.size > 0) {
val data = body.stringBuffer.toLowerCase(Locale.getDefault()) val data = body.utf8Text?.toLowerCase(Locale.getDefault())
val voiceMail = data.split("voice-message: ") val voiceMail = data?.split("voice-message: ")
if (voiceMail.size >= 2) { if (voiceMail?.size ?: 0 >= 2) {
val toParse = voiceMail[1].split("/", limit = 0) val toParse = voiceMail!![1].split("/", limit = 0)
try { try {
val unreadCount: Int = toParse[0].toInt() val unreadCount: Int = toParse[0].toInt()
voiceMailCount.value = unreadCount voiceMailCount.value = unreadCount

View file

@ -341,8 +341,11 @@ class CoreContext(val context: Context, coreConfig: Config) {
fun declineCall(call: Call) { fun declineCall(call: Call) {
val voiceMailUri = corePreferences.voiceMailUri val voiceMailUri = corePreferences.voiceMailUri
if (voiceMailUri != null && corePreferences.redirectDeclinedCallToVoiceMail) { if (voiceMailUri != null && corePreferences.redirectDeclinedCallToVoiceMail) {
Log.i("[Context] Redirecting call $call to voice mail") val voiceMailAddress = core.interpretUrl(voiceMailUri)
call.redirect(voiceMailUri) if (voiceMailAddress != null) {
Log.i("[Context] Redirecting call $call to voice mail URI: $voiceMailUri")
call.redirectTo(voiceMailAddress)
}
} else { } else {
Log.i("[Context] Declining call $call") Log.i("[Context] Declining call $call")
call.decline(Reason.Declined) call.decline(Reason.Declined)
@ -359,8 +362,11 @@ class CoreContext(val context: Context, coreConfig: Config) {
if (currentCall == null) { if (currentCall == null) {
Log.e("[Context] Couldn't find a call to transfer") Log.e("[Context] Couldn't find a call to transfer")
} else { } else {
Log.i("[Context] Transferring current call to $addressToCall") val address = core.interpretUrl(addressToCall)
currentCall.transfer(addressToCall) if (address != null) {
Log.i("[Context] Transferring current call to $addressToCall")
currentCall.transferTo(address)
}
} }
} }

View file

@ -79,7 +79,7 @@ class NotificationBroadcastReceiver : BroadcastReceiver() {
return return
} }
val msg = room.createMessage(reply) val msg = room.createMessageFromUtf8(reply)
msg.userData = notificationId msg.userData = notificationId
msg.addListener(coreContext.notificationsManager.chatListener) msg.addListener(coreContext.notificationsManager.chatListener)
msg.send() msg.send()
@ -90,10 +90,11 @@ class NotificationBroadcastReceiver : BroadcastReceiver() {
} }
private fun handleCallIntent(intent: Intent, notificationId: Int) { private fun handleCallIntent(intent: Intent, notificationId: Int) {
val remoteAddress: String? = coreContext.notificationsManager.getSipUriForCallNotificationId(notificationId) val remote: String = coreContext.notificationsManager.getSipUriForCallNotificationId(notificationId) ?: ""
val core: Core = coreContext.core val core: Core = coreContext.core
val call = if (remoteAddress != null) core.findCallFromUri(remoteAddress) else null val remoteAddress = core.interpretUrl(remote)
val call = if (remoteAddress != null) core.getCallByRemoteAddress2(remoteAddress) else null
if (call == null) { if (call == null) {
Log.e("[Notification Broadcast Receiver] Couldn't find call from remote address $remoteAddress") Log.e("[Notification Broadcast Receiver] Couldn't find call from remote address $remoteAddress")
return return

View file

@ -116,7 +116,6 @@ class NotificationsManager(private val context: Context) {
state: Call.State, state: Call.State,
message: String message: String
) { ) {
if (call == null) return
Log.i("[Notifications Manager] Call state changed [$state]") Log.i("[Notifications Manager] Call state changed [$state]")
when (state) { when (state) {