Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#241 Group call notifications #250

Open
wants to merge 18 commits into
base: sc
Choose a base branch
from
Open

Conversation

Turubaev
Copy link

@Turubaev Turubaev commented Sep 9, 2024

This PR add ring for group jitsi calls. Also it includes corresponding lab feature, that enable/disable this functionality.

@SpiritCroc
Copy link
Member

Thanks for your PR! I'll properly review and test when I have more time, maybe on the weekend.
I see you have added strings to both strings.xml and strings_sc.xml, you probably want to remove the duplicated ones from strings.xml.

when (intent?.getIntExtra(EXTRA_CALL_ACTION_KEY, 0)) {
CALL_ACTION_REJECT -> {
val callId = intent.getStringExtra(EXTRA_CALL_ID) ?: return
notificationUtils.cancelAllNotifications()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this really cancel all notifications?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeap, this was for testing purpose. Fixed, here we should cancel certain notification

@Turubaev
Copy link
Author

Thanks for your PR! I'll properly review and test when I have more time, maybe on the weekend. I see you have added strings to both strings.xml and strings_sc.xml, you probably want to remove the duplicated ones from strings.xml.

When I try to remove from "string.xml", I got "Unresolved reference: call_notification_open_app_action" while building the project. May be you can give example, how to correctly fix it

Copy link
Member

@SpiritCroc SpiritCroc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would you mind rebasing on top of SchildiChat's sc branch? If I merge this as is currently, it pulls in some unwanted upstream commits

@Turubaev
Copy link
Author

Would you mind rebasing on top of SchildiChat's sc branch? If I merge this as is currently, it pulls in some unwanted upstream commits

Rebased, could you check if it is correct now ?

Copy link
Member

@SpiritCroc SpiritCroc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rebase is fine!
I think your logic for detecting jitsi calls is too generic. From checking the code it looks like it triggers for all kind of widgets. From my experiments it also triggers when removing widgets (i.e. the call will ring again when you actually remove it).

In case it's too hard to get the detection fully accurate, you may get a way with adding a description to the settings so users know about the downsides, but showing a call notification for say a timetable widget being added could be somewhat confusing.

@@ -51,6 +51,7 @@
<bool name="settings_labs_rich_text_editor_default">false</bool>
<bool name="settings_labs_enable_voice_broadcast_visible">true</bool>
<bool name="settings_labs_enable_voice_broadcast_default">false</bool>
<bool name="settings_labs_enable_jitsi_call_notifications_default">true</bool>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should be false

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Disabled by default

@@ -498,6 +498,8 @@ fun Event.getPollContent(): MessagePollContent? {
return getClearContent().toModel<MessagePollContent>()
}

fun Event.isJitsiEvent() = this.getClearType() == EventType.STATE_ROOM_WIDGET_LEGACY
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks too generic to me, won't that trigger for all kinds of widgets, not just jitsi?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated detecting function to more accurate one

@@ -0,0 +1 @@
Added ring for group calls
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We don't need this file for downstream changes

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed this file

@@ -180,4 +180,6 @@
<string name="settings_clear_highlight_on_scroll">Очистить выделение при прокрутке</string>
<string name="settings_call_ringtone_use_default_stun_title">Разрешить резервный сервер звонков</string>
<string name="settings_integrations_scalar_warning">⚠️ Эта настройка по умолчанию (если не изменена конфигурацией Вашего домашнего сервера) включает доступ к \"Scalar\", менеджеру интеграций от Element. К сожалению, он является проприетарным, т.е. его исходый код не открытый и не может быть проверен пользователями или разработчиками SchildiChat.</string>
<string name="call_notification_open_app_action">Открыть приложение</string>
<string name="labs_enable_group_call_notifications_summary">Включить уведомление для групповых звонков</string>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure if weblate will be happy for manually added translations. Maybe it works but safer path would probably merging without translation first, then add translations via weblate later. 🤔

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed manually added translation for Russian

@SpiritCroc
Copy link
Member

SpiritCroc commented Sep 25, 2024

This is quite buggy. I now get call notifications even when I send myself messages in a total different room (a DM), for a different room in which I stopped the widget before.

@alexander-potemkin
Copy link

This is quite buggy. I now get call notifications even when I send myself messages in a total different room (a DM), for a different room in which I stopped the widget before.

Apologies for the issue and thanks for raising it - somehow it missed our tests - something we shall work at.

Meanwhile - picking this up, hopefully will be fixed in a week or two max.

…ault. Changed detection for group calls more accurate. Added tracking visibility status for jitsi notifications
@Turubaev
Copy link
Author

Turubaev commented Oct 5, 2024

This is quite buggy. I now get call notifications even when I send myself messages in a total different room (a DM), for a different room in which I stopped the widget before.

Fixed all cases, tested, now that should be much better. Could you please check updated version?

Copy link
Member

@SpiritCroc SpiritCroc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! With these changes, it no longer notified for jitsi calls for me. Looks like I got
JitsiEventContent(type=jitsi, name=Jitsi), i.e. with uppercase name rather then what you're checking. I was able to fix by adding lowercase() calls to the check, so it matches both lowercase and uppercase scenarios:

content?.toModel<JitsiEventContent>()?.type?.lowercase() == IS_JITSI_CALL && content.toModel<JitsiEventContent>()?.name?.lowercase() == IS_JITSI_CALL

Otherwise seems to work fine now. I think I'm fine with merging, but I'll probably want to do some code refactoring right after to reduce possible future merge conflicts (I've learnt some tricks which probably doesn't make sense to expect from new contributors to apply).

Let me know if you've tested this a bunch and are confident it works fine for you, so you consider it ready for merge.

@@ -1,7 +1,5 @@
apply plugin: 'com.android.library'

apply plugin: 'com.android.library'
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How does this change relate to the PR?
(I see the line is duplicated, but fixing upstream code style is not really something we want to do here)

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was unable to build properly and launch an app, with this duplicated line and after removing it, building was success. I am not sure how it affects and can't remember exact error, unfortunately. Do you think we should return back this duplicated line ?

@Turubaev
Copy link
Author

Turubaev commented Oct 7, 2024

Thanks! With these changes, it no longer notified for jitsi calls for me. Looks like I got JitsiEventContent(type=jitsi, name=Jitsi), i.e. with uppercase name rather then what you're checking. I was able to fix by adding lowercase() calls to the check, so it matches both lowercase and uppercase scenarios:

content?.toModel<JitsiEventContent>()?.type?.lowercase() == IS_JITSI_CALL && content.toModel<JitsiEventContent>()?.name?.lowercase() == IS_JITSI_CALL

Otherwise seems to work fine now. I think I'm fine with merging, but I'll probably want to do some code refactoring right after to reduce possible future merge conflicts (I've learnt some tricks which probably doesn't make sense to expect from new contributors to apply).

Let me know if you've tested this a bunch and are confident it works fine for you, so you consider it ready for merge.

Yeap, I think modifying to lowercase would be much better, to ensure that strings compared correctly. Tested after applying this changes, everything looks good. From my perspective, it is ready to be merged

@alexander-potemkin
Copy link

Otherwise seems to work fine now. I think I'm fine with merging

@SpiritCroc thank you very much! I don't mean to push or cause any other kind of inconvenience - I understand you are doing and will be doing it when you can. Just to plan things - do you have any ideas when you believe you can have this merged?

I'll probably want to do some code refactoring right after to reduce possible future merge conflicts (I've learnt some tricks which probably doesn't make sense to expect from new contributors to apply).

And I can't help myself and ask: what is the idea in general?
My experience is that keeping a fork up to date is quite a task, so in my personal experience I try keeping abstractions solid and keep my code aside as much as possible, keeping in mind that fork and merge would be a diff / patch work after all, but I wonder what is your experience and tools set in that case? If you don't mind me asking?

@SpiritCroc
Copy link
Member

@SpiritCroc thank you very much! I don't mean to push or cause any other kind of inconvenience - I understand you are doing and will be doing it when you can. Just to plan things - do you have any ideas when you believe you can have this merged?

No ETAs.

And I can't help myself and ask: what is the idea in general? My experience is that keeping a fork up to date is quite a task, so in my personal experience I try keeping abstractions solid and keep my code aside as much as possible, keeping in mind that fork and merge would be a diff / patch work after all, but I wonder what is your experience and tools set in that case? If you don't mind me asking?

There's a bunch of tricks, I haven't really started writing them down yet. Some things

  • Use your own files instead of upstream files as much as possible (kotlin extension functions are great for this!), unless you want to be sure you don't miss any updates to the upstream login in that file. Exaggerated example to keep upstream impact low: SchildiChat/schildichat-android-next@5366754
  • When wrapping upstream code into additional blocks (if-else or whatever), don't mind code-style, just keep the upstream indention as is.
  • For some things, may be useful to write scripts to revert some changes to upstream before the merge, and restore your own changes after. See pre_merge.sh and post_merge.sh in this repo.

@alexander-potemkin
Copy link

There's a bunch of tricks, I haven't really started writing them down yet. Some things

  • Use your own files instead of upstream files as much as possible (kotlin extension functions are great for this!), unless you want to be sure you don't miss any updates to the upstream login in that file. Exaggerated example to keep upstream impact low: SchildiChat/schildichat-android-next@5366754
  • When wrapping upstream code into additional blocks (if-else or whatever), don't mind code-style, just keep the upstream indention as is.
  • For some things, may be useful to write scripts to revert some changes to upstream before the merge, and restore your own changes after. See pre_merge.sh and post_merge.sh in this repo.

Thank you! I had something similar from my experience, but couldn't help myself with code-style things... That would help me to stay in line :)

No ETAs.

Understood, makes perfect sense.

If there is something we could do - please, let us know! We would really need that working the sooner - the better, so if there is anything - anything at all - that could be done from my side - just ping me.

@SpiritCroc
Copy link
Member

Out of curiosity, what makes this feature urgent in your eyes? I'm a bit surprised that people invest time on jitsi at all with Element call on the horizon. (Not that that would affect how much time my weekend gives me, just curious)

@alexander-potemkin
Copy link

Out of curiosity, what makes this feature urgent in your eyes? I'm a bit surprised that people invest time on jitsi at all with Element call on the horizon. (Not that that would affect how much time my weekend gives me, just curious)

Sure, to keep things short: Element X is not exactly there yet, and I guess it will take them like half-of-the-year to stabilize and/or reach features parity. And missing the calls is something very much annoying, especially if those group calls are actually a 1:1 calls - that breaks ability to work normally.

The thing is that 'groups' are happening at Matrix when you add a third something to 1:1 chat. That something doesn't have to be a person - it could be a bot doing some function you need for work. So, immediately, after you try to enhance your chat with a tool, you lose the ability to make calls.
And it goes without saying, that having a group / conference calls feels just natural.

So, at the end of the day we end up with a custom development. Android team seems like ignoring anything related to that functionality (issue at meta, issue at android).
I understand the Element/Matrix team is now passing over complicated times, merging the code from someone outside still requires some time and resources, but that particular issue is like a blank spot, or at least that's how it feels to me.

I always liked SchildiChat approach (you might remember - I was asking for an iOS port earlier) so I decided this time we shall try our luck with SchildiChat and I'm glad to see that you are responding.

I understand that the amount of time in days is limited and that to re-organize code takes time, but it's still our best option, and I'm absolutely grateful for everything you do!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants