mirror of
https://gitlab.linphone.org/BC/public/linphone-android.git
synced 2026-01-17 11:28:06 +00:00
Updated one_account_max to allow to set a different limit
This commit is contained in:
parent
f449763c4e
commit
811a0466d4
2 changed files with 11 additions and 3 deletions
|
|
@ -175,8 +175,8 @@ class CorePreferences @UiThread constructor(private val context: Context) {
|
|||
get() = config.getBool("ui", "disable_call_recordings_feature", false)
|
||||
|
||||
@get:WorkerThread
|
||||
val oneAccountMax: Boolean
|
||||
get() = config.getBool("ui", "one_account_max", false)
|
||||
val maxAccountsCount: Int
|
||||
get() = config.getInt("ui", "max_account", 0) // 0 means no max
|
||||
|
||||
@get:WorkerThread
|
||||
val hideSettings: Boolean
|
||||
|
|
|
|||
|
|
@ -171,6 +171,14 @@ class DrawerMenuViewModel @UiThread constructor() : GenericViewModel() {
|
|||
}
|
||||
accounts.postValue(list)
|
||||
|
||||
hideAddAccount.postValue(corePreferences.oneAccountMax && list.isNotEmpty())
|
||||
val maxAccount = corePreferences.maxAccountsCount
|
||||
val accountsCount = list.size
|
||||
val maxAccountsReached = maxAccount > 0 && accountsCount >= maxAccount
|
||||
if (maxAccountsReached) {
|
||||
Log.w(
|
||||
"$TAG Max number of allowed accounts reached [$maxAccount], hiding add account button"
|
||||
)
|
||||
}
|
||||
hideAddAccount.postValue(maxAccountsReached)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue