Added a setting to use native addressbook in read only
This commit is contained in:
parent
a8bdca0c26
commit
b0e25f9a67
17 changed files with 41 additions and 13 deletions
|
@ -17,6 +17,7 @@ Group changes to describe their impact on the project, as follows:
|
|||
- Confirmation dialog before removing account
|
||||
- Attended transfer instead of blind transfer if there is more than 1 call
|
||||
- Added hidden setting to disable video completely
|
||||
- Added hidden setting to prevent adding / editing / removing native contacts
|
||||
|
||||
### Changed
|
||||
- Account EXPIRES is now set to 1 month instead of 1 year for sip.linphone.org accounts
|
||||
|
|
|
@ -34,6 +34,7 @@ import androidx.recyclerview.widget.DiffUtil
|
|||
import androidx.recyclerview.widget.RecyclerView
|
||||
import kotlin.math.abs
|
||||
import org.linphone.LinphoneApplication.Companion.coreContext
|
||||
import org.linphone.LinphoneApplication.Companion.corePreferences
|
||||
import org.linphone.R
|
||||
import org.linphone.activities.main.adapters.SelectionListAdapter
|
||||
import org.linphone.activities.main.chat.data.ChatMessageData
|
||||
|
@ -327,7 +328,8 @@ class ChatMessagesListAdapter(
|
|||
}
|
||||
if (chatMessage.isOutgoing ||
|
||||
chatMessageViewModel.contact.value != null ||
|
||||
advancedContextMenuOptionsDisabled
|
||||
advancedContextMenuOptionsDisabled ||
|
||||
corePreferences.readOnlyNativeContacts
|
||||
) {
|
||||
popupView.addToContactsHidden = true
|
||||
totalSize -= itemSize
|
||||
|
|
|
@ -952,6 +952,11 @@ class DetailChatRoomFragment : MasterFragment<ChatRoomDetailFragmentBinding, Cha
|
|||
popupView.addToContactsHidden = true
|
||||
} else {
|
||||
popupView.goToContactHidden = true
|
||||
|
||||
if (corePreferences.readOnlyNativeContacts) {
|
||||
popupView.addToContactsHidden = true
|
||||
totalSize -= itemSize
|
||||
}
|
||||
}
|
||||
|
||||
popupView.meetingHidden = true
|
||||
|
|
|
@ -197,8 +197,11 @@ class MasterContactsFragment : MasterFragment<ContactMasterFragmentBinding, Cont
|
|||
dialog.show()
|
||||
}
|
||||
}
|
||||
RecyclerViewSwipeUtils(ItemTouchHelper.LEFT, swipeConfiguration, swipeListener)
|
||||
.attachToRecyclerView(binding.contactsList)
|
||||
|
||||
if (!corePreferences.readOnlyNativeContacts) {
|
||||
RecyclerViewSwipeUtils(ItemTouchHelper.LEFT, swipeConfiguration, swipeListener)
|
||||
.attachToRecyclerView(binding.contactsList)
|
||||
}
|
||||
|
||||
// Divider between items
|
||||
binding.contactsList.addItemDecoration(AppUtils.getDividerDecoration(requireContext(), layoutManager))
|
||||
|
|
|
@ -79,6 +79,8 @@ class ContactViewModel(friend: Friend, async: Boolean = false) : MessageNotifier
|
|||
|
||||
val isNativeContact = MutableLiveData<Boolean>()
|
||||
|
||||
val readOnlyNativeAddressBook = MutableLiveData<Boolean>()
|
||||
|
||||
private val chatRoomListener = object : ChatRoomListenerStub() {
|
||||
override fun onStateChanged(chatRoom: ChatRoom, state: ChatRoom.State) {
|
||||
if (state == ChatRoom.State.Created) {
|
||||
|
@ -144,11 +146,13 @@ class ContactViewModel(friend: Friend, async: Boolean = false) : MessageNotifier
|
|||
displayName.postValue(friend.name)
|
||||
isNativeContact.postValue(friend.refKey != null)
|
||||
presenceStatus.postValue(friend.consolidatedPresence)
|
||||
readOnlyNativeAddressBook.postValue(corePreferences.readOnlyNativeContacts)
|
||||
} else {
|
||||
contact.value = friend
|
||||
displayName.value = friend.name
|
||||
isNativeContact.value = friend.refKey != null
|
||||
presenceStatus.value = friend.consolidatedPresence
|
||||
readOnlyNativeAddressBook.value = corePreferences.readOnlyNativeContacts
|
||||
}
|
||||
|
||||
friend.addListener {
|
||||
|
|
|
@ -40,6 +40,8 @@ class ContactsListViewModel : ViewModel() {
|
|||
|
||||
val nativeAddressBookEnabled = MutableLiveData<Boolean>()
|
||||
|
||||
val readOnlyNativeAddressBook = MutableLiveData<Boolean>()
|
||||
|
||||
val fetchInProgress = MutableLiveData<Boolean>()
|
||||
private var searchResultsPending: Boolean = false
|
||||
private var fastFetchJob: Job? = null
|
||||
|
@ -75,6 +77,7 @@ class ContactsListViewModel : ViewModel() {
|
|||
init {
|
||||
sipContactsSelected.value = coreContext.contactsManager.shouldDisplaySipContactsList()
|
||||
nativeAddressBookEnabled.value = corePreferences.enableNativeAddressBookIntegration
|
||||
readOnlyNativeAddressBook.value = corePreferences.readOnlyNativeContacts
|
||||
|
||||
coreContext.contactsManager.addListener(contactsUpdatedListener)
|
||||
coreContext.contactsManager.magicSearch.addListener(magicSearchListener)
|
||||
|
|
|
@ -49,6 +49,8 @@ class DialerViewModel : LogsUploadViewModel() {
|
|||
|
||||
val scheduleConferenceAvailable = MutableLiveData<Boolean>()
|
||||
|
||||
val hideAddContactButton = MutableLiveData<Boolean>()
|
||||
|
||||
val updateAvailableEvent: MutableLiveData<Event<String>> by lazy {
|
||||
MutableLiveData<Event<String>>()
|
||||
}
|
||||
|
@ -152,6 +154,7 @@ class DialerViewModel : LogsUploadViewModel() {
|
|||
enteredUri.value = ""
|
||||
atLeastOneCall.value = coreContext.core.callsNb > 0
|
||||
transferVisibility.value = false
|
||||
hideAddContactButton.value = corePreferences.readOnlyNativeContacts
|
||||
|
||||
showSwitchCamera.value = coreContext.showSwitchCameraButton()
|
||||
scheduleConferenceAvailable.value = LinphoneUtils.isRemoteConferencingAvailable()
|
||||
|
|
|
@ -122,6 +122,8 @@ class CallLogViewModel(val callLog: CallLog, private val isRelated: Boolean = fa
|
|||
val conferenceTime = MutableLiveData<String>()
|
||||
val conferenceDate = MutableLiveData<String>()
|
||||
|
||||
val readOnlyNativeAddressBook = MutableLiveData<Boolean>()
|
||||
|
||||
override val showGroupChatAvatar: Boolean
|
||||
get() = isConferenceCallLog
|
||||
|
||||
|
@ -140,6 +142,7 @@ class CallLogViewModel(val callLog: CallLog, private val isRelated: Boolean = fa
|
|||
|
||||
init {
|
||||
waitForChatRoomCreation.value = false
|
||||
readOnlyNativeAddressBook.value = corePreferences.readOnlyNativeContacts
|
||||
|
||||
if (!isRelated) {
|
||||
val conferenceInfo = callLog.conferenceInfo
|
||||
|
|
|
@ -24,7 +24,6 @@ import androidx.lifecycle.MediatorLiveData
|
|||
import androidx.lifecycle.MutableLiveData
|
||||
import androidx.lifecycle.ViewModel
|
||||
import org.linphone.LinphoneApplication.Companion.coreContext
|
||||
import org.linphone.LinphoneApplication.Companion.corePreferences
|
||||
import org.linphone.R
|
||||
import org.linphone.activities.voip.data.CallData
|
||||
import org.linphone.core.*
|
||||
|
|
|
@ -471,6 +471,10 @@ class CorePreferences constructor(private val context: Context) {
|
|||
val hideStaticImageCamera: Boolean
|
||||
get() = config.getBool("app", "hide_static_image_camera", true)
|
||||
|
||||
// Will prevent user adding contact and editing / removing existing contacts
|
||||
val readOnlyNativeContacts: Boolean
|
||||
get() = config.getBool("app", "read_only_native_address_book", false)
|
||||
|
||||
// Will disable chat feature completely
|
||||
val disableChat: Boolean
|
||||
get() = config.getBool("app", "disable_chat_feature", false)
|
||||
|
|
|
@ -81,7 +81,7 @@
|
|||
|
||||
<ImageView
|
||||
android:onClick="@{newContactClickListener}"
|
||||
android:visibility="@{viewModel.scheduleConferenceAvailable ? View.GONE : View.VISIBLE, default=gone}"
|
||||
android:visibility="@{viewModel.scheduleConferenceAvailable || viewModel.hideAddContactButton ? View.GONE : View.VISIBLE, default=gone}"
|
||||
android:enabled="@{viewModel.enteredUri.length() > 0}"
|
||||
android:contentDescription="@string/content_description_add_contact"
|
||||
android:layout_width="match_parent"
|
||||
|
|
|
@ -122,7 +122,7 @@
|
|||
|
||||
<ImageView
|
||||
android:onClick="@{newContactClickListener}"
|
||||
android:visibility="@{viewModel.scheduleConferenceAvailable ? View.GONE : View.VISIBLE, default=gone}"
|
||||
android:visibility="@{viewModel.scheduleConferenceAvailable || viewModel.hideAddContactButton ? View.GONE : View.VISIBLE, default=gone}"
|
||||
android:enabled="@{viewModel.enteredUri.length() > 0}"
|
||||
android:contentDescription="@string/content_description_add_contact"
|
||||
android:layout_width="match_parent"
|
||||
|
|
|
@ -122,7 +122,7 @@
|
|||
|
||||
<ImageView
|
||||
android:onClick="@{newContactClickListener}"
|
||||
android:visibility="@{viewModel.scheduleConferenceAvailable ? View.GONE : View.VISIBLE, default=gone}"
|
||||
android:visibility="@{viewModel.scheduleConferenceAvailable || viewModel.hideAddContactButton ? View.GONE : View.VISIBLE, default=gone}"
|
||||
android:enabled="@{viewModel.enteredUri.length() > 0}"
|
||||
android:contentDescription="@string/content_description_add_contact"
|
||||
android:layout_width="match_parent"
|
||||
|
|
|
@ -49,7 +49,7 @@
|
|||
|
||||
<ImageView
|
||||
android:onClick="@{editClickListener}"
|
||||
android:visibility="@{viewModel.isNativeContact ? View.VISIBLE : View.INVISIBLE}"
|
||||
android:visibility="@{viewModel.isNativeContact && !viewModel.readOnlyNativeAddressBook ? View.VISIBLE : View.INVISIBLE}"
|
||||
android:contentDescription="@string/content_description_edit_contact"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="match_parent"
|
||||
|
@ -60,7 +60,7 @@
|
|||
|
||||
<ImageView
|
||||
android:onClick="@{deleteClickListener}"
|
||||
android:visibility="@{viewModel.isNativeContact ? View.VISIBLE : View.INVISIBLE}"
|
||||
android:visibility="@{viewModel.isNativeContact && !viewModel.readOnlyNativeAddressBook ? View.VISIBLE : View.INVISIBLE}"
|
||||
android:contentDescription="@string/content_description_delete_contact"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="match_parent"
|
||||
|
|
|
@ -103,7 +103,7 @@
|
|||
android:background="?attr/button_background_drawable"
|
||||
android:padding="15dp"
|
||||
android:src="@drawable/contact_add"
|
||||
android:visibility="@{viewModel.nativeAddressBookEnabled ? View.VISIBLE : View.GONE}"/>
|
||||
android:visibility="@{viewModel.nativeAddressBookEnabled && !viewModel.readOnlyNativeAddressBook ? View.VISIBLE : View.INVISIBLE}"/>
|
||||
|
||||
<ImageView
|
||||
android:onClick="@{editClickListener}"
|
||||
|
@ -114,7 +114,8 @@
|
|||
android:layout_weight="0.2"
|
||||
android:background="?attr/button_background_drawable"
|
||||
android:padding="15dp"
|
||||
android:src="@drawable/delete" />
|
||||
android:src="@drawable/delete"
|
||||
android:visibility="@{viewModel.readOnlyNativeAddressBook ? View.INVISIBLE : View.VISIBLE}" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
|
|
|
@ -82,7 +82,7 @@
|
|||
|
||||
<ImageView
|
||||
android:onClick="@{newContactClickListener}"
|
||||
android:visibility="@{viewModel.scheduleConferenceAvailable ? View.GONE : View.VISIBLE, default=gone}"
|
||||
android:visibility="@{viewModel.scheduleConferenceAvailable || viewModel.hideAddContactButton ? View.GONE : View.VISIBLE, default=gone}"
|
||||
android:enabled="@{viewModel.enteredUri.length() > 0}"
|
||||
android:contentDescription="@string/content_description_add_contact"
|
||||
android:layout_width="match_parent"
|
||||
|
|
|
@ -49,7 +49,7 @@
|
|||
|
||||
<ImageView
|
||||
android:onClick="@{newContactClickListener}"
|
||||
android:visibility="@{viewModel.contact != null ? View.GONE : View.VISIBLE}"
|
||||
android:visibility="@{viewModel.contact != null || viewModel.readOnlyNativeAddressBook ? View.GONE : View.VISIBLE}"
|
||||
android:contentDescription="@string/content_description_add_contact"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="match_parent"
|
||||
|
|
Loading…
Reference in a new issue