mirror of
https://gitlab.linphone.org/BC/public/linphone-android.git
synced 2026-01-17 11:28:06 +00:00
Hide message button if chat is disabled
This commit is contained in:
parent
141c613eb9
commit
544f37a75b
4 changed files with 17 additions and 0 deletions
|
|
@ -4,6 +4,7 @@ import androidx.annotation.UiThread
|
|||
import androidx.lifecycle.MutableLiveData
|
||||
import androidx.lifecycle.ViewModel
|
||||
import org.linphone.LinphoneApplication.Companion.coreContext
|
||||
import org.linphone.LinphoneApplication.Companion.corePreferences
|
||||
import org.linphone.core.Address
|
||||
import org.linphone.core.Call
|
||||
import org.linphone.ui.main.calls.model.CallLogHistoryModel
|
||||
|
|
@ -18,12 +19,20 @@ class CallLogViewModel @UiThread constructor() : ViewModel() {
|
|||
|
||||
val historyCallLogs = MutableLiveData<ArrayList<CallLogHistoryModel>>()
|
||||
|
||||
val chatDisabled = MutableLiveData<Boolean>()
|
||||
|
||||
val historyDeletedEvent: MutableLiveData<Event<Boolean>> by lazy {
|
||||
MutableLiveData<Event<Boolean>>()
|
||||
}
|
||||
|
||||
private lateinit var address: Address
|
||||
|
||||
init {
|
||||
coreContext.postOnCoreThread {
|
||||
chatDisabled.postValue(corePreferences.disableChat)
|
||||
}
|
||||
}
|
||||
|
||||
@UiThread
|
||||
fun findCallLogByCallId(callId: String) {
|
||||
coreContext.postOnCoreThread { core ->
|
||||
|
|
|
|||
|
|
@ -28,6 +28,7 @@ import java.io.File
|
|||
import java.util.Locale
|
||||
import kotlinx.coroutines.launch
|
||||
import org.linphone.LinphoneApplication.Companion.coreContext
|
||||
import org.linphone.LinphoneApplication.Companion.corePreferences
|
||||
import org.linphone.contacts.ContactsManager
|
||||
import org.linphone.contacts.getListOfSipAddressesAndPhoneNumbers
|
||||
import org.linphone.core.Friend
|
||||
|
|
@ -65,6 +66,8 @@ class ContactViewModel @UiThread constructor() : ViewModel() {
|
|||
|
||||
val contactFoundEvent = MutableLiveData<Event<Boolean>>()
|
||||
|
||||
val chatDisabled = MutableLiveData<Boolean>()
|
||||
|
||||
val showLongPressMenuForNumberOrAddressEvent: MutableLiveData<Event<ContactNumberOrAddressModel>> by lazy {
|
||||
MutableLiveData<Event<ContactNumberOrAddressModel>>()
|
||||
}
|
||||
|
|
@ -143,6 +146,7 @@ class ContactViewModel @UiThread constructor() : ViewModel() {
|
|||
expandDevicesTrust.value = false // TODO FIXME: set it to true when it will work for real
|
||||
|
||||
coreContext.postOnCoreThread {
|
||||
chatDisabled.postValue(corePreferences.disableChat)
|
||||
coreContext.contactsManager.addListener(contactsListener)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -168,6 +168,7 @@
|
|||
<ImageView
|
||||
android:onClick="@{() -> viewModel.sendMessage()}"
|
||||
android:id="@+id/chat"
|
||||
android:visibility="@{viewModel.chatDisabled ? View.GONE : View.VISIBLE}"
|
||||
android:layout_width="56dp"
|
||||
android:layout_height="56dp"
|
||||
android:layout_marginTop="20dp"
|
||||
|
|
@ -183,6 +184,7 @@
|
|||
style="@style/default_text_style"
|
||||
android:onClick="@{() -> viewModel.sendMessage()}"
|
||||
android:id="@+id/chat_label"
|
||||
android:visibility="@{viewModel.chatDisabled ? View.GONE : View.VISIBLE}"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="8dp"
|
||||
|
|
|
|||
|
|
@ -181,6 +181,7 @@
|
|||
|
||||
<ImageView
|
||||
android:id="@+id/chat"
|
||||
android:visibility="@{viewModel.chatDisabled ? View.GONE : View.VISIBLE}"
|
||||
android:layout_width="56dp"
|
||||
android:layout_height="56dp"
|
||||
android:layout_marginTop="20dp"
|
||||
|
|
@ -196,6 +197,7 @@
|
|||
style="@style/default_text_style"
|
||||
android:onClick="@{() -> viewModel.sendMessage()}"
|
||||
android:id="@+id/chat_label"
|
||||
android:visibility="@{viewModel.chatDisabled ? View.GONE : View.VISIBLE}"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="8dp"
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue