Improved toast API

This commit is contained in:
Sylvain Berfini 2025-02-04 13:53:49 +01:00
parent 536667cfe1
commit 74394445c9
24 changed files with 70 additions and 355 deletions

View file

@ -19,6 +19,8 @@
*/
package org.linphone.ui
import androidx.annotation.DrawableRes
import androidx.annotation.StringRes
import androidx.lifecycle.MutableLiveData
import androidx.lifecycle.ViewModel
import org.linphone.utils.Event
@ -41,4 +43,20 @@ open class GenericViewModel : ViewModel() {
val showFormattedRedToastEvent: MutableLiveData<Event<Pair<String, Int>>> by lazy {
MutableLiveData<Event<Pair<String, Int>>>()
}
fun showGreenToast(@StringRes message: Int, @DrawableRes icon: Int) {
showGreenToastEvent.postValue(Event(Pair(message, icon)))
}
fun showFormattedGreenToast(message: String, @DrawableRes icon: Int) {
showFormattedGreenToastEvent.postValue(Event(Pair(message, icon)))
}
fun showRedToast(@StringRes message: Int, @DrawableRes icon: Int) {
showRedToastEvent.postValue(Event(Pair(message, icon)))
}
fun showFormattedRedToast(message: String, @DrawableRes icon: Int) {
showFormattedRedToastEvent.postValue(Event(Pair(message, icon)))
}
}

View file

@ -168,14 +168,7 @@ class AccountCreationViewModel
operationInProgress.postValue(false)
if (!errorMessage.isNullOrEmpty()) {
showFormattedRedToastEvent.postValue(
Event(
Pair(
errorMessage,
R.drawable.warning_circle
)
)
)
showFormattedRedToast(errorMessage, R.drawable.warning_circle)
}
for (parameter in parameterErrors?.keys.orEmpty()) {

View file

@ -175,14 +175,7 @@ open class AccountLoginViewModel
val identityAddress = Factory.instance().createAddress(identity)
if (identityAddress == null) {
Log.e("$TAG Can't parse [$identity] as Address!")
showRedToastEvent.postValue(
Event(
Pair(
R.string.assistant_login_cant_parse_address_toast,
R.drawable.warning_circle
)
)
)
showRedToast(R.string.assistant_login_cant_parse_address_toast, R.drawable.warning_circle)
return@postOnCoreThread
}
@ -191,14 +184,7 @@ open class AccountLoginViewModel
Log.e(
"$TAG Address [${identityAddress.asStringUriOnly()}] doesn't contains an username!"
)
showRedToastEvent.postValue(
Event(
Pair(
R.string.assistant_login_address_without_username_toast,
R.drawable.warning_circle
)
)
)
showRedToast(R.string.assistant_login_address_without_username_toast, R.drawable.warning_circle)
return@postOnCoreThread
}

View file

@ -199,14 +199,7 @@ class ThirdPartySipAccountLoginViewModel
val identityAddress = Factory.instance().createAddress(identity)
if (identityAddress == null) {
Log.e("$TAG Can't parse [$identity] as Address!")
showRedToastEvent.postValue(
Event(
Pair(
R.string.assistant_login_cant_parse_address_toast,
R.drawable.warning_circle
)
)
)
showRedToast(R.string.assistant_login_cant_parse_address_toast, R.drawable.warning_circle)
return@postOnCoreThread
}

View file

@ -410,14 +410,7 @@ class ConferenceViewModel
Log.e(
"$TAG Failed to parse SIP URI [$uri] into address, can't add it to the conference!"
)
showRedToastEvent.postValue(
Event(
Pair(
R.string.conference_failed_to_add_participant_invalid_address_toast,
R.drawable.warning_circle
)
)
)
showRedToast(R.string.conference_failed_to_add_participant_invalid_address_toast, R.drawable.warning_circle)
}
}
val addressesArray = arrayOfNulls<Address>(addresses.size)
@ -810,14 +803,7 @@ class ConferenceViewModel
"$TAG Too many participant devices for grid layout, switching to active speaker layout"
)
setNewLayout(ACTIVE_SPEAKER_LAYOUT)
showRedToastEvent.postValue(
Event(
Pair(
R.string.conference_too_many_participants_for_mosaic_layout_toast,
R.drawable.warning_circle
)
)
)
showRedToast(R.string.conference_too_many_participants_for_mosaic_layout_toast, R.drawable.warning_circle)
}
}
}

