mirror of
https://gitlab.linphone.org/BC/public/linphone-android.git
synced 2026-01-17 11:28:06 +00:00
Refactored toasts
This commit is contained in:
parent
465201010d
commit
889b98db1e
96 changed files with 511 additions and 474 deletions
|
|
@ -83,11 +83,15 @@ class CoreContext @UiThread constructor(val context: Context) : HandlerThread("C
|
|||
MutableLiveData<Event<String>>()
|
||||
}
|
||||
|
||||
val greenToastToShowEvent: MutableLiveData<Event<Pair<String, Int>>> by lazy {
|
||||
MutableLiveData<Event<Pair<String, Int>>>()
|
||||
val showGreenToastEvent: MutableLiveData<Event<Pair<Int, Int>>> by lazy {
|
||||
MutableLiveData<Event<Pair<Int, Int>>>()
|
||||
}
|
||||
|
||||
val redToastToShowEvent: MutableLiveData<Event<Pair<String, Int>>> by lazy {
|
||||
val showRedToastEvent: MutableLiveData<Event<Pair<Int, Int>>> by lazy {
|
||||
MutableLiveData<Event<Pair<Int, Int>>>()
|
||||
}
|
||||
|
||||
val showFormattedRedToastEvent: MutableLiveData<Event<Pair<String, Int>>> by lazy {
|
||||
MutableLiveData<Event<Pair<String, Int>>>()
|
||||
}
|
||||
|
||||
|
|
@ -136,16 +140,22 @@ class CoreContext @UiThread constructor(val context: Context) : HandlerThread("C
|
|||
) {
|
||||
Log.i("$TAG Configuring state changed [$status], message is [$message]")
|
||||
if (status == ConfiguringState.Successful) {
|
||||
val text = context.getString(
|
||||
org.linphone.R.string.toast_remote_provisioning_config_applied
|
||||
showGreenToastEvent.postValue(
|
||||
Event(
|
||||
Pair(
|
||||
org.linphone.R.string.toast_remote_provisioning_config_applied,
|
||||
org.linphone.R.drawable.smiley
|
||||
)
|
||||
)
|
||||
)
|
||||
greenToastToShowEvent.postValue(Event(Pair(text, org.linphone.R.drawable.smiley)))
|
||||
} else if (status == ConfiguringState.Failed) {
|
||||
val text = context.getString(
|
||||
org.linphone.R.string.toast_remote_provisioning_config_failed
|
||||
)
|
||||
redToastToShowEvent.postValue(
|
||||
Event(Pair(text, org.linphone.R.drawable.warning_circle))
|
||||
showRedToastEvent.postValue(
|
||||
Event(
|
||||
Pair(
|
||||
org.linphone.R.string.toast_remote_provisioning_config_failed,
|
||||
org.linphone.R.drawable.warning_circle
|
||||
)
|
||||
)
|
||||
)
|
||||
}
|
||||
}
|
||||
|
|
@ -183,7 +193,7 @@ class CoreContext @UiThread constructor(val context: Context) : HandlerThread("C
|
|||
"$TAG Call error reason is [${errorInfo.reason}](${errorInfo.protocolCode}): ${errorInfo.phrase}"
|
||||
)
|
||||
val text = LinphoneUtils.getCallErrorInfoToast(call)
|
||||
redToastToShowEvent.postValue(
|
||||
showFormattedRedToastEvent.postValue(
|
||||
Event(Pair(text, org.linphone.R.drawable.warning_circle))
|
||||
)
|
||||
}
|
||||
|
|
@ -198,12 +208,10 @@ class CoreContext @UiThread constructor(val context: Context) : HandlerThread("C
|
|||
"$TAG Transferred call [${transfered.remoteAddress.asStringUriOnly()}] state changed [$state]"
|
||||
)
|
||||
if (state == Call.State.Connected) {
|
||||
val message = context.getString(
|
||||
org.linphone.R.string.toast_call_transfer_successful
|
||||
)
|
||||
val icon = org.linphone.R.drawable.phone_transfer
|
||||
|
||||
greenToastToShowEvent.postValue(Event(Pair(message, icon)))
|
||||
showGreenToastEvent.postValue(
|
||||
Event(Pair(org.linphone.R.string.toast_call_transfer_successful, icon))
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
64
app/src/main/java/org/linphone/ui/GenericFragment.kt
Normal file
64
app/src/main/java/org/linphone/ui/GenericFragment.kt
Normal file
|
|
@ -0,0 +1,64 @@
|
|||
/*
|
||||
* Copyright (c) 2010-2023 Belledonne Communications SARL.
|
||||
*
|
||||
* This file is part of linphone-android
|
||||
* (see https://www.linphone.org).
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package org.linphone.ui
|
||||
|
||||
import androidx.annotation.UiThread
|
||||
import androidx.fragment.app.Fragment
|
||||
|
||||
@UiThread
|
||||
abstract class GenericFragment : Fragment() {
|
||||
companion object {
|
||||
private const val TAG = "[Generic Fragment]"
|
||||
}
|
||||
|
||||
protected fun observeToastEvents(viewModel: GenericViewModel) {
|
||||
viewModel.showRedToastEvent.observe(viewLifecycleOwner) {
|
||||
it.consume { pair ->
|
||||
val message = getString(pair.first)
|
||||
val icon = pair.second
|
||||
(requireActivity() as GenericActivity).showRedToast(message, icon)
|
||||
}
|
||||
}
|
||||
|
||||
viewModel.showFormattedRedToastEvent.observe(viewLifecycleOwner) {
|
||||
it.consume { pair ->
|
||||
val message = pair.first
|
||||
val icon = pair.second
|
||||
(requireActivity() as GenericActivity).showRedToast(message, icon)
|
||||
}
|
||||
}
|
||||
|
||||
viewModel.showGreenToastEvent.observe(viewLifecycleOwner) {
|
||||
it.consume { pair ->
|
||||
val message = getString(pair.first)
|
||||
val icon = pair.second
|
||||
(requireActivity() as GenericActivity).showRedToast(message, icon)
|
||||
}
|
||||
}
|
||||
|
||||
viewModel.showFormattedGreenToastEvent.observe(viewLifecycleOwner) {
|
||||
it.consume { pair ->
|
||||
val message = pair.first
|
||||
val icon = pair.second
|
||||
(requireActivity() as GenericActivity).showGreenToast(message, icon)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
42
app/src/main/java/org/linphone/ui/GenericViewModel.kt
Normal file
42
app/src/main/java/org/linphone/ui/GenericViewModel.kt
Normal file
|
|
@ -0,0 +1,42 @@
|
|||
/*
|
||||
* Copyright (c) 2010-2024 Belledonne Communications SARL.
|
||||
*
|
||||
* This file is part of linphone-android
|
||||
* (see https://www.linphone.org).
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package org.linphone.ui
|
||||
|
||||
import androidx.lifecycle.MutableLiveData
|
||||
import androidx.lifecycle.ViewModel
|
||||
import org.linphone.utils.Event
|
||||
|
||||
open class GenericViewModel : ViewModel() {
|
||||
val showGreenToastEvent: MutableLiveData<Event<Pair<Int, Int>>> by lazy {
|
||||
MutableLiveData<Event<Pair<Int, Int>>>()
|
||||
}
|
||||
|
||||
val showFormattedGreenToastEvent: MutableLiveData<Event<Pair<String, Int>>> by lazy {
|
||||
MutableLiveData<Event<Pair<String, Int>>>()
|
||||
}
|
||||
|
||||
val showRedToastEvent: MutableLiveData<Event<Pair<Int, Int>>> by lazy {
|
||||
MutableLiveData<Event<Pair<Int, Int>>>()
|
||||
}
|
||||
|
||||
val showFormattedRedToastEvent: MutableLiveData<Event<Pair<String, Int>>> by lazy {
|
||||
MutableLiveData<Event<Pair<String, Int>>>()
|
||||
}
|
||||
}
|
||||
|
|
@ -26,7 +26,6 @@ import android.view.LayoutInflater
|
|||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import androidx.annotation.UiThread
|
||||
import androidx.fragment.app.Fragment
|
||||
import androidx.lifecycle.lifecycleScope
|
||||
import androidx.navigation.fragment.findNavController
|
||||
import androidx.navigation.navGraphViewModels
|
||||
|
|
@ -38,13 +37,14 @@ import org.linphone.R
|
|||
import org.linphone.core.tools.Log
|
||||
import org.linphone.databinding.AssistantLandingFragmentBinding
|
||||
import org.linphone.ui.GenericActivity
|
||||
import org.linphone.ui.GenericFragment
|
||||
import org.linphone.ui.assistant.model.AcceptConditionsAndPolicyDialogModel
|
||||
import org.linphone.ui.assistant.viewmodel.LandingViewModel
|
||||
import org.linphone.utils.DialogUtils
|
||||
import org.linphone.utils.PhoneNumberUtils
|
||||
|
||||
@UiThread
|
||||
class LandingFragment : Fragment() {
|
||||
class LandingFragment : GenericFragment() {
|
||||
companion object {
|
||||
private const val TAG = "[Landing Fragment]"
|
||||
}
|
||||
|
|
@ -69,6 +69,7 @@ class LandingFragment : Fragment() {
|
|||
|
||||
binding.lifecycleOwner = viewLifecycleOwner
|
||||
binding.viewModel = viewModel
|
||||
observeToastEvents(viewModel)
|
||||
|
||||
binding.setBackClickListener {
|
||||
requireActivity().finish()
|
||||
|
|
@ -131,15 +132,6 @@ class LandingFragment : Fragment() {
|
|||
}
|
||||
}
|
||||
|
||||
viewModel.showRedToastEvent.observe(viewLifecycleOwner) {
|
||||
it.consume { message ->
|
||||
(requireActivity() as GenericActivity).showRedToast(
|
||||
getString(message),
|
||||
R.drawable.warning_circle
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
coreContext.postOnCoreThread {
|
||||
val dialPlan = PhoneNumberUtils.getDeviceDialPlan(requireContext())
|
||||
if (dialPlan != null) {
|
||||
|
|
|
|||
|
|
@ -26,7 +26,6 @@ import android.view.LayoutInflater
|
|||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import androidx.annotation.UiThread
|
||||
import androidx.fragment.app.Fragment
|
||||
import androidx.lifecycle.lifecycleScope
|
||||
import androidx.navigation.fragment.findNavController
|
||||
import androidx.navigation.fragment.navArgs
|
||||
|
|
@ -38,11 +37,12 @@ import org.linphone.R
|
|||
import org.linphone.core.tools.Log
|
||||
import org.linphone.databinding.AssistantLoginFragmentBinding
|
||||
import org.linphone.ui.GenericActivity
|
||||
import org.linphone.ui.GenericFragment
|
||||
import org.linphone.ui.assistant.viewmodel.AccountLoginViewModel
|
||||
import org.linphone.utils.PhoneNumberUtils
|
||||
|
||||
@UiThread
|
||||
class LoginFragment : Fragment() {
|
||||
class LoginFragment : GenericFragment() {
|
||||
companion object {
|
||||
private const val TAG = "[Login Fragment]"
|
||||
}
|
||||
|
|
@ -69,6 +69,7 @@ class LoginFragment : Fragment() {
|
|||
|
||||
binding.lifecycleOwner = viewLifecycleOwner
|
||||
binding.viewModel = viewModel
|
||||
observeToastEvents(viewModel)
|
||||
|
||||
binding.setBackClickListener {
|
||||
goBack()
|
||||
|
|
@ -113,15 +114,6 @@ class LoginFragment : Fragment() {
|
|||
}
|
||||
}
|
||||
|
||||
viewModel.showRedToastEvent.observe(viewLifecycleOwner) {
|
||||
it.consume { message ->
|
||||
(requireActivity() as GenericActivity).showRedToast(
|
||||
getString(message),
|
||||
R.drawable.warning_circle
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
coreContext.postOnCoreThread {
|
||||
val dialPlan = PhoneNumberUtils.getDeviceDialPlan(requireContext())
|
||||
if (dialPlan != null) {
|
||||
|
|
|
|||
|
|
@ -28,17 +28,17 @@ import android.view.ViewGroup
|
|||
import androidx.activity.result.contract.ActivityResultContracts
|
||||
import androidx.annotation.UiThread
|
||||
import androidx.core.content.ContextCompat
|
||||
import androidx.fragment.app.Fragment
|
||||
import androidx.navigation.fragment.findNavController
|
||||
import org.linphone.LinphoneApplication.Companion.coreContext
|
||||
import org.linphone.R
|
||||
import org.linphone.compatibility.Compatibility
|
||||
import org.linphone.core.tools.Log
|
||||
import org.linphone.databinding.AssistantPermissionsFragmentBinding
|
||||
import org.linphone.ui.GenericFragment
|
||||
import org.linphone.ui.assistant.AssistantActivity
|
||||
|
||||
@UiThread
|
||||
class PermissionsFragment : Fragment() {
|
||||
class PermissionsFragment : GenericFragment() {
|
||||
companion object {
|
||||
private const val TAG = "[Permissions Fragment]"
|
||||
}
|
||||
|
|
|
|||
|
|
@ -24,16 +24,16 @@ import android.view.LayoutInflater
|
|||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import androidx.annotation.UiThread
|
||||
import androidx.fragment.app.Fragment
|
||||
import androidx.navigation.fragment.findNavController
|
||||
import androidx.navigation.navGraphViewModels
|
||||
import org.linphone.R
|
||||
import org.linphone.databinding.AssistantSecureModeFragmentBinding
|
||||
import org.linphone.ui.GenericFragment
|
||||
import org.linphone.ui.assistant.viewmodel.AccountLoginViewModel
|
||||
import org.linphone.utils.DialogUtils
|
||||
|
||||
@UiThread
|
||||
class ProfileModeFragment : Fragment() {
|
||||
class ProfileModeFragment : GenericFragment() {
|
||||
companion object {
|
||||
private const val TAG = "[Profile Mode Fragment]"
|
||||
}
|
||||
|
|
@ -58,6 +58,7 @@ class ProfileModeFragment : Fragment() {
|
|||
|
||||
binding.lifecycleOwner = viewLifecycleOwner
|
||||
binding.viewModel = viewModel
|
||||
observeToastEvents(viewModel)
|
||||
|
||||
binding.setBackClickListener {
|
||||
findNavController().popBackStack()
|
||||
|
|
|
|||
|
|
@ -28,7 +28,6 @@ import android.view.ViewGroup
|
|||
import androidx.activity.result.contract.ActivityResultContracts
|
||||
import androidx.annotation.UiThread
|
||||
import androidx.core.content.ContextCompat
|
||||
import androidx.fragment.app.Fragment
|
||||
import androidx.navigation.fragment.findNavController
|
||||
import androidx.navigation.navGraphViewModels
|
||||
import org.linphone.LinphoneApplication.Companion.coreContext
|
||||
|
|
@ -36,10 +35,11 @@ import org.linphone.R
|
|||
import org.linphone.core.tools.Log
|
||||
import org.linphone.databinding.AssistantQrCodeScannerFragmentBinding
|
||||
import org.linphone.ui.GenericActivity
|
||||
import org.linphone.ui.GenericFragment
|
||||
import org.linphone.ui.assistant.viewmodel.QrCodeViewModel
|
||||
|
||||
@UiThread
|
||||
class QrCodeScannerFragment : Fragment() {
|
||||
class QrCodeScannerFragment : GenericFragment() {
|
||||
companion object {
|
||||
private const val TAG = "[Qr Code Scanner Fragment]"
|
||||
}
|
||||
|
|
@ -76,6 +76,7 @@ class QrCodeScannerFragment : Fragment() {
|
|||
|
||||
binding.lifecycleOwner = viewLifecycleOwner
|
||||
binding.viewModel = viewModel
|
||||
observeToastEvents(viewModel)
|
||||
|
||||
binding.setBackClickListener {
|
||||
goBack()
|
||||
|
|
|
|||
|
|
@ -26,16 +26,16 @@ import android.view.LayoutInflater
|
|||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import androidx.annotation.UiThread
|
||||
import androidx.fragment.app.Fragment
|
||||
import androidx.navigation.fragment.findNavController
|
||||
import androidx.navigation.navGraphViewModels
|
||||
import org.linphone.R
|
||||
import org.linphone.core.tools.Log
|
||||
import org.linphone.databinding.AssistantRegisterConfirmSmsCodeFragmentBinding
|
||||
import org.linphone.ui.GenericFragment
|
||||
import org.linphone.ui.assistant.viewmodel.AccountCreationViewModel
|
||||
|
||||
@UiThread
|
||||
class RegisterCodeConfirmationFragment : Fragment() {
|
||||
class RegisterCodeConfirmationFragment : GenericFragment() {
|
||||
companion object {
|
||||
private const val TAG = "[Register Code Confirmation Fragment]"
|
||||
}
|
||||
|
|
@ -60,6 +60,7 @@ class RegisterCodeConfirmationFragment : Fragment() {
|
|||
|
||||
binding.lifecycleOwner = viewLifecycleOwner
|
||||
binding.viewModel = viewModel
|
||||
observeToastEvents(viewModel)
|
||||
|
||||
binding.setBackClickListener {
|
||||
goBack()
|
||||
|
|
|
|||
|
|
@ -31,7 +31,6 @@ import android.widget.AdapterView
|
|||
import android.widget.ArrayAdapter
|
||||
import androidx.annotation.UiThread
|
||||
import androidx.appcompat.widget.AppCompatTextView
|
||||
import androidx.fragment.app.Fragment
|
||||
import androidx.lifecycle.lifecycleScope
|
||||
import androidx.navigation.fragment.findNavController
|
||||
import androidx.navigation.navGraphViewModels
|
||||
|
|
@ -42,13 +41,14 @@ import org.linphone.R
|
|||
import org.linphone.core.tools.Log
|
||||
import org.linphone.databinding.AssistantRegisterFragmentBinding
|
||||
import org.linphone.ui.GenericActivity
|
||||
import org.linphone.ui.GenericFragment
|
||||
import org.linphone.ui.assistant.model.ConfirmPhoneNumberDialogModel
|
||||
import org.linphone.ui.assistant.viewmodel.AccountCreationViewModel
|
||||
import org.linphone.utils.DialogUtils
|
||||
import org.linphone.utils.PhoneNumberUtils
|
||||
|
||||
@UiThread
|
||||
class RegisterFragment : Fragment() {
|
||||
class RegisterFragment : GenericFragment() {
|
||||
companion object {
|
||||
private const val TAG = "[Register Fragment]"
|
||||
}
|
||||
|
|
@ -86,6 +86,7 @@ class RegisterFragment : Fragment() {
|
|||
|
||||
binding.lifecycleOwner = viewLifecycleOwner
|
||||
binding.viewModel = viewModel
|
||||
observeToastEvents(viewModel)
|
||||
|
||||
binding.setBackClickListener {
|
||||
goBack()
|
||||
|
|
|
|||
|
|
@ -26,7 +26,6 @@ import android.view.ViewGroup
|
|||
import android.widget.AdapterView
|
||||
import android.widget.ArrayAdapter
|
||||
import androidx.annotation.UiThread
|
||||
import androidx.fragment.app.Fragment
|
||||
import androidx.lifecycle.lifecycleScope
|
||||
import androidx.navigation.fragment.findNavController
|
||||
import androidx.navigation.navGraphViewModels
|
||||
|
|
@ -37,11 +36,12 @@ import org.linphone.R
|
|||
import org.linphone.core.tools.Log
|
||||
import org.linphone.databinding.AssistantThirdPartySipAccountLoginFragmentBinding
|
||||
import org.linphone.ui.GenericActivity
|
||||
import org.linphone.ui.GenericFragment
|
||||
import org.linphone.ui.assistant.viewmodel.ThirdPartySipAccountLoginViewModel
|
||||
import org.linphone.utils.PhoneNumberUtils
|
||||
|
||||
@UiThread
|
||||
class ThirdPartySipAccountLoginFragment : Fragment() {
|
||||
class ThirdPartySipAccountLoginFragment : GenericFragment() {
|
||||
companion object {
|
||||
private const val TAG = "[Third Party SIP Account Login Fragment]"
|
||||
}
|
||||
|
|
@ -90,6 +90,7 @@ class ThirdPartySipAccountLoginFragment : Fragment() {
|
|||
binding.transport.setSelection(viewModel.availableTransports.size - 1)
|
||||
|
||||
binding.viewModel = viewModel
|
||||
observeToastEvents(viewModel)
|
||||
|
||||
binding.setBackClickListener {
|
||||
goBack()
|
||||
|
|
|
|||
|
|
@ -26,14 +26,14 @@ import android.view.LayoutInflater
|
|||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import androidx.annotation.UiThread
|
||||
import androidx.fragment.app.Fragment
|
||||
import androidx.navigation.fragment.findNavController
|
||||
import org.linphone.R
|
||||
import org.linphone.core.tools.Log
|
||||
import org.linphone.databinding.AssistantThirdPartySipAccountWarningFragmentBinding
|
||||
import org.linphone.ui.GenericFragment
|
||||
|
||||
@UiThread
|
||||
class ThirdPartySipAccountWarningFragment : Fragment() {
|
||||
class ThirdPartySipAccountWarningFragment : GenericFragment() {
|
||||
companion object {
|
||||
private const val TAG = "[Third Party SIP Account Warning Fragment]"
|
||||
}
|
||||
|
|
|
|||
|
|
@ -23,7 +23,6 @@ import androidx.annotation.UiThread
|
|||
import androidx.annotation.WorkerThread
|
||||
import androidx.lifecycle.MediatorLiveData
|
||||
import androidx.lifecycle.MutableLiveData
|
||||
import androidx.lifecycle.ViewModel
|
||||
import androidx.lifecycle.viewModelScope
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.Job
|
||||
|
|
@ -44,11 +43,12 @@ import org.linphone.core.CoreListenerStub
|
|||
import org.linphone.core.DialPlan
|
||||
import org.linphone.core.Factory
|
||||
import org.linphone.core.tools.Log
|
||||
import org.linphone.ui.GenericViewModel
|
||||
import org.linphone.utils.AppUtils
|
||||
import org.linphone.utils.Event
|
||||
import org.linphone.utils.LinphoneUtils
|
||||
|
||||
class AccountCreationViewModel @UiThread constructor() : ViewModel() {
|
||||
class AccountCreationViewModel @UiThread constructor() : GenericViewModel() {
|
||||
companion object {
|
||||
private const val TAG = "[Account Creation ViewModel]"
|
||||
}
|
||||
|
|
|
|||
|
|
@ -23,7 +23,6 @@ import androidx.annotation.UiThread
|
|||
import androidx.annotation.WorkerThread
|
||||
import androidx.lifecycle.MediatorLiveData
|
||||
import androidx.lifecycle.MutableLiveData
|
||||
import androidx.lifecycle.ViewModel
|
||||
import org.linphone.LinphoneApplication.Companion.coreContext
|
||||
import org.linphone.LinphoneApplication.Companion.corePreferences
|
||||
import org.linphone.R
|
||||
|
|
@ -35,12 +34,13 @@ import org.linphone.core.Factory
|
|||
import org.linphone.core.Reason
|
||||
import org.linphone.core.RegistrationState
|
||||
import org.linphone.core.tools.Log
|
||||
import org.linphone.ui.GenericViewModel
|
||||
import org.linphone.ui.main.model.setEndToEndEncryptionMandatory
|
||||
import org.linphone.ui.main.model.setInteroperabilityMode
|
||||
import org.linphone.utils.AppUtils
|
||||
import org.linphone.utils.Event
|
||||
|
||||
open class AccountLoginViewModel @UiThread constructor() : ViewModel() {
|
||||
open class AccountLoginViewModel @UiThread constructor() : GenericViewModel() {
|
||||
companion object {
|
||||
private const val TAG = "[Account Login ViewModel]"
|
||||
}
|
||||
|
|
@ -69,10 +69,6 @@ open class AccountLoginViewModel @UiThread constructor() : ViewModel() {
|
|||
MutableLiveData<Event<String>>()
|
||||
}
|
||||
|
||||
val showRedToastEvent: MutableLiveData<Event<Int>> by lazy {
|
||||
MutableLiveData<Event<Int>>()
|
||||
}
|
||||
|
||||
private lateinit var newlyCreatedAuthInfo: AuthInfo
|
||||
private lateinit var newlyCreatedAccount: Account
|
||||
|
||||
|
|
@ -157,7 +153,12 @@ open class AccountLoginViewModel @UiThread constructor() : ViewModel() {
|
|||
if (identityAddress == null) {
|
||||
Log.e("$TAG Can't parse [$identity] as Address!")
|
||||
showRedToastEvent.postValue(
|
||||
Event(R.string.assistant_login_cant_parse_address_toast)
|
||||
Event(
|
||||
Pair(
|
||||
R.string.assistant_login_cant_parse_address_toast,
|
||||
R.drawable.warning_circle
|
||||
)
|
||||
)
|
||||
)
|
||||
return@postOnCoreThread
|
||||
}
|
||||
|
|
@ -168,7 +169,12 @@ open class AccountLoginViewModel @UiThread constructor() : ViewModel() {
|
|||
"$TAG Address [${identityAddress.asStringUriOnly()}] doesn't contains an username!"
|
||||
)
|
||||
showRedToastEvent.postValue(
|
||||
Event(R.string.assistant_login_address_without_username_toast)
|
||||
Event(
|
||||
Pair(
|
||||
R.string.assistant_login_address_without_username_toast,
|
||||
R.drawable.warning_circle
|
||||
)
|
||||
)
|
||||
)
|
||||
return@postOnCoreThread
|
||||
}
|
||||
|
|
|
|||
|
|
@ -23,14 +23,14 @@ import android.util.Patterns
|
|||
import androidx.annotation.UiThread
|
||||
import androidx.annotation.WorkerThread
|
||||
import androidx.lifecycle.MutableLiveData
|
||||
import androidx.lifecycle.ViewModel
|
||||
import org.linphone.LinphoneApplication.Companion.coreContext
|
||||
import org.linphone.core.Core
|
||||
import org.linphone.core.CoreListenerStub
|
||||
import org.linphone.core.tools.Log
|
||||
import org.linphone.ui.GenericViewModel
|
||||
import org.linphone.utils.Event
|
||||
|
||||
class QrCodeViewModel @UiThread constructor() : ViewModel() {
|
||||
class QrCodeViewModel @UiThread constructor() : GenericViewModel() {
|
||||
companion object {
|
||||
private const val TAG = "[Qr Code Scanner ViewModel]"
|
||||
}
|
||||
|
|
|
|||
|
|
@ -23,7 +23,6 @@ import androidx.annotation.UiThread
|
|||
import androidx.annotation.WorkerThread
|
||||
import androidx.lifecycle.MediatorLiveData
|
||||
import androidx.lifecycle.MutableLiveData
|
||||
import androidx.lifecycle.ViewModel
|
||||
import java.util.Locale
|
||||
import org.linphone.LinphoneApplication.Companion.coreContext
|
||||
import org.linphone.LinphoneApplication.Companion.corePreferences
|
||||
|
|
@ -37,10 +36,11 @@ import org.linphone.core.Reason
|
|||
import org.linphone.core.RegistrationState
|
||||
import org.linphone.core.TransportType
|
||||
import org.linphone.core.tools.Log
|
||||
import org.linphone.ui.GenericViewModel
|
||||
import org.linphone.utils.AppUtils
|
||||
import org.linphone.utils.Event
|
||||
|
||||
class ThirdPartySipAccountLoginViewModel @UiThread constructor() : ViewModel() {
|
||||
class ThirdPartySipAccountLoginViewModel @UiThread constructor() : GenericViewModel() {
|
||||
companion object {
|
||||
private const val TAG = "[Third Party SIP Account Login ViewModel]"
|
||||
}
|
||||
|
|
|
|||
|
|
@ -75,8 +75,8 @@ class ConferenceAddParticipantsFragment : GenericAddressPickerFragment() {
|
|||
super.onViewCreated(view, savedInstanceState)
|
||||
|
||||
binding.lifecycleOwner = viewLifecycleOwner
|
||||
|
||||
binding.viewModel = viewModel
|
||||
observeToastEvents(viewModel)
|
||||
|
||||
binding.setBackClickListener {
|
||||
goBack()
|
||||
|
|
|
|||
|
|
@ -82,6 +82,8 @@ class ConferenceParticipantsListFragment : GenericCallFragment() {
|
|||
|
||||
binding.lifecycleOwner = viewLifecycleOwner
|
||||
binding.viewModel = viewModel
|
||||
observeToastEvents(viewModel)
|
||||
observeToastEvents(viewModel.conferenceModel)
|
||||
|
||||
binding.participantsList.setHasFixedSize(true)
|
||||
binding.participantsList.layoutManager = LinearLayoutManager(requireContext())
|
||||
|
|
@ -114,15 +116,6 @@ class ConferenceParticipantsListFragment : GenericCallFragment() {
|
|||
showKickParticipantDialog(displayName, participant)
|
||||
}
|
||||
}
|
||||
|
||||
viewModel.conferenceModel.showRedToastEvent.observe(viewLifecycleOwner) {
|
||||
it.consume { message ->
|
||||
(requireActivity() as GenericActivity).showRedToast(
|
||||
getString(message),
|
||||
R.drawable.warning_circle
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun showKickParticipantDialog(displayName: String, participant: Participant) {
|
||||
|
|
|
|||
|
|
@ -33,13 +33,14 @@ import org.linphone.core.Participant
|
|||
import org.linphone.core.ParticipantDevice
|
||||
import org.linphone.core.StreamType
|
||||
import org.linphone.core.tools.Log
|
||||
import org.linphone.ui.GenericViewModel
|
||||
import org.linphone.ui.call.conference.model.ConferenceParticipantDeviceModel
|
||||
import org.linphone.ui.call.conference.model.ConferenceParticipantModel
|
||||
import org.linphone.ui.call.conference.view.GridBoxLayout
|
||||
import org.linphone.utils.AppUtils
|
||||
import org.linphone.utils.Event
|
||||
|
||||
class ConferenceViewModel {
|
||||
class ConferenceViewModel : GenericViewModel() {
|
||||
companion object {
|
||||
private const val TAG = "[Conference ViewModel]"
|
||||
|
||||
|
|
@ -80,10 +81,6 @@ class ConferenceViewModel {
|
|||
MutableLiveData<Event<Pair<String, Participant>>>()
|
||||
}
|
||||
|
||||
val showRedToastEvent: MutableLiveData<Event<Int>> by lazy {
|
||||
MutableLiveData<Event<Int>>()
|
||||
}
|
||||
|
||||
private lateinit var conference: Conference
|
||||
|
||||
private val conferenceListener = object : ConferenceListenerStub() {
|
||||
|
|
@ -310,7 +307,12 @@ class ConferenceViewModel {
|
|||
"$TAG Failed to parse SIP URI [$uri] into address, can't add it to the conference!"
|
||||
)
|
||||
showRedToastEvent.postValue(
|
||||
Event(R.string.conference_failed_to_add_participant_invalid_address_toast)
|
||||
Event(
|
||||
Pair(
|
||||
R.string.conference_failed_to_add_participant_invalid_address_toast,
|
||||
R.drawable.warning_circle
|
||||
)
|
||||
)
|
||||
)
|
||||
}
|
||||
}
|
||||
|
|
@ -698,7 +700,12 @@ class ConferenceViewModel {
|
|||
)
|
||||
setNewLayout(ACTIVE_SPEAKER_LAYOUT)
|
||||
showRedToastEvent.postValue(
|
||||
Event(R.string.conference_too_many_participants_for_mosaic_layout_toast)
|
||||
Event(
|
||||
Pair(
|
||||
R.string.conference_too_many_participants_for_mosaic_layout_toast,
|
||||
R.drawable.warning_circle
|
||||
)
|
||||
)
|
||||
)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -106,6 +106,7 @@ abstract class AbstractNewTransferCallFragment : GenericCallFragment() {
|
|||
|
||||
viewModel.title.value = title
|
||||
binding.viewModel = viewModel
|
||||
observeToastEvents(viewModel)
|
||||
|
||||
binding.setBackClickListener {
|
||||
findNavController().popBackStack()
|
||||
|
|
|
|||
|
|
@ -71,6 +71,7 @@ class CallsListFragment : GenericCallFragment() {
|
|||
|
||||
binding.lifecycleOwner = viewLifecycleOwner
|
||||
binding.viewModel = viewModel
|
||||
observeToastEvents(viewModel)
|
||||
|
||||
binding.callsList.setHasFixedSize(true)
|
||||
binding.callsList.layoutManager = LinearLayoutManager(requireContext())
|
||||
|
|
|
|||
|
|
@ -204,9 +204,11 @@ class ConversationFragment : GenericCallFragment() {
|
|||
|
||||
viewModel.isInCallConversation.value = true
|
||||
binding.viewModel = viewModel
|
||||
observeToastEvents(viewModel)
|
||||
|
||||
sendMessageViewModel.isInCallConversation.value = true
|
||||
binding.sendMessageViewModel = sendMessageViewModel
|
||||
observeToastEvents(sendMessageViewModel)
|
||||
|
||||
binding.setBackClickListener {
|
||||
findNavController().popBackStack()
|
||||
|
|
@ -362,14 +364,6 @@ class ConversationFragment : GenericCallFragment() {
|
|||
}
|
||||
}
|
||||
|
||||
sendMessageViewModel.showRedToastEvent.observe(viewLifecycleOwner) {
|
||||
it.consume { pair ->
|
||||
val message = pair.first
|
||||
val icon = pair.second
|
||||
(requireActivity() as GenericActivity).showRedToast(message, icon)
|
||||
}
|
||||
}
|
||||
|
||||
viewModel.searchFilter.observe(viewLifecycleOwner) { filter ->
|
||||
viewModel.applyFilter(filter.trim())
|
||||
}
|
||||
|
|
@ -400,14 +394,6 @@ class ConversationFragment : GenericCallFragment() {
|
|||
}
|
||||
}
|
||||
|
||||
viewModel.showRedToastEvent.observe(viewLifecycleOwner) {
|
||||
it.consume { pair ->
|
||||
val message = pair.first
|
||||
val icon = pair.second
|
||||
(requireActivity() as GenericActivity).showRedToast(message, icon)
|
||||
}
|
||||
}
|
||||
|
||||
viewModel.messageDeletedEvent.observe(viewLifecycleOwner) {
|
||||
it.consume {
|
||||
val message = getString(R.string.conversation_message_deleted_toast)
|
||||
|
|
|
|||
|
|
@ -22,12 +22,12 @@ package org.linphone.ui.call.fragment
|
|||
import android.os.Bundle
|
||||
import android.view.View
|
||||
import androidx.annotation.UiThread
|
||||
import androidx.fragment.app.Fragment
|
||||
import androidx.lifecycle.ViewModelProvider
|
||||
import org.linphone.ui.GenericFragment
|
||||
import org.linphone.ui.call.viewmodel.SharedCallViewModel
|
||||
|
||||
@UiThread
|
||||
abstract class GenericCallFragment : Fragment() {
|
||||
abstract class GenericCallFragment : GenericFragment() {
|
||||
companion object {
|
||||
private const val TAG = "[Generic Call Fragment]"
|
||||
}
|
||||
|
|
|
|||
|
|
@ -21,17 +21,17 @@ package org.linphone.ui.call.model
|
|||
|
||||
import androidx.annotation.UiThread
|
||||
import androidx.lifecycle.MutableLiveData
|
||||
import androidx.lifecycle.ViewModel
|
||||
import java.util.Random
|
||||
import org.linphone.R
|
||||
import org.linphone.core.tools.Log
|
||||
import org.linphone.ui.GenericViewModel
|
||||
import org.linphone.utils.AppUtils
|
||||
import org.linphone.utils.Event
|
||||
|
||||
class ZrtpSasConfirmationDialogModel @UiThread constructor(
|
||||
authTokenToRead: String,
|
||||
private val authTokenToListen: String
|
||||
) : ViewModel() {
|
||||
) : GenericViewModel() {
|
||||
companion object {
|
||||
private const val TAG = "[ZRTP SAS Confirmation Dialog]"
|
||||
private const val ALPHABET = "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"
|
||||
|
|
|
|||
|
|
@ -22,19 +22,19 @@ package org.linphone.ui.call.viewmodel
|
|||
import androidx.annotation.UiThread
|
||||
import androidx.annotation.WorkerThread
|
||||
import androidx.lifecycle.MutableLiveData
|
||||
import androidx.lifecycle.ViewModel
|
||||
import org.linphone.LinphoneApplication.Companion.coreContext
|
||||
import org.linphone.R
|
||||
import org.linphone.core.Call
|
||||
import org.linphone.core.Core
|
||||
import org.linphone.core.CoreListenerStub
|
||||
import org.linphone.core.tools.Log
|
||||
import org.linphone.ui.GenericViewModel
|
||||
import org.linphone.ui.call.model.CallModel
|
||||
import org.linphone.utils.AppUtils
|
||||
import org.linphone.utils.Event
|
||||
import org.linphone.utils.LinphoneUtils
|
||||
|
||||
class CallsViewModel @UiThread constructor() : ViewModel() {
|
||||
class CallsViewModel @UiThread constructor() : GenericViewModel() {
|
||||
companion object {
|
||||
private const val TAG = "[Calls ViewModel]"
|
||||
}
|
||||
|
|
|
|||
|
|
@ -26,7 +26,6 @@ import androidx.annotation.UiThread
|
|||
import androidx.annotation.WorkerThread
|
||||
import androidx.core.app.ActivityCompat
|
||||
import androidx.lifecycle.MutableLiveData
|
||||
import androidx.lifecycle.ViewModel
|
||||
import androidx.lifecycle.viewModelScope
|
||||
import java.util.Locale
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
|
|
@ -51,6 +50,7 @@ import org.linphone.core.MediaEncryption
|
|||
import org.linphone.core.SecurityLevel
|
||||
import org.linphone.core.StreamType
|
||||
import org.linphone.core.tools.Log
|
||||
import org.linphone.ui.GenericViewModel
|
||||
import org.linphone.ui.call.conference.viewmodel.ConferenceViewModel
|
||||
import org.linphone.ui.call.model.AudioDeviceModel
|
||||
import org.linphone.ui.call.model.CallMediaEncryptionModel
|
||||
|
|
@ -63,7 +63,7 @@ import org.linphone.utils.AudioUtils
|
|||
import org.linphone.utils.Event
|
||||
import org.linphone.utils.LinphoneUtils
|
||||
|
||||
class CurrentCallViewModel @UiThread constructor() : ViewModel() {
|
||||
class CurrentCallViewModel @UiThread constructor() : GenericViewModel() {
|
||||
companion object {
|
||||
private const val TAG = "[Current Call ViewModel]"
|
||||
}
|
||||
|
|
|
|||
|
|
@ -21,11 +21,11 @@ package org.linphone.ui.call.viewmodel
|
|||
|
||||
import androidx.annotation.UiThread
|
||||
import androidx.lifecycle.MutableLiveData
|
||||
import androidx.lifecycle.ViewModel
|
||||
import androidx.window.layout.FoldingFeature
|
||||
import org.linphone.ui.GenericViewModel
|
||||
import org.linphone.utils.Event
|
||||
|
||||
class SharedCallViewModel @UiThread constructor() : ViewModel() {
|
||||
class SharedCallViewModel @UiThread constructor() : GenericViewModel() {
|
||||
val toggleFullScreenEvent = MutableLiveData<Event<Boolean>>()
|
||||
|
||||
val foldingState = MutableLiveData<FoldingFeature>()
|
||||
|
|
|
|||
|
|
@ -196,15 +196,23 @@ class MainActivity : GenericActivity() {
|
|||
}
|
||||
}
|
||||
|
||||
coreContext.greenToastToShowEvent.observe(this) {
|
||||
coreContext.showGreenToastEvent.observe(this) {
|
||||
it.consume { pair ->
|
||||
val message = pair.first
|
||||
val message = getString(pair.first)
|
||||
val icon = pair.second
|
||||
showGreenToast(message, icon)
|
||||
}
|
||||
}
|
||||
|
||||
coreContext.redToastToShowEvent.observe(this) {
|
||||
coreContext.showRedToastEvent.observe(this) {
|
||||
it.consume { pair ->
|
||||
val message = getString(pair.first)
|
||||
val icon = pair.second
|
||||
showRedToast(message, icon)
|
||||
}
|
||||
}
|
||||
|
||||
coreContext.showFormattedRedToastEvent.observe(this) {
|
||||
it.consume { pair ->
|
||||
val message = pair.first
|
||||
val icon = pair.second
|
||||
|
|
|
|||
|
|
@ -84,6 +84,7 @@ class ConversationDocumentsListFragment : SlidingPaneChildFragment() {
|
|||
|
||||
viewModel = ViewModelProvider(this)[ConversationDocumentsListViewModel::class.java]
|
||||
binding.viewModel = viewModel
|
||||
observeToastEvents(viewModel)
|
||||
|
||||
val localSipUri = args.localSipUri
|
||||
val remoteSipUri = args.remoteSipUri
|
||||
|
|
|
|||
|
|
@ -65,6 +65,7 @@ class ConversationEphemeralLifetimeFragment : SlidingPaneChildFragment() {
|
|||
|
||||
viewModel = ViewModelProvider(this)[ConversationEphemeralLifetimeViewModel::class.java]
|
||||
binding.viewModel = viewModel
|
||||
observeToastEvents(viewModel)
|
||||
|
||||
val lifetime = args.currentEphemeralLifetime
|
||||
Log.i("$TAG Current lifetime for ephemeral messages is [$lifetime]")
|
||||
|
|
|
|||
|
|
@ -352,6 +352,9 @@ class ConversationFragment : SlidingPaneChildFragment() {
|
|||
binding.viewModel = viewModel
|
||||
binding.sendMessageViewModel = sendMessageViewModel
|
||||
|
||||
observeToastEvents(viewModel)
|
||||
observeToastEvents(sendMessageViewModel)
|
||||
|
||||
binding.setBackClickListener {
|
||||
goBack()
|
||||
}
|
||||
|
|
@ -592,14 +595,6 @@ class ConversationFragment : SlidingPaneChildFragment() {
|
|||
}
|
||||
}
|
||||
|
||||
sendMessageViewModel.showRedToastEvent.observe(viewLifecycleOwner) {
|
||||
it.consume { pair ->
|
||||
val message = pair.first
|
||||
val icon = pair.second
|
||||
(requireActivity() as GenericActivity).showRedToast(message, icon)
|
||||
}
|
||||
}
|
||||
|
||||
viewModel.searchFilter.observe(viewLifecycleOwner) { filter ->
|
||||
viewModel.applyFilter(filter.trim())
|
||||
}
|
||||
|
|
@ -662,22 +657,6 @@ class ConversationFragment : SlidingPaneChildFragment() {
|
|||
}
|
||||
}
|
||||
|
||||
viewModel.showGreenToastEvent.observe(viewLifecycleOwner) {
|
||||
it.consume { pair ->
|
||||
val message = pair.first
|
||||
val icon = pair.second
|
||||
(requireActivity() as GenericActivity).showGreenToast(message, icon)
|
||||
}
|
||||
}
|
||||
|
||||
viewModel.showRedToastEvent.observe(viewLifecycleOwner) {
|
||||
it.consume { pair ->
|
||||
val message = pair.first
|
||||
val icon = pair.second
|
||||
(requireActivity() as GenericActivity).showRedToast(message, icon)
|
||||
}
|
||||
}
|
||||
|
||||
viewModel.messageDeletedEvent.observe(viewLifecycleOwner) {
|
||||
it.consume {
|
||||
val message = getString(R.string.conversation_message_deleted_toast)
|
||||
|
|
|
|||
|
|
@ -86,6 +86,7 @@ class ConversationInfoFragment : SlidingPaneChildFragment() {
|
|||
|
||||
viewModel = ViewModelProvider(this)[ConversationInfoViewModel::class.java]
|
||||
binding.viewModel = viewModel
|
||||
observeToastEvents(viewModel)
|
||||
|
||||
val localSipUri = args.localSipUri
|
||||
val remoteSipUri = args.remoteSipUri
|
||||
|
|
@ -179,22 +180,6 @@ class ConversationInfoFragment : SlidingPaneChildFragment() {
|
|||
}
|
||||
}
|
||||
|
||||
viewModel.showGreenToastEvent.observe(viewLifecycleOwner) {
|
||||
it.consume { pair ->
|
||||
val message = pair.first
|
||||
val icon = pair.second
|
||||
(requireActivity() as GenericActivity).showGreenToast(message, icon)
|
||||
}
|
||||
}
|
||||
|
||||
viewModel.showRedToastEvent.observe(viewLifecycleOwner) {
|
||||
it.consume { pair ->
|
||||
val message = pair.first
|
||||
val icon = pair.second
|
||||
(requireActivity() as GenericActivity).showRedToast(message, icon)
|
||||
}
|
||||
}
|
||||
|
||||
sharedViewModel.listOfSelectedSipUrisEvent.observe(viewLifecycleOwner) {
|
||||
it.consume { list ->
|
||||
Log.i("$TAG Found [${list.size}] new participants to add to the group, let's do it")
|
||||
|
|
|
|||
|
|
@ -85,6 +85,7 @@ class ConversationMediaListFragment : SlidingPaneChildFragment() {
|
|||
|
||||
viewModel = ViewModelProvider(this)[ConversationMediaListViewModel::class.java]
|
||||
binding.viewModel = viewModel
|
||||
observeToastEvents(viewModel)
|
||||
|
||||
val localSipUri = args.localSipUri
|
||||
val remoteSipUri = args.remoteSipUri
|
||||
|
|
|
|||
|
|
@ -66,8 +66,8 @@ class StartConversationFragment : GenericAddressPickerFragment() {
|
|||
super.onViewCreated(view, savedInstanceState)
|
||||
|
||||
binding.lifecycleOwner = viewLifecycleOwner
|
||||
|
||||
binding.viewModel = viewModel
|
||||
observeToastEvents(viewModel)
|
||||
|
||||
binding.setBackClickListener {
|
||||
goBack()
|
||||
|
|
|
|||
|
|
@ -36,7 +36,7 @@ class EventLogModel @WorkerThread constructor(
|
|||
onJoinConferenceClicked: ((uri: String) -> Unit)? = null,
|
||||
onWebUrlClicked: ((url: String) -> Unit)? = null,
|
||||
onContactClicked: ((friendRefKey: String) -> Unit)? = null,
|
||||
onRedToastToShow: ((pair: Pair<String, Int>) -> Unit)? = null
|
||||
onRedToastToShow: ((pair: Pair<Int, Int>) -> Unit)? = null
|
||||
) {
|
||||
companion object {
|
||||
private const val TAG = "[Event Log Model]"
|
||||
|
|
|
|||
|
|
@ -77,7 +77,7 @@ class MessageModel @WorkerThread constructor(
|
|||
private val onJoinConferenceClicked: ((uri: String) -> Unit)? = null,
|
||||
private val onWebUrlClicked: ((url: String) -> Unit)? = null,
|
||||
private val onContactClicked: ((friendRefKey: String) -> Unit)? = null,
|
||||
private val onRedToastToShow: ((pair: Pair<String, Int>) -> Unit)? = null
|
||||
private val onRedToastToShow: ((pair: Pair<Int, Int>) -> Unit)? = null
|
||||
) {
|
||||
companion object {
|
||||
private const val TAG = "[Message Model]"
|
||||
|
|
@ -702,8 +702,9 @@ class MessageModel @WorkerThread constructor(
|
|||
val lowMediaVolume = AudioUtils.isMediaVolumeLow(coreContext.context)
|
||||
if (lowMediaVolume) {
|
||||
Log.w("$TAG Media volume is low, notifying user as they may not hear voice message")
|
||||
val message = AppUtils.getString(R.string.toast_low_media_volume)
|
||||
onRedToastToShow?.invoke(Pair(message, R.drawable.speaker_slash))
|
||||
onRedToastToShow?.invoke(
|
||||
Pair(R.string.toast_low_media_volume, R.drawable.speaker_slash)
|
||||
)
|
||||
}
|
||||
|
||||
if (voiceRecordAudioFocusRequest == null) {
|
||||
|
|
|
|||
|
|
@ -22,14 +22,14 @@ package org.linphone.ui.main.chat.viewmodel
|
|||
import androidx.annotation.UiThread
|
||||
import androidx.annotation.WorkerThread
|
||||
import androidx.lifecycle.MutableLiveData
|
||||
import androidx.lifecycle.ViewModel
|
||||
import org.linphone.LinphoneApplication.Companion.coreContext
|
||||
import org.linphone.core.ChatRoom
|
||||
import org.linphone.core.Factory
|
||||
import org.linphone.core.tools.Log
|
||||
import org.linphone.ui.GenericViewModel
|
||||
import org.linphone.utils.Event
|
||||
|
||||
abstract class AbstractConversationViewModel : ViewModel() {
|
||||
abstract class AbstractConversationViewModel : GenericViewModel() {
|
||||
companion object {
|
||||
private const val TAG = "[Abstract Conversation ViewModel]"
|
||||
}
|
||||
|
|
|
|||
|
|
@ -21,9 +21,9 @@ package org.linphone.ui.main.chat.viewmodel
|
|||
|
||||
import androidx.annotation.UiThread
|
||||
import androidx.lifecycle.MutableLiveData
|
||||
import androidx.lifecycle.ViewModel
|
||||
import org.linphone.ui.GenericViewModel
|
||||
|
||||
class ConversationEphemeralLifetimeViewModel @UiThread constructor() : ViewModel() {
|
||||
class ConversationEphemeralLifetimeViewModel @UiThread constructor() : GenericViewModel() {
|
||||
val currentlySelectedValue = MutableLiveData<Long>()
|
||||
|
||||
init {
|
||||
|
|
|
|||
|
|
@ -92,14 +92,6 @@ class ConversationInfoViewModel @UiThread constructor() : AbstractConversationVi
|
|||
MutableLiveData<Event<ArrayList<String>>>()
|
||||
}
|
||||
|
||||
val showGreenToastEvent: MutableLiveData<Event<Pair<String, Int>>> by lazy {
|
||||
MutableLiveData<Event<Pair<String, Int>>>()
|
||||
}
|
||||
|
||||
val showRedToastEvent: MutableLiveData<Event<Pair<String, Int>>> by lazy {
|
||||
MutableLiveData<Event<Pair<String, Int>>>()
|
||||
}
|
||||
|
||||
private val chatRoomListener = object : ChatRoomListenerStub() {
|
||||
@WorkerThread
|
||||
override fun onParticipantAdded(chatRoom: ChatRoom, eventLog: EventLog) {
|
||||
|
|
@ -108,7 +100,7 @@ class ConversationInfoViewModel @UiThread constructor() : AbstractConversationVi
|
|||
R.string.toast_participant_added_to_conversation,
|
||||
getParticipant(eventLog)
|
||||
)
|
||||
showGreenToastEvent.postValue(Event(Pair(message, R.drawable.user_circle)))
|
||||
showFormattedGreenToastEvent.postValue(Event(Pair(message, R.drawable.user_circle)))
|
||||
|
||||
computeParticipantsList()
|
||||
infoChangedEvent.postValue(Event(true))
|
||||
|
|
@ -121,7 +113,7 @@ class ConversationInfoViewModel @UiThread constructor() : AbstractConversationVi
|
|||
R.string.toast_participant_removed_from_conversation,
|
||||
getParticipant(eventLog)
|
||||
)
|
||||
showGreenToastEvent.postValue(Event(Pair(message, R.drawable.user_circle)))
|
||||
showFormattedGreenToastEvent.postValue(Event(Pair(message, R.drawable.user_circle)))
|
||||
|
||||
computeParticipantsList()
|
||||
infoChangedEvent.postValue(Event(true))
|
||||
|
|
@ -143,7 +135,7 @@ class ConversationInfoViewModel @UiThread constructor() : AbstractConversationVi
|
|||
getParticipant(eventLog)
|
||||
)
|
||||
}
|
||||
showGreenToastEvent.postValue(Event(Pair(message, R.drawable.user_circle)))
|
||||
showFormattedGreenToastEvent.postValue(Event(Pair(message, R.drawable.user_circle)))
|
||||
|
||||
computeParticipantsList()
|
||||
}
|
||||
|
|
@ -153,10 +145,9 @@ class ConversationInfoViewModel @UiThread constructor() : AbstractConversationVi
|
|||
Log.i(
|
||||
"$TAG Conversation [${LinphoneUtils.getChatRoomId(chatRoom)}] has a new subject [${chatRoom.subject}]"
|
||||
)
|
||||
val message = AppUtils.getString(
|
||||
R.string.toast_conversation_subject_changed
|
||||
showGreenToastEvent.postValue(
|
||||
Event(Pair(R.string.toast_conversation_subject_changed, R.drawable.check))
|
||||
)
|
||||
showGreenToastEvent.postValue(Event(Pair(message, R.drawable.check)))
|
||||
|
||||
subject.postValue(chatRoom.subject)
|
||||
infoChangedEvent.postValue(Event(true))
|
||||
|
|
@ -165,24 +156,38 @@ class ConversationInfoViewModel @UiThread constructor() : AbstractConversationVi
|
|||
@WorkerThread
|
||||
override fun onEphemeralEvent(chatRoom: ChatRoom, eventLog: EventLog) {
|
||||
Log.i("$TAG Ephemeral event [${eventLog.type}]")
|
||||
val message = when (eventLog.type) {
|
||||
when (eventLog.type) {
|
||||
EventLog.Type.ConferenceEphemeralMessageEnabled -> {
|
||||
AppUtils.getString(
|
||||
R.string.toast_conversation_ephemeral_messages_enabled
|
||||
showGreenToastEvent.postValue(
|
||||
Event(
|
||||
Pair(
|
||||
R.string.toast_conversation_ephemeral_messages_enabled,
|
||||
R.drawable.clock_countdown
|
||||
)
|
||||
)
|
||||
)
|
||||
}
|
||||
EventLog.Type.ConferenceEphemeralMessageDisabled -> {
|
||||
AppUtils.getString(
|
||||
R.string.toast_conversation_ephemeral_messages_disabled
|
||||
showGreenToastEvent.postValue(
|
||||
Event(
|
||||
Pair(
|
||||
R.string.toast_conversation_ephemeral_messages_disabled,
|
||||
R.drawable.clock_countdown
|
||||
)
|
||||
)
|
||||
)
|
||||
}
|
||||
else -> {
|
||||
AppUtils.getString(
|
||||
R.string.toast_conversation_ephemeral_messages_lifetime_changed
|
||||
showGreenToastEvent.postValue(
|
||||
Event(
|
||||
Pair(
|
||||
R.string.toast_conversation_ephemeral_messages_lifetime_changed,
|
||||
R.drawable.clock_countdown
|
||||
)
|
||||
)
|
||||
)
|
||||
}
|
||||
}
|
||||
showGreenToastEvent.postValue(Event(Pair(message, R.drawable.clock_countdown)))
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -203,18 +208,26 @@ class ConversationInfoViewModel @UiThread constructor() : AbstractConversationVi
|
|||
coreContext.startVideoCall(conferenceAddress)
|
||||
} else {
|
||||
Log.e("$TAG Conference info URI is null!")
|
||||
val message = AppUtils.getString(
|
||||
R.string.conference_failed_to_create_group_call_toast
|
||||
showRedToastEvent.postValue(
|
||||
Event(
|
||||
Pair(
|
||||
R.string.conference_failed_to_create_group_call_toast,
|
||||
R.drawable.warning_circle
|
||||
)
|
||||
)
|
||||
)
|
||||
showRedToastEvent.postValue(Event(Pair(message, R.drawable.warning_circle)))
|
||||
}
|
||||
} else if (state == ConferenceScheduler.State.Error) {
|
||||
conferenceScheduler.removeListener(this)
|
||||
Log.e("$TAG Failed to create group call!")
|
||||
val message = AppUtils.getString(
|
||||
R.string.conference_failed_to_create_group_call_toast
|
||||
showRedToastEvent.postValue(
|
||||
Event(
|
||||
Pair(
|
||||
R.string.conference_failed_to_create_group_call_toast,
|
||||
R.drawable.warning_circle
|
||||
)
|
||||
)
|
||||
)
|
||||
showRedToastEvent.postValue(Event(Pair(message, R.drawable.warning_circle)))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -451,10 +464,14 @@ class ConversationInfoViewModel @UiThread constructor() : AbstractConversationVi
|
|||
val ok = chatRoom.addParticipants(toAddList.toTypedArray())
|
||||
if (!ok) {
|
||||
Log.w("$TAG Failed to add some/all participants to the group!")
|
||||
val message = AppUtils.getString(
|
||||
R.string.toast_failed_to_add_participant_to_group_conversation
|
||||
showRedToastEvent.postValue(
|
||||
Event(
|
||||
Pair(
|
||||
R.string.toast_failed_to_add_participant_to_group_conversation,
|
||||
R.drawable.warning_circle
|
||||
)
|
||||
)
|
||||
)
|
||||
showRedToastEvent.postValue(Event(Pair(message, R.drawable.warning_circle)))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -116,14 +116,6 @@ class ConversationViewModel @UiThread constructor() : AbstractConversationViewMo
|
|||
MutableLiveData<Event<String>>()
|
||||
}
|
||||
|
||||
val showGreenToastEvent: MutableLiveData<Event<Pair<String, Int>>> by lazy {
|
||||
MutableLiveData<Event<Pair<String, Int>>>()
|
||||
}
|
||||
|
||||
val showRedToastEvent: MutableLiveData<Event<Pair<String, Int>>> by lazy {
|
||||
MutableLiveData<Event<Pair<String, Int>>>()
|
||||
}
|
||||
|
||||
val messageDeletedEvent: MutableLiveData<Event<Boolean>> by lazy {
|
||||
MutableLiveData<Event<Boolean>>()
|
||||
}
|
||||
|
|
@ -295,18 +287,26 @@ class ConversationViewModel @UiThread constructor() : AbstractConversationViewMo
|
|||
coreContext.startVideoCall(conferenceAddress)
|
||||
} else {
|
||||
Log.e("$TAG Conference info URI is null!")
|
||||
val message = AppUtils.getString(
|
||||
R.string.conference_failed_to_create_group_call_toast
|
||||
showRedToastEvent.postValue(
|
||||
Event(
|
||||
Pair(
|
||||
R.string.conference_failed_to_create_group_call_toast,
|
||||
R.drawable.warning_circle
|
||||
)
|
||||
)
|
||||
)
|
||||
showRedToastEvent.postValue(Event(Pair(message, R.drawable.warning_circle)))
|
||||
}
|
||||
} else if (state == ConferenceScheduler.State.Error) {
|
||||
conferenceScheduler.removeListener(this)
|
||||
Log.e("$TAG Failed to create group call!")
|
||||
val message = AppUtils.getString(
|
||||
R.string.conference_failed_to_create_group_call_toast
|
||||
showRedToastEvent.postValue(
|
||||
Event(
|
||||
Pair(
|
||||
R.string.conference_failed_to_create_group_call_toast,
|
||||
R.drawable.warning_circle
|
||||
)
|
||||
)
|
||||
)
|
||||
showRedToastEvent.postValue(Event(Pair(message, R.drawable.warning_circle)))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -864,16 +864,24 @@ class ConversationViewModel @UiThread constructor() : AbstractConversationViewMo
|
|||
Log.i(
|
||||
"$TAG File [$filePath] has been successfully exported to documents"
|
||||
)
|
||||
val message = AppUtils.getString(
|
||||
R.string.toast_file_successfully_exported_to_documents
|
||||
showGreenToastEvent.postValue(
|
||||
Event(
|
||||
Pair(
|
||||
R.string.toast_file_successfully_exported_to_documents,
|
||||
R.drawable.check
|
||||
)
|
||||
)
|
||||
)
|
||||
showGreenToastEvent.postValue(Event(Pair(message, R.drawable.check)))
|
||||
} else {
|
||||
Log.e("$TAG Failed to export file [$filePath] to documents!")
|
||||
val message = AppUtils.getString(
|
||||
R.string.toast_export_file_to_documents_error
|
||||
showRedToastEvent.postValue(
|
||||
Event(
|
||||
Pair(
|
||||
R.string.toast_export_file_to_documents_error,
|
||||
R.drawable.warning_circle
|
||||
)
|
||||
)
|
||||
)
|
||||
showRedToastEvent.postValue(Event(Pair(message, R.drawable.warning_circle)))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -32,7 +32,6 @@ import org.linphone.core.CoreListenerStub
|
|||
import org.linphone.core.tools.Log
|
||||
import org.linphone.ui.main.chat.model.ConversationModel
|
||||
import org.linphone.ui.main.viewmodel.AbstractMainViewModel
|
||||
import org.linphone.utils.AppUtils
|
||||
import org.linphone.utils.Event
|
||||
import org.linphone.utils.LinphoneUtils
|
||||
|
||||
|
|
@ -45,10 +44,6 @@ class ConversationsListViewModel @UiThread constructor() : AbstractMainViewModel
|
|||
|
||||
val fetchInProgress = MutableLiveData<Boolean>()
|
||||
|
||||
val showGreenToastEvent: MutableLiveData<Event<Pair<String, Int>>> by lazy {
|
||||
MutableLiveData<Event<Pair<String, Int>>>()
|
||||
}
|
||||
|
||||
private val coreListener = object : CoreListenerStub() {
|
||||
@WorkerThread
|
||||
override fun onChatRoomStateChanged(
|
||||
|
|
@ -67,9 +62,10 @@ class ConversationsListViewModel @UiThread constructor() : AbstractMainViewModel
|
|||
ChatRoom.State.Deleted -> {
|
||||
computeChatRoomsList(currentFilter)
|
||||
|
||||
val message = AppUtils.getString(R.string.toast_conversation_deleted)
|
||||
showGreenToastEvent.postValue(
|
||||
Event(Pair(message, R.drawable.chat_teardrop_text))
|
||||
Event(
|
||||
Pair(R.string.toast_conversation_deleted, R.drawable.chat_teardrop_text)
|
||||
)
|
||||
)
|
||||
}
|
||||
else -> {}
|
||||
|
|
|
|||
|
|
@ -25,7 +25,6 @@ import androidx.annotation.UiThread
|
|||
import androidx.annotation.WorkerThread
|
||||
import androidx.core.app.ActivityCompat
|
||||
import androidx.lifecycle.MutableLiveData
|
||||
import androidx.lifecycle.ViewModel
|
||||
import androidx.lifecycle.viewModelScope
|
||||
import androidx.media.AudioFocusRequestCompat
|
||||
import java.text.SimpleDateFormat
|
||||
|
|
@ -47,16 +46,16 @@ import org.linphone.core.Player
|
|||
import org.linphone.core.PlayerListener
|
||||
import org.linphone.core.Recorder
|
||||
import org.linphone.core.tools.Log
|
||||
import org.linphone.ui.GenericViewModel
|
||||
import org.linphone.ui.main.chat.model.FileModel
|
||||
import org.linphone.ui.main.chat.model.MessageModel
|
||||
import org.linphone.ui.main.chat.model.ParticipantModel
|
||||
import org.linphone.utils.AppUtils
|
||||
import org.linphone.utils.AudioUtils
|
||||
import org.linphone.utils.Event
|
||||
import org.linphone.utils.FileUtils
|
||||
import org.linphone.utils.LinphoneUtils
|
||||
|
||||
class SendMessageInConversationViewModel @UiThread constructor() : ViewModel() {
|
||||
class SendMessageInConversationViewModel @UiThread constructor() : GenericViewModel() {
|
||||
companion object {
|
||||
private const val TAG = "[Send Message In Conversation ViewModel]"
|
||||
}
|
||||
|
|
@ -120,10 +119,6 @@ class SendMessageInConversationViewModel @UiThread constructor() : ViewModel() {
|
|||
MutableLiveData<Event<Boolean>>()
|
||||
}
|
||||
|
||||
val showRedToastEvent: MutableLiveData<Event<Pair<String, Int>>> by lazy {
|
||||
MutableLiveData<Event<Pair<String, Int>>>()
|
||||
}
|
||||
|
||||
lateinit var chatRoom: ChatRoom
|
||||
|
||||
private var chatMessageToReplyTo: ChatMessage? = null
|
||||
|
|
@ -521,10 +516,14 @@ class SendMessageInConversationViewModel @UiThread constructor() : ViewModel() {
|
|||
"$TAG Max duration for voice recording exceeded (${maxVoiceRecordDuration}ms), stopping."
|
||||
)
|
||||
stopVoiceRecorder()
|
||||
val message = AppUtils.getString(
|
||||
R.string.toast_voice_recording_max_duration_reached
|
||||
showRedToastEvent.postValue(
|
||||
Event(
|
||||
Pair(
|
||||
R.string.toast_voice_recording_max_duration_reached,
|
||||
R.drawable.warning_circle
|
||||
)
|
||||
)
|
||||
)
|
||||
showRedToastEvent.postValue(Event(Pair(message, R.drawable.warning_circle)))
|
||||
}
|
||||
}
|
||||
}.launchIn(viewModelScope)
|
||||
|
|
@ -589,8 +588,9 @@ class SendMessageInConversationViewModel @UiThread constructor() : ViewModel() {
|
|||
val lowMediaVolume = AudioUtils.isMediaVolumeLow(context)
|
||||
if (lowMediaVolume) {
|
||||
Log.w("$TAG Media volume is low, notifying user as they may not hear voice message")
|
||||
val message = AppUtils.getString(R.string.toast_low_media_volume)
|
||||
showRedToastEvent.postValue(Event(Pair(message, R.drawable.speaker_slash)))
|
||||
showRedToastEvent.postValue(
|
||||
Event(Pair(R.string.toast_low_media_volume, R.drawable.speaker_slash))
|
||||
)
|
||||
}
|
||||
|
||||
if (voiceRecordAudioFocusRequest == null) {
|
||||
|
|
|
|||
|
|
@ -98,6 +98,7 @@ class ContactFragment : SlidingPaneChildFragment() {
|
|||
|
||||
viewModel = ViewModelProvider(this)[ContactViewModel::class.java]
|
||||
binding.viewModel = viewModel
|
||||
observeToastEvents(viewModel)
|
||||
|
||||
val refKey = args.contactRefKey
|
||||
Log.i("$TAG Looking up for contact with ref key [$refKey]")
|
||||
|
|
|
|||
|
|
@ -42,7 +42,6 @@ import org.linphone.R
|
|||
import org.linphone.core.tools.Log
|
||||
import org.linphone.databinding.ContactsListFilterPopupMenuBinding
|
||||
import org.linphone.databinding.ContactsListFragmentBinding
|
||||
import org.linphone.ui.GenericActivity
|
||||
import org.linphone.ui.main.contacts.adapter.ContactsListAdapter
|
||||
import org.linphone.ui.main.contacts.model.ContactAvatarModel
|
||||
import org.linphone.ui.main.contacts.viewmodel.ContactsListViewModel
|
||||
|
|
@ -105,6 +104,7 @@ class ContactsListFragment : AbstractMainFragment() {
|
|||
|
||||
binding.lifecycleOwner = viewLifecycleOwner
|
||||
binding.viewModel = listViewModel
|
||||
observeToastEvents(listViewModel)
|
||||
|
||||
binding.contactsList.setHasFixedSize(true)
|
||||
binding.contactsList.layoutManager = LinearLayoutManager(requireContext())
|
||||
|
|
@ -150,15 +150,6 @@ class ContactsListFragment : AbstractMainFragment() {
|
|||
}
|
||||
}
|
||||
|
||||
listViewModel.showGreenToastEvent.observe(viewLifecycleOwner) {
|
||||
it.consume { message ->
|
||||
(requireActivity() as GenericActivity).showRedToast(
|
||||
getString(message),
|
||||
R.drawable.check
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
binding.setOnNewContactClicked {
|
||||
sharedViewModel.showNewContactEvent.value = Event(true)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -115,6 +115,7 @@ class EditContactFragment : SlidingPaneChildFragment() {
|
|||
|
||||
binding.lifecycleOwner = viewLifecycleOwner
|
||||
binding.viewModel = viewModel
|
||||
observeToastEvents(viewModel)
|
||||
|
||||
val refKey = args.contactRefKey
|
||||
Log.i("$TAG Looking up for contact with ref key [$refKey]")
|
||||
|
|
@ -182,15 +183,6 @@ class EditContactFragment : SlidingPaneChildFragment() {
|
|||
removeCell(model)
|
||||
}
|
||||
}
|
||||
|
||||
viewModel.showRedToastEvent.observe(viewLifecycleOwner) {
|
||||
it.consume { message ->
|
||||
(requireActivity() as GenericActivity).showRedToast(
|
||||
getString(message),
|
||||
R.drawable.warning_circle
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override fun onResume() {
|
||||
|
|
|
|||
|
|
@ -43,14 +43,14 @@ import org.linphone.ui.GenericActivity
|
|||
import org.linphone.ui.main.MainActivity
|
||||
import org.linphone.ui.main.contacts.model.NewOrEditNumberOrAddressModel
|
||||
import org.linphone.ui.main.contacts.viewmodel.ContactNewOrEditViewModel
|
||||
import org.linphone.ui.main.fragment.GenericFragment
|
||||
import org.linphone.ui.main.fragment.GenericMainFragment
|
||||
import org.linphone.ui.main.history.model.ConfirmationDialogModel
|
||||
import org.linphone.utils.DialogUtils
|
||||
import org.linphone.utils.Event
|
||||
import org.linphone.utils.FileUtils
|
||||
|
||||
@UiThread
|
||||
class NewContactFragment : GenericFragment() {
|
||||
class NewContactFragment : GenericMainFragment() {
|
||||
companion object {
|
||||
private const val TAG = "[New Contact Fragment]"
|
||||
}
|
||||
|
|
@ -111,6 +111,7 @@ class NewContactFragment : GenericFragment() {
|
|||
|
||||
viewModel = ViewModelProvider(this)[ContactNewOrEditViewModel::class.java]
|
||||
binding.viewModel = viewModel
|
||||
observeToastEvents(viewModel)
|
||||
|
||||
val addressToAdd = sharedViewModel.sipAddressToAddToNewContact
|
||||
if (addressToAdd.isNotEmpty()) {
|
||||
|
|
@ -180,15 +181,6 @@ class NewContactFragment : GenericFragment() {
|
|||
removeCell(model)
|
||||
}
|
||||
}
|
||||
|
||||
viewModel.showRedToastEvent.observe(viewLifecycleOwner) {
|
||||
it.consume { message ->
|
||||
(requireActivity() as GenericActivity).showRedToast(
|
||||
getString(message),
|
||||
R.drawable.warning_circle
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override fun onResume() {
|
||||
|
|
|
|||
|
|
@ -24,7 +24,6 @@ import androidx.annotation.AnyThread
|
|||
import androidx.annotation.UiThread
|
||||
import androidx.annotation.WorkerThread
|
||||
import androidx.lifecycle.MutableLiveData
|
||||
import androidx.lifecycle.ViewModel
|
||||
import androidx.lifecycle.viewModelScope
|
||||
import kotlinx.coroutines.launch
|
||||
import org.linphone.LinphoneApplication.Companion.coreContext
|
||||
|
|
@ -34,11 +33,12 @@ import org.linphone.core.Friend
|
|||
import org.linphone.core.FriendList.Status
|
||||
import org.linphone.core.SubscribePolicy
|
||||
import org.linphone.core.tools.Log
|
||||
import org.linphone.ui.GenericViewModel
|
||||
import org.linphone.ui.main.contacts.model.NewOrEditNumberOrAddressModel
|
||||
import org.linphone.utils.Event
|
||||
import org.linphone.utils.FileUtils
|
||||
|
||||
class ContactNewOrEditViewModel @UiThread constructor() : ViewModel() {
|
||||
class ContactNewOrEditViewModel @UiThread constructor() : GenericViewModel() {
|
||||
companion object {
|
||||
private const val TAG = "[Contact New/Edit View Model]"
|
||||
|
||||
|
|
@ -75,10 +75,6 @@ class ContactNewOrEditViewModel @UiThread constructor() : ViewModel() {
|
|||
|
||||
val removeNewNumberOrAddressFieldEvent = MutableLiveData<Event<NewOrEditNumberOrAddressModel>>()
|
||||
|
||||
val showRedToastEvent: MutableLiveData<Event<Int>> by lazy {
|
||||
MutableLiveData<Event<Int>>()
|
||||
}
|
||||
|
||||
@UiThread
|
||||
fun findFriendByRefKey(refKey: String?) {
|
||||
reset()
|
||||
|
|
@ -143,7 +139,12 @@ class ContactNewOrEditViewModel @UiThread constructor() : ViewModel() {
|
|||
if (fn.isEmpty() && ln.isEmpty() && organization.isEmpty()) {
|
||||
Log.e("$TAG At least a mandatory field wasn't filled, aborting save")
|
||||
showRedToastEvent.postValue(
|
||||
Event(R.string.contact_editor_mandatory_field_not_filled_toast)
|
||||
Event(
|
||||
Pair(
|
||||
R.string.contact_editor_mandatory_field_not_filled_toast,
|
||||
R.drawable.warning_circle
|
||||
)
|
||||
)
|
||||
)
|
||||
return
|
||||
}
|
||||
|
|
|
|||
|
|
@ -22,7 +22,6 @@ package org.linphone.ui.main.contacts.viewmodel
|
|||
import androidx.annotation.UiThread
|
||||
import androidx.annotation.WorkerThread
|
||||
import androidx.lifecycle.MutableLiveData
|
||||
import androidx.lifecycle.ViewModel
|
||||
import androidx.lifecycle.viewModelScope
|
||||
import java.io.File
|
||||
import java.util.Locale
|
||||
|
|
@ -42,6 +41,7 @@ import org.linphone.core.CoreListenerStub
|
|||
import org.linphone.core.Friend
|
||||
import org.linphone.core.SecurityLevel
|
||||
import org.linphone.core.tools.Log
|
||||
import org.linphone.ui.GenericViewModel
|
||||
import org.linphone.ui.main.contacts.model.ContactAvatarModel
|
||||
import org.linphone.ui.main.contacts.model.ContactDeviceModel
|
||||
import org.linphone.ui.main.contacts.model.ContactNumberOrAddressClickListener
|
||||
|
|
@ -52,7 +52,7 @@ import org.linphone.utils.Event
|
|||
import org.linphone.utils.FileUtils
|
||||
import org.linphone.utils.LinphoneUtils
|
||||
|
||||
class ContactViewModel @UiThread constructor() : ViewModel() {
|
||||
class ContactViewModel @UiThread constructor() : GenericViewModel() {
|
||||
companion object {
|
||||
private const val TAG = "[Contact ViewModel]"
|
||||
|
||||
|
|
|
|||
|
|
@ -64,10 +64,6 @@ class ContactsListViewModel @UiThread constructor() : AbstractMainViewModel() {
|
|||
MutableLiveData<Event<Pair<String, File>>>()
|
||||
}
|
||||
|
||||
val showGreenToastEvent: MutableLiveData<Event<Int>> by lazy {
|
||||
MutableLiveData<Event<Int>>()
|
||||
}
|
||||
|
||||
private var previousFilter = "NotSet"
|
||||
private var domainFilter = ""
|
||||
|
||||
|
|
@ -223,7 +219,9 @@ class ContactsListViewModel @UiThread constructor() : AbstractMainViewModel() {
|
|||
coreContext.contactsManager.contactRemoved(contactModel.friend)
|
||||
contactModel.friend.remove()
|
||||
coreContext.contactsManager.notifyContactsListChanged()
|
||||
showGreenToastEvent.postValue(Event(R.string.contact_deleted_toast))
|
||||
showGreenToastEvent.postValue(
|
||||
Event(Pair(R.string.contact_deleted_toast, R.drawable.warning_circle))
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -40,14 +40,13 @@ import kotlinx.coroutines.launch
|
|||
import org.linphone.R
|
||||
import org.linphone.core.tools.Log
|
||||
import org.linphone.databinding.FileViewerFragmentBinding
|
||||
import org.linphone.ui.GenericActivity
|
||||
import org.linphone.ui.main.file_media_viewer.adapter.PdfPagesListAdapter
|
||||
import org.linphone.ui.main.file_media_viewer.viewmodel.FileViewModel
|
||||
import org.linphone.ui.main.fragment.GenericFragment
|
||||
import org.linphone.ui.main.fragment.GenericMainFragment
|
||||
import org.linphone.utils.FileUtils
|
||||
|
||||
@UiThread
|
||||
class FileViewerFragment : GenericFragment() {
|
||||
class FileViewerFragment : GenericMainFragment() {
|
||||
companion object {
|
||||
private const val TAG = "[File Viewer Fragment]"
|
||||
|
||||
|
|
@ -93,6 +92,7 @@ class FileViewerFragment : GenericFragment() {
|
|||
|
||||
binding.lifecycleOwner = viewLifecycleOwner
|
||||
binding.viewModel = viewModel
|
||||
observeToastEvents(viewModel)
|
||||
|
||||
val path = args.path
|
||||
val preLoadedContent = args.content
|
||||
|
|
@ -157,22 +157,6 @@ class FileViewerFragment : GenericFragment() {
|
|||
startActivityForResult(intent, EXPORT_FILE_AS_DOCUMENT)
|
||||
}
|
||||
}
|
||||
|
||||
viewModel.showGreenToastEvent.observe(viewLifecycleOwner) {
|
||||
it.consume { pair ->
|
||||
val message = pair.first
|
||||
val icon = pair.second
|
||||
(requireActivity() as GenericActivity).showGreenToast(message, icon)
|
||||
}
|
||||
}
|
||||
|
||||
viewModel.showRedToastEvent.observe(viewLifecycleOwner) {
|
||||
it.consume { pair ->
|
||||
val message = pair.first
|
||||
val icon = pair.second
|
||||
(requireActivity() as GenericActivity).showRedToast(message, icon)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override fun onResume() {
|
||||
|
|
|
|||
|
|
@ -41,11 +41,11 @@ import org.linphone.databinding.FileMediaViewerFragmentBinding
|
|||
import org.linphone.ui.GenericActivity
|
||||
import org.linphone.ui.main.chat.viewmodel.ConversationMediaListViewModel
|
||||
import org.linphone.ui.main.file_media_viewer.adapter.MediaListAdapter
|
||||
import org.linphone.ui.main.fragment.GenericFragment
|
||||
import org.linphone.ui.main.fragment.GenericMainFragment
|
||||
import org.linphone.utils.AppUtils
|
||||
import org.linphone.utils.FileUtils
|
||||
|
||||
class MediaListViewerFragment : GenericFragment() {
|
||||
class MediaListViewerFragment : GenericMainFragment() {
|
||||
companion object {
|
||||
private const val TAG = "[Media List Viewer]"
|
||||
}
|
||||
|
|
@ -91,6 +91,7 @@ class MediaListViewerFragment : GenericFragment() {
|
|||
|
||||
viewModel = ViewModelProvider(this)[ConversationMediaListViewModel::class.java]
|
||||
binding.viewModel = viewModel
|
||||
observeToastEvents(viewModel)
|
||||
|
||||
// Consider full screen mode the default
|
||||
sharedViewModel.mediaViewerFullScreenMode.value = true
|
||||
|
|
|
|||
|
|
@ -28,11 +28,11 @@ import androidx.lifecycle.ViewModelProvider
|
|||
import org.linphone.core.tools.Log
|
||||
import org.linphone.databinding.FileMediaViewerChildFragmentBinding
|
||||
import org.linphone.ui.main.file_media_viewer.viewmodel.MediaViewModel
|
||||
import org.linphone.ui.main.fragment.GenericFragment
|
||||
import org.linphone.ui.main.fragment.GenericMainFragment
|
||||
import org.linphone.ui.main.viewmodel.SharedMainViewModel
|
||||
|
||||
@UiThread
|
||||
class MediaViewerFragment : GenericFragment() {
|
||||
class MediaViewerFragment : GenericMainFragment() {
|
||||
companion object {
|
||||
private const val TAG = "[Media Viewer Fragment]"
|
||||
}
|
||||
|
|
@ -61,6 +61,7 @@ class MediaViewerFragment : GenericFragment() {
|
|||
|
||||
binding.lifecycleOwner = viewLifecycleOwner
|
||||
binding.viewModel = viewModel
|
||||
observeToastEvents(viewModel)
|
||||
|
||||
val path = if (arguments?.containsKey("path") == true) {
|
||||
requireArguments().getString("path")
|
||||
|
|
|
|||
|
|
@ -26,7 +26,6 @@ import android.os.ParcelFileDescriptor
|
|||
import android.widget.ImageView
|
||||
import androidx.annotation.UiThread
|
||||
import androidx.lifecycle.MutableLiveData
|
||||
import androidx.lifecycle.ViewModel
|
||||
import androidx.lifecycle.viewModelScope
|
||||
import java.io.BufferedReader
|
||||
import java.io.File
|
||||
|
|
@ -38,11 +37,11 @@ import kotlinx.coroutines.launch
|
|||
import kotlinx.coroutines.withContext
|
||||
import org.linphone.R
|
||||
import org.linphone.core.tools.Log
|
||||
import org.linphone.utils.AppUtils
|
||||
import org.linphone.ui.GenericViewModel
|
||||
import org.linphone.utils.Event
|
||||
import org.linphone.utils.FileUtils
|
||||
|
||||
class FileViewModel @UiThread constructor() : ViewModel() {
|
||||
class FileViewModel @UiThread constructor() : GenericViewModel() {
|
||||
companion object {
|
||||
private const val TAG = "[File ViewModel]"
|
||||
}
|
||||
|
|
@ -77,14 +76,6 @@ class FileViewModel @UiThread constructor() : ViewModel() {
|
|||
MutableLiveData<Event<String>>()
|
||||
}
|
||||
|
||||
val showGreenToastEvent: MutableLiveData<Event<Pair<String, Int>>> by lazy {
|
||||
MutableLiveData<Event<Pair<String, Int>>>()
|
||||
}
|
||||
|
||||
val showRedToastEvent: MutableLiveData<Event<Pair<String, Int>>> by lazy {
|
||||
MutableLiveData<Event<Pair<String, Int>>>()
|
||||
}
|
||||
|
||||
// Below are required for PDF viewer
|
||||
private lateinit var pdfRenderer: PdfRenderer
|
||||
|
||||
|
|
@ -231,16 +222,24 @@ class FileViewModel @UiThread constructor() : ViewModel() {
|
|||
Log.i(
|
||||
"$TAG File [$filePath] has been successfully exported to documents"
|
||||
)
|
||||
val message = AppUtils.getString(
|
||||
R.string.toast_file_successfully_exported_to_documents
|
||||
showGreenToastEvent.postValue(
|
||||
Event(
|
||||
Pair(
|
||||
R.string.toast_file_successfully_exported_to_documents,
|
||||
R.drawable.check
|
||||
)
|
||||
)
|
||||
)
|
||||
showGreenToastEvent.postValue(Event(Pair(message, R.drawable.check)))
|
||||
} else {
|
||||
Log.e("$TAG Failed to export file [$filePath] to documents!")
|
||||
val message = AppUtils.getString(
|
||||
R.string.toast_export_file_to_documents_error
|
||||
showRedToastEvent.postValue(
|
||||
Event(
|
||||
Pair(
|
||||
R.string.toast_export_file_to_documents_error,
|
||||
R.drawable.warning_circle
|
||||
)
|
||||
)
|
||||
)
|
||||
showRedToastEvent.postValue(Event(Pair(message, R.drawable.warning_circle)))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -256,16 +255,24 @@ class FileViewModel @UiThread constructor() : ViewModel() {
|
|||
Log.i(
|
||||
"$TAG Text has been successfully exported to documents"
|
||||
)
|
||||
val message = AppUtils.getString(
|
||||
R.string.toast_file_successfully_exported_to_documents
|
||||
showGreenToastEvent.postValue(
|
||||
Event(
|
||||
Pair(
|
||||
R.string.toast_file_successfully_exported_to_documents,
|
||||
R.drawable.check
|
||||
)
|
||||
)
|
||||
)
|
||||
showGreenToastEvent.postValue(Event(Pair(message, R.drawable.check)))
|
||||
} else {
|
||||
Log.e("$TAG Failed to save text to documents!")
|
||||
val message = AppUtils.getString(
|
||||
R.string.toast_export_file_to_documents_error
|
||||
showRedToastEvent.postValue(
|
||||
Event(
|
||||
Pair(
|
||||
R.string.toast_export_file_to_documents_error,
|
||||
R.drawable.warning_circle
|
||||
)
|
||||
)
|
||||
)
|
||||
showRedToastEvent.postValue(Event(Pair(message, R.drawable.warning_circle)))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -23,12 +23,12 @@ import android.media.AudioAttributes
|
|||
import android.media.MediaPlayer
|
||||
import androidx.annotation.UiThread
|
||||
import androidx.lifecycle.MutableLiveData
|
||||
import androidx.lifecycle.ViewModel
|
||||
import org.linphone.core.tools.Log
|
||||
import org.linphone.ui.GenericViewModel
|
||||
import org.linphone.utils.Event
|
||||
import org.linphone.utils.FileUtils
|
||||
|
||||
class MediaViewModel @UiThread constructor() : ViewModel() {
|
||||
class MediaViewModel @UiThread constructor() : GenericViewModel() {
|
||||
companion object {
|
||||
private const val TAG = "[Media ViewModel]"
|
||||
}
|
||||
|
|
|
|||
|
|
@ -45,7 +45,7 @@ import org.linphone.utils.setKeyboardInsetListener
|
|||
import org.linphone.utils.showKeyboard
|
||||
|
||||
@UiThread
|
||||
abstract class AbstractMainFragment : GenericFragment() {
|
||||
abstract class AbstractMainFragment : GenericMainFragment() {
|
||||
companion object {
|
||||
private const val TAG = "[Abstract Main Fragment]"
|
||||
}
|
||||
|
|
|
|||
|
|
@ -71,8 +71,8 @@ class AddParticipantsFragment : GenericAddressPickerFragment() {
|
|||
super.onViewCreated(view, savedInstanceState)
|
||||
|
||||
binding.lifecycleOwner = viewLifecycleOwner
|
||||
|
||||
binding.viewModel = viewModel
|
||||
observeToastEvents(viewModel)
|
||||
|
||||
binding.setBackClickListener {
|
||||
goBack()
|
||||
|
|
|
|||
|
|
@ -45,7 +45,7 @@ import org.linphone.ui.main.settings.fragment.AccountProfileFragmentDirections
|
|||
import org.linphone.ui.main.viewmodel.DrawerMenuViewModel
|
||||
|
||||
@UiThread
|
||||
class DrawerMenuFragment : GenericFragment() {
|
||||
class DrawerMenuFragment : GenericMainFragment() {
|
||||
companion object {
|
||||
private const val TAG = "[Drawer Menu Fragment]"
|
||||
}
|
||||
|
|
@ -72,6 +72,7 @@ class DrawerMenuFragment : GenericFragment() {
|
|||
|
||||
binding.lifecycleOwner = viewLifecycleOwner
|
||||
binding.viewModel = viewModel
|
||||
observeToastEvents(viewModel)
|
||||
|
||||
binding.setSettingsClickedListener {
|
||||
val navController = (requireActivity() as MainActivity).findNavController()
|
||||
|
|
|
|||
|
|
@ -24,12 +24,12 @@ import android.view.LayoutInflater
|
|||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import androidx.annotation.UiThread
|
||||
import androidx.fragment.app.Fragment
|
||||
import androidx.navigation.fragment.findNavController
|
||||
import org.linphone.databinding.EmptyFragmentBinding
|
||||
import org.linphone.ui.GenericFragment
|
||||
|
||||
@UiThread
|
||||
class EmptyFragment : Fragment() {
|
||||
class EmptyFragment : GenericFragment() {
|
||||
private lateinit var binding: EmptyFragmentBinding
|
||||
|
||||
override fun onCreateView(
|
||||
|
|
|
|||
|
|
@ -44,7 +44,7 @@ import org.linphone.utils.LinphoneUtils
|
|||
import org.linphone.utils.RecyclerViewHeaderDecoration
|
||||
|
||||
@UiThread
|
||||
abstract class GenericAddressPickerFragment : GenericFragment() {
|
||||
abstract class GenericAddressPickerFragment : GenericMainFragment() {
|
||||
companion object {
|
||||
private const val TAG = "[Generic Address Picker Fragment]"
|
||||
}
|
||||
|
|
|
|||
|
|
@ -22,15 +22,15 @@ package org.linphone.ui.main.fragment
|
|||
import android.os.Bundle
|
||||
import android.view.View
|
||||
import androidx.annotation.UiThread
|
||||
import androidx.fragment.app.Fragment
|
||||
import androidx.lifecycle.ViewModelProvider
|
||||
import org.linphone.core.tools.Log
|
||||
import org.linphone.ui.GenericFragment
|
||||
import org.linphone.ui.main.viewmodel.SharedMainViewModel
|
||||
|
||||
@UiThread
|
||||
abstract class GenericFragment : Fragment() {
|
||||
abstract class GenericMainFragment : GenericFragment() {
|
||||
companion object {
|
||||
private const val TAG = "[Generic Fragment]"
|
||||
private const val TAG = "[Generic Main Fragment]"
|
||||
}
|
||||
|
||||
protected lateinit var sharedViewModel: SharedMainViewModel
|
||||
|
|
@ -29,7 +29,7 @@ import org.linphone.core.tools.Log
|
|||
import org.linphone.ui.main.viewmodel.DefaultAccountChangedViewModel
|
||||
|
||||
@UiThread
|
||||
abstract class SlidingPaneChildFragment : GenericFragment() {
|
||||
abstract class SlidingPaneChildFragment : GenericMainFragment() {
|
||||
companion object {
|
||||
private const val TAG = "[Sliding Pane Child Fragment]"
|
||||
}
|
||||
|
|
|
|||
|
|
@ -32,10 +32,10 @@ import org.linphone.core.CorePreferences
|
|||
import org.linphone.core.tools.Log
|
||||
import org.linphone.databinding.HelpDebugFragmentBinding
|
||||
import org.linphone.ui.GenericActivity
|
||||
import org.linphone.ui.main.fragment.GenericFragment
|
||||
import org.linphone.ui.main.fragment.GenericMainFragment
|
||||
import org.linphone.ui.main.help.viewmodel.HelpViewModel
|
||||
|
||||
class DebugFragment : GenericFragment() {
|
||||
class DebugFragment : GenericMainFragment() {
|
||||
companion object {
|
||||
private const val TAG = "[Debug Fragment]"
|
||||
}
|
||||
|
|
@ -59,6 +59,7 @@ class DebugFragment : GenericFragment() {
|
|||
super.onViewCreated(view, savedInstanceState)
|
||||
binding.lifecycleOwner = viewLifecycleOwner
|
||||
binding.viewModel = viewModel
|
||||
observeToastEvents(viewModel)
|
||||
|
||||
binding.setBackClickListener {
|
||||
goBack()
|
||||
|
|
|
|||
|
|
@ -32,13 +32,13 @@ import org.linphone.R
|
|||
import org.linphone.core.tools.Log
|
||||
import org.linphone.databinding.HelpFragmentBinding
|
||||
import org.linphone.ui.GenericActivity
|
||||
import org.linphone.ui.main.fragment.GenericFragment
|
||||
import org.linphone.ui.main.fragment.GenericMainFragment
|
||||
import org.linphone.ui.main.help.viewmodel.HelpViewModel
|
||||
import org.linphone.ui.main.history.model.ConfirmationDialogModel
|
||||
import org.linphone.utils.DialogUtils
|
||||
|
||||
@UiThread
|
||||
class HelpFragment : GenericFragment() {
|
||||
class HelpFragment : GenericMainFragment() {
|
||||
companion object {
|
||||
private const val TAG = "[Help Fragment]"
|
||||
}
|
||||
|
|
@ -62,6 +62,7 @@ class HelpFragment : GenericFragment() {
|
|||
super.onViewCreated(view, savedInstanceState)
|
||||
binding.lifecycleOwner = viewLifecycleOwner
|
||||
binding.viewModel = viewModel
|
||||
observeToastEvents(viewModel)
|
||||
|
||||
binding.setBackClickListener {
|
||||
goBack()
|
||||
|
|
|
|||
|
|
@ -22,7 +22,6 @@ package org.linphone.ui.main.help.viewmodel
|
|||
import androidx.annotation.UiThread
|
||||
import androidx.annotation.WorkerThread
|
||||
import androidx.lifecycle.MutableLiveData
|
||||
import androidx.lifecycle.ViewModel
|
||||
import org.linphone.BuildConfig
|
||||
import org.linphone.LinphoneApplication.Companion.coreContext
|
||||
import org.linphone.LinphoneApplication.Companion.corePreferences
|
||||
|
|
@ -32,10 +31,11 @@ import org.linphone.core.CoreListenerStub
|
|||
import org.linphone.core.Factory
|
||||
import org.linphone.core.VersionUpdateCheckResult
|
||||
import org.linphone.core.tools.Log
|
||||
import org.linphone.ui.GenericViewModel
|
||||
import org.linphone.utils.AppUtils
|
||||
import org.linphone.utils.Event
|
||||
|
||||
class HelpViewModel @UiThread constructor() : ViewModel() {
|
||||
class HelpViewModel @UiThread constructor() : GenericViewModel() {
|
||||
companion object {
|
||||
private const val TAG = "[Help ViewModel]"
|
||||
}
|
||||
|
|
|
|||
|
|
@ -97,6 +97,7 @@ class HistoryFragment : SlidingPaneChildFragment() {
|
|||
|
||||
viewModel = ViewModelProvider(this)[HistoryViewModel::class.java]
|
||||
binding.viewModel = viewModel
|
||||
observeToastEvents(viewModel)
|
||||
|
||||
val callId = args.callId
|
||||
Log.i("$TAG Looking up for call log with call id [$callId]")
|
||||
|
|
|
|||
|
|
@ -74,6 +74,7 @@ class StartCallFragment : GenericAddressPickerFragment() {
|
|||
|
||||
viewModel.title.value = getString(R.string.history_call_start_title)
|
||||
binding.viewModel = viewModel
|
||||
observeToastEvents(viewModel)
|
||||
|
||||
binding.setBackClickListener {
|
||||
goBack()
|
||||
|
|
@ -142,15 +143,6 @@ class StartCallFragment : GenericAddressPickerFragment() {
|
|||
}
|
||||
}
|
||||
|
||||
viewModel.showRedToastEvent.observe(viewLifecycleOwner) {
|
||||
it.consume { message ->
|
||||
(requireActivity() as GenericActivity).showRedToast(
|
||||
getString(message),
|
||||
R.drawable.warning_circle
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
binding.root.setKeyboardInsetListener { keyboardVisible ->
|
||||
if (keyboardVisible) {
|
||||
viewModel.isNumpadVisible.value = false
|
||||
|
|
|
|||
|
|
@ -22,7 +22,6 @@ package org.linphone.ui.main.history.viewmodel
|
|||
import androidx.annotation.UiThread
|
||||
import androidx.annotation.WorkerThread
|
||||
import androidx.lifecycle.MutableLiveData
|
||||
import androidx.lifecycle.ViewModel
|
||||
import org.linphone.LinphoneApplication.Companion.coreContext
|
||||
import org.linphone.LinphoneApplication.Companion.corePreferences
|
||||
import org.linphone.R
|
||||
|
|
@ -31,6 +30,7 @@ import org.linphone.core.ChatRoom
|
|||
import org.linphone.core.ChatRoomListenerStub
|
||||
import org.linphone.core.ChatRoomParams
|
||||
import org.linphone.core.tools.Log
|
||||
import org.linphone.ui.GenericViewModel
|
||||
import org.linphone.ui.main.history.model.CallLogHistoryModel
|
||||
import org.linphone.ui.main.history.model.CallLogModel
|
||||
import org.linphone.ui.main.model.isEndToEndEncryptionMandatory
|
||||
|
|
@ -38,7 +38,7 @@ import org.linphone.utils.AppUtils
|
|||
import org.linphone.utils.Event
|
||||
import org.linphone.utils.LinphoneUtils
|
||||
|
||||
class HistoryViewModel @UiThread constructor() : ViewModel() {
|
||||
class HistoryViewModel @UiThread constructor() : GenericViewModel() {
|
||||
companion object {
|
||||
private const val TAG = "[History ViewModel]"
|
||||
}
|
||||
|
|
|
|||
|
|
@ -70,10 +70,6 @@ class StartCallViewModel @UiThread constructor() : AddressSelectionViewModel() {
|
|||
MutableLiveData<Event<Boolean>>()
|
||||
}
|
||||
|
||||
val showRedToastEvent: MutableLiveData<Event<Int>> by lazy {
|
||||
MutableLiveData<Event<Int>>()
|
||||
}
|
||||
|
||||
private val conferenceSchedulerListener = object : ConferenceSchedulerListenerStub() {
|
||||
override fun onStateChanged(
|
||||
conferenceScheduler: ConferenceScheduler,
|
||||
|
|
@ -92,7 +88,12 @@ class StartCallViewModel @UiThread constructor() : AddressSelectionViewModel() {
|
|||
} else {
|
||||
Log.e("$TAG Conference info URI is null!")
|
||||
showRedToastEvent.postValue(
|
||||
Event(R.string.conference_failed_to_create_group_call_toast)
|
||||
Event(
|
||||
Pair(
|
||||
R.string.conference_failed_to_create_group_call_toast,
|
||||
R.drawable.warning_circle
|
||||
)
|
||||
)
|
||||
)
|
||||
}
|
||||
operationInProgress.postValue(false)
|
||||
|
|
@ -100,7 +101,12 @@ class StartCallViewModel @UiThread constructor() : AddressSelectionViewModel() {
|
|||
conferenceScheduler.removeListener(this)
|
||||
Log.e("$TAG Failed to create group call!")
|
||||
showRedToastEvent.postValue(
|
||||
Event(R.string.conference_failed_to_create_group_call_toast)
|
||||
Event(
|
||||
Pair(
|
||||
R.string.conference_failed_to_create_group_call_toast,
|
||||
R.drawable.warning_circle
|
||||
)
|
||||
)
|
||||
)
|
||||
operationInProgress.postValue(false)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -73,6 +73,7 @@ class EditMeetingFragment : SlidingPaneChildFragment() {
|
|||
|
||||
viewModel = ViewModelProvider(this)[ScheduleMeetingViewModel::class.java]
|
||||
binding.viewModel = viewModel
|
||||
observeToastEvents(viewModel)
|
||||
|
||||
val conferenceUri = args.conferenceUri
|
||||
Log.i("$TAG Found conference URI [$conferenceUri] in arguments")
|
||||
|
|
@ -185,15 +186,6 @@ class EditMeetingFragment : SlidingPaneChildFragment() {
|
|||
}
|
||||
}
|
||||
|
||||
viewModel.showRedToastEvent.observe(viewLifecycleOwner) {
|
||||
it.consume { message ->
|
||||
(requireActivity() as GenericActivity).showRedToast(
|
||||
getString(message),
|
||||
R.drawable.warning_circle
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
sharedViewModel.listOfSelectedSipUrisEvent.observe(viewLifecycleOwner) {
|
||||
it.consume { list ->
|
||||
Log.i(
|
||||
|
|
|
|||
|
|
@ -99,6 +99,7 @@ class MeetingFragment : SlidingPaneChildFragment() {
|
|||
|
||||
viewModel = ViewModelProvider(this)[MeetingViewModel::class.java]
|
||||
binding.viewModel = viewModel
|
||||
observeToastEvents(viewModel)
|
||||
|
||||
val uri = args.conferenceUri
|
||||
Log.i(
|
||||
|
|
|
|||
|
|
@ -40,11 +40,11 @@ import org.linphone.databinding.MeetingWaitingRoomFragmentBinding
|
|||
import org.linphone.ui.GenericActivity
|
||||
import org.linphone.ui.call.fragment.AudioDevicesMenuDialogFragment
|
||||
import org.linphone.ui.call.model.AudioDeviceModel
|
||||
import org.linphone.ui.main.fragment.GenericFragment
|
||||
import org.linphone.ui.main.fragment.GenericMainFragment
|
||||
import org.linphone.ui.main.meetings.viewmodel.MeetingWaitingRoomViewModel
|
||||
|
||||
@UiThread
|
||||
class MeetingWaitingRoomFragment : GenericFragment() {
|
||||
class MeetingWaitingRoomFragment : GenericMainFragment() {
|
||||
companion object {
|
||||
private const val TAG = "[Meeting Waiting Room Fragment]"
|
||||
}
|
||||
|
|
@ -94,6 +94,7 @@ class MeetingWaitingRoomFragment : GenericFragment() {
|
|||
|
||||
viewModel = ViewModelProvider(this)[MeetingWaitingRoomViewModel::class.java]
|
||||
binding.viewModel = viewModel
|
||||
observeToastEvents(viewModel)
|
||||
|
||||
val uri = args.conferenceUri
|
||||
Log.i(
|
||||
|
|
|
|||
|
|
@ -37,12 +37,12 @@ import org.linphone.R
|
|||
import org.linphone.core.tools.Log
|
||||
import org.linphone.databinding.MeetingScheduleFragmentBinding
|
||||
import org.linphone.ui.GenericActivity
|
||||
import org.linphone.ui.main.fragment.GenericFragment
|
||||
import org.linphone.ui.main.fragment.GenericMainFragment
|
||||
import org.linphone.ui.main.meetings.viewmodel.ScheduleMeetingViewModel
|
||||
import org.linphone.utils.Event
|
||||
|
||||
@UiThread
|
||||
class ScheduleMeetingFragment : GenericFragment() {
|
||||
class ScheduleMeetingFragment : GenericMainFragment() {
|
||||
companion object {
|
||||
private const val TAG = "[Schedule Meeting Fragment]"
|
||||
}
|
||||
|
|
@ -73,6 +73,7 @@ class ScheduleMeetingFragment : GenericFragment() {
|
|||
|
||||
viewModel = ViewModelProvider(this)[ScheduleMeetingViewModel::class.java]
|
||||
binding.viewModel = viewModel
|
||||
observeToastEvents(viewModel)
|
||||
|
||||
val participants = args.participants
|
||||
if (!participants.isNullOrEmpty()) {
|
||||
|
|
@ -186,15 +187,6 @@ class ScheduleMeetingFragment : GenericFragment() {
|
|||
}
|
||||
}
|
||||
|
||||
viewModel.showRedToastEvent.observe(viewLifecycleOwner) {
|
||||
it.consume { message ->
|
||||
(requireActivity() as GenericActivity).showRedToast(
|
||||
getString(message),
|
||||
R.drawable.warning_circle
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
sharedViewModel.listOfSelectedSipUrisEvent.observe(viewLifecycleOwner) {
|
||||
it.consume { list ->
|
||||
Log.i(
|
||||
|
|
|
|||
|
|
@ -22,7 +22,6 @@ package org.linphone.ui.main.meetings.viewmodel
|
|||
import androidx.annotation.UiThread
|
||||
import androidx.annotation.WorkerThread
|
||||
import androidx.lifecycle.MutableLiveData
|
||||
import androidx.lifecycle.ViewModel
|
||||
import java.util.Locale
|
||||
import java.util.TimeZone
|
||||
import org.linphone.LinphoneApplication.Companion.coreContext
|
||||
|
|
@ -35,12 +34,13 @@ import org.linphone.core.ConferenceSchedulerListenerStub
|
|||
import org.linphone.core.Factory
|
||||
import org.linphone.core.Participant
|
||||
import org.linphone.core.tools.Log
|
||||
import org.linphone.ui.GenericViewModel
|
||||
import org.linphone.ui.main.meetings.model.ParticipantModel
|
||||
import org.linphone.utils.AppUtils
|
||||
import org.linphone.utils.Event
|
||||
import org.linphone.utils.TimestampUtils
|
||||
|
||||
class MeetingViewModel @UiThread constructor() : ViewModel() {
|
||||
class MeetingViewModel @UiThread constructor() : GenericViewModel() {
|
||||
companion object {
|
||||
private const val TAG = "[Meeting ViewModel]"
|
||||
}
|
||||
|
|
|
|||
|
|
@ -25,7 +25,6 @@ import androidx.annotation.UiThread
|
|||
import androidx.annotation.WorkerThread
|
||||
import androidx.core.app.ActivityCompat
|
||||
import androidx.lifecycle.MutableLiveData
|
||||
import androidx.lifecycle.ViewModel
|
||||
import org.linphone.LinphoneApplication.Companion.coreContext
|
||||
import org.linphone.LinphoneApplication.Companion.corePreferences
|
||||
import org.linphone.R
|
||||
|
|
@ -39,13 +38,14 @@ import org.linphone.core.CoreListenerStub
|
|||
import org.linphone.core.Factory
|
||||
import org.linphone.core.MediaDirection
|
||||
import org.linphone.core.tools.Log
|
||||
import org.linphone.ui.GenericViewModel
|
||||
import org.linphone.ui.call.model.AudioDeviceModel
|
||||
import org.linphone.ui.main.contacts.model.ContactAvatarModel
|
||||
import org.linphone.utils.AppUtils
|
||||
import org.linphone.utils.Event
|
||||
import org.linphone.utils.TimestampUtils
|
||||
|
||||
class MeetingWaitingRoomViewModel @UiThread constructor() : ViewModel() {
|
||||
class MeetingWaitingRoomViewModel @UiThread constructor() : GenericViewModel() {
|
||||
companion object {
|
||||
private const val TAG = "[Meeting Waiting Room ViewModel]"
|
||||
}
|
||||
|
|
|
|||
|
|
@ -23,7 +23,6 @@ import androidx.annotation.AnyThread
|
|||
import androidx.annotation.UiThread
|
||||
import androidx.annotation.WorkerThread
|
||||
import androidx.lifecycle.MutableLiveData
|
||||
import androidx.lifecycle.ViewModel
|
||||
import java.util.Calendar
|
||||
import java.util.Locale
|
||||
import java.util.TimeZone
|
||||
|
|
@ -39,12 +38,13 @@ import org.linphone.core.Factory
|
|||
import org.linphone.core.Participant
|
||||
import org.linphone.core.ParticipantInfo
|
||||
import org.linphone.core.tools.Log
|
||||
import org.linphone.ui.GenericViewModel
|
||||
import org.linphone.ui.main.model.SelectedAddressModel
|
||||
import org.linphone.utils.AppUtils
|
||||
import org.linphone.utils.Event
|
||||
import org.linphone.utils.TimestampUtils
|
||||
|
||||
class ScheduleMeetingViewModel @UiThread constructor() : ViewModel() {
|
||||
class ScheduleMeetingViewModel @UiThread constructor() : GenericViewModel() {
|
||||
companion object {
|
||||
private const val TAG = "[Schedule Meeting ViewModel]"
|
||||
}
|
||||
|
|
@ -81,10 +81,6 @@ class ScheduleMeetingViewModel @UiThread constructor() : ViewModel() {
|
|||
MutableLiveData<Event<Boolean>>()
|
||||
}
|
||||
|
||||
val showRedToastEvent: MutableLiveData<Event<Int>> by lazy {
|
||||
MutableLiveData<Event<Int>>()
|
||||
}
|
||||
|
||||
private var startTimestamp = 0L
|
||||
private var endTimestamp = 0L
|
||||
|
||||
|
|
@ -108,7 +104,14 @@ class ScheduleMeetingViewModel @UiThread constructor() : ViewModel() {
|
|||
when (state) {
|
||||
ConferenceScheduler.State.Error -> {
|
||||
operationInProgress.postValue(false)
|
||||
showRedToastEvent.postValue(Event(R.string.meeting_failed_to_schedule_toast))
|
||||
showRedToastEvent.postValue(
|
||||
Event(
|
||||
Pair(
|
||||
R.string.meeting_failed_to_schedule_toast,
|
||||
R.drawable.warning_circle
|
||||
)
|
||||
)
|
||||
)
|
||||
}
|
||||
ConferenceScheduler.State.Ready -> {
|
||||
val conferenceAddress = conferenceScheduler.info?.uri
|
||||
|
|
@ -153,7 +156,12 @@ class ScheduleMeetingViewModel @UiThread constructor() : ViewModel() {
|
|||
participants.value.orEmpty().size -> {
|
||||
Log.e("$TAG No invitation sent!")
|
||||
showRedToastEvent.postValue(
|
||||
Event(R.string.meeting_failed_to_send_invites_toast)
|
||||
Event(
|
||||
Pair(
|
||||
R.string.meeting_failed_to_send_invites_toast,
|
||||
R.drawable.warning_circle
|
||||
)
|
||||
)
|
||||
)
|
||||
}
|
||||
else -> {
|
||||
|
|
@ -162,7 +170,12 @@ class ScheduleMeetingViewModel @UiThread constructor() : ViewModel() {
|
|||
Log.w(failed.asStringUriOnly())
|
||||
}
|
||||
showRedToastEvent.postValue(
|
||||
Event(R.string.meeting_failed_to_send_part_of_invites_toast)
|
||||
Event(
|
||||
Pair(
|
||||
R.string.meeting_failed_to_send_part_of_invites_toast,
|
||||
R.drawable.warning_circle
|
||||
)
|
||||
)
|
||||
)
|
||||
}
|
||||
}
|
||||
|
|
@ -354,7 +367,12 @@ class ScheduleMeetingViewModel @UiThread constructor() : ViewModel() {
|
|||
"$TAG Either no subject was set or no participant was selected, can't schedule meeting."
|
||||
)
|
||||
showRedToastEvent.postValue(
|
||||
Event(R.string.meeting_schedule_mandatory_field_not_filled_toast)
|
||||
Event(
|
||||
Pair(
|
||||
R.string.meeting_schedule_mandatory_field_not_filled_toast,
|
||||
R.drawable.warning_circle
|
||||
)
|
||||
)
|
||||
)
|
||||
return
|
||||
}
|
||||
|
|
|
|||
|
|
@ -25,10 +25,10 @@ import android.view.View
|
|||
import android.view.ViewGroup
|
||||
import androidx.annotation.UiThread
|
||||
import org.linphone.databinding.RecordingsFragmentBinding
|
||||
import org.linphone.ui.main.fragment.GenericFragment
|
||||
import org.linphone.ui.main.fragment.GenericMainFragment
|
||||
|
||||
@UiThread
|
||||
class RecordingsFragment : GenericFragment() {
|
||||
class RecordingsFragment : GenericMainFragment() {
|
||||
private lateinit var binding: RecordingsFragmentBinding
|
||||
|
||||
override fun onCreateView(
|
||||
|
|
|
|||
|
|
@ -38,7 +38,7 @@ import org.linphone.R
|
|||
import org.linphone.core.tools.Log
|
||||
import org.linphone.databinding.AccountProfileFragmentBinding
|
||||
import org.linphone.ui.GenericActivity
|
||||
import org.linphone.ui.main.fragment.GenericFragment
|
||||
import org.linphone.ui.main.fragment.GenericMainFragment
|
||||
import org.linphone.ui.main.history.model.ConfirmationDialogModel
|
||||
import org.linphone.ui.main.settings.viewmodel.AccountProfileViewModel
|
||||
import org.linphone.utils.DialogUtils
|
||||
|
|
@ -46,7 +46,7 @@ import org.linphone.utils.Event
|
|||
import org.linphone.utils.FileUtils
|
||||
|
||||
@UiThread
|
||||
class AccountProfileFragment : GenericFragment() {
|
||||
class AccountProfileFragment : GenericMainFragment() {
|
||||
companion object {
|
||||
private const val TAG = "[Account Profile Fragment]"
|
||||
}
|
||||
|
|
@ -113,6 +113,7 @@ class AccountProfileFragment : GenericFragment() {
|
|||
|
||||
binding.lifecycleOwner = viewLifecycleOwner
|
||||
binding.viewModel = viewModel
|
||||
observeToastEvents(viewModel)
|
||||
|
||||
val identity = args.accountIdentity
|
||||
Log.i("$TAG Looking up for account with identity address [$identity]")
|
||||
|
|
|
|||
|
|
@ -28,12 +28,12 @@ import androidx.navigation.navGraphViewModels
|
|||
import org.linphone.R
|
||||
import org.linphone.core.tools.Log
|
||||
import org.linphone.databinding.AccountProfileSecureModeFragmentBinding
|
||||
import org.linphone.ui.main.fragment.GenericFragment
|
||||
import org.linphone.ui.main.fragment.GenericMainFragment
|
||||
import org.linphone.ui.main.settings.viewmodel.AccountProfileViewModel
|
||||
import org.linphone.utils.DialogUtils
|
||||
|
||||
@UiThread
|
||||
class AccountProfileModeFragment : GenericFragment() {
|
||||
class AccountProfileModeFragment : GenericMainFragment() {
|
||||
companion object {
|
||||
private const val TAG = "[Account Profile Mode Fragment]"
|
||||
}
|
||||
|
|
@ -58,6 +58,7 @@ class AccountProfileModeFragment : GenericFragment() {
|
|||
|
||||
binding.lifecycleOwner = viewLifecycleOwner
|
||||
binding.viewModel = viewModel
|
||||
observeToastEvents(viewModel)
|
||||
|
||||
binding.setBackClickListener {
|
||||
Log.i("$TAG Leaving without saving changes...")
|
||||
|
|
|
|||
|
|
@ -36,12 +36,12 @@ import org.linphone.core.TransportType
|
|||
import org.linphone.core.tools.Log
|
||||
import org.linphone.databinding.AccountSettingsFragmentBinding
|
||||
import org.linphone.ui.GenericActivity
|
||||
import org.linphone.ui.main.fragment.GenericFragment
|
||||
import org.linphone.ui.main.fragment.GenericMainFragment
|
||||
import org.linphone.ui.main.settings.viewmodel.AccountSettingsViewModel
|
||||
import org.linphone.utils.Event
|
||||
|
||||
@UiThread
|
||||
class AccountSettingsFragment : GenericFragment() {
|
||||
class AccountSettingsFragment : GenericMainFragment() {
|
||||
companion object {
|
||||
private const val TAG = "[Account Settings Fragment]"
|
||||
}
|
||||
|
|
@ -89,6 +89,7 @@ class AccountSettingsFragment : GenericFragment() {
|
|||
|
||||
viewModel = ViewModelProvider(this)[AccountSettingsViewModel::class.java]
|
||||
binding.viewModel = viewModel
|
||||
observeToastEvents(viewModel)
|
||||
|
||||
val identity = args.accountIdentity
|
||||
Log.i("$TAG Looking up for account with identity address [$identity]")
|
||||
|
|
|
|||
|
|
@ -28,12 +28,11 @@ import androidx.lifecycle.ViewModelProvider
|
|||
import androidx.navigation.fragment.navArgs
|
||||
import org.linphone.core.tools.Log
|
||||
import org.linphone.databinding.SettingsContactsCarddavBinding
|
||||
import org.linphone.ui.GenericActivity
|
||||
import org.linphone.ui.main.fragment.GenericFragment
|
||||
import org.linphone.ui.main.fragment.GenericMainFragment
|
||||
import org.linphone.ui.main.settings.viewmodel.CardDavViewModel
|
||||
|
||||
@UiThread
|
||||
class CardDavAddressBookConfigurationFragment : GenericFragment() {
|
||||
class CardDavAddressBookConfigurationFragment : GenericMainFragment() {
|
||||
companion object {
|
||||
private const val TAG = "[CardDAV Address Book Configuration Fragment]"
|
||||
}
|
||||
|
|
@ -60,6 +59,7 @@ class CardDavAddressBookConfigurationFragment : GenericFragment() {
|
|||
|
||||
binding.lifecycleOwner = viewLifecycleOwner
|
||||
binding.viewModel = viewModel
|
||||
observeToastEvents(viewModel)
|
||||
|
||||
val friendListDisplayName = args.displayName
|
||||
if (friendListDisplayName != null) {
|
||||
|
|
@ -72,22 +72,5 @@ class CardDavAddressBookConfigurationFragment : GenericFragment() {
|
|||
binding.setBackClickListener {
|
||||
goBack()
|
||||
}
|
||||
|
||||
viewModel.showGreenToastEvent.observe(viewLifecycleOwner) {
|
||||
it.consume { pair ->
|
||||
val message = getString(pair.first)
|
||||
val icon = pair.second
|
||||
(requireActivity() as GenericActivity).showGreenToast(message, icon)
|
||||
goBack()
|
||||
}
|
||||
}
|
||||
|
||||
viewModel.showRedToastEvent.observe(viewLifecycleOwner) {
|
||||
it.consume { pair ->
|
||||
val message = getString(pair.first)
|
||||
val icon = pair.second
|
||||
(requireActivity() as GenericActivity).showRedToast(message, icon)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -28,12 +28,11 @@ import androidx.lifecycle.ViewModelProvider
|
|||
import androidx.navigation.fragment.navArgs
|
||||
import org.linphone.core.tools.Log
|
||||
import org.linphone.databinding.SettingsContactsLdapBinding
|
||||
import org.linphone.ui.GenericActivity
|
||||
import org.linphone.ui.main.fragment.GenericFragment
|
||||
import org.linphone.ui.main.fragment.GenericMainFragment
|
||||
import org.linphone.ui.main.settings.viewmodel.LdapViewModel
|
||||
|
||||
@UiThread
|
||||
class LdapServerConfigurationFragment : GenericFragment() {
|
||||
class LdapServerConfigurationFragment : GenericMainFragment() {
|
||||
companion object {
|
||||
private const val TAG = "[LDAP Server Configuration Fragment]"
|
||||
}
|
||||
|
|
@ -60,6 +59,7 @@ class LdapServerConfigurationFragment : GenericFragment() {
|
|||
|
||||
binding.lifecycleOwner = viewLifecycleOwner
|
||||
binding.viewModel = viewModel
|
||||
observeToastEvents(viewModel)
|
||||
|
||||
val ldapServerUrl = args.serverUrl
|
||||
if (ldapServerUrl != null) {
|
||||
|
|
@ -79,13 +79,5 @@ class LdapServerConfigurationFragment : GenericFragment() {
|
|||
goBack()
|
||||
}
|
||||
}
|
||||
|
||||
viewModel.showRedToastEvent.observe(viewLifecycleOwner) {
|
||||
it.consume { pair ->
|
||||
val message = getString(pair.first)
|
||||
val icon = pair.second
|
||||
(requireActivity() as GenericActivity).showRedToast(message, icon)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -26,11 +26,11 @@ import android.view.ViewGroup
|
|||
import androidx.annotation.UiThread
|
||||
import androidx.lifecycle.ViewModelProvider
|
||||
import org.linphone.databinding.SettingsAdvancedFragmentBinding
|
||||
import org.linphone.ui.main.fragment.GenericFragment
|
||||
import org.linphone.ui.main.fragment.GenericMainFragment
|
||||
import org.linphone.ui.main.settings.viewmodel.SettingsViewModel
|
||||
|
||||
@UiThread
|
||||
class SettingsAdvancedFragment : GenericFragment() {
|
||||
class SettingsAdvancedFragment : GenericMainFragment() {
|
||||
companion object {
|
||||
private const val TAG = "[Advanced Settings Fragment]"
|
||||
}
|
||||
|
|
@ -56,6 +56,7 @@ class SettingsAdvancedFragment : GenericFragment() {
|
|||
|
||||
binding.lifecycleOwner = viewLifecycleOwner
|
||||
binding.viewModel = viewModel
|
||||
observeToastEvents(viewModel)
|
||||
|
||||
binding.setBackClickListener {
|
||||
goBack()
|
||||
|
|
|
|||
|
|
@ -32,11 +32,11 @@ import org.linphone.R
|
|||
import org.linphone.compatibility.Compatibility
|
||||
import org.linphone.core.tools.Log
|
||||
import org.linphone.databinding.SettingsFragmentBinding
|
||||
import org.linphone.ui.main.fragment.GenericFragment
|
||||
import org.linphone.ui.main.fragment.GenericMainFragment
|
||||
import org.linphone.ui.main.settings.viewmodel.SettingsViewModel
|
||||
|
||||
@UiThread
|
||||
class SettingsFragment : GenericFragment() {
|
||||
class SettingsFragment : GenericMainFragment() {
|
||||
companion object {
|
||||
private const val TAG = "[Settings Fragment]"
|
||||
}
|
||||
|
|
@ -108,6 +108,7 @@ class SettingsFragment : GenericFragment() {
|
|||
|
||||
binding.lifecycleOwner = viewLifecycleOwner
|
||||
binding.viewModel = viewModel
|
||||
observeToastEvents(viewModel)
|
||||
|
||||
binding.setBackClickListener {
|
||||
goBack()
|
||||
|
|
|
|||
|
|
@ -21,13 +21,13 @@ package org.linphone.ui.main.settings.viewmodel
|
|||
|
||||
import androidx.annotation.UiThread
|
||||
import androidx.lifecycle.MutableLiveData
|
||||
import androidx.lifecycle.ViewModel
|
||||
import org.linphone.LinphoneApplication.Companion.coreContext
|
||||
import org.linphone.LinphoneApplication.Companion.corePreferences
|
||||
import org.linphone.core.Account
|
||||
import org.linphone.core.DialPlan
|
||||
import org.linphone.core.Factory
|
||||
import org.linphone.core.tools.Log
|
||||
import org.linphone.ui.GenericViewModel
|
||||
import org.linphone.ui.main.model.AccountModel
|
||||
import org.linphone.ui.main.model.isEndToEndEncryptionMandatory
|
||||
import org.linphone.ui.main.model.setEndToEndEncryptionMandatory
|
||||
|
|
@ -35,7 +35,7 @@ import org.linphone.ui.main.model.setInteroperabilityMode
|
|||
import org.linphone.ui.main.settings.model.AccountDeviceModel
|
||||
import org.linphone.utils.Event
|
||||
|
||||
class AccountProfileViewModel @UiThread constructor() : ViewModel() {
|
||||
class AccountProfileViewModel @UiThread constructor() : GenericViewModel() {
|
||||
companion object {
|
||||
private const val TAG = "[Account Profile ViewModel]"
|
||||
}
|
||||
|
|
|
|||
|
|
@ -21,7 +21,6 @@ package org.linphone.ui.main.settings.viewmodel
|
|||
|
||||
import androidx.annotation.UiThread
|
||||
import androidx.lifecycle.MutableLiveData
|
||||
import androidx.lifecycle.ViewModel
|
||||
import java.util.Locale
|
||||
import org.linphone.LinphoneApplication.Companion.coreContext
|
||||
import org.linphone.core.AVPFMode
|
||||
|
|
@ -29,10 +28,11 @@ import org.linphone.core.Account
|
|||
import org.linphone.core.NatPolicy
|
||||
import org.linphone.core.TransportType
|
||||
import org.linphone.core.tools.Log
|
||||
import org.linphone.ui.GenericViewModel
|
||||
import org.linphone.ui.main.model.isEndToEndEncryptionMandatory
|
||||
import org.linphone.utils.Event
|
||||
|
||||
class AccountSettingsViewModel @UiThread constructor() : ViewModel() {
|
||||
class AccountSettingsViewModel @UiThread constructor() : GenericViewModel() {
|
||||
companion object {
|
||||
private const val TAG = "[Account Settings ViewModel]"
|
||||
}
|
||||
|
|
|
|||
|
|
@ -22,16 +22,16 @@ package org.linphone.ui.main.settings.viewmodel
|
|||
import androidx.annotation.UiThread
|
||||
import androidx.annotation.WorkerThread
|
||||
import androidx.lifecycle.MutableLiveData
|
||||
import androidx.lifecycle.ViewModel
|
||||
import org.linphone.LinphoneApplication.Companion.coreContext
|
||||
import org.linphone.R
|
||||
import org.linphone.core.Factory
|
||||
import org.linphone.core.FriendList
|
||||
import org.linphone.core.FriendListListenerStub
|
||||
import org.linphone.core.tools.Log
|
||||
import org.linphone.ui.GenericViewModel
|
||||
import org.linphone.utils.Event
|
||||
|
||||
class CardDavViewModel : ViewModel() {
|
||||
class CardDavViewModel : GenericViewModel() {
|
||||
companion object {
|
||||
private const val TAG = "[CardDAV ViewModel]"
|
||||
}
|
||||
|
|
@ -52,14 +52,6 @@ class CardDavViewModel : ViewModel() {
|
|||
|
||||
val syncInProgress = MutableLiveData<Boolean>()
|
||||
|
||||
val showGreenToastEvent: MutableLiveData<Event<Pair<Int, Int>>> by lazy {
|
||||
MutableLiveData<Event<Pair<Int, Int>>>()
|
||||
}
|
||||
|
||||
val showRedToastEvent: MutableLiveData<Event<Pair<Int, Int>>> by lazy {
|
||||
MutableLiveData<Event<Pair<Int, Int>>>()
|
||||
}
|
||||
|
||||
private lateinit var friendList: FriendList
|
||||
|
||||
private val friendListListener = object : FriendListListenerStub() {
|
||||
|
|
|
|||
|
|
@ -21,14 +21,14 @@ package org.linphone.ui.main.settings.viewmodel
|
|||
|
||||
import androidx.annotation.UiThread
|
||||
import androidx.lifecycle.MutableLiveData
|
||||
import androidx.lifecycle.ViewModel
|
||||
import org.linphone.LinphoneApplication.Companion.coreContext
|
||||
import org.linphone.R
|
||||
import org.linphone.core.Ldap
|
||||
import org.linphone.core.tools.Log
|
||||
import org.linphone.ui.GenericViewModel
|
||||
import org.linphone.utils.Event
|
||||
|
||||
class LdapViewModel : ViewModel() {
|
||||
class LdapViewModel : GenericViewModel() {
|
||||
companion object {
|
||||
private const val TAG = "[LDAP ViewModel]"
|
||||
}
|
||||
|
|
@ -67,10 +67,6 @@ class LdapViewModel : ViewModel() {
|
|||
MutableLiveData<Event<Boolean>>()
|
||||
}
|
||||
|
||||
val showRedToastEvent: MutableLiveData<Event<Pair<Int, Int>>> by lazy {
|
||||
MutableLiveData<Event<Pair<Int, Int>>>()
|
||||
}
|
||||
|
||||
private lateinit var ldapToEdit: Ldap
|
||||
|
||||
init {
|
||||
|
|
|
|||
|
|
@ -22,7 +22,6 @@ package org.linphone.ui.main.settings.viewmodel
|
|||
import android.os.Vibrator
|
||||
import androidx.annotation.UiThread
|
||||
import androidx.lifecycle.MutableLiveData
|
||||
import androidx.lifecycle.ViewModel
|
||||
import org.linphone.LinphoneApplication.Companion.coreContext
|
||||
import org.linphone.LinphoneApplication.Companion.corePreferences
|
||||
import org.linphone.R
|
||||
|
|
@ -30,11 +29,12 @@ import org.linphone.core.Conference
|
|||
import org.linphone.core.FriendList
|
||||
import org.linphone.core.VFS
|
||||
import org.linphone.core.tools.Log
|
||||
import org.linphone.ui.GenericViewModel
|
||||
import org.linphone.ui.main.settings.model.CardDavLdapModel
|
||||
import org.linphone.utils.AppUtils
|
||||
import org.linphone.utils.Event
|
||||
|
||||
class SettingsViewModel @UiThread constructor() : ViewModel() {
|
||||
class SettingsViewModel @UiThread constructor() : GenericViewModel() {
|
||||
companion object {
|
||||
private const val TAG = "[Settings ViewModel]"
|
||||
}
|
||||
|
|
|
|||
|
|
@ -32,10 +32,10 @@ import org.linphone.R
|
|||
import org.linphone.core.tools.Log
|
||||
import org.linphone.databinding.SingleSignOnFragmentBinding
|
||||
import org.linphone.ui.GenericActivity
|
||||
import org.linphone.ui.main.fragment.GenericFragment
|
||||
import org.linphone.ui.main.fragment.GenericMainFragment
|
||||
import org.linphone.ui.main.sso.viewmodel.SingleSignOnViewModel
|
||||
|
||||
class SingleSignOnFragment : GenericFragment() {
|
||||
class SingleSignOnFragment : GenericMainFragment() {
|
||||
companion object {
|
||||
private const val TAG = "[Single Sign On Fragment]"
|
||||
|
||||
|
|
@ -63,6 +63,7 @@ class SingleSignOnFragment : GenericFragment() {
|
|||
super.onViewCreated(view, savedInstanceState)
|
||||
binding.lifecycleOwner = viewLifecycleOwner
|
||||
binding.viewModel = viewModel
|
||||
observeToastEvents(viewModel)
|
||||
|
||||
viewModel.singleSignOnProcessCompletedEvent.observe(viewLifecycleOwner) {
|
||||
it.consume {
|
||||
|
|
|
|||
|
|
@ -23,7 +23,6 @@ import android.content.Intent
|
|||
import android.net.Uri
|
||||
import androidx.annotation.UiThread
|
||||
import androidx.lifecycle.MutableLiveData
|
||||
import androidx.lifecycle.ViewModel
|
||||
import androidx.lifecycle.viewModelScope
|
||||
import java.io.File
|
||||
import kotlinx.coroutines.launch
|
||||
|
|
@ -37,11 +36,12 @@ import net.openid.appauth.ResponseTypeValues
|
|||
import org.linphone.LinphoneApplication.Companion.coreContext
|
||||
import org.linphone.core.Factory
|
||||
import org.linphone.core.tools.Log
|
||||
import org.linphone.ui.GenericViewModel
|
||||
import org.linphone.utils.Event
|
||||
import org.linphone.utils.FileUtils
|
||||
import org.linphone.utils.TimestampUtils
|
||||
|
||||
class SingleSignOnViewModel : ViewModel() {
|
||||
class SingleSignOnViewModel : GenericViewModel() {
|
||||
companion object {
|
||||
private const val TAG = "[Single Sign On ViewModel]"
|
||||
|
||||
|
|
|
|||
|
|
@ -22,7 +22,6 @@ package org.linphone.ui.main.viewmodel
|
|||
import androidx.annotation.UiThread
|
||||
import androidx.annotation.WorkerThread
|
||||
import androidx.lifecycle.MutableLiveData
|
||||
import androidx.lifecycle.ViewModel
|
||||
import org.linphone.LinphoneApplication.Companion.coreContext
|
||||
import org.linphone.LinphoneApplication.Companion.corePreferences
|
||||
import org.linphone.core.Account
|
||||
|
|
@ -33,11 +32,12 @@ import org.linphone.core.ConfiguringState
|
|||
import org.linphone.core.Core
|
||||
import org.linphone.core.CoreListenerStub
|
||||
import org.linphone.core.tools.Log
|
||||
import org.linphone.ui.GenericViewModel
|
||||
import org.linphone.ui.main.model.AccountModel
|
||||
import org.linphone.utils.Event
|
||||
import org.linphone.utils.LinphoneUtils
|
||||
|
||||
open class AbstractMainViewModel @UiThread constructor() : ViewModel() {
|
||||
open class AbstractMainViewModel @UiThread constructor() : GenericViewModel() {
|
||||
companion object {
|
||||
private const val TAG = "[Abstract Main ViewModel]"
|
||||
}
|
||||
|
|
|
|||
|
|
@ -21,14 +21,14 @@ package org.linphone.ui.main.viewmodel
|
|||
|
||||
import androidx.annotation.WorkerThread
|
||||
import androidx.lifecycle.MutableLiveData
|
||||
import androidx.lifecycle.ViewModel
|
||||
import org.linphone.LinphoneApplication.Companion.coreContext
|
||||
import org.linphone.core.Account
|
||||
import org.linphone.core.Core
|
||||
import org.linphone.core.CoreListenerStub
|
||||
import org.linphone.ui.GenericViewModel
|
||||
import org.linphone.utils.Event
|
||||
|
||||
open class DefaultAccountChangedViewModel : ViewModel() {
|
||||
open class DefaultAccountChangedViewModel : GenericViewModel() {
|
||||
val defaultAccountChangedEvent: MutableLiveData<Event<Boolean>> by lazy {
|
||||
MutableLiveData<Event<Boolean>>()
|
||||
}
|
||||
|
|
|
|||
|
|
@ -23,7 +23,6 @@ import android.view.View
|
|||
import androidx.annotation.UiThread
|
||||
import androidx.annotation.WorkerThread
|
||||
import androidx.lifecycle.MutableLiveData
|
||||
import androidx.lifecycle.ViewModel
|
||||
import org.linphone.LinphoneApplication.Companion.coreContext
|
||||
import org.linphone.LinphoneApplication.Companion.corePreferences
|
||||
import org.linphone.core.Account
|
||||
|
|
@ -31,10 +30,11 @@ import org.linphone.core.ConfiguringState
|
|||
import org.linphone.core.Core
|
||||
import org.linphone.core.CoreListenerStub
|
||||
import org.linphone.core.tools.Log
|
||||
import org.linphone.ui.GenericViewModel
|
||||
import org.linphone.ui.main.model.AccountModel
|
||||
import org.linphone.utils.Event
|
||||
|
||||
class DrawerMenuViewModel @UiThread constructor() : ViewModel() {
|
||||
class DrawerMenuViewModel @UiThread constructor() : GenericViewModel() {
|
||||
companion object {
|
||||
private const val TAG = "[Drawer Menu ViewModel]"
|
||||
}
|
||||
|
|
|
|||
|
|
@ -24,11 +24,11 @@ import android.view.LayoutInflater
|
|||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import androidx.annotation.UiThread
|
||||
import androidx.fragment.app.Fragment
|
||||
import org.linphone.R
|
||||
import org.linphone.ui.GenericFragment
|
||||
|
||||
@UiThread
|
||||
class WelcomePage1Fragment : Fragment() {
|
||||
class WelcomePage1Fragment : GenericFragment() {
|
||||
override fun onCreateView(
|
||||
inflater: LayoutInflater,
|
||||
container: ViewGroup?,
|
||||
|
|
|
|||
|
|
@ -24,11 +24,11 @@ import android.view.LayoutInflater
|
|||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import androidx.annotation.UiThread
|
||||
import androidx.fragment.app.Fragment
|
||||
import org.linphone.R
|
||||
import org.linphone.ui.GenericFragment
|
||||
|
||||
@UiThread
|
||||
class WelcomePage2Fragment : Fragment() {
|
||||
class WelcomePage2Fragment : GenericFragment() {
|
||||
override fun onCreateView(
|
||||
inflater: LayoutInflater,
|
||||
container: ViewGroup?,
|
||||
|
|
|
|||
|
|
@ -24,11 +24,11 @@ import android.view.LayoutInflater
|
|||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import androidx.annotation.UiThread
|
||||
import androidx.fragment.app.Fragment
|
||||
import org.linphone.R
|
||||
import org.linphone.ui.GenericFragment
|
||||
|
||||
@UiThread
|
||||
class WelcomePage3Fragment : Fragment() {
|
||||
class WelcomePage3Fragment : GenericFragment() {
|
||||
override fun onCreateView(
|
||||
inflater: LayoutInflater,
|
||||
container: ViewGroup?,
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue