├── .github
└── workflows
│ └── changelog.yml
├── .gitignore
├── .gitmodules
├── CHANGELOG.md
├── CONTRIBUTING.md
├── COPYING
├── LICENSE
├── README.md
├── app
├── .gitignore
├── build.gradle
├── lint.xml
├── proguard-rules.pro
├── schemas
│ └── org.secuso.privacyfriendlyfoodtracker.database.ApplicationDatabase
│ │ └── 1.json
└── src
│ ├── main
│ ├── AndroidManifest.xml
│ ├── ic__black_left_arrow_timmed-web.png
│ ├── ic__black_right_arrow_timmed-web.png
│ ├── ic__cancel-web.png
│ ├── ic__check-web.png
│ ├── ic__date-web.png
│ ├── ic__delete-web.png
│ ├── ic__edit-web.png
│ ├── ic_chart-web.png
│ ├── java
│ │ └── org
│ │ │ └── secuso
│ │ │ └── privacyfriendlyfoodtracker
│ │ │ ├── PFFoodTrackerApplication.kt
│ │ │ ├── backup
│ │ │ ├── BackupCreator.kt
│ │ │ ├── BackupRestorer.kt
│ │ │ └── PFABackupService.kt
│ │ │ ├── database
│ │ │ ├── ApplicationDatabase.java
│ │ │ ├── ConsumedEntrieAndProductDao.java
│ │ │ ├── ConsumedEntries.java
│ │ │ ├── ConsumedEntriesDao.java
│ │ │ ├── DatabaseExporter.java
│ │ │ ├── Product.java
│ │ │ ├── ProductDao.java
│ │ │ └── converter
│ │ │ │ └── DateConverter.java
│ │ │ ├── helpers
│ │ │ ├── FirstLaunchManager.java
│ │ │ └── KeyGenHelper.java
│ │ │ ├── network
│ │ │ ├── ApiManager.java
│ │ │ ├── IApiManager.java
│ │ │ ├── ProductApiService.java
│ │ │ ├── models
│ │ │ │ ├── NetworkProduct.java
│ │ │ │ └── ProductResponse.java
│ │ │ └── utils
│ │ │ │ └── ProductConversionHelper.java
│ │ │ └── ui
│ │ │ ├── AboutActivity.java
│ │ │ ├── AddFoodFragment.java
│ │ │ ├── BaseAddFoodActivity.java
│ │ │ ├── BaseStatisticActivity.java
│ │ │ ├── GenerateKeyActivity.java
│ │ │ ├── HelpActivity.java
│ │ │ ├── MainActivity.java
│ │ │ ├── MonthStatisticFragment.java
│ │ │ ├── OverviewActivity.java
│ │ │ ├── SearchFoodFragment.java
│ │ │ ├── SettingsActivity.java
│ │ │ ├── SplashActivity.java
│ │ │ ├── TutorialActivity.java
│ │ │ ├── WeekStatisticFragment.java
│ │ │ ├── adapter
│ │ │ ├── AddFoodPagerAdapter.java
│ │ │ ├── DatabaseEntry.java
│ │ │ ├── DatabaseFacade.java
│ │ │ ├── HelpExpandableListAdapter.java
│ │ │ ├── SearchResultAdapter.java
│ │ │ └── StatisticPagerAdapter.java
│ │ │ ├── helper
│ │ │ ├── AppCompatPreferenceActivity.java
│ │ │ ├── BaseActivity.java
│ │ │ ├── DateHelper.java
│ │ │ └── MathHelper.java
│ │ │ ├── viewmodels
│ │ │ ├── OverviewViewModel.java
│ │ │ └── SharedStatisticViewModel.java
│ │ │ └── views
│ │ │ └── CheckableCardView.java
│ └── res
│ │ ├── color
│ │ └── selector_card_view_colors.xml
│ │ ├── drawable
│ │ ├── add_entry.png
│ │ ├── baseline_search_white_18.png
│ │ ├── baseline_search_white_24.png
│ │ ├── baseline_search_white_36.png
│ │ ├── baseline_search_white_48.png
│ │ ├── button_cancel.png
│ │ ├── button_confirm.png
│ │ ├── button_disabled.xml
│ │ ├── button_fullwidth.xml
│ │ ├── button_highlighted.xml
│ │ ├── button_highlighted_2.xml
│ │ ├── button_highlighted_3.xml
│ │ ├── button_highlighted_4.xml
│ │ ├── button_middleblue.xml
│ │ ├── button_normal.xml
│ │ ├── ic_info_black_24dp.xml
│ │ ├── ic_keyboard_arrow_left_black_24dp.xml
│ │ ├── ic_keyboard_arrow_right_black_24dp.xml
│ │ ├── ic_launcher_foreground.xml
│ │ ├── ic_launcher_foreground_shadow.xml
│ │ ├── ic_menu_help.xml
│ │ ├── ic_menu_home.xml
│ │ ├── ic_menu_info.xml
│ │ ├── ic_menu_settings.xml
│ │ ├── ic_menu_tutorial.xml
│ │ ├── privacyfriendlyappslogo.png
│ │ ├── secuso_logo_black.xml
│ │ ├── secuso_logo_blau_blau.png
│ │ ├── secuso_logo_white.xml
│ │ └── splash_screen.xml
│ │ ├── layout-land
│ │ ├── activity_about.xml
│ │ ├── activity_about_with_navigationdrawer.xml
│ │ ├── activity_base_statistic.xml
│ │ ├── activity_calendar.xml
│ │ ├── activity_generate_key.xml
│ │ ├── activity_help.xml
│ │ ├── activity_main.xml
│ │ ├── activity_settings.xml
│ │ ├── activity_tutorial.xml
│ │ ├── content_food.xml
│ │ ├── content_main.xml
│ │ ├── content_search.xml
│ │ └── dialog_edit_entry.xml
│ │ ├── layout
│ │ ├── activity_about.xml
│ │ ├── activity_about_with_navigationdrawer.xml
│ │ ├── activity_base_add_food.xml
│ │ ├── activity_base_statistic.xml
│ │ ├── activity_calendar.xml
│ │ ├── activity_food.xml
│ │ ├── activity_generate_key.xml
│ │ ├── activity_help.xml
│ │ ├── activity_main.xml
│ │ ├── activity_overview.xml
│ │ ├── activity_settings.xml
│ │ ├── activity_tutorial.xml
│ │ ├── content_food.xml
│ │ ├── content_main.xml
│ │ ├── content_overview.xml
│ │ ├── content_search.xml
│ │ ├── dialog_edit_entry.xml
│ │ ├── fragment_month_statistic.xml
│ │ ├── fragment_week_statistic.xml
│ │ ├── list_group.xml
│ │ ├── list_item.xml
│ │ ├── nav_header_main.xml
│ │ ├── search_result.xml
│ │ ├── toolbar.xml
│ │ ├── tutorial_slide1.xml
│ │ ├── tutorial_slide2.xml
│ │ └── tutorial_slide3.xml
│ │ ├── menu
│ │ ├── main.xml
│ │ ├── main_drawer.xml
│ │ ├── menu_statistics.xml
│ │ └── overview_actionbar.xml
│ │ ├── mipmap-anydpi-v26
│ │ └── ic_launcher.xml
│ │ ├── mipmap-hdpi
│ │ ├── ic__black_left_arrow_timmed.png
│ │ ├── ic__black_right_arrow_timmed.png
│ │ ├── ic__cancel.png
│ │ ├── ic__chart.png
│ │ ├── ic__check.png
│ │ ├── ic__date.png
│ │ ├── ic__delete.png
│ │ ├── ic__edit.png
│ │ ├── ic_launcher.png
│ │ ├── ic_launcher_adaptive_back.png
│ │ ├── ic_launcher_adaptive_fore.png
│ │ ├── ic_navbar.png
│ │ └── ic_splash.png
│ │ ├── mipmap-mdpi
│ │ ├── ic__black_left_arrow_timmed.png
│ │ ├── ic__black_right_arrow_timmed.png
│ │ ├── ic__cancel.png
│ │ ├── ic__chart.png
│ │ ├── ic__check.png
│ │ ├── ic__date.png
│ │ ├── ic__delete.png
│ │ ├── ic__edit.png
│ │ ├── ic_launcher.png
│ │ ├── ic_launcher_adaptive_back.png
│ │ ├── ic_launcher_adaptive_fore.png
│ │ ├── ic_navbar.png
│ │ └── ic_splash.png
│ │ ├── mipmap-xhdpi
│ │ ├── ic__black_left_arrow_timmed.png
│ │ ├── ic__black_right_arrow_timmed.png
│ │ ├── ic__cancel.png
│ │ ├── ic__chart.png
│ │ ├── ic__check.png
│ │ ├── ic__date.png
│ │ ├── ic__delete.png
│ │ ├── ic__edit.png
│ │ ├── ic_launcher.png
│ │ ├── ic_launcher_adaptive_back.png
│ │ ├── ic_launcher_adaptive_fore.png
│ │ ├── ic_navbar.png
│ │ └── ic_splash.png
│ │ ├── mipmap-xxhdpi
│ │ ├── ic__black_left_arrow_timmed.png
│ │ ├── ic__black_right_arrow_timmed.png
│ │ ├── ic__cancel.png
│ │ ├── ic__chart.png
│ │ ├── ic__check.png
│ │ ├── ic__date.png
│ │ ├── ic__delete.png
│ │ ├── ic__edit.png
│ │ ├── ic_launcher.png
│ │ ├── ic_launcher_adaptive_back.png
│ │ ├── ic_launcher_adaptive_fore.png
│ │ ├── ic_navbar.png
│ │ └── ic_splash.png
│ │ ├── mipmap-xxxhdpi
│ │ ├── ic__black_left_arrow_timmed.png
│ │ ├── ic__black_right_arrow_timmed.png
│ │ ├── ic__cancel.png
│ │ ├── ic__chart.png
│ │ ├── ic__check.png
│ │ ├── ic__date.png
│ │ ├── ic__delete.png
│ │ ├── ic__edit.png
│ │ ├── ic_launcher.png
│ │ ├── ic_launcher_adaptive_back.png
│ │ ├── ic_launcher_adaptive_fore.png
│ │ ├── ic_navbar.png
│ │ └── ic_splash.png
│ │ ├── values-de
│ │ └── strings.xml
│ │ ├── values-fr
│ │ └── strings.xml
│ │ ├── values-pl
│ │ └── strings.xml
│ │ ├── values-v21
│ │ └── styles.xml
│ │ ├── values-w820dp
│ │ └── dimens.xml
│ │ ├── values
│ │ ├── attrs.xml
│ │ ├── colors.xml
│ │ ├── dimens.xml
│ │ ├── drawables.xml
│ │ ├── strings.xml
│ │ └── styles.xml
│ │ └── xml
│ │ ├── pref_general.xml
│ │ └── pref_headers.xml
│ └── test
│ └── java
│ └── org
│ └── secuso
│ └── privacyfriendlyfoodtracker
│ └── ApiManagerTest.java
├── build.gradle
├── fastlane
└── metadata
│ └── android
│ ├── de
│ ├── full_description.txt
│ ├── images
│ │ └── phoneScreenshots
│ │ │ ├── 1.jpg
│ │ │ └── 2.jpg
│ ├── short_description.txt
│ └── title.txt
│ └── en-US
│ ├── full_description.txt
│ ├── images
│ ├── icon.png
│ └── phoneScreenshots
│ │ ├── 1.jpg
│ │ └── 2.jpg
│ ├── short_description.txt
│ └── title.txt
├── gradle.properties
├── gradle
└── wrapper
│ ├── gradle-wrapper.jar
│ └── gradle-wrapper.properties
├── gradlew
├── gradlew.bat
└── settings.gradle
/.github/workflows/changelog.yml:
--------------------------------------------------------------------------------
1 | name: Changelog Generation
2 |
3 | on:
4 | release:
5 | types: [published, released]
6 | workflow_dispatch:
7 |
8 | jobs:
9 | changelog:
10 | runs-on: ubuntu-latest
11 | steps:
12 | - uses: actions/checkout@v3
13 | with:
14 | submodules: 'recursive'
15 | ref: master
16 | - uses: rhysd/changelog-from-release/action@v3
17 | with:
18 | file: CHANGELOG.md
19 | github_token: ${{ secrets.GITHUB_TOKEN }}
20 | commit_summary_template: 'update changelog for %s changes'
21 | args: -l 2
22 | header: |
23 | # Changelog
24 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | # Built application files
2 | /*/build/
3 | build/*
4 |
5 | # Crashlytics configuations
6 | com_crashlytics_export_strings.xml
7 |
8 | # Local configuration file (sdk path, etc)
9 | local.properties
10 |
11 | # Gradle generated files
12 | .gradle/
13 |
14 | # Signing files
15 | .signing/
16 |
17 | # User-specific configurations
18 | .idea/*
19 | *.iml
20 |
21 | # OS-specific files
22 | .DS_Store
23 | .DS_Store?
24 | ._*
25 | .Spotlight-V100
26 | .Trashes
27 | ehthumbs.db
28 | Thumbs.db
29 |
30 | # Documents
31 | *.pdf
32 | *.doc
33 | *.docx
34 | *.odt
35 |
36 | # APKs, release files
37 | app/release/*
38 | *.apk
39 |
40 |
--------------------------------------------------------------------------------
/.gitmodules:
--------------------------------------------------------------------------------
1 | [submodule "libs/privacy-friendly-backup-api"]
2 | path = libs/privacy-friendly-backup-api
3 | url = https://github.com/SecUSo/privacy-friendly-backup-api.git
4 |
--------------------------------------------------------------------------------
/CHANGELOG.md:
--------------------------------------------------------------------------------
1 | # Changelog
2 |
3 |
4 | ## [Food Tracker (Privacy Friendly) v1.2.1](https://github.com/SecUSo/privacy-friendly-food-tracker/releases/tag/v1.2.1) - 2024-04-02
5 |
6 | ## What's Changed
7 | * documentation: Added info re: Privacy Friendly Backup by [@jahway603](https://github.com/jahway603) in [#109](https://github.com/SecUSo/privacy-friendly-food-tracker/pull/109)
8 | * Updates to Android 14
9 |
10 | ## New Contributors
11 | * [@jahway603](https://github.com/jahway603) made their first contribution in [#109](https://github.com/SecUSo/privacy-friendly-food-tracker/pull/109)
12 | * [@coderPaddyS](https://github.com/coderPaddyS) made their first contribution in [#111](https://github.com/SecUSo/privacy-friendly-food-tracker/pull/111)
13 |
14 | **Full Changelog**: https://github.com/SecUSo/privacy-friendly-food-tracker/compare/v1.2.0...v1.2.1
15 |
16 | [Changes][v1.2.1]
17 |
18 |
19 |
20 | ## [Food Tracker (Privacy Friendly) v1.2.0](https://github.com/SecUSo/privacy-friendly-food-tracker/releases/tag/v1.2.0) - 2022-09-06
21 |
22 | ## What's Changed
23 | * fix [#77](https://github.com/SecUSo/privacy-friendly-food-tracker/issues/77) and other race condition bugs by [@conrad57](https://github.com/conrad57) in [#78](https://github.com/SecUSo/privacy-friendly-food-tracker/pull/78)
24 | * fix [#79](https://github.com/SecUSo/privacy-friendly-food-tracker/issues/79): weekly average not calculated correctly by [@conrad57](https://github.com/conrad57) in [#81](https://github.com/SecUSo/privacy-friendly-food-tracker/pull/81)
25 | * First French Translation by [@dobriseb](https://github.com/dobriseb) in [#83](https://github.com/SecUSo/privacy-friendly-food-tracker/pull/83)
26 | * Add privacy friendly backup support by [@udenr](https://github.com/udenr) in [#96](https://github.com/SecUSo/privacy-friendly-food-tracker/pull/96)
27 |
28 | ## New Contributors
29 | * [@conrad57](https://github.com/conrad57) made their first contribution in [#78](https://github.com/SecUSo/privacy-friendly-food-tracker/pull/78)
30 | * [@dobriseb](https://github.com/dobriseb) made their first contribution in [#83](https://github.com/SecUSo/privacy-friendly-food-tracker/pull/83)
31 | * [@udenr](https://github.com/udenr) made their first contribution in [#96](https://github.com/SecUSo/privacy-friendly-food-tracker/pull/96)
32 |
33 | **Full Changelog**: https://github.com/SecUSo/privacy-friendly-food-tracker/compare/v1.1.0...v1.2.0
34 |
35 | [Changes][v1.2.0]
36 |
37 |
38 |
39 | ## [Food Tracker (Privacy Friendly) v1.1.0](https://github.com/SecUSo/privacy-friendly-food-tracker/releases/tag/v1.1.0) - 2020-05-14
40 |
41 | - Added adaptive icon
42 | - Fixed key generation issues that would prevent users from using the app
43 | - Fixed the overview not being scollable
44 | - Improvements to database access
45 | - Added fastlane structure files
46 | - Gradle update
47 |
48 | [Changes][v1.1.0]
49 |
50 |
51 |
52 | ## [Food Tracker (Privacy Friendly) v1.0.1](https://github.com/SecUSo/privacy-friendly-food-tracker/releases/tag/v1.0.1) - 2019-06-06
53 |
54 | - bugfixes
55 |
56 | [Changes][v1.0.1]
57 |
58 |
59 |
60 | ## [Food Tracker (Privacy Friendly) v1.0](https://github.com/SecUSo/privacy-friendly-food-tracker/releases/tag/v1.0) - 2019-04-27
61 |
62 | - Initial Release
63 |
64 | [Changes][v1.0]
65 |
66 |
67 | [v1.2.1]: https://github.com/SecUSo/privacy-friendly-food-tracker/compare/v1.2.0...v1.2.1
68 | [v1.2.0]: https://github.com/SecUSo/privacy-friendly-food-tracker/compare/v1.1.0...v1.2.0
69 | [v1.1.0]: https://github.com/SecUSo/privacy-friendly-food-tracker/compare/v1.0.1...v1.1.0
70 | [v1.0.1]: https://github.com/SecUSo/privacy-friendly-food-tracker/compare/v1.0...v1.0.1
71 | [v1.0]: https://github.com/SecUSo/privacy-friendly-food-tracker/tree/v1.0
72 |
73 |
74 |
--------------------------------------------------------------------------------
/CONTRIBUTING.md:
--------------------------------------------------------------------------------
1 | # How to contribute
2 |
3 | We encourage open source developers to support the Privacy Friendly Apps.
4 | We also wish to keep it as easy as possible to contribute. There are a few
5 | guidelines that we need contributors to follow.
6 | For further questions we refer to the contact details on the [Privacy Friendly Apps website](https://secuso.org/pfa).
7 |
8 | ## Reporting of Issues
9 |
10 | * Make sure you have a [GitHub account](https://github.com/signup/free).
11 | * Open an issue in the corresponding app's repository, assuming one does not already exist.
12 | * Clearly describe the issue including steps to reproduce when it is a bug.
13 | In some cases screenshots can be supportive.
14 | * Make sure you mention the Android version and the device you have used when
15 | you encountered the issue.
16 | * Make your description as precise as possible.
17 |
18 | ## Making Changes
19 |
20 | * Make sure you have a [GitHub account](https://github.com/signup/free).
21 | * Find an issue that you wish to close. If the issue you wish to close is not
22 | present, open it. Make sure that the issue has one of the following labels
23 | which are set by our team:
24 | * Bug
25 | * Enhancement
26 | * Help wanted
27 | * No integration planned
28 | That means that we have already reviewed the issue. If you wish to add a
29 | translation, opening an issue is not required.
30 | * Fork the repository on GitHub.
31 | * Create a topic branch from where you want to base your work (usually master branch).
32 | * To quickly create a topic branch based on master, run `git checkout -b
33 | fix/master/my_contribution master`.
34 | * Please avoid working directly on the `master` branch.
35 | * Make commits of logical units in english language.
36 | * Make sure your commit messages are in the proper format. If the commit
37 | addresses an issue filed in the Github repository, start the first line
38 | of the commit with a hash followed by the issue number (e.g. #42).
39 | * Make sure you have added the necessary tests for your changes.
40 | * Run all available tests to assure nothing else was accidentally broken.
41 |
42 | ### Unwanted Changes
43 |
44 | The Privacy Friendly Apps are a group of Android apps that are optimized regarding
45 | the user's privacy. Therefore, Pull Requests that contain the following functionality
46 | will be rejected:
47 | * Analytics or advertisement frameworks
48 | * User tracking (e.g. sending of data to a third party)
49 | * Any that use of libraries that do not comply the license of the corresponding Privacy
50 | Friendly App (GPLv3 or Apache2).
51 | * Unnecessary use of Android permissions. If new functionality is added that requires
52 | the usage of an Android permission you should clearly explain the Pull Request why
53 | this permission is required.
54 | * New translations/languages
55 |
56 | ## Submitting Changes
57 |
58 | * Push your changes to a topic branch in your fork of the repository.
59 | * Submit a Pull Request to the repository of the corresponding Privacy Friendly App.
60 | * Indicate that you have read this policy by writing the second word of the section "unwanted changes"
61 | * Our team looks at Pull Requests on a regular basis and assigns a reviewer.
62 | * After feedback has been given we expect responses within one month. After one
63 | month we might close the pull request if no activity is shown.
64 |
65 |
--------------------------------------------------------------------------------
/app/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/app/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.application'
2 | apply plugin: 'kotlin-android'
3 |
4 | android {
5 | namespace "org.secuso.privacyfriendlyfoodtracker"
6 |
7 | defaultConfig {
8 | applicationId "org.secuso.privacyfriendlyfoodtracker"
9 | minSdkVersion 21
10 | targetSdkVersion 34
11 | compileSdk 34
12 | versionCode 7
13 | versionName "1.2.2"
14 | testInstrumentationRunner 'androidx.test.runner.AndroidJUnitRunner'
15 |
16 | javaCompileOptions {
17 | annotationProcessorOptions {
18 | arguments = ["room.schemaLocation": "$projectDir/schemas".toString()]
19 | }
20 | }
21 | }
22 |
23 | compileOptions {
24 | sourceCompatibility JavaVersion.VERSION_21
25 | targetCompatibility JavaVersion.VERSION_21
26 | }
27 |
28 | kotlinOptions {
29 | jvmTarget = JavaVersion.VERSION_21.toString()
30 | }
31 |
32 | kotlin {
33 | jvmToolchain(21)
34 | }
35 |
36 | lint {
37 | lintConfig = file("lint.xml")
38 | }
39 |
40 | buildFeatures {
41 | buildConfig true
42 | }
43 |
44 | applicationVariants.all { variant ->
45 | variant.outputs.all {
46 | outputFileName = "pfa-food-tracker-${variant.name}-v${variant.versionName}.apk"
47 | }
48 | }
49 |
50 | buildTypes {
51 | release {
52 | minifyEnabled false
53 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
54 | }
55 | }
56 |
57 | sourceSets {
58 | androidTest.assets.srcDirs += files("$projectDir/schemas".toString())
59 | }
60 | }
61 |
62 | dependencies {
63 | implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
64 | testImplementation 'junit:junit:4.13.2'
65 | androidTestImplementation 'androidx.test:runner:1.4.0'
66 | androidTestImplementation 'androidx.test:rules:1.4.0'
67 |
68 | androidTestImplementation 'androidx.test.ext:junit:1.1.3'
69 |
70 | implementation fileTree(dir: 'libs', include: ['*.jar'])
71 | implementation 'androidx.appcompat:appcompat:1.5.0'
72 | implementation 'com.google.android.material:material:1.6.1'
73 | implementation 'androidx.legacy:legacy-support-v4:1.0.0'
74 | implementation 'androidx.cardview:cardview:1.0.0'
75 | implementation 'androidx.recyclerview:recyclerview:1.2.1'
76 |
77 | coreLibraryDesugaring 'com.android.tools:desugar_jdk_libs:1.1.5'
78 |
79 | // Room components
80 | def room_version = "2.6.1"
81 | implementation "androidx.room:room-runtime:$room_version"
82 | annotationProcessor "androidx.room:room-compiler:$room_version"
83 | androidTestImplementation "androidx.room:room-testing:$room_version"
84 |
85 | // Lifecycle components
86 | implementation 'androidx.lifecycle:lifecycle-extensions:2.2.0'
87 |
88 | // Gson
89 | implementation 'com.google.code.gson:gson:2.8.9'
90 |
91 | // SQLCipher
92 | implementation 'net.zetetic:android-database-sqlcipher:4.5.0'
93 |
94 | // Retrofit
95 | implementation 'com.squareup.retrofit2:retrofit:2.9.0'
96 | implementation 'com.squareup.retrofit2:converter-gson:2.9.0'
97 |
98 | //Jakewharton
99 | implementation 'com.jakewharton.picasso:picasso2-okhttp3-downloader:1.1.0'
100 |
101 | // Statistic
102 | implementation 'com.jjoe64:graphview:4.2.2'
103 |
104 | // Backup API
105 | implementation project(':backup-api')
106 | def work_version = '2.7.1'
107 | implementation "androidx.work:work-runtime:$work_version"
108 | implementation "androidx.work:work-runtime-ktx:$work_version"
109 | androidTestImplementation "androidx.work:work-testing:$work_version"
110 |
111 | }
112 |
--------------------------------------------------------------------------------
/app/lint.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/app/proguard-rules.pro:
--------------------------------------------------------------------------------
1 | # Add project specific ProGuard rules here.
2 | # By default, the flags in this file are appended to flags specified
3 | # in /home/yonjuni/Android/Sdk/tools/proguard/proguard-android.txt
4 | # You can edit the include path and order by changing the proguardFiles
5 | # directive in build.gradle.
6 | #
7 | # For more details, see
8 | # http://developer.android.com/guide/developing/tools/proguard.html
9 |
10 | # Add any project specific keep options here:
11 |
12 | # If your project uses WebView with JS, uncomment the following
13 | # and specify the fully qualified class name to the JavaScript interface
14 | # class:
15 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview {
16 | # public *;
17 | #}
18 |
--------------------------------------------------------------------------------
/app/schemas/org.secuso.privacyfriendlyfoodtracker.database.ApplicationDatabase/1.json:
--------------------------------------------------------------------------------
1 | {
2 | "formatVersion": 1,
3 | "database": {
4 | "version": 1,
5 | "identityHash": "1c4b4d71bcbdb586cc4af0a0585902ca",
6 | "entities": [
7 | {
8 | "tableName": "ConsumedEntries",
9 | "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, `productId` INTEGER NOT NULL, `amount` INTEGER NOT NULL, `date` INTEGER, `name` TEXT, FOREIGN KEY(`productId`) REFERENCES `Product`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE )",
10 | "fields": [
11 | {
12 | "fieldPath": "id",
13 | "columnName": "id",
14 | "affinity": "INTEGER",
15 | "notNull": true
16 | },
17 | {
18 | "fieldPath": "productId",
19 | "columnName": "productId",
20 | "affinity": "INTEGER",
21 | "notNull": true
22 | },
23 | {
24 | "fieldPath": "amount",
25 | "columnName": "amount",
26 | "affinity": "INTEGER",
27 | "notNull": true
28 | },
29 | {
30 | "fieldPath": "date",
31 | "columnName": "date",
32 | "affinity": "INTEGER",
33 | "notNull": false
34 | },
35 | {
36 | "fieldPath": "name",
37 | "columnName": "name",
38 | "affinity": "TEXT",
39 | "notNull": false
40 | }
41 | ],
42 | "primaryKey": {
43 | "columnNames": [
44 | "id"
45 | ],
46 | "autoGenerate": true
47 | },
48 | "indices": [],
49 | "foreignKeys": [
50 | {
51 | "table": "Product",
52 | "onDelete": "CASCADE",
53 | "onUpdate": "NO ACTION",
54 | "columns": [
55 | "productId"
56 | ],
57 | "referencedColumns": [
58 | "id"
59 | ]
60 | }
61 | ]
62 | },
63 | {
64 | "tableName": "Product",
65 | "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, `name` TEXT, `energy` REAL NOT NULL, `barcode` TEXT)",
66 | "fields": [
67 | {
68 | "fieldPath": "id",
69 | "columnName": "id",
70 | "affinity": "INTEGER",
71 | "notNull": true
72 | },
73 | {
74 | "fieldPath": "name",
75 | "columnName": "name",
76 | "affinity": "TEXT",
77 | "notNull": false
78 | },
79 | {
80 | "fieldPath": "energy",
81 | "columnName": "energy",
82 | "affinity": "REAL",
83 | "notNull": true
84 | },
85 | {
86 | "fieldPath": "barcode",
87 | "columnName": "barcode",
88 | "affinity": "TEXT",
89 | "notNull": false
90 | }
91 | ],
92 | "primaryKey": {
93 | "columnNames": [
94 | "id"
95 | ],
96 | "autoGenerate": true
97 | },
98 | "indices": [],
99 | "foreignKeys": []
100 | }
101 | ],
102 | "setupQueries": [
103 | "CREATE TABLE IF NOT EXISTS room_master_table (id INTEGER PRIMARY KEY,identity_hash TEXT)",
104 | "INSERT OR REPLACE INTO room_master_table (id,identity_hash) VALUES(42, \"1c4b4d71bcbdb586cc4af0a0585902ca\")"
105 | ]
106 | }
107 | }
--------------------------------------------------------------------------------
/app/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 |
13 |
14 |
15 |
16 |
24 |
28 |
29 |
30 |
31 |
32 |
33 |
36 |
39 |
40 |
44 |
48 |
51 |
52 |
57 |
60 |
61 |
66 |
69 |
70 |
71 |
75 |
80 |
86 |
87 |
93 |
94 |
95 |
96 |
97 |
101 |
102 |
103 |
--------------------------------------------------------------------------------
/app/src/main/ic__black_left_arrow_timmed-web.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/SecUSo/privacy-friendly-food-tracker/247d9a525cd2ad293edaa6fe4b610ce36979a61a/app/src/main/ic__black_left_arrow_timmed-web.png
--------------------------------------------------------------------------------
/app/src/main/ic__black_right_arrow_timmed-web.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/SecUSo/privacy-friendly-food-tracker/247d9a525cd2ad293edaa6fe4b610ce36979a61a/app/src/main/ic__black_right_arrow_timmed-web.png
--------------------------------------------------------------------------------
/app/src/main/ic__cancel-web.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/SecUSo/privacy-friendly-food-tracker/247d9a525cd2ad293edaa6fe4b610ce36979a61a/app/src/main/ic__cancel-web.png
--------------------------------------------------------------------------------
/app/src/main/ic__check-web.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/SecUSo/privacy-friendly-food-tracker/247d9a525cd2ad293edaa6fe4b610ce36979a61a/app/src/main/ic__check-web.png
--------------------------------------------------------------------------------
/app/src/main/ic__date-web.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/SecUSo/privacy-friendly-food-tracker/247d9a525cd2ad293edaa6fe4b610ce36979a61a/app/src/main/ic__date-web.png
--------------------------------------------------------------------------------
/app/src/main/ic__delete-web.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/SecUSo/privacy-friendly-food-tracker/247d9a525cd2ad293edaa6fe4b610ce36979a61a/app/src/main/ic__delete-web.png
--------------------------------------------------------------------------------
/app/src/main/ic__edit-web.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/SecUSo/privacy-friendly-food-tracker/247d9a525cd2ad293edaa6fe4b610ce36979a61a/app/src/main/ic__edit-web.png
--------------------------------------------------------------------------------
/app/src/main/ic_chart-web.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/SecUSo/privacy-friendly-food-tracker/247d9a525cd2ad293edaa6fe4b610ce36979a61a/app/src/main/ic_chart-web.png
--------------------------------------------------------------------------------
/app/src/main/java/org/secuso/privacyfriendlyfoodtracker/PFFoodTrackerApplication.kt:
--------------------------------------------------------------------------------
1 | package org.secuso.privacyfriendlyfoodtracker
2 |
3 | import android.app.Application
4 | import android.util.Log
5 | import androidx.work.Configuration
6 | import org.secuso.privacyfriendlybackup.api.pfa.BackupManager
7 | import org.secuso.privacyfriendlyfoodtracker.backup.BackupCreator
8 | import org.secuso.privacyfriendlyfoodtracker.backup.BackupRestorer
9 |
10 | class PFFoodTrackerApplication : Application(), Configuration.Provider {
11 |
12 | override fun onCreate() {
13 | super.onCreate()
14 | BackupManager.backupCreator = BackupCreator()
15 | BackupManager.backupRestorer = BackupRestorer()
16 | }
17 |
18 | override val workManagerConfiguration = Configuration.Builder().setMinimumLoggingLevel(Log.INFO).build()
19 | }
--------------------------------------------------------------------------------
/app/src/main/java/org/secuso/privacyfriendlyfoodtracker/backup/BackupCreator.kt:
--------------------------------------------------------------------------------
1 | package org.secuso.privacyfriendlyfoodtracker.backup
2 |
3 | import android.content.Context
4 | import android.preference.PreferenceManager
5 | import android.util.JsonWriter
6 | import android.util.Log
7 | import net.sqlcipher.database.SQLiteDatabase
8 | import net.sqlcipher.database.SQLiteDatabaseHook
9 | import org.secuso.privacyfriendlybackup.api.backup.DatabaseUtil
10 | import org.secuso.privacyfriendlybackup.api.backup.PreferenceUtil
11 | import org.secuso.privacyfriendlybackup.api.pfa.IBackupCreator
12 | import org.secuso.privacyfriendlyfoodtracker.database.ApplicationDatabase
13 | import org.secuso.privacyfriendlyfoodtracker.helpers.KeyGenHelper
14 | import java.io.OutputStream
15 | import java.io.OutputStreamWriter
16 |
17 | class BackupCreator : IBackupCreator {
18 | override fun writeBackup(context: Context, outputStream: OutputStream): Boolean {
19 | Log.d(TAG, "createBackup() started")
20 | val outputStreamWriter = OutputStreamWriter(outputStream, Charsets.UTF_8)
21 | val writer = JsonWriter(outputStreamWriter)
22 | writer.setIndent("")
23 |
24 | try {
25 | writer.beginObject()
26 |
27 | Log.d(TAG, "Writing database")
28 | writer.name("database")
29 |
30 | SQLiteDatabase.loadLibs(context)
31 |
32 | if (context.getDatabasePath(ApplicationDatabase.DATABASE_NAME).exists()) {
33 | val database = SQLiteDatabase.openDatabase(
34 | context.getDatabasePath(ApplicationDatabase.DATABASE_NAME).path,
35 | KeyGenHelper.getSecretKeyAsChar(context),
36 | null,
37 | SQLiteDatabase.OPEN_READONLY,
38 | object : SQLiteDatabaseHook {
39 | override fun preKey(database: SQLiteDatabase) {}
40 | override fun postKey(database: SQLiteDatabase) {
41 | database.rawExecSQL("PRAGMA cipher_compatibility = 3;")
42 | }
43 | })
44 |
45 | DatabaseUtil.writeDatabase(writer, database)
46 | database.close()
47 | } else {
48 | Log.d(TAG, "No database found")
49 | writer.beginObject()
50 | writer.endObject()
51 | }
52 |
53 | Log.d(TAG, "Writing preferences")
54 | writer.name("preferences")
55 |
56 | val pref = PreferenceManager.getDefaultSharedPreferences(context.applicationContext)
57 | PreferenceUtil.writePreferences(writer, pref, arrayOf(KeyGenHelper.PREFERENCE_ENCRYPTED_KEY_NAME))
58 |
59 | Log.d(TAG, "Writing files")
60 | writer.endObject()
61 | writer.close()
62 | } catch (e: Exception) {
63 | Log.e(TAG, "Error occurred", e)
64 | e.printStackTrace()
65 | }
66 |
67 | Log.d(TAG, "Backup created successfully")
68 | return true
69 | }
70 |
71 | companion object {
72 | const val TAG = "PFABackupCreator"
73 | }
74 | }
--------------------------------------------------------------------------------
/app/src/main/java/org/secuso/privacyfriendlyfoodtracker/backup/PFABackupService.kt:
--------------------------------------------------------------------------------
1 | package org.secuso.privacyfriendlyfoodtracker.backup
2 |
3 | import org.secuso.privacyfriendlybackup.api.pfa.PFAAuthService
4 |
5 | class PFABackupService : PFAAuthService()
--------------------------------------------------------------------------------
/app/src/main/java/org/secuso/privacyfriendlyfoodtracker/database/ConsumedEntrieAndProductDao.java:
--------------------------------------------------------------------------------
1 | /*
2 | This file is part of Privacy friendly food tracker.
3 |
4 | Privacy friendly food tracker is free software: you can redistribute it and/or modify
5 | it under the terms of the GNU General Public License as published by
6 | the Free Software Foundation, either version 3 of the License, or
7 | (at your option) any later version.
8 |
9 | Privacy friendly food tracker is distributed in the hope that it will be useful,
10 | but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | GNU General Public License for more details.
13 |
14 | You should have received a copy of the GNU General Public License
15 | along with Privacy friendly food tracker. If not, see .
16 | */
17 | package org.secuso.privacyfriendlyfoodtracker.database;
18 |
19 | import androidx.lifecycle.LiveData;
20 | import androidx.room.Dao;
21 | import androidx.room.Query;
22 |
23 | import org.secuso.privacyfriendlyfoodtracker.ui.adapter.DatabaseEntry;
24 |
25 | import java.sql.Date;
26 | import java.util.List;
27 |
28 | /**
29 | * Includes methods that offer abstract access to the app database to manage products and consumed entries.
30 | *
31 | * @author Andre Lutz
32 | */
33 | @Dao
34 | public interface ConsumedEntrieAndProductDao {
35 | @Query("SELECT consumedEntries.date AS unique1, (sum(product.energy*consumedEntries.amount)) AS unique2 FROM consumedEntries INNER JOIN product ON consumedEntries.productId = product.id WHERE consumedEntries.date BETWEEN :dayst AND :dayet GROUP BY consumedEntries.date ")
36 | List getCaloriesPerDayinPeriod(final Date dayst, final Date dayet);
37 |
38 | @Query("SELECT consumedEntries.date AS unique1, sum(product.energy*consumedEntries.amount/100) AS unique2 FROM consumedEntries INNER JOIN product ON consumedEntries.productId = product.id WHERE consumedEntries.date BETWEEN :dayst AND :dayet")
39 | List getCaloriesPeriod(final Date dayst, final Date dayet);
40 |
41 | @Query("SELECT consumedEntries.amount AS amount, consumedEntries.id AS id,consumedEntries.name as name, product.energy as energy FROM consumedEntries INNER JOIN product ON consumedEntries.productId = product.id WHERE consumedEntries.date=:day")
42 | LiveData> findConsumedEntriesForDate(final Date day);
43 |
44 | static class DateCalories
45 | {
46 | public Date unique1;
47 | public int unique2;
48 | }
49 | }
50 |
--------------------------------------------------------------------------------
/app/src/main/java/org/secuso/privacyfriendlyfoodtracker/database/ConsumedEntries.java:
--------------------------------------------------------------------------------
1 | /*
2 | This file is part of Privacy friendly food tracker.
3 |
4 | Privacy friendly food tracker is free software: you can redistribute it and/or modify
5 | it under the terms of the GNU General Public License as published by
6 | the Free Software Foundation, either version 3 of the License, or
7 | (at your option) any later version.
8 |
9 | Privacy friendly food tracker is distributed in the hope that it will be useful,
10 | but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | GNU General Public License for more details.
13 |
14 | You should have received a copy of the GNU General Public License
15 | along with Privacy friendly food tracker. If not, see .
16 | */
17 | package org.secuso.privacyfriendlyfoodtracker.database;
18 |
19 | import androidx.room.Entity;
20 | import androidx.room.ForeignKey;
21 | import androidx.room.PrimaryKey;
22 | import androidx.room.TypeConverters;
23 |
24 | import org.secuso.privacyfriendlyfoodtracker.database.converter.DateConverter;
25 |
26 |
27 | import java.sql.Date;
28 |
29 | import static androidx.room.ForeignKey.CASCADE;
30 |
31 | /**
32 | * Information about consuming.
33 | *
34 | * @author Andre Lutz
35 | */
36 | @Entity(foreignKeys = @ForeignKey(entity = Product.class,
37 | parentColumns = "id",
38 | childColumns = "productId",
39 | onDelete = CASCADE))
40 | public class ConsumedEntries {
41 | @PrimaryKey(autoGenerate = true)
42 | public final int id;
43 | public final int productId;
44 | public int amount;
45 | @TypeConverters({DateConverter.class}) public final Date date;
46 | public final String name;
47 |
48 | public ConsumedEntries(final int id, final int amount, final Date date, final String name, final int productId) {
49 | this.id = id;
50 | this.productId = productId;
51 | this.amount = amount;
52 | this.date = date;
53 | this.name = name;
54 | }
55 | }
56 |
--------------------------------------------------------------------------------
/app/src/main/java/org/secuso/privacyfriendlyfoodtracker/database/ConsumedEntriesDao.java:
--------------------------------------------------------------------------------
1 | /*
2 | This file is part of Privacy friendly food tracker.
3 |
4 | Privacy friendly food tracker is free software: you can redistribute it and/or modify
5 | it under the terms of the GNU General Public License as published by
6 | the Free Software Foundation, either version 3 of the License, or
7 | (at your option) any later version.
8 |
9 | Privacy friendly food tracker is distributed in the hope that it will be useful,
10 | but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | GNU General Public License for more details.
13 |
14 | You should have received a copy of the GNU General Public License
15 | along with Privacy friendly food tracker. If not, see .
16 | */
17 | package org.secuso.privacyfriendlyfoodtracker.database;
18 |
19 | import androidx.lifecycle.LiveData;
20 | import androidx.room.Dao;
21 | import androidx.room.Delete;
22 | import androidx.room.Insert;
23 | import androidx.room.Query;
24 | import androidx.room.Update;
25 |
26 | import java.sql.Date;
27 | import java.util.List;
28 | /**
29 | * Includes methods that offer abstract access to the app database to manage consumed entries.
30 | *
31 | * @author Andre Lutz
32 | */
33 | @Dao
34 | public interface ConsumedEntriesDao {
35 |
36 | @Insert
37 | void insert(ConsumedEntries consumedEntries);
38 |
39 | @Update
40 | void update(ConsumedEntries... consumedEntries);
41 |
42 | @Delete
43 | void delete(ConsumedEntries... consumedEntries);
44 |
45 | @Query("SELECT * FROM consumedEntries")
46 | List getAllConsumedEntries();
47 |
48 | @Query("SELECT * FROM consumedEntries WHERE productId=:consumedEntriesId")
49 | List findConsumedEntriesForProduct(final int consumedEntriesId);
50 |
51 | @Query("SELECT productId FROM consumedEntries GROUP BY productId ORDER BY COUNT(productId) DESC")
52 | List findMostCommonProducts();
53 |
54 | @Query("SELECT * FROM consumedEntries, product WHERE date BETWEEN DATE(:dayst) AND DATE(:dayet)")
55 | List findConsumedEntriesBetweenDates(final Date dayst, final Date dayet);
56 |
57 | @Query("SELECT * FROM consumedEntries WHERE id=:id")
58 | List findConsumedEntriesById(final int id);
59 |
60 | @Query("SELECT * FROM consumedEntries WHERE productId=:productId AND amount=:amount AND date=:date AND name=:name ")
61 | List findExistingConsumedEntries( int productId, int amount, Date date, String name);
62 |
63 |
64 |
65 | @Query("DELETE FROM consumedEntries")
66 | void deleteAll();
67 | }
68 |
--------------------------------------------------------------------------------
/app/src/main/java/org/secuso/privacyfriendlyfoodtracker/database/Product.java:
--------------------------------------------------------------------------------
1 | /*
2 | This file is part of Privacy friendly food tracker.
3 |
4 | Privacy friendly food tracker is free software: you can redistribute it and/or modify
5 | it under the terms of the GNU General Public License as published by
6 | the Free Software Foundation, either version 3 of the License, or
7 | (at your option) any later version.
8 |
9 | Privacy friendly food tracker is distributed in the hope that it will be useful,
10 | but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | GNU General Public License for more details.
13 |
14 | You should have received a copy of the GNU General Public License
15 | along with Privacy friendly food tracker. If not, see .
16 | */
17 | package org.secuso.privacyfriendlyfoodtracker.database;
18 |
19 | import androidx.room.ColumnInfo;
20 | import androidx.room.Entity;
21 | import androidx.room.PrimaryKey;
22 | import androidx.annotation.NonNull;
23 |
24 | /**
25 | * A Product.
26 | *
27 | * @author Andre Lutz
28 | */
29 | @Entity
30 | public class Product {
31 | @PrimaryKey(autoGenerate = true)
32 | public final int id;
33 | public final String name;
34 | public final float energy;
35 | public final String barcode;
36 |
37 | public Product(final int id, String name, float energy, String barcode) {
38 | this.id = id;
39 | this.name = name;
40 | this.energy = energy;
41 | this.barcode = barcode;
42 | }
43 | }
44 |
--------------------------------------------------------------------------------
/app/src/main/java/org/secuso/privacyfriendlyfoodtracker/database/ProductDao.java:
--------------------------------------------------------------------------------
1 | /*
2 | This file is part of Privacy friendly food tracker.
3 |
4 | Privacy friendly food tracker is free software: you can redistribute it and/or modify
5 | it under the terms of the GNU General Public License as published by
6 | the Free Software Foundation, either version 3 of the License, or
7 | (at your option) any later version.
8 |
9 | Privacy friendly food tracker is distributed in the hope that it will be useful,
10 | but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | GNU General Public License for more details.
13 |
14 | You should have received a copy of the GNU General Public License
15 | along with Privacy friendly food tracker. If not, see .
16 | */
17 | package org.secuso.privacyfriendlyfoodtracker.database;
18 |
19 | import androidx.lifecycle.LiveData;
20 | import androidx.room.Dao;
21 | import androidx.room.Delete;
22 | import androidx.room.Insert;
23 | import androidx.room.Query;
24 | import androidx.room.Update;
25 |
26 | import java.util.List;
27 |
28 | /**
29 | * Includes methods that offer abstract access to the app database to manage products.
30 | *
31 | * @author Andre Lutz
32 | */
33 | @Dao
34 | public interface ProductDao {
35 | @Insert
36 | void insert(Product... product);
37 |
38 | @Update
39 | void update(Product... product);
40 |
41 | @Delete
42 | void delete(Product... product);
43 |
44 | @Query("DELETE FROM product")
45 | void deleteAll();
46 |
47 | @Query("SELECT * FROM product")
48 | LiveData> getAllProducts();
49 |
50 | @Query("SELECT * FROM product WHERE id=:id")
51 | Product findProductById(final int id);
52 |
53 | @Query("SELECT * FROM product WHERE name=:name AND energy=:energy AND barcode=:barcode")
54 | List findExistingProducts(String name, float energy, String barcode);
55 |
56 | @Query("SELECT * FROM product WHERE name LIKE :name")
57 | List findProductsByName(String name);
58 | }
59 |
--------------------------------------------------------------------------------
/app/src/main/java/org/secuso/privacyfriendlyfoodtracker/database/converter/DateConverter.java:
--------------------------------------------------------------------------------
1 | /*
2 | This file is part of Privacy friendly food tracker.
3 |
4 | Privacy friendly food tracker is free software: you can redistribute it and/or modify
5 | it under the terms of the GNU General Public License as published by
6 | the Free Software Foundation, either version 3 of the License, or
7 | (at your option) any later version.
8 |
9 | Privacy friendly food tracker is distributed in the hope that it will be useful,
10 | but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | GNU General Public License for more details.
13 |
14 | You should have received a copy of the GNU General Public License
15 | along with Privacy friendly food tracker. If not, see .
16 | */
17 | package org.secuso.privacyfriendlyfoodtracker.database.converter;
18 |
19 | import androidx.room.TypeConverter;
20 |
21 | import java.sql.Date;
22 |
23 | /**
24 | * Converts a date to long and the reverse conversion. It's required to store a date object in the room database.
25 | *
26 | * @author Andre Lutz
27 | */
28 | public class DateConverter {
29 |
30 | @TypeConverter
31 | public static Date fromTimestamp(Long value) {
32 | return value == null ? null : new Date(value);
33 | }
34 |
35 | @TypeConverter
36 | public static Long dateToTimestamp(Date date) {
37 | return date == null ? null : date.getTime();
38 | }
39 |
40 | }
41 |
--------------------------------------------------------------------------------
/app/src/main/java/org/secuso/privacyfriendlyfoodtracker/helpers/FirstLaunchManager.java:
--------------------------------------------------------------------------------
1 | /*
2 | This file is part of Privacy friendly food tracker.
3 |
4 | Privacy friendly food tracker is free software: you can redistribute it and/or modify
5 | it under the terms of the GNU General Public License as published by
6 | the Free Software Foundation, either version 3 of the License, or
7 | (at your option) any later version.
8 |
9 | Privacy friendly food tracker is distributed in the hope that it will be useful,
10 | but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | GNU General Public License for more details.
13 |
14 | You should have received a copy of the GNU General Public License
15 | along with Privacy friendly food tracker. If not, see .
16 | */
17 |
18 | package org.secuso.privacyfriendlyfoodtracker.helpers;
19 |
20 | import android.content.Context;
21 | import android.content.SharedPreferences;
22 |
23 |
24 | /**
25 | * @author Karola Marky
26 | * @version 20161214
27 | * Class structure taken from tutorial at http://www.androidhive.info/2016/05/android-build-intro-slider-app/
28 | */
29 | public class FirstLaunchManager {
30 | private SharedPreferences pref;
31 | private SharedPreferences.Editor editor;
32 |
33 | // shared pref mode
34 | private int PRIVATE_MODE = 0;
35 |
36 | // Shared preferences file name
37 | private static final String PREF_NAME = "privacy_friendly_apps";
38 |
39 | private static final String IS_FIRST_TIME_LAUNCH = "IsFirstTimeLaunch";
40 |
41 | public FirstLaunchManager(Context context) {
42 | pref = context.getSharedPreferences(PREF_NAME, PRIVATE_MODE);
43 | editor = pref.edit();
44 | }
45 |
46 | public void setFirstTimeLaunch(boolean isFirstTime) {
47 | editor.putBoolean(IS_FIRST_TIME_LAUNCH, isFirstTime);
48 | editor.commit();
49 | }
50 |
51 | public boolean isFirstTimeLaunch() {
52 | return pref.getBoolean(IS_FIRST_TIME_LAUNCH, true);
53 | }
54 |
55 | public void initFirstTimeLaunch() {
56 | if(pref.getBoolean(IS_FIRST_TIME_LAUNCH, true)) {
57 | // First time setup in here
58 | }
59 | }
60 |
61 | }
62 |
--------------------------------------------------------------------------------
/app/src/main/java/org/secuso/privacyfriendlyfoodtracker/network/ApiManager.java:
--------------------------------------------------------------------------------
1 | /*
2 | This file is part of Privacy friendly food tracker.
3 |
4 | Privacy friendly food tracker is free software: you can redistribute it and/or modify
5 | it under the terms of the GNU General Public License as published by
6 | the Free Software Foundation, either version 3 of the License, or
7 | (at your option) any later version.
8 |
9 | Privacy friendly food tracker is distributed in the hope that it will be useful,
10 | but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | GNU General Public License for more details.
13 |
14 | You should have received a copy of the GNU General Public License
15 | along with Privacy friendly food tracker. If not, see .
16 | */
17 | package org.secuso.privacyfriendlyfoodtracker.network;
18 |
19 |
20 | import java.util.Locale;
21 |
22 | import retrofit2.Retrofit;
23 | import retrofit2.converter.gson.GsonConverterFactory;
24 |
25 | /**
26 | * Creates the open food facts api service to send out network requests to the web-api.
27 | *
28 | * @author Andre Lutz
29 | */
30 | public class ApiManager implements IApiManager {
31 |
32 | private static ApiManager instance;
33 | private ProductApiService productApiService;
34 |
35 |
36 | public static ApiManager getInstance() {
37 | if (instance == null) {
38 | instance = new ApiManager();
39 | }
40 |
41 | return instance;
42 | }
43 |
44 | private ApiManager() {
45 | }
46 |
47 | /**
48 | * Returns the product api service. Uses the current default language code (de=Germany search, otherwise=Global search) to define the base url.
49 | *
50 | * @return product api service
51 | */
52 | @Override
53 | public ProductApiService getProductApiService() {
54 | if (productApiService == null) {
55 | productApiService = createProductApiService();
56 | }
57 |
58 | return productApiService;
59 | }
60 |
61 | /**
62 | * Returns the product api service.
63 | *
64 | * @param languageCode the locale on which the products will be searched (de=Germany search, otherwise=Global search) to define the base url
65 | * @return product api service
66 | */
67 | @Override
68 | public ProductApiService getProductApiService(String languageCode) {
69 | if (productApiService == null) {
70 | productApiService = createProductApiService(languageCode);
71 | }
72 |
73 | return productApiService;
74 | }
75 |
76 | private ProductApiService createProductApiService() {
77 | String languageCode = Locale.getDefault().getCountry();
78 | // TODO: check if it supported -> https://world.openfoodfacts.org/data/taxonomies/countries.json
79 | if (languageCode.equals("")) {
80 | languageCode = "world";
81 | }
82 | productApiService = createProductApiService(languageCode);
83 |
84 | return productApiService;
85 | }
86 |
87 |
88 | private ProductApiService createProductApiService(String languageCode) {
89 | productApiService = new Retrofit.Builder()
90 | .baseUrl("https://" + languageCode + ".openfoodfacts.org/")
91 | .addConverterFactory(GsonConverterFactory.create())
92 | .build().create(ProductApiService.class);
93 |
94 | return productApiService;
95 | }
96 | }
--------------------------------------------------------------------------------
/app/src/main/java/org/secuso/privacyfriendlyfoodtracker/network/IApiManager.java:
--------------------------------------------------------------------------------
1 | /*
2 | This file is part of Privacy friendly food tracker.
3 |
4 | Privacy friendly food tracker is free software: you can redistribute it and/or modify
5 | it under the terms of the GNU General Public License as published by
6 | the Free Software Foundation, either version 3 of the License, or
7 | (at your option) any later version.
8 |
9 | Privacy friendly food tracker is distributed in the hope that it will be useful,
10 | but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | GNU General Public License for more details.
13 |
14 | You should have received a copy of the GNU General Public License
15 | along with Privacy friendly food tracker. If not, see .
16 | */
17 | package org.secuso.privacyfriendlyfoodtracker.network;
18 |
19 | /**
20 | * Interface for creating the api service.
21 | *
22 | * @author Andre Lutz
23 | */
24 | public interface IApiManager {
25 |
26 | ProductApiService getProductApiService();
27 |
28 | ProductApiService getProductApiService(String languageCode);
29 | }
--------------------------------------------------------------------------------
/app/src/main/java/org/secuso/privacyfriendlyfoodtracker/network/ProductApiService.java:
--------------------------------------------------------------------------------
1 | /*
2 | This file is part of Privacy friendly food tracker.
3 |
4 | Privacy friendly food tracker is free software: you can redistribute it and/or modify
5 | it under the terms of the GNU General Public License as published by
6 | the Free Software Foundation, either version 3 of the License, or
7 | (at your option) any later version.
8 |
9 | Privacy friendly food tracker is distributed in the hope that it will be useful,
10 | but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | GNU General Public License for more details.
13 |
14 | You should have received a copy of the GNU General Public License
15 | along with Privacy friendly food tracker. If not, see .
16 | */
17 | package org.secuso.privacyfriendlyfoodtracker.network;
18 |
19 | import org.secuso.privacyfriendlyfoodtracker.network.models.ProductResponse;
20 |
21 | import java.util.List;
22 |
23 | import retrofit2.Call;
24 | import retrofit2.http.GET;
25 | import retrofit2.http.Path;
26 | import retrofit2.http.Query;
27 |
28 | /**
29 | * Defines the Open Food Facts API requests.
30 | *
31 | * @author Andre Lutz
32 | */
33 | public interface ProductApiService {
34 |
35 | @GET("/cgi/search.pl?product_size=1&search_simple=0&action=process&json=1")
36 | Call listProducts(@Query("search_terms") String productName);
37 |
38 | @GET("/cgi/search.pl?product_size=1&search_simple=0&action=process&json=1")
39 | Call listProductsFromPage(@Query("search_terms") String productName, @Query("page") String page );
40 | }
--------------------------------------------------------------------------------
/app/src/main/java/org/secuso/privacyfriendlyfoodtracker/network/models/ProductResponse.java:
--------------------------------------------------------------------------------
1 | /*
2 | This file is part of Privacy friendly food tracker.
3 |
4 | Privacy friendly food tracker is free software: you can redistribute it and/or modify
5 | it under the terms of the GNU General Public License as published by
6 | the Free Software Foundation, either version 3 of the License, or
7 | (at your option) any later version.
8 |
9 | Privacy friendly food tracker is distributed in the hope that it will be useful,
10 | but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | GNU General Public License for more details.
13 |
14 | You should have received a copy of the GNU General Public License
15 | along with Privacy friendly food tracker. If not, see .
16 | */
17 | package org.secuso.privacyfriendlyfoodtracker.network.models;
18 |
19 | import com.google.gson.Gson;
20 | import com.google.gson.GsonBuilder;
21 | import com.google.gson.annotations.SerializedName;
22 |
23 | import java.util.ArrayList;
24 | import java.util.List;
25 |
26 | /**
27 | * Java Model for the JSON Open Food Facts response. Representation a product.
28 | */
29 | public class ProductResponse {
30 |
31 | public List getProducts() {
32 | return products;
33 | }
34 |
35 | String skip;
36 | String count;
37 | String page;
38 | String page_size;
39 | List products;
40 |
41 | public ProductResponse() {
42 | products = new ArrayList();
43 | }
44 |
45 | public static ProductResponse parseJSON(String response) {
46 | Gson gson = new GsonBuilder().create();
47 | ProductResponse productResponse = gson.fromJson(response, ProductResponse.class);
48 | return productResponse;
49 | }
50 |
51 |
52 | }
53 |
--------------------------------------------------------------------------------
/app/src/main/java/org/secuso/privacyfriendlyfoodtracker/network/utils/ProductConversionHelper.java:
--------------------------------------------------------------------------------
1 | package org.secuso.privacyfriendlyfoodtracker.network.utils;
2 |
3 | import org.secuso.privacyfriendlyfoodtracker.database.Product;
4 |
5 | /**
6 | * Helper for conversion from NetworkProduct to the database Product object.
7 | *
8 | * @author Andre Lutz
9 | */
10 | public class ProductConversionHelper {
11 | public static Product conversionProduct(org.secuso.privacyfriendlyfoodtracker.network.models.NetworkProduct product) {
12 | String energyS = product.getNutrimentEnergy();
13 | if (energyS.equals("")) {
14 | return null;
15 | }
16 | float energy_100g;
17 | try {
18 | energy_100g = Integer.parseInt(product.getNutrimentEnergy()) / 4.184f;
19 | } catch (NumberFormatException e){
20 | energy_100g = Float.parseFloat(product.getNutrimentEnergy()) / 4.184f;
21 | }
22 | // if the id is equals to 0 then the room database creates a new id (primary key)
23 | return new Product(0, product.getProductName(), energy_100g, product.getCode());
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/app/src/main/java/org/secuso/privacyfriendlyfoodtracker/ui/AboutActivity.java:
--------------------------------------------------------------------------------
1 | /*
2 | This file is part of Privacy friendly food tracker.
3 |
4 | Privacy friendly food tracker is free software: you can redistribute it and/or modify
5 | it under the terms of the GNU General Public License as published by
6 | the Free Software Foundation, either version 3 of the License, or
7 | (at your option) any later version.
8 |
9 | Privacy friendly food tracker is distributed in the hope that it will be useful,
10 | but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | GNU General Public License for more details.
13 |
14 | You should have received a copy of the GNU General Public License
15 | along with Privacy friendly food tracker. If not, see .
16 | */
17 |
18 | package org.secuso.privacyfriendlyfoodtracker.ui;
19 |
20 | import android.os.Bundle;
21 | import androidx.appcompat.app.ActionBar;
22 | import androidx.appcompat.app.AppCompatActivity;
23 | import android.text.method.LinkMovementMethod;
24 | import android.view.View;
25 | import android.widget.TextView;
26 |
27 | import org.secuso.privacyfriendlyfoodtracker.BuildConfig;
28 | import org.secuso.privacyfriendlyfoodtracker.R;
29 | import org.secuso.privacyfriendlyfoodtracker.ui.helper.BaseActivity;
30 |
31 | /**
32 | * Displays an "about" page
33 | * @author Simon Reinkemeier, yonjuni
34 | *
35 | */
36 | public class AboutActivity extends AppCompatActivity {
37 |
38 | protected void onCreate(Bundle savedInstanceState) {
39 | super.onCreate(savedInstanceState);
40 | setContentView(R.layout.activity_about);
41 |
42 | ActionBar ab = getSupportActionBar();
43 | if(ab != null) {
44 | ab.setDisplayHomeAsUpEnabled(true);
45 | }
46 |
47 | View mainContent = findViewById(R.id.main_content);
48 | if (mainContent != null) {
49 | mainContent.setAlpha(0);
50 | mainContent.animate().alpha(1).setDuration(BaseActivity.MAIN_CONTENT_FADEIN_DURATION);
51 | }
52 |
53 | overridePendingTransition(0, 0);
54 |
55 | ((TextView)findViewById(R.id.secusoWebsite)).setMovementMethod(LinkMovementMethod.getInstance());
56 | ((TextView)findViewById(R.id.githubURL)).setMovementMethod(LinkMovementMethod.getInstance());
57 | ((TextView)findViewById(R.id.textFieldVersionName)).setText(getString(R.string.version_number, BuildConfig.VERSION_NAME));
58 | }
59 |
60 | }
61 |
62 |
--------------------------------------------------------------------------------
/app/src/main/java/org/secuso/privacyfriendlyfoodtracker/ui/BaseAddFoodActivity.java:
--------------------------------------------------------------------------------
1 | /*
2 | This file is part of Privacy friendly food tracker.
3 |
4 | Privacy friendly food tracker is free software: you can redistribute it and/or modify
5 | it under the terms of the GNU General Public License as published by
6 | the Free Software Foundation, either version 3 of the License, or
7 | (at your option) any later version.
8 |
9 | Privacy friendly food tracker is distributed in the hope that it will be useful,
10 | but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | GNU General Public License for more details.
13 |
14 | You should have received a copy of the GNU General Public License
15 | along with Privacy friendly food tracker. If not, see .
16 | */
17 | package org.secuso.privacyfriendlyfoodtracker.ui;
18 |
19 | import android.content.Intent;
20 | import com.google.android.material.tabs.TabLayout;
21 | import androidx.viewpager.widget.ViewPager;
22 | import androidx.appcompat.app.ActionBar;
23 | import androidx.appcompat.app.AppCompatActivity;
24 | import android.os.Bundle;
25 | import androidx.appcompat.widget.Toolbar;
26 | import android.view.MenuItem;
27 |
28 | import org.secuso.privacyfriendlyfoodtracker.R;
29 | import org.secuso.privacyfriendlyfoodtracker.ui.adapter.AddFoodPagerAdapter;
30 |
31 | import java.util.Date;
32 |
33 | /**
34 | * Base code for tapped activity.
35 | *
36 | * @author Simon Reinkemeier
37 | */
38 | public class BaseAddFoodActivity extends AppCompatActivity {
39 |
40 | // Date for the entry
41 | Date date;
42 | // Name of the product
43 | String name;
44 | // Calories per 100g
45 | float calories;
46 | // ID of the product
47 | int id;
48 |
49 | long dateLong;
50 | // true if a productID has been set by the SearchFoodFragment
51 | boolean productSet = false;
52 |
53 | /**
54 | * Called when the Activity is created
55 | * @param savedInstanceState the saved instance state
56 | */
57 | @Override
58 | protected void onCreate(Bundle savedInstanceState) {
59 | super.onCreate(savedInstanceState);
60 |
61 | setContentView(R.layout.activity_base_add_food);
62 | Toolbar toolbar = findViewById(R.id.toolbar);
63 | setSupportActionBar(toolbar);
64 |
65 | ViewPager viewPager = (ViewPager) findViewById(R.id.pager_food);
66 | AddFoodPagerAdapter myPagerAdapter = new AddFoodPagerAdapter(getSupportFragmentManager(), this);
67 | viewPager.setAdapter(myPagerAdapter);
68 |
69 | TabLayout tabLayout = (TabLayout) findViewById(R.id.tablayout_food);
70 | tabLayout.setupWithViewPager(viewPager);
71 |
72 | tabLayout.addOnTabSelectedListener(new TabLayout.OnTabSelectedListener() {
73 | @Override
74 | public void onTabReselected(TabLayout.Tab t){
75 | }
76 | @Override
77 | public void onTabUnselected(TabLayout.Tab t){
78 | }
79 | @Override
80 | public void onTabSelected(TabLayout.Tab t){
81 | productSet = false;
82 | }
83 |
84 | });
85 |
86 | Intent intent = getIntent();
87 |
88 |
89 | dateLong = intent.getLongExtra("DATE", System.currentTimeMillis());
90 | date = new Date();
91 | date.setTime(dateLong);
92 | setupActionBar();
93 |
94 |
95 |
96 | }
97 |
98 | @Override
99 | public boolean onOptionsItemSelected(MenuItem item) {
100 | switch (item.getItemId()) {
101 | case android.R.id.home:
102 | // todo: goto back activity from here
103 |
104 | Intent intent = new Intent(BaseAddFoodActivity.this, OverviewActivity.class);
105 | intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_NEW_TASK);
106 | intent.putExtra("DATE", dateLong);
107 | startActivity(intent);
108 | finish();
109 | return true;
110 |
111 | default:
112 | return super.onOptionsItemSelected(item);
113 | }
114 | }
115 |
116 | /**
117 | * Displays the "Back" or "Up" button in the Action bar
118 | */
119 | private void setupActionBar() {
120 | ActionBar actionBar = getSupportActionBar();
121 | if (actionBar != null) {
122 | // Show the Up button in the action bar.
123 | actionBar.setDisplayHomeAsUpEnabled(true);
124 | }
125 | }
126 |
127 | }
128 |
--------------------------------------------------------------------------------
/app/src/main/java/org/secuso/privacyfriendlyfoodtracker/ui/BaseStatisticActivity.java:
--------------------------------------------------------------------------------
1 | /*
2 | This file is part of Privacy friendly food tracker.
3 |
4 | Privacy friendly food tracker is free software: you can redistribute it and/or modify
5 | it under the terms of the GNU General Public License as published by
6 | the Free Software Foundation, either version 3 of the License, or
7 | (at your option) any later version.
8 |
9 | Privacy friendly food tracker is distributed in the hope that it will be useful,
10 | but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | GNU General Public License for more details.
13 |
14 | You should have received a copy of the GNU General Public License
15 | along with Privacy friendly food tracker. If not, see .
16 | */
17 | package org.secuso.privacyfriendlyfoodtracker.ui;
18 |
19 | import com.google.android.material.tabs.TabLayout;
20 | import androidx.viewpager.widget.ViewPager;
21 | import android.os.Bundle;
22 |
23 | import org.secuso.privacyfriendlyfoodtracker.R;
24 | import org.secuso.privacyfriendlyfoodtracker.ui.adapter.StatisticPagerAdapter;
25 | import org.secuso.privacyfriendlyfoodtracker.ui.helper.BaseActivity;
26 |
27 | /**
28 | * Base code for tapped activity.
29 | *
30 | * @author Andre Lutz
31 | */
32 | public class BaseStatisticActivity extends BaseActivity {
33 |
34 | @Override
35 | protected void onCreate(Bundle savedInstanceState) {
36 | super.onCreate(savedInstanceState);
37 |
38 | setContentView(R.layout.activity_base_statistic);
39 |
40 | ViewPager viewPager = (ViewPager) findViewById(R.id.pager);
41 | StatisticPagerAdapter myPagerAdapter = new StatisticPagerAdapter(getSupportFragmentManager(), this);
42 | viewPager.setAdapter(myPagerAdapter);
43 |
44 | TabLayout tabLayout = (TabLayout) findViewById(R.id.tablayout);
45 | tabLayout.setupWithViewPager(viewPager);
46 | }
47 |
48 | protected int getNavigationDrawerID() {
49 | return R.id.nav_statistic;
50 | }
51 |
52 | }
53 |
--------------------------------------------------------------------------------
/app/src/main/java/org/secuso/privacyfriendlyfoodtracker/ui/HelpActivity.java:
--------------------------------------------------------------------------------
1 | /*
2 | This file is part of Privacy friendly food tracker.
3 |
4 | Privacy friendly food tracker is free software: you can redistribute it and/or modify
5 | it under the terms of the GNU General Public License as published by
6 | the Free Software Foundation, either version 3 of the License, or
7 | (at your option) any later version.
8 |
9 | Privacy friendly food tracker is distributed in the hope that it will be useful,
10 | but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | GNU General Public License for more details.
13 |
14 | You should have received a copy of the GNU General Public License
15 | along with Privacy friendly food tracker. If not, see .
16 | */
17 |
18 | package org.secuso.privacyfriendlyfoodtracker.ui;
19 |
20 | import android.os.Bundle;
21 | import android.widget.ExpandableListView;
22 |
23 | import org.secuso.privacyfriendlyfoodtracker.R;
24 | import org.secuso.privacyfriendlyfoodtracker.ui.adapter.HelpExpandableListAdapter;
25 | import org.secuso.privacyfriendlyfoodtracker.ui.helper.BaseActivity;
26 |
27 | import java.util.ArrayList;
28 | import java.util.Collections;
29 | import java.util.LinkedHashMap;
30 | import java.util.List;
31 |
32 | /**
33 | * Shows a "Help" page
34 | * @author Karola Marky, Christopher Beckmann, Simon Reinkemeier
35 | * @version 20171016
36 | */
37 | public class HelpActivity extends BaseActivity {
38 |
39 | @Override
40 | protected void onCreate(Bundle savedInstanceState) {
41 | super.onCreate(savedInstanceState);
42 | setContentView(R.layout.activity_help);
43 |
44 | LinkedHashMap> expandableListDetail = buildData();
45 |
46 | ExpandableListView generalExpandableListView = findViewById(R.id.generalExpandableListView);
47 | generalExpandableListView.setAdapter(new HelpExpandableListAdapter(this, new ArrayList<>(expandableListDetail.keySet()), expandableListDetail));
48 |
49 | overridePendingTransition(0, 0);
50 | }
51 |
52 | private LinkedHashMap> buildData() {
53 | LinkedHashMap> expandableListDetail = new LinkedHashMap>();
54 |
55 | expandableListDetail.put(getString(R.string.help_whatis), Collections.singletonList(getString(R.string.help_whatis_answer)));
56 | expandableListDetail.put(getString(R.string.help_feature_one), Collections.singletonList(getString(R.string.help_feature_one_answer)));
57 | expandableListDetail.put(getString(R.string.help_privacy), Collections.singletonList(getString(R.string.help_privacy_answer)));
58 | expandableListDetail.put(getString(R.string.help_permission), Collections.singletonList(getString(R.string.help_permission_answer)));
59 |
60 | return expandableListDetail;
61 | }
62 |
63 | protected int getNavigationDrawerID() {
64 | return R.id.nav_help;
65 | }
66 |
67 | }
68 |
--------------------------------------------------------------------------------
/app/src/main/java/org/secuso/privacyfriendlyfoodtracker/ui/MainActivity.java:
--------------------------------------------------------------------------------
1 | /*
2 | This file is part of Privacy friendly food tracker.
3 |
4 | Privacy friendly food tracker is free software: you can redistribute it and/or modify
5 | it under the terms of the GNU General Public License as published by
6 | the Free Software Foundation, either version 3 of the License, or
7 | (at your option) any later version.
8 |
9 | Privacy friendly food tracker is distributed in the hope that it will be useful,
10 | but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | GNU General Public License for more details.
13 |
14 | You should have received a copy of the GNU General Public License
15 | along with Privacy friendly food tracker. If not, see .
16 | */
17 |
18 | package org.secuso.privacyfriendlyfoodtracker.ui;
19 |
20 | import android.content.Intent;
21 | import android.os.Bundle;
22 | import android.view.View;
23 | import android.widget.CalendarView;
24 |
25 | import java.text.ParseException;
26 | import java.text.SimpleDateFormat;
27 |
28 | import org.secuso.privacyfriendlyfoodtracker.R;
29 | import org.secuso.privacyfriendlyfoodtracker.ui.helper.BaseActivity;
30 |
31 | import java.util.Date;
32 |
33 | /**
34 | * @author Christopher Beckmann, Karola Marky, Andre Lutz
35 | * @version 20171016
36 | */
37 | public class MainActivity extends BaseActivity {
38 | private CalendarView calendarView;
39 |
40 | @Override
41 | protected void onCreate(Bundle savedInstanceState) {
42 | super.onCreate(savedInstanceState);
43 | setContentView(R.layout.activity_main);
44 | calendarView = (CalendarView) findViewById(R.id.CalendarView); // get the reference of CalendarView
45 | calendarView.setDate(System.currentTimeMillis(), false, true);
46 | calendarView.setOnDateChangeListener(new CalendarView.OnDateChangeListener() {
47 | @Override
48 | public void onSelectedDayChange(CalendarView view, int year, int month, int dayOfMonth) {
49 | Intent intent = new Intent(MainActivity.this, OverviewActivity.class);
50 | // Build string from chosen date to parse into Date object
51 | // (month+1) because months count from 0 in java but SimpleDateFormat parses it as 1-12
52 | String chosenDate = dayOfMonth + "/" + (month+1) + "/" + year;
53 | SimpleDateFormat sdf = new SimpleDateFormat("dd/MM/yyyy");
54 | try{
55 | Date date = sdf.parse(chosenDate);
56 | long millis = date.getTime();
57 | intent.putExtra("DATE", millis);
58 | } catch (ParseException e){
59 | e.printStackTrace();
60 | }
61 |
62 | startActivity(intent);
63 | }
64 | });
65 | overridePendingTransition(0, 0);
66 | }
67 |
68 | /**
69 | * This method connects the Activity to the menu item
70 | *
71 | * @return ID of the menu item it belongs to
72 | */
73 | @Override
74 | protected int getNavigationDrawerID() {
75 | return R.id.nav_example;
76 | }
77 |
78 | public void onClick(View v) {
79 | if (v != null) switch (v.getId()) {
80 |
81 | }
82 | }
83 | }
84 |
--------------------------------------------------------------------------------
/app/src/main/java/org/secuso/privacyfriendlyfoodtracker/ui/SplashActivity.java:
--------------------------------------------------------------------------------
1 | /*
2 | This file is part of Privacy friendly food tracker.
3 |
4 | Privacy friendly food tracker is free software: you can redistribute it and/or modify
5 | it under the terms of the GNU General Public License as published by
6 | the Free Software Foundation, either version 3 of the License, or
7 | (at your option) any later version.
8 |
9 | Privacy friendly food tracker is distributed in the hope that it will be useful,
10 | but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | GNU General Public License for more details.
13 |
14 | You should have received a copy of the GNU General Public License
15 | along with Privacy friendly food tracker. If not, see .
16 | */
17 |
18 | package org.secuso.privacyfriendlyfoodtracker.ui;
19 |
20 | import android.content.Intent;
21 | import android.os.Bundle;
22 | import androidx.appcompat.app.AppCompatActivity;
23 |
24 | import org.secuso.privacyfriendlyfoodtracker.helpers.FirstLaunchManager;
25 | import org.secuso.privacyfriendlyfoodtracker.helpers.KeyGenHelper;
26 |
27 | /**
28 | * @author Karola Marky
29 | * @version 20161022
30 | */
31 |
32 | public class SplashActivity extends AppCompatActivity {
33 |
34 | @Override
35 | protected void onCreate(Bundle savedInstanceState) {
36 | super.onCreate(savedInstanceState);
37 |
38 | Intent mainIntent = new Intent(SplashActivity.this, TutorialActivity.class);
39 |
40 | FirstLaunchManager firstStartPref = new FirstLaunchManager(this);
41 |
42 | if(firstStartPref.isFirstTimeLaunch()) {
43 | firstStartPref.initFirstTimeLaunch();
44 | mainIntent = new Intent(this, TutorialActivity.class);
45 | } else if(!KeyGenHelper.isKeyGenerated()) {
46 | firstStartPref.initFirstTimeLaunch();
47 | mainIntent = new Intent(this, TutorialActivity.class);
48 | } else {
49 | mainIntent = new Intent(this, MainActivity.class);
50 | mainIntent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
51 | }
52 |
53 | startActivity(mainIntent);
54 | finish();
55 | }
56 |
57 | }
58 |
--------------------------------------------------------------------------------
/app/src/main/java/org/secuso/privacyfriendlyfoodtracker/ui/adapter/AddFoodPagerAdapter.java:
--------------------------------------------------------------------------------
1 | /*
2 | This file is part of Privacy friendly food tracker.
3 |
4 | Privacy friendly food tracker is free software: you can redistribute it and/or modify
5 | it under the terms of the GNU General Public License as published by
6 | the Free Software Foundation, either version 3 of the License, or
7 | (at your option) any later version.
8 |
9 | Privacy friendly food tracker is distributed in the hope that it will be useful,
10 | but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | GNU General Public License for more details.
13 |
14 | You should have received a copy of the GNU General Public License
15 | along with Privacy friendly food tracker. If not, see .
16 | */
17 | package org.secuso.privacyfriendlyfoodtracker.ui.adapter;
18 |
19 | import android.content.Context;
20 | import androidx.fragment.app.Fragment;
21 | import androidx.fragment.app.FragmentManager;
22 | import androidx.fragment.app.FragmentStatePagerAdapter;
23 |
24 | import org.secuso.privacyfriendlyfoodtracker.R;
25 | import org.secuso.privacyfriendlyfoodtracker.ui.AddFoodFragment;
26 | import org.secuso.privacyfriendlyfoodtracker.ui.SearchFoodFragment;
27 |
28 | /**
29 | * Implementation of PagerAdapter that uses a Fragment to manage each page. This class also handles saving and restoring of fragment's state.
30 | *
31 | * @author Simon Reinkemeier
32 | */
33 | public class AddFoodPagerAdapter extends FragmentStatePagerAdapter {
34 | private Context context;
35 |
36 | /**
37 | * A pager adapter.
38 | *
39 | * @param fm the fragment manager
40 | * @param context the context
41 | */
42 | public AddFoodPagerAdapter(FragmentManager fm, Context context) {
43 | super(fm);
44 | this.context = context;
45 | }
46 |
47 | /**
48 | * Get the fragment for position.
49 | *
50 | * @param position the position
51 | * @return the fragment at position or null
52 | */
53 | @Override
54 | public Fragment getItem(int position) {
55 | switch (position) {
56 | case 0:
57 | return new SearchFoodFragment();
58 | case 1:
59 | return new AddFoodFragment();
60 | }
61 | return null;
62 | }
63 |
64 | /**
65 | * The number of fragments.
66 | *
67 | * @return number of fragments
68 | */
69 | @Override
70 | public int getCount() {
71 | return 2;
72 | }
73 |
74 | /**
75 | * Get the page title.
76 | *
77 | * @param position
78 | * @return the fragment position
79 | */
80 | @Override
81 | public CharSequence getPageTitle(int position) {
82 | switch (position) {
83 | case 0:
84 | return context.getResources().getString(R.string.search);
85 | case 1:
86 | return context.getResources().getString(R.string.add);
87 | default:
88 | return null;
89 | }
90 | }
91 | }
92 |
--------------------------------------------------------------------------------
/app/src/main/java/org/secuso/privacyfriendlyfoodtracker/ui/adapter/DatabaseEntry.java:
--------------------------------------------------------------------------------
1 | /*
2 | This file is part of Privacy friendly food tracker.
3 |
4 | Privacy friendly food tracker is free software: you can redistribute it and/or modify
5 | it under the terms of the GNU General Public License as published by
6 | the Free Software Foundation, either version 3 of the License, or
7 | (at your option) any later version.
8 |
9 | Privacy friendly food tracker is distributed in the hope that it will be useful,
10 | but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | GNU General Public License for more details.
13 |
14 | You should have received a copy of the GNU General Public License
15 | along with Privacy friendly food tracker. If not, see .
16 | */
17 | package org.secuso.privacyfriendlyfoodtracker.ui.adapter;
18 |
19 | /**
20 | * Models a consumed entry.
21 | * @author Simon Reinkemeier
22 | */
23 | public class DatabaseEntry {
24 | public float energy;
25 | public int amount;
26 | public String name;
27 | public int id;
28 | public DatabaseEntry(int id, String name, int amount, float energy){
29 | this.id = id;
30 | this.amount = amount;
31 | this.energy = energy;
32 | this.name = name;
33 | }
34 | }
--------------------------------------------------------------------------------
/app/src/main/java/org/secuso/privacyfriendlyfoodtracker/ui/adapter/StatisticPagerAdapter.java:
--------------------------------------------------------------------------------
1 | /*
2 | This file is part of Privacy friendly food tracker.
3 |
4 | Privacy friendly food tracker is free software: you can redistribute it and/or modify
5 | it under the terms of the GNU General Public License as published by
6 | the Free Software Foundation, either version 3 of the License, or
7 | (at your option) any later version.
8 |
9 | Privacy friendly food tracker is distributed in the hope that it will be useful,
10 | but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | GNU General Public License for more details.
13 |
14 | You should have received a copy of the GNU General Public License
15 | along with Privacy friendly food tracker. If not, see .
16 | */
17 | package org.secuso.privacyfriendlyfoodtracker.ui.adapter;
18 |
19 | import android.content.Context;
20 | import androidx.fragment.app.Fragment;
21 | import androidx.fragment.app.FragmentManager;
22 | import androidx.fragment.app.FragmentStatePagerAdapter;
23 |
24 | import org.secuso.privacyfriendlyfoodtracker.R;
25 | import org.secuso.privacyfriendlyfoodtracker.ui.MonthStatisticFragment;
26 | import org.secuso.privacyfriendlyfoodtracker.ui.WeekStatisticFragment;
27 |
28 | /**
29 | * Implementation of PagerAdapter that uses a Fragment to manage each page. This class also handles saving and restoring of fragment's state.
30 | *
31 | * @author Andre Lutz
32 | */
33 | public class StatisticPagerAdapter extends FragmentStatePagerAdapter {
34 | private Context context;
35 |
36 | /**
37 | * A pager adapter.
38 | *
39 | * @param fm the fragment manager
40 | * @param context the context
41 | */
42 | public StatisticPagerAdapter(FragmentManager fm, Context context) {
43 | super(fm);
44 | this.context = context;
45 | }
46 |
47 | /**
48 | * Get the fragment for position.
49 | *
50 | * @param position the position
51 | * @return the fragment at position or null
52 | */
53 | @Override
54 | public Fragment getItem(int position) {
55 | switch (position) {
56 | case 0:
57 | return new WeekStatisticFragment();
58 | case 1:
59 | return new MonthStatisticFragment();
60 | }
61 | return null;
62 | }
63 |
64 | /**
65 | * The number of fragments.
66 | *
67 | * @return number of fragments
68 | */
69 | @Override
70 | public int getCount() {
71 | return 2;
72 | }
73 |
74 | /**
75 | * Get the page title.
76 | *
77 | * @param position
78 | * @return the fragment position
79 | */
80 | @Override
81 | public CharSequence getPageTitle(int position) {
82 | switch (position) {
83 | case 0:
84 | return context.getResources().getString(R.string.week);
85 | case 1:
86 | return context.getResources().getString(R.string.month);
87 | default:
88 | return null;
89 | }
90 | }
91 | }
92 |
--------------------------------------------------------------------------------
/app/src/main/java/org/secuso/privacyfriendlyfoodtracker/ui/helper/AppCompatPreferenceActivity.java:
--------------------------------------------------------------------------------
1 | /*
2 | This file is part of Privacy Friendly App Example.
3 |
4 | Privacy Friendly App Example is free software:
5 | you can redistribute it and/or modify it under the terms of the
6 | GNU General Public License as published by the Free Software Foundation,
7 | either version 3 of the License, or any later version.
8 |
9 | Privacy Friendly App Example is distributed in the hope
10 | that it will be useful, but WITHOUT ANY WARRANTY; without even
11 | the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
12 | See the GNU General Public License for more details.
13 |
14 | You should have received a copy of the GNU General Public License
15 | along with Privacy Friendly App Example. If not, see .
16 | */
17 |
18 | package org.secuso.privacyfriendlyfoodtracker.ui.helper;
19 |
20 | import android.content.res.Configuration;
21 | import android.os.Bundle;
22 | import android.preference.PreferenceActivity;
23 | import androidx.annotation.LayoutRes;
24 | import androidx.annotation.Nullable;
25 | import androidx.appcompat.app.ActionBar;
26 | import androidx.appcompat.app.AppCompatDelegate;
27 | import androidx.appcompat.widget.Toolbar;
28 | import android.view.MenuInflater;
29 | import android.view.View;
30 | import android.view.ViewGroup;
31 |
32 | /**
33 | * A {@link android.preference.PreferenceActivity} which implements and proxies the necessary calls
34 | * to be used with AppCompat.
35 | */
36 | public abstract class AppCompatPreferenceActivity extends PreferenceActivity {
37 |
38 | private AppCompatDelegate mDelegate;
39 |
40 | @Override
41 | protected void onCreate(Bundle savedInstanceState) {
42 | getDelegate().installViewFactory();
43 | getDelegate().onCreate(savedInstanceState);
44 | super.onCreate(savedInstanceState);
45 | }
46 |
47 | @Override
48 | protected void onPostCreate(Bundle savedInstanceState) {
49 | super.onPostCreate(savedInstanceState);
50 | getDelegate().onPostCreate(savedInstanceState);
51 | }
52 |
53 | public ActionBar getSupportActionBar() {
54 | return getDelegate().getSupportActionBar();
55 | }
56 |
57 | public void setSupportActionBar(@Nullable Toolbar toolbar) {
58 | getDelegate().setSupportActionBar(toolbar);
59 | }
60 |
61 | @Override
62 | public MenuInflater getMenuInflater() {
63 | return getDelegate().getMenuInflater();
64 | }
65 |
66 | @Override
67 | public void setContentView(@LayoutRes int layoutResID) {
68 | getDelegate().setContentView(layoutResID);
69 | }
70 |
71 | @Override
72 | public void setContentView(View view) {
73 | getDelegate().setContentView(view);
74 | }
75 |
76 | @Override
77 | public void setContentView(View view, ViewGroup.LayoutParams params) {
78 | getDelegate().setContentView(view, params);
79 | }
80 |
81 | @Override
82 | public void addContentView(View view, ViewGroup.LayoutParams params) {
83 | getDelegate().addContentView(view, params);
84 | }
85 |
86 | @Override
87 | protected void onPostResume() {
88 | super.onPostResume();
89 | getDelegate().onPostResume();
90 | }
91 |
92 | @Override
93 | protected void onTitleChanged(CharSequence title, int color) {
94 | super.onTitleChanged(title, color);
95 | getDelegate().setTitle(title);
96 | }
97 |
98 | @Override
99 | public void onConfigurationChanged(Configuration newConfig) {
100 | super.onConfigurationChanged(newConfig);
101 | getDelegate().onConfigurationChanged(newConfig);
102 | }
103 |
104 | @Override
105 | protected void onStop() {
106 | super.onStop();
107 | getDelegate().onStop();
108 | }
109 |
110 | @Override
111 | protected void onDestroy() {
112 | super.onDestroy();
113 | getDelegate().onDestroy();
114 | }
115 |
116 | public void invalidateOptionsMenu() {
117 | getDelegate().invalidateOptionsMenu();
118 | }
119 |
120 | private AppCompatDelegate getDelegate() {
121 | if (mDelegate == null) {
122 | mDelegate = AppCompatDelegate.create(this, null);
123 | }
124 | return mDelegate;
125 | }
126 | }
127 |
--------------------------------------------------------------------------------
/app/src/main/java/org/secuso/privacyfriendlyfoodtracker/ui/helper/DateHelper.java:
--------------------------------------------------------------------------------
1 | package org.secuso.privacyfriendlyfoodtracker.ui.helper;
2 |
3 | import java.text.DateFormat;
4 | import java.util.Calendar;
5 | import java.util.Date;
6 | import java.util.Locale;
7 |
8 | /**
9 | * Helps to modified the week or month attributes of a date object.
10 | */
11 | public class DateHelper {
12 |
13 |
14 | /**
15 | * Change the month of a date by a value.
16 | *
17 | * @param date the current date
18 | * @param value number of months
19 | * @return new date with modified month
20 | */
21 | public static Date changeMonth(Date date, int value) {
22 | Calendar calendar = Calendar.getInstance();
23 | calendar.setTime(date);
24 | calendar.add(Calendar.MONTH, value);
25 | return calendar.getTime();
26 | }
27 |
28 | /**
29 | * Change the week of a date by a value.
30 | *
31 | * @param date the current date
32 | * @param value number of weeks
33 | * @return new date with modified week
34 | */
35 | public static Date changeWeek(Date date, int value) {
36 | Calendar calendar = Calendar.getInstance();
37 | calendar.setTime(date);
38 | //calendar.add(Calendar.DAY_OF_YEAR, value * 7);
39 | calendar.add(Calendar.WEEK_OF_YEAR, value);
40 | calendar.add(Calendar.DAY_OF_YEAR, 1);
41 | return calendar.getTime();
42 | }
43 |
44 | /**
45 | * Converts a date to string.
46 | *
47 | * @param date the current date
48 | * @return the date as localized string
49 | */
50 | public static String dateToString(Date date) {
51 | DateFormat dateFormat = DateFormat.getDateInstance(DateFormat.SHORT, Locale.getDefault());
52 | return dateFormat.format(date);
53 | }
54 |
55 | /**
56 | * Sets a given Date's time to 00:00:00.00, so getting a weeks daily calories works reliably.
57 | * @param date the date whose time shall be midnight
58 | * @return the new changed date
59 | */
60 | public static Date changeDateTimeToMidnight(Date date){
61 | Calendar calendar = Calendar.getInstance();
62 | calendar.setTime(date);
63 | calendar.set(Calendar.HOUR_OF_DAY, 0);
64 | calendar.set(Calendar.MINUTE, 0);
65 | calendar.set(Calendar.SECOND, 0);
66 | calendar.set(Calendar.MILLISECOND, 0);
67 |
68 | return calendar.getTime();
69 | }
70 | }
71 |
--------------------------------------------------------------------------------
/app/src/main/java/org/secuso/privacyfriendlyfoodtracker/ui/helper/MathHelper.java:
--------------------------------------------------------------------------------
1 | package org.secuso.privacyfriendlyfoodtracker.ui.helper;
2 |
3 | import java.math.BigDecimal;
4 |
5 | public class MathHelper {
6 |
7 | /**
8 | * Source: https://stackoverflow.com/questions/8911356/whats-the-best-practice-to-round-a-float-to-2-decimals
9 | * By Carlos Alberto Martínez
10 | * @param d
11 | * @param decimalPlace
12 | * @return
13 | */
14 | public static BigDecimal round(float d, int decimalPlace) {
15 | BigDecimal bd = new BigDecimal(Float.toString(d));
16 | bd = bd.setScale(decimalPlace, BigDecimal.ROUND_HALF_UP);
17 | return bd;
18 | }
19 | }
20 |
--------------------------------------------------------------------------------
/app/src/main/java/org/secuso/privacyfriendlyfoodtracker/ui/viewmodels/OverviewViewModel.java:
--------------------------------------------------------------------------------
1 | package org.secuso.privacyfriendlyfoodtracker.ui.viewmodels;
2 |
3 | import android.app.Application;
4 | import androidx.lifecycle.AndroidViewModel;
5 | import androidx.lifecycle.LiveData;
6 | import androidx.lifecycle.MutableLiveData;
7 | import androidx.lifecycle.ViewModel;
8 | import androidx.lifecycle.ViewModelProvider;
9 | import androidx.annotation.NonNull;
10 |
11 | import org.secuso.privacyfriendlyfoodtracker.ui.adapter.DatabaseEntry;
12 | import org.secuso.privacyfriendlyfoodtracker.ui.adapter.DatabaseFacade;
13 |
14 | import java.util.Date;
15 | import java.util.List;
16 |
17 | public class OverviewViewModel extends AndroidViewModel {
18 | private LiveData> list = new MutableLiveData<>();
19 |
20 | DatabaseFacade dbHelper = null;
21 |
22 | /**
23 | *
24 | * @param application
25 |
26 | */
27 | public OverviewViewModel(@NonNull Application application) {
28 | super(application);
29 |
30 | try {
31 | dbHelper = new DatabaseFacade(application.getApplicationContext());
32 | } catch (Exception e) {
33 | e.printStackTrace();
34 | }
35 | }
36 |
37 | /**
38 | *
39 | * @param day The date for which the database entries are to be fetched
40 | * */
41 | public void init(Date day) {
42 | list = dbHelper.getConsumedEntriesForDay(day);
43 | }
44 |
45 | public LiveData> getList() {
46 | return list;
47 | }
48 |
49 |
50 | public void deleteEntryById(int id) {
51 | dbHelper.deleteEntryById(id);
52 | }
53 |
54 | public void editEntryById(int id, int amount) {
55 | dbHelper.editEntryById(id, amount);
56 | }
57 |
58 | }
59 |
--------------------------------------------------------------------------------
/app/src/main/java/org/secuso/privacyfriendlyfoodtracker/ui/viewmodels/SharedStatisticViewModel.java:
--------------------------------------------------------------------------------
1 | /*
2 | This file is part of Privacy friendly food tracker.
3 |
4 | Privacy friendly food tracker is free software: you can redistribute it and/or modify
5 | it under the terms of the GNU General Public License as published by
6 | the Free Software Foundation, either version 3 of the License, or
7 | (at your option) any later version.
8 |
9 | Privacy friendly food tracker is distributed in the hope that it will be useful,
10 | but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | GNU General Public License for more details.
13 |
14 | You should have received a copy of the GNU General Public License
15 | along with Privacy friendly food tracker. If not, see .
16 | */
17 | package org.secuso.privacyfriendlyfoodtracker.ui.viewmodels;
18 |
19 | import androidx.lifecycle.LiveData;
20 | import androidx.lifecycle.MutableLiveData;
21 | import androidx.lifecycle.ViewModel;
22 |
23 | import java.util.Calendar;
24 | import java.util.Date;
25 |
26 | /**
27 | * For sharing data between WeekStatisticFragment and MonthStatisticFragment.
28 | */
29 | public class SharedStatisticViewModel extends ViewModel {
30 | private final MutableLiveData liveCalendar = new MutableLiveData();
31 |
32 | public LiveData getLiveCalendar() {
33 | return liveCalendar;
34 | }
35 |
36 | /**
37 | * Constructor. Sets the calender value to the current day.
38 | */
39 | public SharedStatisticViewModel() {
40 | final Calendar currentTime = Calendar.getInstance();
41 | calendar = currentTime;
42 | liveCalendar.setValue(calendar);
43 | }
44 |
45 | private Calendar calendar;
46 |
47 |
48 | public Date getDate() {
49 | return calendar.getTime();
50 | }
51 |
52 | public Calendar getCalendar() {
53 | return calendar;
54 | }
55 |
56 | public void setDate(int day, int month, int year) {
57 | Calendar cal = Calendar.getInstance();
58 | cal.set(Calendar.YEAR, year);
59 | cal.set(Calendar.MONTH, month);
60 | cal.set(Calendar.DAY_OF_MONTH, day);
61 | calendar = cal;
62 | liveCalendar.setValue(calendar);
63 | }
64 |
65 | public void setCalendarWithDateObj(Date date) {
66 | Calendar cal = Calendar.getInstance();
67 | cal.setTime(date);
68 | calendar = cal;
69 | liveCalendar.setValue(calendar);
70 | }
71 | }
72 |
--------------------------------------------------------------------------------
/app/src/main/java/org/secuso/privacyfriendlyfoodtracker/ui/views/CheckableCardView.java:
--------------------------------------------------------------------------------
1 | /*
2 | This file is part of Privacy friendly food tracker.
3 |
4 | Privacy friendly food tracker is free software: you can redistribute it and/or modify
5 | it under the terms of the GNU General Public License as published by
6 | the Free Software Foundation, either version 3 of the License, or
7 | (at your option) any later version.
8 |
9 | Privacy friendly food tracker is distributed in the hope that it will be useful,
10 | but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | GNU General Public License for more details.
13 |
14 | You should have received a copy of the GNU General Public License
15 | along with Privacy friendly food tracker. If not, see .
16 | */
17 | package org.secuso.privacyfriendlyfoodtracker.ui.views;
18 |
19 | import android.content.Context;
20 | import androidx.cardview.widget.CardView;
21 | import android.widget.Checkable;
22 |
23 | /**
24 | * Makes a card view checkable
25 | * @author Simon Reinkemeier
26 | */
27 | public class CheckableCardView extends CardView
28 | implements Checkable {
29 |
30 | private static final int[] CHECKED_STATE_SET = {
31 | android.R.attr.state_checked,
32 | };
33 |
34 | /**
35 | * merges state values into base drawable states
36 | * @param extraSpace the extra space
37 | * @return a drawable state
38 | */
39 | @Override
40 | protected int[] onCreateDrawableState(int extraSpace) {
41 | final int[] drawableState =
42 | super.onCreateDrawableState(extraSpace + 1);
43 |
44 | if (isChecked()) {
45 | mergeDrawableStates(drawableState, CHECKED_STATE_SET);
46 | }
47 | return drawableState;
48 | }
49 |
50 | /**
51 | * Constructors and view initialization
52 | * @param t the context
53 | */
54 | public CheckableCardView(Context t){
55 | super(t);
56 | }
57 |
58 | private boolean isChecked = false;
59 |
60 | /**
61 | * toggles the state if a long click is performed
62 | * @return true if the parent method returns true
63 | */
64 | @Override
65 | public boolean performLongClick() {
66 | toggle();
67 | return super.performLongClick();
68 | }
69 |
70 | /**
71 | * Set the check state to 'checked'
72 | * @param checked the new 'isChecked' state
73 | */
74 | @Override
75 | public void setChecked(boolean checked) {
76 | this.isChecked = checked;
77 | }
78 |
79 | /**
80 | * Returns the state of the check
81 | * @return true if cardview is checked
82 | */
83 | @Override
84 | public boolean isChecked() {
85 | return isChecked;
86 | }
87 |
88 | /**
89 | * inverses the check state every time its called.
90 | */
91 | @Override
92 | public void toggle() {
93 | setChecked(!this.isChecked);
94 | }
95 | }
96 |
--------------------------------------------------------------------------------
/app/src/main/res/color/selector_card_view_colors.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
7 |
8 |
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/add_entry.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/SecUSo/privacy-friendly-food-tracker/247d9a525cd2ad293edaa6fe4b610ce36979a61a/app/src/main/res/drawable/add_entry.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable/baseline_search_white_18.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/SecUSo/privacy-friendly-food-tracker/247d9a525cd2ad293edaa6fe4b610ce36979a61a/app/src/main/res/drawable/baseline_search_white_18.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable/baseline_search_white_24.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/SecUSo/privacy-friendly-food-tracker/247d9a525cd2ad293edaa6fe4b610ce36979a61a/app/src/main/res/drawable/baseline_search_white_24.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable/baseline_search_white_36.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/SecUSo/privacy-friendly-food-tracker/247d9a525cd2ad293edaa6fe4b610ce36979a61a/app/src/main/res/drawable/baseline_search_white_36.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable/baseline_search_white_48.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/SecUSo/privacy-friendly-food-tracker/247d9a525cd2ad293edaa6fe4b610ce36979a61a/app/src/main/res/drawable/baseline_search_white_48.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable/button_cancel.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/SecUSo/privacy-friendly-food-tracker/247d9a525cd2ad293edaa6fe4b610ce36979a61a/app/src/main/res/drawable/button_cancel.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable/button_confirm.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/SecUSo/privacy-friendly-food-tracker/247d9a525cd2ad293edaa6fe4b610ce36979a61a/app/src/main/res/drawable/button_confirm.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable/button_disabled.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | -
4 |
5 |
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/button_fullwidth.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | -
4 |
5 |
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/button_highlighted.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | -
4 |
5 |
6 |
7 |
8 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/button_highlighted_2.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | -
4 |
5 |
6 |
7 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/button_highlighted_3.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | -
4 |
5 |
6 |
7 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/button_highlighted_4.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | -
4 |
5 |
6 |
7 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/button_middleblue.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | -
4 |
5 |
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/button_normal.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | -
4 |
5 |
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/ic_info_black_24dp.xml:
--------------------------------------------------------------------------------
1 |
6 |
9 |
10 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/ic_keyboard_arrow_left_black_24dp.xml:
--------------------------------------------------------------------------------
1 |
6 |
9 |
10 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/ic_keyboard_arrow_right_black_24dp.xml:
--------------------------------------------------------------------------------
1 |
6 |
9 |
10 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/ic_menu_help.xml:
--------------------------------------------------------------------------------
1 |
6 |
9 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/ic_menu_home.xml:
--------------------------------------------------------------------------------
1 |
6 |
9 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/ic_menu_info.xml:
--------------------------------------------------------------------------------
1 |
6 |
9 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/ic_menu_settings.xml:
--------------------------------------------------------------------------------
1 |
4 |
5 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/ic_menu_tutorial.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
10 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/privacyfriendlyappslogo.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/SecUSo/privacy-friendly-food-tracker/247d9a525cd2ad293edaa6fe4b610ce36979a61a/app/src/main/res/drawable/privacyfriendlyappslogo.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable/secuso_logo_blau_blau.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/SecUSo/privacy-friendly-food-tracker/247d9a525cd2ad293edaa6fe4b610ce36979a61a/app/src/main/res/drawable/secuso_logo_blau_blau.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable/splash_screen.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
5 |
6 | -
7 |
11 |
12 |
--------------------------------------------------------------------------------
/app/src/main/res/layout-land/activity_base_statistic.xml:
--------------------------------------------------------------------------------
1 |
2 |
11 |
12 |
20 |
21 |
28 |
29 |
30 |
40 |
41 |
42 |
43 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
63 |
64 |
--------------------------------------------------------------------------------
/app/src/main/res/layout-land/activity_calendar.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
11 |
--------------------------------------------------------------------------------
/app/src/main/res/layout-land/activity_help.xml:
--------------------------------------------------------------------------------
1 |
2 |
10 |
11 |
18 |
19 |
20 |
21 |
29 |
30 |
37 |
38 |
39 |
40 |
41 |
42 |
50 |
51 |
--------------------------------------------------------------------------------
/app/src/main/res/layout-land/activity_main.xml:
--------------------------------------------------------------------------------
1 |
2 |
10 |
11 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
31 |
32 |
33 |
--------------------------------------------------------------------------------
/app/src/main/res/layout-land/activity_settings.xml:
--------------------------------------------------------------------------------
1 |
2 |
11 |
12 |
17 |
18 |
19 |
20 |
30 |
31 |
35 |
36 |
37 |
38 |
39 |
40 |
48 |
49 |
--------------------------------------------------------------------------------
/app/src/main/res/layout-land/activity_tutorial.xml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
9 |
10 |
14 |
15 |
23 |
24 |
30 |
31 |
41 |
42 |
52 |
53 |
--------------------------------------------------------------------------------
/app/src/main/res/layout-land/content_food.xml:
--------------------------------------------------------------------------------
1 |
2 |
9 |
18 |
19 |
26 |
27 |
34 |
35 |
36 |
37 |
43 |
44 |
51 |
52 |
53 |
59 |
60 |
67 |
68 |
69 |
70 |
71 |
72 |
80 |
81 |
--------------------------------------------------------------------------------
/app/src/main/res/layout-land/content_main.xml:
--------------------------------------------------------------------------------
1 |
2 |
18 |
22 |
23 |
--------------------------------------------------------------------------------
/app/src/main/res/layout-land/content_search.xml:
--------------------------------------------------------------------------------
1 |
2 |
12 |
19 |
20 |
28 |
29 |
30 |
37 |
38 |
48 |
49 |
--------------------------------------------------------------------------------
/app/src/main/res/layout-land/dialog_edit_entry.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
8 |
16 |
17 |
22 |
23 |
30 |
31 |
32 |
33 |
38 |
39 |
55 |
56 |
72 |
73 |
74 |
75 |
76 |
77 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_base_add_food.xml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
9 |
21 |
22 |
29 |
30 |
31 |
41 |
42 |
43 |
44 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_base_statistic.xml:
--------------------------------------------------------------------------------
1 |
2 |
11 |
12 |
20 |
21 |
28 |
29 |
30 |
40 |
41 |
42 |
43 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
63 |
64 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_calendar.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
11 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_food.xml:
--------------------------------------------------------------------------------
1 |
2 |
9 |
13 |
14 |
20 |
21 |
22 |
23 |
24 |
25 |
32 |
33 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_help.xml:
--------------------------------------------------------------------------------
1 |
2 |
10 |
11 |
18 |
19 |
20 |
21 |
29 |
30 |
37 |
38 |
39 |
40 |
41 |
42 |
50 |
51 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_main.xml:
--------------------------------------------------------------------------------
1 |
2 |
10 |
11 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
31 |
32 |
33 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_overview.xml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
9 |
14 |
15 |
22 |
23 |
24 |
25 |
26 |
27 |
34 |
35 |
41 |
42 |
50 |
58 |
59 |
60 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_settings.xml:
--------------------------------------------------------------------------------
1 |
2 |
11 |
12 |
17 |
18 |
19 |
20 |
30 |
31 |
35 |
36 |
37 |
38 |
39 |
40 |
48 |
49 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_tutorial.xml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
9 |
10 |
14 |
15 |
23 |
24 |
30 |
31 |
41 |
42 |
52 |
53 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/content_food.xml:
--------------------------------------------------------------------------------
1 |
2 |
9 |
10 |
19 |
20 |
27 |
28 |
35 |
36 |
37 |
38 |
44 |
45 |
52 |
53 |
54 |
55 |
61 |
62 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
83 |
84 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/content_main.xml:
--------------------------------------------------------------------------------
1 |
2 |
18 |
22 |
23 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/content_overview.xml:
--------------------------------------------------------------------------------
1 |
2 |
14 |
15 |
25 |
26 |
33 |
34 |
40 |
41 |
42 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/content_search.xml:
--------------------------------------------------------------------------------
1 |
2 |
12 |
19 |
20 |
28 |
29 |
30 |
37 |
38 |
48 |
49 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/dialog_edit_entry.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
8 |
16 |
17 |
22 |
23 |
30 |
31 |
32 |
33 |
38 |
39 |
55 |
56 |
72 |
73 |
74 |
75 |
76 |
77 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/list_group.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 |
14 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/list_item.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
6 |
14 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/nav_header_main.xml:
--------------------------------------------------------------------------------
1 |
2 |
11 |
12 |
19 |
20 |
26 |
27 |
37 |
38 |
39 |
40 |
41 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/search_result.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
8 |
12 |
13 |
24 |
34 |
40 |
41 |
42 |
43 |
44 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/toolbar.xml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
9 |
15 |
16 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/tutorial_slide1.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
14 |
15 |
16 |
23 |
24 |
29 |
30 |
41 |
42 |
43 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/tutorial_slide2.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
14 |
15 |
22 |
23 |
28 |
29 |
40 |
41 |
42 |
43 |
44 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/tutorial_slide3.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
14 |
15 |
22 |
23 |
28 |
29 |
40 |
41 |
42 |
43 |
--------------------------------------------------------------------------------
/app/src/main/res/menu/main.xml:
--------------------------------------------------------------------------------
1 |
2 |
10 |
--------------------------------------------------------------------------------
/app/src/main/res/menu/main_drawer.xml:
--------------------------------------------------------------------------------
1 |
2 |
33 |
--------------------------------------------------------------------------------
/app/src/main/res/menu/menu_statistics.xml:
--------------------------------------------------------------------------------
1 |
11 |
--------------------------------------------------------------------------------
/app/src/main/res/menu/overview_actionbar.xml:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-hdpi/ic__black_left_arrow_timmed.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/SecUSo/privacy-friendly-food-tracker/247d9a525cd2ad293edaa6fe4b610ce36979a61a/app/src/main/res/mipmap-hdpi/ic__black_left_arrow_timmed.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-hdpi/ic__black_right_arrow_timmed.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/SecUSo/privacy-friendly-food-tracker/247d9a525cd2ad293edaa6fe4b610ce36979a61a/app/src/main/res/mipmap-hdpi/ic__black_right_arrow_timmed.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-hdpi/ic__cancel.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/SecUSo/privacy-friendly-food-tracker/247d9a525cd2ad293edaa6fe4b610ce36979a61a/app/src/main/res/mipmap-hdpi/ic__cancel.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-hdpi/ic__chart.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/SecUSo/privacy-friendly-food-tracker/247d9a525cd2ad293edaa6fe4b610ce36979a61a/app/src/main/res/mipmap-hdpi/ic__chart.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-hdpi/ic__check.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/SecUSo/privacy-friendly-food-tracker/247d9a525cd2ad293edaa6fe4b610ce36979a61a/app/src/main/res/mipmap-hdpi/ic__check.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-hdpi/ic__date.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/SecUSo/privacy-friendly-food-tracker/247d9a525cd2ad293edaa6fe4b610ce36979a61a/app/src/main/res/mipmap-hdpi/ic__date.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-hdpi/ic__delete.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/SecUSo/privacy-friendly-food-tracker/247d9a525cd2ad293edaa6fe4b610ce36979a61a/app/src/main/res/mipmap-hdpi/ic__delete.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-hdpi/ic__edit.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/SecUSo/privacy-friendly-food-tracker/247d9a525cd2ad293edaa6fe4b610ce36979a61a/app/src/main/res/mipmap-hdpi/ic__edit.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-hdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/SecUSo/privacy-friendly-food-tracker/247d9a525cd2ad293edaa6fe4b610ce36979a61a/app/src/main/res/mipmap-hdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-hdpi/ic_launcher_adaptive_back.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/SecUSo/privacy-friendly-food-tracker/247d9a525cd2ad293edaa6fe4b610ce36979a61a/app/src/main/res/mipmap-hdpi/ic_launcher_adaptive_back.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-hdpi/ic_launcher_adaptive_fore.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/SecUSo/privacy-friendly-food-tracker/247d9a525cd2ad293edaa6fe4b610ce36979a61a/app/src/main/res/mipmap-hdpi/ic_launcher_adaptive_fore.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-hdpi/ic_navbar.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/SecUSo/privacy-friendly-food-tracker/247d9a525cd2ad293edaa6fe4b610ce36979a61a/app/src/main/res/mipmap-hdpi/ic_navbar.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-hdpi/ic_splash.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/SecUSo/privacy-friendly-food-tracker/247d9a525cd2ad293edaa6fe4b610ce36979a61a/app/src/main/res/mipmap-hdpi/ic_splash.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-mdpi/ic__black_left_arrow_timmed.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/SecUSo/privacy-friendly-food-tracker/247d9a525cd2ad293edaa6fe4b610ce36979a61a/app/src/main/res/mipmap-mdpi/ic__black_left_arrow_timmed.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-mdpi/ic__black_right_arrow_timmed.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/SecUSo/privacy-friendly-food-tracker/247d9a525cd2ad293edaa6fe4b610ce36979a61a/app/src/main/res/mipmap-mdpi/ic__black_right_arrow_timmed.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-mdpi/ic__cancel.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/SecUSo/privacy-friendly-food-tracker/247d9a525cd2ad293edaa6fe4b610ce36979a61a/app/src/main/res/mipmap-mdpi/ic__cancel.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-mdpi/ic__chart.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/SecUSo/privacy-friendly-food-tracker/247d9a525cd2ad293edaa6fe4b610ce36979a61a/app/src/main/res/mipmap-mdpi/ic__chart.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-mdpi/ic__check.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/SecUSo/privacy-friendly-food-tracker/247d9a525cd2ad293edaa6fe4b610ce36979a61a/app/src/main/res/mipmap-mdpi/ic__check.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-mdpi/ic__date.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/SecUSo/privacy-friendly-food-tracker/247d9a525cd2ad293edaa6fe4b610ce36979a61a/app/src/main/res/mipmap-mdpi/ic__date.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-mdpi/ic__delete.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/SecUSo/privacy-friendly-food-tracker/247d9a525cd2ad293edaa6fe4b610ce36979a61a/app/src/main/res/mipmap-mdpi/ic__delete.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-mdpi/ic__edit.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/SecUSo/privacy-friendly-food-tracker/247d9a525cd2ad293edaa6fe4b610ce36979a61a/app/src/main/res/mipmap-mdpi/ic__edit.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-mdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/SecUSo/privacy-friendly-food-tracker/247d9a525cd2ad293edaa6fe4b610ce36979a61a/app/src/main/res/mipmap-mdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-mdpi/ic_launcher_adaptive_back.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/SecUSo/privacy-friendly-food-tracker/247d9a525cd2ad293edaa6fe4b610ce36979a61a/app/src/main/res/mipmap-mdpi/ic_launcher_adaptive_back.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-mdpi/ic_launcher_adaptive_fore.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/SecUSo/privacy-friendly-food-tracker/247d9a525cd2ad293edaa6fe4b610ce36979a61a/app/src/main/res/mipmap-mdpi/ic_launcher_adaptive_fore.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-mdpi/ic_navbar.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/SecUSo/privacy-friendly-food-tracker/247d9a525cd2ad293edaa6fe4b610ce36979a61a/app/src/main/res/mipmap-mdpi/ic_navbar.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-mdpi/ic_splash.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/SecUSo/privacy-friendly-food-tracker/247d9a525cd2ad293edaa6fe4b610ce36979a61a/app/src/main/res/mipmap-mdpi/ic_splash.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/ic__black_left_arrow_timmed.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/SecUSo/privacy-friendly-food-tracker/247d9a525cd2ad293edaa6fe4b610ce36979a61a/app/src/main/res/mipmap-xhdpi/ic__black_left_arrow_timmed.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/ic__black_right_arrow_timmed.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/SecUSo/privacy-friendly-food-tracker/247d9a525cd2ad293edaa6fe4b610ce36979a61a/app/src/main/res/mipmap-xhdpi/ic__black_right_arrow_timmed.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/ic__cancel.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/SecUSo/privacy-friendly-food-tracker/247d9a525cd2ad293edaa6fe4b610ce36979a61a/app/src/main/res/mipmap-xhdpi/ic__cancel.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/ic__chart.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/SecUSo/privacy-friendly-food-tracker/247d9a525cd2ad293edaa6fe4b610ce36979a61a/app/src/main/res/mipmap-xhdpi/ic__chart.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/ic__check.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/SecUSo/privacy-friendly-food-tracker/247d9a525cd2ad293edaa6fe4b610ce36979a61a/app/src/main/res/mipmap-xhdpi/ic__check.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/ic__date.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/SecUSo/privacy-friendly-food-tracker/247d9a525cd2ad293edaa6fe4b610ce36979a61a/app/src/main/res/mipmap-xhdpi/ic__date.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/ic__delete.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/SecUSo/privacy-friendly-food-tracker/247d9a525cd2ad293edaa6fe4b610ce36979a61a/app/src/main/res/mipmap-xhdpi/ic__delete.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/ic__edit.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/SecUSo/privacy-friendly-food-tracker/247d9a525cd2ad293edaa6fe4b610ce36979a61a/app/src/main/res/mipmap-xhdpi/ic__edit.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/SecUSo/privacy-friendly-food-tracker/247d9a525cd2ad293edaa6fe4b610ce36979a61a/app/src/main/res/mipmap-xhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/ic_launcher_adaptive_back.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/SecUSo/privacy-friendly-food-tracker/247d9a525cd2ad293edaa6fe4b610ce36979a61a/app/src/main/res/mipmap-xhdpi/ic_launcher_adaptive_back.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/ic_launcher_adaptive_fore.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/SecUSo/privacy-friendly-food-tracker/247d9a525cd2ad293edaa6fe4b610ce36979a61a/app/src/main/res/mipmap-xhdpi/ic_launcher_adaptive_fore.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/ic_navbar.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/SecUSo/privacy-friendly-food-tracker/247d9a525cd2ad293edaa6fe4b610ce36979a61a/app/src/main/res/mipmap-xhdpi/ic_navbar.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/ic_splash.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/SecUSo/privacy-friendly-food-tracker/247d9a525cd2ad293edaa6fe4b610ce36979a61a/app/src/main/res/mipmap-xhdpi/ic_splash.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxhdpi/ic__black_left_arrow_timmed.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/SecUSo/privacy-friendly-food-tracker/247d9a525cd2ad293edaa6fe4b610ce36979a61a/app/src/main/res/mipmap-xxhdpi/ic__black_left_arrow_timmed.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxhdpi/ic__black_right_arrow_timmed.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/SecUSo/privacy-friendly-food-tracker/247d9a525cd2ad293edaa6fe4b610ce36979a61a/app/src/main/res/mipmap-xxhdpi/ic__black_right_arrow_timmed.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxhdpi/ic__cancel.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/SecUSo/privacy-friendly-food-tracker/247d9a525cd2ad293edaa6fe4b610ce36979a61a/app/src/main/res/mipmap-xxhdpi/ic__cancel.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxhdpi/ic__chart.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/SecUSo/privacy-friendly-food-tracker/247d9a525cd2ad293edaa6fe4b610ce36979a61a/app/src/main/res/mipmap-xxhdpi/ic__chart.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxhdpi/ic__check.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/SecUSo/privacy-friendly-food-tracker/247d9a525cd2ad293edaa6fe4b610ce36979a61a/app/src/main/res/mipmap-xxhdpi/ic__check.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxhdpi/ic__date.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/SecUSo/privacy-friendly-food-tracker/247d9a525cd2ad293edaa6fe4b610ce36979a61a/app/src/main/res/mipmap-xxhdpi/ic__date.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxhdpi/ic__delete.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/SecUSo/privacy-friendly-food-tracker/247d9a525cd2ad293edaa6fe4b610ce36979a61a/app/src/main/res/mipmap-xxhdpi/ic__delete.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxhdpi/ic__edit.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/SecUSo/privacy-friendly-food-tracker/247d9a525cd2ad293edaa6fe4b610ce36979a61a/app/src/main/res/mipmap-xxhdpi/ic__edit.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/SecUSo/privacy-friendly-food-tracker/247d9a525cd2ad293edaa6fe4b610ce36979a61a/app/src/main/res/mipmap-xxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxhdpi/ic_launcher_adaptive_back.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/SecUSo/privacy-friendly-food-tracker/247d9a525cd2ad293edaa6fe4b610ce36979a61a/app/src/main/res/mipmap-xxhdpi/ic_launcher_adaptive_back.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxhdpi/ic_launcher_adaptive_fore.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/SecUSo/privacy-friendly-food-tracker/247d9a525cd2ad293edaa6fe4b610ce36979a61a/app/src/main/res/mipmap-xxhdpi/ic_launcher_adaptive_fore.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxhdpi/ic_navbar.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/SecUSo/privacy-friendly-food-tracker/247d9a525cd2ad293edaa6fe4b610ce36979a61a/app/src/main/res/mipmap-xxhdpi/ic_navbar.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxhdpi/ic_splash.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/SecUSo/privacy-friendly-food-tracker/247d9a525cd2ad293edaa6fe4b610ce36979a61a/app/src/main/res/mipmap-xxhdpi/ic_splash.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxxhdpi/ic__black_left_arrow_timmed.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/SecUSo/privacy-friendly-food-tracker/247d9a525cd2ad293edaa6fe4b610ce36979a61a/app/src/main/res/mipmap-xxxhdpi/ic__black_left_arrow_timmed.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxxhdpi/ic__black_right_arrow_timmed.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/SecUSo/privacy-friendly-food-tracker/247d9a525cd2ad293edaa6fe4b610ce36979a61a/app/src/main/res/mipmap-xxxhdpi/ic__black_right_arrow_timmed.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxxhdpi/ic__cancel.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/SecUSo/privacy-friendly-food-tracker/247d9a525cd2ad293edaa6fe4b610ce36979a61a/app/src/main/res/mipmap-xxxhdpi/ic__cancel.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxxhdpi/ic__chart.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/SecUSo/privacy-friendly-food-tracker/247d9a525cd2ad293edaa6fe4b610ce36979a61a/app/src/main/res/mipmap-xxxhdpi/ic__chart.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxxhdpi/ic__check.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/SecUSo/privacy-friendly-food-tracker/247d9a525cd2ad293edaa6fe4b610ce36979a61a/app/src/main/res/mipmap-xxxhdpi/ic__check.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxxhdpi/ic__date.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/SecUSo/privacy-friendly-food-tracker/247d9a525cd2ad293edaa6fe4b610ce36979a61a/app/src/main/res/mipmap-xxxhdpi/ic__date.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxxhdpi/ic__delete.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/SecUSo/privacy-friendly-food-tracker/247d9a525cd2ad293edaa6fe4b610ce36979a61a/app/src/main/res/mipmap-xxxhdpi/ic__delete.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxxhdpi/ic__edit.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/SecUSo/privacy-friendly-food-tracker/247d9a525cd2ad293edaa6fe4b610ce36979a61a/app/src/main/res/mipmap-xxxhdpi/ic__edit.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/SecUSo/privacy-friendly-food-tracker/247d9a525cd2ad293edaa6fe4b610ce36979a61a/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxxhdpi/ic_launcher_adaptive_back.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/SecUSo/privacy-friendly-food-tracker/247d9a525cd2ad293edaa6fe4b610ce36979a61a/app/src/main/res/mipmap-xxxhdpi/ic_launcher_adaptive_back.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxxhdpi/ic_launcher_adaptive_fore.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/SecUSo/privacy-friendly-food-tracker/247d9a525cd2ad293edaa6fe4b610ce36979a61a/app/src/main/res/mipmap-xxxhdpi/ic_launcher_adaptive_fore.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxxhdpi/ic_navbar.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/SecUSo/privacy-friendly-food-tracker/247d9a525cd2ad293edaa6fe4b610ce36979a61a/app/src/main/res/mipmap-xxxhdpi/ic_navbar.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxxhdpi/ic_splash.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/SecUSo/privacy-friendly-food-tracker/247d9a525cd2ad293edaa6fe4b610ce36979a61a/app/src/main/res/mipmap-xxxhdpi/ic_splash.png
--------------------------------------------------------------------------------
/app/src/main/res/values-v21/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
9 |
10 |
--------------------------------------------------------------------------------
/app/src/main/res/values-w820dp/dimens.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 | 64dp
6 |
7 |
--------------------------------------------------------------------------------
/app/src/main/res/values/attrs.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/app/src/main/res/values/colors.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | #024265
4 | #024265
5 | #0274B2
6 | #00000000
7 | #ffffff
8 | #000000
9 | #0274B2
10 | #8aa5ce
11 | #024265
12 | #A8A8A8
13 | #f6d126
14 | #B71C1C
15 | #388E3C
16 |
17 |
18 | #026499
19 |
20 |
21 | #448bb2
22 |
23 |
24 | - @color/dot_light_screen
25 | - @color/dot_light_screen
26 | - @color/dot_light_screen
27 |
28 |
29 |
30 | - @color/dot_dark_screen
31 | - @color/dot_dark_screen
32 | - @color/dot_dark_screen
33 |
34 |
35 | #3680BB
36 |
37 |
--------------------------------------------------------------------------------
/app/src/main/res/values/dimens.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | 16dp
4 | 160dp
5 |
6 | 16dp
7 | 16dp
8 | 16dp
9 |
10 | 30dp
11 | 20dp
12 | 120dp
13 | 30dp
14 | 16dp
15 | 20dp
16 | 40dp
17 | 8dp
18 |
19 |
20 |
--------------------------------------------------------------------------------
/app/src/main/res/values/drawables.xml:
--------------------------------------------------------------------------------
1 |
2 | - @android:drawable/ic_menu_camera
3 | - @android:drawable/ic_menu_gallery
4 | - @android:drawable/ic_menu_slideshow
5 | - @android:drawable/ic_menu_manage
6 | - @android:drawable/ic_menu_share
7 |
8 |
--------------------------------------------------------------------------------
/app/src/main/res/values/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
11 |
12 |
16 |
17 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
--------------------------------------------------------------------------------
/app/src/main/res/xml/pref_general.xml:
--------------------------------------------------------------------------------
1 |
3 |
4 |
6 |
12 |
14 |
15 |
16 |
17 |
18 |
38 |
39 |
40 |
--------------------------------------------------------------------------------
/app/src/main/res/xml/pref_headers.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/app/src/test/java/org/secuso/privacyfriendlyfoodtracker/ApiManagerTest.java:
--------------------------------------------------------------------------------
1 | package org.secuso.privacyfriendlyfoodtracker;
2 |
3 | import org.junit.Before;
4 | import org.junit.Test;
5 | import org.secuso.privacyfriendlyfoodtracker.network.ApiManager;
6 | import org.secuso.privacyfriendlyfoodtracker.network.ProductApiService;
7 | import org.secuso.privacyfriendlyfoodtracker.network.models.NetworkProduct;
8 | import org.secuso.privacyfriendlyfoodtracker.network.models.ProductResponse;
9 | import org.secuso.privacyfriendlyfoodtracker.network.utils.ProductConversionHelper;
10 |
11 | import java.util.ArrayList;
12 | import java.util.List;
13 | import java.util.concurrent.CountDownLatch;
14 |
15 | import retrofit2.Call;
16 | import retrofit2.Callback;
17 | import retrofit2.Response;
18 |
19 | import static org.junit.Assert.assertTrue;
20 |
21 |
22 | public class ApiManagerTest {
23 | ProductApiService mProductApiService = null ;
24 | ProductResponse productResponse = new ProductResponse();
25 | List products = new ArrayList<>();
26 |
27 | @Before
28 | public void createManager() {
29 | this.mProductApiService = ApiManager.getInstance().getProductApiService("de");
30 |
31 | }
32 |
33 | @Test
34 | public void readProductInformation() throws Exception {
35 | final CountDownLatch signal = new CountDownLatch(1);
36 | Call call = mProductApiService.listProducts("banane");
37 | call.enqueue(new Callback() {
38 | @Override
39 | public void onResponse(Call call, Response response) {
40 | if (response.isSuccessful()) {
41 | productResponse = response.body();
42 | }
43 | else{
44 | //show error
45 | }
46 | signal.countDown();
47 |
48 | }
49 |
50 | @Override
51 | public void onFailure(Call call, Throwable t) {
52 | signal.countDown();
53 |
54 | }
55 | });
56 | signal.await();// wait for callback
57 | // uses the current location. To pass the test, the location must be "de"
58 | assertTrue("Responds should contains 20 product informations ", productResponse.getProducts().size() == 20 );
59 | }
60 |
61 | @Test
62 | public void readProductInformationConverter() throws Exception {
63 | final CountDownLatch signal = new CountDownLatch(1);
64 | Call call = mProductApiService.listProducts("banane");
65 |
66 | call.enqueue(new Callback() {
67 | @Override
68 | public void onResponse(Call call, Response response) {
69 | if (response.isSuccessful()) {
70 | // Conversion to db product
71 | productResponse = response.body();
72 | for(int i = 0; i < productResponse.getProducts().size();i++){
73 | NetworkProduct product = productResponse.getProducts().get(i);
74 | if(product != null){
75 | products.add(ProductConversionHelper.conversionProduct(product));
76 | }
77 | }
78 | }
79 | else{
80 | //show error
81 | }
82 | signal.countDown();
83 |
84 | }
85 |
86 | @Override
87 | public void onFailure(Call call, Throwable t) {
88 | signal.countDown();
89 |
90 | }
91 | });
92 | signal.await();// wait for callback
93 | // uses the current location. To pass the test, the location must be "de"
94 | assertTrue("Responds should contains 20 product informations ", products.get(0).energy != 0 );
95 | }
96 | }
97 |
--------------------------------------------------------------------------------
/build.gradle:
--------------------------------------------------------------------------------
1 | // Top-level build file where you can add configuration options common to all sub-projects/modules.
2 |
3 | buildscript {
4 | ext.kotlin_version = '2.0.21'
5 |
6 | repositories {
7 | mavenCentral()
8 | google()
9 | }
10 | dependencies {
11 | classpath 'com.android.tools.build:gradle:8.3.2'
12 | classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
13 |
14 | // NOTE: Do not place your application dependencies here; they belong
15 | // in the individual module build.gradle files
16 | }
17 | }
18 |
19 | allprojects {
20 | repositories {
21 | mavenCentral()
22 | google()
23 | maven {
24 | url "https://s3.amazonaws.com/repo.commonsware.com"
25 | }
26 | }
27 | }
28 |
29 | task clean(type: Delete) {
30 | delete rootProject.buildDir
31 | }
--------------------------------------------------------------------------------
/fastlane/metadata/android/de/full_description.txt:
--------------------------------------------------------------------------------
1 | Dieser Ernährungstracker hilft, die tägliche Kalorienaufnahme zu ermitteln.
2 | Zu diesem Zweck kann der Nutzer alle konsumierten Lebensmittel mitsamt Gewicht
3 | eintragen, die App berechnet dann die Gesamtkalorienzahl und erlaubt eine
4 | Analyse des Kalorienkonsums über größere Zeiträume. Die App gehört zur
5 | Gruppe der Privacy Friendly Apps, die von der Forschungsgruppe SECUSO am
6 | Karlsruher Institut für Technologie entwickelt wird. Mehr Informationen können
7 | unter https://secuso.org/pfa gefunden werden.
8 |
9 | Was macht diese App anders als andere Ernährungstracker?
10 | - Es werden absolut keine Daten über den Nutzer gesammelt und/oder verarbeitet.
11 | - Die Datenbank mit Einträgen wird verschlüsselt, um absolute Privatsphäre zu garantieren.
12 | - Die App braucht keine sensiblen Berechtigungen. Nur der Internetzugriff wird für die
13 | Suchfunktion benötigt.
14 | - Zudem wird komplett auf Tracker und Werbung jeglicher Art verzichtet.
15 |
16 | Welche Funktionen hat die App?
17 | - Personalisierung durch Erstellen eigener Produkte
18 | - Berechnung der Gesamtkalorienzahl für einen Tag
19 | - Erstellen von Statistiken, die den Gesamt- sowie Durchschnittskonsum an
20 | Kalorien uber eine Woche bzw. einen Monat anzeigen
21 | - Kalenderübersicht zum schnellen Auswählen einzelner Tage
22 | - Verschlüsselung der Daten auf dem Gerät, so dass nur der Benutzer Zugriff
23 | auf die Daten hat
24 | - Onlinesuche, um Produkte schnell und einfach zu finden
25 |
26 | Bitte beachten: Die Onlinesuche stellt Anfragen an die Datenbank OpenFood-
27 | Facts. Dies erlaubt es der Datenbank theoretisch, die Ernährungsgewohnheiten über die Suchanfragen zu verfolgen. Für absolute Privatsphäre ist es also empfehlenswert,
28 | auf die Onlinesuche zu verzichten (Es wird erst online gesucht, wenn
29 | der "Suchen"-Knopf gedrückt wird). Die App funktioniert auch problemlos ohne
30 | Internetzugriff.
31 |
32 | Kontaktieren Sie uns gerne über:
33 | Bluesky - @secusoresearch.bsky.social https://bsky.app/profile/secusoresearch.bsky.social
34 | Mastodon - @SECUSO_Research@bawü.social https://xn--baw-joa.social/@SECUSO_Research/
35 | Offene Stellen - https://secuso.aifb.kit.edu/83.php
--------------------------------------------------------------------------------
/fastlane/metadata/android/de/images/phoneScreenshots/1.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/SecUSo/privacy-friendly-food-tracker/247d9a525cd2ad293edaa6fe4b610ce36979a61a/fastlane/metadata/android/de/images/phoneScreenshots/1.jpg
--------------------------------------------------------------------------------
/fastlane/metadata/android/de/images/phoneScreenshots/2.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/SecUSo/privacy-friendly-food-tracker/247d9a525cd2ad293edaa6fe4b610ce36979a61a/fastlane/metadata/android/de/images/phoneScreenshots/2.jpg
--------------------------------------------------------------------------------
/fastlane/metadata/android/de/short_description.txt:
--------------------------------------------------------------------------------
1 | (SECUSO) Der Ernährungstracker hilft, die Kalorienaufnahme zu verfolgen
2 |
--------------------------------------------------------------------------------
/fastlane/metadata/android/de/title.txt:
--------------------------------------------------------------------------------
1 | Ernährungstracker (PFA)
--------------------------------------------------------------------------------
/fastlane/metadata/android/en-US/full_description.txt:
--------------------------------------------------------------------------------
1 | Privacy Friendly Food Tracker allows tracking your daily calorie consumption.
2 | To do this, you can enter all your consumed food and drink as well as its weight.
3 | The app will then calculate the total daily calorie consumption. The app also allows
4 | an analysis of calorie consumption over a larger timeframe such as weeks
5 | or months.
6 |
7 | What functionality does this app include?
8 | - Personalization through the creation of your own products
9 | - Calculation of the total calorie count for the day
10 | - Creation of statistics and graphs that show total and average calorie intake over a week or a month
11 | - Calendar overview to quickly show daily overviews
12 | - Encryption of data on the device
13 | - Online search to find products quickly and easily
14 |
15 | This app belongs to the group of Privacy Friendly Apps developed
16 | by the research group SECUSO at Karlsruhe Institute of Technology. You can find more information at https://secuso.org/pfa.
17 |
18 | This food tracker does not collect any information about its users. The database
19 | is encrypted to guarantee absolute privacy. Also this app does not require any dangerous permissions from the user. Only internet access is needed for
20 | the search function. Additionally, this food tracker does not include any
21 | tracking or any advertisements at all. This increases battery lifetime and reduces or eliminates data usage by this app.
22 |
23 | Please note that the online search requests information from the OpenFoodFacts
24 | database. This would theoretically allow the database to track a users nutritional
25 | habits. For absolute privacy it is therefore recommended to not use the online
26 | search feature (The request is not triggered until the 'search' button is pressed).
27 | The app also works without an internet connection.
28 |
29 | You can reach us via
30 | Bluesky - @secusoresearch.bsky.social https://bsky.app/profile/secusoresearch.bsky.social
31 | Mastodon - @SECUSO_Research@bawü.social https://xn--baw-joa.social/@SECUSO_Research/
32 | Job opening - https://secuso.aifb.kit.edu/english/Job_Offers.php
--------------------------------------------------------------------------------
/fastlane/metadata/android/en-US/images/icon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/SecUSo/privacy-friendly-food-tracker/247d9a525cd2ad293edaa6fe4b610ce36979a61a/fastlane/metadata/android/en-US/images/icon.png
--------------------------------------------------------------------------------
/fastlane/metadata/android/en-US/images/phoneScreenshots/1.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/SecUSo/privacy-friendly-food-tracker/247d9a525cd2ad293edaa6fe4b610ce36979a61a/fastlane/metadata/android/en-US/images/phoneScreenshots/1.jpg
--------------------------------------------------------------------------------
/fastlane/metadata/android/en-US/images/phoneScreenshots/2.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/SecUSo/privacy-friendly-food-tracker/247d9a525cd2ad293edaa6fe4b610ce36979a61a/fastlane/metadata/android/en-US/images/phoneScreenshots/2.jpg
--------------------------------------------------------------------------------
/fastlane/metadata/android/en-US/short_description.txt:
--------------------------------------------------------------------------------
1 | (SECUSO) Food Tracker allows tracking your daily calorie consumption.
2 |
--------------------------------------------------------------------------------
/fastlane/metadata/android/en-US/title.txt:
--------------------------------------------------------------------------------
1 | Food-Tracker (PFA)
--------------------------------------------------------------------------------
/gradle.properties:
--------------------------------------------------------------------------------
1 | # Project-wide Gradle settings.
2 |
3 | # IDE (e.g. Android Studio) users:
4 | # Gradle settings configured through the IDE *will override*
5 | # any settings specified in this file.
6 |
7 | # For more details on how to configure your build environment visit
8 | # http://www.gradle.org/docs/current/userguide/build_environment.html
9 |
10 | # Specifies the JVM arguments used for the daemon process.
11 | # The setting is particularly useful for tweaking memory settings.
12 | # Default value: -Xmx10248m -XX:MaxPermSize=256m
13 | # org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8
14 |
15 | # When configured, Gradle will run in incubating parallel mode.
16 | # This option should only be used with decoupled projects. More details, visit
17 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
18 | # org.gradle.parallel=true
19 | android.enableJetifier=true
20 | android.useAndroidX=true
21 | android.nonTransitiveRClass=false
22 | android.nonFinalResIds=false
23 | org.gradle.jvmargs=-Xmx2048m
24 |
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/SecUSo/privacy-friendly-food-tracker/247d9a525cd2ad293edaa6fe4b610ce36979a61a/gradle/wrapper/gradle-wrapper.jar
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | distributionBase=GRADLE_USER_HOME
2 | distributionPath=wrapper/dists
3 | distributionUrl=https\://services.gradle.org/distributions/gradle-8.5-bin.zip
4 | networkTimeout=10000
5 | validateDistributionUrl=true
6 | zipStoreBase=GRADLE_USER_HOME
7 | zipStorePath=wrapper/dists
8 |
--------------------------------------------------------------------------------
/gradlew.bat:
--------------------------------------------------------------------------------
1 | @rem
2 | @rem Copyright 2015 the original author or authors.
3 | @rem
4 | @rem Licensed under the Apache License, Version 2.0 (the "License");
5 | @rem you may not use this file except in compliance with the License.
6 | @rem You may obtain a copy of the License at
7 | @rem
8 | @rem https://www.apache.org/licenses/LICENSE-2.0
9 | @rem
10 | @rem Unless required by applicable law or agreed to in writing, software
11 | @rem distributed under the License is distributed on an "AS IS" BASIS,
12 | @rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | @rem See the License for the specific language governing permissions and
14 | @rem limitations under the License.
15 | @rem
16 |
17 | @if "%DEBUG%"=="" @echo off
18 | @rem ##########################################################################
19 | @rem
20 | @rem Gradle startup script for Windows
21 | @rem
22 | @rem ##########################################################################
23 |
24 | @rem Set local scope for the variables with windows NT shell
25 | if "%OS%"=="Windows_NT" setlocal
26 |
27 | set DIRNAME=%~dp0
28 | if "%DIRNAME%"=="" set DIRNAME=.
29 | @rem This is normally unused
30 | set APP_BASE_NAME=%~n0
31 | set APP_HOME=%DIRNAME%
32 |
33 | @rem Resolve any "." and ".." in APP_HOME to make it shorter.
34 | for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi
35 |
36 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
37 | set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m"
38 |
39 | @rem Find java.exe
40 | if defined JAVA_HOME goto findJavaFromJavaHome
41 |
42 | set JAVA_EXE=java.exe
43 | %JAVA_EXE% -version >NUL 2>&1
44 | if %ERRORLEVEL% equ 0 goto execute
45 |
46 | echo.
47 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
48 | echo.
49 | echo Please set the JAVA_HOME variable in your environment to match the
50 | echo location of your Java installation.
51 |
52 | goto fail
53 |
54 | :findJavaFromJavaHome
55 | set JAVA_HOME=%JAVA_HOME:"=%
56 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe
57 |
58 | if exist "%JAVA_EXE%" goto execute
59 |
60 | echo.
61 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
62 | echo.
63 | echo Please set the JAVA_HOME variable in your environment to match the
64 | echo location of your Java installation.
65 |
66 | goto fail
67 |
68 | :execute
69 | @rem Setup the command line
70 |
71 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
72 |
73 |
74 | @rem Execute Gradle
75 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %*
76 |
77 | :end
78 | @rem End local scope for the variables with windows NT shell
79 | if %ERRORLEVEL% equ 0 goto mainEnd
80 |
81 | :fail
82 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
83 | rem the _cmd.exe /c_ return code!
84 | set EXIT_CODE=%ERRORLEVEL%
85 | if %EXIT_CODE% equ 0 set EXIT_CODE=1
86 | if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE%
87 | exit /b %EXIT_CODE%
88 |
89 | :mainEnd
90 | if "%OS%"=="Windows_NT" endlocal
91 |
92 | :omega
93 |
--------------------------------------------------------------------------------
/settings.gradle:
--------------------------------------------------------------------------------
1 | include ':app'
2 | include ':backup-api'
3 | project(':backup-api').projectDir = new File('libs/privacy-friendly-backup-api/BackupAPI')
4 |
--------------------------------------------------------------------------------