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
c556d14fb0
commit
0ca4eba63b
6 changed files with 45 additions and 20 deletions
|
|
@ -607,7 +607,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)
|
||||
|
|
@ -1055,22 +1054,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 {
|
||||
|
|
|
|||
|
|
@ -119,6 +119,8 @@ class SettingsViewModel
|
|||
|
||||
val cardDavFriendsLists = MutableLiveData<List<CardDavLdapModel>>()
|
||||
|
||||
val presenceSubscribe = MutableLiveData<Boolean>()
|
||||
|
||||
val addLdapServerEvent: MutableLiveData<Event<Boolean>> by lazy {
|
||||
MutableLiveData<Event<Boolean>>()
|
||||
}
|
||||
|
|
@ -342,6 +344,7 @@ class SettingsViewModel
|
|||
|
||||
sortContactsBy.postValue(if (corePreferences.sortContactsByFirstName) 0 else 1)
|
||||
hideEmptyContacts.postValue(corePreferences.hideContactsWithoutPhoneNumberOrSipAddress)
|
||||
presenceSubscribe.postValue(core.isFriendListSubscriptionEnabled)
|
||||
|
||||
defaultLayout.postValue(core.defaultConferenceLayout.toInt())
|
||||
|
||||
|
|
@ -643,6 +646,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)
|
||||
|
|
|
|||
|
|
@ -63,7 +63,7 @@
|
|||
|
||||
<androidx.appcompat.widget.AppCompatTextView
|
||||
style="@style/settings_title_style"
|
||||
android:onClick="@{() -> viewModel.toggleLogcat()}"
|
||||
android:onClick="@{() -> viewModel.toggleHideEmptyContacts()}"
|
||||
android:id="@+id/hide_empty_contacts_title"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
|
|
@ -157,10 +157,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>
|
||||
|
|
@ -227,6 +227,7 @@
|
|||
<string name="settings_contacts_title">Contacts</string>
|
||||
<string name="settings_contacts_sort_by_first_name_title">Trier les contacts par</string>
|
||||
<string name="settings_contacts_hide_empty_contacts_title">Masquer les contacts sans adresse SIP ni numéro de téléphone</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>
|
||||
|
|
|
|||
|
|
@ -269,6 +269,7 @@
|
|||
<string name="settings_contacts_title">Contacts</string>
|
||||
<string name="settings_contacts_sort_by_first_name_title">Sort contacts by</string>
|
||||
<string name="settings_contacts_hide_empty_contacts_title">Hide contacts without SIP address nor phone number</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