-
-
Notifications
You must be signed in to change notification settings - Fork 944
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
Dismiss notifications by swiping right #1173
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you keep the original commits, so that then the original author is credited properly?
I think the original author is properly credited: commit author is still Simon Willshire, and I'm mentioned as co-author in the commit, which is also shown correctly in the GitHub overview And I like clean commits which work by itself. |
e75f3cf
to
3cf9e98
Compare
fixed code formatting errors and rebased on current develop branch |
Ah ok, I didn't see @Tiggilyboo's profile picture by the commit, so I thought they weren't a co-author. |
Nice work, testing it on my watch, so far everything's stable and working as expected! |
ef0cda7
to
b934383
Compare
If I have notifications like this: The PineTime LCD drawing is very slow and not well suited to display movement without making use of hardware scrolling. There are only a few frames of animation using this method. It would be nice if the sideways animation that's used between QuickSettings and watchface could be used here too. TRIM_20220611_173137.mp4There's also this old notification dismissal pull which is probably worth examining if that hasn't been done already #323. |
b934383
to
d961ffd
Compare
fixed the direction a new notifications is moved in. Didn't touch the swipe animation as quite like the swiping animation when dismissing the notification. Would it be a show stopper to keep the little laggy animation? Thanks to InfiniTimeOrg/InfiniSim#37 the screen transitions can also be shown in the simulator |
Agree, also I quite like the animation. Is the hardware scrolling only limited to the y direction? Will take a look and see for later MR. Good work! |
I wouldn't say I like the laggy animation, but perhaps it's passable. I'd personally like for it to be changed soon after merging though if we don't change it beforehand. There is only hardware based vertical scrolling. This is why the horizontal scrolling is done in stripes. I recently also had a crash related to notifications, but can't remember what branch I was running. It happened when notifications were already open, I think as history and not a popup, I think the screen was also on and I received a new notification. |
@Riksu9000 Would enabling VSync help make the animation more seamless? Alternatively we could cheat by displaying a small thrash pop-up on top of the current notification and then use vertical scroll to go to the next notification. |
Edit: never mind it's not a solution. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for this PR, this feature will make a lot of users happy ;-)
There are a few points I would like to discuss before merging.
I have to admit that the sliding animation looks far better than what I would have expected knowing that the whole screen is refreshed at every frame. However, this is still not on par with other animations in the project (the vertical animation is smooth thanks to the hardware scrolling effect, and the left/right animations we use for the quick menu hides the slowness of the display). On one hand, I like this animation because it's similar to what we are used to on other touch devices, and on the other side, it's still a bit laggy. I would like to keep the UI of InfiniTime as smooth as possible, so I would appreciate if we at least tried to improve this one.
The changes in the struct NotificationManager::Notification
. In the original code, the struct contained a field id
. Its purpose was to uniquely identify a notification regardless of it position in the buffer. I added this field knowing that in the future, we will want to remove a specific notification either via BLE or the UI. As notification are received asynchronously, a new notification could be received while another one is being removed, which could result in the wrong notification being deleted. The purpose of this id
field was to ensure that the correct notification is removed.
The new implementation removed that field and also mixes the concept of id
(identifier) and index
(position in the buffer). I think this implementation could be reviewed to re-add the concept of id
: each notification has an unique ID, and, when the Notification app wants to delete a notification, it passes the id
of the notification instead of the index
of the notification in the buffer.
Note : when writing this comment, I noticed that NotificationManager does not seem to be correctly protected against concurrent accesses from BLE and the UI (and was not before this PR)... that's probably something to keep in mind if we encounter crashes.
Notice that GetNext()
, GetPrevious()
and GetLastNotification()
return the Notification by value and I did it on purpose : If they returned a ref to the notification, the content of notification could be changed/deleted by a new notification received by BLE while it's currently being processed in the Notification app. I think the new methods At()
should do the same. I also find the name At()
a bit confusing and inconsistent. Couldn't we name this method Get()
?
Regarding the code formatting, the variables begin_idx
and read_idx
and index_
do not follow the coding conventions of the project.
Well, I hope I didn't discourage you with this rather long review, and feel free to discuss those comments if you do not agree with me ;-)
The easiest solution for the transition would be to use the "swipe right stripey" animation (the one that is used from clock to quicksettings) to "disintegrate" the current notification and instantly show the new one. Then the checks if a new message is shown to swipe in from below or of the top of the screen could be removed as well. Another a bit more complicated way would be to "disintegrate" onto a black new screen, which in turn then swipes to the new message (from below or top). The The uh, yes sorry, I need to rename those internal variables 😅 I like code reviews. They take effort and time, but the outcome is always better code and programmers who learned something new :) |
d742e6a
to
4d85f7a
Compare
ready for re-review
|
Thanks @NeroBurner. The result looks quite good, IMO : https://video.codingfield.com/w/p4kXKd3Bp9co4C6yvKvjQR But I'm still a bit troubled by the new NotificationManager : it still exposes methods with "indexes" in the public API, which is against the encapsulation goal of the original implementation. In the original implementation, my goal was to provide a high level API to the Notification screen:
In my mind, the only change needed to add support for notification dismissal should be to add a method There might be good reasons to re-write a lot of the internals of NotificationManager, but I can't see them. Was the original implementation not adapted to this new use-case? Was it too complex or too difficult to understand? However, I really think we should keep the encapsulation level as it was in the original implementation. |
Could we do that refactor in a follow-up PR? |
I've got a few hours today to see how much I can rewrite the encapsulation. The reason for the rewrite was the problems with the dismiss and reordering of the notifications after a dismiss. And the dependence of the "id" to the displayed index (the notification 1/5 part on the display). A great part of the rewrite at the |
Yes, probably :) And I'm even willing to write such PR, as I have a clear view of what I would like to achieve (and probably fail at explaining it). |
Thanks for the explanation! So yes, indeed, changes in NotificationManager were indeed needed! I didn't realize that when reading the PR. |
f757c94
to
effecd6
Compare
That was easier than I expected 🎉 I still needed to introduce two new functions in total:
This way Edit: it's three new functions
|
effecd6
to
f12bb82
Compare
f12bb82
to
245d4a7
Compare
Add a new interface `NotificationManager::Dismiss(id)` to delete a notification with the specified `id`. The animate the notification dismiss the `RightAnim` transition to a black screen is used. After the dismiss the new message is swiped in from below or above. If we dismiss the oldest message (when we are at 5/5, or 3/3), then the new message after a dismiss should appear to come from below. Otherwise (when we are at 2/3) the new message after a dismiss should appear to come from above. Rework the index code to show the index of the currently viewed notification. Instead of calculating the index relative to the oldest `id` introduce a new interface `NotificationManager::IndexOf(id)`. This is done because the `id` of the notifications in the buffer aren't continuous anymore (as some messages could have been dismissed). Rework notification ring buffer to have a beginIdx and a size internally to make the dismissal of notifications easier. Fixes: #176 Co-authored-by: Simon Willshire <me@simonwillshire.com> Co-authored-by: Reinhold Gschweicher <pyro4hell@gmail.com>
245d4a7
to
8bcfde7
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This'll be a great addition to the next release. The fast animations look great.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It looks really good to me, thanks for making the extra effort on this PR, @NeroBurner
@NeroBurner Thank you for this great feature! Could you consider to make the dismiss function also work for incoming notifications? (The screen that you see when you just received a notification and which shows is a time/progress bar until it goes back to the current app.) |
@devnoname120 please create a separate issue (or maybe one is already open) and ping me there It should be possible |
@NeroBurner Someone else created an issue in the mean time: #1232 |
Original code by @Tiggilyboo at #1150 rebased on current
develop
branch. I just reworked the ringbuffer and squashed to one clean commitRework notification ring buffer to have a begin-idx and a size_ internally. And add a new interface to access the notifications by index. The
0
index is always the latest notification.The second new function is a
Dismiss
function to remove the notification with a specified idx from the buffer.Fixes: #176