diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 83b960ed..b61c6a20 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -6,7 +6,7 @@ name: CI on: # Triggers the workflow on push or pull request events but only for the master branch push: - branches: [ master ] + branches: [master] # Allows you to run this workflow manually from the Actions tab workflow_dispatch: @@ -30,8 +30,8 @@ jobs: - name: Setup JDK uses: actions/setup-java@v3 with: - distribution: 'zulu' # See 'Supported distributions' for available options - java-version: '11' + distribution: "zulu" # See 'Supported distributions' for available options + java-version: "11" - name: Build APK run: ./gradlew assembleDebug - uses: "marvinpinto/action-automatic-releases@latest" @@ -41,6 +41,4 @@ jobs: prerelease: true title: "openScale development build" files: | - /home/runner/work/openScale/openScale/android_app/app/build/outputs/apk/debug/openScale-debug.apk - - + android_app/app/build/outputs/apk/debug/openScale-debug.apk diff --git a/android_app/app/src/main/java/com/health/openscale/gui/statistic/StatisticsFragment.java b/android_app/app/src/main/java/com/health/openscale/gui/statistic/StatisticsFragment.java index 2a443698..78f58fb5 100644 --- a/android_app/app/src/main/java/com/health/openscale/gui/statistic/StatisticsFragment.java +++ b/android_app/app/src/main/java/com/health/openscale/gui/statistic/StatisticsFragment.java @@ -67,15 +67,18 @@ public class StatisticsFragment extends Fragment { private TextView txtGoalWeight; private TextView txtGoalDiff; private TextView txtGoalDayLeft; + private TextView txtTotalWeightLost; private TextView txtLabelGoalWeight; private TextView txtLabelGoalDiff; private TextView txtLabelDayLeft; + private TextView txtLabelTotalWeightLost; private RadarChart radarChartWeek; private RadarChart radarChartMonth; private ScaleUser currentScaleUser; + private ScaleMeasurement firstScaleMeasurement; private ScaleMeasurement lastScaleMeasurement; private ArrayList viewMeasurementsStatistics; @@ -90,6 +93,8 @@ public class StatisticsFragment extends Fragment { txtGoalDiff.setTextColor(ColorUtil.getTintColor(statisticsView.getContext())); txtGoalDayLeft = statisticsView.findViewById(R.id.txtGoalDayLeft); txtGoalDayLeft.setTextColor(ColorUtil.getTintColor(statisticsView.getContext())); + txtTotalWeightLost = statisticsView.findViewById(R.id.txtTotalWeightLost); + txtTotalWeightLost.setTextColor(ColorUtil.getTintColor(statisticsView.getContext())); txtLabelGoalWeight = statisticsView.findViewById(R.id.txtLabelGoalWeight); txtLabelGoalWeight.setTextColor(ColorUtil.getTintColor(statisticsView.getContext())); @@ -97,6 +102,8 @@ public class StatisticsFragment extends Fragment { txtLabelGoalDiff.setTextColor(ColorUtil.getTintColor(statisticsView.getContext())); txtLabelDayLeft = statisticsView.findViewById(R.id.txtLabelDayLeft); txtLabelDayLeft.setTextColor(ColorUtil.getTintColor(statisticsView.getContext())); + txtLabelTotalWeightLost = statisticsView.findViewById(R.id.txtLabelTotalWeightLost); + txtLabelTotalWeightLost.setTextColor(ColorUtil.getTintColor(statisticsView.getContext())); viewMeasurementsStatistics = new ArrayList<>(); @@ -171,8 +178,10 @@ public class StatisticsFragment extends Fragment { lastScaleMeasurement = new ScaleMeasurement(); lastScaleMeasurement.setUserId(currentScaleUser.getId()); lastScaleMeasurement.setWeight(currentScaleUser.getInitialWeight()); + firstScaleMeasurement = lastScaleMeasurement; } else { lastScaleMeasurement = scaleMeasurementList.get(0); + firstScaleMeasurement = scaleMeasurementList.get(scaleMeasurementList.size() - 1); } updateStatistics(scaleMeasurementList); @@ -194,6 +203,10 @@ public class StatisticsFragment extends Fragment { Converters.fromKilogram(goalScaleMeasurement.getWeight() - lastScaleMeasurement.getWeight(), unit), unit.toString())); + txtTotalWeightLost.setText(String.format("%.1f %s", + Converters.fromKilogram(firstScaleMeasurement.getWeight() - lastScaleMeasurement.getWeight(), unit), + unit.toString())); + Calendar goalCalendar = Calendar.getInstance(); goalCalendar.setTime(currentScaleUser.getGoalDate()); int days = Math.max(0, DateTimeHelpers.daysBetween(Calendar.getInstance(), goalCalendar)); @@ -228,6 +241,14 @@ public class StatisticsFragment extends Fragment { getResources().getString(R.string.label_days_left), getResources().getString(R.string.label_goal_date_is), DateFormat.getDateInstance(DateFormat.LONG).format(currentScaleUser.getGoalDate())))); + + txtLabelTotalWeightLost.setText( + Html.fromHtml(String.format( + "%s
%s %.1f %s", + getResources().getString(R.string.label_total_weight_lost), + getResources().getString(R.string.label_total_weight_lost_weight_reference), + Converters.fromKilogram(firstScaleMeasurement.getWeight(), unit), + unit.toString()))); } private void updateStatistics(List scaleMeasurementList) { diff --git a/android_app/app/src/main/res/drawable/ic_weight_loss.xml b/android_app/app/src/main/res/drawable/ic_weight_loss.xml new file mode 100644 index 00000000..d3218619 --- /dev/null +++ b/android_app/app/src/main/res/drawable/ic_weight_loss.xml @@ -0,0 +1,13 @@ + + + diff --git a/android_app/app/src/main/res/layout/fragment_statistics.xml b/android_app/app/src/main/res/layout/fragment_statistics.xml index e40d13ef..dcd81ee3 100644 --- a/android_app/app/src/main/res/layout/fragment_statistics.xml +++ b/android_app/app/src/main/res/layout/fragment_statistics.xml @@ -120,6 +120,49 @@ android:textSize="15dp" /> + + + + + + + + + Average past week Average past month Weight difference + Total weight lost + Reference weight: Goal date: Days left Date