mirror of
https://gitlab.linphone.org/BC/public/linphone-android.git
synced 2026-05-07 05:53:07 +00:00
Added toast when new account is successfully configured + set first available account as default when previous one was removed
This commit is contained in:
parent
fa796b9609
commit
e9f19b6834
3 changed files with 45 additions and 0 deletions
|
|
@ -144,6 +144,13 @@ class MainActivity : GenericActivity() {
|
|||
}
|
||||
}
|
||||
|
||||
viewModel.showNewAccountToastEvent.observe(this) {
|
||||
it.consume {
|
||||
val message = getString(R.string.toast_new_account_configured)
|
||||
showGreenToast(message, R.drawable.user_circle)
|
||||
}
|
||||
}
|
||||
|
||||
binding.root.doOnAttach {
|
||||
Log.i("$TAG Report UI has been fully drawn (TTFD)")
|
||||
try {
|
||||
|
|
@ -259,8 +266,15 @@ class MainActivity : GenericActivity() {
|
|||
super.onPause()
|
||||
}
|
||||
|
||||
override fun onResume() {
|
||||
super.onResume()
|
||||
|
||||
viewModel.checkForNewAccount()
|
||||
}
|
||||
|
||||
override fun onNewIntent(intent: Intent?) {
|
||||
super.onNewIntent(intent)
|
||||
|
||||
if (intent != null) {
|
||||
handleIntent(intent, -1, true)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -80,6 +80,12 @@ class MainViewModel @UiThread constructor() : ViewModel() {
|
|||
MutableLiveData<Event<Boolean>>()
|
||||
}
|
||||
|
||||
val showNewAccountToastEvent: MutableLiveData<Event<Boolean>> by lazy {
|
||||
MutableLiveData<Event<Boolean>>()
|
||||
}
|
||||
|
||||
var accountsFound = -1
|
||||
|
||||
private var defaultAccountRegistrationFailed = false
|
||||
|
||||
private val alertsList = arrayListOf<Pair<Int, String>>()
|
||||
|
|
@ -196,6 +202,17 @@ class MainViewModel @UiThread constructor() : ViewModel() {
|
|||
|
||||
// TODO: compute other calls notifications count
|
||||
}
|
||||
|
||||
override fun onAccountRemoved(core: Core, account: Account) {
|
||||
accountsFound -= 1
|
||||
|
||||
if (core.defaultAccount == null) {
|
||||
Log.i(
|
||||
"$TAG Default account was removed, setting first available account (if any) as default"
|
||||
)
|
||||
core.defaultAccount = core.accountList.firstOrNull()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
init {
|
||||
|
|
@ -203,6 +220,8 @@ class MainViewModel @UiThread constructor() : ViewModel() {
|
|||
showAlert.value = false
|
||||
|
||||
coreContext.postOnCoreThread { core ->
|
||||
accountsFound = core.accountList.size
|
||||
|
||||
core.addListener(coreListener)
|
||||
|
||||
if (!core.isNetworkReachable) {
|
||||
|
|
@ -227,6 +246,17 @@ class MainViewModel @UiThread constructor() : ViewModel() {
|
|||
}
|
||||
}
|
||||
|
||||
@UiThread
|
||||
fun checkForNewAccount() {
|
||||
coreContext.postOnCoreThread { core ->
|
||||
val count = core.accountList.size
|
||||
if (count > accountsFound) {
|
||||
showNewAccountToastEvent.postValue(Event(true))
|
||||
}
|
||||
accountsFound = count
|
||||
}
|
||||
}
|
||||
|
||||
@UiThread
|
||||
fun closeTopBar() {
|
||||
showAlert.value = false
|
||||
|
|
|
|||
|
|
@ -132,6 +132,7 @@
|
|||
<string name="toast_alert_low_cellular_signal">Low cellular signal!</string>
|
||||
<string name="toast_alert_low_cellular_signal_cleared">Cellular signal is no longer low</string>
|
||||
<string name="toast_call_can_be_trusted">This call can be trusted</string>
|
||||
<string name="toast_new_account_configured">Connection successful</string>
|
||||
<string name="toast_default_account_connection_state_error">Connection error!</string>
|
||||
<string name="toast_file_successfully_exported_to_media_store">File has been exported to native gallery</string>
|
||||
<string name="toast_export_file_to_media_store_error">Error trying to export file to native gallery</string>
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue