Disable attach file & voice messages in chat if no file transfer server URL is set

This commit is contained in:
Sylvain Berfini 2023-06-20 15:12:12 +02:00
parent 197ceb9e69
commit 226095bec7
8 changed files with 16 additions and 2 deletions

View file

@ -107,6 +107,8 @@ class ChatMessageSendingViewModel(private val chatRoom: ChatRoom) : ViewModel()
val isEmojiPickerVisible = MutableLiveData<Boolean>()
val isFileTransferAvailable = MutableLiveData<Boolean>()
val requestKeyboardHidingEvent: MutableLiveData<Event<Boolean>> by lazy {
MutableLiveData<Event<Boolean>>()
}
@ -146,6 +148,7 @@ class ChatMessageSendingViewModel(private val chatRoom: ChatRoom) : ViewModel()
sendMessageEnabled.value = false
isEmojiPickerOpen.value = false
isEmojiPickerVisible.value = corePreferences.showEmojiPickerButton
isFileTransferAvailable.value = LinphoneUtils.isFileTransferAvailable()
updateChatRoomReadOnlyState()
}

View file

@ -288,6 +288,11 @@ class LinphoneUtils {
return true
}
fun isFileTransferAvailable(): Boolean {
val core = coreContext.core
return core.fileTransferServer.orEmpty().isNotEmpty()
}
fun hashPassword(
userId: String,
password: String,

View file

@ -44,6 +44,7 @@
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="?attr/backgroundColor"
android:clickable="true">
<LinearLayout

View file

@ -34,7 +34,8 @@
<RelativeLayout
android:layout_width="@dimen/master_fragment_width"
android:layout_height="match_parent"
android:layout_gravity="start">
android:layout_gravity="start"
android:background="?attr/backgroundColor">
<LinearLayout
android:id="@+id/top_bar"

View file

@ -126,7 +126,7 @@
android:layout_height="0dp"
android:layout_marginStart="@dimen/chat_message_sending_icons_margin"
android:contentDescription="@string/content_description_attach_file"
android:enabled="@{chatSendingViewModel.attachFileEnabled &amp;&amp; !chatSendingViewModel.attachFilePending}"
android:enabled="@{chatSendingViewModel.attachFileEnabled &amp;&amp; !chatSendingViewModel.attachFilePending &amp;&amp; chatSendingViewModel.isFileTransferAvailable}"
android:onClick="@{attachFileClickListener}"
android:paddingTop="@dimen/chat_message_sending_icons_margin"
android:paddingBottom="@dimen/chat_message_sending_icons_margin"
@ -147,6 +147,7 @@
android:paddingTop="@dimen/chat_message_sending_icons_margin"
android:paddingBottom="@dimen/chat_message_sending_icons_margin"
android:selected="@{chatSendingViewModel.isVoiceRecording}"
android:enabled="@{chatSendingViewModel.isFileTransferAvailable}"
android:src="@drawable/record_audio_message"
app:layout_constraintHeight_max="@dimen/chat_message_sending_icons_size"
app:layout_constraintBottom_toBottomOf="@id/message"

View file

@ -31,6 +31,7 @@
<RelativeLayout
android:layout_width="@dimen/master_fragment_width"
android:layout_height="match_parent"
android:background="?attr/backgroundColor"
android:layout_gravity="start">
<LinearLayout

View file

@ -23,6 +23,7 @@
<RelativeLayout
android:layout_width="@dimen/master_fragment_width"
android:layout_height="match_parent"
android:background="?attr/backgroundColor"
android:layout_gravity="start">
<LinearLayout

View file

@ -20,6 +20,7 @@
<RelativeLayout
android:layout_width="@dimen/master_fragment_width"
android:layout_height="match_parent"
android:background="?attr/backgroundColor"
android:layout_gravity="start">
<LinearLayout