mirror of
https://gitlab.linphone.org/BC/public/linphone-android.git
synced 2026-01-17 11:28:06 +00:00
Fixed issue when creating a new contact
This commit is contained in:
parent
9fcdb2bffa
commit
565e957387
4 changed files with 18 additions and 18 deletions
|
|
@ -131,9 +131,6 @@ class ContactNewOrEditViewModel @UiThread constructor() : ViewModel() {
|
|||
|
||||
if (!::friend.isInitialized) {
|
||||
friend = core.createFriend()
|
||||
friend.isSubscribesEnabled = false
|
||||
// Disable peer to peer short term presence
|
||||
friend.incSubscribePolicy = SubscribePolicy.SPDeny
|
||||
}
|
||||
val fn = firstName.value.orEmpty().trim()
|
||||
val ln = lastName.value.orEmpty().trim()
|
||||
|
|
@ -188,6 +185,11 @@ class ContactNewOrEditViewModel @UiThread constructor() : ViewModel() {
|
|||
Log.e("$TAG Failed to generate a ref key using vCard's generateUniqueId()")
|
||||
// TODO? : generate unique ref key
|
||||
}
|
||||
|
||||
friend.isSubscribesEnabled = false
|
||||
// Disable peer to peer short term presence
|
||||
friend.incSubscribePolicy = SubscribePolicy.SPDeny
|
||||
|
||||
friend.done()
|
||||
|
||||
val fl = core.getFriendListByName(LINPHONE_ADDRESS_BOOK_FRIEND_LIST) ?: core.createFriendList()
|
||||
|
|
@ -200,6 +202,7 @@ class ContactNewOrEditViewModel @UiThread constructor() : ViewModel() {
|
|||
core.addFriendList(fl)
|
||||
}
|
||||
status = fl.addFriend(friend)
|
||||
Log.e("UPDATE SUB")
|
||||
fl.updateSubscriptions()
|
||||
} else {
|
||||
friend.done()
|
||||
|
|
|
|||
|
|
@ -47,16 +47,12 @@ class AccountModel @WorkerThread constructor(
|
|||
|
||||
val initials = MutableLiveData<String>()
|
||||
|
||||
val registrationState = MutableLiveData<String>()
|
||||
val registrationState = MutableLiveData<RegistrationState>()
|
||||
|
||||
val registrationStateLabel = MutableLiveData<String>()
|
||||
|
||||
val registrationStateSummary = MutableLiveData<String>()
|
||||
|
||||
val isConnected = MutableLiveData<Boolean>()
|
||||
|
||||
val inError = MutableLiveData<Boolean>()
|
||||
|
||||
val isDisabled = MutableLiveData<Boolean>()
|
||||
|
||||
val isDefault = MutableLiveData<Boolean>()
|
||||
|
||||
val showTrust = MutableLiveData<Boolean>()
|
||||
|
|
@ -142,9 +138,11 @@ class AccountModel @WorkerThread constructor(
|
|||
|
||||
isDefault.postValue(coreContext.core.defaultAccount == account)
|
||||
|
||||
val state = when (account.state) {
|
||||
val state = account.state
|
||||
registrationState.postValue(state)
|
||||
|
||||
val label = when (state) {
|
||||
RegistrationState.None, RegistrationState.Cleared -> {
|
||||
isDisabled.postValue(true)
|
||||
AppUtils.getString(
|
||||
R.string.drawer_menu_account_connection_status_cleared
|
||||
)
|
||||
|
|
@ -153,13 +151,11 @@ class AccountModel @WorkerThread constructor(
|
|||
R.string.drawer_menu_account_connection_status_progress
|
||||
)
|
||||
RegistrationState.Failed -> {
|
||||
inError.postValue(true)
|
||||
AppUtils.getString(
|
||||
R.string.drawer_menu_account_connection_status_failed
|
||||
)
|
||||
}
|
||||
RegistrationState.Ok -> {
|
||||
isConnected.postValue(true)
|
||||
AppUtils.getString(
|
||||
R.string.drawer_menu_account_connection_status_connected
|
||||
)
|
||||
|
|
@ -169,7 +165,7 @@ class AccountModel @WorkerThread constructor(
|
|||
)
|
||||
else -> "${account.state}"
|
||||
}
|
||||
registrationState.postValue(state)
|
||||
registrationStateLabel.postValue(label)
|
||||
|
||||
val summary = when (account.state) {
|
||||
RegistrationState.None, RegistrationState.Cleared -> AppUtils.getString(
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@
|
|||
<data>
|
||||
<import type="android.view.View" />
|
||||
<import type="android.graphics.Typeface" />
|
||||
<import type="org.linphone.core.RegistrationState" />
|
||||
<variable
|
||||
name="model"
|
||||
type="org.linphone.ui.main.model.AccountModel" />
|
||||
|
|
@ -84,8 +85,8 @@
|
|||
android:paddingBottom="4dp"
|
||||
android:background="@drawable/shape_squircle_main2_200_background"
|
||||
android:gravity="center"
|
||||
android:text="@{model.registrationState, default=@string/drawer_menu_account_connection_status_connected}"
|
||||
android:textColor="@{model.isConnected ? @color/green_success_500 : model.inError ? @color/red_danger_500 : model.isDisabled ? @color/orange_warning_600 : @color/gray_main2_500, default=@color/green_success_500}"
|
||||
android:text="@{model.registrationStateLabel, default=@string/drawer_menu_account_connection_status_connected}"
|
||||
android:textColor="@{model.registrationState == RegistrationState.Ok ? @color/green_success_500 : model.registrationState == RegistrationState.Failed ? @color/red_danger_500 : model.registrationState == RegistrationState.Cleared || model.registrationState == RegistrationState.None ? @color/orange_warning_600 : @color/gray_main2_500, default=@color/green_success_500}"
|
||||
android:textSize="12sp"
|
||||
app:layout_constraintHorizontal_bias="0"
|
||||
app:layout_constraintStart_toStartOf="@id/name"
|
||||
|
|
|
|||
|
|
@ -263,7 +263,7 @@
|
|||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="16dp"
|
||||
android:text="@{viewModel.accountModel.registrationState, default=@string/drawer_menu_account_connection_status_connected}"
|
||||
android:text="@{viewModel.accountModel.registrationStateLabel, default=@string/drawer_menu_account_connection_status_connected}"
|
||||
app:layout_constraintStart_toEndOf="@id/connected_switch"
|
||||
app:layout_constraintTop_toTopOf="@id/connected_switch"
|
||||
app:layout_constraintBottom_toBottomOf="@id/connected_switch" />
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue