Ran new version of kotlin auto formatter
This commit is contained in:
parent
06a3124ee6
commit
f2a1869a1a
74 changed files with 1776 additions and 1219 deletions
|
@ -448,7 +448,8 @@ internal fun ChatRoomCreationFragment.navigateToEmptyChatRoom() {
|
|||
|
||||
internal fun GroupInfoFragment.navigateToChatRoomCreation(args: Bundle?) {
|
||||
if (findNavController().currentDestination?.id == R.id.groupInfoFragment) {
|
||||
findNavController().navigate(R.id.action_groupInfoFragment_to_chatRoomCreationFragment,
|
||||
findNavController().navigate(
|
||||
R.id.action_groupInfoFragment_to_chatRoomCreationFragment,
|
||||
args,
|
||||
getLeftToRightAnimationNavOptions(R.id.chatRoomCreationFragment, true)
|
||||
)
|
||||
|
|
|
@ -71,9 +71,9 @@ abstract class AbstractPhoneFragment<T : ViewDataBinding> : GenericFragment<T>()
|
|||
.setTitle(getString(R.string.assistant_phone_number_info_title))
|
||||
.setMessage(
|
||||
getString(R.string.assistant_phone_number_link_info_content) + "\n" +
|
||||
getString(
|
||||
R.string.assistant_phone_number_link_info_content_already_account
|
||||
)
|
||||
getString(
|
||||
R.string.assistant_phone_number_link_info_content_already_account
|
||||
)
|
||||
)
|
||||
.setNegativeButton(getString(R.string.dialog_ok), null)
|
||||
.show()
|
||||
|
|
|
@ -74,51 +74,66 @@ class AccountLoginFragment : AbstractPhoneFragment<AssistantAccountLoginFragment
|
|||
startActivity(intent)
|
||||
}
|
||||
|
||||
viewModel.goToSmsValidationEvent.observe(viewLifecycleOwner, {
|
||||
it.consume {
|
||||
val args = Bundle()
|
||||
args.putBoolean("IsLogin", true)
|
||||
args.putString("PhoneNumber", viewModel.accountCreator.phoneNumber)
|
||||
navigateToPhoneAccountValidation(args)
|
||||
}
|
||||
})
|
||||
|
||||
viewModel.leaveAssistantEvent.observe(viewLifecycleOwner, {
|
||||
it.consume {
|
||||
coreContext.contactsManager.updateLocalContacts()
|
||||
|
||||
if (coreContext.core.isEchoCancellerCalibrationRequired) {
|
||||
navigateToEchoCancellerCalibration()
|
||||
} else {
|
||||
requireActivity().finish()
|
||||
viewModel.goToSmsValidationEvent.observe(
|
||||
viewLifecycleOwner,
|
||||
{
|
||||
it.consume {
|
||||
val args = Bundle()
|
||||
args.putBoolean("IsLogin", true)
|
||||
args.putString("PhoneNumber", viewModel.accountCreator.phoneNumber)
|
||||
navigateToPhoneAccountValidation(args)
|
||||
}
|
||||
}
|
||||
})
|
||||
)
|
||||
|
||||
viewModel.invalidCredentialsEvent.observe(viewLifecycleOwner, {
|
||||
it.consume {
|
||||
val dialogViewModel = DialogViewModel(getString(R.string.assistant_error_invalid_credentials))
|
||||
val dialog: Dialog = DialogUtils.getDialog(requireContext(), dialogViewModel)
|
||||
viewModel.leaveAssistantEvent.observe(
|
||||
viewLifecycleOwner,
|
||||
{
|
||||
it.consume {
|
||||
coreContext.contactsManager.updateLocalContacts()
|
||||
|
||||
dialogViewModel.showCancelButton {
|
||||
viewModel.removeInvalidProxyConfig()
|
||||
dialog.dismiss()
|
||||
if (coreContext.core.isEchoCancellerCalibrationRequired) {
|
||||
navigateToEchoCancellerCalibration()
|
||||
} else {
|
||||
requireActivity().finish()
|
||||
}
|
||||
}
|
||||
|
||||
dialogViewModel.showDeleteButton({
|
||||
viewModel.continueEvenIfInvalidCredentials()
|
||||
dialog.dismiss()
|
||||
}, getString(R.string.assistant_continue_even_if_credentials_invalid))
|
||||
|
||||
dialog.show()
|
||||
}
|
||||
})
|
||||
)
|
||||
|
||||
viewModel.onErrorEvent.observe(viewLifecycleOwner, {
|
||||
it.consume { message ->
|
||||
(requireActivity() as AssistantActivity).showSnackBar(message)
|
||||
viewModel.invalidCredentialsEvent.observe(
|
||||
viewLifecycleOwner,
|
||||
{
|
||||
it.consume {
|
||||
val dialogViewModel = DialogViewModel(getString(R.string.assistant_error_invalid_credentials))
|
||||
val dialog: Dialog = DialogUtils.getDialog(requireContext(), dialogViewModel)
|
||||
|
||||
dialogViewModel.showCancelButton {
|
||||
viewModel.removeInvalidProxyConfig()
|
||||
dialog.dismiss()
|
||||
}
|
||||
|
||||
dialogViewModel.showDeleteButton(
|
||||
{
|
||||
viewModel.continueEvenIfInvalidCredentials()
|
||||
dialog.dismiss()
|
||||
},
|
||||
getString(R.string.assistant_continue_even_if_credentials_invalid)
|
||||
)
|
||||
|
||||
dialog.show()
|
||||
}
|
||||
}
|
||||
})
|
||||
)
|
||||
|
||||
viewModel.onErrorEvent.observe(
|
||||
viewLifecycleOwner,
|
||||
{
|
||||
it.consume { message ->
|
||||
(requireActivity() as AssistantActivity).showSnackBar(message)
|
||||
}
|
||||
}
|
||||
)
|
||||
|
||||
checkPermission()
|
||||
}
|
||||
|
|
|
@ -43,11 +43,14 @@ class EchoCancellerCalibrationFragment : GenericFragment<AssistantEchoCancellerC
|
|||
viewModel = ViewModelProvider(this).get(EchoCancellerCalibrationViewModel::class.java)
|
||||
binding.viewModel = viewModel
|
||||
|
||||
viewModel.echoCalibrationTerminated.observe(viewLifecycleOwner, {
|
||||
it.consume {
|
||||
requireActivity().finish()
|
||||
viewModel.echoCalibrationTerminated.observe(
|
||||
viewLifecycleOwner,
|
||||
{
|
||||
it.consume {
|
||||
requireActivity().finish()
|
||||
}
|
||||
}
|
||||
})
|
||||
)
|
||||
|
||||
if (!PermissionHelper.required(requireContext()).hasRecordAudioPermission()) {
|
||||
Log.i("[Echo Canceller Calibration] Asking for RECORD_AUDIO permission")
|
||||
|
|
|
@ -49,16 +49,22 @@ class EmailAccountCreationFragment : GenericFragment<AssistantEmailAccountCreati
|
|||
viewModel = ViewModelProvider(this, EmailAccountCreationViewModelFactory(sharedViewModel.getAccountCreator())).get(EmailAccountCreationViewModel::class.java)
|
||||
binding.viewModel = viewModel
|
||||
|
||||
viewModel.goToEmailValidationEvent.observe(viewLifecycleOwner, {
|
||||
it.consume {
|
||||
navigateToEmailAccountValidation()
|
||||
viewModel.goToEmailValidationEvent.observe(
|
||||
viewLifecycleOwner,
|
||||
{
|
||||
it.consume {
|
||||
navigateToEmailAccountValidation()
|
||||
}
|
||||
}
|
||||
})
|
||||
)
|
||||
|
||||
viewModel.onErrorEvent.observe(viewLifecycleOwner, {
|
||||
it.consume { message ->
|
||||
(requireActivity() as AssistantActivity).showSnackBar(message)
|
||||
viewModel.onErrorEvent.observe(
|
||||
viewLifecycleOwner,
|
||||
{
|
||||
it.consume { message ->
|
||||
(requireActivity() as AssistantActivity).showSnackBar(message)
|
||||
}
|
||||
}
|
||||
})
|
||||
)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -48,22 +48,28 @@ class EmailAccountValidationFragment : GenericFragment<AssistantEmailAccountVali
|
|||
viewModel = ViewModelProvider(this, EmailAccountValidationViewModelFactory(sharedViewModel.getAccountCreator())).get(EmailAccountValidationViewModel::class.java)
|
||||
binding.viewModel = viewModel
|
||||
|
||||
viewModel.leaveAssistantEvent.observe(viewLifecycleOwner, {
|
||||
it.consume {
|
||||
coreContext.contactsManager.updateLocalContacts()
|
||||
viewModel.leaveAssistantEvent.observe(
|
||||
viewLifecycleOwner,
|
||||
{
|
||||
it.consume {
|
||||
coreContext.contactsManager.updateLocalContacts()
|
||||
|
||||
val args = Bundle()
|
||||
args.putBoolean("AllowSkip", true)
|
||||
args.putString("Username", viewModel.accountCreator.username)
|
||||
args.putString("Password", viewModel.accountCreator.password)
|
||||
navigateToAccountLinking(args)
|
||||
val args = Bundle()
|
||||
args.putBoolean("AllowSkip", true)
|
||||
args.putString("Username", viewModel.accountCreator.username)
|
||||
args.putString("Password", viewModel.accountCreator.password)
|
||||
navigateToAccountLinking(args)
|
||||
}
|
||||
}
|
||||
})
|
||||
)
|
||||
|
||||
viewModel.onErrorEvent.observe(viewLifecycleOwner, {
|
||||
it.consume { message ->
|
||||
(requireActivity() as AssistantActivity).showSnackBar(message)
|
||||
viewModel.onErrorEvent.observe(
|
||||
viewLifecycleOwner,
|
||||
{
|
||||
it.consume { message ->
|
||||
(requireActivity() as AssistantActivity).showSnackBar(message)
|
||||
}
|
||||
}
|
||||
})
|
||||
)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -53,41 +53,53 @@ class GenericAccountLoginFragment : GenericFragment<AssistantGenericAccountLogin
|
|||
viewModel = ViewModelProvider(this, GenericLoginViewModelFactory(sharedViewModel.getAccountCreator(true))).get(GenericLoginViewModel::class.java)
|
||||
binding.viewModel = viewModel
|
||||
|
||||
viewModel.leaveAssistantEvent.observe(viewLifecycleOwner, {
|
||||
it.consume {
|
||||
coreContext.contactsManager.updateLocalContacts()
|
||||
viewModel.leaveAssistantEvent.observe(
|
||||
viewLifecycleOwner,
|
||||
{
|
||||
it.consume {
|
||||
coreContext.contactsManager.updateLocalContacts()
|
||||
|
||||
if (coreContext.core.isEchoCancellerCalibrationRequired) {
|
||||
navigateToEchoCancellerCalibration()
|
||||
} else {
|
||||
requireActivity().finish()
|
||||
if (coreContext.core.isEchoCancellerCalibrationRequired) {
|
||||
navigateToEchoCancellerCalibration()
|
||||
} else {
|
||||
requireActivity().finish()
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
)
|
||||
|
||||
viewModel.invalidCredentialsEvent.observe(viewLifecycleOwner, {
|
||||
it.consume {
|
||||
val dialogViewModel = DialogViewModel(getString(R.string.assistant_error_invalid_credentials))
|
||||
val dialog: Dialog = DialogUtils.getDialog(requireContext(), dialogViewModel)
|
||||
viewModel.invalidCredentialsEvent.observe(
|
||||
viewLifecycleOwner,
|
||||
{
|
||||
it.consume {
|
||||
val dialogViewModel = DialogViewModel(getString(R.string.assistant_error_invalid_credentials))
|
||||
val dialog: Dialog = DialogUtils.getDialog(requireContext(), dialogViewModel)
|
||||
|
||||
dialogViewModel.showCancelButton {
|
||||
viewModel.removeInvalidProxyConfig()
|
||||
dialog.dismiss()
|
||||
dialogViewModel.showCancelButton {
|
||||
viewModel.removeInvalidProxyConfig()
|
||||
dialog.dismiss()
|
||||
}
|
||||
|
||||
dialogViewModel.showDeleteButton(
|
||||
{
|
||||
viewModel.continueEvenIfInvalidCredentials()
|
||||
dialog.dismiss()
|
||||
},
|
||||
getString(R.string.assistant_continue_even_if_credentials_invalid)
|
||||
)
|
||||
|
||||
dialog.show()
|
||||
}
|
||||
|
||||
dialogViewModel.showDeleteButton({
|
||||
viewModel.continueEvenIfInvalidCredentials()
|
||||
dialog.dismiss()
|
||||
}, getString(R.string.assistant_continue_even_if_credentials_invalid))
|
||||
|
||||
dialog.show()
|
||||
}
|
||||
})
|
||||
)
|
||||
|
||||
viewModel.onErrorEvent.observe(viewLifecycleOwner, {
|
||||
it.consume { message ->
|
||||
(requireActivity() as AssistantActivity).showSnackBar(message)
|
||||
viewModel.onErrorEvent.observe(
|
||||
viewLifecycleOwner,
|
||||
{
|
||||
it.consume { message ->
|
||||
(requireActivity() as AssistantActivity).showSnackBar(message)
|
||||
}
|
||||
}
|
||||
})
|
||||
)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -56,20 +56,26 @@ class PhoneAccountCreationFragment : AbstractPhoneFragment<AssistantPhoneAccount
|
|||
CountryPickerFragment(viewModel).show(childFragmentManager, "CountryPicker")
|
||||
}
|
||||
|
||||
viewModel.goToSmsValidationEvent.observe(viewLifecycleOwner, {
|
||||
it.consume {
|
||||
val args = Bundle()
|
||||
args.putBoolean("IsCreation", true)
|
||||
args.putString("PhoneNumber", viewModel.accountCreator.phoneNumber)
|
||||
navigateToPhoneAccountValidation(args)
|
||||
viewModel.goToSmsValidationEvent.observe(
|
||||
viewLifecycleOwner,
|
||||
{
|
||||
it.consume {
|
||||
val args = Bundle()
|
||||
args.putBoolean("IsCreation", true)
|
||||
args.putString("PhoneNumber", viewModel.accountCreator.phoneNumber)
|
||||
navigateToPhoneAccountValidation(args)
|
||||
}
|
||||
}
|
||||
})
|
||||
)
|
||||
|
||||
viewModel.onErrorEvent.observe(viewLifecycleOwner, {
|
||||
it.consume { message ->
|
||||
(requireActivity() as AssistantActivity).showSnackBar(message)
|
||||
viewModel.onErrorEvent.observe(
|
||||
viewLifecycleOwner,
|
||||
{
|
||||
it.consume { message ->
|
||||
(requireActivity() as AssistantActivity).showSnackBar(message)
|
||||
}
|
||||
}
|
||||
})
|
||||
)
|
||||
|
||||
checkPermission()
|
||||
}
|
||||
|
|
|
@ -71,30 +71,39 @@ class PhoneAccountLinkingFragment : AbstractPhoneFragment<AssistantPhoneAccountL
|
|||
CountryPickerFragment(viewModel).show(childFragmentManager, "CountryPicker")
|
||||
}
|
||||
|
||||
viewModel.goToSmsValidationEvent.observe(viewLifecycleOwner, {
|
||||
it.consume {
|
||||
val args = Bundle()
|
||||
args.putBoolean("IsLinking", true)
|
||||
args.putString("PhoneNumber", viewModel.accountCreator.phoneNumber)
|
||||
navigateToPhoneAccountValidation(args)
|
||||
}
|
||||
})
|
||||
|
||||
viewModel.leaveAssistantEvent.observe(viewLifecycleOwner, {
|
||||
it.consume {
|
||||
if (LinphoneApplication.coreContext.core.isEchoCancellerCalibrationRequired) {
|
||||
navigateToEchoCancellerCalibration()
|
||||
} else {
|
||||
requireActivity().finish()
|
||||
viewModel.goToSmsValidationEvent.observe(
|
||||
viewLifecycleOwner,
|
||||
{
|
||||
it.consume {
|
||||
val args = Bundle()
|
||||
args.putBoolean("IsLinking", true)
|
||||
args.putString("PhoneNumber", viewModel.accountCreator.phoneNumber)
|
||||
navigateToPhoneAccountValidation(args)
|
||||
}
|
||||
}
|
||||
})
|
||||
)
|
||||
|
||||
viewModel.onErrorEvent.observe(viewLifecycleOwner, {
|
||||
it.consume { message ->
|
||||
(requireActivity() as AssistantActivity).showSnackBar(message)
|
||||
viewModel.leaveAssistantEvent.observe(
|
||||
viewLifecycleOwner,
|
||||
{
|
||||
it.consume {
|
||||
if (LinphoneApplication.coreContext.core.isEchoCancellerCalibrationRequired) {
|
||||
navigateToEchoCancellerCalibration()
|
||||
} else {
|
||||
requireActivity().finish()
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
)
|
||||
|
||||
viewModel.onErrorEvent.observe(
|
||||
viewLifecycleOwner,
|
||||
{
|
||||
it.consume { message ->
|
||||
(requireActivity() as AssistantActivity).showSnackBar(message)
|
||||
}
|
||||
}
|
||||
)
|
||||
|
||||
checkPermission()
|
||||
}
|
||||
|
|
|
@ -58,32 +58,38 @@ class PhoneAccountValidationFragment : GenericFragment<AssistantPhoneAccountVali
|
|||
viewModel.isCreation.value = arguments?.getBoolean("IsCreation", false)
|
||||
viewModel.isLinking.value = arguments?.getBoolean("IsLinking", false)
|
||||
|
||||
viewModel.leaveAssistantEvent.observe(viewLifecycleOwner, {
|
||||
it.consume {
|
||||
when {
|
||||
viewModel.isLogin.value == true || viewModel.isCreation.value == true -> {
|
||||
coreContext.contactsManager.updateLocalContacts()
|
||||
viewModel.leaveAssistantEvent.observe(
|
||||
viewLifecycleOwner,
|
||||
{
|
||||
it.consume {
|
||||
when {
|
||||
viewModel.isLogin.value == true || viewModel.isCreation.value == true -> {
|
||||
coreContext.contactsManager.updateLocalContacts()
|
||||
|
||||
if (coreContext.core.isEchoCancellerCalibrationRequired) {
|
||||
navigateToEchoCancellerCalibration()
|
||||
} else {
|
||||
requireActivity().finish()
|
||||
if (coreContext.core.isEchoCancellerCalibrationRequired) {
|
||||
navigateToEchoCancellerCalibration()
|
||||
} else {
|
||||
requireActivity().finish()
|
||||
}
|
||||
}
|
||||
viewModel.isLinking.value == true -> {
|
||||
val args = Bundle()
|
||||
args.putString("Identity", "sip:${viewModel.accountCreator.username}@${viewModel.accountCreator.domain}")
|
||||
navigateToAccountSettings(args)
|
||||
}
|
||||
}
|
||||
viewModel.isLinking.value == true -> {
|
||||
val args = Bundle()
|
||||
args.putString("Identity", "sip:${viewModel.accountCreator.username}@${viewModel.accountCreator.domain}")
|
||||
navigateToAccountSettings(args)
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
)
|
||||
|
||||
viewModel.onErrorEvent.observe(viewLifecycleOwner, {
|
||||
it.consume { message ->
|
||||
(requireActivity() as AssistantActivity).showSnackBar(message)
|
||||
viewModel.onErrorEvent.observe(
|
||||
viewLifecycleOwner,
|
||||
{
|
||||
it.consume { message ->
|
||||
(requireActivity() as AssistantActivity).showSnackBar(message)
|
||||
}
|
||||
}
|
||||
})
|
||||
)
|
||||
|
||||
val clipboard = requireContext().getSystemService(CLIPBOARD_SERVICE) as ClipboardManager
|
||||
clipboard.addPrimaryClipChangedListener {
|
||||
|
|
|
@ -51,12 +51,15 @@ class QrCodeFragment : GenericFragment<AssistantQrCodeFragmentBinding>() {
|
|||
viewModel = ViewModelProvider(this).get(QrCodeViewModel::class.java)
|
||||
binding.viewModel = viewModel
|
||||
|
||||
viewModel.qrCodeFoundEvent.observe(viewLifecycleOwner, {
|
||||
it.consume { url ->
|
||||
sharedViewModel.remoteProvisioningUrl.value = url
|
||||
findNavController().navigateUp()
|
||||
viewModel.qrCodeFoundEvent.observe(
|
||||
viewLifecycleOwner,
|
||||
{
|
||||
it.consume { url ->
|
||||
sharedViewModel.remoteProvisioningUrl.value = url
|
||||
findNavController().navigateUp()
|
||||
}
|
||||
}
|
||||
})
|
||||
)
|
||||
viewModel.setBackCamera()
|
||||
|
||||
if (!PermissionHelper.required(requireContext()).hasCameraPermission()) {
|
||||
|
|
|
@ -54,20 +54,23 @@ class RemoteProvisioningFragment : GenericFragment<AssistantRemoteProvisioningFr
|
|||
navigateToQrCode()
|
||||
}
|
||||
|
||||
viewModel.fetchSuccessfulEvent.observe(viewLifecycleOwner, {
|
||||
it.consume { success ->
|
||||
if (success) {
|
||||
if (coreContext.core.isEchoCancellerCalibrationRequired) {
|
||||
navigateToEchoCancellerCalibration()
|
||||
viewModel.fetchSuccessfulEvent.observe(
|
||||
viewLifecycleOwner,
|
||||
{
|
||||
it.consume { success ->
|
||||
if (success) {
|
||||
if (coreContext.core.isEchoCancellerCalibrationRequired) {
|
||||
navigateToEchoCancellerCalibration()
|
||||
} else {
|
||||
requireActivity().finish()
|
||||
}
|
||||
} else {
|
||||
requireActivity().finish()
|
||||
val activity = requireActivity() as AssistantActivity
|
||||
activity.showSnackBar(R.string.assistant_remote_provisioning_failure)
|
||||
}
|
||||
} else {
|
||||
val activity = requireActivity() as AssistantActivity
|
||||
activity.showSnackBar(R.string.assistant_remote_provisioning_failure)
|
||||
}
|
||||
}
|
||||
})
|
||||
)
|
||||
|
||||
viewModel.urlToFetch.value = sharedViewModel.remoteProvisioningUrl.value ?: coreContext.core.provisioningUri
|
||||
}
|
||||
|
|
|
@ -72,9 +72,12 @@ class WelcomeFragment : GenericFragment<AssistantWelcomeFragmentBinding>() {
|
|||
navigateToRemoteProvisioning()
|
||||
}
|
||||
|
||||
viewModel.termsAndPrivacyAccepted.observe(viewLifecycleOwner, {
|
||||
if (it) corePreferences.readAndAgreeTermsAndPrivacy = true
|
||||
})
|
||||
viewModel.termsAndPrivacyAccepted.observe(
|
||||
viewLifecycleOwner,
|
||||
{
|
||||
if (it) corePreferences.readAndAgreeTermsAndPrivacy = true
|
||||
}
|
||||
)
|
||||
|
||||
setUpTermsAndPrivacyLinks()
|
||||
}
|
||||
|
|
|
@ -30,7 +30,8 @@ import org.linphone.core.DialPlan
|
|||
import org.linphone.core.tools.Log
|
||||
import org.linphone.utils.PhoneNumberUtils
|
||||
|
||||
abstract class AbstractPhoneViewModel(val accountCreator: AccountCreator) : ViewModel(),
|
||||
abstract class AbstractPhoneViewModel(val accountCreator: AccountCreator) :
|
||||
ViewModel(),
|
||||
CountryPickerFragment.CountryPickedListener {
|
||||
|
||||
val prefix = MutableLiveData<String>()
|
||||
|
|
|
@ -84,12 +84,12 @@ class AccountLoginViewModel(accountCreator: AccountCreator) : AbstractPhoneViewM
|
|||
private var proxyConfigToCheck: ProxyConfig? = null
|
||||
|
||||
private val coreListener = object : CoreListenerStub() {
|
||||
override fun onRegistrationStateChanged(
|
||||
core: Core,
|
||||
cfg: ProxyConfig,
|
||||
state: RegistrationState,
|
||||
message: String
|
||||
) {
|
||||
override fun onRegistrationStateChanged(
|
||||
core: Core,
|
||||
cfg: ProxyConfig,
|
||||
state: RegistrationState,
|
||||
message: String
|
||||
) {
|
||||
if (cfg == proxyConfigToCheck) {
|
||||
Log.i("[Assistant] [Account Login] Registration state is $state: $message")
|
||||
if (state == RegistrationState.Ok) {
|
||||
|
|
|
@ -158,13 +158,13 @@ class EmailAccountCreationViewModel(val accountCreator: AccountCreator) : ViewMo
|
|||
|
||||
private fun isCreateButtonEnabled(): Boolean {
|
||||
return username.value.orEmpty().isNotEmpty() &&
|
||||
email.value.orEmpty().isNotEmpty() &&
|
||||
password.value.orEmpty().isNotEmpty() &&
|
||||
passwordConfirmation.value.orEmpty().isNotEmpty() &&
|
||||
password.value == passwordConfirmation.value &&
|
||||
usernameError.value.orEmpty().isEmpty() &&
|
||||
emailError.value.orEmpty().isEmpty() &&
|
||||
passwordError.value.orEmpty().isEmpty() &&
|
||||
passwordConfirmationError.value.orEmpty().isEmpty()
|
||||
email.value.orEmpty().isNotEmpty() &&
|
||||
password.value.orEmpty().isNotEmpty() &&
|
||||
passwordConfirmation.value.orEmpty().isNotEmpty() &&
|
||||
password.value == passwordConfirmation.value &&
|
||||
usernameError.value.orEmpty().isEmpty() &&
|
||||
emailError.value.orEmpty().isEmpty() &&
|
||||
passwordError.value.orEmpty().isEmpty() &&
|
||||
passwordConfirmationError.value.orEmpty().isEmpty()
|
||||
}
|
||||
}
|
||||
|
|
|
@ -160,9 +160,11 @@ class PhoneAccountCreationViewModel(accountCreator: AccountCreator) : AbstractPh
|
|||
private fun isCreateButtonEnabled(): Boolean {
|
||||
val usernameRegexp = corePreferences.config.getString("assistant", "username_regex", "^[a-z0-9+_.\\-]*\$")
|
||||
return isPhoneNumberOk() && usernameRegexp != null &&
|
||||
(useUsername.value == false ||
|
||||
(
|
||||
useUsername.value == false ||
|
||||
username.value.orEmpty().matches(Regex(usernameRegexp)) &&
|
||||
username.value.orEmpty().isNotEmpty() &&
|
||||
usernameError.value.orEmpty().isEmpty())
|
||||
usernameError.value.orEmpty().isEmpty()
|
||||
)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -62,21 +62,27 @@ class CallActivity : ProximitySensorActivity() {
|
|||
|
||||
sharedViewModel = ViewModelProvider(this).get(SharedCallViewModel::class.java)
|
||||
|
||||
sharedViewModel.toggleDrawerEvent.observe(this, {
|
||||
it.consume {
|
||||
if (binding.statsMenu.isDrawerOpen(Gravity.LEFT)) {
|
||||
binding.statsMenu.closeDrawer(binding.sideMenuContent, true)
|
||||
} else {
|
||||
binding.statsMenu.openDrawer(binding.sideMenuContent, true)
|
||||
sharedViewModel.toggleDrawerEvent.observe(
|
||||
this,
|
||||
{
|
||||
it.consume {
|
||||
if (binding.statsMenu.isDrawerOpen(Gravity.LEFT)) {
|
||||
binding.statsMenu.closeDrawer(binding.sideMenuContent, true)
|
||||
} else {
|
||||
binding.statsMenu.openDrawer(binding.sideMenuContent, true)
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
)
|
||||
|
||||
sharedViewModel.resetHiddenInterfaceTimerInVideoCallEvent.observe(this, {
|
||||
it.consume {
|
||||
viewModel.showMomentarily()
|
||||
sharedViewModel.resetHiddenInterfaceTimerInVideoCallEvent.observe(
|
||||
this,
|
||||
{
|
||||
it.consume {
|
||||
viewModel.showMomentarily()
|
||||
}
|
||||
}
|
||||
})
|
||||
)
|
||||
|
||||
coreContext.core.nativeVideoWindowId = binding.remoteVideoSurface
|
||||
coreContext.core.nativePreviewWindowId = binding.localPreviewVideoSurface
|
||||
|
@ -104,9 +110,12 @@ class CallActivity : ProximitySensorActivity() {
|
|||
|
||||
videoZoomHelper = VideoZoomHelper(this, binding.remoteVideoSurface)
|
||||
|
||||
viewModel.proximitySensorEnabled.observe(this, {
|
||||
enableProximitySensor(it)
|
||||
})
|
||||
viewModel.proximitySensorEnabled.observe(
|
||||
this,
|
||||
{
|
||||
enableProximitySensor(it)
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
override fun onResume() {
|
||||
|
@ -191,10 +200,10 @@ class CallActivity : ProximitySensorActivity() {
|
|||
|
||||
private fun hideSystemUI() {
|
||||
window.decorView.systemUiVisibility = View.SYSTEM_UI_FLAG_FULLSCREEN or
|
||||
View.SYSTEM_UI_FLAG_HIDE_NAVIGATION or
|
||||
View.SYSTEM_UI_FLAG_IMMERSIVE or
|
||||
View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN or
|
||||
View.SYSTEM_UI_FLAG_LAYOUT_STABLE or
|
||||
View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
|
||||
View.SYSTEM_UI_FLAG_HIDE_NAVIGATION or
|
||||
View.SYSTEM_UI_FLAG_IMMERSIVE or
|
||||
View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN or
|
||||
View.SYSTEM_UI_FLAG_LAYOUT_STABLE or
|
||||
View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
|
||||
}
|
||||
}
|
||||
|
|
|
@ -78,19 +78,25 @@ class IncomingCallActivity : GenericActivity() {
|
|||
)[IncomingCallViewModel::class.java]
|
||||
binding.viewModel = viewModel
|
||||
|
||||
viewModel.callEndedEvent.observe(this, {
|
||||
it.consume {
|
||||
Log.i("[Incoming Call Activity] Call ended, finish activity")
|
||||
finish()
|
||||
viewModel.callEndedEvent.observe(
|
||||
this,
|
||||
{
|
||||
it.consume {
|
||||
Log.i("[Incoming Call Activity] Call ended, finish activity")
|
||||
finish()
|
||||
}
|
||||
}
|
||||
})
|
||||
)
|
||||
|
||||
viewModel.earlyMediaVideoEnabled.observe(this, {
|
||||
if (it) {
|
||||
Log.i("[Incoming Call Activity] Early media video being received, set native window id")
|
||||
coreContext.core.nativeVideoWindowId = binding.remoteVideoSurface
|
||||
viewModel.earlyMediaVideoEnabled.observe(
|
||||
this,
|
||||
{
|
||||
if (it) {
|
||||
Log.i("[Incoming Call Activity] Early media video being received, set native window id")
|
||||
coreContext.core.nativeVideoWindowId = binding.remoteVideoSurface
|
||||
}
|
||||
}
|
||||
})
|
||||
)
|
||||
|
||||
val keyguardManager = getSystemService(Context.KEYGUARD_SERVICE) as KeyguardManager
|
||||
val keyguardLocked = keyguardManager.isKeyguardLocked
|
||||
|
@ -169,7 +175,8 @@ class IncomingCallActivity : GenericActivity() {
|
|||
private fun findIncomingCall(): Call? {
|
||||
for (call in coreContext.core.calls) {
|
||||
if (call.state == Call.State.IncomingReceived ||
|
||||
call.state == Call.State.IncomingEarlyMedia) {
|
||||
call.state == Call.State.IncomingEarlyMedia
|
||||
) {
|
||||
return call
|
||||
}
|
||||
}
|
||||
|
|
|
@ -79,41 +79,56 @@ class OutgoingCallActivity : ProximitySensorActivity() {
|
|||
controlsViewModel = ViewModelProvider(this).get(ControlsViewModel::class.java)
|
||||
binding.controlsViewModel = controlsViewModel
|
||||
|
||||
viewModel.callEndedEvent.observe(this, {
|
||||
it.consume {
|
||||
Log.i("[Outgoing Call Activity] Call ended, finish activity")
|
||||
finish()
|
||||
viewModel.callEndedEvent.observe(
|
||||
this,
|
||||
{
|
||||
it.consume {
|
||||
Log.i("[Outgoing Call Activity] Call ended, finish activity")
|
||||
finish()
|
||||
}
|
||||
}
|
||||
})
|
||||
)
|
||||
|
||||
viewModel.callConnectedEvent.observe(this, {
|
||||
it.consume {
|
||||
Log.i("[Outgoing Call Activity] Call connected, finish activity")
|
||||
finish()
|
||||
viewModel.callConnectedEvent.observe(
|
||||
this,
|
||||
{
|
||||
it.consume {
|
||||
Log.i("[Outgoing Call Activity] Call connected, finish activity")
|
||||
finish()
|
||||
}
|
||||
}
|
||||
})
|
||||
)
|
||||
|
||||
controlsViewModel.isSpeakerSelected.observe(this, {
|
||||
enableProximitySensor(!it)
|
||||
})
|
||||
|
||||
controlsViewModel.askPermissionEvent.observe(this, {
|
||||
it.consume { permission ->
|
||||
requestPermissions(arrayOf(permission), 0)
|
||||
controlsViewModel.isSpeakerSelected.observe(
|
||||
this,
|
||||
{
|
||||
enableProximitySensor(!it)
|
||||
}
|
||||
})
|
||||
)
|
||||
|
||||
controlsViewModel.toggleNumpadEvent.observe(this, {
|
||||
it.consume { open ->
|
||||
if (this::numpadAnimator.isInitialized) {
|
||||
if (open) {
|
||||
numpadAnimator.start()
|
||||
} else {
|
||||
numpadAnimator.reverse()
|
||||
controlsViewModel.askPermissionEvent.observe(
|
||||
this,
|
||||
{
|
||||
it.consume { permission ->
|
||||
requestPermissions(arrayOf(permission), 0)
|
||||
}
|
||||
}
|
||||
)
|
||||
|
||||
controlsViewModel.toggleNumpadEvent.observe(
|
||||
this,
|
||||
{
|
||||
it.consume { open ->
|
||||
if (this::numpadAnimator.isInitialized) {
|
||||
if (open) {
|
||||
numpadAnimator.start()
|
||||
} else {
|
||||
numpadAnimator.reverse()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
)
|
||||
|
||||
if (Version.sdkAboveOrEqual(Version.API23_MARSHMALLOW_60)) {
|
||||
checkPermissions()
|
||||
|
@ -192,7 +207,8 @@ class OutgoingCallActivity : ProximitySensorActivity() {
|
|||
for (call in coreContext.core.calls) {
|
||||
if (call.state == Call.State.OutgoingInit ||
|
||||
call.state == Call.State.OutgoingProgress ||
|
||||
call.state == Call.State.OutgoingRinging) {
|
||||
call.state == Call.State.OutgoingRinging
|
||||
) {
|
||||
return call
|
||||
}
|
||||
}
|
||||
|
|
|
@ -39,26 +39,29 @@ class VideoZoomHelper(context: Context, private var videoDisplayView: View) : Ge
|
|||
init {
|
||||
val gestureDetector = GestureDetector(context, this)
|
||||
|
||||
scaleDetector = ScaleGestureDetector(context, object :
|
||||
ScaleGestureDetector.SimpleOnScaleGestureListener() {
|
||||
override fun onScale(detector: ScaleGestureDetector): Boolean {
|
||||
zoomFactor *= detector.scaleFactor
|
||||
// Don't let the object get too small or too large.
|
||||
// Zoom to make the video fill the screen vertically
|
||||
val portraitZoomFactor = videoDisplayView.height.toFloat() / (3 * videoDisplayView.width / 4)
|
||||
// Zoom to make the video fill the screen horizontally
|
||||
val landscapeZoomFactor = videoDisplayView.width.toFloat() / (3 * videoDisplayView.height / 4)
|
||||
zoomFactor = max(0.1f, min(zoomFactor, max(portraitZoomFactor, landscapeZoomFactor)))
|
||||
scaleDetector = ScaleGestureDetector(
|
||||
context,
|
||||
object :
|
||||
ScaleGestureDetector.SimpleOnScaleGestureListener() {
|
||||
override fun onScale(detector: ScaleGestureDetector): Boolean {
|
||||
zoomFactor *= detector.scaleFactor
|
||||
// Don't let the object get too small or too large.
|
||||
// Zoom to make the video fill the screen vertically
|
||||
val portraitZoomFactor = videoDisplayView.height.toFloat() / (3 * videoDisplayView.width / 4)
|
||||
// Zoom to make the video fill the screen horizontally
|
||||
val landscapeZoomFactor = videoDisplayView.width.toFloat() / (3 * videoDisplayView.height / 4)
|
||||
zoomFactor = max(0.1f, min(zoomFactor, max(portraitZoomFactor, landscapeZoomFactor)))
|
||||
|
||||
val currentCall: Call? = coreContext.core.currentCall
|
||||
if (currentCall != null) {
|
||||
currentCall.zoom(zoomFactor, zoomCenterX, zoomCenterY)
|
||||
return true
|
||||
val currentCall: Call? = coreContext.core.currentCall
|
||||
if (currentCall != null) {
|
||||
currentCall.zoom(zoomFactor, zoomCenterX, zoomCenterY)
|
||||
return true
|
||||
}
|
||||
|
||||
return false
|
||||
}
|
||||
|
||||
return false
|
||||
}
|
||||
})
|
||||
)
|
||||
|
||||
videoDisplayView.setOnTouchListener { _, event ->
|
||||
val currentZoomFactor = zoomFactor
|
||||
|
|
|
@ -80,101 +80,131 @@ class ControlsFragment : GenericFragment<CallControlsFragmentBinding>() {
|
|||
conferenceViewModel = ViewModelProvider(this).get(ConferenceViewModel::class.java)
|
||||
binding.conferenceViewModel = conferenceViewModel
|
||||
|
||||
callsViewModel.currentCallViewModel.observe(viewLifecycleOwner, {
|
||||
if (it != null) {
|
||||
binding.activeCallTimer.base =
|
||||
SystemClock.elapsedRealtime() - (1000 * it.call.duration) // Linphone timestamps are in seconds
|
||||
binding.activeCallTimer.start()
|
||||
}
|
||||
})
|
||||
|
||||
callsViewModel.noMoreCallEvent.observe(viewLifecycleOwner, {
|
||||
it.consume {
|
||||
requireActivity().finish()
|
||||
}
|
||||
})
|
||||
|
||||
callsViewModel.askWriteExternalStoragePermissionEvent.observe(viewLifecycleOwner, {
|
||||
it.consume {
|
||||
if (!PermissionHelper.get().hasWriteExternalStorage()) {
|
||||
Log.i("[Controls Fragment] Asking for WRITE_EXTERNAL_STORAGE permission")
|
||||
requestPermissions(arrayOf(Manifest.permission.WRITE_EXTERNAL_STORAGE), 1)
|
||||
callsViewModel.currentCallViewModel.observe(
|
||||
viewLifecycleOwner,
|
||||
{
|
||||
if (it != null) {
|
||||
binding.activeCallTimer.base =
|
||||
SystemClock.elapsedRealtime() - (1000 * it.call.duration) // Linphone timestamps are in seconds
|
||||
binding.activeCallTimer.start()
|
||||
}
|
||||
}
|
||||
})
|
||||
)
|
||||
|
||||
callsViewModel.callUpdateEvent.observe(viewLifecycleOwner, {
|
||||
it.consume { call ->
|
||||
if (call.state == Call.State.StreamsRunning) {
|
||||
dialog?.dismiss()
|
||||
} else if (call.state == Call.State.UpdatedByRemote) {
|
||||
if (coreContext.core.videoCaptureEnabled() || coreContext.core.videoDisplayEnabled()) {
|
||||
if (call.currentParams.videoEnabled() != call.remoteParams?.videoEnabled()) {
|
||||
showCallVideoUpdateDialog(call)
|
||||
callsViewModel.noMoreCallEvent.observe(
|
||||
viewLifecycleOwner,
|
||||
{
|
||||
it.consume {
|
||||
requireActivity().finish()
|
||||
}
|
||||
}
|
||||
)
|
||||
|
||||
callsViewModel.askWriteExternalStoragePermissionEvent.observe(
|
||||
viewLifecycleOwner,
|
||||
{
|
||||
it.consume {
|
||||
if (!PermissionHelper.get().hasWriteExternalStorage()) {
|
||||
Log.i("[Controls Fragment] Asking for WRITE_EXTERNAL_STORAGE permission")
|
||||
requestPermissions(arrayOf(Manifest.permission.WRITE_EXTERNAL_STORAGE), 1)
|
||||
}
|
||||
}
|
||||
}
|
||||
)
|
||||
|
||||
callsViewModel.callUpdateEvent.observe(
|
||||
viewLifecycleOwner,
|
||||
{
|
||||
it.consume { call ->
|
||||
if (call.state == Call.State.StreamsRunning) {
|
||||
dialog?.dismiss()
|
||||
} else if (call.state == Call.State.UpdatedByRemote) {
|
||||
if (coreContext.core.videoCaptureEnabled() || coreContext.core.videoDisplayEnabled()) {
|
||||
if (call.currentParams.videoEnabled() != call.remoteParams?.videoEnabled()) {
|
||||
showCallVideoUpdateDialog(call)
|
||||
}
|
||||
} else {
|
||||
Log.w("[Controls Fragment] Video display & capture are disabled, don't show video dialog")
|
||||
}
|
||||
} else {
|
||||
Log.w("[Controls Fragment] Video display & capture are disabled, don't show video dialog")
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
)
|
||||
|
||||
controlsViewModel.chatClickedEvent.observe(viewLifecycleOwner, {
|
||||
it.consume {
|
||||
val intent = Intent()
|
||||
intent.setClass(requireContext(), MainActivity::class.java)
|
||||
intent.putExtra("Chat", true)
|
||||
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
|
||||
startActivity(intent)
|
||||
controlsViewModel.chatClickedEvent.observe(
|
||||
viewLifecycleOwner,
|
||||
{
|
||||
it.consume {
|
||||
val intent = Intent()
|
||||
intent.setClass(requireContext(), MainActivity::class.java)
|
||||
intent.putExtra("Chat", true)
|
||||
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
|
||||
startActivity(intent)
|
||||
}
|
||||
}
|
||||
})
|
||||
)
|
||||
|
||||
controlsViewModel.addCallClickedEvent.observe(viewLifecycleOwner, {
|
||||
it.consume {
|
||||
val intent = Intent()
|
||||
intent.setClass(requireContext(), MainActivity::class.java)
|
||||
intent.putExtra("Dialer", true)
|
||||
intent.putExtra("Transfer", false)
|
||||
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
|
||||
startActivity(intent)
|
||||
controlsViewModel.addCallClickedEvent.observe(
|
||||
viewLifecycleOwner,
|
||||
{
|
||||
it.consume {
|
||||
val intent = Intent()
|
||||
intent.setClass(requireContext(), MainActivity::class.java)
|
||||
intent.putExtra("Dialer", true)
|
||||
intent.putExtra("Transfer", false)
|
||||
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
|
||||
startActivity(intent)
|
||||
}
|
||||
}
|
||||
})
|
||||
)
|
||||
|
||||
controlsViewModel.transferCallClickedEvent.observe(viewLifecycleOwner, {
|
||||
it.consume {
|
||||
val intent = Intent()
|
||||
intent.setClass(requireContext(), MainActivity::class.java)
|
||||
intent.putExtra("Dialer", true)
|
||||
intent.putExtra("Transfer", true)
|
||||
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
|
||||
startActivity(intent)
|
||||
controlsViewModel.transferCallClickedEvent.observe(
|
||||
viewLifecycleOwner,
|
||||
{
|
||||
it.consume {
|
||||
val intent = Intent()
|
||||
intent.setClass(requireContext(), MainActivity::class.java)
|
||||
intent.putExtra("Dialer", true)
|
||||
intent.putExtra("Transfer", true)
|
||||
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
|
||||
startActivity(intent)
|
||||
}
|
||||
}
|
||||
})
|
||||
)
|
||||
|
||||
controlsViewModel.askPermissionEvent.observe(viewLifecycleOwner, {
|
||||
it.consume { permission ->
|
||||
Log.i("[Controls Fragment] Asking for $permission permission")
|
||||
requestPermissions(arrayOf(permission), 0)
|
||||
controlsViewModel.askPermissionEvent.observe(
|
||||
viewLifecycleOwner,
|
||||
{
|
||||
it.consume { permission ->
|
||||
Log.i("[Controls Fragment] Asking for $permission permission")
|
||||
requestPermissions(arrayOf(permission), 0)
|
||||
}
|
||||
}
|
||||
})
|
||||
)
|
||||
|
||||
controlsViewModel.toggleNumpadEvent.observe(viewLifecycleOwner, {
|
||||
it.consume { open ->
|
||||
if (this::numpadAnimator.isInitialized) {
|
||||
if (open) {
|
||||
numpadAnimator.start()
|
||||
} else {
|
||||
numpadAnimator.reverse()
|
||||
controlsViewModel.toggleNumpadEvent.observe(
|
||||
viewLifecycleOwner,
|
||||
{
|
||||
it.consume { open ->
|
||||
if (this::numpadAnimator.isInitialized) {
|
||||
if (open) {
|
||||
numpadAnimator.start()
|
||||
} else {
|
||||
numpadAnimator.reverse()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
)
|
||||
|
||||
controlsViewModel.somethingClickedEvent.observe(viewLifecycleOwner, {
|
||||
it.consume {
|
||||
sharedViewModel.resetHiddenInterfaceTimerInVideoCallEvent.value = Event(true)
|
||||
controlsViewModel.somethingClickedEvent.observe(
|
||||
viewLifecycleOwner,
|
||||
{
|
||||
it.consume {
|
||||
sharedViewModel.resetHiddenInterfaceTimerInVideoCallEvent.value = Event(true)
|
||||
}
|
||||
}
|
||||
})
|
||||
)
|
||||
|
||||
if (Version.sdkAboveOrEqual(Version.API23_MARSHMALLOW_60)) {
|
||||
checkPermissions()
|
||||
|
@ -245,15 +275,21 @@ class ControlsFragment : GenericFragment<CallControlsFragmentBinding>() {
|
|||
val viewModel = DialogViewModel(AppUtils.getString(R.string.call_video_update_requested_dialog))
|
||||
dialog = DialogUtils.getDialog(requireContext(), viewModel)
|
||||
|
||||
viewModel.showCancelButton({
|
||||
callsViewModel.answerCallVideoUpdateRequest(call, false)
|
||||
dialog?.dismiss()
|
||||
}, getString(R.string.dialog_decline))
|
||||
viewModel.showCancelButton(
|
||||
{
|
||||
callsViewModel.answerCallVideoUpdateRequest(call, false)
|
||||
dialog?.dismiss()
|
||||
},
|
||||
getString(R.string.dialog_decline)
|
||||
)
|
||||
|
||||
viewModel.showOkButton({
|
||||
callsViewModel.answerCallVideoUpdateRequest(call, true)
|
||||
dialog?.dismiss()
|
||||
}, getString(R.string.dialog_accept))
|
||||
viewModel.showOkButton(
|
||||
{
|
||||
callsViewModel.answerCallVideoUpdateRequest(call, true)
|
||||
dialog?.dismiss()
|
||||
},
|
||||
getString(R.string.dialog_accept)
|
||||
)
|
||||
|
||||
dialog?.show()
|
||||
}
|
||||
|
|
|
@ -62,13 +62,16 @@ class StatusFragment : GenericFragment<CallStatusFragmentBinding>() {
|
|||
viewModel.refreshRegister()
|
||||
}
|
||||
|
||||
viewModel.showZrtpDialogEvent.observe(viewLifecycleOwner, {
|
||||
it.consume { call ->
|
||||
if (call.state == Call.State.Connected || call.state == Call.State.StreamsRunning) {
|
||||
showZrtpDialog(call)
|
||||
viewModel.showZrtpDialogEvent.observe(
|
||||
viewLifecycleOwner,
|
||||
{
|
||||
it.consume { call ->
|
||||
if (call.state == Call.State.Connected || call.state == Call.State.StreamsRunning) {
|
||||
showZrtpDialog(call)
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
)
|
||||
}
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
|
@ -117,19 +120,25 @@ class StatusFragment : GenericFragment<CallStatusFragmentBinding>() {
|
|||
|
||||
val dialog: Dialog = DialogUtils.getDialog(requireContext(), viewModel)
|
||||
|
||||
viewModel.showDeleteButton({
|
||||
call.authenticationTokenVerified = false
|
||||
this@StatusFragment.viewModel.updateEncryptionInfo(call)
|
||||
dialog.dismiss()
|
||||
zrtpDialog = null
|
||||
}, getString(R.string.zrtp_dialog_deny_button_label))
|
||||
viewModel.showDeleteButton(
|
||||
{
|
||||
call.authenticationTokenVerified = false
|
||||
this@StatusFragment.viewModel.updateEncryptionInfo(call)
|
||||
dialog.dismiss()
|
||||
zrtpDialog = null
|
||||
},
|
||||
getString(R.string.zrtp_dialog_deny_button_label)
|
||||
)
|
||||
|
||||
viewModel.showOkButton({
|
||||
call.authenticationTokenVerified = true
|
||||
this@StatusFragment.viewModel.updateEncryptionInfo(call)
|
||||
dialog.dismiss()
|
||||
zrtpDialog = null
|
||||
}, getString(R.string.zrtp_dialog_ok_button_label))
|
||||
viewModel.showOkButton(
|
||||
{
|
||||
call.authenticationTokenVerified = true
|
||||
this@StatusFragment.viewModel.updateEncryptionInfo(call)
|
||||
dialog.dismiss()
|
||||
zrtpDialog = null
|
||||
},
|
||||
getString(R.string.zrtp_dialog_ok_button_label)
|
||||
)
|
||||
|
||||
zrtpDialog = dialog
|
||||
dialog.show()
|
||||
|
|
|
@ -148,15 +148,18 @@ open class CallViewModel(val call: Call) : GenericContactViewModel(call.remoteAd
|
|||
timer?.cancel()
|
||||
|
||||
timer = Timer("Call update timeout")
|
||||
timer?.schedule(object : TimerTask() {
|
||||
override fun run() {
|
||||
// Decline call update
|
||||
viewModelScope.launch {
|
||||
withContext(Dispatchers.Main) {
|
||||
coreContext.answerCallVideoUpdateRequest(call, false)
|
||||
timer?.schedule(
|
||||
object : TimerTask() {
|
||||
override fun run() {
|
||||
// Decline call update
|
||||
viewModelScope.launch {
|
||||
withContext(Dispatchers.Main) {
|
||||
coreContext.answerCallVideoUpdateRequest(call, false)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}, 30000)
|
||||
},
|
||||
30000
|
||||
)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -123,15 +123,18 @@ class ControlsFadingViewModel : ViewModel() {
|
|||
timer?.cancel()
|
||||
|
||||
timer = Timer("Hide UI controls scheduler")
|
||||
timer?.schedule(object : TimerTask() {
|
||||
override fun run() {
|
||||
viewModelScope.launch {
|
||||
withContext(Dispatchers.Main) {
|
||||
val videoEnabled = coreContext.isVideoCallOrConferenceActive()
|
||||
areControlsHidden.postValue(videoEnabled)
|
||||
timer?.schedule(
|
||||
object : TimerTask() {
|
||||
override fun run() {
|
||||
viewModelScope.launch {
|
||||
withContext(Dispatchers.Main) {
|
||||
val videoEnabled = coreContext.isVideoCallOrConferenceActive()
|
||||
areControlsHidden.postValue(videoEnabled)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}, 3000)
|
||||
},
|
||||
3000
|
||||
)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -445,8 +445,10 @@ class ControlsViewModel : ViewModel() {
|
|||
val core = coreContext.core
|
||||
val currentCall = core.currentCall
|
||||
isVideoAvailable.value = (core.videoCaptureEnabled() || core.videoPreviewEnabled()) &&
|
||||
((currentCall != null && !currentCall.mediaInProgress()) ||
|
||||
core.conference?.isIn == true)
|
||||
(
|
||||
(currentCall != null && !currentCall.mediaInProgress()) ||
|
||||
core.conference?.isIn == true
|
||||
)
|
||||
}
|
||||
|
||||
private fun updateVideoEnabled() {
|
||||
|
|
|
@ -62,8 +62,8 @@ class IncomingCallViewModel(call: Call) : CallViewModel(call) {
|
|||
screenLocked.value = false
|
||||
inviteWithVideo.value = call.remoteParams?.videoEnabled() == true && coreContext.core.videoActivationPolicy.automaticallyAccept
|
||||
earlyMediaVideoEnabled.value = corePreferences.acceptEarlyMedia &&
|
||||
call.state == Call.State.IncomingEarlyMedia &&
|
||||
call.currentParams.videoEnabled()
|
||||
call.state == Call.State.IncomingEarlyMedia &&
|
||||
call.currentParams.videoEnabled()
|
||||
}
|
||||
|
||||
override fun onCleared() {
|
||||
|
|
|
@ -73,7 +73,8 @@ class ChatBubbleActivity : GenericActivity() {
|
|||
val localAddress = Factory.instance().createAddress(localSipUri)
|
||||
val remoteSipAddress = Factory.instance().createAddress(remoteSipUri)
|
||||
chatRoom = coreContext.core.searchChatRoom(
|
||||
null, localAddress, remoteSipAddress, arrayOfNulls(
|
||||
null, localAddress, remoteSipAddress,
|
||||
arrayOfNulls(
|
||||
0
|
||||
)
|
||||
)
|
||||
|
@ -114,27 +115,36 @@ class ChatBubbleActivity : GenericActivity() {
|
|||
// Disable context menu on each message
|
||||
adapter.disableContextMenu()
|
||||
|
||||
adapter.openContentEvent.observe(this, {
|
||||
it.consume { content ->
|
||||
if (content.isFileEncrypted) {
|
||||
Toast.makeText(this, R.string.chat_bubble_cant_open_enrypted_file, Toast.LENGTH_LONG).show()
|
||||
} else {
|
||||
FileUtils.openFileInThirdPartyApp(this, content.filePath.orEmpty(), true)
|
||||
adapter.openContentEvent.observe(
|
||||
this,
|
||||
{
|
||||
it.consume { content ->
|
||||
if (content.isFileEncrypted) {
|
||||
Toast.makeText(this, R.string.chat_bubble_cant_open_enrypted_file, Toast.LENGTH_LONG).show()
|
||||
} else {
|
||||
FileUtils.openFileInThirdPartyApp(this, content.filePath.orEmpty(), true)
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
)
|
||||
|
||||
val layoutManager = LinearLayoutManager(this)
|
||||
layoutManager.stackFromEnd = true
|
||||
binding.chatMessagesList.layoutManager = layoutManager
|
||||
|
||||
listViewModel.events.observe(this, { events ->
|
||||
adapter.submitList(events)
|
||||
})
|
||||
listViewModel.events.observe(
|
||||
this,
|
||||
{ events ->
|
||||
adapter.submitList(events)
|
||||
}
|
||||
)
|
||||
|
||||
chatSendingViewModel.textToSend.observe(this, {
|
||||
chatSendingViewModel.onTextToSendChanged(it)
|
||||
})
|
||||
chatSendingViewModel.textToSend.observe(
|
||||
this,
|
||||
{
|
||||
chatSendingViewModel.onTextToSendChanged(it)
|
||||
}
|
||||
)
|
||||
|
||||
binding.setOpenAppClickListener {
|
||||
val intent = Intent(this, MainActivity::class.java)
|
||||
|
|
|
@ -121,21 +121,27 @@ class MainActivity : GenericActivity(), SnackBarActivity, NavController.OnDestin
|
|||
callOverlayViewModel = ViewModelProvider(this).get(CallOverlayViewModel::class.java)
|
||||
binding.callOverlayViewModel = callOverlayViewModel
|
||||
|
||||
sharedViewModel.toggleDrawerEvent.observe(this, {
|
||||
it.consume {
|
||||
if (binding.sideMenu.isDrawerOpen(Gravity.LEFT)) {
|
||||
binding.sideMenu.closeDrawer(binding.sideMenuContent, true)
|
||||
} else {
|
||||
binding.sideMenu.openDrawer(binding.sideMenuContent, true)
|
||||
sharedViewModel.toggleDrawerEvent.observe(
|
||||
this,
|
||||
{
|
||||
it.consume {
|
||||
if (binding.sideMenu.isDrawerOpen(Gravity.LEFT)) {
|
||||
binding.sideMenu.closeDrawer(binding.sideMenuContent, true)
|
||||
} else {
|
||||
binding.sideMenu.openDrawer(binding.sideMenuContent, true)
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
)
|
||||
|
||||
coreContext.callErrorMessageResourceId.observe(this, {
|
||||
it.consume { message ->
|
||||
showSnackBar(message)
|
||||
coreContext.callErrorMessageResourceId.observe(
|
||||
this,
|
||||
{
|
||||
it.consume { message ->
|
||||
showSnackBar(message)
|
||||
}
|
||||
}
|
||||
})
|
||||
)
|
||||
|
||||
if (coreContext.core.accountList.isEmpty()) {
|
||||
if (corePreferences.firstStart) {
|
||||
|
@ -486,7 +492,8 @@ class MainActivity : GenericActivity(), SnackBarActivity, NavController.OnDestin
|
|||
}
|
||||
MotionEvent.ACTION_UP -> {
|
||||
if (abs(initPosX - view.x) < CorePreferences.OVERLAY_CLICK_SENSITIVITY &&
|
||||
abs(initPosY - view.y) < CorePreferences.OVERLAY_CLICK_SENSITIVITY) {
|
||||
abs(initPosY - view.y) < CorePreferences.OVERLAY_CLICK_SENSITIVITY
|
||||
) {
|
||||
view.performClick()
|
||||
}
|
||||
}
|
||||
|
|
|
@ -153,9 +153,12 @@ class ChatMessagesListAdapter(
|
|||
|
||||
// This is for item selection through ListTopBarFragment
|
||||
selectionListViewModel = selectionViewModel
|
||||
selectionViewModel.isEditionEnabled.observe(viewLifecycleOwner, {
|
||||
position = adapterPosition
|
||||
})
|
||||
selectionViewModel.isEditionEnabled.observe(
|
||||
viewLifecycleOwner,
|
||||
{
|
||||
position = adapterPosition
|
||||
}
|
||||
)
|
||||
|
||||
setClickListener {
|
||||
if (selectionViewModel.isEditionEnabled.value == true) {
|
||||
|
@ -213,7 +216,8 @@ class ChatMessagesListAdapter(
|
|||
val itemSize = AppUtils.getDimension(R.dimen.chat_message_popup_item_height).toInt()
|
||||
var totalSize = itemSize * 7
|
||||
if (chatMessage.chatRoom.hasCapability(ChatRoomCapabilities.OneToOne.toInt()) ||
|
||||
chatMessage.state == ChatMessage.State.NotDelivered) { // No message id
|
||||
chatMessage.state == ChatMessage.State.NotDelivered
|
||||
) { // No message id
|
||||
popupView.imdnHidden = true
|
||||
totalSize -= itemSize
|
||||
}
|
||||
|
@ -236,7 +240,8 @@ class ChatMessagesListAdapter(
|
|||
|
||||
// When using WRAP_CONTENT instead of real size, fails to place the
|
||||
// popup window above if not enough space is available below
|
||||
val popupWindow = PopupWindow(popupView.root,
|
||||
val popupWindow = PopupWindow(
|
||||
popupView.root,
|
||||
AppUtils.getDimension(R.dimen.chat_message_popup_width).toInt(),
|
||||
totalSize,
|
||||
true
|
||||
|
@ -354,9 +359,12 @@ class ChatMessagesListAdapter(
|
|||
|
||||
// This is for item selection through ListTopBarFragment
|
||||
selectionListViewModel = selectionViewModel
|
||||
selectionViewModel.isEditionEnabled.observe(viewLifecycleOwner, {
|
||||
position = adapterPosition
|
||||
})
|
||||
selectionViewModel.isEditionEnabled.observe(
|
||||
viewLifecycleOwner,
|
||||
{
|
||||
position = adapterPosition
|
||||
}
|
||||
)
|
||||
|
||||
binding.setClickListener {
|
||||
if (selectionViewModel.isEditionEnabled.value == true) {
|
||||
|
@ -376,9 +384,10 @@ private class ChatMessageDiffCallback : DiffUtil.ItemCallback<EventLogData>() {
|
|||
newItem: EventLogData
|
||||
): Boolean {
|
||||
return if (oldItem.eventLog.type == EventLog.Type.ConferenceChatMessage &&
|
||||
newItem.eventLog.type == EventLog.Type.ConferenceChatMessage) {
|
||||
newItem.eventLog.type == EventLog.Type.ConferenceChatMessage
|
||||
) {
|
||||
oldItem.eventLog.chatMessage?.time == newItem.eventLog.chatMessage?.time &&
|
||||
oldItem.eventLog.chatMessage?.isOutgoing == newItem.eventLog.chatMessage?.isOutgoing
|
||||
oldItem.eventLog.chatMessage?.isOutgoing == newItem.eventLog.chatMessage?.isOutgoing
|
||||
} else oldItem.eventLog.notifyId == newItem.eventLog.notifyId
|
||||
}
|
||||
|
||||
|
|
|
@ -72,9 +72,12 @@ class ChatRoomsListAdapter(
|
|||
|
||||
// This is for item selection through ListTopBarFragment
|
||||
selectionListViewModel = selectionViewModel
|
||||
selectionViewModel.isEditionEnabled.observe(viewLifecycleOwner, {
|
||||
position = adapterPosition
|
||||
})
|
||||
selectionViewModel.isEditionEnabled.observe(
|
||||
viewLifecycleOwner,
|
||||
{
|
||||
position = adapterPosition
|
||||
}
|
||||
)
|
||||
|
||||
forwardPending = isForwardPending
|
||||
|
||||
|
|
|
@ -47,7 +47,7 @@ class ChatMessageContentData(
|
|||
|
||||
) {
|
||||
var listener: OnContentClickedListener? = null
|
||||
|
||||
|
||||
val isOutgoing = chatMessage.isOutgoing
|
||||
|
||||
val isImage = MutableLiveData<Boolean>()
|
||||
|
@ -214,7 +214,7 @@ class ChatMessageContentData(
|
|||
isVoiceRecording.value = isVoiceRecord
|
||||
|
||||
if (isVoiceRecord) {
|
||||
val duration = content.fileDuration// duration is in ms
|
||||
val duration = content.fileDuration // duration is in ms
|
||||
voiceRecordDuration.value = duration
|
||||
formattedDuration.value = SimpleDateFormat("mm:ss", Locale.getDefault()).format(duration)
|
||||
Log.i("[Voice Recording] Duration is ${voiceRecordDuration.value} ($duration)")
|
||||
|
|
|
@ -35,7 +35,8 @@ class EventData(private val eventLog: EventLog) : GenericContactData(
|
|||
} else {
|
||||
eventLog.participantAddress!!
|
||||
}
|
||||
}) {
|
||||
}
|
||||
) {
|
||||
val text = MutableLiveData<String>()
|
||||
|
||||
val isSecurity: Boolean by lazy {
|
||||
|
|
|
@ -90,42 +90,63 @@ class ChatRoomCreationFragment : SecureFragment<ChatRoomCreationFragmentBinding>
|
|||
viewModel.sipContactsSelected.value = true
|
||||
}
|
||||
|
||||
viewModel.contactsList.observe(viewLifecycleOwner, {
|
||||
adapter.submitList(it)
|
||||
})
|
||||
|
||||
viewModel.isEncrypted.observe(viewLifecycleOwner, {
|
||||
adapter.updateSecurity(it)
|
||||
})
|
||||
|
||||
viewModel.sipContactsSelected.observe(viewLifecycleOwner, {
|
||||
viewModel.updateContactsList()
|
||||
})
|
||||
|
||||
viewModel.selectedAddresses.observe(viewLifecycleOwner, {
|
||||
adapter.updateSelectedAddresses(it)
|
||||
})
|
||||
|
||||
viewModel.chatRoomCreatedEvent.observe(viewLifecycleOwner, {
|
||||
it.consume { chatRoom ->
|
||||
sharedViewModel.selectedChatRoom.value = chatRoom
|
||||
navigateToChatRoom(AppUtils.createBundleWithSharedTextAndFiles(sharedViewModel))
|
||||
viewModel.contactsList.observe(
|
||||
viewLifecycleOwner,
|
||||
{
|
||||
adapter.submitList(it)
|
||||
}
|
||||
})
|
||||
)
|
||||
|
||||
viewModel.filter.observe(viewLifecycleOwner, {
|
||||
viewModel.applyFilter()
|
||||
})
|
||||
viewModel.isEncrypted.observe(
|
||||
viewLifecycleOwner,
|
||||
{
|
||||
adapter.updateSecurity(it)
|
||||
}
|
||||
)
|
||||
|
||||
adapter.selectedContact.observe(viewLifecycleOwner, {
|
||||
it.consume { searchResult ->
|
||||
if (createGroup) {
|
||||
viewModel.toggleSelectionForSearchResult(searchResult)
|
||||
} else {
|
||||
viewModel.createOneToOneChat(searchResult)
|
||||
viewModel.sipContactsSelected.observe(
|
||||
viewLifecycleOwner,
|
||||
{
|
||||
viewModel.updateContactsList()
|
||||
}
|
||||
)
|
||||
|
||||
viewModel.selectedAddresses.observe(
|
||||
viewLifecycleOwner,
|
||||
{
|
||||
adapter.updateSelectedAddresses(it)
|
||||
}
|
||||
)
|
||||
|
||||
viewModel.chatRoomCreatedEvent.observe(
|
||||
viewLifecycleOwner,
|
||||
{
|
||||
it.consume { chatRoom ->
|
||||
sharedViewModel.selectedChatRoom.value = chatRoom
|
||||
navigateToChatRoom(AppUtils.createBundleWithSharedTextAndFiles(sharedViewModel))
|
||||
}
|
||||
}
|
||||
})
|
||||
)
|
||||
|
||||
viewModel.filter.observe(
|
||||
viewLifecycleOwner,
|
||||
{
|
||||
viewModel.applyFilter()
|
||||
}
|
||||
)
|
||||
|
||||
adapter.selectedContact.observe(
|
||||
viewLifecycleOwner,
|
||||
{
|
||||
it.consume { searchResult ->
|
||||
if (createGroup) {
|
||||
viewModel.toggleSelectionForSearchResult(searchResult)
|
||||
} else {
|
||||
viewModel.createOneToOneChat(searchResult)
|
||||
}
|
||||
}
|
||||
}
|
||||
)
|
||||
|
||||
addParticipantsFromSharedViewModel()
|
||||
|
||||
|
@ -136,11 +157,14 @@ class ChatRoomCreationFragment : SecureFragment<ChatRoomCreationFragmentBinding>
|
|||
navigateToGroupInfo()
|
||||
}
|
||||
|
||||
viewModel.onErrorEvent.observe(viewLifecycleOwner, {
|
||||
it.consume { messageResourceId ->
|
||||
(activity as MainActivity).showSnackBar(messageResourceId)
|
||||
viewModel.onErrorEvent.observe(
|
||||
viewLifecycleOwner,
|
||||
{
|
||||
it.consume { messageResourceId ->
|
||||
(activity as MainActivity).showSnackBar(messageResourceId)
|
||||
}
|
||||
}
|
||||
})
|
||||
)
|
||||
|
||||
if (!PermissionHelper.get().hasReadContactsPermission()) {
|
||||
Log.i("[Chat Room Creation] Asking for READ_CONTACTS permission")
|
||||
|
|
|
@ -115,7 +115,8 @@ class DetailChatRoomFragment : MasterFragment<ChatRoomDetailFragmentBinding, Cha
|
|||
val localAddress = Factory.instance().createAddress(localSipUri)
|
||||
val remoteSipAddress = Factory.instance().createAddress(remoteSipUri)
|
||||
sharedViewModel.selectedChatRoom.value = coreContext.core.searchChatRoom(
|
||||
null, localAddress, remoteSipAddress, arrayOfNulls(
|
||||
null, localAddress, remoteSipAddress,
|
||||
arrayOfNulls(
|
||||
0
|
||||
)
|
||||
)
|
||||
|
@ -189,146 +190,185 @@ class DetailChatRoomFragment : MasterFragment<ChatRoomDetailFragmentBinding, Cha
|
|||
}
|
||||
binding.chatMessagesList.addOnScrollListener(chatScrollListener)
|
||||
|
||||
chatSendingViewModel.textToSend.observe(viewLifecycleOwner, {
|
||||
chatSendingViewModel.onTextToSendChanged(it)
|
||||
})
|
||||
|
||||
chatSendingViewModel.requestRecordAudioPermissionEvent.observe(viewLifecycleOwner, {
|
||||
it.consume {
|
||||
Log.i("[Chat Room] Asking for RECORD_AUDIO permission")
|
||||
requestPermissions(arrayOf(android.Manifest.permission.RECORD_AUDIO), 2)
|
||||
chatSendingViewModel.textToSend.observe(
|
||||
viewLifecycleOwner,
|
||||
{
|
||||
chatSendingViewModel.onTextToSendChanged(it)
|
||||
}
|
||||
})
|
||||
)
|
||||
|
||||
listViewModel.events.observe(viewLifecycleOwner, { events ->
|
||||
adapter.submitList(events)
|
||||
})
|
||||
|
||||
listViewModel.messageUpdatedEvent.observe(viewLifecycleOwner, {
|
||||
it.consume { position ->
|
||||
adapter.notifyItemChanged(position)
|
||||
}
|
||||
})
|
||||
|
||||
listViewModel.requestWriteExternalStoragePermissionEvent.observe(viewLifecycleOwner, {
|
||||
it.consume {
|
||||
requestPermissions(arrayOf(android.Manifest.permission.WRITE_EXTERNAL_STORAGE), 1)
|
||||
}
|
||||
})
|
||||
|
||||
adapter.deleteMessageEvent.observe(viewLifecycleOwner, {
|
||||
it.consume { chatMessage ->
|
||||
listViewModel.deleteMessage(chatMessage)
|
||||
}
|
||||
})
|
||||
|
||||
adapter.resendMessageEvent.observe(viewLifecycleOwner, {
|
||||
it.consume { chatMessage ->
|
||||
listViewModel.resendMessage(chatMessage)
|
||||
}
|
||||
})
|
||||
|
||||
adapter.forwardMessageEvent.observe(viewLifecycleOwner, {
|
||||
it.consume { chatMessage ->
|
||||
// Remove observer before setting the message to forward
|
||||
// as we don't want to forward it in this chat room
|
||||
sharedViewModel.messageToForwardEvent.removeObservers(viewLifecycleOwner)
|
||||
sharedViewModel.messageToForwardEvent.value = Event(chatMessage)
|
||||
sharedViewModel.isPendingMessageForward.value = true
|
||||
|
||||
if (sharedViewModel.canSlidingPaneBeClosed.value == true) {
|
||||
Log.i("[Chat Room] Forwarding message, going to chat rooms list")
|
||||
sharedViewModel.closeSlidingPaneEvent.value = Event(true)
|
||||
chatSendingViewModel.requestRecordAudioPermissionEvent.observe(
|
||||
viewLifecycleOwner,
|
||||
{
|
||||
it.consume {
|
||||
Log.i("[Chat Room] Asking for RECORD_AUDIO permission")
|
||||
requestPermissions(arrayOf(android.Manifest.permission.RECORD_AUDIO), 2)
|
||||
}
|
||||
}
|
||||
})
|
||||
)
|
||||
|
||||
adapter.replyMessageEvent.observe(viewLifecycleOwner, {
|
||||
it.consume { chatMessage ->
|
||||
chatSendingViewModel.pendingChatMessageToReplyTo.value?.destroy()
|
||||
chatSendingViewModel.pendingChatMessageToReplyTo.value = ChatMessageData(chatMessage)
|
||||
chatSendingViewModel.isPendingAnswer.value = true
|
||||
listViewModel.events.observe(
|
||||
viewLifecycleOwner,
|
||||
{ events ->
|
||||
adapter.submitList(events)
|
||||
}
|
||||
})
|
||||
)
|
||||
|
||||
adapter.showImdnForMessageEvent.observe(viewLifecycleOwner, {
|
||||
it.consume { chatMessage ->
|
||||
val args = Bundle()
|
||||
args.putString("MessageId", chatMessage.messageId)
|
||||
navigateToImdn(args)
|
||||
listViewModel.messageUpdatedEvent.observe(
|
||||
viewLifecycleOwner,
|
||||
{
|
||||
it.consume { position ->
|
||||
adapter.notifyItemChanged(position)
|
||||
}
|
||||
}
|
||||
})
|
||||
)
|
||||
|
||||
adapter.addSipUriToContactEvent.observe(viewLifecycleOwner, {
|
||||
it.consume { sipUri ->
|
||||
Log.i("[Chat Room] Going to contacts list with SIP URI to add: $sipUri")
|
||||
navigateToContacts(sipUri)
|
||||
listViewModel.requestWriteExternalStoragePermissionEvent.observe(
|
||||
viewLifecycleOwner,
|
||||
{
|
||||
it.consume {
|
||||
requestPermissions(arrayOf(android.Manifest.permission.WRITE_EXTERNAL_STORAGE), 1)
|
||||
}
|
||||
}
|
||||
})
|
||||
)
|
||||
|
||||
adapter.openContentEvent.observe(viewLifecycleOwner, {
|
||||
it.consume { content ->
|
||||
val path = content.filePath.orEmpty()
|
||||
adapter.deleteMessageEvent.observe(
|
||||
viewLifecycleOwner,
|
||||
{
|
||||
it.consume { chatMessage ->
|
||||
listViewModel.deleteMessage(chatMessage)
|
||||
}
|
||||
}
|
||||
)
|
||||
|
||||
if (!File(path).exists()) {
|
||||
(requireActivity() as MainActivity).showSnackBar(R.string.chat_room_file_not_found)
|
||||
} else {
|
||||
Log.i("[Chat Message] Opening file: $path")
|
||||
sharedViewModel.contentToOpen.value = content
|
||||
adapter.resendMessageEvent.observe(
|
||||
viewLifecycleOwner,
|
||||
{
|
||||
it.consume { chatMessage ->
|
||||
listViewModel.resendMessage(chatMessage)
|
||||
}
|
||||
}
|
||||
)
|
||||
|
||||
if (corePreferences.useInAppFileViewerForNonEncryptedFiles || content.isFileEncrypted) {
|
||||
val preventScreenshots =
|
||||
viewModel.chatRoom.currentParams.encryptionEnabled()
|
||||
when {
|
||||
FileUtils.isExtensionImage(path) -> navigateToImageFileViewer(
|
||||
preventScreenshots
|
||||
)
|
||||
FileUtils.isExtensionVideo(path) -> navigateToVideoFileViewer(
|
||||
preventScreenshots
|
||||
)
|
||||
FileUtils.isExtensionAudio(path) -> navigateToAudioFileViewer(
|
||||
preventScreenshots
|
||||
)
|
||||
FileUtils.isExtensionPdf(path) -> navigateToPdfFileViewer(
|
||||
preventScreenshots
|
||||
)
|
||||
FileUtils.isPlainTextFile(path) -> navigateToTextFileViewer(
|
||||
preventScreenshots
|
||||
)
|
||||
else -> {
|
||||
if (content.isFileEncrypted) {
|
||||
Log.w("[Chat Message] File is encrypted and can't be opened in one of our viewers...")
|
||||
showDialogForUserConsentBeforeExportingFileInThirdPartyApp(content)
|
||||
} else if (!FileUtils.openFileInThirdPartyApp(requireActivity(), path)) {
|
||||
showDialogToSuggestOpeningFileAsText()
|
||||
adapter.forwardMessageEvent.observe(
|
||||
viewLifecycleOwner,
|
||||
{
|
||||
it.consume { chatMessage ->
|
||||
// Remove observer before setting the message to forward
|
||||
// as we don't want to forward it in this chat room
|
||||
sharedViewModel.messageToForwardEvent.removeObservers(viewLifecycleOwner)
|
||||
sharedViewModel.messageToForwardEvent.value = Event(chatMessage)
|
||||
sharedViewModel.isPendingMessageForward.value = true
|
||||
|
||||
if (sharedViewModel.canSlidingPaneBeClosed.value == true) {
|
||||
Log.i("[Chat Room] Forwarding message, going to chat rooms list")
|
||||
sharedViewModel.closeSlidingPaneEvent.value = Event(true)
|
||||
}
|
||||
}
|
||||
}
|
||||
)
|
||||
|
||||
adapter.replyMessageEvent.observe(
|
||||
viewLifecycleOwner,
|
||||
{
|
||||
it.consume { chatMessage ->
|
||||
chatSendingViewModel.pendingChatMessageToReplyTo.value?.destroy()
|
||||
chatSendingViewModel.pendingChatMessageToReplyTo.value = ChatMessageData(chatMessage)
|
||||
chatSendingViewModel.isPendingAnswer.value = true
|
||||
}
|
||||
}
|
||||
)
|
||||
|
||||
adapter.showImdnForMessageEvent.observe(
|
||||
viewLifecycleOwner,
|
||||
{
|
||||
it.consume { chatMessage ->
|
||||
val args = Bundle()
|
||||
args.putString("MessageId", chatMessage.messageId)
|
||||
navigateToImdn(args)
|
||||
}
|
||||
}
|
||||
)
|
||||
|
||||
adapter.addSipUriToContactEvent.observe(
|
||||
viewLifecycleOwner,
|
||||
{
|
||||
it.consume { sipUri ->
|
||||
Log.i("[Chat Room] Going to contacts list with SIP URI to add: $sipUri")
|
||||
navigateToContacts(sipUri)
|
||||
}
|
||||
}
|
||||
)
|
||||
|
||||
adapter.openContentEvent.observe(
|
||||
viewLifecycleOwner,
|
||||
{
|
||||
it.consume { content ->
|
||||
val path = content.filePath.orEmpty()
|
||||
|
||||
if (!File(path).exists()) {
|
||||
(requireActivity() as MainActivity).showSnackBar(R.string.chat_room_file_not_found)
|
||||
} else {
|
||||
Log.i("[Chat Message] Opening file: $path")
|
||||
sharedViewModel.contentToOpen.value = content
|
||||
|
||||
if (corePreferences.useInAppFileViewerForNonEncryptedFiles || content.isFileEncrypted) {
|
||||
val preventScreenshots =
|
||||
viewModel.chatRoom.currentParams.encryptionEnabled()
|
||||
when {
|
||||
FileUtils.isExtensionImage(path) -> navigateToImageFileViewer(
|
||||
preventScreenshots
|
||||
)
|
||||
FileUtils.isExtensionVideo(path) -> navigateToVideoFileViewer(
|
||||
preventScreenshots
|
||||
)
|
||||
FileUtils.isExtensionAudio(path) -> navigateToAudioFileViewer(
|
||||
preventScreenshots
|
||||
)
|
||||
FileUtils.isExtensionPdf(path) -> navigateToPdfFileViewer(
|
||||
preventScreenshots
|
||||
)
|
||||
FileUtils.isPlainTextFile(path) -> navigateToTextFileViewer(
|
||||
preventScreenshots
|
||||
)
|
||||
else -> {
|
||||
if (content.isFileEncrypted) {
|
||||
Log.w("[Chat Message] File is encrypted and can't be opened in one of our viewers...")
|
||||
showDialogForUserConsentBeforeExportingFileInThirdPartyApp(content)
|
||||
} else if (!FileUtils.openFileInThirdPartyApp(requireActivity(), path)) {
|
||||
showDialogToSuggestOpeningFileAsText()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (!FileUtils.openFileInThirdPartyApp(requireActivity(), path)) {
|
||||
showDialogToSuggestOpeningFileAsText()
|
||||
} else {
|
||||
if (!FileUtils.openFileInThirdPartyApp(requireActivity(), path)) {
|
||||
showDialogToSuggestOpeningFileAsText()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
)
|
||||
|
||||
adapter.scrollToChatMessageEvent.observe(viewLifecycleOwner, {
|
||||
it.consume { chatMessage ->
|
||||
val events = listViewModel.events.value.orEmpty()
|
||||
val eventLog = events.find { eventLog ->
|
||||
if (eventLog.eventLog.type == EventLog.Type.ConferenceChatMessage) {
|
||||
(eventLog.data as ChatMessageData).chatMessage.messageId == chatMessage.messageId
|
||||
} else false
|
||||
}
|
||||
val index = events.indexOf(eventLog)
|
||||
try {
|
||||
binding.chatMessagesList.smoothScrollToPosition(index)
|
||||
} catch (iae: IllegalArgumentException) {
|
||||
Log.e("[Chat Room] Can't scroll to position $index")
|
||||
adapter.scrollToChatMessageEvent.observe(
|
||||
viewLifecycleOwner,
|
||||
{
|
||||
it.consume { chatMessage ->
|
||||
val events = listViewModel.events.value.orEmpty()
|
||||
val eventLog = events.find { eventLog ->
|
||||
if (eventLog.eventLog.type == EventLog.Type.ConferenceChatMessage) {
|
||||
(eventLog.data as ChatMessageData).chatMessage.messageId == chatMessage.messageId
|
||||
} else false
|
||||
}
|
||||
val index = events.indexOf(eventLog)
|
||||
try {
|
||||
binding.chatMessagesList.smoothScrollToPosition(index)
|
||||
} catch (iae: IllegalArgumentException) {
|
||||
Log.e("[Chat Room] Can't scroll to position $index")
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
)
|
||||
|
||||
binding.setBackClickListener {
|
||||
goBack()
|
||||
|
@ -336,7 +376,8 @@ class DetailChatRoomFragment : MasterFragment<ChatRoomDetailFragmentBinding, Cha
|
|||
|
||||
binding.setTitleClickListener {
|
||||
binding.sipUri.visibility = if (!viewModel.oneToOneChatRoom ||
|
||||
binding.sipUri.visibility == View.VISIBLE) View.GONE else View.VISIBLE
|
||||
binding.sipUri.visibility == View.VISIBLE
|
||||
) View.GONE else View.VISIBLE
|
||||
}
|
||||
|
||||
binding.setMenuClickListener {
|
||||
|
@ -360,7 +401,8 @@ class DetailChatRoomFragment : MasterFragment<ChatRoomDetailFragmentBinding, Cha
|
|||
arrayOf(
|
||||
android.Manifest.permission.READ_EXTERNAL_STORAGE,
|
||||
android.Manifest.permission.CAMERA
|
||||
), 0
|
||||
),
|
||||
0
|
||||
)
|
||||
}
|
||||
}
|
||||
|
@ -400,13 +442,16 @@ class DetailChatRoomFragment : MasterFragment<ChatRoomDetailFragmentBinding, Cha
|
|||
}
|
||||
}
|
||||
|
||||
sharedViewModel.messageToForwardEvent.observe(viewLifecycleOwner, {
|
||||
it.consume { chatMessage ->
|
||||
Log.i("[Chat Room] Found message to transfer")
|
||||
showForwardConfirmationDialog(chatMessage)
|
||||
sharedViewModel.isPendingMessageForward.value = false
|
||||
sharedViewModel.messageToForwardEvent.observe(
|
||||
viewLifecycleOwner,
|
||||
{
|
||||
it.consume { chatMessage ->
|
||||
Log.i("[Chat Room] Found message to transfer")
|
||||
showForwardConfirmationDialog(chatMessage)
|
||||
sharedViewModel.isPendingMessageForward.value = false
|
||||
}
|
||||
}
|
||||
})
|
||||
)
|
||||
}
|
||||
|
||||
override fun deleteItems(indexesOfItemToDelete: ArrayList<Int>) {
|
||||
|
@ -464,10 +509,12 @@ class DetailChatRoomFragment : MasterFragment<ChatRoomDetailFragmentBinding, Cha
|
|||
override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
|
||||
if (resultCode == Activity.RESULT_OK) {
|
||||
lifecycleScope.launch {
|
||||
for (fileToUploadPath in FileUtils.getFilesPathFromPickerIntent(
|
||||
data,
|
||||
chatSendingViewModel.temporaryFileUploadPath
|
||||
)) {
|
||||
for (
|
||||
fileToUploadPath in FileUtils.getFilesPathFromPickerIntent(
|
||||
data,
|
||||
chatSendingViewModel.temporaryFileUploadPath
|
||||
)
|
||||
) {
|
||||
chatSendingViewModel.addAttachment(fileToUploadPath)
|
||||
}
|
||||
}
|
||||
|
@ -502,20 +549,23 @@ class DetailChatRoomFragment : MasterFragment<ChatRoomDetailFragmentBinding, Cha
|
|||
val okLabel = if (viewModel.oneParticipantOneDevice) getString(R.string.dialog_call) else getString(
|
||||
R.string.dialog_ok
|
||||
)
|
||||
dialogViewModel.showOkButton({ doNotAskAgain ->
|
||||
if (doNotAskAgain) corePreferences.limeSecurityPopupEnabled = false
|
||||
dialogViewModel.showOkButton(
|
||||
{ doNotAskAgain ->
|
||||
if (doNotAskAgain) corePreferences.limeSecurityPopupEnabled = false
|
||||
|
||||
val address = viewModel.onlyParticipantOnlyDeviceAddress
|
||||
if (viewModel.oneParticipantOneDevice) {
|
||||
if (address != null) {
|
||||
coreContext.startCall(address, true)
|
||||
val address = viewModel.onlyParticipantOnlyDeviceAddress
|
||||
if (viewModel.oneParticipantOneDevice) {
|
||||
if (address != null) {
|
||||
coreContext.startCall(address, true)
|
||||
}
|
||||
} else {
|
||||
navigateToDevices()
|
||||
}
|
||||
} else {
|
||||
navigateToDevices()
|
||||
}
|
||||
|
||||
dialog.dismiss()
|
||||
}, okLabel)
|
||||
dialog.dismiss()
|
||||
},
|
||||
okLabel
|
||||
)
|
||||
|
||||
dialog.show()
|
||||
} else {
|
||||
|
@ -551,11 +601,14 @@ class DetailChatRoomFragment : MasterFragment<ChatRoomDetailFragmentBinding, Cha
|
|||
dialog.dismiss()
|
||||
}
|
||||
|
||||
viewModel.showOkButton({
|
||||
Log.i("[Chat Room] Transfer confirmed")
|
||||
chatSendingViewModel.transferMessage(chatMessage)
|
||||
dialog.dismiss()
|
||||
}, getString(R.string.chat_message_context_menu_forward))
|
||||
viewModel.showOkButton(
|
||||
{
|
||||
Log.i("[Chat Room] Transfer confirmed")
|
||||
chatSendingViewModel.transferMessage(chatMessage)
|
||||
dialog.dismiss()
|
||||
},
|
||||
getString(R.string.chat_message_context_menu_forward)
|
||||
)
|
||||
|
||||
dialog.show()
|
||||
}
|
||||
|
@ -679,25 +732,31 @@ class DetailChatRoomFragment : MasterFragment<ChatRoomDetailFragmentBinding, Cha
|
|||
)
|
||||
val dialog = DialogUtils.getDialog(requireContext(), dialogViewModel)
|
||||
|
||||
dialogViewModel.showDeleteButton({
|
||||
dialog.dismiss()
|
||||
lifecycleScope.launch {
|
||||
val plainFilePath = content.plainFilePath
|
||||
Log.i("[Cht Room] Making a copy of [$plainFilePath] to the cache directory before exporting it")
|
||||
val cacheCopyPath = FileUtils.copyFileToCache(plainFilePath)
|
||||
if (cacheCopyPath != null) {
|
||||
Log.i("[Cht Room] Cache copy has been made: $cacheCopyPath")
|
||||
if (!FileUtils.openFileInThirdPartyApp(requireActivity(), cacheCopyPath)) {
|
||||
showDialogToSuggestOpeningFileAsText()
|
||||
dialogViewModel.showDeleteButton(
|
||||
{
|
||||
dialog.dismiss()
|
||||
lifecycleScope.launch {
|
||||
val plainFilePath = content.plainFilePath
|
||||
Log.i("[Cht Room] Making a copy of [$plainFilePath] to the cache directory before exporting it")
|
||||
val cacheCopyPath = FileUtils.copyFileToCache(plainFilePath)
|
||||
if (cacheCopyPath != null) {
|
||||
Log.i("[Cht Room] Cache copy has been made: $cacheCopyPath")
|
||||
if (!FileUtils.openFileInThirdPartyApp(requireActivity(), cacheCopyPath)) {
|
||||
showDialogToSuggestOpeningFileAsText()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}, getString(R.string.chat_message_cant_open_file_in_app_dialog_export_button))
|
||||
},
|
||||
getString(R.string.chat_message_cant_open_file_in_app_dialog_export_button)
|
||||
)
|
||||
|
||||
dialogViewModel.showOkButton({
|
||||
dialog.dismiss()
|
||||
navigateToTextFileViewer(true)
|
||||
}, getString(R.string.chat_message_cant_open_file_in_app_dialog_open_as_text_button))
|
||||
dialogViewModel.showOkButton(
|
||||
{
|
||||
dialog.dismiss()
|
||||
navigateToTextFileViewer(true)
|
||||
},
|
||||
getString(R.string.chat_message_cant_open_file_in_app_dialog_open_as_text_button)
|
||||
)
|
||||
|
||||
dialogViewModel.showCancelButton {
|
||||
dialog.dismiss()
|
||||
|
|
|
@ -74,7 +74,7 @@ class GroupInfoFragment : SecureFragment<ChatRoomGroupInfoFragmentBinding>() {
|
|||
adapter = GroupInfoParticipantsAdapter(
|
||||
viewLifecycleOwner,
|
||||
chatRoom?.hasCapability(ChatRoomCapabilities.Encrypted.toInt()) ?: viewModel.isEncrypted.value == true
|
||||
)
|
||||
)
|
||||
binding.participants.adapter = adapter
|
||||
|
||||
val layoutManager = LinearLayoutManager(activity)
|
||||
|
@ -83,25 +83,37 @@ class GroupInfoFragment : SecureFragment<ChatRoomGroupInfoFragmentBinding>() {
|
|||
// Divider between items
|
||||
binding.participants.addItemDecoration(AppUtils.getDividerDecoration(requireContext(), layoutManager))
|
||||
|
||||
viewModel.participants.observe(viewLifecycleOwner, {
|
||||
adapter.submitList(it)
|
||||
})
|
||||
|
||||
viewModel.isMeAdmin.observe(viewLifecycleOwner, { isMeAdmin ->
|
||||
adapter.showAdminControls(isMeAdmin && chatRoom != null)
|
||||
})
|
||||
|
||||
viewModel.meAdminChangedEvent.observe(viewLifecycleOwner, {
|
||||
it.consume { isMeAdmin ->
|
||||
showMeAdminStateChanged(isMeAdmin)
|
||||
viewModel.participants.observe(
|
||||
viewLifecycleOwner,
|
||||
{
|
||||
adapter.submitList(it)
|
||||
}
|
||||
})
|
||||
)
|
||||
|
||||
adapter.participantRemovedEvent.observe(viewLifecycleOwner, {
|
||||
it.consume { participant ->
|
||||
viewModel.removeParticipant(participant)
|
||||
viewModel.isMeAdmin.observe(
|
||||
viewLifecycleOwner,
|
||||
{ isMeAdmin ->
|
||||
adapter.showAdminControls(isMeAdmin && chatRoom != null)
|
||||
}
|
||||
})
|
||||
)
|
||||
|
||||
viewModel.meAdminChangedEvent.observe(
|
||||
viewLifecycleOwner,
|
||||
{
|
||||
it.consume { isMeAdmin ->
|
||||
showMeAdminStateChanged(isMeAdmin)
|
||||
}
|
||||
}
|
||||
)
|
||||
|
||||
adapter.participantRemovedEvent.observe(
|
||||
viewLifecycleOwner,
|
||||
{
|
||||
it.consume { participant ->
|
||||
viewModel.removeParticipant(participant)
|
||||
}
|
||||
}
|
||||
)
|
||||
|
||||
addParticipantsFromSharedViewModel()
|
||||
|
||||
|
@ -109,12 +121,15 @@ class GroupInfoFragment : SecureFragment<ChatRoomGroupInfoFragmentBinding>() {
|
|||
goBack()
|
||||
}
|
||||
|
||||
viewModel.createdChatRoomEvent.observe(viewLifecycleOwner, {
|
||||
it.consume { chatRoom ->
|
||||
sharedViewModel.selectedChatRoom.value = chatRoom
|
||||
navigateToChatRoom(AppUtils.createBundleWithSharedTextAndFiles(sharedViewModel))
|
||||
viewModel.createdChatRoomEvent.observe(
|
||||
viewLifecycleOwner,
|
||||
{
|
||||
it.consume { chatRoom ->
|
||||
sharedViewModel.selectedChatRoom.value = chatRoom
|
||||
navigateToChatRoom(AppUtils.createBundleWithSharedTextAndFiles(sharedViewModel))
|
||||
}
|
||||
}
|
||||
})
|
||||
)
|
||||
|
||||
binding.setNextClickListener {
|
||||
if (viewModel.chatRoom != null) {
|
||||
|
@ -143,10 +158,13 @@ class GroupInfoFragment : SecureFragment<ChatRoomGroupInfoFragmentBinding>() {
|
|||
val dialogViewModel = DialogViewModel(getString(R.string.chat_room_group_info_leave_dialog_message))
|
||||
val dialog: Dialog = DialogUtils.getDialog(requireContext(), dialogViewModel)
|
||||
|
||||
dialogViewModel.showDeleteButton({
|
||||
viewModel.leaveGroup()
|
||||
dialog.dismiss()
|
||||
}, getString(R.string.chat_room_group_info_leave_dialog_button))
|
||||
dialogViewModel.showDeleteButton(
|
||||
{
|
||||
viewModel.leaveGroup()
|
||||
dialog.dismiss()
|
||||
},
|
||||
getString(R.string.chat_room_group_info_leave_dialog_button)
|
||||
)
|
||||
|
||||
dialogViewModel.showCancelButton {
|
||||
dialog.dismiss()
|
||||
|
@ -155,11 +173,14 @@ class GroupInfoFragment : SecureFragment<ChatRoomGroupInfoFragmentBinding>() {
|
|||
dialog.show()
|
||||
}
|
||||
|
||||
viewModel.onErrorEvent.observe(viewLifecycleOwner, {
|
||||
it.consume { messageResourceId ->
|
||||
(activity as MainActivity).showSnackBar(messageResourceId)
|
||||
viewModel.onErrorEvent.observe(
|
||||
viewLifecycleOwner,
|
||||
{
|
||||
it.consume { messageResourceId ->
|
||||
(activity as MainActivity).showSnackBar(messageResourceId)
|
||||
}
|
||||
}
|
||||
})
|
||||
)
|
||||
}
|
||||
|
||||
private fun addParticipantsFromSharedViewModel() {
|
||||
|
@ -175,9 +196,11 @@ class GroupInfoFragment : SecureFragment<ChatRoomGroupInfoFragmentBinding>() {
|
|||
if (exists != null) {
|
||||
list.add(exists)
|
||||
} else {
|
||||
list.add(GroupInfoParticipantData(
|
||||
GroupChatRoomMember(address, false, hasLimeX3DHCapability = viewModel.isEncrypted.value == true)
|
||||
))
|
||||
list.add(
|
||||
GroupInfoParticipantData(
|
||||
GroupChatRoomMember(address, false, hasLimeX3DHCapability = viewModel.isEncrypted.value == true)
|
||||
)
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -97,9 +97,12 @@ class ImdnFragment : SecureFragment<ChatRoomImdnFragmentBinding>() {
|
|||
val headerItemDecoration = RecyclerViewHeaderDecoration(requireContext(), adapter)
|
||||
binding.participantsList.addItemDecoration(headerItemDecoration)
|
||||
|
||||
viewModel.participants.observe(viewLifecycleOwner, {
|
||||
adapter.submitList(it)
|
||||
})
|
||||
viewModel.participants.observe(
|
||||
viewLifecycleOwner,
|
||||
{
|
||||
adapter.submitList(it)
|
||||
}
|
||||
)
|
||||
|
||||
binding.setBackClickListener {
|
||||
goBack()
|
||||
|
|
|
@ -92,25 +92,31 @@ class MasterChatRoomsFragment : MasterFragment<ChatRoomMasterFragmentBinding, Ch
|
|||
|
||||
view.doOnPreDraw { sharedViewModel.canSlidingPaneBeClosed.value = binding.slidingPane.isSlideable }
|
||||
|
||||
sharedViewModel.closeSlidingPaneEvent.observe(viewLifecycleOwner, {
|
||||
it.consume {
|
||||
if (!binding.slidingPane.closePane()) {
|
||||
goBack()
|
||||
}
|
||||
}
|
||||
})
|
||||
sharedViewModel.layoutChangedEvent.observe(viewLifecycleOwner, {
|
||||
it.consume {
|
||||
sharedViewModel.canSlidingPaneBeClosed.value = binding.slidingPane.isSlideable
|
||||
if (binding.slidingPane.isSlideable) {
|
||||
val navHostFragment = childFragmentManager.findFragmentById(R.id.chat_nav_container) as NavHostFragment
|
||||
if (navHostFragment.navController.currentDestination?.id == R.id.emptyChatFragment) {
|
||||
Log.i("[Chat] Foldable device has been folded, closing side pane with empty fragment")
|
||||
binding.slidingPane.closePane()
|
||||
sharedViewModel.closeSlidingPaneEvent.observe(
|
||||
viewLifecycleOwner,
|
||||
{
|
||||
it.consume {
|
||||
if (!binding.slidingPane.closePane()) {
|
||||
goBack()
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
)
|
||||
sharedViewModel.layoutChangedEvent.observe(
|
||||
viewLifecycleOwner,
|
||||
{
|
||||
it.consume {
|
||||
sharedViewModel.canSlidingPaneBeClosed.value = binding.slidingPane.isSlideable
|
||||
if (binding.slidingPane.isSlideable) {
|
||||
val navHostFragment = childFragmentManager.findFragmentById(R.id.chat_nav_container) as NavHostFragment
|
||||
if (navHostFragment.navController.currentDestination?.id == R.id.emptyChatFragment) {
|
||||
Log.i("[Chat] Foldable device has been folded, closing side pane with empty fragment")
|
||||
binding.slidingPane.closePane()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
)
|
||||
binding.slidingPane.lockMode = SlidingPaneLayout.LOCK_MODE_LOCKED
|
||||
binding.slidingPane.addPanelSlideListener(object : SlidingPaneLayout.PanelSlideListener {
|
||||
override fun onPanelSlide(panel: View, slideOffset: Float) { }
|
||||
|
@ -171,16 +177,20 @@ class MasterChatRoomsFragment : MasterFragment<ChatRoomMasterFragmentBinding, Ch
|
|||
dialog.dismiss()
|
||||
}
|
||||
|
||||
viewModel.showDeleteButton({
|
||||
val deletedChatRoom = adapter.currentList[viewHolder.adapterPosition].chatRoom
|
||||
listViewModel.deleteChatRoom(deletedChatRoom)
|
||||
if (!binding.slidingPane.isSlideable &&
|
||||
deletedChatRoom == sharedViewModel.selectedChatRoom.value) {
|
||||
Log.i("[Chat] Currently displayed chat room has been deleted, removing detail fragment")
|
||||
clearDisplayedChatRoom()
|
||||
}
|
||||
dialog.dismiss()
|
||||
}, getString(R.string.dialog_delete))
|
||||
viewModel.showDeleteButton(
|
||||
{
|
||||
val deletedChatRoom = adapter.currentList[viewHolder.adapterPosition].chatRoom
|
||||
listViewModel.deleteChatRoom(deletedChatRoom)
|
||||
if (!binding.slidingPane.isSlideable &&
|
||||
deletedChatRoom == sharedViewModel.selectedChatRoom.value
|
||||
) {
|
||||
Log.i("[Chat] Currently displayed chat room has been deleted, removing detail fragment")
|
||||
clearDisplayedChatRoom()
|
||||
}
|
||||
dialog.dismiss()
|
||||
},
|
||||
getString(R.string.dialog_delete)
|
||||
)
|
||||
|
||||
dialog.show()
|
||||
}
|
||||
|
@ -191,28 +201,37 @@ class MasterChatRoomsFragment : MasterFragment<ChatRoomMasterFragmentBinding, Ch
|
|||
// Divider between items
|
||||
binding.chatList.addItemDecoration(AppUtils.getDividerDecoration(requireContext(), layoutManager))
|
||||
|
||||
listViewModel.chatRooms.observe(viewLifecycleOwner, { chatRooms ->
|
||||
adapter.submitList(chatRooms)
|
||||
})
|
||||
|
||||
listViewModel.contactsUpdatedEvent.observe(viewLifecycleOwner, {
|
||||
it.consume {
|
||||
adapter.notifyDataSetChanged()
|
||||
listViewModel.chatRooms.observe(
|
||||
viewLifecycleOwner,
|
||||
{ chatRooms ->
|
||||
adapter.submitList(chatRooms)
|
||||
}
|
||||
})
|
||||
)
|
||||
|
||||
adapter.selectedChatRoomEvent.observe(viewLifecycleOwner, {
|
||||
it.consume { chatRoom ->
|
||||
if ((requireActivity() as GenericActivity).isDestructionPending) {
|
||||
Log.w("[Chat] Activity is pending destruction, don't start navigating now!")
|
||||
sharedViewModel.destructionPendingChatRoom = chatRoom
|
||||
} else {
|
||||
binding.slidingPane.openPane()
|
||||
sharedViewModel.selectedChatRoom.value = chatRoom
|
||||
navigateToChatRoom(AppUtils.createBundleWithSharedTextAndFiles(sharedViewModel))
|
||||
listViewModel.contactsUpdatedEvent.observe(
|
||||
viewLifecycleOwner,
|
||||
{
|
||||
it.consume {
|
||||
adapter.notifyDataSetChanged()
|
||||
}
|
||||
}
|
||||
})
|
||||
)
|
||||
|
||||
adapter.selectedChatRoomEvent.observe(
|
||||
viewLifecycleOwner,
|
||||
{
|
||||
it.consume { chatRoom ->
|
||||
if ((requireActivity() as GenericActivity).isDestructionPending) {
|
||||
Log.w("[Chat] Activity is pending destruction, don't start navigating now!")
|
||||
sharedViewModel.destructionPendingChatRoom = chatRoom
|
||||
} else {
|
||||
binding.slidingPane.openPane()
|
||||
sharedViewModel.selectedChatRoom.value = chatRoom
|
||||
navigateToChatRoom(AppUtils.createBundleWithSharedTextAndFiles(sharedViewModel))
|
||||
}
|
||||
}
|
||||
}
|
||||
)
|
||||
|
||||
binding.setEditClickListener {
|
||||
listSelectionViewModel.isEditionEnabled.value = true
|
||||
|
@ -268,43 +287,55 @@ class MasterChatRoomsFragment : MasterFragment<ChatRoomMasterFragmentBinding, Ch
|
|||
adapter.selectedChatRoomEvent.value = Event(chatRoom)
|
||||
}
|
||||
} else {
|
||||
sharedViewModel.textToShare.observe(viewLifecycleOwner, {
|
||||
if (it.isNotEmpty()) {
|
||||
Log.i("[Chat] Found text to share")
|
||||
// val activity = requireActivity() as MainActivity
|
||||
// activity.showSnackBar(R.string.chat_room_toast_choose_for_sharing)
|
||||
listViewModel.textSharingPending.value = true
|
||||
} else {
|
||||
if (sharedViewModel.filesToShare.value.isNullOrEmpty()) {
|
||||
listViewModel.textSharingPending.value = false
|
||||
sharedViewModel.textToShare.observe(
|
||||
viewLifecycleOwner,
|
||||
{
|
||||
if (it.isNotEmpty()) {
|
||||
Log.i("[Chat] Found text to share")
|
||||
// val activity = requireActivity() as MainActivity
|
||||
// activity.showSnackBar(R.string.chat_room_toast_choose_for_sharing)
|
||||
listViewModel.textSharingPending.value = true
|
||||
} else {
|
||||
if (sharedViewModel.filesToShare.value.isNullOrEmpty()) {
|
||||
listViewModel.textSharingPending.value = false
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
sharedViewModel.filesToShare.observe(viewLifecycleOwner, {
|
||||
if (it.isNotEmpty()) {
|
||||
Log.i("[Chat] Found ${it.size} files to share")
|
||||
// val activity = requireActivity() as MainActivity
|
||||
// activity.showSnackBar(R.string.chat_room_toast_choose_for_sharing)
|
||||
listViewModel.fileSharingPending.value = true
|
||||
} else {
|
||||
if (sharedViewModel.textToShare.value.isNullOrEmpty()) {
|
||||
listViewModel.fileSharingPending.value = false
|
||||
)
|
||||
sharedViewModel.filesToShare.observe(
|
||||
viewLifecycleOwner,
|
||||
{
|
||||
if (it.isNotEmpty()) {
|
||||
Log.i("[Chat] Found ${it.size} files to share")
|
||||
// val activity = requireActivity() as MainActivity
|
||||
// activity.showSnackBar(R.string.chat_room_toast_choose_for_sharing)
|
||||
listViewModel.fileSharingPending.value = true
|
||||
} else {
|
||||
if (sharedViewModel.textToShare.value.isNullOrEmpty()) {
|
||||
listViewModel.fileSharingPending.value = false
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
sharedViewModel.isPendingMessageForward.observe(viewLifecycleOwner, {
|
||||
listViewModel.forwardPending.value = it
|
||||
adapter.forwardPending(it)
|
||||
if (it) {
|
||||
Log.i("[Chat] Found chat message to transfer")
|
||||
)
|
||||
sharedViewModel.isPendingMessageForward.observe(
|
||||
viewLifecycleOwner,
|
||||
{
|
||||
listViewModel.forwardPending.value = it
|
||||
adapter.forwardPending(it)
|
||||
if (it) {
|
||||
Log.i("[Chat] Found chat message to transfer")
|
||||
}
|
||||
}
|
||||
})
|
||||
)
|
||||
|
||||
listViewModel.onErrorEvent.observe(viewLifecycleOwner, {
|
||||
it.consume { messageResourceId ->
|
||||
(activity as MainActivity).showSnackBar(messageResourceId)
|
||||
listViewModel.onErrorEvent.observe(
|
||||
viewLifecycleOwner,
|
||||
{
|
||||
it.consume { messageResourceId ->
|
||||
(activity as MainActivity).showSnackBar(messageResourceId)
|
||||
}
|
||||
}
|
||||
})
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -149,9 +149,11 @@ class ChatMessageSendingViewModel(private val chatRoom: ChatRoom) : ViewModel()
|
|||
fun addAttachment(path: String) {
|
||||
val list = arrayListOf<ChatMessageAttachmentData>()
|
||||
list.addAll(attachments.value.orEmpty())
|
||||
list.add(ChatMessageAttachmentData(path) {
|
||||
removeAttachment(it)
|
||||
})
|
||||
list.add(
|
||||
ChatMessageAttachmentData(path) {
|
||||
removeAttachment(it)
|
||||
}
|
||||
)
|
||||
attachments.value = list
|
||||
|
||||
sendMessageEnabled.value = textToSend.value.orEmpty().isNotEmpty() || list.isNotEmpty() || isPendingVoiceRecord.value == true
|
||||
|
|
|
@ -47,7 +47,7 @@ class ChatRoomViewModel(val chatRoom: ChatRoom) : ViewModel(), ContactDataInterf
|
|||
override val displayName: MutableLiveData<String> = MutableLiveData<String>()
|
||||
override val securityLevel: MutableLiveData<ChatRoomSecurityLevel> = MutableLiveData<ChatRoomSecurityLevel>()
|
||||
override val showGroupChatAvatar: Boolean = chatRoom.hasCapability(ChatRoomCapabilities.Conference.toInt()) &&
|
||||
!chatRoom.hasCapability(ChatRoomCapabilities.OneToOne.toInt())
|
||||
!chatRoom.hasCapability(ChatRoomCapabilities.OneToOne.toInt())
|
||||
|
||||
val subject = MutableLiveData<String>()
|
||||
|
||||
|
@ -310,8 +310,8 @@ class ChatRoomViewModel(val chatRoom: ChatRoom) : ViewModel(), ContactDataInterf
|
|||
else chatRoom.peerAddress.asStringUriOnly()
|
||||
|
||||
oneParticipantOneDevice = chatRoom.hasCapability(ChatRoomCapabilities.OneToOne.toInt()) &&
|
||||
chatRoom.me?.devices?.size == 1 &&
|
||||
chatRoom.participants.firstOrNull()?.devices?.size == 1
|
||||
chatRoom.me?.devices?.size == 1 &&
|
||||
chatRoom.participants.firstOrNull()?.devices?.size == 1
|
||||
|
||||
addressToCall = if (chatRoom.hasCapability(ChatRoomCapabilities.Basic.toInt()))
|
||||
chatRoom.peerAddress
|
||||
|
|
|
@ -211,9 +211,11 @@ class GroupInfoViewModel(val chatRoom: ChatRoom?) : ErrorReportingViewModel() {
|
|||
|
||||
if (chatRoom != null) {
|
||||
for (participant in chatRoom.participants) {
|
||||
list.add(GroupInfoParticipantData(
|
||||
GroupChatRoomMember(participant.address, participant.isAdmin, participant.securityLevel, canBeSetAdmin = true)
|
||||
))
|
||||
list.add(
|
||||
GroupInfoParticipantData(
|
||||
GroupChatRoomMember(participant.address, participant.isAdmin, participant.securityLevel, canBeSetAdmin = true)
|
||||
)
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -47,9 +47,11 @@ class MultiLineWrapContentWidthTextView : AppCompatTextView {
|
|||
if (widthMode == MeasureSpec.AT_MOST) {
|
||||
val layout = layout
|
||||
if (layout != null) {
|
||||
val maxWidth = (ceil(getMaxLineWidth(layout).toDouble()).toInt() +
|
||||
val maxWidth = (
|
||||
ceil(getMaxLineWidth(layout).toDouble()).toInt() +
|
||||
totalPaddingLeft +
|
||||
totalPaddingRight)
|
||||
totalPaddingRight
|
||||
)
|
||||
wSpec = MeasureSpec.makeMeasureSpec(maxWidth, MeasureSpec.AT_MOST)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -70,9 +70,12 @@ class ContactsListAdapter(
|
|||
|
||||
// This is for item selection through ListTopBarFragment
|
||||
selectionListViewModel = selectionViewModel
|
||||
selectionViewModel.isEditionEnabled.observe(viewLifecycleOwner, {
|
||||
position = adapterPosition
|
||||
})
|
||||
selectionViewModel.isEditionEnabled.observe(
|
||||
viewLifecycleOwner,
|
||||
{
|
||||
position = adapterPosition
|
||||
}
|
||||
)
|
||||
|
||||
setClickListener {
|
||||
if (selectionViewModel.isEditionEnabled.value == true) {
|
||||
|
|
|
@ -78,35 +78,44 @@ class DetailContactFragment : GenericFragment<ContactDetailFragmentBinding>() {
|
|||
)[ContactViewModel::class.java]
|
||||
binding.viewModel = viewModel
|
||||
|
||||
viewModel.sendSmsToEvent.observe(viewLifecycleOwner, {
|
||||
it.consume { number ->
|
||||
sendSms(number)
|
||||
}
|
||||
})
|
||||
|
||||
viewModel.startCallToEvent.observe(viewLifecycleOwner, {
|
||||
it.consume { address ->
|
||||
if (coreContext.core.callsNb > 0) {
|
||||
Log.i("[Contact] Starting dialer with pre-filled URI ${address.asStringUriOnly()}, is transfer? ${sharedViewModel.pendingCallTransfer}")
|
||||
val args = Bundle()
|
||||
args.putString("URI", address.asStringUriOnly())
|
||||
args.putBoolean("Transfer", sharedViewModel.pendingCallTransfer)
|
||||
args.putBoolean("SkipAutoCallStart", true) // If auto start call setting is enabled, ignore it
|
||||
navigateToDialer(args)
|
||||
} else {
|
||||
coreContext.startCall(address)
|
||||
viewModel.sendSmsToEvent.observe(
|
||||
viewLifecycleOwner,
|
||||
{
|
||||
it.consume { number ->
|
||||
sendSms(number)
|
||||
}
|
||||
}
|
||||
})
|
||||
)
|
||||
|
||||
viewModel.chatRoomCreatedEvent.observe(viewLifecycleOwner, {
|
||||
it.consume { chatRoom ->
|
||||
val args = Bundle()
|
||||
args.putString("LocalSipUri", chatRoom.localAddress.asStringUriOnly())
|
||||
args.putString("RemoteSipUri", chatRoom.peerAddress.asStringUriOnly())
|
||||
navigateToChatRoom(args)
|
||||
viewModel.startCallToEvent.observe(
|
||||
viewLifecycleOwner,
|
||||
{
|
||||
it.consume { address ->
|
||||
if (coreContext.core.callsNb > 0) {
|
||||
Log.i("[Contact] Starting dialer with pre-filled URI ${address.asStringUriOnly()}, is transfer? ${sharedViewModel.pendingCallTransfer}")
|
||||
val args = Bundle()
|
||||
args.putString("URI", address.asStringUriOnly())
|
||||
args.putBoolean("Transfer", sharedViewModel.pendingCallTransfer)
|
||||
args.putBoolean("SkipAutoCallStart", true) // If auto start call setting is enabled, ignore it
|
||||
navigateToDialer(args)
|
||||
} else {
|
||||
coreContext.startCall(address)
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
)
|
||||
|
||||
viewModel.chatRoomCreatedEvent.observe(
|
||||
viewLifecycleOwner,
|
||||
{
|
||||
it.consume { chatRoom ->
|
||||
val args = Bundle()
|
||||
args.putString("LocalSipUri", chatRoom.localAddress.asStringUriOnly())
|
||||
args.putString("RemoteSipUri", chatRoom.peerAddress.asStringUriOnly())
|
||||
navigateToChatRoom(args)
|
||||
}
|
||||
}
|
||||
)
|
||||
|
||||
binding.setBackClickListener {
|
||||
goBack()
|
||||
|
@ -120,11 +129,14 @@ class DetailContactFragment : GenericFragment<ContactDetailFragmentBinding>() {
|
|||
confirmContactRemoval()
|
||||
}
|
||||
|
||||
viewModel.onErrorEvent.observe(viewLifecycleOwner, {
|
||||
it.consume { messageResourceId ->
|
||||
(activity as MainActivity).showSnackBar(messageResourceId)
|
||||
viewModel.onErrorEvent.observe(
|
||||
viewLifecycleOwner,
|
||||
{
|
||||
it.consume { messageResourceId ->
|
||||
(activity as MainActivity).showSnackBar(messageResourceId)
|
||||
}
|
||||
}
|
||||
})
|
||||
)
|
||||
}
|
||||
|
||||
override fun goBack() {
|
||||
|
@ -143,11 +155,14 @@ class DetailContactFragment : GenericFragment<ContactDetailFragmentBinding>() {
|
|||
dialog.dismiss()
|
||||
}
|
||||
|
||||
dialogViewModel.showDeleteButton({
|
||||
viewModel.deleteContact()
|
||||
dialog.dismiss()
|
||||
goBack()
|
||||
}, getString(R.string.dialog_delete))
|
||||
dialogViewModel.showDeleteButton(
|
||||
{
|
||||
viewModel.deleteContact()
|
||||
dialog.dismiss()
|
||||
goBack()
|
||||
},
|
||||
getString(R.string.dialog_delete)
|
||||
)
|
||||
|
||||
dialog.show()
|
||||
}
|
||||
|
|
|
@ -80,25 +80,31 @@ class MasterContactsFragment : MasterFragment<ContactMasterFragmentBinding, Cont
|
|||
|
||||
view.doOnPreDraw { sharedViewModel.canSlidingPaneBeClosed.value = binding.slidingPane.isSlideable }
|
||||
|
||||
sharedViewModel.closeSlidingPaneEvent.observe(viewLifecycleOwner, {
|
||||
it.consume {
|
||||
if (!binding.slidingPane.closePane()) {
|
||||
goBack()
|
||||
}
|
||||
}
|
||||
})
|
||||
sharedViewModel.layoutChangedEvent.observe(viewLifecycleOwner, {
|
||||
it.consume {
|
||||
sharedViewModel.canSlidingPaneBeClosed.value = binding.slidingPane.isSlideable
|
||||
if (binding.slidingPane.isSlideable) {
|
||||
val navHostFragment = childFragmentManager.findFragmentById(R.id.contacts_nav_container) as NavHostFragment
|
||||
if (navHostFragment.navController.currentDestination?.id == R.id.emptyContactFragment) {
|
||||
Log.i("[Contacts] Foldable device has been folded, closing side pane with empty fragment")
|
||||
binding.slidingPane.closePane()
|
||||
sharedViewModel.closeSlidingPaneEvent.observe(
|
||||
viewLifecycleOwner,
|
||||
{
|
||||
it.consume {
|
||||
if (!binding.slidingPane.closePane()) {
|
||||
goBack()
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
)
|
||||
sharedViewModel.layoutChangedEvent.observe(
|
||||
viewLifecycleOwner,
|
||||
{
|
||||
it.consume {
|
||||
sharedViewModel.canSlidingPaneBeClosed.value = binding.slidingPane.isSlideable
|
||||
if (binding.slidingPane.isSlideable) {
|
||||
val navHostFragment = childFragmentManager.findFragmentById(R.id.contacts_nav_container) as NavHostFragment
|
||||
if (navHostFragment.navController.currentDestination?.id == R.id.emptyContactFragment) {
|
||||
Log.i("[Contacts] Foldable device has been folded, closing side pane with empty fragment")
|
||||
binding.slidingPane.closePane()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
)
|
||||
binding.slidingPane.lockMode = SlidingPaneLayout.LOCK_MODE_LOCKED
|
||||
/*binding.slidingPane.addPanelSlideListener(object : SlidingPaneLayout.PanelSlideListener {
|
||||
override fun onPanelSlide(panel: View, slideOffset: Float) { }
|
||||
|
@ -155,16 +161,20 @@ class MasterContactsFragment : MasterFragment<ContactMasterFragmentBinding, Cont
|
|||
dialog.dismiss()
|
||||
}
|
||||
|
||||
viewModel.showDeleteButton({
|
||||
val deletedContact = adapter.currentList[viewHolder.adapterPosition].contactInternal
|
||||
listViewModel.deleteContact(deletedContact)
|
||||
if (!binding.slidingPane.isSlideable &&
|
||||
deletedContact == sharedViewModel.selectedContact.value) {
|
||||
Log.i("[Contacts] Currently displayed contact has been deleted, removing detail fragment")
|
||||
clearDisplayedContact()
|
||||
}
|
||||
dialog.dismiss()
|
||||
}, getString(R.string.dialog_delete))
|
||||
viewModel.showDeleteButton(
|
||||
{
|
||||
val deletedContact = adapter.currentList[viewHolder.adapterPosition].contactInternal
|
||||
listViewModel.deleteContact(deletedContact)
|
||||
if (!binding.slidingPane.isSlideable &&
|
||||
deletedContact == sharedViewModel.selectedContact.value
|
||||
) {
|
||||
Log.i("[Contacts] Currently displayed contact has been deleted, removing detail fragment")
|
||||
clearDisplayedContact()
|
||||
}
|
||||
dialog.dismiss()
|
||||
},
|
||||
getString(R.string.dialog_delete)
|
||||
)
|
||||
|
||||
dialog.show()
|
||||
}
|
||||
|
@ -179,35 +189,41 @@ class MasterContactsFragment : MasterFragment<ContactMasterFragmentBinding, Cont
|
|||
val headerItemDecoration = RecyclerViewHeaderDecoration(requireContext(), adapter)
|
||||
binding.contactsList.addItemDecoration(headerItemDecoration)
|
||||
|
||||
adapter.selectedContactEvent.observe(viewLifecycleOwner, {
|
||||
it.consume { contact ->
|
||||
Log.i("[Contacts] Selected item in list changed: $contact")
|
||||
sharedViewModel.selectedContact.value = contact
|
||||
listViewModel.filter.value = ""
|
||||
adapter.selectedContactEvent.observe(
|
||||
viewLifecycleOwner,
|
||||
{
|
||||
it.consume { contact ->
|
||||
Log.i("[Contacts] Selected item in list changed: $contact")
|
||||
sharedViewModel.selectedContact.value = contact
|
||||
listViewModel.filter.value = ""
|
||||
|
||||
binding.slidingPane.openPane()
|
||||
if (editOnClick) {
|
||||
navigateToContactEditor(sipUriToAdd)
|
||||
editOnClick = false
|
||||
sipUriToAdd = null
|
||||
} else {
|
||||
navigateToContact()
|
||||
binding.slidingPane.openPane()
|
||||
if (editOnClick) {
|
||||
navigateToContactEditor(sipUriToAdd)
|
||||
editOnClick = false
|
||||
sipUriToAdd = null
|
||||
} else {
|
||||
navigateToContact()
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
)
|
||||
|
||||
listViewModel.contactsList.observe(viewLifecycleOwner, {
|
||||
val id = contactIdToDisplay
|
||||
if (id != null) {
|
||||
val contact = coreContext.contactsManager.findContactById(id)
|
||||
if (contact != null) {
|
||||
contactIdToDisplay = null
|
||||
Log.i("[Contacts] Found matching contact $contact after callback")
|
||||
adapter.selectedContactEvent.value = Event(contact)
|
||||
listViewModel.contactsList.observe(
|
||||
viewLifecycleOwner,
|
||||
{
|
||||
val id = contactIdToDisplay
|
||||
if (id != null) {
|
||||
val contact = coreContext.contactsManager.findContactById(id)
|
||||
if (contact != null) {
|
||||
contactIdToDisplay = null
|
||||
Log.i("[Contacts] Found matching contact $contact after callback")
|
||||
adapter.selectedContactEvent.value = Event(contact)
|
||||
}
|
||||
}
|
||||
adapter.submitList(it)
|
||||
}
|
||||
adapter.submitList(it)
|
||||
})
|
||||
)
|
||||
|
||||
binding.setAllContactsToggleClickListener {
|
||||
listViewModel.sipContactsSelected.value = false
|
||||
|
@ -216,13 +232,19 @@ class MasterContactsFragment : MasterFragment<ContactMasterFragmentBinding, Cont
|
|||
listViewModel.sipContactsSelected.value = true
|
||||
}
|
||||
|
||||
listViewModel.sipContactsSelected.observe(viewLifecycleOwner, {
|
||||
listViewModel.updateContactsList()
|
||||
})
|
||||
listViewModel.sipContactsSelected.observe(
|
||||
viewLifecycleOwner,
|
||||
{
|
||||
listViewModel.updateContactsList()
|
||||
}
|
||||
)
|
||||
|
||||
listViewModel.filter.observe(viewLifecycleOwner, {
|
||||
listViewModel.updateContactsList()
|
||||
})
|
||||
listViewModel.filter.observe(
|
||||
viewLifecycleOwner,
|
||||
{
|
||||
listViewModel.updateContactsList()
|
||||
}
|
||||
)
|
||||
|
||||
binding.setNewContactClickListener {
|
||||
// Remove any previously selected contact
|
||||
|
|
|
@ -166,12 +166,15 @@ class ContactEditorViewModel(val c: Contact?) : ViewModel(), ContactDataInterfac
|
|||
}
|
||||
|
||||
when (orientation) {
|
||||
ExifInterface.ORIENTATION_ROTATE_90 -> image =
|
||||
ImageUtils.rotateImage(image, 90f)
|
||||
ExifInterface.ORIENTATION_ROTATE_180 -> image =
|
||||
ImageUtils.rotateImage(image, 180f)
|
||||
ExifInterface.ORIENTATION_ROTATE_270 -> image =
|
||||
ImageUtils.rotateImage(image, 270f)
|
||||
ExifInterface.ORIENTATION_ROTATE_90 ->
|
||||
image =
|
||||
ImageUtils.rotateImage(image, 90f)
|
||||
ExifInterface.ORIENTATION_ROTATE_180 ->
|
||||
image =
|
||||
ImageUtils.rotateImage(image, 180f)
|
||||
ExifInterface.ORIENTATION_ROTATE_270 ->
|
||||
image =
|
||||
ImageUtils.rotateImage(image, 270f)
|
||||
}
|
||||
|
||||
val stream = ByteArrayOutputStream()
|
||||
|
|
|
@ -95,35 +95,44 @@ class DialerFragment : SecureFragment<DialerFragmentBinding>() {
|
|||
}
|
||||
arguments?.clear()
|
||||
|
||||
viewModel.enteredUri.observe(viewLifecycleOwner, {
|
||||
if (it == corePreferences.debugPopupCode) {
|
||||
displayDebugPopup()
|
||||
viewModel.enteredUri.value = ""
|
||||
}
|
||||
})
|
||||
|
||||
viewModel.uploadFinishedEvent.observe(viewLifecycleOwner, {
|
||||
it.consume { url ->
|
||||
// To prevent being trigger when using the Send Logs button in About page
|
||||
if (uploadLogsInitiatedByUs) {
|
||||
val clipboard =
|
||||
requireContext().getSystemService(Context.CLIPBOARD_SERVICE) as ClipboardManager
|
||||
val clip = ClipData.newPlainText("Logs url", url)
|
||||
clipboard.setPrimaryClip(clip)
|
||||
|
||||
val activity = requireActivity() as MainActivity
|
||||
activity.showSnackBar(R.string.logs_url_copied_to_clipboard)
|
||||
|
||||
AppUtils.shareUploadedLogsUrl(activity, url)
|
||||
viewModel.enteredUri.observe(
|
||||
viewLifecycleOwner,
|
||||
{
|
||||
if (it == corePreferences.debugPopupCode) {
|
||||
displayDebugPopup()
|
||||
viewModel.enteredUri.value = ""
|
||||
}
|
||||
}
|
||||
})
|
||||
)
|
||||
|
||||
viewModel.updateAvailableEvent.observe(viewLifecycleOwner, {
|
||||
it.consume { url ->
|
||||
displayNewVersionAvailableDialog(url)
|
||||
viewModel.uploadFinishedEvent.observe(
|
||||
viewLifecycleOwner,
|
||||
{
|
||||
it.consume { url ->
|
||||
// To prevent being trigger when using the Send Logs button in About page
|
||||
if (uploadLogsInitiatedByUs) {
|
||||
val clipboard =
|
||||
requireContext().getSystemService(Context.CLIPBOARD_SERVICE) as ClipboardManager
|
||||
val clip = ClipData.newPlainText("Logs url", url)
|
||||
clipboard.setPrimaryClip(clip)
|
||||
|
||||
val activity = requireActivity() as MainActivity
|
||||
activity.showSnackBar(R.string.logs_url_copied_to_clipboard)
|
||||
|
||||
AppUtils.shareUploadedLogsUrl(activity, url)
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
)
|
||||
|
||||
viewModel.updateAvailableEvent.observe(
|
||||
viewLifecycleOwner,
|
||||
{
|
||||
it.consume { url ->
|
||||
displayNewVersionAvailableDialog(url)
|
||||
}
|
||||
}
|
||||
)
|
||||
|
||||
Log.i("[Dialer] Pending call transfer mode = ${sharedViewModel.pendingCallTransfer}")
|
||||
viewModel.transferVisibility.value = sharedViewModel.pendingCallTransfer
|
||||
|
@ -204,11 +213,14 @@ class DialerFragment : SecureFragment<DialerFragmentBinding>() {
|
|||
dialog.dismiss()
|
||||
}
|
||||
|
||||
viewModel.showOkButton({
|
||||
val browserIntent = Intent(Intent.ACTION_VIEW, Uri.parse(url))
|
||||
startActivity(browserIntent)
|
||||
dialog.dismiss()
|
||||
}, getString(R.string.dialog_ok))
|
||||
viewModel.showOkButton(
|
||||
{
|
||||
val browserIntent = Intent(Intent.ACTION_VIEW, Uri.parse(url))
|
||||
startActivity(browserIntent)
|
||||
dialog.dismiss()
|
||||
},
|
||||
getString(R.string.dialog_ok)
|
||||
)
|
||||
|
||||
dialog.show()
|
||||
}
|
||||
|
|
|
@ -62,42 +62,57 @@ abstract class MasterFragment<T : ViewDataBinding, U : SelectionListAdapter<*, *
|
|||
// List selection
|
||||
listSelectionViewModel = ViewModelProvider(this).get(ListTopBarViewModel::class.java)
|
||||
|
||||
listSelectionViewModel.isEditionEnabled.observe(viewLifecycleOwner, {
|
||||
if (!it) listSelectionViewModel.onUnSelectAll()
|
||||
})
|
||||
|
||||
listSelectionViewModel.selectAllEvent.observe(viewLifecycleOwner, {
|
||||
it.consume {
|
||||
listSelectionViewModel.onSelectAll(getItemCount() - 1)
|
||||
listSelectionViewModel.isEditionEnabled.observe(
|
||||
viewLifecycleOwner,
|
||||
{
|
||||
if (!it) listSelectionViewModel.onUnSelectAll()
|
||||
}
|
||||
})
|
||||
)
|
||||
|
||||
listSelectionViewModel.unSelectAllEvent.observe(viewLifecycleOwner, {
|
||||
it.consume {
|
||||
listSelectionViewModel.onUnSelectAll()
|
||||
}
|
||||
})
|
||||
|
||||
listSelectionViewModel.deleteSelectionEvent.observe(viewLifecycleOwner, {
|
||||
it.consume {
|
||||
val confirmationDialog = AppUtils.getStringWithPlural(dialogConfirmationMessageBeforeRemoval, listSelectionViewModel.selectedItems.value.orEmpty().size)
|
||||
val viewModel = DialogViewModel(confirmationDialog)
|
||||
val dialog: Dialog = DialogUtils.getDialog(requireContext(), viewModel)
|
||||
|
||||
viewModel.showCancelButton {
|
||||
dialog.dismiss()
|
||||
listSelectionViewModel.isEditionEnabled.value = false
|
||||
listSelectionViewModel.selectAllEvent.observe(
|
||||
viewLifecycleOwner,
|
||||
{
|
||||
it.consume {
|
||||
listSelectionViewModel.onSelectAll(getItemCount() - 1)
|
||||
}
|
||||
|
||||
viewModel.showDeleteButton({
|
||||
delete()
|
||||
dialog.dismiss()
|
||||
listSelectionViewModel.isEditionEnabled.value = false
|
||||
}, getString(R.string.dialog_delete))
|
||||
|
||||
dialog.show()
|
||||
}
|
||||
})
|
||||
)
|
||||
|
||||
listSelectionViewModel.unSelectAllEvent.observe(
|
||||
viewLifecycleOwner,
|
||||
{
|
||||
it.consume {
|
||||
listSelectionViewModel.onUnSelectAll()
|
||||
}
|
||||
}
|
||||
)
|
||||
|
||||
listSelectionViewModel.deleteSelectionEvent.observe(
|
||||
viewLifecycleOwner,
|
||||
{
|
||||
it.consume {
|
||||
val confirmationDialog = AppUtils.getStringWithPlural(dialogConfirmationMessageBeforeRemoval, listSelectionViewModel.selectedItems.value.orEmpty().size)
|
||||
val viewModel = DialogViewModel(confirmationDialog)
|
||||
val dialog: Dialog = DialogUtils.getDialog(requireContext(), viewModel)
|
||||
|
||||
viewModel.showCancelButton {
|
||||
dialog.dismiss()
|
||||
listSelectionViewModel.isEditionEnabled.value = false
|
||||
}
|
||||
|
||||
viewModel.showDeleteButton(
|
||||
{
|
||||
delete()
|
||||
dialog.dismiss()
|
||||
listSelectionViewModel.isEditionEnabled.value = false
|
||||
},
|
||||
getString(R.string.dialog_delete)
|
||||
)
|
||||
|
||||
dialog.show()
|
||||
}
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
private fun delete() {
|
||||
|
|
|
@ -75,7 +75,8 @@ abstract class SecureFragment<T : ViewDataBinding> : GenericFragment<T>() {
|
|||
|
||||
val flags: Int = window.attributes.flags
|
||||
if ((enable && flags and WindowManager.LayoutParams.FLAG_SECURE != 0) ||
|
||||
(!enable && flags and WindowManager.LayoutParams.FLAG_SECURE == 0)) {
|
||||
(!enable && flags and WindowManager.LayoutParams.FLAG_SECURE == 0)
|
||||
) {
|
||||
Log.d("[Secure Fragment] Secure flag is already ${if (enable) "enabled" else "disabled"}, skipping...")
|
||||
return
|
||||
}
|
||||
|
|
|
@ -49,13 +49,16 @@ class StatusFragment : GenericFragment<StatusFragmentBinding>() {
|
|||
ViewModelProvider(this).get(SharedMainViewModel::class.java)
|
||||
}
|
||||
|
||||
sharedViewModel.accountRemoved.observe(viewLifecycleOwner, {
|
||||
Log.i("[Status Fragment] An account was removed, update default account state")
|
||||
val defaultAccount = coreContext.core.defaultAccount
|
||||
if (defaultAccount != null) {
|
||||
viewModel.updateDefaultAccountRegistrationStatus(defaultAccount.state)
|
||||
sharedViewModel.accountRemoved.observe(
|
||||
viewLifecycleOwner,
|
||||
{
|
||||
Log.i("[Status Fragment] An account was removed, update default account state")
|
||||
val defaultAccount = coreContext.core.defaultAccount
|
||||
if (defaultAccount != null) {
|
||||
viewModel.updateDefaultAccountRegistrationStatus(defaultAccount.state)
|
||||
}
|
||||
}
|
||||
})
|
||||
)
|
||||
|
||||
binding.setMenuClickListener {
|
||||
sharedViewModel.toggleDrawerEvent.value = Event(true)
|
||||
|
|
|
@ -72,9 +72,12 @@ class CallLogsListAdapter(
|
|||
|
||||
// This is for item selection through ListTopBarFragment
|
||||
selectionListViewModel = selectionViewModel
|
||||
selectionViewModel.isEditionEnabled.observe(viewLifecycleOwner, {
|
||||
position = adapterPosition
|
||||
})
|
||||
selectionViewModel.isEditionEnabled.observe(
|
||||
viewLifecycleOwner,
|
||||
{
|
||||
position = adapterPosition
|
||||
}
|
||||
)
|
||||
|
||||
setClickListener {
|
||||
if (selectionViewModel.isEditionEnabled.value == true) {
|
||||
|
|
|
@ -94,40 +94,49 @@ class DetailCallLogFragment : GenericFragment<HistoryDetailFragmentBinding>() {
|
|||
}
|
||||
}
|
||||
|
||||
viewModel.startCallEvent.observe(viewLifecycleOwner, {
|
||||
it.consume { callLog ->
|
||||
val address = callLog.remoteAddress
|
||||
if (coreContext.core.callsNb > 0) {
|
||||
Log.i("[History] Starting dialer with pre-filled URI ${address.asStringUriOnly()}, is transfer? ${sharedViewModel.pendingCallTransfer}")
|
||||
val args = Bundle()
|
||||
args.putString("URI", address.asStringUriOnly())
|
||||
args.putBoolean("Transfer", sharedViewModel.pendingCallTransfer)
|
||||
args.putBoolean(
|
||||
"SkipAutoCallStart",
|
||||
true
|
||||
) // If auto start call setting is enabled, ignore it
|
||||
navigateToDialer(args)
|
||||
} else {
|
||||
val localAddress = callLog.localAddress
|
||||
coreContext.startCall(address, localAddress = localAddress)
|
||||
viewModel.startCallEvent.observe(
|
||||
viewLifecycleOwner,
|
||||
{
|
||||
it.consume { callLog ->
|
||||
val address = callLog.remoteAddress
|
||||
if (coreContext.core.callsNb > 0) {
|
||||
Log.i("[History] Starting dialer with pre-filled URI ${address.asStringUriOnly()}, is transfer? ${sharedViewModel.pendingCallTransfer}")
|
||||
val args = Bundle()
|
||||
args.putString("URI", address.asStringUriOnly())
|
||||
args.putBoolean("Transfer", sharedViewModel.pendingCallTransfer)
|
||||
args.putBoolean(
|
||||
"SkipAutoCallStart",
|
||||
true
|
||||
) // If auto start call setting is enabled, ignore it
|
||||
navigateToDialer(args)
|
||||
} else {
|
||||
val localAddress = callLog.localAddress
|
||||
coreContext.startCall(address, localAddress = localAddress)
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
)
|
||||
|
||||
viewModel.chatRoomCreatedEvent.observe(viewLifecycleOwner, {
|
||||
it.consume { chatRoom ->
|
||||
val args = Bundle()
|
||||
args.putString("LocalSipUri", chatRoom.localAddress.asStringUriOnly())
|
||||
args.putString("RemoteSipUri", chatRoom.peerAddress.asStringUriOnly())
|
||||
navigateToChatRoom(args)
|
||||
viewModel.chatRoomCreatedEvent.observe(
|
||||
viewLifecycleOwner,
|
||||
{
|
||||
it.consume { chatRoom ->
|
||||
val args = Bundle()
|
||||
args.putString("LocalSipUri", chatRoom.localAddress.asStringUriOnly())
|
||||
args.putString("RemoteSipUri", chatRoom.peerAddress.asStringUriOnly())
|
||||
navigateToChatRoom(args)
|
||||
}
|
||||
}
|
||||
})
|
||||
)
|
||||
|
||||
viewModel.onErrorEvent.observe(viewLifecycleOwner, {
|
||||
it.consume { messageResourceId ->
|
||||
(activity as MainActivity).showSnackBar(messageResourceId)
|
||||
viewModel.onErrorEvent.observe(
|
||||
viewLifecycleOwner,
|
||||
{
|
||||
it.consume { messageResourceId ->
|
||||
(activity as MainActivity).showSnackBar(messageResourceId)
|
||||
}
|
||||
}
|
||||
})
|
||||
)
|
||||
}
|
||||
|
||||
override fun goBack() {
|
||||
|
|
|
@ -83,25 +83,31 @@ class MasterCallLogsFragment : MasterFragment<HistoryMasterFragmentBinding, Call
|
|||
|
||||
view.doOnPreDraw { sharedViewModel.canSlidingPaneBeClosed.value = binding.slidingPane.isSlideable }
|
||||
|
||||
sharedViewModel.closeSlidingPaneEvent.observe(viewLifecycleOwner, {
|
||||
it.consume {
|
||||
if (!binding.slidingPane.closePane()) {
|
||||
goBack()
|
||||
}
|
||||
}
|
||||
})
|
||||
sharedViewModel.layoutChangedEvent.observe(viewLifecycleOwner, {
|
||||
it.consume {
|
||||
sharedViewModel.canSlidingPaneBeClosed.value = binding.slidingPane.isSlideable
|
||||
if (binding.slidingPane.isSlideable) {
|
||||
val navHostFragment = childFragmentManager.findFragmentById(R.id.history_nav_container) as NavHostFragment
|
||||
if (navHostFragment.navController.currentDestination?.id == R.id.emptyCallHistoryFragment) {
|
||||
Log.i("[History] Foldable device has been folded, closing side pane with empty fragment")
|
||||
binding.slidingPane.closePane()
|
||||
sharedViewModel.closeSlidingPaneEvent.observe(
|
||||
viewLifecycleOwner,
|
||||
{
|
||||
it.consume {
|
||||
if (!binding.slidingPane.closePane()) {
|
||||
goBack()
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
)
|
||||
sharedViewModel.layoutChangedEvent.observe(
|
||||
viewLifecycleOwner,
|
||||
{
|
||||
it.consume {
|
||||
sharedViewModel.canSlidingPaneBeClosed.value = binding.slidingPane.isSlideable
|
||||
if (binding.slidingPane.isSlideable) {
|
||||
val navHostFragment = childFragmentManager.findFragmentById(R.id.history_nav_container) as NavHostFragment
|
||||
if (navHostFragment.navController.currentDestination?.id == R.id.emptyCallHistoryFragment) {
|
||||
Log.i("[History] Foldable device has been folded, closing side pane with empty fragment")
|
||||
binding.slidingPane.closePane()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
)
|
||||
binding.slidingPane.lockMode = SlidingPaneLayout.LOCK_MODE_LOCKED
|
||||
/*binding.slidingPane.addPanelSlideListener(object : SlidingPaneLayout.PanelSlideListener {
|
||||
override fun onPanelSlide(panel: View, slideOffset: Float) { }
|
||||
|
@ -156,16 +162,20 @@ class MasterCallLogsFragment : MasterFragment<HistoryMasterFragmentBinding, Call
|
|||
dialog.dismiss()
|
||||
}
|
||||
|
||||
viewModel.showDeleteButton({
|
||||
val deletedCallGroup = adapter.currentList[viewHolder.adapterPosition]
|
||||
listViewModel.deleteCallLogGroup(deletedCallGroup)
|
||||
if (!binding.slidingPane.isSlideable &&
|
||||
deletedCallGroup.lastCallLog.callId == sharedViewModel.selectedCallLogGroup.value?.lastCallLog?.callId) {
|
||||
Log.i("[History] Currently displayed history has been deleted, removing detail fragment")
|
||||
clearDisplayedCallHistory()
|
||||
}
|
||||
dialog.dismiss()
|
||||
}, getString(R.string.dialog_delete))
|
||||
viewModel.showDeleteButton(
|
||||
{
|
||||
val deletedCallGroup = adapter.currentList[viewHolder.adapterPosition]
|
||||
listViewModel.deleteCallLogGroup(deletedCallGroup)
|
||||
if (!binding.slidingPane.isSlideable &&
|
||||
deletedCallGroup.lastCallLog.callId == sharedViewModel.selectedCallLogGroup.value?.lastCallLog?.callId
|
||||
) {
|
||||
Log.i("[History] Currently displayed history has been deleted, removing detail fragment")
|
||||
clearDisplayedCallHistory()
|
||||
}
|
||||
dialog.dismiss()
|
||||
},
|
||||
getString(R.string.dialog_delete)
|
||||
)
|
||||
|
||||
dialog.show()
|
||||
}
|
||||
|
@ -180,56 +190,74 @@ class MasterCallLogsFragment : MasterFragment<HistoryMasterFragmentBinding, Call
|
|||
val headerItemDecoration = RecyclerViewHeaderDecoration(requireContext(), adapter)
|
||||
binding.callLogsList.addItemDecoration(headerItemDecoration)
|
||||
|
||||
listViewModel.callLogs.observe(viewLifecycleOwner, { callLogs ->
|
||||
if (listViewModel.missedCallLogsSelected.value == false) {
|
||||
adapter.submitList(callLogs)
|
||||
}
|
||||
})
|
||||
|
||||
listViewModel.missedCallLogs.observe(viewLifecycleOwner, { callLogs ->
|
||||
if (listViewModel.missedCallLogsSelected.value == true) {
|
||||
adapter.submitList(callLogs)
|
||||
}
|
||||
})
|
||||
|
||||
listViewModel.missedCallLogsSelected.observe(viewLifecycleOwner, {
|
||||
if (it) {
|
||||
adapter.submitList(listViewModel.missedCallLogs.value)
|
||||
} else {
|
||||
adapter.submitList(listViewModel.callLogs.value)
|
||||
}
|
||||
})
|
||||
|
||||
listViewModel.contactsUpdatedEvent.observe(viewLifecycleOwner, {
|
||||
it.consume {
|
||||
adapter.notifyDataSetChanged()
|
||||
}
|
||||
})
|
||||
|
||||
adapter.selectedCallLogEvent.observe(viewLifecycleOwner, {
|
||||
it.consume { callLog ->
|
||||
sharedViewModel.selectedCallLogGroup.value = callLog
|
||||
binding.slidingPane.openPane()
|
||||
navigateToCallHistory()
|
||||
}
|
||||
})
|
||||
|
||||
adapter.startCallToEvent.observe(viewLifecycleOwner, {
|
||||
it.consume { callLogGroup ->
|
||||
val remoteAddress = callLogGroup.lastCallLog.remoteAddress
|
||||
if (coreContext.core.callsNb > 0) {
|
||||
Log.i("[History] Starting dialer with pre-filled URI ${remoteAddress.asStringUriOnly()}, is transfer? ${sharedViewModel.pendingCallTransfer}")
|
||||
val args = Bundle()
|
||||
args.putString("URI", remoteAddress.asStringUriOnly())
|
||||
args.putBoolean("Transfer", sharedViewModel.pendingCallTransfer)
|
||||
args.putBoolean("SkipAutoCallStart", true) // If auto start call setting is enabled, ignore it
|
||||
navigateToDialer(args)
|
||||
} else {
|
||||
val localAddress = callLogGroup.lastCallLog.localAddress
|
||||
coreContext.startCall(remoteAddress, localAddress = localAddress)
|
||||
listViewModel.callLogs.observe(
|
||||
viewLifecycleOwner,
|
||||
{ callLogs ->
|
||||
if (listViewModel.missedCallLogsSelected.value == false) {
|
||||
adapter.submitList(callLogs)
|
||||
}
|
||||
}
|
||||
})
|
||||
)
|
||||
|
||||
listViewModel.missedCallLogs.observe(
|
||||
viewLifecycleOwner,
|
||||
{ callLogs ->
|
||||
if (listViewModel.missedCallLogsSelected.value == true) {
|
||||
adapter.submitList(callLogs)
|
||||
}
|
||||
}
|
||||
)
|
||||
|
||||
listViewModel.missedCallLogsSelected.observe(
|
||||
viewLifecycleOwner,
|
||||
{
|
||||
if (it) {
|
||||
adapter.submitList(listViewModel.missedCallLogs.value)
|
||||
} else {
|
||||
adapter.submitList(listViewModel.callLogs.value)
|
||||
}
|
||||
}
|
||||
)
|
||||
|
||||
listViewModel.contactsUpdatedEvent.observe(
|
||||
viewLifecycleOwner,
|
||||
{
|
||||
it.consume {
|
||||
adapter.notifyDataSetChanged()
|
||||
}
|
||||
}
|
||||
)
|
||||
|
||||
adapter.selectedCallLogEvent.observe(
|
||||
viewLifecycleOwner,
|
||||
{
|
||||
it.consume { callLog ->
|
||||
sharedViewModel.selectedCallLogGroup.value = callLog
|
||||
binding.slidingPane.openPane()
|
||||
navigateToCallHistory()
|
||||
}
|
||||
}
|
||||
)
|
||||
|
||||
adapter.startCallToEvent.observe(
|
||||
viewLifecycleOwner,
|
||||
{
|
||||
it.consume { callLogGroup ->
|
||||
val remoteAddress = callLogGroup.lastCallLog.remoteAddress
|
||||
if (coreContext.core.callsNb > 0) {
|
||||
Log.i("[History] Starting dialer with pre-filled URI ${remoteAddress.asStringUriOnly()}, is transfer? ${sharedViewModel.pendingCallTransfer}")
|
||||
val args = Bundle()
|
||||
args.putString("URI", remoteAddress.asStringUriOnly())
|
||||
args.putBoolean("Transfer", sharedViewModel.pendingCallTransfer)
|
||||
args.putBoolean("SkipAutoCallStart", true) // If auto start call setting is enabled, ignore it
|
||||
navigateToDialer(args)
|
||||
} else {
|
||||
val localAddress = callLogGroup.lastCallLog.localAddress
|
||||
coreContext.startCall(remoteAddress, localAddress = localAddress)
|
||||
}
|
||||
}
|
||||
}
|
||||
)
|
||||
|
||||
binding.setAllCallLogsToggleClickListener {
|
||||
listViewModel.missedCallLogsSelected.value = false
|
||||
|
|
|
@ -109,7 +109,8 @@ class CallLogsListViewModel : ViewModel() {
|
|||
if (previousCallLogGroup == null) {
|
||||
previousCallLogGroup = GroupedCallLogData(callLog)
|
||||
} else if (previousCallLogGroup.lastCallLog.localAddress.weakEqual(callLog.localAddress) &&
|
||||
previousCallLogGroup.lastCallLog.remoteAddress.weakEqual(callLog.remoteAddress)) {
|
||||
previousCallLogGroup.lastCallLog.remoteAddress.weakEqual(callLog.remoteAddress)
|
||||
) {
|
||||
if (TimestampUtils.isSameDay(previousCallLogGroup.lastCallLog.startDate, callLog.startDate)) {
|
||||
previousCallLogGroup.callLogs.add(callLog)
|
||||
previousCallLogGroup.lastCallLog = callLog
|
||||
|
@ -126,7 +127,8 @@ class CallLogsListViewModel : ViewModel() {
|
|||
if (previousMissedCallLogGroup == null) {
|
||||
previousMissedCallLogGroup = GroupedCallLogData(callLog)
|
||||
} else if (previousMissedCallLogGroup.lastCallLog.localAddress.weakEqual(callLog.localAddress) &&
|
||||
previousMissedCallLogGroup.lastCallLog.remoteAddress.weakEqual(callLog.remoteAddress)) {
|
||||
previousMissedCallLogGroup.lastCallLog.remoteAddress.weakEqual(callLog.remoteAddress)
|
||||
) {
|
||||
if (TimestampUtils.isSameDay(previousMissedCallLogGroup.lastCallLog.startDate, callLog.startDate)) {
|
||||
previousMissedCallLogGroup.callLogs.add(callLog)
|
||||
previousMissedCallLogGroup.lastCallLog = callLog
|
||||
|
|
|
@ -68,9 +68,12 @@ class RecordingsFragment : MasterFragment<RecordingsFragmentBinding, RecordingsL
|
|||
val headerItemDecoration = RecyclerViewHeaderDecoration(requireContext(), adapter)
|
||||
binding.recordingsList.addItemDecoration(headerItemDecoration)
|
||||
|
||||
viewModel.recordingsList.observe(viewLifecycleOwner, { recordings ->
|
||||
adapter.submitList(recordings)
|
||||
})
|
||||
viewModel.recordingsList.observe(
|
||||
viewLifecycleOwner,
|
||||
{ recordings ->
|
||||
adapter.submitList(recordings)
|
||||
}
|
||||
)
|
||||
|
||||
binding.setBackClickListener { goBack() }
|
||||
|
||||
|
|
|
@ -59,7 +59,8 @@ class AccountSettingsFragment : GenericFragment<SettingsAccountFragmentBinding>(
|
|||
|
||||
try {
|
||||
viewModel = ViewModelProvider(this, AccountSettingsViewModelFactory(identity)).get(
|
||||
AccountSettingsViewModel::class.java)
|
||||
AccountSettingsViewModel::class.java
|
||||
)
|
||||
} catch (nsee: NoSuchElementException) {
|
||||
Log.e("[Account Settings] Failed to find Account object, aborting!")
|
||||
goBack()
|
||||
|
@ -69,27 +70,33 @@ class AccountSettingsFragment : GenericFragment<SettingsAccountFragmentBinding>(
|
|||
|
||||
binding.setBackClickListener { goBack() }
|
||||
|
||||
viewModel.linkPhoneNumberEvent.observe(viewLifecycleOwner, {
|
||||
it.consume {
|
||||
val authInfo = viewModel.account.findAuthInfo()
|
||||
if (authInfo == null) {
|
||||
Log.e("[Account Settings] Failed to find auth info for account ${viewModel.account}")
|
||||
} else {
|
||||
val args = Bundle()
|
||||
args.putString("Username", authInfo.username)
|
||||
args.putString("Password", authInfo.password)
|
||||
args.putString("HA1", authInfo.ha1)
|
||||
navigateToPhoneLinking(args)
|
||||
viewModel.linkPhoneNumberEvent.observe(
|
||||
viewLifecycleOwner,
|
||||
{
|
||||
it.consume {
|
||||
val authInfo = viewModel.account.findAuthInfo()
|
||||
if (authInfo == null) {
|
||||
Log.e("[Account Settings] Failed to find auth info for account ${viewModel.account}")
|
||||
} else {
|
||||
val args = Bundle()
|
||||
args.putString("Username", authInfo.username)
|
||||
args.putString("Password", authInfo.password)
|
||||
args.putString("HA1", authInfo.ha1)
|
||||
navigateToPhoneLinking(args)
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
)
|
||||
|
||||
viewModel.accountRemovedEvent.observe(viewLifecycleOwner, {
|
||||
it.consume {
|
||||
sharedViewModel.accountRemoved.value = true
|
||||
goBack()
|
||||
viewModel.accountRemovedEvent.observe(
|
||||
viewLifecycleOwner,
|
||||
{
|
||||
it.consume {
|
||||
sharedViewModel.accountRemoved.value = true
|
||||
goBack()
|
||||
}
|
||||
}
|
||||
})
|
||||
)
|
||||
}
|
||||
|
||||
override fun goBack() {
|
||||
|
|
|
@ -61,77 +61,104 @@ class AdvancedSettingsFragment : GenericFragment<SettingsAdvancedFragmentBinding
|
|||
|
||||
binding.setBackClickListener { goBack() }
|
||||
|
||||
viewModel.uploadFinishedEvent.observe(viewLifecycleOwner, {
|
||||
it.consume { url ->
|
||||
val clipboard =
|
||||
requireContext().getSystemService(Context.CLIPBOARD_SERVICE) as ClipboardManager
|
||||
val clip = ClipData.newPlainText("Logs url", url)
|
||||
clipboard.setPrimaryClip(clip)
|
||||
viewModel.uploadFinishedEvent.observe(
|
||||
viewLifecycleOwner,
|
||||
{
|
||||
it.consume { url ->
|
||||
val clipboard =
|
||||
requireContext().getSystemService(Context.CLIPBOARD_SERVICE) as ClipboardManager
|
||||
val clip = ClipData.newPlainText("Logs url", url)
|
||||
clipboard.setPrimaryClip(clip)
|
||||
|
||||
val activity = requireActivity() as MainActivity
|
||||
activity.showSnackBar(R.string.logs_url_copied_to_clipboard)
|
||||
val activity = requireActivity() as MainActivity
|
||||
activity.showSnackBar(R.string.logs_url_copied_to_clipboard)
|
||||
|
||||
AppUtils.shareUploadedLogsUrl(activity, url)
|
||||
AppUtils.shareUploadedLogsUrl(activity, url)
|
||||
}
|
||||
}
|
||||
})
|
||||
)
|
||||
|
||||
viewModel.uploadErrorEvent.observe(viewLifecycleOwner, {
|
||||
it.consume {
|
||||
val activity = requireActivity() as MainActivity
|
||||
activity.showSnackBar(R.string.logs_upload_failure)
|
||||
viewModel.uploadErrorEvent.observe(
|
||||
viewLifecycleOwner,
|
||||
{
|
||||
it.consume {
|
||||
val activity = requireActivity() as MainActivity
|
||||
activity.showSnackBar(R.string.logs_upload_failure)
|
||||
}
|
||||
}
|
||||
})
|
||||
)
|
||||
|
||||
viewModel.resetCompleteEvent.observe(viewLifecycleOwner, {
|
||||
it.consume {
|
||||
val activity = requireActivity() as MainActivity
|
||||
activity.showSnackBar(R.string.logs_reset_complete)
|
||||
viewModel.resetCompleteEvent.observe(
|
||||
viewLifecycleOwner,
|
||||
{
|
||||
it.consume {
|
||||
val activity = requireActivity() as MainActivity
|
||||
activity.showSnackBar(R.string.logs_reset_complete)
|
||||
}
|
||||
}
|
||||
})
|
||||
)
|
||||
|
||||
viewModel.setNightModeEvent.observe(viewLifecycleOwner, {
|
||||
it.consume { value ->
|
||||
AppCompatDelegate.setDefaultNightMode(
|
||||
when (value) {
|
||||
0 -> AppCompatDelegate.MODE_NIGHT_NO
|
||||
1 -> AppCompatDelegate.MODE_NIGHT_YES
|
||||
else -> AppCompatDelegate.MODE_NIGHT_FOLLOW_SYSTEM
|
||||
}
|
||||
)
|
||||
viewModel.setNightModeEvent.observe(
|
||||
viewLifecycleOwner,
|
||||
{
|
||||
it.consume { value ->
|
||||
AppCompatDelegate.setDefaultNightMode(
|
||||
when (value) {
|
||||
0 -> AppCompatDelegate.MODE_NIGHT_NO
|
||||
1 -> AppCompatDelegate.MODE_NIGHT_YES
|
||||
else -> AppCompatDelegate.MODE_NIGHT_FOLLOW_SYSTEM
|
||||
}
|
||||
)
|
||||
}
|
||||
}
|
||||
})
|
||||
)
|
||||
|
||||
viewModel.backgroundModeEnabled.value = !DeviceUtils.isAppUserRestricted(requireContext())
|
||||
|
||||
viewModel.goToBatterySettingsEvent.observe(viewLifecycleOwner, { it.consume {
|
||||
try {
|
||||
val intent = Intent("android.settings.IGNORE_BATTERY_OPTIMIZATION_SETTINGS")
|
||||
startActivity(intent)
|
||||
} catch (anfe: ActivityNotFoundException) {
|
||||
Log.e("[Advanced Settings] ActivityNotFound exception: ", anfe)
|
||||
}
|
||||
} })
|
||||
|
||||
viewModel.powerManagerSettingsVisibility.value = PowerManagerUtils.getDevicePowerManagerIntent(requireContext()) != null
|
||||
viewModel.goToPowerManagerSettingsEvent.observe(viewLifecycleOwner, { it.consume {
|
||||
val intent = PowerManagerUtils.getDevicePowerManagerIntent(requireActivity())
|
||||
if (intent != null) {
|
||||
try {
|
||||
startActivity(intent)
|
||||
} catch (se: SecurityException) {
|
||||
Log.e("[Advanced Settings] Security exception: ", se)
|
||||
viewModel.goToBatterySettingsEvent.observe(
|
||||
viewLifecycleOwner,
|
||||
{
|
||||
it.consume {
|
||||
try {
|
||||
val intent = Intent("android.settings.IGNORE_BATTERY_OPTIMIZATION_SETTINGS")
|
||||
startActivity(intent)
|
||||
} catch (anfe: ActivityNotFoundException) {
|
||||
Log.e("[Advanced Settings] ActivityNotFound exception: ", anfe)
|
||||
}
|
||||
}
|
||||
}
|
||||
} })
|
||||
)
|
||||
|
||||
viewModel.goToAndroidSettingsEvent.observe(viewLifecycleOwner, { it.consume {
|
||||
val intent = Intent()
|
||||
intent.action = Settings.ACTION_APPLICATION_DETAILS_SETTINGS
|
||||
intent.addCategory(Intent.CATEGORY_DEFAULT)
|
||||
intent.data = Uri.parse("package:${requireContext().packageName}")
|
||||
intent.addFlags(Intent.FLAG_ACTIVITY_NO_HISTORY)
|
||||
ContextCompat.startActivity(requireContext(), intent, null)
|
||||
} })
|
||||
viewModel.powerManagerSettingsVisibility.value = PowerManagerUtils.getDevicePowerManagerIntent(requireContext()) != null
|
||||
viewModel.goToPowerManagerSettingsEvent.observe(
|
||||
viewLifecycleOwner,
|
||||
{
|
||||
it.consume {
|
||||
val intent = PowerManagerUtils.getDevicePowerManagerIntent(requireActivity())
|
||||
if (intent != null) {
|
||||
try {
|
||||
startActivity(intent)
|
||||
} catch (se: SecurityException) {
|
||||
Log.e("[Advanced Settings] Security exception: ", se)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
)
|
||||
|
||||
viewModel.goToAndroidSettingsEvent.observe(
|
||||
viewLifecycleOwner,
|
||||
{
|
||||
it.consume {
|
||||
val intent = Intent()
|
||||
intent.action = Settings.ACTION_APPLICATION_DETAILS_SETTINGS
|
||||
intent.addCategory(Intent.CATEGORY_DEFAULT)
|
||||
intent.data = Uri.parse("package:${requireContext().packageName}")
|
||||
intent.addFlags(Intent.FLAG_ACTIVITY_NO_HISTORY)
|
||||
ContextCompat.startActivity(requireContext(), intent, null)
|
||||
}
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
override fun goBack() {
|
||||
|
|
|
@ -60,19 +60,25 @@ class AudioSettingsFragment : GenericFragment<SettingsAudioFragmentBinding>() {
|
|||
|
||||
binding.setBackClickListener { goBack() }
|
||||
|
||||
viewModel.askAudioRecordPermissionForEchoCancellerCalibrationEvent.observe(viewLifecycleOwner, {
|
||||
it.consume {
|
||||
Log.i("[Audio Settings] Asking for RECORD_AUDIO permission for echo canceller calibration")
|
||||
requestPermissions(arrayOf(android.Manifest.permission.RECORD_AUDIO), 1)
|
||||
viewModel.askAudioRecordPermissionForEchoCancellerCalibrationEvent.observe(
|
||||
viewLifecycleOwner,
|
||||
{
|
||||
it.consume {
|
||||
Log.i("[Audio Settings] Asking for RECORD_AUDIO permission for echo canceller calibration")
|
||||
requestPermissions(arrayOf(android.Manifest.permission.RECORD_AUDIO), 1)
|
||||
}
|
||||
}
|
||||
})
|
||||
)
|
||||
|
||||
viewModel.askAudioRecordPermissionForEchoTesterEvent.observe(viewLifecycleOwner, {
|
||||
it.consume {
|
||||
Log.i("[Audio Settings] Asking for RECORD_AUDIO permission for echo tester")
|
||||
requestPermissions(arrayOf(android.Manifest.permission.RECORD_AUDIO), 2)
|
||||
viewModel.askAudioRecordPermissionForEchoTesterEvent.observe(
|
||||
viewLifecycleOwner,
|
||||
{
|
||||
it.consume {
|
||||
Log.i("[Audio Settings] Asking for RECORD_AUDIO permission for echo tester")
|
||||
requestPermissions(arrayOf(android.Manifest.permission.RECORD_AUDIO), 2)
|
||||
}
|
||||
}
|
||||
})
|
||||
)
|
||||
|
||||
initAudioCodecsList()
|
||||
|
||||
|
@ -107,11 +113,14 @@ class AudioSettingsFragment : GenericFragment<SettingsAudioFragmentBinding>() {
|
|||
binding.setVariable(BR.title, payload.mimeType)
|
||||
binding.setVariable(BR.subtitle, "${payload.clockRate} Hz")
|
||||
binding.setVariable(BR.checked, payload.enabled())
|
||||
binding.setVariable(BR.listener, object : SettingListenerStub() {
|
||||
override fun onBoolValueChanged(newValue: Boolean) {
|
||||
payload.enable(newValue)
|
||||
binding.setVariable(
|
||||
BR.listener,
|
||||
object : SettingListenerStub() {
|
||||
override fun onBoolValueChanged(newValue: Boolean) {
|
||||
payload.enable(newValue)
|
||||
}
|
||||
}
|
||||
})
|
||||
)
|
||||
binding.lifecycleOwner = this
|
||||
list.add(binding)
|
||||
}
|
||||
|
|
|
@ -57,31 +57,39 @@ class CallSettingsFragment : GenericFragment<SettingsCallFragmentBinding>() {
|
|||
|
||||
binding.setBackClickListener { goBack() }
|
||||
|
||||
viewModel.systemWideOverlayEnabledEvent.observe(viewLifecycleOwner, {
|
||||
it.consume {
|
||||
if (!Compatibility.canDrawOverlay(requireContext())) {
|
||||
val intent = Intent("android.settings.action.MANAGE_OVERLAY_PERMISSION", Uri.parse("package:${requireContext().packageName}"))
|
||||
startActivityForResult(intent, 0)
|
||||
viewModel.systemWideOverlayEnabledEvent.observe(
|
||||
viewLifecycleOwner,
|
||||
{
|
||||
it.consume {
|
||||
if (!Compatibility.canDrawOverlay(requireContext())) {
|
||||
val intent = Intent("android.settings.action.MANAGE_OVERLAY_PERMISSION", Uri.parse("package:${requireContext().packageName}"))
|
||||
startActivityForResult(intent, 0)
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
)
|
||||
|
||||
viewModel.goToAndroidNotificationSettingsEvent.observe(viewLifecycleOwner, { it.consume {
|
||||
if (Build.VERSION.SDK_INT >= Version.API26_O_80) {
|
||||
val i = Intent()
|
||||
i.action = Settings.ACTION_CHANNEL_NOTIFICATION_SETTINGS
|
||||
i.putExtra(Settings.EXTRA_APP_PACKAGE, requireContext().packageName)
|
||||
i.putExtra(
|
||||
Settings.EXTRA_CHANNEL_ID,
|
||||
getString(R.string.notification_channel_service_id)
|
||||
)
|
||||
i.addCategory(Intent.CATEGORY_DEFAULT)
|
||||
i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
|
||||
i.addFlags(Intent.FLAG_ACTIVITY_NO_HISTORY)
|
||||
i.addFlags(Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS)
|
||||
startActivity(i)
|
||||
viewModel.goToAndroidNotificationSettingsEvent.observe(
|
||||
viewLifecycleOwner,
|
||||
{
|
||||
it.consume {
|
||||
if (Build.VERSION.SDK_INT >= Version.API26_O_80) {
|
||||
val i = Intent()
|
||||
i.action = Settings.ACTION_CHANNEL_NOTIFICATION_SETTINGS
|
||||
i.putExtra(Settings.EXTRA_APP_PACKAGE, requireContext().packageName)
|
||||
i.putExtra(
|
||||
Settings.EXTRA_CHANNEL_ID,
|
||||
getString(R.string.notification_channel_service_id)
|
||||
)
|
||||
i.addCategory(Intent.CATEGORY_DEFAULT)
|
||||
i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
|
||||
i.addFlags(Intent.FLAG_ACTIVITY_NO_HISTORY)
|
||||
i.addFlags(Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS)
|
||||
startActivity(i)
|
||||
}
|
||||
}
|
||||
}
|
||||
} })
|
||||
)
|
||||
}
|
||||
|
||||
override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
|
||||
|
|
|
@ -56,32 +56,40 @@ class ChatSettingsFragment : GenericFragment<SettingsChatFragmentBinding>() {
|
|||
|
||||
binding.setBackClickListener { goBack() }
|
||||
|
||||
viewModel.launcherShortcutsEvent.observe(viewLifecycleOwner, {
|
||||
it.consume { newValue ->
|
||||
if (newValue) {
|
||||
Compatibility.createShortcutsToChatRooms(requireContext())
|
||||
} else {
|
||||
Compatibility.removeShortcuts(requireContext())
|
||||
viewModel.launcherShortcutsEvent.observe(
|
||||
viewLifecycleOwner,
|
||||
{
|
||||
it.consume { newValue ->
|
||||
if (newValue) {
|
||||
Compatibility.createShortcutsToChatRooms(requireContext())
|
||||
} else {
|
||||
Compatibility.removeShortcuts(requireContext())
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
)
|
||||
|
||||
viewModel.goToAndroidNotificationSettingsEvent.observe(viewLifecycleOwner, { it.consume {
|
||||
if (Build.VERSION.SDK_INT >= Version.API26_O_80) {
|
||||
val i = Intent()
|
||||
i.action = Settings.ACTION_CHANNEL_NOTIFICATION_SETTINGS
|
||||
i.putExtra(Settings.EXTRA_APP_PACKAGE, requireContext().packageName)
|
||||
i.putExtra(
|
||||
Settings.EXTRA_CHANNEL_ID,
|
||||
getString(R.string.notification_channel_chat_id)
|
||||
)
|
||||
i.addCategory(Intent.CATEGORY_DEFAULT)
|
||||
i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
|
||||
i.addFlags(Intent.FLAG_ACTIVITY_NO_HISTORY)
|
||||
i.addFlags(Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS)
|
||||
startActivity(i)
|
||||
viewModel.goToAndroidNotificationSettingsEvent.observe(
|
||||
viewLifecycleOwner,
|
||||
{
|
||||
it.consume {
|
||||
if (Build.VERSION.SDK_INT >= Version.API26_O_80) {
|
||||
val i = Intent()
|
||||
i.action = Settings.ACTION_CHANNEL_NOTIFICATION_SETTINGS
|
||||
i.putExtra(Settings.EXTRA_APP_PACKAGE, requireContext().packageName)
|
||||
i.putExtra(
|
||||
Settings.EXTRA_CHANNEL_ID,
|
||||
getString(R.string.notification_channel_chat_id)
|
||||
)
|
||||
i.addCategory(Intent.CATEGORY_DEFAULT)
|
||||
i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
|
||||
i.addFlags(Intent.FLAG_ACTIVITY_NO_HISTORY)
|
||||
i.addFlags(Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS)
|
||||
startActivity(i)
|
||||
}
|
||||
}
|
||||
}
|
||||
} })
|
||||
)
|
||||
}
|
||||
|
||||
override fun goBack() {
|
||||
|
|
|
@ -57,25 +57,31 @@ class ContactsSettingsFragment : GenericFragment<SettingsContactsFragmentBinding
|
|||
|
||||
binding.setBackClickListener { goBack() }
|
||||
|
||||
viewModel.launcherShortcutsEvent.observe(viewLifecycleOwner, {
|
||||
it.consume { newValue ->
|
||||
if (newValue) {
|
||||
Compatibility.createShortcutsToContacts(requireContext())
|
||||
} else {
|
||||
Compatibility.removeShortcuts(requireContext())
|
||||
if (corePreferences.chatRoomShortcuts) {
|
||||
Compatibility.createShortcutsToChatRooms(requireContext())
|
||||
viewModel.launcherShortcutsEvent.observe(
|
||||
viewLifecycleOwner,
|
||||
{
|
||||
it.consume { newValue ->
|
||||
if (newValue) {
|
||||
Compatibility.createShortcutsToContacts(requireContext())
|
||||
} else {
|
||||
Compatibility.removeShortcuts(requireContext())
|
||||
if (corePreferences.chatRoomShortcuts) {
|
||||
Compatibility.createShortcutsToChatRooms(requireContext())
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
)
|
||||
|
||||
viewModel.askWriteContactsPermissionForPresenceStorageEvent.observe(viewLifecycleOwner, {
|
||||
it.consume {
|
||||
Log.i("[Contacts Settings] Asking for WRITE_CONTACTS permission to be able to store presence")
|
||||
requestPermissions(arrayOf(android.Manifest.permission.WRITE_CONTACTS), 1)
|
||||
viewModel.askWriteContactsPermissionForPresenceStorageEvent.observe(
|
||||
viewLifecycleOwner,
|
||||
{
|
||||
it.consume {
|
||||
Log.i("[Contacts Settings] Asking for WRITE_CONTACTS permission to be able to store presence")
|
||||
requestPermissions(arrayOf(android.Manifest.permission.WRITE_CONTACTS), 1)
|
||||
}
|
||||
}
|
||||
})
|
||||
)
|
||||
|
||||
if (!PermissionHelper.required(requireContext()).hasReadContactsPermission()) {
|
||||
Log.i("[Contacts Settings] Asking for READ_CONTACTS permission")
|
||||
|
|
|
@ -57,25 +57,31 @@ class SettingsFragment : SecureFragment<SettingsFragmentBinding>() {
|
|||
|
||||
view.doOnPreDraw { sharedViewModel.canSlidingPaneBeClosed.value = binding.slidingPane.isSlideable }
|
||||
|
||||
sharedViewModel.closeSlidingPaneEvent.observe(viewLifecycleOwner, {
|
||||
it.consume {
|
||||
if (!binding.slidingPane.closePane()) {
|
||||
goBack()
|
||||
}
|
||||
}
|
||||
})
|
||||
sharedViewModel.layoutChangedEvent.observe(viewLifecycleOwner, {
|
||||
it.consume {
|
||||
sharedViewModel.canSlidingPaneBeClosed.value = binding.slidingPane.isSlideable
|
||||
if (binding.slidingPane.isSlideable) {
|
||||
val navHostFragment = childFragmentManager.findFragmentById(R.id.settings_nav_container) as NavHostFragment
|
||||
if (navHostFragment.navController.currentDestination?.id == R.id.emptySettingsFragment) {
|
||||
Log.i("[Settings] Foldable device has been folded, closing side pane with empty fragment")
|
||||
binding.slidingPane.closePane()
|
||||
sharedViewModel.closeSlidingPaneEvent.observe(
|
||||
viewLifecycleOwner,
|
||||
{
|
||||
it.consume {
|
||||
if (!binding.slidingPane.closePane()) {
|
||||
goBack()
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
)
|
||||
sharedViewModel.layoutChangedEvent.observe(
|
||||
viewLifecycleOwner,
|
||||
{
|
||||
it.consume {
|
||||
sharedViewModel.canSlidingPaneBeClosed.value = binding.slidingPane.isSlideable
|
||||
if (binding.slidingPane.isSlideable) {
|
||||
val navHostFragment = childFragmentManager.findFragmentById(R.id.settings_nav_container) as NavHostFragment
|
||||
if (navHostFragment.navController.currentDestination?.id == R.id.emptySettingsFragment) {
|
||||
Log.i("[Settings] Foldable device has been folded, closing side pane with empty fragment")
|
||||
binding.slidingPane.closePane()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
)
|
||||
binding.slidingPane.lockMode = SlidingPaneLayout.LOCK_MODE_LOCKED
|
||||
|
||||
/* End of shared view model & sliding pane related */
|
||||
|
@ -85,10 +91,13 @@ class SettingsFragment : SecureFragment<SettingsFragmentBinding>() {
|
|||
|
||||
binding.setBackClickListener { goBack() }
|
||||
|
||||
sharedViewModel.accountRemoved.observe(viewLifecycleOwner, {
|
||||
Log.i("[Settings] Account removed, update accounts list")
|
||||
viewModel.updateAccountsList()
|
||||
})
|
||||
sharedViewModel.accountRemoved.observe(
|
||||
viewLifecycleOwner,
|
||||
{
|
||||
Log.i("[Settings] Account removed, update accounts list")
|
||||
viewModel.updateAccountsList()
|
||||
}
|
||||
)
|
||||
|
||||
val identity = arguments?.getString("Identity")
|
||||
if (identity != null) {
|
||||
|
|
|
@ -93,15 +93,18 @@ class VideoSettingsFragment : GenericFragment<SettingsVideoFragmentBinding>() {
|
|||
binding.setVariable(BR.text_subtitle, "")
|
||||
binding.setVariable(BR.defaultValue, payload.recvFmtp)
|
||||
binding.setVariable(BR.checked, payload.enabled())
|
||||
binding.setVariable(BR.listener, object : SettingListenerStub() {
|
||||
override fun onBoolValueChanged(newValue: Boolean) {
|
||||
payload.enable(newValue)
|
||||
}
|
||||
binding.setVariable(
|
||||
BR.listener,
|
||||
object : SettingListenerStub() {
|
||||
override fun onBoolValueChanged(newValue: Boolean) {
|
||||
payload.enable(newValue)
|
||||
}
|
||||
|
||||
override fun onTextValueChanged(newValue: String) {
|
||||
payload.recvFmtp = newValue
|
||||
override fun onTextValueChanged(newValue: String) {
|
||||
payload.recvFmtp = newValue
|
||||
}
|
||||
}
|
||||
})
|
||||
)
|
||||
binding.lifecycleOwner = this
|
||||
list.add(binding)
|
||||
}
|
||||
|
|
|
@ -64,8 +64,8 @@ class CallSettingsViewModel : GenericSettingsViewModel() {
|
|||
|
||||
val fullScreenListener = object : SettingListenerStub() {
|
||||
override fun onBoolValueChanged(newValue: Boolean) {
|
||||
prefs.fullScreenCallUI = newValue
|
||||
}
|
||||
prefs.fullScreenCallUI = newValue
|
||||
}
|
||||
}
|
||||
val fullScreen = MutableLiveData<Boolean>()
|
||||
|
||||
|
|
|
@ -67,10 +67,13 @@ class SideMenuFragment : GenericFragment<SideMenuFragmentBinding>() {
|
|||
ViewModelProvider(this).get(SharedMainViewModel::class.java)
|
||||
}
|
||||
|
||||
sharedViewModel.accountRemoved.observe(viewLifecycleOwner, {
|
||||
Log.i("[Side Menu] Account removed, update accounts list")
|
||||
viewModel.updateAccountsList()
|
||||
})
|
||||
sharedViewModel.accountRemoved.observe(
|
||||
viewLifecycleOwner,
|
||||
{
|
||||
Log.i("[Side Menu] Account removed, update accounts list")
|
||||
viewModel.updateAccountsList()
|
||||
}
|
||||
)
|
||||
|
||||
viewModel.accountsSettingsListener = object : SettingListenerStub() {
|
||||
override fun onAccountClicked(identity: String) {
|
||||
|
|
|
@ -49,8 +49,8 @@ class CallOverlayViewModel : ViewModel() {
|
|||
|
||||
init {
|
||||
displayCallOverlay.value = corePreferences.showCallOverlay &&
|
||||
!corePreferences.systemWideCallOverlay &&
|
||||
coreContext.core.callsNb > 0
|
||||
!corePreferences.systemWideCallOverlay &&
|
||||
coreContext.core.callsNb > 0
|
||||
|
||||
coreContext.core.addListener(listener)
|
||||
}
|
||||
|
|
|
@ -315,7 +315,8 @@ class ContactsManager(private val context: Context) {
|
|||
val accounts = accountManager.getAccountsByType(context.getString(R.string.sync_account_type))
|
||||
if (accounts.isEmpty()) {
|
||||
val newAccount = Account(
|
||||
context.getString(R.string.sync_account_name), context.getString(
|
||||
context.getString(R.string.sync_account_name),
|
||||
context.getString(
|
||||
R.string.sync_account_type
|
||||
)
|
||||
)
|
||||
|
|
|
@ -178,10 +178,13 @@ class CoreContext(val context: Context, coreConfig: Config) {
|
|||
} else {
|
||||
Log.i("[Context] Scheduling auto answering in $autoAnswerDelay milliseconds")
|
||||
val mainThreadHandler = Handler(Looper.getMainLooper())
|
||||
mainThreadHandler.postDelayed({
|
||||
Log.w("[Context] Auto answering call")
|
||||
answerCall(call)
|
||||
}, autoAnswerDelay.toLong())
|
||||
mainThreadHandler.postDelayed(
|
||||
{
|
||||
Log.w("[Context] Auto answering call")
|
||||
answerCall(call)
|
||||
},
|
||||
autoAnswerDelay.toLong()
|
||||
)
|
||||
}
|
||||
}
|
||||
} else if (state == Call.State.OutgoingInit) {
|
||||
|
@ -214,7 +217,8 @@ class CoreContext(val context: Context, coreConfig: Config) {
|
|||
// Do not turn speaker on when video is enabled if headset or bluetooth is used
|
||||
if (!AudioRouteUtils.isHeadsetAudioRouteAvailable() && !AudioRouteUtils.isBluetoothAudioRouteCurrentlyUsed(
|
||||
call
|
||||
)) {
|
||||
)
|
||||
) {
|
||||
Log.i("[Context] Video enabled and no wired headset not bluetooth in use, routing audio to speaker")
|
||||
AudioRouteUtils.routeAudioToSpeaker(call)
|
||||
}
|
||||
|
@ -237,8 +241,9 @@ class CoreContext(val context: Context, coreConfig: Config) {
|
|||
}
|
||||
callErrorMessageResourceId.value = Event(message)
|
||||
} else if (state == Call.State.End &&
|
||||
call.dir == Call.Dir.Outgoing &&
|
||||
call.errorInfo.reason == Reason.Declined) {
|
||||
call.dir == Call.Dir.Outgoing &&
|
||||
call.errorInfo.reason == Reason.Declined
|
||||
) {
|
||||
Log.i("[Context] Call has been declined")
|
||||
val message = context.getString(R.string.call_error_declined)
|
||||
callErrorMessageResourceId.value = Event(message)
|
||||
|
@ -597,7 +602,8 @@ class CoreContext(val context: Context, coreConfig: Config) {
|
|||
}
|
||||
MotionEvent.ACTION_UP -> {
|
||||
if (abs(overlayX - params.x) < CorePreferences.OVERLAY_CLICK_SENSITIVITY &&
|
||||
abs(overlayY - params.y) < CorePreferences.OVERLAY_CLICK_SENSITIVITY) {
|
||||
abs(overlayY - params.y) < CorePreferences.OVERLAY_CLICK_SENSITIVITY
|
||||
) {
|
||||
view.performClick()
|
||||
}
|
||||
overlayX = params.x.toFloat()
|
||||
|
|
|
@ -151,8 +151,9 @@ class NotificationsManager(private val context: Context) {
|
|||
}
|
||||
|
||||
if (message.contents.find { content ->
|
||||
content.isFile or content.isFileTransfer or content.isText
|
||||
} == null) {
|
||||
content.isFile or content.isFileTransfer or content.isText
|
||||
} == null
|
||||
) {
|
||||
Log.w("[Notifications Manager] Received message with neither text or attachment, do not notify")
|
||||
return
|
||||
}
|
||||
|
@ -291,7 +292,7 @@ class NotificationsManager(private val context: Context) {
|
|||
currentForegroundServiceNotificationId = notificationId
|
||||
service?.startForeground(currentForegroundServiceNotificationId, callNotification)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun stopForegroundNotification() {
|
||||
if (service != null) {
|
||||
|
@ -462,7 +463,8 @@ class NotificationsManager(private val context: Context) {
|
|||
.createPendingIntent()
|
||||
|
||||
val builder = NotificationCompat.Builder(
|
||||
context, context.getString(R.string.notification_channel_missed_call_id))
|
||||
context, context.getString(R.string.notification_channel_missed_call_id)
|
||||
)
|
||||
.setContentTitle(context.getString(R.string.missed_call_notification_title))
|
||||
.setContentText(body)
|
||||
.setSmallIcon(R.drawable.topbar_missed_call_notification)
|
||||
|
@ -546,7 +548,8 @@ class NotificationsManager(private val context: Context) {
|
|||
val pendingIntent = PendingIntent.getActivity(context, 0, callNotificationIntent, PendingIntent.FLAG_UPDATE_CURRENT)
|
||||
|
||||
val builder = NotificationCompat.Builder(
|
||||
context, channelToUse)
|
||||
context, channelToUse
|
||||
)
|
||||
.setContentTitle(contact?.fullName ?: displayName)
|
||||
.setContentText(context.getString(stringResourceId))
|
||||
.setSmallIcon(iconResourceId)
|
||||
|
|
|
@ -106,7 +106,8 @@ class AudioRouteUtils {
|
|||
fun isBluetoothAudioRouteAvailable(): Boolean {
|
||||
for (audioDevice in coreContext.core.audioDevices) {
|
||||
if (audioDevice.type == AudioDevice.Type.Bluetooth &&
|
||||
audioDevice.hasCapability(AudioDevice.Capabilities.CapabilityPlay)) {
|
||||
audioDevice.hasCapability(AudioDevice.Capabilities.CapabilityPlay)
|
||||
) {
|
||||
Log.i("[Audio Route Helper] Found bluetooth audio device [${audioDevice.deviceName}]")
|
||||
return true
|
||||
}
|
||||
|
@ -117,7 +118,8 @@ class AudioRouteUtils {
|
|||
fun isHeadsetAudioRouteAvailable(): Boolean {
|
||||
for (audioDevice in coreContext.core.audioDevices) {
|
||||
if ((audioDevice.type == AudioDevice.Type.Headset || audioDevice.type == AudioDevice.Type.Headphones) &&
|
||||
audioDevice.hasCapability(AudioDevice.Capabilities.CapabilityPlay)) {
|
||||
audioDevice.hasCapability(AudioDevice.Capabilities.CapabilityPlay)
|
||||
) {
|
||||
Log.i("[Audio Route Helper] Found headset/headphones audio device [${audioDevice.deviceName}]")
|
||||
return true
|
||||
}
|
||||
|
|
|
@ -265,9 +265,9 @@ class FileUtils {
|
|||
context.contentResolver.openInputStream(uri)
|
||||
Log.i(
|
||||
"[File Utils] Trying to copy file from " +
|
||||
uri.toString() +
|
||||
" to local file " +
|
||||
localFile.absolutePath
|
||||
uri.toString() +
|
||||
" to local file " +
|
||||
localFile.absolutePath
|
||||
)
|
||||
coroutineScope {
|
||||
val deferred = async { copyToFile(remoteFile, localFile) }
|
||||
|
@ -417,7 +417,8 @@ class FileUtils {
|
|||
} catch (e: Exception) {
|
||||
Log.e(
|
||||
"[Chat Message] Couldn't get URI for file $file using file provider ${context.getString(
|
||||
R.string.file_provider)}"
|
||||
R.string.file_provider
|
||||
)}"
|
||||
)
|
||||
Uri.parse(path)
|
||||
}
|
||||
|
|
|
@ -67,8 +67,8 @@ class LinphoneUtils {
|
|||
fun isLimeAvailable(): Boolean {
|
||||
val core = coreContext.core
|
||||
return core.limeX3DhAvailable() && core.limeX3DhEnabled() &&
|
||||
core.limeX3DhServerUrl != null &&
|
||||
core.defaultAccount?.params?.conferenceFactoryUri != null
|
||||
core.limeX3DhServerUrl != null &&
|
||||
core.defaultAccount?.params?.conferenceFactoryUri != null
|
||||
}
|
||||
|
||||
fun isGroupChatAvailable(): Boolean {
|
||||
|
@ -143,10 +143,14 @@ class LinphoneUtils {
|
|||
}
|
||||
|
||||
fun isCallLogMissed(callLog: CallLog): Boolean {
|
||||
return (callLog.dir == Call.Dir.Incoming &&
|
||||
(callLog.status == Call.Status.Missed ||
|
||||
callLog.status == Call.Status.Aborted ||
|
||||
callLog.status == Call.Status.EarlyAborted))
|
||||
return (
|
||||
callLog.dir == Call.Dir.Incoming &&
|
||||
(
|
||||
callLog.status == Call.Status.Missed ||
|
||||
callLog.status == Call.Status.Aborted ||
|
||||
callLog.status == Call.Status.EarlyAborted
|
||||
)
|
||||
)
|
||||
}
|
||||
|
||||
fun getChatRoomId(localAddress: String, remoteAddress: String): String {
|
||||
|
|
|
@ -93,8 +93,8 @@ class TimestampUtils {
|
|||
cal2: Calendar
|
||||
): Boolean {
|
||||
return cal1[Calendar.ERA] == cal2[Calendar.ERA] &&
|
||||
cal1[Calendar.YEAR] == cal2[Calendar.YEAR] &&
|
||||
cal1[Calendar.DAY_OF_YEAR] == cal2[Calendar.DAY_OF_YEAR]
|
||||
cal1[Calendar.YEAR] == cal2[Calendar.YEAR] &&
|
||||
cal1[Calendar.DAY_OF_YEAR] == cal2[Calendar.DAY_OF_YEAR]
|
||||
}
|
||||
|
||||
private fun isSameYear(
|
||||
|
@ -102,7 +102,7 @@ class TimestampUtils {
|
|||
cal2: Calendar
|
||||
): Boolean {
|
||||
return cal1[Calendar.ERA] == cal2[Calendar.ERA] &&
|
||||
cal1[Calendar.YEAR] == cal2[Calendar.YEAR]
|
||||
cal1[Calendar.YEAR] == cal2[Calendar.YEAR]
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -63,7 +63,8 @@ class VoiceRecordProgressBar : View {
|
|||
context.theme.obtainStyledAttributes(
|
||||
attrs,
|
||||
R.styleable.VoiceRecordProgressBar,
|
||||
0, 0).apply {
|
||||
0, 0
|
||||
).apply {
|
||||
|
||||
try {
|
||||
val drawable = getDrawable(R.styleable.VoiceRecordProgressBar_progressDrawable)
|
||||
|
|
Loading…
Reference in a new issue