View file

@ -231,14 +231,7 @@ class CallsViewModel
val conference = LinphoneUtils.createGroupCall(defaultAccount, subject)
if (conference == null) {
Log.e("$TAG Failed to create conference!")
showRedToastEvent.postValue(
Event(
Pair(
R.string.conference_failed_to_merge_calls_into_conference_toast,
R.drawable.warning_circle
)
)
)
showRedToast(R.string.conference_failed_to_merge_calls_into_conference_toast, R.drawable.warning_circle)
} else {
conference.addParticipants(core.calls)
}

View file

@ -1486,13 +1486,6 @@ class CurrentCallViewModel
@AnyThread
private fun showRecordingToast() {
showGreenToastEvent.postValue(
Event(
Pair(
R.string.call_is_being_recorded,
R.drawable.record_fill
)
)
)
showGreenToast(R.string.call_is_being_recorded, R.drawable.record_fill)
}
}

View file

@ -239,24 +239,10 @@ class FileViewModel
Log.i(
"$TAG File [$filePath] has been successfully exported to documents"
)
showGreenToastEvent.postValue(
Event(
Pair(
R.string.file_successfully_exported_to_documents_toast,
R.drawable.check
)
)
)
showGreenToast(R.string.file_successfully_exported_to_documents_toast, R.drawable.check)
} else {
Log.e("$TAG Failed to export file [$filePath] to documents!")
showRedToastEvent.postValue(
Event(
Pair(
R.string.export_file_to_documents_error_toast,
R.drawable.warning_circle
)
)
)
showRedToast(R.string.export_file_to_documents_error_toast, R.drawable.warning_circle)
}
}
}
@ -272,24 +258,13 @@ class FileViewModel
Log.i(
"$TAG Text has been successfully exported to documents"
)
showGreenToastEvent.postValue(
Event(
Pair(
showGreenToast(
R.string.file_successfully_exported_to_documents_toast,
R.drawable.check
)
)
)
} else {
Log.e("$TAG Failed to save text to documents!")
showRedToastEvent.postValue(
Event(
Pair(
R.string.export_file_to_documents_error_toast,
R.drawable.warning_circle
)
)
)
showRedToast(R.string.export_file_to_documents_error_toast, R.drawable.warning_circle)
}
}
}
@ -337,14 +312,7 @@ class FileViewModel
// TODO FIXME : improve performances !
} catch (e: Exception) {
Log.e("$TAG Exception trying to read file [$filePath] as text: $e")
showRedToastEvent.postValue(
Event(
Pair(
R.string.conversation_file_cant_be_opened_error_toast,
R.drawable.warning_circle
)
)
)
showRedToast(R.string.conversation_file_cant_be_opened_error_toast, R.drawable.warning_circle)
}
}
}

View file

