Skip to content

Commit

Permalink
Merge pull request #57 from Faltenreich/develop
Browse files Browse the repository at this point in the history
Release 3.13.0
  • Loading branch information
Faltenreich authored Oct 23, 2024
2 parents 6ad8cc2 + 701bfa1 commit bba9e16
Show file tree
Hide file tree
Showing 46 changed files with 1,006 additions and 7,745 deletions.
19 changes: 12 additions & 7 deletions .github/workflows/ci.yml → .github/workflows/verify.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: ci
name: verify

on:
push:
Expand All @@ -7,9 +7,13 @@ on:
pull_request:
workflow_dispatch:

concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true

jobs:
android:
runs-on: macos-latest
runs-on: macos-13
timeout-minutes: 60
strategy:
fail-fast: false
Expand All @@ -20,10 +24,10 @@ jobs:

steps:
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Set up JDK
uses: actions/setup-java@v3
uses: actions/setup-java@v4
with:
distribution: 'zulu'
java-version: '17'
Expand All @@ -33,13 +37,13 @@ jobs:
uses: android-actions/setup-android@v3

- name: Validate Gradle wrapper
uses: gradle/wrapper-validation-action@v1
uses: gradle/wrapper-validation-action@v3

- name: Grant execute permission for Gradle wrapper
run: chmod +x gradlew

- name: Cache Gradle dependencies
uses: actions/cache@v2
uses: actions/cache@v4
with:
path: |
~/.gradle/caches
Expand All @@ -62,8 +66,9 @@ jobs:
script: ./gradlew connectedBetaDebugAndroidTest

- name: Upload test reports
uses: actions/upload-artifact@v2
uses: actions/upload-artifact@v4
with:
name: reports
path: app/build/reports
overwrite: true
if: always()
19 changes: 10 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
# Diaguard

