Moved lambdas arguments out of parenthesis
This commit is contained in:
parent
81884dd218
commit
a0ebeb1fea
47 changed files with 1238 additions and 1350 deletions
|
@ -79,8 +79,8 @@ class AccountLoginFragment : AbstractPhoneFragment<AssistantAccountLoginFragment
|
|||
}
|
||||
|
||||
viewModel.goToSmsValidationEvent.observe(
|
||||
viewLifecycleOwner,
|
||||
{
|
||||
viewLifecycleOwner
|
||||
) {
|
||||
it.consume {
|
||||
val args = Bundle()
|
||||
args.putBoolean("IsLogin", true)
|
||||
|
@ -88,11 +88,10 @@ class AccountLoginFragment : AbstractPhoneFragment<AssistantAccountLoginFragment
|
|||
navigateToPhoneAccountValidation(args)
|
||||
}
|
||||
}
|
||||
)
|
||||
|
||||
viewModel.leaveAssistantEvent.observe(
|
||||
viewLifecycleOwner,
|
||||
{
|
||||
viewLifecycleOwner
|
||||
) {
|
||||
it.consume {
|
||||
coreContext.contactsManager.updateLocalContacts()
|
||||
|
||||
|
@ -103,11 +102,10 @@ class AccountLoginFragment : AbstractPhoneFragment<AssistantAccountLoginFragment
|
|||
}
|
||||
}
|
||||
}
|
||||
)
|
||||
|
||||
viewModel.invalidCredentialsEvent.observe(
|
||||
viewLifecycleOwner,
|
||||
{
|
||||
viewLifecycleOwner
|
||||
) {
|
||||
it.consume {
|
||||
val dialogViewModel =
|
||||
DialogViewModel(getString(R.string.assistant_error_invalid_credentials))
|
||||
|
@ -129,16 +127,14 @@ class AccountLoginFragment : AbstractPhoneFragment<AssistantAccountLoginFragment
|
|||
dialog.show()
|
||||
}
|
||||
}
|
||||
)
|
||||
|
||||
viewModel.onErrorEvent.observe(
|
||||
viewLifecycleOwner,
|
||||
{
|
||||
viewLifecycleOwner
|
||||
) {
|
||||
it.consume { message ->
|
||||
(requireActivity() as AssistantActivity).showSnackBar(message)
|
||||
}
|
||||
}
|
||||
)
|
||||
|
||||
if (Version.sdkAboveOrEqual(Version.API23_MARSHMALLOW_60)) {
|
||||
checkPermissions()
|
||||
|
|
|
@ -48,13 +48,12 @@ class EchoCancellerCalibrationFragment : GenericFragment<AssistantEchoCancellerC
|
|||
binding.viewModel = viewModel
|
||||
|
||||
viewModel.echoCalibrationTerminated.observe(
|
||||
viewLifecycleOwner,
|
||||
{
|
||||
viewLifecycleOwner
|
||||
) {
|
||||
it.consume {
|
||||
requireActivity().finish()
|
||||
}
|
||||
}
|
||||
)
|
||||
|
||||
if (!PermissionHelper.required(requireContext()).hasRecordAudioPermission()) {
|
||||
Log.i("[Echo Canceller Calibration] Asking for RECORD_AUDIO permission")
|
||||
|
|
|
@ -50,21 +50,19 @@ class EmailAccountCreationFragment : GenericFragment<AssistantEmailAccountCreati
|
|||
binding.viewModel = viewModel
|
||||
|
||||
viewModel.goToEmailValidationEvent.observe(
|
||||
viewLifecycleOwner,
|
||||
{
|
||||
viewLifecycleOwner
|
||||
) {
|
||||
it.consume {
|
||||
navigateToEmailAccountValidation()
|
||||
}
|
||||
}
|
||||
)
|
||||
|
||||
viewModel.onErrorEvent.observe(
|
||||
viewLifecycleOwner,
|
||||
{
|
||||
viewLifecycleOwner
|
||||
) {
|
||||
it.consume { message ->
|
||||
(requireActivity() as AssistantActivity).showSnackBar(message)
|
||||
}
|
||||
}
|
||||
)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -49,8 +49,8 @@ class EmailAccountValidationFragment : GenericFragment<AssistantEmailAccountVali
|
|||
binding.viewModel = viewModel
|
||||
|
||||
viewModel.leaveAssistantEvent.observe(
|
||||
viewLifecycleOwner,
|
||||
{
|
||||
viewLifecycleOwner
|
||||
) {
|
||||
it.consume {
|
||||
coreContext.contactsManager.updateLocalContacts()
|
||||
|
||||
|
@ -61,15 +61,13 @@ class EmailAccountValidationFragment : GenericFragment<AssistantEmailAccountVali
|
|||
navigateToAccountLinking(args)
|
||||
}
|
||||
}
|
||||
)
|
||||
|
||||
viewModel.onErrorEvent.observe(
|
||||
viewLifecycleOwner,
|
||||
{
|
||||
viewLifecycleOwner
|
||||
) {
|
||||
it.consume { message ->
|
||||
(requireActivity() as AssistantActivity).showSnackBar(message)
|
||||
}
|
||||
}
|
||||
)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -54,8 +54,8 @@ class GenericAccountLoginFragment : GenericFragment<AssistantGenericAccountLogin
|
|||
binding.viewModel = viewModel
|
||||
|
||||
viewModel.leaveAssistantEvent.observe(
|
||||
viewLifecycleOwner,
|
||||
{
|
||||
viewLifecycleOwner
|
||||
) {
|
||||
it.consume {
|
||||
coreContext.contactsManager.updateLocalContacts()
|
||||
|
||||
|
@ -66,13 +66,13 @@ class GenericAccountLoginFragment : GenericFragment<AssistantGenericAccountLogin
|
|||
}
|
||||
}
|
||||
}
|
||||
)
|
||||
|
||||
viewModel.invalidCredentialsEvent.observe(
|
||||
viewLifecycleOwner,
|
||||
{
|
||||
viewLifecycleOwner
|
||||
) {
|
||||
it.consume {
|
||||
val dialogViewModel = DialogViewModel(getString(R.string.assistant_error_invalid_credentials))
|
||||
val dialogViewModel =
|
||||
DialogViewModel(getString(R.string.assistant_error_invalid_credentials))
|
||||
val dialog: Dialog = DialogUtils.getDialog(requireContext(), dialogViewModel)
|
||||
|
||||
dialogViewModel.showCancelButton {
|
||||
|
@ -91,15 +91,13 @@ class GenericAccountLoginFragment : GenericFragment<AssistantGenericAccountLogin
|
|||
dialog.show()
|
||||
}
|
||||
}
|
||||
)
|
||||
|
||||
viewModel.onErrorEvent.observe(
|
||||
viewLifecycleOwner,
|
||||
{
|
||||
viewLifecycleOwner
|
||||
) {
|
||||
it.consume { message ->
|
||||
(requireActivity() as AssistantActivity).showSnackBar(message)
|
||||
}
|
||||
}
|
||||
)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -62,8 +62,8 @@ class PhoneAccountCreationFragment :
|
|||
}
|
||||
|
||||
viewModel.goToSmsValidationEvent.observe(
|
||||
viewLifecycleOwner,
|
||||
{
|
||||
viewLifecycleOwner
|
||||
) {
|
||||
it.consume {
|
||||
val args = Bundle()
|
||||
args.putBoolean("IsCreation", true)
|
||||
|
@ -71,16 +71,14 @@ class PhoneAccountCreationFragment :
|
|||
navigateToPhoneAccountValidation(args)
|
||||
}
|
||||
}
|
||||
)
|
||||
|
||||
viewModel.onErrorEvent.observe(
|
||||
viewLifecycleOwner,
|
||||
{
|
||||
viewLifecycleOwner
|
||||
) {
|
||||
it.consume { message ->
|
||||
(requireActivity() as AssistantActivity).showSnackBar(message)
|
||||
}
|
||||
}
|
||||
)
|
||||
|
||||
if (Version.sdkAboveOrEqual(Version.API23_MARSHMALLOW_60)) {
|
||||
checkPermissions()
|
||||
|
|
|
@ -73,8 +73,8 @@ class PhoneAccountLinkingFragment : AbstractPhoneFragment<AssistantPhoneAccountL
|
|||
}
|
||||
|
||||
viewModel.goToSmsValidationEvent.observe(
|
||||
viewLifecycleOwner,
|
||||
{
|
||||
viewLifecycleOwner
|
||||
) {
|
||||
it.consume {
|
||||
val args = Bundle()
|
||||
args.putBoolean("IsLinking", true)
|
||||
|
@ -82,11 +82,10 @@ class PhoneAccountLinkingFragment : AbstractPhoneFragment<AssistantPhoneAccountL
|
|||
navigateToPhoneAccountValidation(args)
|
||||
}
|
||||
}
|
||||
)
|
||||
|
||||
viewModel.leaveAssistantEvent.observe(
|
||||
viewLifecycleOwner,
|
||||
{
|
||||
viewLifecycleOwner
|
||||
) {
|
||||
it.consume {
|
||||
if (LinphoneApplication.coreContext.core.isEchoCancellerCalibrationRequired) {
|
||||
navigateToEchoCancellerCalibration()
|
||||
|
@ -95,16 +94,14 @@ class PhoneAccountLinkingFragment : AbstractPhoneFragment<AssistantPhoneAccountL
|
|||
}
|
||||
}
|
||||
}
|
||||
)
|
||||
|
||||
viewModel.onErrorEvent.observe(
|
||||
viewLifecycleOwner,
|
||||
{
|
||||
viewLifecycleOwner
|
||||
) {
|
||||
it.consume { message ->
|
||||
(requireActivity() as AssistantActivity).showSnackBar(message)
|
||||
}
|
||||
}
|
||||
)
|
||||
|
||||
if (Version.sdkAboveOrEqual(Version.API23_MARSHMALLOW_60)) {
|
||||
checkPermissions()
|
||||
|
|
|
@ -59,8 +59,8 @@ class PhoneAccountValidationFragment : GenericFragment<AssistantPhoneAccountVali
|
|||
viewModel.isLinking.value = arguments?.getBoolean("IsLinking", false)
|
||||
|
||||
viewModel.leaveAssistantEvent.observe(
|
||||
viewLifecycleOwner,
|
||||
{
|
||||
viewLifecycleOwner
|
||||
) {
|
||||
it.consume {
|
||||
when {
|
||||
viewModel.isLogin.value == true || viewModel.isCreation.value == true -> {
|
||||
|
@ -74,22 +74,23 @@ class PhoneAccountValidationFragment : GenericFragment<AssistantPhoneAccountVali
|
|||
}
|
||||
viewModel.isLinking.value == true -> {
|
||||
val args = Bundle()
|
||||
args.putString("Identity", "sip:${viewModel.accountCreator.username}@${viewModel.accountCreator.domain}")
|
||||
args.putString(
|
||||
"Identity",
|
||||
"sip:${viewModel.accountCreator.username}@${viewModel.accountCreator.domain}"
|
||||
)
|
||||
navigateToAccountSettings(args)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
)
|
||||
|
||||
viewModel.onErrorEvent.observe(
|
||||
viewLifecycleOwner,
|
||||
{
|
||||
viewLifecycleOwner
|
||||
) {
|
||||
it.consume { message ->
|
||||
(requireActivity() as AssistantActivity).showSnackBar(message)
|
||||
}
|
||||
}
|
||||
)
|
||||
|
||||
val clipboard = requireContext().getSystemService(CLIPBOARD_SERVICE) as ClipboardManager
|
||||
clipboard.addPrimaryClipChangedListener {
|
||||
|
|
|
@ -56,14 +56,13 @@ class QrCodeFragment : GenericFragment<AssistantQrCodeFragmentBinding>() {
|
|||
binding.viewModel = viewModel
|
||||
|
||||
viewModel.qrCodeFoundEvent.observe(
|
||||
viewLifecycleOwner,
|
||||
{
|
||||
viewLifecycleOwner
|
||||
) {
|
||||
it.consume { url ->
|
||||
sharedViewModel.remoteProvisioningUrl.value = url
|
||||
findNavController().navigateUp()
|
||||
}
|
||||
}
|
||||
)
|
||||
viewModel.setBackCamera()
|
||||
|
||||
if (!PermissionHelper.required(requireContext()).hasCameraPermission()) {
|
||||
|
|
|
@ -55,8 +55,8 @@ class RemoteProvisioningFragment : GenericFragment<AssistantRemoteProvisioningFr
|
|||
}
|
||||
|
||||
viewModel.fetchSuccessfulEvent.observe(
|
||||
viewLifecycleOwner,
|
||||
{
|
||||
viewLifecycleOwner
|
||||
) {
|
||||
it.consume { success ->
|
||||
if (success) {
|
||||
if (coreContext.core.isEchoCancellerCalibrationRequired) {
|
||||
|
@ -70,7 +70,6 @@ class RemoteProvisioningFragment : GenericFragment<AssistantRemoteProvisioningFr
|
|||
}
|
||||
}
|
||||
}
|
||||
)
|
||||
|
||||
viewModel.urlToFetch.value = sharedViewModel.remoteProvisioningUrl.value ?: coreContext.core.provisioningUri
|
||||
}
|
||||
|
|
|
@ -73,11 +73,10 @@ class WelcomeFragment : GenericFragment<AssistantWelcomeFragmentBinding>() {
|
|||
}
|
||||
|
||||
viewModel.termsAndPrivacyAccepted.observe(
|
||||
viewLifecycleOwner,
|
||||
{
|
||||
viewLifecycleOwner
|
||||
) {
|
||||
if (it) corePreferences.readAndAgreeTermsAndPrivacy = true
|
||||
}
|
||||
)
|
||||
|
||||
setUpTermsAndPrivacyLinks()
|
||||
}
|
||||
|
|
|
@ -61,8 +61,8 @@ class CallActivity : ProximitySensorActivity() {
|
|||
sharedViewModel = ViewModelProvider(this)[SharedCallViewModel::class.java]
|
||||
|
||||
sharedViewModel.toggleDrawerEvent.observe(
|
||||
this,
|
||||
{
|
||||
this
|
||||
) {
|
||||
it.consume {
|
||||
if (binding.statsMenu.isDrawerOpen(Gravity.LEFT)) {
|
||||
binding.statsMenu.closeDrawer(binding.sideMenuContent, true)
|
||||
|
@ -71,30 +71,26 @@ class CallActivity : ProximitySensorActivity() {
|
|||
}
|
||||
}
|
||||
}
|
||||
)
|
||||
|
||||
sharedViewModel.resetHiddenInterfaceTimerInVideoCallEvent.observe(
|
||||
this,
|
||||
{
|
||||
this
|
||||
) {
|
||||
it.consume {
|
||||
viewModel.showMomentarily()
|
||||
}
|
||||
}
|
||||
)
|
||||
|
||||
viewModel.proximitySensorEnabled.observe(
|
||||
this,
|
||||
{
|
||||
this
|
||||
) {
|
||||
enableProximitySensor(it)
|
||||
}
|
||||
)
|
||||
|
||||
viewModel.videoEnabled.observe(
|
||||
this,
|
||||
{
|
||||
this
|
||||
) {
|
||||
updateConstraintSetDependingOnFoldingState()
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
override fun onLayoutChanges(foldingFeature: FoldingFeature?) {
|
||||
|
|
|
@ -79,24 +79,22 @@ class IncomingCallActivity : GenericActivity() {
|
|||
binding.viewModel = viewModel
|
||||
|
||||
viewModel.callEndedEvent.observe(
|
||||
this,
|
||||
{
|
||||
this
|
||||
) {
|
||||
it.consume {
|
||||
Log.i("[Incoming Call Activity] Call ended, finish activity")
|
||||
finish()
|
||||
}
|
||||
}
|
||||
)
|
||||
|
||||
viewModel.earlyMediaVideoEnabled.observe(
|
||||
this,
|
||||
{
|
||||
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
|
||||
|
|
|
@ -80,53 +80,48 @@ class OutgoingCallActivity : ProximitySensorActivity() {
|
|||
binding.controlsViewModel = controlsViewModel
|
||||
|
||||
viewModel.callEndedEvent.observe(
|
||||
this,
|
||||
{
|
||||
this
|
||||
) {
|
||||
it.consume {
|
||||
Log.i("[Outgoing Call Activity] Call ended, finish activity")
|
||||
finish()
|
||||
}
|
||||
}
|
||||
)
|
||||
|
||||
viewModel.callConnectedEvent.observe(
|
||||
this,
|
||||
{
|
||||
this
|
||||
) {
|
||||
it.consume {
|
||||
Log.i("[Outgoing Call Activity] Call connected, finish activity")
|
||||
finish()
|
||||
}
|
||||
}
|
||||
)
|
||||
|
||||
controlsViewModel.isSpeakerSelected.observe(
|
||||
this,
|
||||
{
|
||||
this
|
||||
) {
|
||||
enableProximitySensor(!it)
|
||||
}
|
||||
)
|
||||
|
||||
controlsViewModel.askAudioRecordPermissionEvent.observe(
|
||||
this,
|
||||
{
|
||||
this
|
||||
) {
|
||||
it.consume { permission ->
|
||||
requestPermissions(arrayOf(permission), 0)
|
||||
}
|
||||
}
|
||||
)
|
||||
|
||||
controlsViewModel.askCameraPermissionEvent.observe(
|
||||
this,
|
||||
{
|
||||
this
|
||||
) {
|
||||
it.consume { permission ->
|
||||
requestPermissions(arrayOf(permission), 0)
|
||||
}
|
||||
}
|
||||
)
|
||||
|
||||
controlsViewModel.toggleNumpadEvent.observe(
|
||||
this,
|
||||
{
|
||||
this
|
||||
) {
|
||||
it.consume { open ->
|
||||
if (this::numpadAnimator.isInitialized) {
|
||||
if (open) {
|
||||
|
@ -137,7 +132,6 @@ class OutgoingCallActivity : ProximitySensorActivity() {
|
|||
}
|
||||
}
|
||||
}
|
||||
)
|
||||
|
||||
if (Version.sdkAboveOrEqual(Version.API23_MARSHMALLOW_60)) {
|
||||
checkPermissions()
|
||||
|
|
|
@ -88,28 +88,26 @@ class ControlsFragment : GenericFragment<CallControlsFragmentBinding>() {
|
|||
binding.conferenceViewModel = conferenceViewModel
|
||||
|
||||
callsViewModel.currentCallViewModel.observe(
|
||||
viewLifecycleOwner,
|
||||
{
|
||||
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,
|
||||
{
|
||||
viewLifecycleOwner
|
||||
) {
|
||||
it.consume {
|
||||
requireActivity().finish()
|
||||
}
|
||||
}
|
||||
)
|
||||
|
||||
callsViewModel.askWriteExternalStoragePermissionEvent.observe(
|
||||
viewLifecycleOwner,
|
||||
{
|
||||
viewLifecycleOwner
|
||||
) {
|
||||
it.consume {
|
||||
if (!PermissionHelper.get().hasWriteExternalStoragePermission()) {
|
||||
Log.i("[Controls Fragment] Asking for WRITE_EXTERNAL_STORAGE permission")
|
||||
|
@ -117,11 +115,10 @@ class ControlsFragment : GenericFragment<CallControlsFragmentBinding>() {
|
|||
}
|
||||
}
|
||||
}
|
||||
)
|
||||
|
||||
callsViewModel.callUpdateEvent.observe(
|
||||
viewLifecycleOwner,
|
||||
{
|
||||
viewLifecycleOwner
|
||||
) {
|
||||
it.consume { call ->
|
||||
if (call.state == Call.State.StreamsRunning) {
|
||||
dialog?.dismiss()
|
||||
|
@ -136,11 +133,10 @@ class ControlsFragment : GenericFragment<CallControlsFragmentBinding>() {
|
|||
}
|
||||
}
|
||||
}
|
||||
)
|
||||
|
||||
controlsViewModel.chatClickedEvent.observe(
|
||||
viewLifecycleOwner,
|
||||
{
|
||||
viewLifecycleOwner
|
||||
) {
|
||||
it.consume {
|
||||
val intent = Intent()
|
||||
intent.setClass(requireContext(), MainActivity::class.java)
|
||||
|
@ -149,11 +145,10 @@ class ControlsFragment : GenericFragment<CallControlsFragmentBinding>() {
|
|||
startActivity(intent)
|
||||
}
|
||||
}
|
||||
)
|
||||
|
||||
controlsViewModel.addCallClickedEvent.observe(
|
||||
viewLifecycleOwner,
|
||||
{
|
||||
viewLifecycleOwner
|
||||
) {
|
||||
it.consume {
|
||||
val intent = Intent()
|
||||
intent.setClass(requireContext(), MainActivity::class.java)
|
||||
|
@ -163,11 +158,10 @@ class ControlsFragment : GenericFragment<CallControlsFragmentBinding>() {
|
|||
startActivity(intent)
|
||||
}
|
||||
}
|
||||
)
|
||||
|
||||
controlsViewModel.transferCallClickedEvent.observe(
|
||||
viewLifecycleOwner,
|
||||
{
|
||||
viewLifecycleOwner
|
||||
) {
|
||||
it.consume {
|
||||
val intent = Intent()
|
||||
intent.setClass(requireContext(), MainActivity::class.java)
|
||||
|
@ -177,31 +171,28 @@ class ControlsFragment : GenericFragment<CallControlsFragmentBinding>() {
|
|||
startActivity(intent)
|
||||
}
|
||||
}
|
||||
)
|
||||
|
||||
controlsViewModel.askAudioRecordPermissionEvent.observe(
|
||||
viewLifecycleOwner,
|
||||
{
|
||||
viewLifecycleOwner
|
||||
) {
|
||||
it.consume { permission ->
|
||||
Log.i("[Controls Fragment] Asking for $permission permission")
|
||||
requestPermissions(arrayOf(permission), 0)
|
||||
}
|
||||
}
|
||||
)
|
||||
|
||||
controlsViewModel.askCameraPermissionEvent.observe(
|
||||
viewLifecycleOwner,
|
||||
{
|
||||
viewLifecycleOwner
|
||||
) {
|
||||
it.consume { permission ->
|
||||
Log.i("[Controls Fragment] Asking for $permission permission")
|
||||
requestPermissions(arrayOf(permission), 1)
|
||||
}
|
||||
}
|
||||
)
|
||||
|
||||
controlsViewModel.toggleNumpadEvent.observe(
|
||||
viewLifecycleOwner,
|
||||
{
|
||||
viewLifecycleOwner
|
||||
) {
|
||||
it.consume { open ->
|
||||
if (this::numpadAnimator.isInitialized) {
|
||||
if (open) {
|
||||
|
@ -212,16 +203,14 @@ class ControlsFragment : GenericFragment<CallControlsFragmentBinding>() {
|
|||
}
|
||||
}
|
||||
}
|
||||
)
|
||||
|
||||
controlsViewModel.somethingClickedEvent.observe(
|
||||
viewLifecycleOwner,
|
||||
{
|
||||
viewLifecycleOwner
|
||||
) {
|
||||
it.consume {
|
||||
sharedViewModel.resetHiddenInterfaceTimerInVideoCallEvent.value = Event(true)
|
||||
}
|
||||
}
|
||||
)
|
||||
|
||||
if (Version.sdkAboveOrEqual(Version.API23_MARSHMALLOW_60)) {
|
||||
checkPermissions()
|
||||
|
|
|
@ -64,15 +64,14 @@ class StatusFragment : GenericFragment<CallStatusFragmentBinding>() {
|
|||
}
|
||||
|
||||
viewModel.showZrtpDialogEvent.observe(
|
||||
viewLifecycleOwner,
|
||||
{
|
||||
viewLifecycleOwner
|
||||
) {
|
||||
it.consume { call ->
|
||||
if (call.state == Call.State.Connected || call.state == Call.State.StreamsRunning) {
|
||||
showZrtpDialog(call)
|
||||
}
|
||||
}
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
|
|
|
@ -122,35 +122,36 @@ class ChatBubbleActivity : GenericActivity() {
|
|||
adapter.disableContextMenu()
|
||||
|
||||
adapter.openContentEvent.observe(
|
||||
this,
|
||||
{
|
||||
this
|
||||
) {
|
||||
it.consume { content ->
|
||||
if (content.isFileEncrypted) {
|
||||
Toast.makeText(this, R.string.chat_bubble_cant_open_enrypted_file, Toast.LENGTH_LONG).show()
|
||||
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 ->
|
||||
this
|
||||
) { events ->
|
||||
adapter.submitList(events)
|
||||
}
|
||||
)
|
||||
|
||||
chatSendingViewModel.textToSend.observe(
|
||||
this,
|
||||
{
|
||||
this
|
||||
) {
|
||||
chatSendingViewModel.onTextToSendChanged(it)
|
||||
}
|
||||
)
|
||||
|
||||
binding.setOpenAppClickListener {
|
||||
coreContext.notificationsManager.currentlyDisplayedChatRoomAddress = null
|
||||
|
|
|
@ -125,8 +125,8 @@ class MainActivity : GenericActivity(), SnackBarActivity, NavController.OnDestin
|
|||
binding.callOverlayViewModel = callOverlayViewModel
|
||||
|
||||
sharedViewModel.toggleDrawerEvent.observe(
|
||||
this,
|
||||
{
|
||||
this
|
||||
) {
|
||||
it.consume {
|
||||
if (binding.sideMenu.isDrawerOpen(Gravity.LEFT)) {
|
||||
binding.sideMenu.closeDrawer(binding.sideMenuContent, true)
|
||||
|
@ -135,16 +135,14 @@ class MainActivity : GenericActivity(), SnackBarActivity, NavController.OnDestin
|
|||
}
|
||||
}
|
||||
}
|
||||
)
|
||||
|
||||
coreContext.callErrorMessageResourceId.observe(
|
||||
this,
|
||||
{
|
||||
this
|
||||
) {
|
||||
it.consume { message ->
|
||||
showSnackBar(message)
|
||||
}
|
||||
}
|
||||
)
|
||||
|
||||
if (coreContext.core.accountList.isEmpty()) {
|
||||
if (corePreferences.firstStart) {
|
||||
|
@ -251,7 +249,7 @@ class MainActivity : GenericActivity(), SnackBarActivity, NavController.OnDestin
|
|||
tabsFragment.visibility = if (tabsFragmentVisible1 && tabsFragmentVisible2) View.VISIBLE else View.GONE
|
||||
}
|
||||
|
||||
fun View.hideKeyboard() {
|
||||
private fun View.hideKeyboard() {
|
||||
val imm = context.getSystemService(Activity.INPUT_METHOD_SERVICE) as InputMethodManager
|
||||
imm.hideSoftInputFromWindow(windowToken, 0)
|
||||
}
|
||||
|
|
|
@ -211,11 +211,10 @@ class ChatMessagesListAdapter(
|
|||
// This is for item selection through ListTopBarFragment
|
||||
selectionListViewModel = selectionViewModel
|
||||
selectionViewModel.isEditionEnabled.observe(
|
||||
viewLifecycleOwner,
|
||||
{
|
||||
viewLifecycleOwner
|
||||
) {
|
||||
position = bindingAdapterPosition
|
||||
}
|
||||
)
|
||||
|
||||
setClickListener {
|
||||
if (selectionViewModel.isEditionEnabled.value == true) {
|
||||
|
@ -416,11 +415,10 @@ class ChatMessagesListAdapter(
|
|||
// This is for item selection through ListTopBarFragment
|
||||
selectionListViewModel = selectionViewModel
|
||||
selectionViewModel.isEditionEnabled.observe(
|
||||
viewLifecycleOwner,
|
||||
{
|
||||
viewLifecycleOwner
|
||||
) {
|
||||
position = bindingAdapterPosition
|
||||
}
|
||||
)
|
||||
|
||||
binding.setClickListener {
|
||||
if (selectionViewModel.isEditionEnabled.value == true) {
|
||||
|
|
|
@ -73,11 +73,10 @@ class ChatRoomsListAdapter(
|
|||
// This is for item selection through ListTopBarFragment
|
||||
selectionListViewModel = selectionViewModel
|
||||
selectionViewModel.isEditionEnabled.observe(
|
||||
viewLifecycleOwner,
|
||||
{
|
||||
viewLifecycleOwner
|
||||
) {
|
||||
position = bindingAdapterPosition
|
||||
}
|
||||
)
|
||||
|
||||
forwardPending = isForwardPending
|
||||
|
||||
|
|
|
@ -93,53 +93,47 @@ class ChatRoomCreationFragment : SecureFragment<ChatRoomCreationFragmentBinding>
|
|||
}
|
||||
|
||||
viewModel.contactsList.observe(
|
||||
viewLifecycleOwner,
|
||||
{
|
||||
viewLifecycleOwner
|
||||
) {
|
||||
adapter.submitList(it)
|
||||
}
|
||||
)
|
||||
|
||||
viewModel.isEncrypted.observe(
|
||||
viewLifecycleOwner,
|
||||
{
|
||||
viewLifecycleOwner
|
||||
) {
|
||||
adapter.updateSecurity(it)
|
||||
}
|
||||
)
|
||||
|
||||
viewModel.sipContactsSelected.observe(
|
||||
viewLifecycleOwner,
|
||||
{
|
||||
viewLifecycleOwner
|
||||
) {
|
||||
viewModel.updateContactsList()
|
||||
}
|
||||
)
|
||||
|
||||
viewModel.selectedAddresses.observe(
|
||||
viewLifecycleOwner,
|
||||
{
|
||||
viewLifecycleOwner
|
||||
) {
|
||||
adapter.updateSelectedAddresses(it)
|
||||
}
|
||||
)
|
||||
|
||||
viewModel.chatRoomCreatedEvent.observe(
|
||||
viewLifecycleOwner,
|
||||
{
|
||||
viewLifecycleOwner
|
||||
) {
|
||||
it.consume { chatRoom ->
|
||||
sharedViewModel.selectedChatRoom.value = chatRoom
|
||||
navigateToChatRoom(AppUtils.createBundleWithSharedTextAndFiles(sharedViewModel))
|
||||
}
|
||||
}
|
||||
)
|
||||
|
||||
viewModel.filter.observe(
|
||||
viewLifecycleOwner,
|
||||
{
|
||||
viewLifecycleOwner
|
||||
) {
|
||||
viewModel.applyFilter()
|
||||
}
|
||||
)
|
||||
|
||||
adapter.selectedContact.observe(
|
||||
viewLifecycleOwner,
|
||||
{
|
||||
viewLifecycleOwner
|
||||
) {
|
||||
it.consume { searchResult ->
|
||||
if (createGroup) {
|
||||
viewModel.toggleSelectionForSearchResult(searchResult)
|
||||
|
@ -148,7 +142,6 @@ class ChatRoomCreationFragment : SecureFragment<ChatRoomCreationFragmentBinding>
|
|||
}
|
||||
}
|
||||
}
|
||||
)
|
||||
|
||||
addParticipantsFromSharedViewModel()
|
||||
|
||||
|
@ -160,13 +153,12 @@ class ChatRoomCreationFragment : SecureFragment<ChatRoomCreationFragmentBinding>
|
|||
}
|
||||
|
||||
viewModel.onErrorEvent.observe(
|
||||
viewLifecycleOwner,
|
||||
{
|
||||
viewLifecycleOwner
|
||||
) {
|
||||
it.consume { messageResourceId ->
|
||||
(activity as MainActivity).showSnackBar(messageResourceId)
|
||||
}
|
||||
}
|
||||
)
|
||||
|
||||
if (!PermissionHelper.get().hasReadContactsPermission()) {
|
||||
Log.i("[Chat Room Creation] Asking for READ_CONTACTS permission")
|
||||
|
|
|
@ -294,70 +294,66 @@ class DetailChatRoomFragment : MasterFragment<ChatRoomDetailFragmentBinding, Cha
|
|||
binding.chatMessagesList.addOnScrollListener(chatScrollListener)
|
||||
|
||||
chatSendingViewModel.textToSend.observe(
|
||||
viewLifecycleOwner,
|
||||
{
|
||||
viewLifecycleOwner
|
||||
) {
|
||||
chatSendingViewModel.onTextToSendChanged(it)
|
||||
}
|
||||
)
|
||||
|
||||
chatSendingViewModel.requestRecordAudioPermissionEvent.observe(
|
||||
viewLifecycleOwner,
|
||||
{
|
||||
viewLifecycleOwner
|
||||
) {
|
||||
it.consume {
|
||||
Log.i("[Chat Room] Asking for RECORD_AUDIO permission")
|
||||
requestPermissions(arrayOf(android.Manifest.permission.RECORD_AUDIO), 2)
|
||||
}
|
||||
}
|
||||
)
|
||||
|
||||
listViewModel.events.observe(
|
||||
viewLifecycleOwner,
|
||||
{ events ->
|
||||
adapter.setUnreadMessageCount(viewModel.chatRoom.unreadMessagesCount, viewModel.isUserScrollingUp.value == true)
|
||||
viewLifecycleOwner
|
||||
) { events ->
|
||||
adapter.setUnreadMessageCount(
|
||||
viewModel.chatRoom.unreadMessagesCount,
|
||||
viewModel.isUserScrollingUp.value == true
|
||||
)
|
||||
adapter.submitList(events)
|
||||
}
|
||||
)
|
||||
|
||||
listViewModel.messageUpdatedEvent.observe(
|
||||
viewLifecycleOwner,
|
||||
{
|
||||
viewLifecycleOwner
|
||||
) {
|
||||
it.consume { position ->
|
||||
adapter.notifyItemChanged(position)
|
||||
}
|
||||
}
|
||||
)
|
||||
|
||||
listViewModel.requestWriteExternalStoragePermissionEvent.observe(
|
||||
viewLifecycleOwner,
|
||||
{
|
||||
viewLifecycleOwner
|
||||
) {
|
||||
it.consume {
|
||||
requestPermissions(arrayOf(android.Manifest.permission.WRITE_EXTERNAL_STORAGE), 1)
|
||||
}
|
||||
}
|
||||
)
|
||||
|
||||
adapter.deleteMessageEvent.observe(
|
||||
viewLifecycleOwner,
|
||||
{
|
||||
viewLifecycleOwner
|
||||
) {
|
||||
it.consume { chatMessage ->
|
||||
listViewModel.deleteMessage(chatMessage)
|
||||
viewModel.updateLastMessageToDisplay()
|
||||
}
|
||||
}
|
||||
)
|
||||
|
||||
adapter.resendMessageEvent.observe(
|
||||
viewLifecycleOwner,
|
||||
{
|
||||
viewLifecycleOwner
|
||||
) {
|
||||
it.consume { chatMessage ->
|
||||
listViewModel.resendMessage(chatMessage)
|
||||
}
|
||||
}
|
||||
)
|
||||
|
||||
adapter.forwardMessageEvent.observe(
|
||||
viewLifecycleOwner,
|
||||
{
|
||||
viewLifecycleOwner
|
||||
) {
|
||||
it.consume { chatMessage ->
|
||||
// Remove observer before setting the message to forward
|
||||
// as we don't want to forward it in this chat room
|
||||
|
@ -373,44 +369,42 @@ class DetailChatRoomFragment : MasterFragment<ChatRoomDetailFragmentBinding, Cha
|
|||
}
|
||||
}
|
||||
}
|
||||
)
|
||||
|
||||
adapter.replyMessageEvent.observe(
|
||||
viewLifecycleOwner,
|
||||
{
|
||||
viewLifecycleOwner
|
||||
) {
|
||||
it.consume { chatMessage ->
|
||||
chatSendingViewModel.pendingChatMessageToReplyTo.value?.destroy()
|
||||
chatSendingViewModel.pendingChatMessageToReplyTo.value = ChatMessageData(chatMessage)
|
||||
chatSendingViewModel.pendingChatMessageToReplyTo.value =
|
||||
ChatMessageData(chatMessage)
|
||||
chatSendingViewModel.isPendingAnswer.value = true
|
||||
}
|
||||
}
|
||||
)
|
||||
|
||||
adapter.showImdnForMessageEvent.observe(
|
||||
viewLifecycleOwner,
|
||||
{
|
||||
viewLifecycleOwner
|
||||
) {
|
||||
it.consume { chatMessage ->
|
||||
val args = Bundle()
|
||||
args.putString("MessageId", chatMessage.messageId)
|
||||
navigateToImdn(args)
|
||||
}
|
||||
}
|
||||
)
|
||||
|
||||
adapter.addSipUriToContactEvent.observe(
|
||||
viewLifecycleOwner,
|
||||
{
|
||||
viewLifecycleOwner
|
||||
) {
|
||||
it.consume { sipUri ->
|
||||
Log.i("[Chat Room] Going to contacts list with SIP URI to add: $sipUri")
|
||||
sharedViewModel.updateContactsAnimationsBasedOnDestination.value = Event(R.id.masterChatRoomsFragment)
|
||||
sharedViewModel.updateContactsAnimationsBasedOnDestination.value =
|
||||
Event(R.id.masterChatRoomsFragment)
|
||||
navigateToContacts(sipUri)
|
||||
}
|
||||
}
|
||||
)
|
||||
|
||||
adapter.openContentEvent.observe(
|
||||
viewLifecycleOwner,
|
||||
{
|
||||
viewLifecycleOwner
|
||||
) {
|
||||
it.consume { content ->
|
||||
val path = content.filePath.orEmpty()
|
||||
|
||||
|
@ -442,8 +436,14 @@ class DetailChatRoomFragment : MasterFragment<ChatRoomDetailFragmentBinding, Cha
|
|||
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)) {
|
||||
showDialogForUserConsentBeforeExportingFileInThirdPartyApp(
|
||||
content
|
||||
)
|
||||
} else if (!FileUtils.openFileInThirdPartyApp(
|
||||
requireActivity(),
|
||||
path
|
||||
)
|
||||
) {
|
||||
showDialogToSuggestOpeningFileAsText()
|
||||
}
|
||||
}
|
||||
|
@ -456,11 +456,10 @@ class DetailChatRoomFragment : MasterFragment<ChatRoomDetailFragmentBinding, Cha
|
|||
}
|
||||
}
|
||||
}
|
||||
)
|
||||
|
||||
adapter.scrollToChatMessageEvent.observe(
|
||||
viewLifecycleOwner,
|
||||
{
|
||||
viewLifecycleOwner
|
||||
) {
|
||||
it.consume { chatMessage ->
|
||||
val events = listViewModel.events.value.orEmpty()
|
||||
val eventLog = events.find { eventLog ->
|
||||
|
@ -480,7 +479,6 @@ class DetailChatRoomFragment : MasterFragment<ChatRoomDetailFragmentBinding, Cha
|
|||
}
|
||||
}
|
||||
}
|
||||
)
|
||||
|
||||
binding.setBackClickListener {
|
||||
goBack()
|
||||
|
@ -571,8 +569,8 @@ class DetailChatRoomFragment : MasterFragment<ChatRoomDetailFragmentBinding, Cha
|
|||
}
|
||||
|
||||
sharedViewModel.richContentUri.observe(
|
||||
viewLifecycleOwner,
|
||||
{
|
||||
viewLifecycleOwner
|
||||
) {
|
||||
it.consume { uri ->
|
||||
Log.i("[Chat] Found rich content URI: $uri")
|
||||
lifecycleScope.launch {
|
||||
|
@ -586,18 +584,16 @@ class DetailChatRoomFragment : MasterFragment<ChatRoomDetailFragmentBinding, Cha
|
|||
}
|
||||
}
|
||||
}
|
||||
)
|
||||
|
||||
sharedViewModel.messageToForwardEvent.observe(
|
||||
viewLifecycleOwner,
|
||||
{
|
||||
viewLifecycleOwner
|
||||
) {
|
||||
it.consume { chatMessage ->
|
||||
Log.i("[Chat Room] Found message to transfer")
|
||||
showForwardConfirmationDialog(chatMessage)
|
||||
sharedViewModel.isPendingMessageForward.value = false
|
||||
}
|
||||
}
|
||||
)
|
||||
|
||||
binding.stubbedMessageToReplyTo.setOnInflateListener { _, inflated ->
|
||||
Log.i("[Chat Room] Replying to message layout inflated")
|
||||
|
|
|
@ -84,36 +84,32 @@ class GroupInfoFragment : SecureFragment<ChatRoomGroupInfoFragmentBinding>() {
|
|||
binding.participants.addItemDecoration(AppUtils.getDividerDecoration(requireContext(), layoutManager))
|
||||
|
||||
viewModel.participants.observe(
|
||||
viewLifecycleOwner,
|
||||
{
|
||||
viewLifecycleOwner
|
||||
) {
|
||||
adapter.submitList(it)
|
||||
}
|
||||
)
|
||||
|
||||
viewModel.isMeAdmin.observe(
|
||||
viewLifecycleOwner,
|
||||
{ isMeAdmin ->
|
||||
viewLifecycleOwner
|
||||
) { isMeAdmin ->
|
||||
adapter.showAdminControls(isMeAdmin && chatRoom != null)
|
||||
}
|
||||
)
|
||||
|
||||
viewModel.meAdminChangedEvent.observe(
|
||||
viewLifecycleOwner,
|
||||
{
|
||||
viewLifecycleOwner
|
||||
) {
|
||||
it.consume { isMeAdmin ->
|
||||
showMeAdminStateChanged(isMeAdmin)
|
||||
}
|
||||
}
|
||||
)
|
||||
|
||||
adapter.participantRemovedEvent.observe(
|
||||
viewLifecycleOwner,
|
||||
{
|
||||
viewLifecycleOwner
|
||||
) {
|
||||
it.consume { participant ->
|
||||
viewModel.removeParticipant(participant)
|
||||
}
|
||||
}
|
||||
)
|
||||
|
||||
addParticipantsFromSharedViewModel()
|
||||
|
||||
|
@ -122,22 +118,20 @@ class GroupInfoFragment : SecureFragment<ChatRoomGroupInfoFragmentBinding>() {
|
|||
}
|
||||
|
||||
viewModel.createdChatRoomEvent.observe(
|
||||
viewLifecycleOwner,
|
||||
{
|
||||
viewLifecycleOwner
|
||||
) {
|
||||
it.consume { chatRoom ->
|
||||
goToChatRoom(chatRoom, true)
|
||||
}
|
||||
}
|
||||
)
|
||||
|
||||
viewModel.updatedChatRoomEvent.observe(
|
||||
viewLifecycleOwner,
|
||||
{
|
||||
viewLifecycleOwner
|
||||
) {
|
||||
it.consume { chatRoom ->
|
||||
goToChatRoom(chatRoom, false)
|
||||
}
|
||||
}
|
||||
)
|
||||
|
||||
binding.setNextClickListener {
|
||||
if (viewModel.chatRoom != null) {
|
||||
|
@ -182,13 +176,12 @@ class GroupInfoFragment : SecureFragment<ChatRoomGroupInfoFragmentBinding>() {
|
|||
}
|
||||
|
||||
viewModel.onErrorEvent.observe(
|
||||
viewLifecycleOwner,
|
||||
{
|
||||
viewLifecycleOwner
|
||||
) {
|
||||
it.consume { messageResourceId ->
|
||||
(activity as MainActivity).showSnackBar(messageResourceId)
|
||||
}
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
private fun addParticipantsFromSharedViewModel() {
|
||||
|
|
|
@ -98,11 +98,10 @@ class ImdnFragment : SecureFragment<ChatRoomImdnFragmentBinding>() {
|
|||
binding.participantsList.addItemDecoration(headerItemDecoration)
|
||||
|
||||
viewModel.participants.observe(
|
||||
viewLifecycleOwner,
|
||||
{
|
||||
viewLifecycleOwner
|
||||
) {
|
||||
adapter.submitList(it)
|
||||
}
|
||||
)
|
||||
|
||||
binding.setBackClickListener {
|
||||
goBack()
|
||||
|
|
|
@ -113,17 +113,16 @@ class MasterChatRoomsFragment : MasterFragment<ChatRoomMasterFragmentBinding, Ch
|
|||
|
||||
// Chat room loading can take some time, so wait until it is ready before opening the pane
|
||||
sharedViewModel.chatRoomFragmentOpenedEvent.observe(
|
||||
viewLifecycleOwner,
|
||||
{
|
||||
viewLifecycleOwner
|
||||
) {
|
||||
it.consume {
|
||||
binding.slidingPane.openPane()
|
||||
}
|
||||
}
|
||||
)
|
||||
|
||||
sharedViewModel.closeSlidingPaneEvent.observe(
|
||||
viewLifecycleOwner,
|
||||
{
|
||||
viewLifecycleOwner
|
||||
) {
|
||||
it.consume {
|
||||
(requireActivity() as MainActivity).hideKeyboard()
|
||||
if (!binding.slidingPane.closePane()) {
|
||||
|
@ -131,14 +130,14 @@ class MasterChatRoomsFragment : MasterFragment<ChatRoomMasterFragmentBinding, Ch
|
|||
}
|
||||
}
|
||||
}
|
||||
)
|
||||
sharedViewModel.layoutChangedEvent.observe(
|
||||
viewLifecycleOwner,
|
||||
{
|
||||
viewLifecycleOwner
|
||||
) {
|
||||
it.consume {
|
||||
sharedViewModel.isSlidingPaneSlideable.value = binding.slidingPane.isSlideable
|
||||
if (binding.slidingPane.isSlideable) {
|
||||
val navHostFragment = childFragmentManager.findFragmentById(R.id.chat_nav_container) as NavHostFragment
|
||||
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()
|
||||
|
@ -146,7 +145,6 @@ class MasterChatRoomsFragment : MasterFragment<ChatRoomMasterFragmentBinding, Ch
|
|||
}
|
||||
}
|
||||
}
|
||||
)
|
||||
binding.slidingPane.lockMode = SlidingPaneLayout.LOCK_MODE_LOCKED
|
||||
|
||||
/* End of shared view model & sliding pane related */
|
||||
|
@ -216,24 +214,22 @@ class MasterChatRoomsFragment : MasterFragment<ChatRoomMasterFragmentBinding, Ch
|
|||
binding.chatList.addItemDecoration(AppUtils.getDividerDecoration(requireContext(), layoutManager))
|
||||
|
||||
listViewModel.chatRooms.observe(
|
||||
viewLifecycleOwner,
|
||||
{ chatRooms ->
|
||||
viewLifecycleOwner
|
||||
) { chatRooms ->
|
||||
adapter.submitList(chatRooms)
|
||||
}
|
||||
)
|
||||
|
||||
listViewModel.contactsUpdatedEvent.observe(
|
||||
viewLifecycleOwner,
|
||||
{
|
||||
viewLifecycleOwner
|
||||
) {
|
||||
it.consume {
|
||||
adapter.notifyDataSetChanged()
|
||||
}
|
||||
}
|
||||
)
|
||||
|
||||
adapter.selectedChatRoomEvent.observe(
|
||||
viewLifecycleOwner,
|
||||
{
|
||||
viewLifecycleOwner
|
||||
) {
|
||||
it.consume { chatRoom ->
|
||||
if ((requireActivity() as GenericActivity).isDestructionPending) {
|
||||
Log.w("[Chat] Activity is pending destruction, don't start navigating now!")
|
||||
|
@ -259,7 +255,6 @@ class MasterChatRoomsFragment : MasterFragment<ChatRoomMasterFragmentBinding, Ch
|
|||
}
|
||||
}
|
||||
}
|
||||
)
|
||||
|
||||
binding.setEditClickListener {
|
||||
listSelectionViewModel.isEditionEnabled.value = true
|
||||
|
@ -313,8 +308,8 @@ class MasterChatRoomsFragment : MasterFragment<ChatRoomMasterFragmentBinding, Ch
|
|||
}
|
||||
} else {
|
||||
sharedViewModel.textToShare.observe(
|
||||
viewLifecycleOwner,
|
||||
{
|
||||
viewLifecycleOwner
|
||||
) {
|
||||
if (it.isNotEmpty()) {
|
||||
Log.i("[Chat] Found text to share")
|
||||
// val activity = requireActivity() as MainActivity
|
||||
|
@ -327,10 +322,9 @@ class MasterChatRoomsFragment : MasterFragment<ChatRoomMasterFragmentBinding, Ch
|
|||
}
|
||||
}
|
||||
}
|
||||
)
|
||||
sharedViewModel.filesToShare.observe(
|
||||
viewLifecycleOwner,
|
||||
{
|
||||
viewLifecycleOwner
|
||||
) {
|
||||
if (it.isNotEmpty()) {
|
||||
Log.i("[Chat] Found ${it.size} files to share")
|
||||
// val activity = requireActivity() as MainActivity
|
||||
|
@ -343,26 +337,23 @@ class MasterChatRoomsFragment : MasterFragment<ChatRoomMasterFragmentBinding, Ch
|
|||
}
|
||||
}
|
||||
}
|
||||
)
|
||||
sharedViewModel.isPendingMessageForward.observe(
|
||||
viewLifecycleOwner,
|
||||
{
|
||||
viewLifecycleOwner
|
||||
) {
|
||||
listViewModel.forwardPending.value = it
|
||||
adapter.forwardPending(it)
|
||||
if (it) {
|
||||
Log.i("[Chat] Found chat message to transfer")
|
||||
}
|
||||
}
|
||||
)
|
||||
|
||||
listViewModel.onErrorEvent.observe(
|
||||
viewLifecycleOwner,
|
||||
{
|
||||
viewLifecycleOwner
|
||||
) {
|
||||
it.consume { messageResourceId ->
|
||||
(activity as MainActivity).showSnackBar(messageResourceId)
|
||||
}
|
||||
}
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -71,11 +71,10 @@ class ContactsListAdapter(
|
|||
// This is for item selection through ListTopBarFragment
|
||||
selectionListViewModel = selectionViewModel
|
||||
selectionViewModel.isEditionEnabled.observe(
|
||||
viewLifecycleOwner,
|
||||
{
|
||||
viewLifecycleOwner
|
||||
) {
|
||||
position = bindingAdapterPosition
|
||||
}
|
||||
)
|
||||
|
||||
setClickListener {
|
||||
if (selectionViewModel.isEditionEnabled.value == true) {
|
||||
|
|
|
@ -83,47 +83,50 @@ class DetailContactFragment : GenericFragment<ContactDetailFragmentBinding>() {
|
|||
binding.viewModel = viewModel
|
||||
|
||||
viewModel.sendSmsToEvent.observe(
|
||||
viewLifecycleOwner,
|
||||
{
|
||||
viewLifecycleOwner
|
||||
) {
|
||||
it.consume { number ->
|
||||
sendSms(number)
|
||||
}
|
||||
}
|
||||
)
|
||||
|
||||
viewModel.startCallToEvent.observe(
|
||||
viewLifecycleOwner,
|
||||
{
|
||||
viewLifecycleOwner
|
||||
) {
|
||||
it.consume { address ->
|
||||
if (coreContext.core.callsNb > 0) {
|
||||
Log.i("[Contact] Starting dialer with pre-filled URI ${address.asStringUriOnly()}, is transfer? ${sharedViewModel.pendingCallTransfer}")
|
||||
sharedViewModel.updateContactsAnimationsBasedOnDestination.value = Event(R.id.dialerFragment)
|
||||
sharedViewModel.updateDialerAnimationsBasedOnDestination.value = Event(R.id.masterContactsFragment)
|
||||
sharedViewModel.updateContactsAnimationsBasedOnDestination.value =
|
||||
Event(R.id.dialerFragment)
|
||||
sharedViewModel.updateDialerAnimationsBasedOnDestination.value =
|
||||
Event(R.id.masterContactsFragment)
|
||||
|
||||
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
|
||||
args.putBoolean(
|
||||
"SkipAutoCallStart",
|
||||
true
|
||||
) // If auto start call setting is enabled, ignore it
|
||||
navigateToDialer(args)
|
||||
} else {
|
||||
coreContext.startCall(address)
|
||||
}
|
||||
}
|
||||
}
|
||||
)
|
||||
|
||||
viewModel.chatRoomCreatedEvent.observe(
|
||||
viewLifecycleOwner,
|
||||
{
|
||||
viewLifecycleOwner
|
||||
) {
|
||||
it.consume { chatRoom ->
|
||||
sharedViewModel.updateContactsAnimationsBasedOnDestination.value = Event(R.id.masterChatRoomsFragment)
|
||||
sharedViewModel.updateContactsAnimationsBasedOnDestination.value =
|
||||
Event(R.id.masterChatRoomsFragment)
|
||||
val args = Bundle()
|
||||
args.putString("LocalSipUri", chatRoom.localAddress.asStringUriOnly())
|
||||
args.putString("RemoteSipUri", chatRoom.peerAddress.asStringUriOnly())
|
||||
navigateToChatRoom(args)
|
||||
}
|
||||
}
|
||||
)
|
||||
|
||||
binding.setBackClickListener {
|
||||
goBack()
|
||||
|
@ -138,13 +141,12 @@ class DetailContactFragment : GenericFragment<ContactDetailFragmentBinding>() {
|
|||
}
|
||||
|
||||
viewModel.onErrorEvent.observe(
|
||||
viewLifecycleOwner,
|
||||
{
|
||||
viewLifecycleOwner
|
||||
) {
|
||||
it.consume { messageResourceId ->
|
||||
(activity as MainActivity).showSnackBar(messageResourceId)
|
||||
}
|
||||
}
|
||||
)
|
||||
|
||||
view.doOnPreDraw {
|
||||
// Notifies fragment is ready to be drawn
|
||||
|
|
|
@ -85,16 +85,18 @@ class MasterContactsFragment : MasterFragment<ContactMasterFragmentBinding, Cont
|
|||
|
||||
useMaterialSharedAxisXForwardAnimation = false
|
||||
sharedViewModel.updateContactsAnimationsBasedOnDestination.observe(
|
||||
viewLifecycleOwner,
|
||||
{
|
||||
viewLifecycleOwner
|
||||
) {
|
||||
it.consume { id ->
|
||||
val forward = when (id) {
|
||||
R.id.dialerFragment, R.id.masterChatRoomsFragment -> false
|
||||
else -> true
|
||||
}
|
||||
if (corePreferences.enableAnimations) {
|
||||
val portraitOrientation = resources.configuration.orientation != Configuration.ORIENTATION_LANDSCAPE
|
||||
val axis = if (portraitOrientation) MaterialSharedAxis.X else MaterialSharedAxis.Y
|
||||
val portraitOrientation =
|
||||
resources.configuration.orientation != Configuration.ORIENTATION_LANDSCAPE
|
||||
val axis =
|
||||
if (portraitOrientation) MaterialSharedAxis.X else MaterialSharedAxis.Y
|
||||
enterTransition = MaterialSharedAxis(axis, forward)
|
||||
reenterTransition = MaterialSharedAxis(axis, forward)
|
||||
returnTransition = MaterialSharedAxis(axis, !forward)
|
||||
|
@ -102,34 +104,32 @@ class MasterContactsFragment : MasterFragment<ContactMasterFragmentBinding, Cont
|
|||
}
|
||||
}
|
||||
}
|
||||
)
|
||||
|
||||
sharedViewModel.contactFragmentOpenedEvent.observe(
|
||||
viewLifecycleOwner,
|
||||
{
|
||||
viewLifecycleOwner
|
||||
) {
|
||||
it.consume {
|
||||
binding.slidingPane.openPane()
|
||||
}
|
||||
}
|
||||
)
|
||||
|
||||
sharedViewModel.closeSlidingPaneEvent.observe(
|
||||
viewLifecycleOwner,
|
||||
{
|
||||
viewLifecycleOwner
|
||||
) {
|
||||
it.consume {
|
||||
if (!binding.slidingPane.closePane()) {
|
||||
goBack()
|
||||
}
|
||||
}
|
||||
}
|
||||
)
|
||||
sharedViewModel.layoutChangedEvent.observe(
|
||||
viewLifecycleOwner,
|
||||
{
|
||||
viewLifecycleOwner
|
||||
) {
|
||||
it.consume {
|
||||
sharedViewModel.isSlidingPaneSlideable.value = binding.slidingPane.isSlideable
|
||||
if (binding.slidingPane.isSlideable) {
|
||||
val navHostFragment = childFragmentManager.findFragmentById(R.id.contacts_nav_container) as NavHostFragment
|
||||
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()
|
||||
|
@ -137,7 +137,6 @@ class MasterContactsFragment : MasterFragment<ContactMasterFragmentBinding, Cont
|
|||
}
|
||||
}
|
||||
}
|
||||
)
|
||||
binding.slidingPane.lockMode = SlidingPaneLayout.LOCK_MODE_LOCKED
|
||||
|
||||
/* End of shared view model & sliding pane related */
|
||||
|
@ -208,8 +207,8 @@ class MasterContactsFragment : MasterFragment<ContactMasterFragmentBinding, Cont
|
|||
binding.contactsList.addItemDecoration(headerItemDecoration)
|
||||
|
||||
adapter.selectedContactEvent.observe(
|
||||
viewLifecycleOwner,
|
||||
{
|
||||
viewLifecycleOwner
|
||||
) {
|
||||
it.consume { contact ->
|
||||
Log.i("[Contacts] Selected item in list changed: $contact")
|
||||
sharedViewModel.selectedContact.value = contact
|
||||
|
@ -223,11 +222,10 @@ class MasterContactsFragment : MasterFragment<ContactMasterFragmentBinding, Cont
|
|||
}
|
||||
}
|
||||
}
|
||||
)
|
||||
|
||||
listViewModel.contactsList.observe(
|
||||
viewLifecycleOwner,
|
||||
{
|
||||
viewLifecycleOwner
|
||||
) {
|
||||
val id = contactIdToDisplay
|
||||
if (id != null) {
|
||||
val contact = coreContext.contactsManager.findContactById(id)
|
||||
|
@ -239,7 +237,6 @@ class MasterContactsFragment : MasterFragment<ContactMasterFragmentBinding, Cont
|
|||
}
|
||||
adapter.submitList(it)
|
||||
}
|
||||
)
|
||||
|
||||
binding.setAllContactsToggleClickListener {
|
||||
listViewModel.sipContactsSelected.value = false
|
||||
|
@ -249,18 +246,16 @@ class MasterContactsFragment : MasterFragment<ContactMasterFragmentBinding, Cont
|
|||
}
|
||||
|
||||
listViewModel.sipContactsSelected.observe(
|
||||
viewLifecycleOwner,
|
||||
{
|
||||
viewLifecycleOwner
|
||||
) {
|
||||
listViewModel.updateContactsList()
|
||||
}
|
||||
)
|
||||
|
||||
listViewModel.filter.observe(
|
||||
viewLifecycleOwner,
|
||||
{
|
||||
viewLifecycleOwner
|
||||
) {
|
||||
listViewModel.updateContactsList()
|
||||
}
|
||||
)
|
||||
|
||||
binding.setNewContactClickListener {
|
||||
// Remove any previously selected contact
|
||||
|
|
|
@ -77,16 +77,18 @@ class DialerFragment : SecureFragment<DialerFragmentBinding>() {
|
|||
|
||||
useMaterialSharedAxisXForwardAnimation = false
|
||||
sharedViewModel.updateDialerAnimationsBasedOnDestination.observe(
|
||||
viewLifecycleOwner,
|
||||
{
|
||||
viewLifecycleOwner
|
||||
) {
|
||||
it.consume { id ->
|
||||
val forward = when (id) {
|
||||
R.id.masterChatRoomsFragment -> false
|
||||
else -> true
|
||||
}
|
||||
if (corePreferences.enableAnimations) {
|
||||
val portraitOrientation = resources.configuration.orientation != Configuration.ORIENTATION_LANDSCAPE
|
||||
val axis = if (portraitOrientation) MaterialSharedAxis.X else MaterialSharedAxis.Y
|
||||
val portraitOrientation =
|
||||
resources.configuration.orientation != Configuration.ORIENTATION_LANDSCAPE
|
||||
val axis =
|
||||
if (portraitOrientation) MaterialSharedAxis.X else MaterialSharedAxis.Y
|
||||
enterTransition = MaterialSharedAxis(axis, forward)
|
||||
reenterTransition = MaterialSharedAxis(axis, forward)
|
||||
returnTransition = MaterialSharedAxis(axis, !forward)
|
||||
|
@ -94,7 +96,6 @@ class DialerFragment : SecureFragment<DialerFragmentBinding>() {
|
|||
}
|
||||
}
|
||||
}
|
||||
)
|
||||
|
||||
binding.setNewContactClickListener {
|
||||
sharedViewModel.updateDialerAnimationsBasedOnDestination.value = Event(R.id.masterContactsFragment)
|
||||
|
@ -111,18 +112,17 @@ class DialerFragment : SecureFragment<DialerFragmentBinding>() {
|
|||
}
|
||||
|
||||
viewModel.enteredUri.observe(
|
||||
viewLifecycleOwner,
|
||||
{
|
||||
viewLifecycleOwner
|
||||
) {
|
||||
if (it == corePreferences.debugPopupCode) {
|
||||
displayDebugPopup()
|
||||
viewModel.enteredUri.value = ""
|
||||
}
|
||||
}
|
||||
)
|
||||
|
||||
viewModel.uploadFinishedEvent.observe(
|
||||
viewLifecycleOwner,
|
||||
{
|
||||
viewLifecycleOwner
|
||||
) {
|
||||
it.consume { url ->
|
||||
// To prevent being trigger when using the Send Logs button in About page
|
||||
if (uploadLogsInitiatedByUs) {
|
||||
|
@ -138,16 +138,14 @@ class DialerFragment : SecureFragment<DialerFragmentBinding>() {
|
|||
}
|
||||
}
|
||||
}
|
||||
)
|
||||
|
||||
viewModel.updateAvailableEvent.observe(
|
||||
viewLifecycleOwner,
|
||||
{
|
||||
viewLifecycleOwner
|
||||
) {
|
||||
it.consume { url ->
|
||||
displayNewVersionAvailableDialog(url)
|
||||
}
|
||||
}
|
||||
)
|
||||
|
||||
if (corePreferences.firstStart) {
|
||||
Log.w("[Dialer] First start detected, wait for assistant to be finished to check for update & request permissions")
|
||||
|
|
|
@ -139,7 +139,7 @@ class TopBarFragment : GenericFragment<FileViewerTopBarFragmentBinding>() {
|
|||
Log.w("[File Viewer] Media store file path is empty, media store export failed?")
|
||||
|
||||
val filePath = content.plainFilePath.orEmpty()
|
||||
plainFilePath = if (filePath.isEmpty()) content.filePath.orEmpty() else filePath
|
||||
plainFilePath = filePath.ifEmpty { content.filePath.orEmpty() }
|
||||
Log.i("[File Viewer] Plain file path is: $plainFilePath")
|
||||
if (plainFilePath.isNotEmpty()) {
|
||||
if (!FileUtils.openFileInThirdPartyApp(requireActivity(), plainFilePath)) {
|
||||
|
|
|
@ -56,35 +56,35 @@ abstract class MasterFragment<T : ViewDataBinding, U : SelectionListAdapter<*, *
|
|||
listSelectionViewModel = ViewModelProvider(this)[ListTopBarViewModel::class.java]
|
||||
|
||||
listSelectionViewModel.isEditionEnabled.observe(
|
||||
viewLifecycleOwner,
|
||||
{
|
||||
viewLifecycleOwner
|
||||
) {
|
||||
if (!it) listSelectionViewModel.onUnSelectAll()
|
||||
}
|
||||
)
|
||||
|
||||
listSelectionViewModel.selectAllEvent.observe(
|
||||
viewLifecycleOwner,
|
||||
{
|
||||
viewLifecycleOwner
|
||||
) {
|
||||
it.consume {
|
||||
listSelectionViewModel.onSelectAll(getItemCount() - 1)
|
||||
}
|
||||
}
|
||||
)
|
||||
|
||||
listSelectionViewModel.unSelectAllEvent.observe(
|
||||
viewLifecycleOwner,
|
||||
{
|
||||
viewLifecycleOwner
|
||||
) {
|
||||
it.consume {
|
||||
listSelectionViewModel.onUnSelectAll()
|
||||
}
|
||||
}
|
||||
)
|
||||
|
||||
listSelectionViewModel.deleteSelectionEvent.observe(
|
||||
viewLifecycleOwner,
|
||||
{
|
||||
viewLifecycleOwner
|
||||
) {
|
||||
it.consume {
|
||||
val confirmationDialog = AppUtils.getStringWithPlural(dialogConfirmationMessageBeforeRemoval, listSelectionViewModel.selectedItems.value.orEmpty().size)
|
||||
val confirmationDialog = AppUtils.getStringWithPlural(
|
||||
dialogConfirmationMessageBeforeRemoval,
|
||||
listSelectionViewModel.selectedItems.value.orEmpty().size
|
||||
)
|
||||
val viewModel = DialogViewModel(confirmationDialog)
|
||||
val dialog: Dialog = DialogUtils.getDialog(requireContext(), viewModel)
|
||||
|
||||
|
@ -105,7 +105,6 @@ abstract class MasterFragment<T : ViewDataBinding, U : SelectionListAdapter<*, *
|
|||
dialog.show()
|
||||
}
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
private fun delete() {
|
||||
|
|
|
@ -51,15 +51,14 @@ class StatusFragment : GenericFragment<StatusFragmentBinding>() {
|
|||
}
|
||||
|
||||
sharedViewModel.accountRemoved.observe(
|
||||
viewLifecycleOwner,
|
||||
{
|
||||
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)
|
||||
|
|
|
@ -73,11 +73,10 @@ class CallLogsListAdapter(
|
|||
// This is for item selection through ListTopBarFragment
|
||||
selectionListViewModel = selectionViewModel
|
||||
selectionViewModel.isEditionEnabled.observe(
|
||||
viewLifecycleOwner,
|
||||
{
|
||||
viewLifecycleOwner
|
||||
) {
|
||||
position = bindingAdapterPosition
|
||||
}
|
||||
)
|
||||
|
||||
setClickListener {
|
||||
if (selectionViewModel.isEditionEnabled.value == true) {
|
||||
|
|
|
@ -99,13 +99,14 @@ class DetailCallLogFragment : GenericFragment<HistoryDetailFragmentBinding>() {
|
|||
}
|
||||
|
||||
viewModel.startCallEvent.observe(
|
||||
viewLifecycleOwner,
|
||||
{
|
||||
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}")
|
||||
sharedViewModel.updateDialerAnimationsBasedOnDestination.value = Event(R.id.masterCallLogsFragment)
|
||||
sharedViewModel.updateDialerAnimationsBasedOnDestination.value =
|
||||
Event(R.id.masterCallLogsFragment)
|
||||
|
||||
val args = Bundle()
|
||||
args.putString("URI", address.asStringUriOnly())
|
||||
|
@ -121,11 +122,10 @@ class DetailCallLogFragment : GenericFragment<HistoryDetailFragmentBinding>() {
|
|||
}
|
||||
}
|
||||
}
|
||||
)
|
||||
|
||||
viewModel.chatRoomCreatedEvent.observe(
|
||||
viewLifecycleOwner,
|
||||
{
|
||||
viewLifecycleOwner
|
||||
) {
|
||||
it.consume { chatRoom ->
|
||||
val args = Bundle()
|
||||
args.putString("LocalSipUri", chatRoom.localAddress.asStringUriOnly())
|
||||
|
@ -133,16 +133,14 @@ class DetailCallLogFragment : GenericFragment<HistoryDetailFragmentBinding>() {
|
|||
navigateToChatRoom(args)
|
||||
}
|
||||
}
|
||||
)
|
||||
|
||||
viewModel.onErrorEvent.observe(
|
||||
viewLifecycleOwner,
|
||||
{
|
||||
viewLifecycleOwner
|
||||
) {
|
||||
it.consume { messageResourceId ->
|
||||
(activity as MainActivity).showSnackBar(messageResourceId)
|
||||
}
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
override fun goBack() {
|
||||
|
|
|
@ -101,22 +101,22 @@ class MasterCallLogsFragment : MasterFragment<HistoryMasterFragmentBinding, Call
|
|||
view.doOnPreDraw { sharedViewModel.isSlidingPaneSlideable.value = binding.slidingPane.isSlideable }
|
||||
|
||||
sharedViewModel.closeSlidingPaneEvent.observe(
|
||||
viewLifecycleOwner,
|
||||
{
|
||||
viewLifecycleOwner
|
||||
) {
|
||||
it.consume {
|
||||
if (!binding.slidingPane.closePane()) {
|
||||
goBack()
|
||||
}
|
||||
}
|
||||
}
|
||||
)
|
||||
sharedViewModel.layoutChangedEvent.observe(
|
||||
viewLifecycleOwner,
|
||||
{
|
||||
viewLifecycleOwner
|
||||
) {
|
||||
it.consume {
|
||||
sharedViewModel.isSlidingPaneSlideable.value = binding.slidingPane.isSlideable
|
||||
if (binding.slidingPane.isSlideable) {
|
||||
val navHostFragment = childFragmentManager.findFragmentById(R.id.history_nav_container) as NavHostFragment
|
||||
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()
|
||||
|
@ -124,7 +124,6 @@ class MasterCallLogsFragment : MasterFragment<HistoryMasterFragmentBinding, Call
|
|||
}
|
||||
}
|
||||
}
|
||||
)
|
||||
binding.slidingPane.lockMode = SlidingPaneLayout.LOCK_MODE_LOCKED
|
||||
|
||||
/* End of shared view model & sliding pane related */
|
||||
|
@ -193,65 +192,64 @@ class MasterCallLogsFragment : MasterFragment<HistoryMasterFragmentBinding, Call
|
|||
binding.callLogsList.addItemDecoration(headerItemDecoration)
|
||||
|
||||
listViewModel.callLogs.observe(
|
||||
viewLifecycleOwner,
|
||||
{ callLogs ->
|
||||
viewLifecycleOwner
|
||||
) { callLogs ->
|
||||
if (listViewModel.missedCallLogsSelected.value == false) {
|
||||
adapter.submitList(callLogs)
|
||||
}
|
||||
}
|
||||
)
|
||||
|
||||
listViewModel.missedCallLogs.observe(
|
||||
viewLifecycleOwner,
|
||||
{ callLogs ->
|
||||
viewLifecycleOwner
|
||||
) { callLogs ->
|
||||
if (listViewModel.missedCallLogsSelected.value == true) {
|
||||
adapter.submitList(callLogs)
|
||||
}
|
||||
}
|
||||
)
|
||||
|
||||
listViewModel.missedCallLogsSelected.observe(
|
||||
viewLifecycleOwner,
|
||||
{
|
||||
viewLifecycleOwner
|
||||
) {
|
||||
if (it) {
|
||||
adapter.submitList(listViewModel.missedCallLogs.value)
|
||||
} else {
|
||||
adapter.submitList(listViewModel.callLogs.value)
|
||||
}
|
||||
}
|
||||
)
|
||||
|
||||
listViewModel.contactsUpdatedEvent.observe(
|
||||
viewLifecycleOwner,
|
||||
{
|
||||
viewLifecycleOwner
|
||||
) {
|
||||
it.consume {
|
||||
adapter.notifyDataSetChanged()
|
||||
}
|
||||
}
|
||||
)
|
||||
|
||||
adapter.selectedCallLogEvent.observe(
|
||||
viewLifecycleOwner,
|
||||
{
|
||||
viewLifecycleOwner
|
||||
) {
|
||||
it.consume { callLog ->
|
||||
sharedViewModel.selectedCallLogGroup.value = callLog
|
||||
navigateToCallHistory(binding.slidingPane)
|
||||
}
|
||||
}
|
||||
)
|
||||
|
||||
adapter.startCallToEvent.observe(
|
||||
viewLifecycleOwner,
|
||||
{
|
||||
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}")
|
||||
sharedViewModel.updateDialerAnimationsBasedOnDestination.value = Event(R.id.masterCallLogsFragment)
|
||||
sharedViewModel.updateDialerAnimationsBasedOnDestination.value =
|
||||
Event(R.id.masterCallLogsFragment)
|
||||
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
|
||||
args.putBoolean(
|
||||
"SkipAutoCallStart",
|
||||
true
|
||||
) // If auto start call setting is enabled, ignore it
|
||||
navigateToDialer(args)
|
||||
} else {
|
||||
val localAddress = callLogGroup.lastCallLog.localAddress
|
||||
|
@ -259,7 +257,6 @@ class MasterCallLogsFragment : MasterFragment<HistoryMasterFragmentBinding, Call
|
|||
}
|
||||
}
|
||||
}
|
||||
)
|
||||
|
||||
binding.setAllCallLogsToggleClickListener {
|
||||
listViewModel.missedCallLogsSelected.value = false
|
||||
|
|
|
@ -22,7 +22,6 @@ package org.linphone.activities.main.history.viewmodels
|
|||
import androidx.lifecycle.MutableLiveData
|
||||
import androidx.lifecycle.ViewModel
|
||||
import androidx.lifecycle.ViewModelProvider
|
||||
import java.util.*
|
||||
import kotlin.collections.ArrayList
|
||||
import org.linphone.LinphoneApplication.Companion.coreContext
|
||||
import org.linphone.LinphoneApplication.Companion.corePreferences
|
||||
|
|
|
@ -69,11 +69,10 @@ class RecordingsFragment : MasterFragment<RecordingsFragmentBinding, RecordingsL
|
|||
binding.recordingsList.addItemDecoration(headerItemDecoration)
|
||||
|
||||
viewModel.recordingsList.observe(
|
||||
viewLifecycleOwner,
|
||||
{ recordings ->
|
||||
viewLifecycleOwner
|
||||
) { recordings ->
|
||||
adapter.submitList(recordings)
|
||||
}
|
||||
)
|
||||
|
||||
binding.setBackClickListener { goBack() }
|
||||
|
||||
|
|
|
@ -63,8 +63,8 @@ class AccountSettingsFragment : GenericSettingFragment<SettingsAccountFragmentBi
|
|||
binding.setBackClickListener { goBack() }
|
||||
|
||||
viewModel.linkPhoneNumberEvent.observe(
|
||||
viewLifecycleOwner,
|
||||
{
|
||||
viewLifecycleOwner
|
||||
) {
|
||||
it.consume {
|
||||
val authInfo = viewModel.account.findAuthInfo()
|
||||
if (authInfo == null) {
|
||||
|
@ -78,17 +78,15 @@ class AccountSettingsFragment : GenericSettingFragment<SettingsAccountFragmentBi
|
|||
}
|
||||
}
|
||||
}
|
||||
)
|
||||
|
||||
viewModel.accountRemovedEvent.observe(
|
||||
viewLifecycleOwner,
|
||||
{
|
||||
viewLifecycleOwner
|
||||
) {
|
||||
it.consume {
|
||||
sharedViewModel.accountRemoved.value = true
|
||||
goBack()
|
||||
}
|
||||
}
|
||||
)
|
||||
|
||||
view.doOnPreDraw {
|
||||
// Notifies fragment is ready to be drawn
|
||||
|
|
|
@ -55,8 +55,8 @@ class AdvancedSettingsFragment : GenericSettingFragment<SettingsAdvancedFragment
|
|||
binding.setBackClickListener { goBack() }
|
||||
|
||||
viewModel.uploadFinishedEvent.observe(
|
||||
viewLifecycleOwner,
|
||||
{
|
||||
viewLifecycleOwner
|
||||
) {
|
||||
it.consume { url ->
|
||||
val clipboard =
|
||||
requireContext().getSystemService(Context.CLIPBOARD_SERVICE) as ClipboardManager
|
||||
|
@ -69,31 +69,28 @@ class AdvancedSettingsFragment : GenericSettingFragment<SettingsAdvancedFragment
|
|||
AppUtils.shareUploadedLogsUrl(activity, url)
|
||||
}
|
||||
}
|
||||
)
|
||||
|
||||
viewModel.uploadErrorEvent.observe(
|
||||
viewLifecycleOwner,
|
||||
{
|
||||
viewLifecycleOwner
|
||||
) {
|
||||
it.consume {
|
||||
val activity = requireActivity() as MainActivity
|
||||
activity.showSnackBar(R.string.logs_upload_failure)
|
||||
}
|
||||
}
|
||||
)
|
||||
|
||||
viewModel.resetCompleteEvent.observe(
|
||||
viewLifecycleOwner,
|
||||
{
|
||||
viewLifecycleOwner
|
||||
) {
|
||||
it.consume {
|
||||
val activity = requireActivity() as MainActivity
|
||||
activity.showSnackBar(R.string.logs_reset_complete)
|
||||
}
|
||||
}
|
||||
)
|
||||
|
||||
viewModel.setNightModeEvent.observe(
|
||||
viewLifecycleOwner,
|
||||
{
|
||||
viewLifecycleOwner
|
||||
) {
|
||||
it.consume { value ->
|
||||
AppCompatDelegate.setDefaultNightMode(
|
||||
when (value) {
|
||||
|
@ -104,13 +101,12 @@ class AdvancedSettingsFragment : GenericSettingFragment<SettingsAdvancedFragment
|
|||
)
|
||||
}
|
||||
}
|
||||
)
|
||||
|
||||
viewModel.backgroundModeEnabled.value = !DeviceUtils.isAppUserRestricted(requireContext())
|
||||
|
||||
viewModel.goToBatterySettingsEvent.observe(
|
||||
viewLifecycleOwner,
|
||||
{
|
||||
viewLifecycleOwner
|
||||
) {
|
||||
it.consume {
|
||||
try {
|
||||
val intent = Intent("android.settings.IGNORE_BATTERY_OPTIMIZATION_SETTINGS")
|
||||
|
@ -120,12 +116,11 @@ class AdvancedSettingsFragment : GenericSettingFragment<SettingsAdvancedFragment
|
|||
}
|
||||
}
|
||||
}
|
||||
)
|
||||
|
||||
viewModel.powerManagerSettingsVisibility.value = PowerManagerUtils.getDevicePowerManagerIntent(requireContext()) != null
|
||||
viewModel.goToPowerManagerSettingsEvent.observe(
|
||||
viewLifecycleOwner,
|
||||
{
|
||||
viewLifecycleOwner
|
||||
) {
|
||||
it.consume {
|
||||
val intent = PowerManagerUtils.getDevicePowerManagerIntent(requireActivity())
|
||||
if (intent != null) {
|
||||
|
@ -137,11 +132,10 @@ class AdvancedSettingsFragment : GenericSettingFragment<SettingsAdvancedFragment
|
|||
}
|
||||
}
|
||||
}
|
||||
)
|
||||
|
||||
viewModel.goToAndroidSettingsEvent.observe(
|
||||
viewLifecycleOwner,
|
||||
{
|
||||
viewLifecycleOwner
|
||||
) {
|
||||
it.consume {
|
||||
val intent = Intent()
|
||||
intent.action = Settings.ACTION_APPLICATION_DETAILS_SETTINGS
|
||||
|
@ -151,7 +145,6 @@ class AdvancedSettingsFragment : GenericSettingFragment<SettingsAdvancedFragment
|
|||
ContextCompat.startActivity(requireContext(), intent, null)
|
||||
}
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
override fun goBack() {
|
||||
|
|
|
@ -54,24 +54,22 @@ class AudioSettingsFragment : GenericSettingFragment<SettingsAudioFragmentBindin
|
|||
binding.setBackClickListener { goBack() }
|
||||
|
||||
viewModel.askAudioRecordPermissionForEchoCancellerCalibrationEvent.observe(
|
||||
viewLifecycleOwner,
|
||||
{
|
||||
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,
|
||||
{
|
||||
viewLifecycleOwner
|
||||
) {
|
||||
it.consume {
|
||||
Log.i("[Audio Settings] Asking for RECORD_AUDIO permission for echo tester")
|
||||
requestPermissions(arrayOf(android.Manifest.permission.RECORD_AUDIO), 2)
|
||||
}
|
||||
}
|
||||
)
|
||||
|
||||
initAudioCodecsList()
|
||||
|
||||
|
|
|
@ -55,20 +55,22 @@ class CallSettingsFragment : GenericSettingFragment<SettingsCallFragmentBinding>
|
|||
binding.setBackClickListener { goBack() }
|
||||
|
||||
viewModel.systemWideOverlayEnabledEvent.observe(
|
||||
viewLifecycleOwner,
|
||||
{
|
||||
viewLifecycleOwner
|
||||
) {
|
||||
it.consume {
|
||||
if (!Compatibility.canDrawOverlay(requireContext())) {
|
||||
val intent = Intent("android.settings.action.MANAGE_OVERLAY_PERMISSION", Uri.parse("package:${requireContext().packageName}"))
|
||||
val intent = Intent(
|
||||
"android.settings.action.MANAGE_OVERLAY_PERMISSION",
|
||||
Uri.parse("package:${requireContext().packageName}")
|
||||
)
|
||||
startActivityForResult(intent, 0)
|
||||
}
|
||||
}
|
||||
}
|
||||
)
|
||||
|
||||
viewModel.goToAndroidNotificationSettingsEvent.observe(
|
||||
viewLifecycleOwner,
|
||||
{
|
||||
viewLifecycleOwner
|
||||
) {
|
||||
it.consume {
|
||||
if (Build.VERSION.SDK_INT >= Version.API26_O_80) {
|
||||
val i = Intent()
|
||||
|
@ -86,11 +88,10 @@ class CallSettingsFragment : GenericSettingFragment<SettingsCallFragmentBinding>
|
|||
}
|
||||
}
|
||||
}
|
||||
)
|
||||
|
||||
viewModel.enableTelecomManagerEvent.observe(
|
||||
viewLifecycleOwner,
|
||||
{
|
||||
viewLifecycleOwner
|
||||
) {
|
||||
it.consume {
|
||||
if (!Compatibility.hasTelecomManagerPermissions(requireContext())) {
|
||||
Compatibility.requestTelecomManagerPermissions(requireActivity(), 1)
|
||||
|
@ -102,11 +103,10 @@ class CallSettingsFragment : GenericSettingFragment<SettingsCallFragmentBinding>
|
|||
}
|
||||
}
|
||||
}
|
||||
)
|
||||
|
||||
viewModel.goToAndroidNotificationSettingsEvent.observe(
|
||||
viewLifecycleOwner,
|
||||
{
|
||||
viewLifecycleOwner
|
||||
) {
|
||||
it.consume {
|
||||
if (Build.VERSION.SDK_INT >= Version.API26_O_80) {
|
||||
val i = Intent()
|
||||
|
@ -124,7 +124,6 @@ class CallSettingsFragment : GenericSettingFragment<SettingsCallFragmentBinding>
|
|||
}
|
||||
}
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
|
||||
|
|
|
@ -50,8 +50,8 @@ class ChatSettingsFragment : GenericSettingFragment<SettingsChatFragmentBinding>
|
|||
binding.setBackClickListener { goBack() }
|
||||
|
||||
viewModel.launcherShortcutsEvent.observe(
|
||||
viewLifecycleOwner,
|
||||
{
|
||||
viewLifecycleOwner
|
||||
) {
|
||||
it.consume { newValue ->
|
||||
if (newValue) {
|
||||
Compatibility.createShortcutsToChatRooms(requireContext())
|
||||
|
@ -60,11 +60,10 @@ class ChatSettingsFragment : GenericSettingFragment<SettingsChatFragmentBinding>
|
|||
}
|
||||
}
|
||||
}
|
||||
)
|
||||
|
||||
viewModel.goToAndroidNotificationSettingsEvent.observe(
|
||||
viewLifecycleOwner,
|
||||
{
|
||||
viewLifecycleOwner
|
||||
) {
|
||||
it.consume {
|
||||
if (Build.VERSION.SDK_INT >= Version.API26_O_80) {
|
||||
val i = Intent()
|
||||
|
@ -82,7 +81,6 @@ class ChatSettingsFragment : GenericSettingFragment<SettingsChatFragmentBinding>
|
|||
}
|
||||
}
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
override fun goBack() {
|
||||
|
|
|
@ -51,8 +51,8 @@ class ContactsSettingsFragment : GenericSettingFragment<SettingsContactsFragment
|
|||
binding.setBackClickListener { goBack() }
|
||||
|
||||
viewModel.launcherShortcutsEvent.observe(
|
||||
viewLifecycleOwner,
|
||||
{
|
||||
viewLifecycleOwner
|
||||
) {
|
||||
it.consume { newValue ->
|
||||
if (newValue) {
|
||||
Compatibility.createShortcutsToContacts(requireContext())
|
||||
|
@ -64,17 +64,15 @@ class ContactsSettingsFragment : GenericSettingFragment<SettingsContactsFragment
|
|||
}
|
||||
}
|
||||
}
|
||||
)
|
||||
|
||||
viewModel.askWriteContactsPermissionForPresenceStorageEvent.observe(
|
||||
viewLifecycleOwner,
|
||||
{
|
||||
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")
|
||||
|
|
|
@ -69,31 +69,30 @@ class SettingsFragment : SecureFragment<SettingsFragmentBinding>() {
|
|||
|
||||
// Account settings loading can take some time, so wait until it is ready before opening the pane
|
||||
sharedViewModel.accountSettingsFragmentOpenedEvent.observe(
|
||||
viewLifecycleOwner,
|
||||
{
|
||||
viewLifecycleOwner
|
||||
) {
|
||||
it.consume {
|
||||
binding.slidingPane.openPane()
|
||||
}
|
||||
}
|
||||
)
|
||||
|
||||
sharedViewModel.closeSlidingPaneEvent.observe(
|
||||
viewLifecycleOwner,
|
||||
{
|
||||
viewLifecycleOwner
|
||||
) {
|
||||
it.consume {
|
||||
if (!binding.slidingPane.closePane()) {
|
||||
goBack()
|
||||
}
|
||||
}
|
||||
}
|
||||
)
|
||||
sharedViewModel.layoutChangedEvent.observe(
|
||||
viewLifecycleOwner,
|
||||
{
|
||||
viewLifecycleOwner
|
||||
) {
|
||||
it.consume {
|
||||
sharedViewModel.isSlidingPaneSlideable.value = binding.slidingPane.isSlideable
|
||||
if (binding.slidingPane.isSlideable) {
|
||||
val navHostFragment = childFragmentManager.findFragmentById(R.id.settings_nav_container) as NavHostFragment
|
||||
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()
|
||||
|
@ -101,7 +100,6 @@ class SettingsFragment : SecureFragment<SettingsFragmentBinding>() {
|
|||
}
|
||||
}
|
||||
}
|
||||
)
|
||||
binding.slidingPane.lockMode = SlidingPaneLayout.LOCK_MODE_LOCKED
|
||||
|
||||
/* End of shared view model & sliding pane related */
|
||||
|
@ -112,12 +110,11 @@ class SettingsFragment : SecureFragment<SettingsFragmentBinding>() {
|
|||
binding.setBackClickListener { goBack() }
|
||||
|
||||
sharedViewModel.accountRemoved.observe(
|
||||
viewLifecycleOwner,
|
||||
{
|
||||
viewLifecycleOwner
|
||||
) {
|
||||
Log.i("[Settings] Account removed, update accounts list")
|
||||
viewModel.updateAccountsList()
|
||||
}
|
||||
)
|
||||
|
||||
val identity = arguments?.getString("Identity")
|
||||
if (identity != null) {
|
||||
|
|
|
@ -33,7 +33,7 @@ class TelephonyListener(private val telephonyManager: TelephonyManager) : PhoneS
|
|||
|
||||
private fun runOnUiThreadExecutor(): Executor {
|
||||
val handler = Handler(Looper.getMainLooper())
|
||||
return Executor() {
|
||||
return Executor {
|
||||
handler.post(it)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<layout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:bind="http://schemas.android.com/tools">
|
||||
<layout xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
|
||||
<data>
|
||||
<import type="android.view.View"/>
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<layout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:bind="http://schemas.android.com/tools">
|
||||
<layout xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
|
||||
<data>
|
||||
<import type="android.view.View"/>
|
||||
|
|
Loading…
Reference in a new issue