@ -38,7 +38,6 @@ import org.linphone.ui.main.contacts.model.ContactNumberOrAddressModel
import org.linphone.ui.main.contacts.model.NumberOrAddressPickerDialogModel
import org.linphone.ui.main.fragment.SlidingPaneChildFragment
import org.linphone.utils.DialogUtils
import org.linphone.utils.Event
import org.linphone.utils.RecyclerViewHeaderDecoration
@UiThread
@ -66,11 +65,7 @@ class ConversationForwardMessageFragment : SlidingPaneChildFragment() {
override fun goBack(): Boolean {
sharedViewModel.messageToForwardEvent.value?.consume {
Log.w("$TAG Cancelling message forward")
viewModel.showRedToastEvent.postValue(
Event(
Pair(R.string.conversation_message_forward_cancelled_toast, R.drawable.forward)
)
)
viewModel.showRedToast(R.string.conversation_message_forward_cancelled_toast, R.drawable.forward)
}
return findNavController().popBackStack()

View file

@ -173,14 +173,7 @@ abstract class AbstractConversationViewModel : GenericViewModel() {
val conference = LinphoneUtils.createGroupCall(account, chatRoom.subject.orEmpty())
if (conference == null) {
Log.e("$TAG Failed to create group call!")
showRedToastEvent.postValue(
Event(
Pair(
R.string.conference_failed_to_create_group_call_toast,
R.drawable.warning_circle
)
)
)
showRedToast(R.string.conference_failed_to_create_group_call_toast, R.drawable.warning_circle)
return@postOnCoreThread
}
@ -199,14 +192,7 @@ abstract class AbstractConversationViewModel : GenericViewModel() {
)
if (conference.inviteParticipants(participants, callParams) != 0) {
Log.e("$TAG Failed to invite participants into group call!")
showRedToastEvent.postValue(
Event(
Pair(
R.string.conference_failed_to_create_group_call_toast,
R.drawable.warning_circle
)
)
)
showRedToast(R.string.conference_failed_to_create_group_call_toast, R.drawable.warning_circle)
}
}
}

View file

@ -102,14 +102,7 @@ class ConversationForwardMessageViewModel
Log.e("$TAG Conversation [$id] creation has failed!")
chatRoom.removeListener(this)
operationInProgress.postValue(false)
showRedToastEvent.postValue(
Event(
Pair(
R.string.conversation_failed_to_create_toast,
R.drawable.warning_circle
)
)
)
showRedToast(R.string.conversation_failed_to_create_toast, R.drawable.warning_circle)
}
}
}
@ -222,14 +215,7 @@ class ConversationForwardMessageViewModel
"$TAG Account is in secure mode, can't chat with SIP address of different domain [${remote.asStringUriOnly()}]"
)
operationInProgress.postValue(false)
showRedToastEvent.postValue(
Event(
Pair(
R.string.conversation_invalid_participant_due_to_security_mode_toast,
R.drawable.warning_circle
)
)
)
showRedToast(R.string.conversation_invalid_participant_due_to_security_mode_toast, R.drawable.warning_circle)
return
}
@ -275,14 +261,7 @@ class ConversationForwardMessageViewModel
} else {
Log.e("$TAG Failed to create 1-1 conversation with [${remote.asStringUriOnly()}]!")
operationInProgress.postValue(false)
showRedToastEvent.postValue(
Event(
Pair(
R.string.conversation_failed_to_create_toast,
R.drawable.warning_circle
)
)
)
showRedToast(R.string.conversation_failed_to_create_toast, R.drawable.warning_circle)
}
} else {
Log.w(

View file

@ -108,7 +108,7 @@ class ConversationInfoViewModel
R.string.conversation_info_participant_added_to_conversation_toast,
getParticipant(eventLog)
)
showFormattedGreenToastEvent.postValue(Event(Pair(message, R.drawable.user_circle)))
showFormattedGreenToast(message, R.drawable.user_circle)
computeParticipantsList()
infoChangedEvent.postValue(Event(true))
@ -121,7 +121,7 @@ class ConversationInfoViewModel
R.string.conversation_info_participant_removed_from_conversation_toast,
getParticipant(eventLog)
)
showFormattedGreenToastEvent.postValue(Event(Pair(message, R.drawable.user_circle)))
showFormattedGreenToast(message, R.drawable.user_circle)
computeParticipantsList()
infoChangedEvent.postValue(Event(true))
@ -143,7 +143,7 @@ class ConversationInfoViewModel
getParticipant(eventLog)
)
}
showFormattedGreenToastEvent.postValue(Event(Pair(message, R.drawable.user_circle)))
showFormattedGreenToast(message, R.drawable.user_circle)
computeParticipantsList()
}
@ -153,9 +153,7 @@ class ConversationInfoViewModel
Log.i(
"$TAG Conversation [${LinphoneUtils.getChatRoomId(chatRoom)}] has a new subject [${chatRoom.subject}]"
)
showGreenToastEvent.postValue(
Event(Pair(R.string.conversation_subject_changed_toast, R.drawable.check))
)
showGreenToast(R.string.conversation_subject_changed_toast, R.drawable.check)
subject.postValue(chatRoom.subject)
infoChangedEvent.postValue(Event(true))
@ -166,34 +164,13 @@ class ConversationInfoViewModel
Log.i("$TAG Ephemeral event [${eventLog.type}]")
when (eventLog.type) {
EventLog.Type.ConferenceEphemeralMessageEnabled -> {
showGreenToastEvent.postValue(
Event(
Pair(
R.string.conversation_ephemeral_messages_enabled_toast,
R.drawable.clock_countdown
)
)
)
showGreenToast(R.string.conversation_ephemeral_messages_enabled_toast, R.drawable.clock_countdown)
}
EventLog.Type.ConferenceEphemeralMessageDisabled -> {
showGreenToastEvent.postValue(
Event(
Pair(
R.string.conversation_ephemeral_messages_disabled_toast,
R.drawable.clock_countdown
)
)
)
showGreenToast(R.string.conversation_ephemeral_messages_disabled_toast, R.drawable.clock_countdown)
}
else -> {
showGreenToastEvent.postValue(
Event(
Pair(
R.string.conversation_ephemeral_messages_lifetime_changed_toast,
R.drawable.clock_countdown
)
)
)
showGreenToast(R.string.conversation_ephemeral_messages_lifetime_changed_toast, R.drawable.clock_countdown)
}
}
}
@ -431,14 +408,7 @@ class ConversationInfoViewModel
val ok = chatRoom.addParticipants(toAddList.toTypedArray())
if (!ok) {
Log.w("$TAG Failed to add some/all participants to the group!")
showRedToastEvent.postValue(
Event(
Pair(
R.string.conversation_failed_to_add_participant_to_group_conversation_toast,
R.drawable.warning_circle
)
)
)
showRedToast(R.string.conversation_failed_to_add_participant_to_group_conversation_toast, R.drawable.warning_circle)
}
}
}

