Added setting to disable new contact account dialog + prevent saving new empty contact
This commit is contained in:
parent
260ed4b3cb
commit
253e2dc654
7 changed files with 34 additions and 7 deletions
|
@ -35,6 +35,7 @@ import androidx.lifecycle.lifecycleScope
|
||||||
import androidx.navigation.fragment.findNavController
|
import androidx.navigation.fragment.findNavController
|
||||||
import java.io.File
|
import java.io.File
|
||||||
import kotlinx.coroutines.launch
|
import kotlinx.coroutines.launch
|
||||||
|
import org.linphone.LinphoneApplication.Companion.corePreferences
|
||||||
import org.linphone.R
|
import org.linphone.R
|
||||||
import org.linphone.activities.main.MainActivity
|
import org.linphone.activities.main.MainActivity
|
||||||
import org.linphone.activities.main.contact.viewmodels.*
|
import org.linphone.activities.main.contact.viewmodels.*
|
||||||
|
@ -86,7 +87,10 @@ class ContactEditorFragment : Fragment(), SyncAccountPickerFragment.SyncAccountP
|
||||||
}
|
}
|
||||||
|
|
||||||
binding.setSaveChangesClickListener {
|
binding.setSaveChangesClickListener {
|
||||||
if (viewModel.c == null) {
|
viewModel.syncAccountName = null
|
||||||
|
viewModel.syncAccountType = null
|
||||||
|
|
||||||
|
if (viewModel.c == null && corePreferences.showNewContactAccountDialog) {
|
||||||
Log.i("[Contact Editor] New contact, ask user where to store it")
|
Log.i("[Contact Editor] New contact, ask user where to store it")
|
||||||
SyncAccountPickerFragment(this).show(childFragmentManager, "SyncAccountPicker")
|
SyncAccountPickerFragment(this).show(childFragmentManager, "SyncAccountPicker")
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -68,12 +68,10 @@ class ContactEditorViewModel(val c: Contact?) : ViewModel(), ContactViewModelInt
|
||||||
var syncAccountType: String? = null
|
var syncAccountType: String? = null
|
||||||
|
|
||||||
init {
|
init {
|
||||||
if (c != null) {
|
|
||||||
contact.value = c
|
contact.value = c
|
||||||
firstName.value = c.firstName
|
firstName.value = c?.firstName ?: ""
|
||||||
lastName.value = c.lastName
|
lastName.value = c?.lastName ?: ""
|
||||||
organization.value = c.organization
|
organization.value = c?.organization ?: ""
|
||||||
}
|
|
||||||
|
|
||||||
updateNumbersAndAddresses()
|
updateNumbersAndAddresses()
|
||||||
}
|
}
|
||||||
|
|
|
@ -38,6 +38,13 @@ class ContactsSettingsViewModel : GenericSettingsViewModel() {
|
||||||
}
|
}
|
||||||
val friendListSubscribe = MutableLiveData<Boolean>()
|
val friendListSubscribe = MutableLiveData<Boolean>()
|
||||||
|
|
||||||
|
val showNewContactAccountDialogListener = object : SettingListenerStub() {
|
||||||
|
override fun onBoolValueChanged(newValue: Boolean) {
|
||||||
|
prefs.showNewContactAccountDialog = newValue
|
||||||
|
}
|
||||||
|
}
|
||||||
|
val showNewContactAccountDialog = MutableLiveData<Boolean>()
|
||||||
|
|
||||||
val nativePresenceListener = object : SettingListenerStub() {
|
val nativePresenceListener = object : SettingListenerStub() {
|
||||||
override fun onBoolValueChanged(newValue: Boolean) {
|
override fun onBoolValueChanged(newValue: Boolean) {
|
||||||
if (newValue) {
|
if (newValue) {
|
||||||
|
@ -73,6 +80,7 @@ class ContactsSettingsViewModel : GenericSettingsViewModel() {
|
||||||
readContactsPermissionGranted.value = PermissionHelper.get().hasReadContactsPermission()
|
readContactsPermissionGranted.value = PermissionHelper.get().hasReadContactsPermission()
|
||||||
|
|
||||||
friendListSubscribe.value = core.isFriendListSubscriptionEnabled
|
friendListSubscribe.value = core.isFriendListSubscriptionEnabled
|
||||||
|
showNewContactAccountDialog.value = prefs.showNewContactAccountDialog
|
||||||
nativePresence.value = prefs.storePresenceInNativeContact
|
nativePresence.value = prefs.storePresenceInNativeContact
|
||||||
showOrganization.value = prefs.displayOrganization
|
showOrganization.value = prefs.displayOrganization
|
||||||
launcherShortcuts.value = prefs.contactsShortcuts
|
launcherShortcuts.value = prefs.contactsShortcuts
|
||||||
|
|
|
@ -125,6 +125,12 @@ class CorePreferences constructor(private val context: Context) {
|
||||||
config.setBool("app", "store_presence_in_native_contact", value)
|
config.setBool("app", "store_presence_in_native_contact", value)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var showNewContactAccountDialog: Boolean
|
||||||
|
get() = config.getBool("app", "show_new_contact_account_dialog", true)
|
||||||
|
set(value) {
|
||||||
|
config.setBool("app", "show_new_contact_account_dialog", value)
|
||||||
|
}
|
||||||
|
|
||||||
var displayOrganization: Boolean
|
var displayOrganization: Boolean
|
||||||
get() = config.getBool("app", "display_contact_organization", contactOrganizationVisible)
|
get() = config.getBool("app", "display_contact_organization", contactOrganizationVisible)
|
||||||
set(value) {
|
set(value) {
|
||||||
|
|
|
@ -48,6 +48,7 @@
|
||||||
|
|
||||||
<ImageView
|
<ImageView
|
||||||
android:id="@+id/ok"
|
android:id="@+id/ok"
|
||||||
|
android:enabled="@{!viewModel.firstName.empty || !viewModel.lastName.empty}"
|
||||||
android:contentDescription="@string/content_description_confirm_contact_edit"
|
android:contentDescription="@string/content_description_confirm_contact_edit"
|
||||||
android:onClick="@{saveChangesClickListener}"
|
android:onClick="@{saveChangesClickListener}"
|
||||||
android:layout_width="0dp"
|
android:layout_width="0dp"
|
||||||
|
|
|
@ -72,6 +72,14 @@
|
||||||
linphone:checked="@={viewModel.friendListSubscribe}"
|
linphone:checked="@={viewModel.friendListSubscribe}"
|
||||||
linphone:enabled="@{viewModel.readContactsPermissionGranted}"/>
|
linphone:enabled="@{viewModel.readContactsPermissionGranted}"/>
|
||||||
|
|
||||||
|
<include
|
||||||
|
layout="@layout/settings_widget_switch"
|
||||||
|
linphone:title="@{@string/contacts_settings_show_new_contact_account_dialog_title}"
|
||||||
|
linphone:subtitle="@{@string/contacts_settings_show_new_contact_account_dialog_summary}"
|
||||||
|
linphone:listener="@{viewModel.showNewContactAccountDialogListener}"
|
||||||
|
linphone:checked="@={viewModel.showNewContactAccountDialog}"
|
||||||
|
linphone:enabled="@{viewModel.readContactsPermissionGranted}"/>
|
||||||
|
|
||||||
<include
|
<include
|
||||||
layout="@layout/settings_widget_switch"
|
layout="@layout/settings_widget_switch"
|
||||||
linphone:title="@{@string/contacts_settings_native_presence_title}"
|
linphone:title="@{@string/contacts_settings_native_presence_title}"
|
||||||
|
|
|
@ -439,6 +439,8 @@
|
||||||
<string name="contacts_settings_show_organization_summary"></string>
|
<string name="contacts_settings_show_organization_summary"></string>
|
||||||
<string name="contacts_settings_launcher_shortcuts_title">Create shortcuts to contacts in launcher</string>
|
<string name="contacts_settings_launcher_shortcuts_title">Create shortcuts to contacts in launcher</string>
|
||||||
<string name="contacts_settings_launcher_shortcuts_summary">Will replace chat room shortcuts if any</string>
|
<string name="contacts_settings_launcher_shortcuts_summary">Will replace chat room shortcuts if any</string>
|
||||||
|
<string name="contacts_settings_show_new_contact_account_dialog_title">Always ask in which account save newly created contact</string>
|
||||||
|
<string name="contacts_settings_show_new_contact_account_dialog_summary">If disabled contact will be stored locally</string>
|
||||||
|
|
||||||
<!-- Advanced settings -->
|
<!-- Advanced settings -->
|
||||||
<string name="advanced_settings_debug_mode_title">Debug logs</string>
|
<string name="advanced_settings_debug_mode_title">Debug logs</string>
|
||||||
|
|
Loading…
Reference in a new issue