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

Notification before expiry date #410

Open
GlitchCat opened this issue Sep 21, 2021 · 12 comments
Open

Notification before expiry date #410

GlitchCat opened this issue Sep 21, 2021 · 12 comments
Labels
common: uncommon Most users are unlikely to come across this or unexpected workflow severity: minor Impairs non-critical functionality or suitable workarounds exist type: enhancement New feature or request

Comments

@GlitchCat
Copy link

Catima allows setting an expiry date. It would be useful to get a notification before the card is expired, in the case of cards with monetary value.

Could be implemented by setting an per-card notification or by adding it to the settings.
Like being able to set a notification for x weeks or days before the expiry date.

@TheLastProject TheLastProject added type: enhancement New feature or request state: help wanted I looked into this issue but couldn't solve it quickly labels Sep 21, 2021
@Ashutoshgupta22
Copy link

Hey! I would like to work on this issue ..

@TheLastProject
Copy link
Member

Sure, go ahead. I can't help you much with this though, as Android "alarms" are not existing knowledge to me either.

@TheLastProject TheLastProject added common: uncommon Most users are unlikely to come across this or unexpected workflow severity: minor Impairs non-critical functionality or suitable workarounds exist labels Feb 5, 2022
@TheLastProject
Copy link
Member

Someone on Google Play asked to add it to a calendar. And that actually raised an interesting idea: instead of implementing this as alerts and everything in Catima, Catima would become a Calendar Provider: https://developer.android.com/guide/topics/providers/calendar-provider

It could then automatically expose a Catima calendar with all expiry dates in there and if cards get deleted/updated update it in the calendar.

Not sure if easier, may be way harder, but it'd be interesting to look into.

@TheLastProject
Copy link
Member

Of course, a much simpler method would be to, when you save a card with a change in expiry date, ask the user if they want to add that expiry date to their calendar.

@TheLastProject
Copy link
Member

Actually, let's go for that, it would be pretty simple to implement and very useful. Users don't expect things shared to their calendar to be synced up normally anyway.

Changing this task to "Good first issue" because implementing it that way would not be much more than:

  1. See if the expiry date changed when someone hits save
  2. Show a dialog
  3. If yes, start a calendar intent

@TheLastProject TheLastProject added good first issue Good for newcomers and removed state: help wanted I looked into this issue but couldn't solve it quickly labels May 21, 2022
@haynescd
Copy link

I see the pull request was never merged? I would like to work this issue if that is cool.

@TheLastProject
Copy link
Member

Yeah that PR was never finished.

Looking back, I'm not 100% sure which method of implementing would be best, but you're free to give implementing it a try :)

@haynescd
Copy link

So I can do something similar to this

And just have the app sync those reminders with the Calendar using the Calendar Provider API you mentioned above?

@TheLastProject
Copy link
Member

There are many ways to go about it and in typical me fashion I've probably been overcomplicating it.

I think we need to go back to the design phase and use something that's simpler and less flexible, but should still work perfectly in the vast majority of use cases.

