From c3cdf2404a8b118b423c7f1ae5622ae0815b387a Mon Sep 17 00:00:00 2001 From: Douglas Rafael Date: Wed, 29 Jan 2020 10:06:52 -0300 Subject: [PATCH] Adjustments to date strings. --- .../ui/activity/PhysicalActivityDetail.java | 105 +++++++++--------- app/src/main/res/values-el/strings.xml | 2 +- app/src/main/res/values-es/strings.xml | 2 +- app/src/main/res/values-pt/strings.xml | 2 +- app/src/main/res/values/strings.xml | 2 +- 5 files changed, 56 insertions(+), 57 deletions(-) diff --git a/app/src/main/java/br/edu/uepb/nutes/ocariot/view/ui/activity/PhysicalActivityDetail.java b/app/src/main/java/br/edu/uepb/nutes/ocariot/view/ui/activity/PhysicalActivityDetail.java index 591b616..1a4a3fb 100644 --- a/app/src/main/java/br/edu/uepb/nutes/ocariot/view/ui/activity/PhysicalActivityDetail.java +++ b/app/src/main/java/br/edu/uepb/nutes/ocariot/view/ui/activity/PhysicalActivityDetail.java @@ -22,7 +22,6 @@ import br.edu.uepb.nutes.ocariot.utils.DateUtils; import butterknife.BindView; import butterknife.ButterKnife; -import timber.log.Timber; /** * A fragment to see the details of a physical physicalActivity. @@ -115,6 +114,58 @@ private void initComponents() { populateView(physicalActivity); } + private void initToolbar() { + ActionBar mActionBar = getSupportActionBar(); + if (mActionBar == null) return; + + mActionBar.setDisplayHomeAsUpEnabled(true); + mActionBar.setDisplayShowTitleEnabled(true); + mActionBar.setHomeAsUpIndicator(R.drawable.ic_close_dark); + mActionBar.setTitle(physicalActivity.getName()); + mActionBar.setSubtitle(childSeelcted.getUsername()); + } + + private void populateView(PhysicalActivity a) { + dateStartDetailsTextView.setText(DateUtils.convertDateTimeUTCToLocale(a.getStartTime(), + getResources().getString(R.string.date_time_abb3), null)); + + rangeDurationTextView.setText(getResources().getString( + R.string.activity_range_time, + DateUtils.convertDateTimeUTCToLocale(a.getStartTime(), getString(R.string.hour_format2)), + DateUtils.convertDateTimeUTCToLocale(a.getEndTime(), getString(R.string.hour_format2)) + )); + + int duration = (int) (a.getDuration() / (60 * 1000)); + durationTextView.setText(getResources().getString(R.string.duration_min, duration)); + stepsTextView.setText(String.valueOf(a.getSteps())); + caloriesTextView.setText(String.valueOf(a.getCalories())); + + if (duration > 0) { + caloriesMinuteTextView.setText(String.valueOf(a.getCalories() / duration)); + } + + // levels + populateLevels(a.getLevels()); + + // heart rate + boxHRZones.setVisibility(View.GONE); + if (a.getHeartRate() != null && a.getHeartRate().getAverage() > 0) { + boxHRZones.setVisibility(View.VISIBLE); + avgHeartRate.setText(String.valueOf(a.getHeartRate().getAverage())); + } + + // distance + if (a.getDistance() != null && a.getDistance() > 0) { + double distance = a.getDistance() / 1000; + double distanceRest = a.getDistance() % 1000; + if (distanceRest > 0) { + distanceTextView.setText(String.format(Locale.getDefault(), "%.2f", distance)); + } else { + distanceTextView.setText(String.format(Locale.getDefault(), "%d", (int) distance)); + } + } + } + private void populateLevels(List levels) { boxLevels.setVisibility(View.GONE); if (levels == null || levels.isEmpty()) return; @@ -178,56 +229,4 @@ private void populateLevels(List levels) { } } } - - private void populateView(PhysicalActivity a) { - dateStartDetailsTextView.setText(DateUtils.convertDateTimeUTCToLocale(a.getStartTime(), - getResources().getString(R.string.date_time_abb3), null)); - - rangeDurationTextView.setText(getResources().getString( - R.string.activity_range_time, - DateUtils.convertDateTimeUTCToLocale(a.getStartTime(), getString(R.string.hour_format2)), - DateUtils.convertDateTimeUTCToLocale(a.getEndTime(), getString(R.string.hour_format2)) - )); - - int duration = (int) (a.getDuration() / (60 * 1000)); - durationTextView.setText(getResources().getString(R.string.duration_min, duration)); - stepsTextView.setText(String.valueOf(a.getSteps())); - caloriesTextView.setText(String.valueOf(a.getCalories())); - - if (duration > 0) { - caloriesMinuteTextView.setText(String.valueOf(a.getCalories() / duration)); - } - - // levels - populateLevels(a.getLevels()); - - // heart rate - boxHRZones.setVisibility(View.GONE); - if (a.getHeartRate() != null && a.getHeartRate().getAverage() > 0) { - boxHRZones.setVisibility(View.VISIBLE); - avgHeartRate.setText(String.valueOf(a.getHeartRate().getAverage())); - } - - // distance - if (a.getDistance() != null && a.getDistance() > 0) { - double distance = a.getDistance() / 1000; - double distanceRest = a.getDistance() % 1000; - if (distanceRest > 0) { - distanceTextView.setText(String.format(Locale.getDefault(), "%.2f", distance)); - } else { - distanceTextView.setText(String.format(Locale.getDefault(), "%d", (int) distance)); - } - } - } - - private void initToolbar() { - ActionBar mActionBar = getSupportActionBar(); - if (mActionBar == null) return; - - mActionBar.setDisplayHomeAsUpEnabled(true); - mActionBar.setDisplayShowTitleEnabled(true); - mActionBar.setHomeAsUpIndicator(R.drawable.ic_close_dark); - mActionBar.setTitle(physicalActivity.getName()); - mActionBar.setSubtitle(childSeelcted.getUsername()); - } } diff --git a/app/src/main/res/values-el/strings.xml b/app/src/main/res/values-el/strings.xml index 8828804..ab4594a 100644 --- a/app/src/main/res/values-el/strings.xml +++ b/app/src/main/res/values-el/strings.xml @@ -53,7 +53,7 @@ Απεικόνιση ρολογιού Απεικόνιση θερμίδων Μέσος καρδιακός ρυθμός - %s στο %s + %s - %s Απεικόνιση Απόστασης diff --git a/app/src/main/res/values-es/strings.xml b/app/src/main/res/values-es/strings.xml index 3d923dd..b560c16 100644 --- a/app/src/main/res/values-es/strings.xml +++ b/app/src/main/res/values-es/strings.xml @@ -53,7 +53,7 @@ Imagen del reloj Imagen de calória Frecuencia cardíaca media - %s en %s + %s - %s Imagen de distancia diff --git a/app/src/main/res/values-pt/strings.xml b/app/src/main/res/values-pt/strings.xml index 7686621..0cd9713 100644 --- a/app/src/main/res/values-pt/strings.xml +++ b/app/src/main/res/values-pt/strings.xml @@ -53,7 +53,7 @@ Imagem do relógio Imagem da caloria Frequência cardíaca média - %s às %s + %s - %s Imagem de distância diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 91e3446..8daa516 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -54,7 +54,7 @@ Clock image Calories image Average Heart Rate - %s at %s + %s - %s Distance image