[![version](https://img.shields.io/badge/Release-3.12.2-478063.svg)](https://github.com/Faltenreich/Diaguard/releases)
[![ci](https://github.com/Faltenreich/Diaguard/actions/workflows/ci.yml/badge.svg)](https://github.com/Faltenreich/Diaguard/actions/workflows/ci.yml)
[![version](https://img.shields.io/badge/Release-3.13.0-478063.svg)](https://github.com/Faltenreich/Diaguard/releases)
[![ci](https://github.com/Faltenreich/Diaguard/actions/workflows/verify.yml/badge.svg)](https://github.com/Faltenreich/Diaguard/actions/workflows/verify.yml)

<img src="./resource/image/marketing/showcase.png" width="750">
<img src="./resource/image/marketing/showcase.png" width="750" alt="">

Diaguard is an Android app for people with diabetes mellitus.

Expand All @@ -21,9 +21,9 @@ It replaces the handwritten diary and helps the user to quickly and easily recor
* Estimated HbA1c
* Statistics
* Dark Mode
* Localized in English, German, French, Spanish and Italian
* Localized in English, German, French, Spanish, Italian and Russian

<img src="./fastlane/metadata/android/en-US/images/phoneScreenshots/1.png" width="100"> <img src="./fastlane/metadata/android/en-US/images/phoneScreenshots/2.png" width="100"> <img src="./fastlane/metadata/android/en-US/images/phoneScreenshots/3.png" width="100"> <img src="./fastlane/metadata/android/en-US/images/phoneScreenshots/4.png" width="100"> <img src="./fastlane/metadata/android/en-US/images/phoneScreenshots/5.png" width="100"> <img src="./fastlane/metadata/android/en-US/images/phoneScreenshots/6.png" width="100"> <img src="./fastlane/metadata/android/en-US/images/phoneScreenshots/7.png" width="100">
<img src="./fastlane/metadata/android/en-US/images/phoneScreenshots/1.png" width="100" alt=""> <img src="./fastlane/metadata/android/en-US/images/phoneScreenshots/2.png" width="100" alt=""> <img src="./fastlane/metadata/android/en-US/images/phoneScreenshots/3.png" width="100" alt=""> <img src="./fastlane/metadata/android/en-US/images/phoneScreenshots/4.png" width="100" alt=""> <img src="./fastlane/metadata/android/en-US/images/phoneScreenshots/5.png" width="100" alt=""> <img src="./fastlane/metadata/android/en-US/images/phoneScreenshots/6.png" width="100" alt=""> <img src="./fastlane/metadata/android/en-US/images/phoneScreenshots/7.png" width="100" alt="">

## Distribution

Expand Down Expand Up @@ -58,7 +58,7 @@ For these reasons, Diaguard has been, is and will always be free of cost.
If you want to buy me a beer or support me in general, please use the donate button and be aware of my thanks.

<a href="https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=AM6HG633T4BWY&source=url">
<img src="https://www.paypalobjects.com/en_US/i/btn/btn_donate_LG.gif" width="100"/>
<img src="https://www.paypalobjects.com/en_US/i/btn/btn_donate_LG.gif" width="100" alt=""/>
</a>

## Development
Expand All @@ -78,8 +78,8 @@ English is used as general language for naming things. Everything except the loc
Localization takes place locally and affects following components:

* User interfaces: localized via [Android resources](https://developer.android.com/guide/topics/resources/localization) (one [strings.xml](/app/src/main/res/values/strings.xml) per language)
* Common food: localized via custom file import (one [food_common.csv](/app/src/main/assets/food_common.csv) for all languages)
* Default tags: localized via custom file import (one [tags.csv](/app/src/main/assets/tags.csv) for all languages)
* Common food: localized via custom file import (one [food_common.csv](/app/src/main/assets/seed/food_common.csv) for all languages)
* Default tags: localized via custom file import (one [tags.csv](/app/src/main/assets/seed/tags.csv) for all languages)

Currently the localization process requires certain programming skills. This should and could be improved by using an external service in order to support localizations by non-developers.

Expand All @@ -104,6 +104,7 @@ This software uses following technologies with great appreciation:
* [Apache Commons Text](http://commons.apache.org/proper/commons-text)
* [App Privacy Policy Generator](https://github.com/nisrulz/app-privacy-policy-generator)
* [BetterPickers](https://github.com/code-troopers/android-betterpickers)
* [Droid Sans](https://github.com/google/fonts)
* [EventBus](https://github.com/greenrobot/EventBus)
* [FloatingActionButton](https://github.com/Clans/FloatingActionButton)
* [Gson](https://github.com/google/gson)
Expand Down Expand Up @@ -150,4 +151,4 @@ Additionally to the permissions, conditions and limitations of the GPLv3, the pe
You should have received a copy of the GNU General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.

<img src="./resource/image/logo/logo_legacy.png" width="100">
<img src="./resource/image/logo/logo_legacy.png" width="100" alt="">
8 changes: 4 additions & 4 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@ apply plugin: 'com.android.application'
apply plugin: 'com.mikepenz.aboutlibraries.plugin'

android {
compileSdk 34
compileSdk 35
namespace 'com.faltenreich.diaguard'

defaultConfig {
minSdk 21
targetSdk 34
versionCode 61
versionName "3.12.2"
targetSdk 35
versionCode 62
versionName "3.13.0"
vectorDrawables.useSupportLibrary true
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
testInstrumentationRunnerArguments clearPackageData: 'true'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import com.faltenreich.diaguard.test.junit.rule.TestRuleFactory;

import org.joda.time.LocalDate;
import org.junit.Ignore;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.TestRule;
Expand All @@ -24,6 +25,7 @@ public class EntryEditDatePickerTest {
public final TestRule rule = TestRuleFactory.forFragment(EntryEditFragment.class);

@Test
@Ignore("Fails on Android 29 but succeeds on Android 21")
public void pickingDate_shouldApplyToForm() {
Espresso.onView(ViewMatchers.withId(R.id.date_button))
.perform(ViewActions.click());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import com.faltenreich.diaguard.test.junit.rule.TestRuleFactory;

import org.joda.time.LocalDate;
import org.junit.Ignore;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.TestRule;
Expand All @@ -33,6 +34,7 @@ public void onClickingDateButton_shouldOpenDateRangePicker() {
}

@Test
@Ignore("Fails on Android 29 but succeeds on Android 21")
public void pickingDateRange_shouldApplyToForm() {
Espresso.onView(ViewMatchers.withId(R.id.date_range_button))
.perform(NestedScroll.nestedScrollTo(), ViewActions.click());
Expand Down
Binary file added app/src/main/assets/font/DroidSans-Bold.ttf
Binary file not shown.
Binary file not shown.
Binary file added app/src/main/assets/font/DroidSans.ttf
Binary file not shown.
Binary file added app/src/main/assets/font/DroidSans.ttf.stream
Binary file not shown.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
de;fr;it;en;carbohydrates, available;energy;fat;fatty saturated;fiber;proteins;salt;sodium;sugars
de;fr;it;en;carbohydrates;energy;fat;fat_saturated;fiber;proteins;salt;sodium;sugars
Agar;Agar;Agar;Agar;0;160;0;;74,1;2,4;;130;
Agavensirup;Sirop d'agave;Sciroppo di agave;Agave syrup;73;295;0;;0;0,2;;;
Älplermagronen, zubereitet;Macaronis de l'alpage, préparés;Maccheroni dell'alpigiano, preparati;Macaroni from the alps, prepared;19;185;9;5,3;1,7;6,1;6,7;440;1,4
Expand Down
9 changes: 9 additions & 0 deletions app/src/main/assets/seed/tags.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
en;de;fr;es;it;ru
just woke up;gerade aufgewacht;juste réveillé;recién desperté;appena alzato;только что проснулся
falling asleep;einschlafen;s'endormir;quedarse dormido;addormentato;засыпать
happy;glücklich;content;contento;contento;счастливый
excited;aufgeregt;excité;excitado;eccitato;возбужденный
tired;müde;fatigué;cansado;stanco;усталый
sick;krank;malade;enfermo;malato;Илл
before the sport;vor dem Sport;avant le sport;antes del deporte;prima dello sport;до спорта
after the sport;nach dem Sport;après le sport;después del deporte;dopo lo sport;после занятий спортом
9 changes: 0 additions & 9 deletions app/src/main/assets/tags.csv

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
package com.faltenreich.diaguard.feature.export.job.pdf.meta;

import android.content.Context;
import android.content.res.AssetManager;

import androidx.core.content.ContextCompat;

import com.faltenreich.diaguard.R;
import com.faltenreich.diaguard.feature.export.job.pdf.print.Pdf;
import com.faltenreich.diaguard.feature.export.job.pdf.print.PdfPage;
import com.pdfjet.CoreFont;
import com.pdfjet.Font;

import org.joda.time.DateTime;
Expand All @@ -34,10 +34,13 @@ public PdfExportCache(PdfExportConfig config, File file) throws Exception {
this.config = config;
this.pdf = new Pdf(file, config);
this.dateTime = config.getDateStart();
this.fontNormal = new Font(pdf, CoreFont.HELVETICA);
this.fontBold = new Font(pdf, CoreFont.HELVETICA_BOLD);
this.fontHeader = new Font(pdf, CoreFont.HELVETICA_BOLD);

AssetManager assets = config.getContext().getAssets();
this.fontNormal = new Font(pdf, assets.open("font/DroidSans.ttf.stream"), Font.STREAM);
this.fontBold = new Font(pdf, assets.open("font/DroidSans-Bold.ttf.stream"), Font.STREAM);
this.fontHeader = new Font(pdf, assets.open("font/DroidSans-Bold.ttf.stream"), Font.STREAM);
this.fontHeader.setSize(FONT_SIZE_HEADER);

this.colorDivider = ContextCompat.getColor(getContext(), R.color.background_light_primary);
this.colorHyperglycemia = ContextCompat.getColor(getContext(), R.color.red);
this.colorHypoglycemia = ContextCompat.getColor(getContext(), R.color.blue);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

import android.content.Context;
import android.content.SharedPreferences;
import android.content.res.Resources;
import android.text.TextUtils;
import android.util.Log;
import android.widget.TextView;
Expand Down Expand Up @@ -168,11 +167,7 @@ public boolean showLinesInTimeline() {
}

public int[] getExtrema(Category category) {
int resourceIdExtrema = getContext().getResources().getIdentifier(category.name().toLowerCase() + "_extrema", "array", getContext().getPackageName());
if (resourceIdExtrema == 0) {
throw new Resources.NotFoundException("Resource \"category_extrema\" not found: IntArray with event value extrema");
}
return getContext().getResources().getIntArray(resourceIdExtrema);
return getContext().getResources().getIntArray(category.getExtremaArrayResourceId());
}

@SuppressWarnings("BooleanMethodIsAlwaysInverted")
Expand Down Expand Up @@ -296,7 +291,7 @@ public Category[] getExportCategories() {

public void addInputQuery(String query) {
String inputQueries = getInputQueriesString();
if (inputQueries.length() > 0) {
if (!inputQueries.isEmpty()) {
inputQueries = inputQueries + INPUT_QUERIES_SEPARATOR;
}
inputQueries = inputQueries + query;
Expand Down Expand Up @@ -353,16 +348,40 @@ public float getLimitHypoglycemia() {

public int getMonthResourceId(DateTime daytime) {
int monthOfYear = daytime.monthOfYear().get();
String identifier = String.format(Locale.getDefault(), "bg_month_%d", monthOfYear - 1);
return getContext().getResources().getIdentifier(identifier,
"drawable", getContext().getPackageName());
switch (monthOfYear - 1) {
case 0: return R.drawable.bg_month_0;
case 1: return R.drawable.bg_month_1;
case 2: return R.drawable.bg_month_2;
case 3: return R.drawable.bg_month_3;
case 4: return R.drawable.bg_month_4;
case 5: return R.drawable.bg_month_5;
case 6: return R.drawable.bg_month_6;
case 7: return R.drawable.bg_month_7;
case 8: return R.drawable.bg_month_8;
case 9: return R.drawable.bg_month_9;
case 10: return R.drawable.bg_month_10;
case 11: return R.drawable.bg_month_11;
default: return 0;
}
}

public int getMonthSmallResourceId(DateTime daytime) {
int monthOfYear = daytime.monthOfYear().get();
String identifier = String.format(Locale.getDefault(), "bg_month_%d_small", monthOfYear - 1);
return getContext().getResources().getIdentifier(identifier,
"drawable", getContext().getPackageName());
switch (monthOfYear - 1) {
case 0: return R.drawable.bg_month_0_small;
case 1: return R.drawable.bg_month_1_small;
case 2: return R.drawable.bg_month_2_small;
case 3: return R.drawable.bg_month_3_small;
case 4: return R.drawable.bg_month_4_small;
case 5: return R.drawable.bg_month_5_small;
case 6: return R.drawable.bg_month_6_small;
case 7: return R.drawable.bg_month_7_small;
case 8: return R.drawable.bg_month_8_small;
case 9: return R.drawable.bg_month_9_small;
case 10: return R.drawable.bg_month_10_small;
case 11: return R.drawable.bg_month_11_small;
default: return 0;
}
}

public boolean isCategoryActive(Category category) {
Expand Down Expand Up @@ -431,10 +450,7 @@ public void setCategoryPinned(Category category, boolean isPinned) {
// UNITS

private String[] getUnitsNames(Category category) {
String categoryName = category.name().toLowerCase();
int resourceIdUnits = getContext().getResources().getIdentifier(categoryName +
"_units", "array", getContext().getPackageName());
return getContext().getResources().getStringArray(resourceIdUnits);
return getContext().getResources().getStringArray(category.getUnitNameArrayResourceId());
}

public String getUnitName(Category category) {
Expand All @@ -444,13 +460,12 @@ public String getUnitName(Category category) {
}

private String[] getUnitsAcronyms(Category category) {
String categoryName = category.name().toLowerCase();
int resourceIdUnits = getContext().getResources().getIdentifier(categoryName +
"_units_acronyms", "array", getContext().getPackageName());
if (resourceIdUnits == 0)
int resourceId = category.getUnitNameAcronymArrayResourceId();
if (resourceId == 0) {
return null;
else
return getContext().getResources().getStringArray(resourceIdUnits);
} else {
return getContext().getResources().getStringArray(resourceId);
}
}

public String getUnitAcronym(Category category) {
Expand All @@ -470,18 +485,15 @@ public String getUnitAcronym(Category category) {
}

public String getLabelForMealPer100g(Context context) {
return String.format("%s %s 100 g", getUnitAcronym(Category.MEAL), context.getString(R.string.per));
}

private String[] getUnitsValues(String unitName) {
int resourceIdUnits = getContext().getResources().getIdentifier(unitName +
"_units_values", "array", getContext().getPackageName());
return getContext().getResources().getStringArray(resourceIdUnits);
return String.format("%s %s 100 %s",
getUnitAcronym(Category.MEAL),
context.getString(R.string.per),
context.getString(R.string.grams_acronym)
);
}

private String[] getUnitsValues(Category category) {
String categoryName = category.name().toLowerCase();
return getUnitsValues(categoryName);
return getContext().getResources().getStringArray(category.getUnitValueArrayResourceId());
}

private float getUnitValue(Category category) {
Expand Down
Loading

0 comments on commit bba9e16

Please sign in to comment.