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

fix #61, #85, #73(partially): add tracking of 36 nutrients #80

Open
wants to merge 19 commits into
base: master
Choose a base branch
from

Conversation

conrad57
Copy link
Contributor

@conrad57 conrad57 commented Jul 7, 2020

Privacy - to indicate I read CONTRIBUTING.md

This enhances the app so users can add macro nutrients to the products they add (#61 ). The macro nutrients for each entry are listed in the overview and below the overview heading the total macros are shown also. Products added from the OpenFoodFacts search also contain macros - if OFF provides them. The statisitics show a graph view for every macro below the energy graph view - carbs & sugar and fat & saturated fat each share a graph view.

I was not able to test how this enhacement works when updating an existing version of the app, I guess there need changes to be done to some database stuff, so that the upgrade works.

@Kamuno Kamuno added the enhancement New feature or request label Jul 12, 2020
@ghost
Copy link

ghost commented Jan 29, 2021

Do you have any plans to finish (test) this? The lack of macro tracking is the only thing preventing me from being able to use the app :'(

@Kamuno Kamuno self-requested a review January 30, 2021 12:53
@Kamuno Kamuno self-assigned this Jan 30, 2021
@conrad57
Copy link
Contributor Author

Hi, finally I had some time to look into this again. I merged the recent changes and refactored it a little. I also fixed the database upgrade issue, now it should be possible to upgrade an existing installation without loosing the data - I only tested this on my phone though.
If the changes make it into the official app, it would probably be a good idea to give users the ability to edit the product database so they can add the other nutrition info to existing entries. I think I will try to implement something like that in the future.

@cloehle
Copy link

cloehle commented Jun 29, 2021

Just want to add that Ive been using this branch for a while and think it works very well and is a good addition to the app. Exactly what I needed.
Modifying existing entries to add macros would be nice, but modifying existing entries in general would be nice to have
Thank you very much for your work @conrad69

@Yky
Copy link

Yky commented Jul 26, 2021

I have also been using this branch for a many months and agree with @cloehle it works very well. Thanks @conrad69

Would be great to get a review done for this branch and get it merged.

@conrad57 conrad57 changed the title fix #61: add macro nutrient tracking fix #61, #85, #73(partially): add tracking of 36 nutrients Sep 30, 2021
@conrad57
Copy link
Contributor Author

conrad57 commented Sep 30, 2021

Hi,
I reworked the macro nutrient tracking and enhanced it to now be able to track 36 nutrients: carbs, sugar, protein, fat, satFat, salt, fiber, vitaminA_retinol, betaCarotin, vitaminD, vitaminE, vitaminK, thiamin_B1, riboflavin_B2, niacin, vitaminB6, folat, pantothenacid, biotin, cobalamin_B12, vitaminC, natrium, chlorid, kalium, calcium, phosphor, magnesium, eisen, jod, fluorid, zink, selen, kupfer, mangan, chrom, molybdaen

In the newly added Settings-Activity users can choose which nutrient to track. For every nutrient and the calories one can set a daily goal and whether one should surpass this goal or not. In the overview activity the goals are shown as progress bars. The following screenshot shows an example, where 4 nutrients have goals set. The sugar goal shall not be surpassed and it isn't, so the progress bar is green. The goal of 150g protein shall be surpassed every day, so the progress bar is orange, since that isn't the case. Salt and fiber progress bars show the behaviour when a goal is surpassed.

FoodTracker_Overview

This fixes #61 , #85 and #73 in a way.

Visualising the daily goals was inspired by @christianfl #61 (comment)

I added an upgrade route for the database, so anyone who used the previous version with the macro nutrient tracking should be able to update with no problem - but I did only test this once on my phone.

@conrad57
Copy link
Contributor Author

conrad57 commented Oct 5, 2021

Without me noticing one of my previous commits introduced a bug where the settings activity would not allow to enable any nutrient tracking. This is fixed now.
I furthermore removed some unused methods which were introduced in an earlier version of the tracking feature.

@conrad57
Copy link
Contributor Author

conrad57 commented Oct 11, 2021

I added the possibility to edit saved products. Now users can add nutrients to Products they already added in the app. This is especially useful if one takes a product from OpenFoodFacts, which most often do not contain infos like vitamin content, and wants to add e.g. vitamin c content.
To edit products simply click the floating +-button in the overview of a day. In the tab view which used to offer 2 tabs (search and add) now a third tab "Edit" is available. In this edit tab type the name of the product and a list of matching products will appear below. Click on the desired product and some input fields, similar to those used to add a new product, with the current product data appears, where one can change name, calories and all nutrients activated in the settings.
I think this last change puts the feature in a state where it should be quite useful and usable. At the moment I don't plan to make further additions to it.

@cloehle
Copy link

cloehle commented Oct 15, 2021

Very cool, I'll try it out and report back.

Copy link
Member

@Kamuno Kamuno left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So I assume db version should be 3. Also I just tested this build and it gives me a NPE every time I choose something from the search results.

It looks good so far, though.

/***
* Migrate database so it also contains micro nutriments.
*/
static final Migration MIGRATION_2_3 = new Migration(2, 3) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Database is set to v2 but there is a migration to v3?
Is this a mistake?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you are right about the database version. I did not look into this for a long time though.
I can look into the npe in like one or two weeks. Do you have more information on the exception?

Copy link

@ReIaxo ReIaxo Sep 30, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi, I also took a look and fixed some bugs:

  • At some places product.key was used instead of offKey which leads to Zero values in database products
  • The click listener in search products was weird implemented. If there was a reason for it I don't get it. I cleaned it up a little which fixed the crash mentioned above.

How can i contribute my changes? This will be my first contribution to an Open Source Project on GitHub.
I have done the changes in the forked repositpory of @conrad57 an have them only local on my machine.
@Kamuno And there are merge conflicts. Which branch do I have to merge into this to resolve the conflicts?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants