mirror of
https://gitlab.linphone.org/BC/public/linphone-android.git
synced 2026-01-17 11:28:06 +00:00
Disable phone numbers if default account is in secure mode
This commit is contained in:
parent
8bba5ea2b6
commit
5ebaf24c04
9 changed files with 60 additions and 30 deletions
|
|
@ -42,6 +42,7 @@ import org.linphone.ui.main.contacts.model.ContactNumberOrAddressModel
|
|||
import org.linphone.ui.main.contacts.model.NumberOrAddressPickerDialogModel
|
||||
import org.linphone.ui.main.contacts.viewmodel.ContactsListViewModel
|
||||
import org.linphone.ui.main.fragment.GenericFragment
|
||||
import org.linphone.ui.main.model.isInSecureMode
|
||||
import org.linphone.utils.DialogUtils
|
||||
|
||||
@UiThread
|
||||
|
|
@ -154,10 +155,14 @@ class StartCallFragment : GenericFragment() {
|
|||
val friend = model.friend
|
||||
val addressesCount = friend.addresses.size
|
||||
val numbersCount = friend.phoneNumbers.size
|
||||
if (addressesCount == 1 && numbersCount == 0) {
|
||||
|
||||
// Do not consider phone numbers if default account is in secure mode
|
||||
val enablePhoneNumbers = core.defaultAccount?.isInSecureMode() != true
|
||||
|
||||
if (addressesCount == 1 && (numbersCount == 0 || !enablePhoneNumbers)) {
|
||||
val address = friend.addresses.first()
|
||||
coreContext.startCall(address)
|
||||
} else if (addressesCount == 1 && numbersCount == 0) {
|
||||
} else if (addressesCount == 0 && numbersCount == 1 && enablePhoneNumbers) {
|
||||
val number = friend.phoneNumbers.first()
|
||||
val address = core.interpretUrl(number, true)
|
||||
if (address != null) {
|
||||
|
|
@ -169,22 +174,26 @@ class StartCallFragment : GenericFragment() {
|
|||
val addressModel = ContactNumberOrAddressModel(
|
||||
address,
|
||||
address.asStringUriOnly(),
|
||||
true,
|
||||
listener,
|
||||
true
|
||||
)
|
||||
list.add(addressModel)
|
||||
}
|
||||
|
||||
for (number in friend.phoneNumbersWithLabel) {
|
||||
val address = core.interpretUrl(number.phoneNumber, true)
|
||||
val addressModel = ContactNumberOrAddressModel(
|
||||
address,
|
||||
number.phoneNumber,
|
||||
listener,
|
||||
false,
|
||||
number.label.orEmpty()
|
||||
)
|
||||
list.add(addressModel)
|
||||
if (enablePhoneNumbers) {
|
||||
for (number in friend.phoneNumbersWithLabel) {
|
||||
val address = core.interpretUrl(number.phoneNumber, true)
|
||||
val addressModel = ContactNumberOrAddressModel(
|
||||
address,
|
||||
number.phoneNumber,
|
||||
true,
|
||||
listener,
|
||||
false,
|
||||
number.label.orEmpty()
|
||||
)
|
||||
list.add(addressModel)
|
||||
}
|
||||
}
|
||||
|
||||
coreContext.postOnMainThread {
|
||||
|
|
|
|||
|
|
@ -33,6 +33,7 @@ import org.linphone.core.MagicSearchListenerStub
|
|||
import org.linphone.core.SearchResult
|
||||
import org.linphone.core.tools.Log
|
||||
import org.linphone.ui.main.contacts.model.ContactAvatarModel
|
||||
import org.linphone.ui.main.model.isInSecureMode
|
||||
|
||||
class SuggestionsListViewModel @UiThread constructor() : ViewModel() {
|
||||
companion object {
|
||||
|
|
@ -70,6 +71,9 @@ class SuggestionsListViewModel @UiThread constructor() : ViewModel() {
|
|||
|
||||
init {
|
||||
coreContext.postOnCoreThread { core ->
|
||||
val defaultAccount = core.defaultAccount
|
||||
limitSearchToLinphoneAccounts = defaultAccount?.isInSecureMode() ?: false
|
||||
|
||||
coreContext.contactsManager.addListener(contactsListener)
|
||||
magicSearch = core.createMagicSearch()
|
||||
magicSearch.limitedSearch = false
|
||||
|
|
|
|||
|
|
@ -26,6 +26,7 @@ import org.linphone.core.Address
|
|||
class ContactNumberOrAddressModel @UiThread constructor(
|
||||
val address: Address?,
|
||||
val displayedValue: String,
|
||||
val isEnabled: Boolean,
|
||||
private val listener: ContactNumberOrAddressClickListener,
|
||||
val isSip: Boolean = true,
|
||||
val label: String = ""
|
||||
|
|
|
|||
|
|
@ -34,6 +34,7 @@ import org.linphone.ui.main.contacts.model.ContactAvatarModel
|
|||
import org.linphone.ui.main.contacts.model.ContactDeviceModel
|
||||
import org.linphone.ui.main.contacts.model.ContactNumberOrAddressClickListener
|
||||
import org.linphone.ui.main.contacts.model.ContactNumberOrAddressModel
|
||||
import org.linphone.ui.main.model.isInSecureMode
|
||||
import org.linphone.utils.Event
|
||||
import org.linphone.utils.FileUtils
|
||||
|
||||
|
|
@ -56,9 +57,9 @@ class ContactViewModel @UiThread constructor() : ViewModel() {
|
|||
|
||||
val showBackButton = MutableLiveData<Boolean>()
|
||||
|
||||
val showNumbersAndAddresses = MutableLiveData<Boolean>()
|
||||
val expandNumbersAndAddresses = MutableLiveData<Boolean>()
|
||||
|
||||
val showDevicesTrust = MutableLiveData<Boolean>()
|
||||
val expandDevicesTrust = MutableLiveData<Boolean>()
|
||||
|
||||
val contactFoundEvent = MutableLiveData<Event<Boolean>>()
|
||||
|
||||
|
|
@ -101,8 +102,8 @@ class ContactViewModel @UiThread constructor() : ViewModel() {
|
|||
private lateinit var friend: Friend
|
||||
|
||||
init {
|
||||
showNumbersAndAddresses.value = true
|
||||
showDevicesTrust.value = false // TODO FIXME: set it to true when it will work for real
|
||||
expandNumbersAndAddresses.value = true
|
||||
expandDevicesTrust.value = false // TODO FIXME: set it to true when it will work for real
|
||||
}
|
||||
|
||||
@UiThread
|
||||
|
|
@ -129,6 +130,7 @@ class ContactViewModel @UiThread constructor() : ViewModel() {
|
|||
val data = ContactNumberOrAddressModel(
|
||||
address,
|
||||
address.asStringUriOnly(),
|
||||
true, // SIP addresses are always enabled
|
||||
listener,
|
||||
true
|
||||
)
|
||||
|
|
@ -151,6 +153,7 @@ class ContactViewModel @UiThread constructor() : ViewModel() {
|
|||
val data = ContactNumberOrAddressModel(
|
||||
address,
|
||||
address.asStringUriOnly(),
|
||||
true, // SIP addresses are always enabled
|
||||
listener,
|
||||
true
|
||||
)
|
||||
|
|
@ -159,10 +162,13 @@ class ContactViewModel @UiThread constructor() : ViewModel() {
|
|||
}
|
||||
}
|
||||
|
||||
// phone numbers are disabled is secure mode
|
||||
val enablePhoneNumbers = core.defaultAccount?.isInSecureMode() != true
|
||||
val address = core.interpretUrl(number.phoneNumber, true)
|
||||
val data = ContactNumberOrAddressModel(
|
||||
address,
|
||||
number.phoneNumber,
|
||||
enablePhoneNumbers,
|
||||
listener,
|
||||
false,
|
||||
label = number.label.orEmpty()
|
||||
|
|
@ -172,7 +178,7 @@ class ContactViewModel @UiThread constructor() : ViewModel() {
|
|||
sipAddressesAndPhoneNumbers.postValue(addressesAndNumbers)
|
||||
|
||||
val devicesList = arrayListOf<ContactDeviceModel>()
|
||||
// TODO FIXME
|
||||
// TODO FIXME: use real devices list from API
|
||||
devicesList.add(ContactDeviceModel("Pixel 6 Pro de Sylvain", true))
|
||||
devicesList.add(ContactDeviceModel("Sylvain Galaxy Tab S9 Pro+ Ultra", true))
|
||||
devicesList.add(ContactDeviceModel("MacBook Pro de Marcel", false))
|
||||
|
|
@ -185,13 +191,13 @@ class ContactViewModel @UiThread constructor() : ViewModel() {
|
|||
}
|
||||
|
||||
@UiThread
|
||||
fun toggleNumbersAndAddressesVisibility() {
|
||||
showNumbersAndAddresses.value = showNumbersAndAddresses.value == false
|
||||
fun toggleNumbersAndAddressesExpand() {
|
||||
expandNumbersAndAddresses.value = expandNumbersAndAddresses.value == false
|
||||
}
|
||||
|
||||
@UiThread
|
||||
fun toggleDevicesTrustVisibility() {
|
||||
showDevicesTrust.value = showDevicesTrust.value == false
|
||||
fun toggleDevicesTrustExpand() {
|
||||
expandDevicesTrust.value = expandDevicesTrust.value == false
|
||||
}
|
||||
|
||||
@UiThread
|
||||
|
|
|
|||
|
|
@ -33,6 +33,7 @@ import org.linphone.core.MagicSearchListenerStub
|
|||
import org.linphone.core.SearchResult
|
||||
import org.linphone.core.tools.Log
|
||||
import org.linphone.ui.main.contacts.model.ContactAvatarModel
|
||||
import org.linphone.ui.main.model.isInSecureMode
|
||||
|
||||
class ContactsListViewModel @UiThread constructor() : ViewModel() {
|
||||
companion object {
|
||||
|
|
@ -78,6 +79,9 @@ class ContactsListViewModel @UiThread constructor() : ViewModel() {
|
|||
showFavourites.value = true
|
||||
|
||||
coreContext.postOnCoreThread { core ->
|
||||
val defaultAccount = core.defaultAccount
|
||||
limitSearchToLinphoneAccounts = defaultAccount?.isInSecureMode() ?: false
|
||||
|
||||
coreContext.contactsManager.addListener(contactsListener)
|
||||
magicSearch = core.createMagicSearch()
|
||||
magicSearch.limitedSearch = false
|
||||
|
|
|
|||
|
|
@ -34,7 +34,7 @@ import org.linphone.core.tools.Log
|
|||
import org.linphone.ui.main.conversations.data.EventLogData
|
||||
import org.linphone.utils.LinphoneUtils
|
||||
|
||||
class ConversationViewModel @WorkerThread constructor(): ViewModel() {
|
||||
class ConversationViewModel @WorkerThread constructor() : ViewModel() {
|
||||
private lateinit var chatRoom: ChatRoom
|
||||
|
||||
val events = MutableLiveData<ArrayList<EventLogData>>()
|
||||
|
|
|
|||
|
|
@ -119,3 +119,8 @@ fun Account.getPicturePath(): String {
|
|||
overrideExisting = true
|
||||
).absolutePath
|
||||
}
|
||||
|
||||
fun Account.isInSecureMode(): Boolean {
|
||||
// TODO FIXME
|
||||
return true
|
||||
}
|
||||
|
|
|
|||
|
|
@ -99,7 +99,7 @@
|
|||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
app:constraint_referenced_ids="trusted_devices_count, trust_background, trusted_devices_progress, devices, trusted_devices_progress_label"
|
||||
android:visibility="@{viewModel.showDevicesTrust ? View.VISIBLE : View.GONE}" />
|
||||
android:visibility="@{viewModel.expandDevicesTrust ? View.VISIBLE : View.GONE}" />
|
||||
|
||||
<io.getstream.avatarview.AvatarView
|
||||
android:id="@+id/avatar"
|
||||
|
|
@ -241,7 +241,7 @@
|
|||
|
||||
<androidx.appcompat.widget.AppCompatTextView
|
||||
style="@style/default_text_style_800"
|
||||
android:onClick="@{() -> viewModel.toggleNumbersAndAddressesVisibility()}"
|
||||
android:onClick="@{() -> viewModel.toggleNumbersAndAddressesExpand()}"
|
||||
android:id="@+id/numbers_and_addresses_label"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
|
|
@ -250,7 +250,7 @@
|
|||
android:layout_marginEnd="26dp"
|
||||
android:layout_marginTop="32dp"
|
||||
android:text="Numbers & addresses"
|
||||
android:drawableEnd="@{viewModel.showNumbersAndAddresses ? @drawable/collapse : @drawable/expand, default=@drawable/collapse}"
|
||||
android:drawableEnd="@{viewModel.expandNumbersAndAddresses ? @drawable/collapse : @drawable/expand, default=@drawable/collapse}"
|
||||
android:drawableTint="@color/gray_9"
|
||||
android:textSize="16sp"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
|
|
@ -259,7 +259,7 @@
|
|||
|
||||
<LinearLayout
|
||||
android:id="@+id/numbers_and_addresses"
|
||||
android:visibility="@{viewModel.showNumbersAndAddresses ? View.VISIBLE : View.GONE}"
|
||||
android:visibility="@{viewModel.expandNumbersAndAddresses ? View.VISIBLE : View.GONE}"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical"
|
||||
|
|
@ -348,7 +348,7 @@
|
|||
|
||||
<androidx.appcompat.widget.AppCompatTextView
|
||||
style="@style/default_text_style_800"
|
||||
android:onClick="@{() -> viewModel.toggleDevicesTrustVisibility()}"
|
||||
android:onClick="@{() -> viewModel.toggleDevicesTrustExpand()}"
|
||||
android:id="@+id/trust_label"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
|
|
@ -357,7 +357,7 @@
|
|||
android:layout_marginEnd="26dp"
|
||||
android:layout_marginTop="16dp"
|
||||
android:text="Trust"
|
||||
android:drawableEnd="@{viewModel.showDevicesTrust ? @drawable/collapse : @drawable/expand, default=@drawable/collapse}"
|
||||
android:drawableEnd="@{viewModel.expandDevicesTrust ? @drawable/collapse : @drawable/expand, default=@drawable/collapse}"
|
||||
android:drawableTint="@color/gray_9"
|
||||
android:textSize="16sp"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
|
|
|
|||
|
|
@ -50,9 +50,10 @@
|
|||
android:id="@+id/call"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:src="@drawable/calls"
|
||||
app:tint="@color/gray_9"
|
||||
android:layout_marginEnd="10dp"
|
||||
android:src="@drawable/calls"
|
||||
android:visibility="@{model.enabled ? View.VISIBLE : View.GONE}"
|
||||
app:tint="@color/gray_9"
|
||||
app:layout_constraintTop_toTopOf="@id/header"
|
||||
app:layout_constraintBottom_toBottomOf="@id/number_or_address"
|
||||
app:layout_constraintEnd_toEndOf="parent" />
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue