Removed a few TODOs in Assistant, replaced them by showing a simple error message in a SnackBar for now
This commit is contained in:
parent
7172d7cf60
commit
b65270d36f
17 changed files with 115 additions and 30 deletions
|
@ -21,4 +21,5 @@ package org.linphone.activities
|
|||
|
||||
interface SnackBarActivity {
|
||||
fun showSnackBar(resourceId: Int)
|
||||
fun showSnackBar(message: String)
|
||||
}
|
||||
|
|
|
@ -44,4 +44,8 @@ class AssistantActivity : GenericActivity(), SnackBarActivity {
|
|||
override fun showSnackBar(resourceId: Int) {
|
||||
Snackbar.make(binding.coordinator, resourceId, Snackbar.LENGTH_LONG).show()
|
||||
}
|
||||
|
||||
override fun showSnackBar(message: String) {
|
||||
Snackbar.make(binding.coordinator, message, Snackbar.LENGTH_LONG).show()
|
||||
}
|
||||
}
|
||||
|
|
|
@ -26,6 +26,7 @@ import android.os.Bundle
|
|||
import androidx.lifecycle.ViewModelProvider
|
||||
import org.linphone.LinphoneApplication.Companion.coreContext
|
||||
import org.linphone.R
|
||||
import org.linphone.activities.assistant.AssistantActivity
|
||||
import org.linphone.activities.assistant.viewmodels.AccountLoginViewModel
|
||||
import org.linphone.activities.assistant.viewmodels.AccountLoginViewModelFactory
|
||||
import org.linphone.activities.assistant.viewmodels.SharedAssistantViewModel
|
||||
|
@ -110,6 +111,12 @@ class AccountLoginFragment : AbstractPhoneFragment<AssistantAccountLoginFragment
|
|||
}
|
||||
})
|
||||
|
||||
viewModel.onErrorEvent.observe(viewLifecycleOwner, {
|
||||
it.consume { message ->
|
||||
(requireActivity() as AssistantActivity).showSnackBar(message)
|
||||
}
|
||||
})
|
||||
|
||||
checkPermission()
|
||||
}
|
||||
}
|
||||
|
|
|
@ -23,6 +23,7 @@ import android.os.Bundle
|
|||
import androidx.lifecycle.ViewModelProvider
|
||||
import org.linphone.R
|
||||
import org.linphone.activities.GenericFragment
|
||||
import org.linphone.activities.assistant.AssistantActivity
|
||||
import org.linphone.activities.assistant.viewmodels.EmailAccountCreationViewModel
|
||||
import org.linphone.activities.assistant.viewmodels.EmailAccountCreationViewModelFactory
|
||||
import org.linphone.activities.assistant.viewmodels.SharedAssistantViewModel
|
||||
|
@ -52,5 +53,11 @@ class EmailAccountCreationFragment : GenericFragment<AssistantEmailAccountCreati
|
|||
navigateToEmailAccountValidation()
|
||||
}
|
||||
})
|
||||
|
||||
viewModel.onErrorEvent.observe(viewLifecycleOwner, {
|
||||
it.consume { message ->
|
||||
(requireActivity() as AssistantActivity).showSnackBar(message)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
|
|
@ -23,6 +23,7 @@ import android.os.Bundle
|
|||
import androidx.lifecycle.ViewModelProvider
|
||||
import org.linphone.R
|
||||
import org.linphone.activities.GenericFragment
|
||||
import org.linphone.activities.assistant.AssistantActivity
|
||||
import org.linphone.activities.assistant.viewmodels.*
|
||||
import org.linphone.activities.main.navigateToAccountLinking
|
||||
import org.linphone.databinding.AssistantEmailAccountValidationFragmentBinding
|
||||
|
@ -54,5 +55,11 @@ class EmailAccountValidationFragment : GenericFragment<AssistantEmailAccountVali
|
|||
navigateToAccountLinking(args)
|
||||
}
|
||||
})
|
||||
|
||||
viewModel.onErrorEvent.observe(viewLifecycleOwner, {
|
||||
it.consume { message ->
|
||||
(requireActivity() as AssistantActivity).showSnackBar(message)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
|
|
@ -25,6 +25,7 @@ import androidx.lifecycle.ViewModelProvider
|
|||
import org.linphone.LinphoneApplication.Companion.coreContext
|
||||
import org.linphone.R
|
||||
import org.linphone.activities.GenericFragment
|
||||
import org.linphone.activities.assistant.AssistantActivity
|
||||
import org.linphone.activities.assistant.viewmodels.GenericLoginViewModel
|
||||
import org.linphone.activities.assistant.viewmodels.GenericLoginViewModelFactory
|
||||
import org.linphone.activities.assistant.viewmodels.SharedAssistantViewModel
|
||||
|
@ -79,5 +80,11 @@ class GenericAccountLoginFragment : GenericFragment<AssistantGenericAccountLogin
|
|||
dialog.show()
|
||||
}
|
||||
})
|
||||
|
||||
viewModel.onErrorEvent.observe(viewLifecycleOwner, {
|
||||
it.consume { message ->
|
||||
(requireActivity() as AssistantActivity).showSnackBar(message)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
|
|
@ -22,6 +22,7 @@ package org.linphone.activities.assistant.fragments
|
|||
import android.os.Bundle
|
||||
import androidx.lifecycle.ViewModelProvider
|
||||
import org.linphone.R
|
||||
import org.linphone.activities.assistant.AssistantActivity
|
||||
import org.linphone.activities.assistant.viewmodels.PhoneAccountCreationViewModel
|
||||
import org.linphone.activities.assistant.viewmodels.PhoneAccountCreationViewModelFactory
|
||||
import org.linphone.activities.assistant.viewmodels.SharedAssistantViewModel
|
||||
|
@ -63,6 +64,12 @@ class PhoneAccountCreationFragment : AbstractPhoneFragment<AssistantPhoneAccount
|
|||
}
|
||||
})
|
||||
|
||||
viewModel.onErrorEvent.observe(viewLifecycleOwner, {
|
||||
it.consume { message ->
|
||||
(requireActivity() as AssistantActivity).showSnackBar(message)
|
||||
}
|
||||
})
|
||||
|
||||
checkPermission()
|
||||
}
|
||||
}
|
||||
|
|
|
@ -23,6 +23,7 @@ import android.os.Bundle
|
|||
import androidx.lifecycle.ViewModelProvider
|
||||
import org.linphone.LinphoneApplication
|
||||
import org.linphone.R
|
||||
import org.linphone.activities.assistant.AssistantActivity
|
||||
import org.linphone.activities.assistant.viewmodels.*
|
||||
import org.linphone.activities.main.navigateToEchoCancellerCalibration
|
||||
import org.linphone.activities.main.navigateToPhoneAccountValidation
|
||||
|
@ -88,6 +89,12 @@ class PhoneAccountLinkingFragment : AbstractPhoneFragment<AssistantPhoneAccountL
|
|||
}
|
||||
})
|
||||
|
||||
viewModel.onErrorEvent.observe(viewLifecycleOwner, {
|
||||
it.consume { message ->
|
||||
(requireActivity() as AssistantActivity).showSnackBar(message)
|
||||
}
|
||||
})
|
||||
|
||||
checkPermission()
|
||||
}
|
||||
}
|
||||
|
|
|
@ -26,6 +26,7 @@ import androidx.lifecycle.ViewModelProvider
|
|||
import org.linphone.LinphoneApplication.Companion.coreContext
|
||||
import org.linphone.R
|
||||
import org.linphone.activities.GenericFragment
|
||||
import org.linphone.activities.assistant.AssistantActivity
|
||||
import org.linphone.activities.assistant.viewmodels.PhoneAccountValidationViewModel
|
||||
import org.linphone.activities.assistant.viewmodels.PhoneAccountValidationViewModelFactory
|
||||
import org.linphone.activities.assistant.viewmodels.SharedAssistantViewModel
|
||||
|
@ -75,6 +76,12 @@ class PhoneAccountValidationFragment : GenericFragment<AssistantPhoneAccountVali
|
|||
}
|
||||
})
|
||||
|
||||
viewModel.onErrorEvent.observe(viewLifecycleOwner, {
|
||||
it.consume { message ->
|
||||
(requireActivity() as AssistantActivity).showSnackBar(message)
|
||||
}
|
||||
})
|
||||
|
||||
val clipboard = requireContext().getSystemService(CLIPBOARD_SERVICE) as ClipboardManager
|
||||
clipboard.addPrimaryClipChangedListener {
|
||||
val data = clipboard.primaryClip
|
||||
|
|
|
@ -60,6 +60,10 @@ class AccountLoginViewModel(accountCreator: AccountCreator) : AbstractPhoneViewM
|
|||
MutableLiveData<Event<Boolean>>()
|
||||
}
|
||||
|
||||
val onErrorEvent: MutableLiveData<Event<String>> by lazy {
|
||||
MutableLiveData<Event<String>>()
|
||||
}
|
||||
|
||||
private val listener = object : AccountCreatorListenerStub() {
|
||||
override fun onRecoverAccount(
|
||||
creator: AccountCreator,
|
||||
|
@ -72,7 +76,7 @@ class AccountLoginViewModel(accountCreator: AccountCreator) : AbstractPhoneViewM
|
|||
if (status == AccountCreator.Status.RequestOk) {
|
||||
goToSmsValidationEvent.value = Event(true)
|
||||
} else {
|
||||
// TODO: show error
|
||||
onErrorEvent.value = Event("Error: ${status.name}")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -167,7 +171,7 @@ class AccountLoginViewModel(accountCreator: AccountCreator) : AbstractPhoneViewM
|
|||
if (!createProxyConfig()) {
|
||||
waitForServerAnswer.value = false
|
||||
coreContext.core.removeListener(coreListener)
|
||||
// TODO: show error
|
||||
onErrorEvent.value = Event("Error: Failed to create account object")
|
||||
}
|
||||
} else {
|
||||
val result = AccountCreator.PhoneNumberStatus.fromInt(accountCreator.setPhoneNumber(phoneNumber.value, prefix.value))
|
||||
|
@ -191,7 +195,7 @@ class AccountLoginViewModel(accountCreator: AccountCreator) : AbstractPhoneViewM
|
|||
Log.i("[Assistant] [Account Login] Recover account returned $status")
|
||||
if (status != AccountCreator.Status.RequestOk) {
|
||||
waitForServerAnswer.value = false
|
||||
// TODO: show error
|
||||
onErrorEvent.value = Event("Error: ${status.name}")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -210,7 +214,7 @@ class AccountLoginViewModel(accountCreator: AccountCreator) : AbstractPhoneViewM
|
|||
|
||||
if (proxyConfig == null) {
|
||||
Log.e("[Assistant] [Account Login] Account creator couldn't create proxy config")
|
||||
// TODO: show error
|
||||
onErrorEvent.value = Event("Error: Failed to create account object")
|
||||
return false
|
||||
}
|
||||
|
||||
|
|
|
@ -58,6 +58,10 @@ class EmailAccountCreationViewModel(val accountCreator: AccountCreator) : ViewMo
|
|||
|
||||
val goToEmailValidationEvent = MutableLiveData<Event<Boolean>>()
|
||||
|
||||
val onErrorEvent: MutableLiveData<Event<String>> by lazy {
|
||||
MutableLiveData<Event<String>>()
|
||||
}
|
||||
|
||||
private val listener = object : AccountCreatorListenerStub() {
|
||||
override fun onIsAccountExist(
|
||||
creator: AccountCreator,
|
||||
|
@ -74,12 +78,12 @@ class EmailAccountCreationViewModel(val accountCreator: AccountCreator) : ViewMo
|
|||
val createAccountStatus = creator.createAccount()
|
||||
if (createAccountStatus != AccountCreator.Status.RequestOk) {
|
||||
waitForServerAnswer.value = false
|
||||
// TODO: show error
|
||||
onErrorEvent.value = Event("Error: ${status.name}")
|
||||
}
|
||||
}
|
||||
else -> {
|
||||
waitForServerAnswer.value = false
|
||||
// TODO: show error
|
||||
onErrorEvent.value = Event("Error: ${status.name}")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -97,7 +101,7 @@ class EmailAccountCreationViewModel(val accountCreator: AccountCreator) : ViewMo
|
|||
goToEmailValidationEvent.value = Event(true)
|
||||
}
|
||||
else -> {
|
||||
// TODO: show error
|
||||
onErrorEvent.value = Event("Error: ${status.name}")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -148,7 +152,7 @@ class EmailAccountCreationViewModel(val accountCreator: AccountCreator) : ViewMo
|
|||
Log.i("[Assistant] [Account Creation] Account exists returned $status")
|
||||
if (status != AccountCreator.Status.RequestOk) {
|
||||
waitForServerAnswer.value = false
|
||||
// TODO: show error
|
||||
onErrorEvent.value = Event("Error: ${status.name}")
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -44,6 +44,10 @@ class EmailAccountValidationViewModel(val accountCreator: AccountCreator) : View
|
|||
|
||||
val leaveAssistantEvent = MutableLiveData<Event<Boolean>>()
|
||||
|
||||
val onErrorEvent: MutableLiveData<Event<String>> by lazy {
|
||||
MutableLiveData<Event<String>>()
|
||||
}
|
||||
|
||||
private val listener = object : AccountCreatorListenerStub() {
|
||||
override fun onIsAccountActivated(
|
||||
creator: AccountCreator,
|
||||
|
@ -58,14 +62,14 @@ class EmailAccountValidationViewModel(val accountCreator: AccountCreator) : View
|
|||
if (createProxyConfig()) {
|
||||
leaveAssistantEvent.value = Event(true)
|
||||
} else {
|
||||
// TODO: show error
|
||||
onErrorEvent.value = Event("Error: ${status.name}")
|
||||
}
|
||||
}
|
||||
AccountCreator.Status.AccountNotActivated -> {
|
||||
// TODO: show error
|
||||
onErrorEvent.value = Event("Error: ${status.name}")
|
||||
}
|
||||
else -> {
|
||||
// TODO: show error
|
||||
onErrorEvent.value = Event("Error: ${status.name}")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -87,7 +91,7 @@ class EmailAccountValidationViewModel(val accountCreator: AccountCreator) : View
|
|||
Log.i("[Assistant] [Account Validation] Account exists returned $status")
|
||||
if (status != AccountCreator.Status.RequestOk) {
|
||||
waitForServerAnswer.value = false
|
||||
// TODO: show error
|
||||
onErrorEvent.value = Event("Error: ${status.name}")
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -96,7 +100,7 @@ class EmailAccountValidationViewModel(val accountCreator: AccountCreator) : View
|
|||
|
||||
if (proxyConfig == null) {
|
||||
Log.e("[Assistant] [Account Validation] Account creator couldn't create proxy config")
|
||||
// TODO: show error
|
||||
onErrorEvent.value = Event("Error: Failed to create account object")
|
||||
return false
|
||||
}
|
||||
|
||||
|
|
|
@ -59,6 +59,10 @@ class GenericLoginViewModel(private val accountCreator: AccountCreator) : ViewMo
|
|||
MutableLiveData<Event<Boolean>>()
|
||||
}
|
||||
|
||||
val onErrorEvent: MutableLiveData<Event<String>> by lazy {
|
||||
MutableLiveData<Event<String>>()
|
||||
}
|
||||
|
||||
private var proxyConfigToCheck: ProxyConfig? = null
|
||||
|
||||
private val coreListener = object : CoreListenerStub() {
|
||||
|
@ -130,7 +134,7 @@ class GenericLoginViewModel(private val accountCreator: AccountCreator) : ViewMo
|
|||
if (proxyConfig == null) {
|
||||
Log.e("[Assistant] [Generic Login] Account creator couldn't create proxy config")
|
||||
coreContext.core.removeListener(coreListener)
|
||||
// TODO: show error
|
||||
onErrorEvent.value = Event("Error: Failed to create account object")
|
||||
return
|
||||
}
|
||||
|
||||
|
|
|
@ -54,6 +54,10 @@ class PhoneAccountCreationViewModel(accountCreator: AccountCreator) : AbstractPh
|
|||
MutableLiveData<Event<Boolean>>()
|
||||
}
|
||||
|
||||
val onErrorEvent: MutableLiveData<Event<String>> by lazy {
|
||||
MutableLiveData<Event<String>>()
|
||||
}
|
||||
|
||||
private val listener = object : AccountCreatorListenerStub() {
|
||||
override fun onIsAccountExist(
|
||||
creator: AccountCreator,
|
||||
|
@ -75,12 +79,12 @@ class PhoneAccountCreationViewModel(accountCreator: AccountCreator) : AbstractPh
|
|||
Log.i("[Phone Account Creation] createAccount returned $createAccountStatus")
|
||||
if (createAccountStatus != AccountCreator.Status.RequestOk) {
|
||||
waitForServerAnswer.value = false
|
||||
// TODO: show error
|
||||
onErrorEvent.value = Event("Error: ${status.name}")
|
||||
}
|
||||
}
|
||||
else -> {
|
||||
waitForServerAnswer.value = false
|
||||
// TODO: show error
|
||||
onErrorEvent.value = Event("Error: ${status.name}")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -100,7 +104,7 @@ class PhoneAccountCreationViewModel(accountCreator: AccountCreator) : AbstractPh
|
|||
phoneNumberError.value = AppUtils.getString(R.string.assistant_error_phone_number_already_exists)
|
||||
}
|
||||
else -> {
|
||||
// TODO: show error
|
||||
onErrorEvent.value = Event("Error: ${status.name}")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -149,7 +153,7 @@ class PhoneAccountCreationViewModel(accountCreator: AccountCreator) : AbstractPh
|
|||
Log.i("[Phone Account Creation] isAccountExist returned $status")
|
||||
if (status != AccountCreator.Status.RequestOk) {
|
||||
waitForServerAnswer.value = false
|
||||
// TODO: show error
|
||||
onErrorEvent.value = Event("Error: ${status.name}")
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -48,6 +48,10 @@ class PhoneAccountLinkingViewModel(accountCreator: AccountCreator) : AbstractPho
|
|||
|
||||
val goToSmsValidationEvent = MutableLiveData<Event<Boolean>>()
|
||||
|
||||
val onErrorEvent: MutableLiveData<Event<String>> by lazy {
|
||||
MutableLiveData<Event<String>>()
|
||||
}
|
||||
|
||||
private val listener = object : AccountCreatorListenerStub() {
|
||||
override fun onIsAliasUsed(
|
||||
creator: AccountCreator,
|
||||
|
@ -61,16 +65,16 @@ class PhoneAccountLinkingViewModel(accountCreator: AccountCreator) : AbstractPho
|
|||
if (creator.linkAccount() != AccountCreator.Status.RequestOk) {
|
||||
Log.e("[Phone Account Linking] linkAccount status is $status")
|
||||
waitForServerAnswer.value = false
|
||||
// TODO: show error
|
||||
onErrorEvent.value = Event("Error: ${status.name}")
|
||||
}
|
||||
}
|
||||
AccountCreator.Status.AliasExist, AccountCreator.Status.AliasIsAccount -> {
|
||||
waitForServerAnswer.value = false
|
||||
// TODO: show error
|
||||
onErrorEvent.value = Event("Error: ${status.name}")
|
||||
}
|
||||
else -> {
|
||||
waitForServerAnswer.value = false
|
||||
// TODO: show error
|
||||
onErrorEvent.value = Event("Error: ${status.name}")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -88,7 +92,7 @@ class PhoneAccountLinkingViewModel(accountCreator: AccountCreator) : AbstractPho
|
|||
goToSmsValidationEvent.value = Event(true)
|
||||
}
|
||||
else -> {
|
||||
// TODO: show error
|
||||
onErrorEvent.value = Event("Error: ${status.name}")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -124,7 +128,7 @@ class PhoneAccountLinkingViewModel(accountCreator: AccountCreator) : AbstractPho
|
|||
Log.i("[Phone Account Linking] isAliasUsed returned $status")
|
||||
if (status != AccountCreator.Status.RequestOk) {
|
||||
waitForServerAnswer.value = false
|
||||
// TODO: show error
|
||||
onErrorEvent.value = Event("Error: ${status.name}")
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -52,6 +52,10 @@ class PhoneAccountValidationViewModel(val accountCreator: AccountCreator) : View
|
|||
|
||||
val leaveAssistantEvent = MutableLiveData<Event<Boolean>>()
|
||||
|
||||
val onErrorEvent: MutableLiveData<Event<String>> by lazy {
|
||||
MutableLiveData<Event<String>>()
|
||||
}
|
||||
|
||||
val listener = object : AccountCreatorListenerStub() {
|
||||
override fun onLoginLinphoneAccount(
|
||||
creator: AccountCreator,
|
||||
|
@ -65,10 +69,10 @@ class PhoneAccountValidationViewModel(val accountCreator: AccountCreator) : View
|
|||
if (createProxyConfig()) {
|
||||
leaveAssistantEvent.value = Event(true)
|
||||
} else {
|
||||
// TODO: show error
|
||||
onErrorEvent.value = Event("Error: Failed to create account object")
|
||||
}
|
||||
} else {
|
||||
// TODO: show error
|
||||
onErrorEvent.value = Event("Error: ${status.name}")
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -85,7 +89,7 @@ class PhoneAccountValidationViewModel(val accountCreator: AccountCreator) : View
|
|||
leaveAssistantEvent.value = Event(true)
|
||||
}
|
||||
else -> {
|
||||
// TODO: show error
|
||||
onErrorEvent.value = Event("Error: ${status.name}")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -102,10 +106,10 @@ class PhoneAccountValidationViewModel(val accountCreator: AccountCreator) : View
|
|||
if (createProxyConfig()) {
|
||||
leaveAssistantEvent.value = Event(true)
|
||||
} else {
|
||||
// TODO: show error
|
||||
onErrorEvent.value = Event("Error: Failed to create account object")
|
||||
}
|
||||
} else {
|
||||
// TODO: show error
|
||||
onErrorEvent.value = Event("Error: ${status.name}")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -133,7 +137,7 @@ class PhoneAccountValidationViewModel(val accountCreator: AccountCreator) : View
|
|||
Log.i("[Assistant] [Phone Account Validation] Code validation result is $status")
|
||||
if (status != AccountCreator.Status.RequestOk) {
|
||||
waitForServerAnswer.value = false
|
||||
// TODO: show error
|
||||
onErrorEvent.value = Event("Error: ${status.name}")
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -142,7 +146,6 @@ class PhoneAccountValidationViewModel(val accountCreator: AccountCreator) : View
|
|||
|
||||
if (proxyConfig == null) {
|
||||
Log.e("[Assistant] [Phone Account Validation] Account creator couldn't create proxy config")
|
||||
// TODO: show error
|
||||
return false
|
||||
}
|
||||
|
||||
|
|
|
@ -132,6 +132,10 @@ class MainActivity : GenericActivity(), SnackBarActivity, NavController.OnDestin
|
|||
Snackbar.make(findViewById(R.id.coordinator), resourceId, Snackbar.LENGTH_LONG).show()
|
||||
}
|
||||
|
||||
override fun showSnackBar(message: String) {
|
||||
Snackbar.make(findViewById(R.id.coordinator), message, Snackbar.LENGTH_LONG).show()
|
||||
}
|
||||
|
||||
override fun onPostCreate(savedInstanceState: Bundle?) {
|
||||
super.onPostCreate(savedInstanceState)
|
||||
findNavController(R.id.nav_host_fragment).addOnDestinationChangedListener(this)
|
||||
|
|
Loading…
Reference in a new issue