vadret / android

🌦 Vädret
https://vadret.github.io/android/
Other
17 stars 3 forks source link

feature: filterable weather warnings by affected area #137

Closed b9AcE closed 5 years ago

b9AcE commented 5 years ago

It could be useful if the warnings-category included a possibility to configure specific locations of interest and when a warning is issued matching that/those areas, the app would issue a notification and the notification could, if the user so desires, be configured to also issue a sound alert with a configurable choice of sound for each location. That way, the user would not have to check for warnings covering their areas of interest manually.

sphrak commented 5 years ago

Hi @b9AcE,

Thanks for reaching out and yes I agree. It would be quite useful. The are several reason this is not currently implemented, one being that I am researching the possibility to also pull data from krisinformation.se which will not only give weather warnings, but any other warning issued by any Swedish authority.

But then there is the problem of delivering notifications which itself is a two part problem.

First part is that SMHI's API does not provide a free pub/sub endpoint. Which means one would have to request data every x minutes, depending on how good of a resolution or accuracy you want - as to instead being notified by a pub/sub endpoint when data actually was updated. The latter being the most fitting one for this usecase.

Secondly, even if SMHI did provide a pub/sub endpoint, this connection must be maintained on a server since if done on a phone it would completely drain the battery and/or most likely get killed by the Android system.

Thus I would have to pay for a hosted server to support this feature. Which I am not interested in, given this is already something I provide for free and for anyone to use. Also I do not want to monetize this project either. There is the option of donations but will likely not cut it since the userbase is still very small (< 100 users) and its a highly unstable source of income with no guarantees. So I have basically ruled this option out entirely.

But I am fairly certain this can be semi-achieved still if one is willing to pay the price of increased battery usage if you want to use the feature that is.

It is possible to schedule requests by interval on the phone and then parse the data and "send a notification" locally without even involving FCM. But again this will increase the battery usage since the phone will have to poll the API every so often, again depending on how accurate you want to be.

Would it still be interesting to have this optional feature, even if it would mean increased battery usage and potentially less accurate warnings?

Let me know and I will consider it for 1.2.0.

Sincerely, Niclas

b9AcE commented 5 years ago

Yes, I was thinking of suggesting krisinformation as a source, but figured you may consider it out of scope for an app specifically named "the weather", but I'm for it.

I think whether or not one wants to have automatic polling for warnings in order to enable notifications, and if so, how often, would be a decision the user could make on its own, if there would be e.g. a warning text describing the result just before enabling or leaving disabled the entire group of settings related to that.

For it to really work, I guess you may have to guide the user through actively disabling the "battery optimization" of Android 9 and above specifically for this app. Some apps do that better than others. I think the ones that have the app throw up the system dialog box asking if the app is to get permission to turn off battery optimization for itself is probably the "correct" way. If the checkbox in app's settings to enable/disable the entire group of settings for the feature is the way you choose to do things, the moment the user checks to enable "warning notifications"-polling in general would probably be when that permission-question should pop up.

sphrak commented 5 years ago

Alright, fair enough. Scheduled for 1.2.0.