Maybe a better way to design this would be to:

  1. Add a section to the settings screen for reminders. In this section, add:
    • An "Enable reminders" checkbox. If disabled, all other options are greyed out.
    • A "Remind me for expiring cards" which is just a bunch of checkboxes like "Day of expiry", "1 day in advance", "2 days in advance", "3 days in advance", "1 week in advance", "1 month in advance" (wonder which are the best possible values, maybe these are? We can easily add more later)
    • A "Reminder time" which allows you to select at what hour you want reminders (what is a good default? 11:00 maybe, as most people probably are awake by then but it's still early enough to get a reminder for a lunch coupon being about to expire?)
  2. When enabling reminders or changing the reminder time set an Android timer (assuming this is the right way) for the chosen time and cancel all other Catima-set timers.
  3. When the timer is called, loop over all cards, check the expiry field and compare it to the expiry alert setting.

I have no experience with Android timers though, so this may be quite a challenging task (how do we make sure Android will actually execute our timer?), but also probably closest to how people expect apps to behave (the app itself reminds you)

Do you have any suggestions or opinions?

@TheLastProject TheLastProject added state: consensus-needed A consensus needs to be reached before this can be implemented and removed good first issue Good for newcomers labels Jul 15, 2022
@haynescd
Copy link

Yea, Ok that is fair. I didn't know how much you wanted to deviate from what you and the previous guy were working....

Yea, I like that idea. Seems simple enough. For "Remind me for expiring cards" I don't know which would be better either. (If having multiple or one reoccurring one) The core logic should be done where this would be just a detail and change when we see it...

Yea, I don't have much experience with Android notifications, but my only suggestion would be to follow the standard way with how most apps send notifications, instead of updating the users calendar. I have one app that does that and it seems kinda invasive. (At least to me)

Just briefly searching I saw mention of an AlarmManager to schedule future intents to wake your app up. We could have some broadcastReceiver listening for this intent to push a notification to the user.

@TheLastProject
Copy link
Member

Yea, Ok that is fair. I didn't know how much you wanted to deviate from what you and the previous guy were working....

I'm always willing to change plans if the new plan is better, especially if it hasn't been released yet as there won't be anyone used to the way it works yet. Designing stuff is hard, and sometimes even when the plan seems perfect it turns out the actual experience isn't that great. But I'm pretty hopeful about this one :)

Yea, I like that idea. Seems simple enough. For "Remind me for expiring cards" I don't know which would be better either. (If having multiple or one reoccurring one) The core logic should be done where this would be just a detail and change when we see it...

Makes sense to me, I'd think the cleanest way to do this would be to add a MultiSelectListPreference in xml/preferences.xml and have the keys just be things like 1d, 2d, 1w, 2w, 1m, etc. I would expect Android to have something built-in for comparing if something is like 1 day different or 1 week different or whatever, so the letters that should be used should become clear during development and we can just ask Android "Hey, is this 1d difference?".

Personally, I think these options would make sense:

Option Selected by default
Today Y
In 1 day Y
In 2 days N
In 3 days N
In 4 days N
In 5 days N
In 6 days N
In 1 week Y
In 2 weeks N
In 3 weeks N
In 1 month N

But we can always tweak this during development.

Yea, I don't have much experience with Android notifications, but my only suggestion would be to follow the standard way with how most apps send notifications, instead of updating the users calendar. I have one app that does that and it seems kinda invasive. (At least to me)

That sounds like the best option, I definitely don't want Catima to feel invasive, especially given Catima is designed to be privacy-respecting.

Just briefly searching I saw mention of an AlarmManager to schedule future intents to wake your app up. We could have some broadcastReceiver listening for this intent to push a notification to the user.

Sounds like the way to go :)

@TheLastProject TheLastProject removed the state: consensus-needed A consensus needs to be reached before this can be implemented label Jul 16, 2022
@TheLastProject
Copy link
Member

Actually, I have a much better idea. Let's keep it simple and use Android's built-in tooling.

  1. Create a notification channel for each of the following options:
    • Card expires in 1 month (IMPORTANCE_LOW)
    • Card expires in 3 weeks (IMPORTANCE_LOW)
    • Card expires in 2 weeks (IMPORTANCE_LOW)
    • Card expires in 1 week (IMPORTANCE_DEFAULT)
    • Card expires in 3 days (IMPORTANCE_DEFAULT)
    • Card expires in 1 day (IMPORTANCE_DEFAULT)
    • Card expires today (IMPORTANCE_DEFAULT)
  2. Somehow schedule a daily check for 11AM (just before lunch in case people have like lunch coupons, seems the most perfect time, perhaps slightly earlier (like 10AM) if the expected Android delay for background notifications is longer)
  3. Each check checks all the cards, groups all cards with the same expiry date together and create 1 notification per date for the affected dates
  4. On Android 8 and above, have a "Configure expiry notifications" option in settings which just sends you to the Android notification settings for Catima
  5. On earlier Android versions, have a "Enable expiry notifications" toggle.

That way, we can:

  1. Keep the codebase simple
  2. Not overwhelm users with options
  3. Give pretty configurable options to 96.5% of Catima users (according to Google Play Android version stats) as they could even choose a different tone for closer to expiry and things like that
  4. Have an useful enough fallback for the other 3.5% of users (which I hope will be sufficient given they'll only get notified once a day at most)

It does mean users can't select per card if they want to be notified, but choosing so precisely for every single card in advance seems way more work than just swiping away a notification you don't care about.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
common: uncommon Most users are unlikely to come across this or unexpected workflow severity: minor Impairs non-critical functionality or suitable workarounds exist type: enhancement New feature or request
Projects
None yet
4 participants