-
-
Notifications
You must be signed in to change notification settings - Fork 29
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
[WIP] Modernize and new features #113
Conversation
Hi @dliw, it's great to see that you made so many improvements (some of which I had also in mind, see #9 or #12)! I'd very much like to be able to merge your modifications (and possibly some of the TODOs also). I'm happy you shared this, thanks! 😃 One thought (as you already wrote about the preferences): Could you make the navigation buttons switchable by preference setting? Some might feel the buttons are redundant. But this is no requirement for your final PR to be merged... |
Great, thanks for your interest. How do you suggest we proceed? In terms of functionality, my code more or less has your state from the beginning of the year plus the new view pager for the week table. A merge would reset all other changes and that can't be the goal. I yet have to understand the new flexi option and figure out, how to migrate it to the modified time calculator. Changes for the version I just pushed:
|
I suggest you try to migrate the changes from this repo into your fork and ask questions if there's something unclear. It took me some attempts at understanding the concept behind PR #59 but it's really not as complicated as it seems - the main point is that you can add a FLEX event at a specific time (e.g. 6 a.m.) and then your daily working time is set to this amount of time (6 hours in the above example). If the FLEX event was at 6 p.m. you would have to work 18 hours until your flexi time was at the same level as on the day before. And finally, if you set the FLEX event at midnight (0:00), the day doesn't have working time even if it's a regular work day, so the flexi time stays the same - and if you clock work on such a day, the flexi time increases from the first minute of work. Maybe @dirkmb can explain it better, but that's my take. Do you mean you created unit tests when you wrote "well tested"? @WildOrangutan just wrote some new tests and migrated some older tests which originally were hidden in the app's production code - my bad, I didn't know better back then 😐. Maybe you can combine the tests with yours? Again, if there's something unclear, I'll try to help. And thank you for taking this step and not just keeping your improvements for yourself! |
If I can add, I would suggest merging multiple times from master into this branch. I would merge from where you're at currently, to the master that is closest to your branch state. I would then do a merge every time feature branch (aka PR) was merged to master. Or something like that, depends on amount of changes - common sense applies. Doing that, I think reviewer could easier compare apples to apples. |
Thanks for explaining the FLEX event. It seems, it will be possible to migrate these events to the new target table.
It means, that I rewrote the core time calculator more than a year ago and been using it since then without issues. Also, I have an app installation for testing purposes with a set of events including various corner cases. The latter could be turned into a unit test, but at the moment this is not my priority. As far as the existing tests are concerned, most of them can be dropped because they are no longer necessary when java.time is used.
The thing is, that I started playing around with the code without any version control (my bad, I should have known better). To make matters worse, my editor changed all tab indents to space indents. Eventually I started a local git repo, but completely separate from upstream (trackworktime looked rather dead at this time). Finally, to prepare this pull request, I imported upstream and tried to reduce the diff as far as possible. Actually, the only clean way would be to start from scratch... My strategy is to port over all the missing features into this branch and once again try to reduce the diff as much as possible. I hope I can find the time and it works out. If not, feel free to use parts of my code as you see fit. |
|
|
The last missing piece (apart from more cleanup and testing) is backup and restore. With the new target table (or should I call it meta as it contains metadata?) there are now two tables that need to be saved. The reason I introduced this table is time zones. With time zones there is no such thing as a start of the day, so per-day settings didn't really fit into the event table or would have had to be rewritten on every change of the home time zone. With this table it is only a matter of recalculating the cache table. Also, this table could be used to store changes to the weekly target working time and the like. However, for backup and restore this makes things more complicated. I see several possible solutions:
What would you prefer? I haven't had a closer look at the backup and restore code yet ... |
Wrong button 🤦 |
@WildOrangutan Can you recommend one of the options? As far as I remember you implemented the backup... |
@mathisdt Are you sure? The "blame" for backup ( Edit: The commit message says contibuted by Peter Rosenberg... |
Yes, that was Peter's work, but I pushed it. I don't know anymore why I did it that way, it's more than six years ago... |
Sorry, but I didn't implement backup. I think you have me confused with the "other" Peter :) |
I'm sorry, I really confused the two of you. @PRosenb Can you recommend a course of action for the backup? |
Does the backup really need to be in readable format tough? What if backup was changed, and would plainly copy database file? At this point, we're basically maintaining two databases. Sure, csv format is more resistant to changes, but still needs to be migrated sometimes. If anyone would need all events in readable format, it's still possible to export them with "reports". |
I'm not sure, if a database file would be that much easier than one (or more) csv files. You will still want to verify the data on import and you wouldn't export the cache, so the backup file would be more of an export similar to what is needed for csv than a simple copy. The advantage of csv is that it is "transparent" and can easily be processed with other tools (and be it Excel). The question of compatibility (forward or backward) IMO is independent of the export format. In any case it would be good if older exports could be imported into a newer app versions. |
Since implementation of that backup behaviour, a lot changed on Android side and "Android Auto Backup" was introduced. For backup purpose I suggest to solely use "Android Auto Backup" (from Android 6.0) what basically stores the database files (and other files) and restores them back on reinstallation of the app. So on dev side we only need to configure "Android Auto Backup" in Android-Manifest.xml and the related backup config file to include/exclude the file we want. And remove the code that did backup with "Android Backup Service". To allow the user to export his/her data is a different story. |
If you refer to what I have called solution 1 the answer is yes. It would be one csv for the actual check in and check out events and one for the metadata. Also, the tables are only loosely linked, so it would be possible to import only either of both.
This app is on F-Droid, so there is a chance, there are people with a more or less Google-free Android. In this case, I assume, Android Auto Backup does not work. Also, an own import and export functionality could be useful for backups to self hosted data storages (Nextcloud), for synchronizing multiple devices, advanced report generation etc. |
Yes, I referred to your solution 1. I see about Google-free Android. In that case I guess ideal would be Android Auto Backup for the users that have a Google Account (similar to how "Android Backup Service" was and almost free to implement) and the export/import of your solution 1 for Google Account free user and the once how want to selfhost their data. |
Backup and restore is implemented now. For CSV two files are created, I extended the existing solution to also write the target table. I kept using the Android Backup Service. It could be migrated to Android Auto Backup as @PRosenb suggested, but I cannot really test. Some minor things are still missing and code could be cleaned up a bit more. Nevertheless I think the code is now ready for (a first round of review) and testing. |
I'm unable to reproduce the widget error. I tested the widget on two devices and it worked fine. Actually, I didn't change the original widget code apart from small adjustments to the time calculation. The other bugs (and a few more) should be fixed now. |
Thanks for your new push! The widget works for me now, I don't know why it didn't in the first place. 🤷♂️ I tested again and still found some issues while testing on API level 19 (probably these issues are also present on other API levels):
Did you test the location-based and WiFi-based tracking features? I didn't test it yet because I currently don't have a spare device. Finally, I have a minor suggestion: Could all of the app's main menu be moved to the nice sidebar? I'm not sure whether there's a clear distinction between the items which are still in the app menu and the items you already moved to the sidebar. |
The "show navigation button" setting is applied immediately now. As for the other issues:
|
@dliw Sorry it took me so long to get back to you. Now I will test-drive this PR's code on my phone and merge it if all works as expected 😃. Some notes:
|
As for the notes:
The fixes shouldn't be too much effort, so I think I will be able to push a new revision within the next few days. |
Thanks for your work! I really appreciate your commitment. 👍 As to your question: Both options are fine by me - but (only) the long-press action on the "Cancel" button is a bit too hidden in my opinion. |
With the latest revision
Once again I would like to remind you, that I changed the app version to 1.9 and that the upgrade text is more or less a placeholder. Feel free to change this as you see fit. Due to the reworked time calculation, probably these bugs are fixed as well: |
Thanks again! 👍 |
Hi @dliw, I wanted to ask if the submodule you added could be incorporated into this project or alternatively turned into a dependency (ideally loaded from Maven Central, but e.g. Github Packages is also fine). |
I'm very content with your PR, but I'm sorry, I still found some problems. I was testing on Kitkat (API 19) but I don't think the API level had any impact on the findings.
|
Yes, of course. Feel free to copy / clone the submodule into your project. The reason for the separate submodule is that it allows better tracking upstream. As far as I know, the only change is compatibility with AndroidX. The crashes should be fixed in the latest revision. I wonder where these come from. I'm rather sure that I have tested all of this. Probably they have crept in while adapting to upstream. Anyway, two stupid mistakes less. |
I feel a bit like Columbo who also often comes back with "one last thing" - I was a bit puzzled by the fact that events I manually enter for the future are not displayed at all in the overview table. Also, events I clock via the buttons are not displayed until the next minute (when they are in the past). Is this intentional? I think most of the users will expect that their actions will reflect in the table immediately. I can live with future events not taken into account for the table (although I don't find it optimal), but events I enter with the buttons should be displayed immediately in the table. Apart from that, I'm very happy - especially with the speed your modifications bring to the app! |
The reason for this had been, that only events used by the time calculator were shown. I just changed this. Future clock-in events are now displayed (first after now if currently clocked-out, first of the day). This could be extended to also include clock-out events, but then it would be necessary to find related events. I don't think this complexity would be justified. In order to display all events in a meaningful way, they would have to be displayed in a timeline... Apart from that, I noticed that the backup task often was called several hundred times in a short time span. It seems like this is a bug in the work manager for certain API levels. Anyway, I have made changes and will monitor if that has helped. |
The way the work time calculation is right now, it gives negative values for future events, because it calculates relative to the current time. If I understand correctly, you would like to have the full work time calculation for future days? If so, this means for me to go back to the drawing board. This will definitely take some time. Edit: Thinking about it, I'm rather sure, the calculation in principle works the same way as it did in the original. Work time was calculated until CLOCK_OUT_NOW. I'm not sure, how this would work, if there are future clock-in and clock-out events to be considered.... Edit2: I'm talking about the original version I started from almost 2 years ago. If something has changed in the meantime, then of course I didn't notice. |
- migrated to AndroidX - ported away from deprecated functions (multiselect, preferences, ...) - ported to java.time using ThreeTenABP - ported to view binding - added support for DST and time zones - new database scheme: * table event: store times as timestamps to avoid parsing strings * cache with intermediate results instead of week table * new target table to store per-day settings - new navigation drawer - restored top buttons (default off) - fix mathisdt#12
I have found a quick way to achieve the desired behaviour after all. The only downside (currently) is, that calculation results from future are not cached. So the calculation takes longer the farther one gets into the future. |
It's great, exactly what I meant. And I don't think the caching/speed is essential for events in the future, presumably the users won't use that excessively. Thank you again for your contribution and for your endurance, this made TWT definitely much better! 👍 |
Can I just ask why timezone selecting is needed? Why is it not ok to use timezone from system? |
In short, this is because the system's time zone changes when you move between time zones. Perhaps the following explanation will make it clearer: #146 (comment) But if that still doesn't make sense to you, feel free to ask 😉 |
Ah okay, I understand it now. Not sure what confused me. Thanks. |
Hello!
After using your app for a while, I started to do some modifications here and there. In the meantime the changes are massive and I have a hard time to follow upstream (@WildOrangutan 😉). Unfortunately, I also missed the point where I still could separate individual changes. At the same time these changes might be useful for others as well. Therefore, I post my current status. If you are interested, I will do my best to get it up to date and in a mergeable state.
To build the app, the following dependency is needed in the main folder (should be a git submodule):
https://github.com/dliw/timezonepicker
Changes (no particular order)