mirror of
https://gitlab.linphone.org/BC/public/linphone-android.git
synced 2026-01-17 03:18:06 +00:00
Hide SIP address field from contact editor when hide SIP addresses flag is set, and fixed issue where dialog with only 1 item would be displayed
This commit is contained in:
parent
0ca4eba63b
commit
df09bcad76
11 changed files with 34 additions and 78 deletions
|
|
@ -789,6 +789,7 @@ fun Friend.getPerson(): Person {
|
|||
@WorkerThread
|
||||
fun Friend.getListOfSipAddresses(): ArrayList<Address> {
|
||||
val addressesList = arrayListOf<Address>()
|
||||
if (corePreferences.hideSipAddresses) return addressesList
|
||||
|
||||
for (address in addresses) {
|
||||
if (addressesList.find { it.weakEqual(address) } == null) {
|
||||
|
|
@ -803,19 +804,19 @@ fun Friend.getListOfSipAddresses(): ArrayList<Address> {
|
|||
fun Friend.getListOfSipAddressesAndPhoneNumbers(listener: ContactNumberOrAddressClickListener): ArrayList<ContactNumberOrAddressModel> {
|
||||
val addressesAndNumbers = arrayListOf<ContactNumberOrAddressModel>()
|
||||
|
||||
if (!corePreferences.hideSipAddresses) {
|
||||
for (address in getListOfSipAddresses()) {
|
||||
val data = ContactNumberOrAddressModel(
|
||||
this,
|
||||
address,
|
||||
address.asStringUriOnly(),
|
||||
true, // SIP addresses are always enabled
|
||||
listener,
|
||||
true
|
||||
)
|
||||
addressesAndNumbers.add(data)
|
||||
}
|
||||
// Will return an empty list if corePreferences.hideSipAddresses == true
|
||||
for (address in getListOfSipAddresses()) {
|
||||
val data = ContactNumberOrAddressModel(
|
||||
this,
|
||||
address,
|
||||
address.asStringUriOnly(),
|
||||
true, // SIP addresses are always enabled
|
||||
listener,
|
||||
true
|
||||
)
|
||||
addressesAndNumbers.add(data)
|
||||
}
|
||||
|
||||
if (corePreferences.hidePhoneNumbers) {
|
||||
return addressesAndNumbers
|
||||
}
|
||||
|
|
|
|||
|
|
@ -361,15 +361,6 @@ class ActiveCallFragment : GenericCallFragment() {
|
|||
}
|
||||
}
|
||||
|
||||
callViewModel.chatRoomCreationErrorEvent.observe(viewLifecycleOwner) {
|
||||
it.consume { error ->
|
||||
(requireActivity() as GenericActivity).showRedToast(
|
||||
getString(error),
|
||||
R.drawable.warning_circle
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
callViewModel.goToConversationEvent.observe(viewLifecycleOwner) {
|
||||
it.consume { conversationId ->
|
||||
if (findNavController().currentDestination?.id == R.id.activeCallFragment) {
|
||||
|
|
|
|||
|
|
@ -220,10 +220,6 @@ class CurrentCallViewModel
|
|||
MutableLiveData<Event<String>>()
|
||||
}
|
||||
|
||||
val chatRoomCreationErrorEvent: MutableLiveData<Event<Int>> by lazy {
|
||||
MutableLiveData<Event<Int>>()
|
||||
}
|
||||
|
||||
// Conference
|
||||
|
||||
val conferenceModel = ConferenceViewModel()
|
||||
|
|
@ -429,9 +425,7 @@ class CurrentCallViewModel
|
|||
Log.e("$TAG Conversation [$id] creation has failed!")
|
||||
chatRoom.removeListener(this)
|
||||
operationInProgress.postValue(false)
|
||||
chatRoomCreationErrorEvent.postValue(
|
||||
Event(R.string.conversation_failed_to_create_toast)
|
||||
)
|
||||
showRedToast(R.string.conversation_failed_to_create_toast, R.drawable.warning_circle)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1434,9 +1428,7 @@ class CurrentCallViewModel
|
|||
"$TAG Failed to create 1-1 conversation with [${remoteAddress.asStringUriOnly()}]!"
|
||||
)
|
||||
operationInProgress.postValue(false)
|
||||
chatRoomCreationErrorEvent.postValue(
|
||||
Event(R.string.conversation_failed_to_create_toast)
|
||||
)
|
||||
showRedToast(R.string.conversation_failed_to_create_toast, R.drawable.warning_circle)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -99,16 +99,6 @@ class StartConversationFragment : GenericAddressPickerFragment() {
|
|||
}
|
||||
}
|
||||
|
||||
viewModel.chatRoomCreationErrorEvent.observe(viewLifecycleOwner) {
|
||||
it.consume { error ->
|
||||
Log.i("$TAG Conversation creation error, showing red toast")
|
||||
(requireActivity() as GenericActivity).showRedToast(
|
||||
getString(error),
|
||||
R.drawable.warning_circle
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
viewModel.defaultAccountChangedEvent.observe(viewLifecycleOwner) {
|
||||
it.consume {
|
||||
viewModel.updateGroupChatButtonVisibility()
|
||||
|
|
|
|||
|
|
@ -52,10 +52,6 @@ class StartConversationViewModel
|
|||
|
||||
val operationInProgress = MutableLiveData<Boolean>()
|
||||
|
||||
val chatRoomCreationErrorEvent: MutableLiveData<Event<Int>> by lazy {
|
||||
MutableLiveData<Event<Int>>()
|
||||
}
|
||||
|
||||
val chatRoomCreatedEvent: MutableLiveData<Event<String>> by lazy {
|
||||
MutableLiveData<Event<String>>()
|
||||
}
|
||||
|
|
@ -78,9 +74,7 @@ class StartConversationViewModel
|
|||
Log.e("$TAG Conversation [$id] creation has failed!")
|
||||
chatRoom.removeListener(this)
|
||||
operationInProgress.postValue(false)
|
||||
chatRoomCreationErrorEvent.postValue(
|
||||
Event(R.string.conversation_failed_to_create_toast)
|
||||
)
|
||||
showRedToast(R.string.conversation_failed_to_create_toast, R.drawable.warning_circle)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -159,9 +153,7 @@ class StartConversationViewModel
|
|||
} else {
|
||||
Log.e("$TAG Failed to create group conversation [$groupChatRoomSubject]!")
|
||||
operationInProgress.postValue(false)
|
||||
chatRoomCreationErrorEvent.postValue(
|
||||
Event(R.string.conversation_failed_to_create_toast)
|
||||
)
|
||||
showRedToast(R.string.conversation_failed_to_create_toast, R.drawable.warning_circle)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -212,9 +204,7 @@ class StartConversationViewModel
|
|||
"$TAG Account is in secure mode, can't chat with SIP address of different domain [${remote.asStringUriOnly()}]"
|
||||
)
|
||||
operationInProgress.postValue(false)
|
||||
chatRoomCreationErrorEvent.postValue(
|
||||
Event(R.string.conversation_invalid_participant_due_to_security_mode_toast)
|
||||
)
|
||||
showRedToast(R.string.conversation_invalid_participant_due_to_security_mode_toast, R.drawable.warning_circle)
|
||||
return
|
||||
}
|
||||
|
||||
|
|
@ -247,9 +237,7 @@ class StartConversationViewModel
|
|||
} else {
|
||||
Log.e("$TAG Failed to create 1-1 conversation with [${remote.asStringUriOnly()}]!")
|
||||
operationInProgress.postValue(false)
|
||||
chatRoomCreationErrorEvent.postValue(
|
||||
Event(R.string.conversation_failed_to_create_toast)
|
||||
)
|
||||
showRedToast(R.string.conversation_failed_to_create_toast, R.drawable.warning_circle)
|
||||
}
|
||||
} else {
|
||||
Log.w(
|
||||
|
|
|
|||
|
|
@ -66,6 +66,8 @@ class ContactNewOrEditViewModel
|
|||
|
||||
val sipAddresses = ArrayList<NewOrEditNumberOrAddressModel>()
|
||||
|
||||
val hideSipAddresses = MutableLiveData<Boolean>()
|
||||
|
||||
val phoneNumbers = ArrayList<NewOrEditNumberOrAddressModel>()
|
||||
|
||||
val company = MutableLiveData<String>()
|
||||
|
|
@ -82,6 +84,10 @@ class ContactNewOrEditViewModel
|
|||
|
||||
val removeNewNumberOrAddressFieldEvent = MutableLiveData<Event<NewOrEditNumberOrAddressModel>>()
|
||||
|
||||
init {
|
||||
hideSipAddresses.postValue(corePreferences.hideSipAddresses)
|
||||
}
|
||||
|
||||
@UiThread
|
||||
fun findFriendByRefKey(refKey: String?) {
|
||||
reset()
|
||||
|
|
|
|||
|
|
@ -99,10 +99,6 @@ class ContactViewModel
|
|||
|
||||
val operationInProgress = MutableLiveData<Boolean>()
|
||||
|
||||
val chatRoomCreationErrorEvent: MutableLiveData<Event<Int>> by lazy {
|
||||
MutableLiveData<Event<Int>>()
|
||||
}
|
||||
|
||||
val showLongPressMenuForNumberOrAddressEvent: MutableLiveData<Event<ContactNumberOrAddressModel>> by lazy {
|
||||
MutableLiveData<Event<ContactNumberOrAddressModel>>()
|
||||
}
|
||||
|
|
@ -214,9 +210,7 @@ class ContactViewModel
|
|||
Log.e("$TAG Conversation [$id] creation has failed!")
|
||||
chatRoom.removeListener(this)
|
||||
operationInProgress.postValue(false)
|
||||
chatRoomCreationErrorEvent.postValue(
|
||||
Event(R.string.conversation_failed_to_create_toast)
|
||||
)
|
||||
showRedToast(R.string.conversation_failed_to_create_toast, R.drawable.warning_circle)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -579,9 +573,7 @@ class ContactViewModel
|
|||
"$TAG Failed to create 1-1 conversation with [${remote.asStringUriOnly()}]!"
|
||||
)
|
||||
operationInProgress.postValue(false)
|
||||
chatRoomCreationErrorEvent.postValue(
|
||||
Event(R.string.conversation_failed_to_create_toast)
|
||||
)
|
||||
showRedToast(R.string.conversation_failed_to_create_toast, R.drawable.warning_circle)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -67,10 +67,6 @@ class HistoryViewModel
|
|||
|
||||
val callLogFoundEvent = MutableLiveData<Event<Boolean>>()
|
||||
|
||||
val chatRoomCreationErrorEvent: MutableLiveData<Event<Int>> by lazy {
|
||||
MutableLiveData<Event<Int>>()
|
||||
}
|
||||
|
||||
val goToMeetingConversationEvent: MutableLiveData<Event<String>> by lazy {
|
||||
MutableLiveData<Event<String>>()
|
||||
}
|
||||
|
|
@ -125,9 +121,7 @@ class HistoryViewModel
|
|||
Log.e("$TAG Conversation [$id] creation has failed!")
|
||||
chatRoom.removeListener(this)
|
||||
operationInProgress.postValue(false)
|
||||
chatRoomCreationErrorEvent.postValue(
|
||||
Event(R.string.conversation_failed_to_create_toast)
|
||||
)
|
||||
showRedToast(R.string.conversation_failed_to_create_toast, R.drawable.warning_circle)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -307,9 +301,7 @@ class HistoryViewModel
|
|||
"$TAG Failed to create 1-1 conversation with [${remote.asStringUriOnly()}]!"
|
||||
)
|
||||
operationInProgress.postValue(false)
|
||||
chatRoomCreationErrorEvent.postValue(
|
||||
Event(R.string.conversation_failed_to_create_toast)
|
||||
)
|
||||
showRedToast(R.string.conversation_failed_to_create_toast, R.drawable.warning_circle)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -142,7 +142,7 @@ class LinphoneUtils {
|
|||
}
|
||||
|
||||
val defaultDomain = corePreferences.defaultDomain
|
||||
val currentDomain = friend.core.defaultAccount?.params?.identityAddress?.domain
|
||||
val currentDomain = getDefaultAccount()?.params?.identityAddress?.domain
|
||||
if (defaultDomain != currentDomain) return null
|
||||
|
||||
var defaultDomainAddressesCount = 0
|
||||
|
|
|
|||
|
|
@ -316,6 +316,7 @@
|
|||
android:layout_height="wrap_content"
|
||||
android:layout_marginEnd="16dp"
|
||||
android:text="@string/sip_address"
|
||||
android:visibility="@{viewModel.hideSipAddresses ? View.GONE : View.VISIBLE}"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
app:layout_constraintStart_toStartOf="@id/sip_addresses"/>
|
||||
|
||||
|
|
@ -326,6 +327,7 @@
|
|||
android:layout_marginStart="16dp"
|
||||
android:layout_marginEnd="16dp"
|
||||
android:orientation="vertical"
|
||||
android:visibility="@{viewModel.hideSipAddresses ? View.GONE : View.VISIBLE}"
|
||||
app:layout_constraintWidth_max="@dimen/text_input_max_width"
|
||||
app:layout_constraintTop_toBottomOf="@id/sip_addresses_label"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
|
|
|
|||
|
|
@ -224,6 +224,7 @@
|
|||
android:layout_marginTop="30dp"
|
||||
android:layout_marginEnd="16dp"
|
||||
android:text="@string/sip_address"
|
||||
android:visibility="@{viewModel.hideSipAddresses ? View.GONE : View.VISIBLE}"
|
||||
app:layout_constraintTop_toBottomOf="@id/last_name"
|
||||
app:layout_constraintStart_toStartOf="@id/sip_addresses"/>
|
||||
|
||||
|
|
@ -234,6 +235,7 @@
|
|||
android:layout_marginStart="16dp"
|
||||
android:layout_marginEnd="16dp"
|
||||
android:orientation="vertical"
|
||||
android:visibility="@{viewModel.hideSipAddresses ? View.GONE : View.VISIBLE}"
|
||||
app:layout_constraintWidth_max="@dimen/text_input_max_width"
|
||||
app:layout_constraintTop_toBottomOf="@id/sip_addresses_label"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue