Show authentication requested dialog if needed
This commit is contained in:
parent
684f913254
commit
918b0d678d
4 changed files with 59 additions and 0 deletions
|
@ -58,6 +58,7 @@ import org.linphone.activities.main.viewmodels.SharedMainViewModel
|
|||
import org.linphone.activities.navigateToDialer
|
||||
import org.linphone.compatibility.Compatibility
|
||||
import org.linphone.contact.ContactsUpdatedListenerStub
|
||||
import org.linphone.core.AuthInfo
|
||||
import org.linphone.core.CorePreferences
|
||||
import org.linphone.core.tools.Log
|
||||
import org.linphone.databinding.MainActivityBinding
|
||||
|
@ -143,6 +144,14 @@ class MainActivity : GenericActivity(), SnackBarActivity, NavController.OnDestin
|
|||
}
|
||||
}
|
||||
|
||||
coreContext.authenticationRequestedEvent.observe(
|
||||
this
|
||||
) {
|
||||
it.consume { authInfo ->
|
||||
showAuthenticationRequestedDialog(authInfo)
|
||||
}
|
||||
}
|
||||
|
||||
if (coreContext.core.accountList.isEmpty()) {
|
||||
if (corePreferences.firstStart) {
|
||||
startActivity(Intent(this, AssistantActivity::class.java))
|
||||
|
@ -630,4 +639,43 @@ class MainActivity : GenericActivity(), SnackBarActivity, NavController.OnDestin
|
|||
|
||||
dialog.show()
|
||||
}
|
||||
|
||||
private fun showAuthenticationRequestedDialog(
|
||||
authInfo: AuthInfo
|
||||
) {
|
||||
val identity = "${authInfo.username}@${authInfo.domain}"
|
||||
Log.i("[Main Activity] Showing authentication required dialog for account [$identity]")
|
||||
|
||||
val dialogViewModel = DialogViewModel(
|
||||
getString(R.string.dialog_authentication_required_message, identity),
|
||||
getString(R.string.dialog_authentication_required_title)
|
||||
)
|
||||
dialogViewModel.showPassword = true
|
||||
dialogViewModel.passwordTitle = getString(
|
||||
R.string.settings_password_protection_dialog_input_hint
|
||||
)
|
||||
val dialog = DialogUtils.getDialog(this, dialogViewModel)
|
||||
|
||||
dialogViewModel.showCancelButton {
|
||||
dialog.dismiss()
|
||||
}
|
||||
|
||||
dialogViewModel.showOkButton(
|
||||
{
|
||||
Log.i(
|
||||
"[Main Activity] Updating password for account [$identity] using auth info [$authInfo]"
|
||||
)
|
||||
val newPassword = dialogViewModel.password
|
||||
authInfo.password = newPassword
|
||||
coreContext.core.addAuthInfo(authInfo)
|
||||
|
||||
coreContext.core.refreshRegisters()
|
||||
|
||||
dialog.dismiss()
|
||||
},
|
||||
getString(R.string.dialog_authentication_required_change_password_label)
|
||||
)
|
||||
|
||||
dialog.show()
|
||||
}
|
||||
}
|
||||
|
|
|
@ -117,6 +117,10 @@ class CoreContext(
|
|||
MutableLiveData<Event<String>>()
|
||||
}
|
||||
|
||||
val authenticationRequestedEvent: MutableLiveData<Event<AuthInfo>> by lazy {
|
||||
MutableLiveData<Event<AuthInfo>>()
|
||||
}
|
||||
|
||||
val coroutineScope = CoroutineScope(Dispatchers.Main + SupervisorJob())
|
||||
|
||||
private val loggingService = Factory.instance().loggingService
|
||||
|
@ -169,6 +173,7 @@ class CoreContext(
|
|||
Log.w(
|
||||
"[Context] Authentication requested for account [${authInfo.username}@${authInfo.domain}] with realm [${authInfo.realm}] using method [$method]"
|
||||
)
|
||||
authenticationRequestedEvent.value = Event(authInfo)
|
||||
}
|
||||
|
||||
override fun onPushNotificationReceived(core: Core, payload: String?) {
|
||||
|
|
|
@ -785,4 +785,7 @@
|
|||
<string name="assistant_alternative_way_create_account">Pour créer un compte avec votre email :</string>
|
||||
<string name="assistant_no_push_warning">Votre périphérique ne semble pas supporter les notifications \'push\'.\n\nVous ne pourrez donc pas créer des comptes dans l\'application mais vous pouvez toujours le faire sur notre site internet :</string>
|
||||
<string name="assistant_create_email_account_not_validated">Votre compte n\'est pas activé, veuillez cliquer sur le lien que vous avez reçu par courriel</string>
|
||||
<string name="dialog_authentication_required_title">Authentification requise</string>
|
||||
<string name="dialog_authentication_required_message">La connexion a échouée car l\'authentification est manquante ou invalide pour le compte\n%s.\n\nVous pouvez fournir le mot de passe à nouveau ou vérifier la configuration de votre compte dans les paramètres.</string>
|
||||
<string name="dialog_authentication_required_change_password_label">Confirmer</string>
|
||||
</resources>
|
|
@ -774,6 +774,9 @@
|
|||
<string name="dialog_try_open_file_as_text_body">Would you like to try opening it as a plain text file?</string>
|
||||
<string name="dialog_apply_remote_provisioning_title">Do you want to download and apply configuration from this URL?</string>
|
||||
<string name="dialog_apply_remote_provisioning_button">Apply</string>
|
||||
<string name="dialog_authentication_required_title">Authentication needed</string>
|
||||
<string name="dialog_authentication_required_message">Connection failed because authentication is missing or invalid for account \n%s.\n\nYou can provide password again, or check your account configuration in the settings.</string>
|
||||
<string name="dialog_authentication_required_change_password_label">Confirm</string>
|
||||
|
||||
<!-- Content description -->
|
||||
<string name="content_description_add_sip_address_field">Add a SIP address field</string>
|
||||
|
|
Loading…
Reference in a new issue