mirror of
https://gitlab.linphone.org/BC/public/linphone-android.git
synced 2026-01-17 03:18:06 +00:00
Fixed contacts presence subscribe being only enabled for default domain account, added setting to disable presence
This commit is contained in:
parent
65ad8235b3
commit
28cae1fca1
6 changed files with 45 additions and 19 deletions
|
|
@ -606,7 +606,6 @@ class CoreContext
|
|||
@WorkerThread
|
||||
fun startCore() {
|
||||
Log.i("$TAG Starting Core")
|
||||
updateFriendListsSubscriptionDependingOnDefaultAccount()
|
||||
|
||||
val audioManager = context.getSystemService(Context.AUDIO_SERVICE) as AudioManager
|
||||
audioManager.registerAudioDeviceCallback(audioDeviceCallback, coreThread)
|
||||
|
|
@ -1038,22 +1037,6 @@ class CoreContext
|
|||
keepAliveServiceStarted = false
|
||||
}
|
||||
|
||||
@WorkerThread
|
||||
fun updateFriendListsSubscriptionDependingOnDefaultAccount() {
|
||||
val account = core.defaultAccount
|
||||
if (account != null) {
|
||||
val enabled = account.params.domain == corePreferences.defaultDomain
|
||||
if (enabled != core.isFriendListSubscriptionEnabled) {
|
||||
core.isFriendListSubscriptionEnabled = enabled
|
||||
Log.i(
|
||||
"$TAG Friend list(s) subscription are now ${if (enabled) "enabled" else "disabled"}"
|
||||
)
|
||||
}
|
||||
} else {
|
||||
Log.e("$TAG Default account is null, do not touch friend lists subscription")
|
||||
}
|
||||
}
|
||||
|
||||
@WorkerThread
|
||||
fun playDtmf(character: Char, duration: Int = 200, ignoreSystemPolicy: Boolean = false) {
|
||||
try {
|
||||
|
|
|
|||
|
|
@ -109,6 +109,8 @@ class SettingsViewModel
|
|||
|
||||
val cardDavFriendsLists = MutableLiveData<List<CardDavLdapModel>>()
|
||||
|
||||
val presenceSubscribe = MutableLiveData<Boolean>()
|
||||
|
||||
val addLdapServerEvent: MutableLiveData<Event<Boolean>> by lazy {
|
||||
MutableLiveData<Event<Boolean>>()
|
||||
}
|
||||
|
|
@ -325,6 +327,8 @@ class SettingsViewModel
|
|||
corePreferences.markConversationAsReadWhenDismissingMessageNotification
|
||||
)
|
||||
|
||||
presenceSubscribe.postValue(core.isFriendListSubscriptionEnabled)
|
||||
|
||||
defaultLayout.postValue(core.defaultConferenceLayout.toInt())
|
||||
|
||||
autoShowDialpad.postValue(corePreferences.automaticallyShowDialpad)
|
||||
|
|
@ -594,6 +598,15 @@ class SettingsViewModel
|
|||
}
|
||||
}
|
||||
|
||||
@UiThread
|
||||
fun togglePresenceSubscribe() {
|
||||
val newValue = presenceSubscribe.value == false
|
||||
coreContext.postOnCoreThread { core ->
|
||||
core.isFriendListSubscriptionEnabled = newValue
|
||||
presenceSubscribe.postValue(newValue)
|
||||
}
|
||||
}
|
||||
|
||||
@UiThread
|
||||
fun toggleMeetingsExpand() {
|
||||
expandMeetings.value = expandMeetings.value == false
|
||||
|
|
|
|||
|
|
@ -282,7 +282,6 @@ class MainViewModel
|
|||
Log.i(
|
||||
"$TAG Default account changed, now is [${account.params.identityAddress?.asStringUriOnly()}]"
|
||||
)
|
||||
coreContext.updateFriendListsSubscriptionDependingOnDefaultAccount()
|
||||
|
||||
removeAlert(DEFAULT_ACCOUNT_DISABLED)
|
||||
removeAlert(NON_DEFAULT_ACCOUNT_NOT_CONNECTED)
|
||||
|
|
|
|||
|
|
@ -82,10 +82,39 @@
|
|||
app:entries="@{viewModel.cardDavFriendsLists}"
|
||||
app:layout="@{@layout/settings_contacts_carddav_ldap_list_cell}"
|
||||
app:layout_constraintTop_toBottomOf="@id/add_carddav_server"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent" />
|
||||
|
||||
<androidx.appcompat.widget.AppCompatTextView
|
||||
style="@style/settings_title_style"
|
||||
android:onClick="@{() -> viewModel.togglePresenceSubscribe()}"
|
||||
android:id="@+id/presence_subscribe_title"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="16dp"
|
||||
android:layout_marginEnd="10dp"
|
||||
android:text="@string/settings_contacts_presence_subscribe_title"
|
||||
android:maxLines="2"
|
||||
android:ellipsize="end"
|
||||
android:labelFor="@id/presence_subscribe_switch"
|
||||
app:layout_constraintTop_toTopOf="@id/presence_subscribe_switch"
|
||||
app:layout_constraintBottom_toBottomOf="@id/presence_subscribe_switch"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintEnd_toStartOf="@id/presence_subscribe_switch"/>
|
||||
|
||||
<com.google.android.material.materialswitch.MaterialSwitch
|
||||
style="@style/material_switch_style"
|
||||
android:id="@+id/presence_subscribe_switch"
|
||||
android:onClick="@{() -> viewModel.togglePresenceSubscribe()}"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="20dp"
|
||||
android:layout_marginEnd="16dp"
|
||||
android:checked="@{viewModel.presenceSubscribe}"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/existing_carddav_servers"
|
||||
app:layout_constraintBottom_toBottomOf="parent" />
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
|
||||
</layout>
|
||||
|
|
@ -210,6 +210,7 @@
|
|||
<string name="settings_conversations_auto_export_media_to_native_gallery_title">Rendre visible dans la galerie les médias téléchargés</string>
|
||||
<string name="settings_conversations_mark_as_read_when_dismissing_notif_title">Marquer la conversation comme lue lorsqu\'une notification de message est supprimée</string>
|
||||
<string name="settings_contacts_title">Contacts</string>
|
||||
<string name="settings_contacts_presence_subscribe_title">Souscrire aux informations de présence</string>
|
||||
<string name="settings_contacts_add_ldap_server_title">Ajouter un serveur LDAP</string>
|
||||
<string name="settings_contacts_edit_ldap_server_title">Editer le serveur LDAP</string>
|
||||
<string name="settings_contacts_add_carddav_server_title">Ajouter un carnet d\'adresse CardDAV</string>
|
||||
|
|
|
|||
|
|
@ -261,6 +261,7 @@
|
|||
<string name="settings_conversations_auto_export_media_to_native_gallery_title">Make downloaded media public</string>
|
||||
<string name="settings_conversations_mark_as_read_when_dismissing_notif_title">Mark conversation as read when dismissing message notification</string>
|
||||
<string name="settings_contacts_title">Contacts</string>
|
||||
<string name="settings_contacts_presence_subscribe_title">Subscribe to presence info</string>
|
||||
<string name="settings_contacts_add_ldap_server_title">Add LDAP server</string>
|
||||
<string name="settings_contacts_edit_ldap_server_title">Edit LDAP server</string>
|
||||
<string name="settings_contacts_add_carddav_server_title">Add CardDAV address book</string>
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue