Skip to content
GitLab
Explore
Projects
Groups
Topics
Snippets
Projects
Groups
Topics
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
BC
public
linphone-android
Commits
31d92abc
Commit
31d92abc
authored
5 months ago
by
Sylvain Berfini
Browse files
Options
Download
Patches
Plain Diff
Update devices list when removing one
parent
92ec1940
master
feature/show_unsecure_conversation_event_at_top
feature/use_theme_main_color_for_icon_and_splashscreen
fix/insistent_notification
fix/restore_previous_release_ringtone_player
fix/telecom_default_audio_endpoint
release/6.0
6.1.0-alpha
6.0.0
6.0.0-beta
1 merge request
!1537
Prevent other accounts message notification header to be displayed when a...
Pipeline
#83673
passed with stage
in 5 minutes and 2 seconds
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
app/src/main/java/org/linphone/ui/main/settings/model/AccountDeviceModel.kt
+2
-2
...org/linphone/ui/main/settings/model/AccountDeviceModel.kt
app/src/main/java/org/linphone/ui/main/settings/viewmodel/AccountProfileViewModel.kt
+28
-11
...one/ui/main/settings/viewmodel/AccountProfileViewModel.kt
with
30 additions
and
13 deletions
app/src/main/java/org/linphone/ui/main/settings/model/AccountDeviceModel.kt
+
2
−
2
View file @
31d92abc
...
...
@@ -27,7 +27,7 @@ import org.linphone.utils.TimestampUtils
class
AccountDeviceModel
@WorkerThread
constructor
(
private
val
accountDevice
:
AccountDevice
,
private
val
onRemove
:
(
accountDevice
:
AccountDevice
)
->
(
Unit
)
private
val
onRemove
:
(
model
:
AccountDeviceModel
,
accountDevice
:
AccountDevice
)
->
(
Unit
)
)
{
companion
object
{
const
val
TAG
=
"[Account Device Model]"
...
...
@@ -63,6 +63,6 @@ class AccountDeviceModel @WorkerThread constructor(
}
fun
removeDevice
()
{
onRemove
(
accountDevice
)
onRemove
(
this
,
accountDevice
)
}
}
This diff is collapsed.
Click to expand it.
app/src/main/java/org/linphone/ui/main/settings/viewmodel/AccountProfileViewModel.kt
+
28
−
11
View file @
31d92abc
...
...
@@ -31,6 +31,7 @@ import org.linphone.core.AccountDevice
import
org.linphone.core.AccountManagerServices
import
org.linphone.core.AccountManagerServicesRequest
import
org.linphone.core.AccountManagerServicesRequestListenerStub
import
org.linphone.core.Address
import
org.linphone.core.DialPlan
import
org.linphone.core.Dictionary
import
org.linphone.core.Factory
...
...
@@ -98,7 +99,7 @@ class AccountProfileViewModel @UiThread constructor() : GenericViewModel() {
val
devicesList
=
arrayListOf
<
AccountDeviceModel
>()
for
(
accountDevice
in
accountDevices
)
{
devicesList
.
add
(
AccountDeviceModel
(
accountDevice
)
{
device
->
AccountDeviceModel
(
accountDevice
)
{
model
,
device
->
if
(
::
accountManagerServices
.
isInitialized
)
{
val
identityAddress
=
account
.
params
.
identityAddress
if
(
identityAddress
!=
null
)
{
...
...
@@ -111,6 +112,11 @@ class AccountProfileViewModel @UiThread constructor() : GenericViewModel() {
)
deleteRequest
.
addListener
(
this
)
deleteRequest
.
submit
()
val
newList
=
arrayListOf
<
AccountDeviceModel
>()
newList
.
addAll
(
devices
.
value
.
orEmpty
())
newList
.
remove
(
model
)
devices
.
postValue
(
newList
)
}
else
{
Log
.
e
(
"$TAG Account identity address is null, can't delete device!"
)
}
...
...
@@ -122,6 +128,12 @@ class AccountProfileViewModel @UiThread constructor() : GenericViewModel() {
devicesFetchInProgress
.
postValue
(
false
)
}
override
fun
onRequestSuccessful
(
request
:
AccountManagerServicesRequest
,
data
:
String
?)
{
if
(
request
.
type
==
AccountManagerServicesRequest
.
Type
.
DeleteDevice
)
{
Log
.
i
(
"$TAG Device successfully deleted: $data"
)
}
}
@WorkerThread
override
fun
onRequestError
(
request
:
AccountManagerServicesRequest
,
...
...
@@ -204,16 +216,7 @@ class AccountProfileViewModel @UiThread constructor() : GenericViewModel() {
val
defaultDomain
=
corePreferences
.
defaultDomain
isOnDefaultDomain
.
postValue
(
domain
==
defaultDomain
)
if
(
domain
==
defaultDomain
)
{
Log
.
i
(
"$TAG Request list of known devices for account [${identityAddress.asStringUriOnly()}]"
)
accountManagerServices
=
core
.
createAccountManagerServices
()
accountManagerServices
.
language
=
Locale
.
getDefault
().
language
// Returns en, fr, etc...
val
request
=
accountManagerServices
.
createGetDevicesListRequest
(
identityAddress
)
request
.
addListener
(
accountManagerServicesListener
)
request
.
submit
()
requestDevicesList
(
identityAddress
)
}
else
{
Log
.
i
(
"$TAG Account with domain [$domain] can't get devices list, only works with [$defaultDomain] domain"
...
...
@@ -385,4 +388,18 @@ class AccountProfileViewModel @UiThread constructor() : GenericViewModel() {
showDeviceId
.
value
=
true
return
true
}
@WorkerThread
private
fun
requestDevicesList
(
identityAddress
:
Address
)
{
Log
.
i
(
"$TAG Request devices list for identity address [${identityAddress.asStringUriOnly()}]"
)
accountManagerServices
=
coreContext
.
core
.
createAccountManagerServices
()
accountManagerServices
.
language
=
Locale
.
getDefault
().
language
// Returns en, fr, etc...
val
request
=
accountManagerServices
.
createGetDevicesListRequest
(
identityAddress
)
request
.
addListener
(
accountManagerServicesListener
)
request
.
submit
()
}
}
This diff is collapsed.
Click to expand it.
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment
Menu
Explore
Projects
Groups
Topics
Snippets