View file

@ -925,11 +925,7 @@ class ConversationViewModel
} else {
R.string.conversation_search_no_more_match
}
showRedToastEvent.postValue(
Event(
Pair(message, R.drawable.magnifying_glass)
)
)
showRedToast(message, R.drawable.magnifying_glass)
} else {
Log.i(
"$TAG Found result [${match.chatMessage?.messageId}] while looking up for message with text [$textToSearch] in direction [$direction] starting from message [${latestMatch?.chatMessage?.messageId}]"
@ -971,24 +967,10 @@ class ConversationViewModel
Log.i(
"$TAG File [$filePath] has been successfully exported to documents"
)
showGreenToastEvent.postValue(
Event(
Pair(
R.string.file_successfully_exported_to_documents_toast,
R.drawable.check
)
)
)
showGreenToast(R.string.file_successfully_exported_to_documents_toast, R.drawable.check)
} else {
Log.e("$TAG Failed to export file [$filePath] to documents!")
showRedToastEvent.postValue(
Event(
Pair(
R.string.export_file_to_documents_error_toast,
R.drawable.warning_circle
)
)
)
showRedToast(R.string.export_file_to_documents_error_toast, R.drawable.warning_circle)
}
}
}

View file

@ -33,7 +33,6 @@ import org.linphone.core.Friend
import org.linphone.core.tools.Log
import org.linphone.ui.main.chat.model.ConversationModel
import org.linphone.ui.main.viewmodel.AbstractMainViewModel
import org.linphone.utils.Event
import org.linphone.utils.LinphoneUtils
class ConversationsListViewModel
@ -231,11 +230,7 @@ class ConversationsListViewModel
)
}
showGreenToastEvent.postValue(
Event(
Pair(R.string.conversation_deleted_toast, R.drawable.chat_teardrop_text)
)
)
showGreenToast(R.string.conversation_deleted_toast, R.drawable.chat_teardrop_text)
}
@WorkerThread

View file

@ -364,14 +364,7 @@ class SendMessageInConversationViewModel
Log.w(
"$TAG Max number of attachments [$MAX_FILES_TO_ATTACH] reached, file [$file] won't be attached"
)
showRedToastEvent.postValue(
Event(
Pair(
R.string.conversation_maximum_number_of_attachments_reached,
R.drawable.warning_circle
)
)
)
showRedToast(R.string.conversation_maximum_number_of_attachments_reached, R.drawable.warning_circle)
viewModelScope.launch {
Log.i("$TAG Deleting temporary file [$file]")
FileUtils.deleteFile(file)
@ -434,9 +427,7 @@ class SendMessageInConversationViewModel
Log.i("$TAG Sending forwarded message")
forwardedMessage.send()
showGreenToastEvent.postValue(
Event(Pair(R.string.conversation_message_forwarded_toast, R.drawable.forward))
)
showGreenToast(R.string.conversation_message_forwarded_toast, R.drawable.forward)
}
}
}
@ -591,14 +582,7 @@ class SendMessageInConversationViewModel
"$TAG Max duration for voice recording exceeded (${maxVoiceRecordDuration}ms), stopping."
)
stopVoiceRecorder()
showRedToastEvent.postValue(
Event(
Pair(
R.string.conversation_voice_recording_max_duration_reached_toast,
R.drawable.warning_circle
)
)
)
showRedToast(R.string.conversation_voice_recording_max_duration_reached_toast, R.drawable.warning_circle)
}
}
}.launchIn(viewModelScope)
@ -663,11 +647,7 @@ class SendMessageInConversationViewModel
val lowMediaVolume = AudioUtils.isMediaVolumeLow(context)
if (lowMediaVolume) {
Log.w("$TAG Media volume is low, notifying user as they may not hear voice message")
showRedToastEvent.postValue(
Event(
Pair(R.string.media_playback_low_volume_warning_toast, R.drawable.speaker_slash)
)
)
showRedToast(R.string.media_playback_low_volume_warning_toast, R.drawable.speaker_slash)
}
if (voiceRecordAudioFocusRequest == null) {

View file

@ -145,14 +145,7 @@ class ContactNewOrEditViewModel
val organization = company.value.orEmpty().trim()
if (fn.isEmpty() && ln.isEmpty() && organization.isEmpty()) {
Log.e("$TAG At least a mandatory field wasn't filled, aborting save")
showRedToastEvent.postValue(
Event(
Pair(
R.string.contact_editor_mandatory_field_not_filled_toast,
R.drawable.warning_circle
)
)
)
showRedToast(R.string.contact_editor_mandatory_field_not_filled_toast, R.drawable.warning_circle)
return
}

View file

@ -242,9 +242,7 @@ class ContactsListViewModel
coreContext.contactsManager.contactRemoved(contactModel.friend)
contactModel.friend.remove()
coreContext.contactsManager.notifyContactsListChanged()
showGreenToastEvent.postValue(
Event(Pair(R.string.contact_deleted_toast, R.drawable.warning_circle))
)
showGreenToast(R.string.contact_deleted_toast, R.drawable.warning_circle)
}
}

View file

@ -187,14 +187,7 @@ class StartCallViewModel
val conference = LinphoneUtils.createGroupCall(account, subject.value.orEmpty())
if (conference == null) {
Log.e("$TAG Failed to create group call!")
showRedToastEvent.postValue(
Event(
Pair(
R.string.conference_failed_to_create_group_call_toast,
R.drawable.warning_circle
)
)
)
showRedToast(R.string.conference_failed_to_create_group_call_toast, R.drawable.warning_circle)
operationInProgress.postValue(false)
return@postOnCoreThread
}
@ -215,14 +208,7 @@ class StartCallViewModel
conference.addListener(conferenceListener)
if (conference.inviteParticipants(participants, callParams) != 0) {
Log.e("$TAG Failed to invite participants into group call!")
showRedToastEvent.postValue(
Event(
Pair(
R.string.conference_failed_to_create_group_call_toast,
R.drawable.warning_circle
)
)
)
showRedToast(R.string.conference_failed_to_create_group_call_toast, R.drawable.warning_circle)
operationInProgress.postValue(false)
}
}

View file

@ -111,14 +111,7 @@ class ScheduleMeetingViewModel
when (state) {
ConferenceScheduler.State.Error -> {
operationInProgress.postValue(false)
showRedToastEvent.postValue(
Event(
Pair(
R.string.meeting_failed_to_schedule_toast,
R.drawable.warning_circle
)
)
)
showRedToast(R.string.meeting_failed_to_schedule_toast, R.drawable.warning_circle)
}
ConferenceScheduler.State.Ready -> {
val conferenceAddress = conferenceScheduler.info?.uri
@ -166,28 +159,14 @@ class ScheduleMeetingViewModel
}
participants.value.orEmpty().size -> {
Log.e("$TAG No invitation sent!")
showRedToastEvent.postValue(
Event(
Pair(
R.string.meeting_failed_to_send_invites_toast,
R.drawable.warning_circle
)
)
)
showRedToast(R.string.meeting_failed_to_send_invites_toast, R.drawable.warning_circle)
}
else -> {
Log.w("$TAG [$failedCount] invitations couldn't have been sent for:")
for (failed in failedInvitations.orEmpty()) {
Log.w(failed.asStringUriOnly())
}
showRedToastEvent.postValue(
Event(
Pair(
R.string.meeting_failed_to_send_part_of_invites_toast,
R.drawable.warning_circle
)
)
)
showRedToast(R.string.meeting_failed_to_send_part_of_invites_toast, R.drawable.warning_circle)
}
}
@ -398,14 +377,7 @@ class ScheduleMeetingViewModel
Log.e(
"$TAG Either no subject was set or no participant was selected, can't schedule meeting."
)
showRedToastEvent.postValue(
Event(
Pair(
R.string.meeting_schedule_mandatory_field_not_filled_toast,
R.drawable.warning_circle
)
)
)
showRedToast(R.string.meeting_schedule_mandatory_field_not_filled_toast, R.drawable.warning_circle)
return
}

View file

@ -38,7 +38,6 @@ import org.linphone.core.tools.Log
import org.linphone.ui.GenericViewModel
import org.linphone.ui.main.recordings.model.RecordingModel
import org.linphone.utils.AudioUtils
import org.linphone.utils.Event
class RecordingMediaPlayerViewModel
@UiThread
@ -122,11 +121,7 @@ class RecordingMediaPlayerViewModel
val lowMediaVolume = AudioUtils.isMediaVolumeLow(coreContext.context)
if (lowMediaVolume) {
Log.w("$TAG Media volume is low, notifying user as they may not hear voice message")
showRedToastEvent.postValue(
Event(
Pair(R.string.media_playback_low_volume_warning_toast, R.drawable.speaker_slash)
)
)
showRedToast(R.string.media_playback_low_volume_warning_toast, R.drawable.speaker_slash)
}
if (player.state == Player.State.Closed) {

View file

@ -156,14 +156,7 @@ class AccountProfileViewModel
if (!errorMessage.isNullOrEmpty()) {
when (request.type) {
AccountManagerServicesRequest.Type.GetDevicesList, AccountManagerServicesRequest.Type.DeleteDevice -> {
showFormattedRedToastEvent.postValue(
Event(
Pair(
errorMessage,
R.drawable.warning_circle
)
)
)
showFormattedRedToast(errorMessage, R.drawable.warning_circle)
devicesFetchInProgress.postValue(false)
}
else -> {}

View file

@ -81,14 +81,7 @@ class CardDavViewModel
when (status) {
FriendList.SyncStatus.Successful -> {
syncInProgress.postValue(false)
showGreenToastEvent.postValue(
Event(
Pair(
R.string.settings_contacts_carddav_sync_successful_toast,
R.drawable.check
)
)
)
showGreenToast(R.string.settings_contacts_carddav_sync_successful_toast, R.drawable.check)
Log.i("$TAG Notifying contacts manager that contacts have changed")
coreContext.contactsManager.notifyContactsListChanged()
@ -97,14 +90,7 @@ class CardDavViewModel
}
FriendList.SyncStatus.Failure -> {
syncInProgress.postValue(false)
showRedToastEvent.postValue(
Event(
Pair(
R.string.settings_contacts_carddav_sync_error_toast,
R.drawable.warning_circle
)
)
)
showRedToast(R.string.settings_contacts_carddav_sync_error_toast, R.drawable.warning_circle)
if (isEdit.value == false) {
Log.e("$TAG Synchronization failed, removing Friend list from Core")
friendList.removeListener(this)
@ -166,14 +152,7 @@ class CardDavViewModel
}
core.removeFriendList(friendList)
Log.i("$TAG Removed friends list with display name [$name]")
showGreenToastEvent.postValue(
Event(
Pair(
R.string.settings_contacts_carddav_deleted_toast,
R.drawable.trash_simple
)
)
)
showGreenToast(R.string.settings_contacts_carddav_deleted_toast, R.drawable.trash_simple)
Log.i("$TAG Notifying contacts manager that contacts have changed")
coreContext.contactsManager.notifyContactsListChanged()
@ -193,14 +172,7 @@ class CardDavViewModel
val name = displayName.value.orEmpty().trim()
val server = serverUrl.value.orEmpty().trim()
if (name.isEmpty() || server.isEmpty()) {
showRedToastEvent.postValue(
Event(
Pair(
R.string.settings_contacts_carddav_mandatory_field_not_filled_toast,
R.drawable.warning_circle
)
)
)
showRedToast(R.string.settings_contacts_carddav_mandatory_field_not_filled_toast, R.drawable.warning_circle)
return
}

View file

@ -139,14 +139,7 @@ class LdapViewModel : GenericViewModel() {
val server = serverUrl.value.orEmpty().trim()
if (server.isEmpty()) {
Log.e("$TAG Server field can't be empty!")
showRedToastEvent.postValue(
Event(
Pair(
R.string.settings_contacts_ldap_empty_server_error_toast,
R.drawable.warning_circle
)
)
)
showRedToast(R.string.settings_contacts_ldap_empty_server_error_toast, R.drawable.warning_circle)
return@postOnCoreThread
}
@ -181,11 +174,7 @@ class LdapViewModel : GenericViewModel() {
ldapServerOperationSuccessfulEvent.postValue(Event(true))
} catch (e: Exception) {
Log.e("$TAG Exception while creating LDAP: $e")
showRedToastEvent.postValue(
Event(
Pair(R.string.settings_contacts_ldap_error_toast, R.drawable.warning_circle)
)
)
showRedToast(R.string.settings_contacts_ldap_error_toast, R.drawable.warning_circle)
}
}
}

View file

@ -332,7 +332,7 @@ class SettingsViewModel
Log.i("$TAG VFS has been enabled")
}
} else {
showRedToastEvent.postValue(Event(Pair(R.string.settings_security_enable_vfs_failure_toast, R.drawable.warning_circle)))
showRedToast(R.string.settings_security_enable_vfs_failure_toast, R.drawable.warning_circle)
isVfsEnabled.postValue(false)
Log.e("$TAG Failed to enable VFS!")
}