-
Couldn't load subscription status.
- Fork 184
Integrate Send Tab and Push components #865
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
Integrate Send Tab and Push components #865
Conversation
0af1898 to
12b2ddc
Compare
|
|
||
| // Pick a random ID for this notification so that different tabs do not clash. | ||
| @SuppressWarnings("MagicNumber") | ||
| val notificationId = (Math.random() * 100).toInt() |
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.
Should we use NotificationIds?
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.
Yes please. :)
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.
Wouldn't this give me the same id all the time? I don't have different tags, but I need new IDs generated for each tab sent.
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.
Ah, yeah, that is tricky. You could still create a different tag based on the URL every time. But that is also wasteful.
Anyhow, using random will just randomly replace other notifications and is not a good choice.
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.
I took the NotificationManager from Fenix, so I wonder how that's working 🤔 .
I guess I should store the IDs in a map to avoid collisions.
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.
Since we're using a unique tag for send tab, I added a simple notification ID counter that would always increment up. That should avoid notification ID collisions.
app/src/main/java/org/mozilla/reference/browser/NotificationManager.kt
Outdated
Show resolved
Hide resolved
app/src/main/java/org/mozilla/reference/browser/NotificationManager.kt
Outdated
Show resolved
Hide resolved
app/src/main/java/org/mozilla/reference/browser/NotificationManager.kt
Outdated
Show resolved
Hide resolved
|
|
||
| // Pick a random ID for this notification so that different tabs do not clash. | ||
| @SuppressWarnings("MagicNumber") | ||
| val notificationId = (Math.random() * 100).toInt() |
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.
Ah, yeah, that is tricky. You could still create a different tag based on the URL every time. But that is also wasteful.
Anyhow, using random will just randomly replace other notifications and is not a good choice.
12b2ddc to
46ffb59
Compare
app/src/main/java/org/mozilla/reference/browser/NotificationManager.kt
Outdated
Show resolved
Hide resolved
| /** | ||
| * Manages notification channels and allows displaying different types of notifications. | ||
| */ | ||
| class NotificationManager(private val context: Context) { |
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.
Since we're creating an NotificationManager, should DataReportingNotification also use this?
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.
Oh wow, when I rebased I didn't see this. I think it's fair to merge them together.
| } | ||
|
|
||
| // Use an incrementing notification ID since they have the same tag. | ||
| var sendTabNotificationIdCount = 0 |
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.
Maybe more generic name if we're using this class for all notifications
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.
LGTM. Some questions related to the new NotificationManager
46ffb59 to
33c395e
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.
🚢
Needs some love from releng to get us the Firebase keys into r-b, but it should work after that. 🎉
Pull Request checklist
Before merging checklist