httpdispatch / MissedNotificationsReminder

Periodical sound reminder for missed notifications in Android OS.
74 stars 22 forks source link

Add support configuring notification channels differently #56

Closed rryk closed 3 years ago

rryk commented 4 years ago

Currently, the app only provides a way to configure whether all notifications from a specific app are repeated or not. Some applications, such as Google Search app, generate a lot of notifications and whereas some are important, e.g. reminders, others can be safely ignored, e.g. audio playback.

Starting with API 26, Android allows app developers to specify a channel for each notification, allowing notifications to be classified into various groups and its behavior (vibration, sound, appearance on the screen etc.) to be configured individually by the user. Many apps take advantage of this feature, including the Google Search app, which has many channels.

Exposing these channels on the app selection screen and allowing the user to configure MNR to only repeat notifications from select channels would be a very useful feature.

P.S. I have just started working on this feature myself. Creating this issue to gauge interest and reference it once I have the pull request ready. If you are working on a similar feature already, please let me know so that we do not do the same work twice.

httpdispatch commented 4 years ago

@rryk wow, that would be a great feature for many users. As for me, i am not working on such feature yet (making migration to kotlin and some other libraries only), so you may keep going. Once it will be done i'll make the merge with master and development branches.

Such as you are starting to make app specific settings would be good to use some POJO for app level settings, so it may be extended in the future. To serialize/deserialize data for shared preferences compatibility we may use moshi library

rryk commented 4 years ago

I was actually planning to change the setting containing set of apps from Set<String> to Map<String, Set<String>> with keys being the package names and values being set of channel IDs. The value may be null, in which case it means all channels. I wasn't planning to change how serialization works (I thought it was taken care by some system code) and as for migration, I was thinking to simply upgrade how provider at https://github.com/httpdispatch/MissedNotificationsReminder/blob/master/app/src/main/java/com/app/missednotificationsreminder/data/DataModule.java#L225 works. If it reads Set<String>, it would rewrite it as Map<String, Set<String>> with old entries as keys and values set to nulls. When writing we will use new type, which it will return as is.

An interesting case that needs to be considered is what to do if a new notification channel is added to an app. Should we notify on it or not? I think a reasonable policy is to notify on it if the value for the corresponding package is null and ignore if it contains a list of channel IDs. The UI will display a small button next to app name in the application list, which will open a new activity. This activity will have a checkbox "All channels" and a list of channels below it. By default "All channels" is selected and list is grayed out.

rryk commented 4 years ago

Ah, I think I see what you mean now. https://developer.android.com/reference/android/content/SharedPreferences only has methods to get basic types and a set of strings, not maps. So I guess, yeah, we could serialize/deserialize the setting as JSON using Moshi.

httpdispatch commented 4 years ago

I thought about POJO not only because of SharedPreferences limitation. In the future it would be possible to extend per-application settings and add there, for example, regexp pattern to filter notifications. It is a bit trickier to add custom ringtones and reminder intervals, because of possible settings conflicts for different apps.

rryk commented 3 years ago

Sorry for not replying for so long. I was quite busy with lots of things at work/home, so didn't have time to work on this feature. However, I was considering starting to work on it now. Have you completed kotlin rewrite yet? Should I rebase on master or some other brandh to avoid working on rewritten code?

httpdispatch commented 3 years ago

Yes, I've completed the kotlin migration mostly. Also I have drafts of regex filtering feature for notification data in progress. As for the channels I've found that third party app can't obtain other apps available notification channels information. However it is possible to obtain channel name directly from the received notification. So I think that regex filtering functionality may cover channel filtering also. If you have better ideas let me know

rryk commented 3 years ago

As for the channels I've found that third party app can't obtain other apps available notification channels information.

That's a bummer.

So I think that regex filtering functionality may cover channel filtering also.

What would regex be matched against? Notification content, channel name, app name? All of the above?

httpdispatch commented 3 years ago

That's a bummer.

But seems that it is true https://stackoverflow.com/questions/50880715/how-to-access-notification-channels-for-another-android-app

What would regex be matched against? Notification content, channel name, app name? All of the above?

I thought to use all the available text content. This will be feature mostly for nerds because of usage complexity

rryk commented 3 years ago

I thought to use all the available text content. This will be feature mostly for nerds because of usage complexity

Yeah, makes sense. In this case I will be closing this issue as there is not much we can do short of rewriting Android.