Added forgot password link on linphone account assistant + updated invalid credentials dialog to allow continuing even if not registered
This commit is contained in:
parent
bf24a6b2a9
commit
01b3162392
6 changed files with 68 additions and 12 deletions
|
@ -20,6 +20,8 @@
|
||||||
package org.linphone.activities.assistant.fragments
|
package org.linphone.activities.assistant.fragments
|
||||||
|
|
||||||
import android.app.Dialog
|
import android.app.Dialog
|
||||||
|
import android.content.Intent
|
||||||
|
import android.net.Uri
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
import android.view.LayoutInflater
|
import android.view.LayoutInflater
|
||||||
import android.view.View
|
import android.view.View
|
||||||
|
@ -74,6 +76,13 @@ class AccountLoginFragment : AbstractPhoneFragment() {
|
||||||
CountryPickerFragment(viewModel).show(childFragmentManager, "CountryPicker")
|
CountryPickerFragment(viewModel).show(childFragmentManager, "CountryPicker")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
binding.setForgotPasswordClickListener {
|
||||||
|
val intent = Intent(Intent.ACTION_VIEW)
|
||||||
|
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
|
||||||
|
intent.data = Uri.parse(getString(R.string.assistant_forgotten_password_link))
|
||||||
|
startActivity(intent)
|
||||||
|
}
|
||||||
|
|
||||||
viewModel.goToSmsValidationEvent.observe(viewLifecycleOwner, Observer {
|
viewModel.goToSmsValidationEvent.observe(viewLifecycleOwner, Observer {
|
||||||
it.consume {
|
it.consume {
|
||||||
if (findNavController().currentDestination?.id == R.id.accountLoginFragment) {
|
if (findNavController().currentDestination?.id == R.id.accountLoginFragment) {
|
||||||
|
@ -102,9 +111,15 @@ class AccountLoginFragment : AbstractPhoneFragment() {
|
||||||
val dialogViewModel = DialogViewModel(getString(R.string.assistant_error_invalid_credentials))
|
val dialogViewModel = DialogViewModel(getString(R.string.assistant_error_invalid_credentials))
|
||||||
val dialog: Dialog = DialogUtils.getDialog(requireContext(), dialogViewModel)
|
val dialog: Dialog = DialogUtils.getDialog(requireContext(), dialogViewModel)
|
||||||
|
|
||||||
dialogViewModel.showDeleteButton({
|
dialogViewModel.showCancelButton {
|
||||||
|
viewModel.removeInvalidProxyConfig()
|
||||||
dialog.dismiss()
|
dialog.dismiss()
|
||||||
}, getString(R.string.dialog_ok))
|
}
|
||||||
|
|
||||||
|
dialogViewModel.showDeleteButton({
|
||||||
|
viewModel.continueEvenIfInvalidCredentials()
|
||||||
|
dialog.dismiss()
|
||||||
|
}, getString(R.string.assistant_continue_even_if_credentials_invalid))
|
||||||
|
|
||||||
dialog.show()
|
dialog.show()
|
||||||
}
|
}
|
||||||
|
|
|
@ -80,9 +80,15 @@ class GenericAccountLoginFragment : Fragment() {
|
||||||
val dialogViewModel = DialogViewModel(getString(R.string.assistant_error_invalid_credentials))
|
val dialogViewModel = DialogViewModel(getString(R.string.assistant_error_invalid_credentials))
|
||||||
val dialog: Dialog = DialogUtils.getDialog(requireContext(), dialogViewModel)
|
val dialog: Dialog = DialogUtils.getDialog(requireContext(), dialogViewModel)
|
||||||
|
|
||||||
dialogViewModel.showDeleteButton({
|
dialogViewModel.showCancelButton {
|
||||||
|
viewModel.removeInvalidProxyConfig()
|
||||||
dialog.dismiss()
|
dialog.dismiss()
|
||||||
}, getString(R.string.dialog_ok))
|
}
|
||||||
|
|
||||||
|
dialogViewModel.showDeleteButton({
|
||||||
|
viewModel.continueEvenIfInvalidCredentials()
|
||||||
|
dialog.dismiss()
|
||||||
|
}, getString(R.string.assistant_continue_even_if_credentials_invalid))
|
||||||
|
|
||||||
dialog.show()
|
dialog.show()
|
||||||
}
|
}
|
||||||
|
|
|
@ -91,10 +91,6 @@ class AccountLoginViewModel(accountCreator: AccountCreator) : AbstractPhoneViewM
|
||||||
core.removeListener(this)
|
core.removeListener(this)
|
||||||
} else if (state == RegistrationState.Failed) {
|
} else if (state == RegistrationState.Failed) {
|
||||||
invalidCredentialsEvent.value = Event(true)
|
invalidCredentialsEvent.value = Event(true)
|
||||||
val authInfo = cfg.findAuthInfo()
|
|
||||||
if (authInfo != null) core.removeAuthInfo(authInfo)
|
|
||||||
core.removeProxyConfig(cfg)
|
|
||||||
proxyConfigToCheck = null
|
|
||||||
core.removeListener(this)
|
core.removeListener(this)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -132,6 +128,19 @@ class AccountLoginViewModel(accountCreator: AccountCreator) : AbstractPhoneViewM
|
||||||
super.onCleared()
|
super.onCleared()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun removeInvalidProxyConfig() {
|
||||||
|
val cfg = proxyConfigToCheck
|
||||||
|
cfg ?: return
|
||||||
|
val authInfo = cfg.findAuthInfo()
|
||||||
|
if (authInfo != null) coreContext.core.removeAuthInfo(authInfo)
|
||||||
|
coreContext.core.removeProxyConfig(cfg)
|
||||||
|
proxyConfigToCheck = null
|
||||||
|
}
|
||||||
|
|
||||||
|
fun continueEvenIfInvalidCredentials() {
|
||||||
|
leaveAssistantEvent.value = Event(true)
|
||||||
|
}
|
||||||
|
|
||||||
fun login() {
|
fun login() {
|
||||||
if (loginWithUsernamePassword.value == true) {
|
if (loginWithUsernamePassword.value == true) {
|
||||||
accountCreator.username = username.value
|
accountCreator.username = username.value
|
||||||
|
|
|
@ -75,10 +75,6 @@ class GenericLoginViewModel(private val accountCreator: AccountCreator) : ViewMo
|
||||||
core.removeListener(this)
|
core.removeListener(this)
|
||||||
} else if (state == RegistrationState.Failed) {
|
} else if (state == RegistrationState.Failed) {
|
||||||
invalidCredentialsEvent.value = Event(true)
|
invalidCredentialsEvent.value = Event(true)
|
||||||
val authInfo = cfg.findAuthInfo()
|
|
||||||
if (authInfo != null) core.removeAuthInfo(authInfo)
|
|
||||||
core.removeProxyConfig(cfg)
|
|
||||||
proxyConfigToCheck = null
|
|
||||||
core.removeListener(this)
|
core.removeListener(this)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -104,6 +100,19 @@ class GenericLoginViewModel(private val accountCreator: AccountCreator) : ViewMo
|
||||||
transport.value = transportType
|
transport.value = transportType
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun removeInvalidProxyConfig() {
|
||||||
|
val cfg = proxyConfigToCheck
|
||||||
|
cfg ?: return
|
||||||
|
val authInfo = cfg.findAuthInfo()
|
||||||
|
if (authInfo != null) coreContext.core.removeAuthInfo(authInfo)
|
||||||
|
coreContext.core.removeProxyConfig(cfg)
|
||||||
|
proxyConfigToCheck = null
|
||||||
|
}
|
||||||
|
|
||||||
|
fun continueEvenIfInvalidCredentials() {
|
||||||
|
leaveAssistantEvent.value = Event(true)
|
||||||
|
}
|
||||||
|
|
||||||
fun createProxyConfig() {
|
fun createProxyConfig() {
|
||||||
waitForServerAnswer.value = true
|
waitForServerAnswer.value = true
|
||||||
coreContext.core.addListener(coreListener)
|
coreContext.core.addListener(coreListener)
|
||||||
|
|
|
@ -11,6 +11,9 @@
|
||||||
<variable
|
<variable
|
||||||
name="infoClickListener"
|
name="infoClickListener"
|
||||||
type="android.view.View.OnClickListener"/>
|
type="android.view.View.OnClickListener"/>
|
||||||
|
<variable
|
||||||
|
name="forgotPasswordClickListener"
|
||||||
|
type="android.view.View.OnClickListener"/>
|
||||||
<variable
|
<variable
|
||||||
name="viewModel"
|
name="viewModel"
|
||||||
type="org.linphone.activities.assistant.viewmodels.AccountLoginViewModel" />
|
type="org.linphone.activities.assistant.viewmodels.AccountLoginViewModel" />
|
||||||
|
@ -219,6 +222,17 @@
|
||||||
android:hint="@string/password"
|
android:hint="@string/password"
|
||||||
android:textColor="@color/black_color" />
|
android:textColor="@color/black_color" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:onClick="@{forgotPasswordClickListener}"
|
||||||
|
android:textColor="?attr/accentColor"
|
||||||
|
android:textSize="8sp"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_gravity="right"
|
||||||
|
android:gravity="center"
|
||||||
|
android:paddingTop="5dp"
|
||||||
|
android:text="@string/assistant_login_forgotten_password" />
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
</RelativeLayout>
|
</RelativeLayout>
|
||||||
|
|
|
@ -266,9 +266,12 @@
|
||||||
<string name="assistant_create_account_part_1">Please confirm your country code and enter your phone number</string>
|
<string name="assistant_create_account_part_1">Please confirm your country code and enter your phone number</string>
|
||||||
<string name="assistant_linphone_login_desc">Please enter your username and password of &appName; account</string>
|
<string name="assistant_linphone_login_desc">Please enter your username and password of &appName; account</string>
|
||||||
<string name="assistant_login_with_username">Use your username and password instead of your phone number</string>
|
<string name="assistant_login_with_username">Use your username and password instead of your phone number</string>
|
||||||
|
<string name="assistant_login_forgotten_password">Forgot your password?</string>
|
||||||
|
<string name="assistant_forgotten_password_link" translatable="false">https://linphone.org/freesip/recover</string>
|
||||||
<string name="assistant_login">Login</string>
|
<string name="assistant_login">Login</string>
|
||||||
<string name="assistant_finish">Finish configuration</string>
|
<string name="assistant_finish">Finish configuration</string>
|
||||||
<string name="assistant_confirmation_code">Confirmation code</string>
|
<string name="assistant_confirmation_code">Confirmation code</string>
|
||||||
|
<string name="assistant_continue_even_if_credentials_invalid">Continue</string>
|
||||||
|
|
||||||
<!-- Assistant generic login -->
|
<!-- Assistant generic login -->
|
||||||
<string name="assistant_generic_account">Use SIP account</string>
|
<string name="assistant_generic_account">Use SIP account</string>
|
||||||
|
|
Loading…
Reference in a new issue