From eddefc97e71ceafca982286cec28fbc6c4666574 Mon Sep 17 00:00:00 2001 From: LeSebring Date: Tue, 18 Oct 2022 13:10:29 +0700 Subject: [PATCH] Adds clarity and detail to the water intake remaining in MainActivity2.java --- .../example/deco3801project/MainActivity2.java | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/app/src/main/java/com/example/deco3801project/MainActivity2.java b/app/src/main/java/com/example/deco3801project/MainActivity2.java index 84684ce..6962c3d 100644 --- a/app/src/main/java/com/example/deco3801project/MainActivity2.java +++ b/app/src/main/java/com/example/deco3801project/MainActivity2.java @@ -138,7 +138,10 @@ protected void onCreate(Bundle savedInstanceState) { // The total amount of water to drink initially TextView amountToDrink = findViewById(R.id.amountToDrink); - amountToDrink.setText(String.valueOf(pref.getInt("currentAmountLeftToDrink", 0))); + amountToDrink.setText(String.valueOf(pref.getInt("currentAmountLeftToDrink", 0)) + .concat(" of ") + .concat(String.valueOf(pref.getInt("recommendedIntake", 0))) + .concat(" remaining")); // The percentage of the amount left to drink TextView amountToDrinkPercent = findViewById(R.id.amountToDrinkPercentage); @@ -260,7 +263,10 @@ public void logIntakeHelper(int drink) { TextView amountToDrinkPercent = findViewById(R.id.amountToDrinkPercentage); // Update the TextViews' texts appropriately - amountToDrink.setText(String.valueOf(currentAmountLeftToDrink)); + amountToDrink.setText(String.valueOf(currentAmountLeftToDrink) + .concat(" of ") + .concat(String.valueOf(pref.getInt("recommendedIntake", 0))) + .concat(" remaining")); double percentageRemaining = calculateRemainingPercentage(); amountToDrinkPercent.setText(String.valueOf((int) percentageRemaining).concat("%")); drinkInput.setText(""); @@ -343,7 +349,10 @@ private void resetWaterIntake() { TextView amountToDrinkPercent = findViewById(R.id.amountToDrinkPercentage); // Update the TextViews' texts appropriately - amountToDrink.setText(String.valueOf(recommendedIntake)); + amountToDrink.setText(String.valueOf(recommendedIntake) + .concat(" of ") + .concat(String.valueOf(recommendedIntake)) + .concat(" remaining")); amountToDrinkPercent.setText(maxPercentage); }