Merge pull request #490 from MilosKozak/tt-remaining

Show remaining time of TT
This commit is contained in:
Milos Kozak 2017-11-01 18:29:54 +01:00 committed by GitHub
commit 00152eaffa
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 19 additions and 3 deletions

View file

@ -997,7 +997,7 @@ public class OverviewFragment extends Fragment implements View.OnClickListener,
tempTargetView.setTextColor(Color.BLACK);
tempTargetView.setBackgroundColor(MainApp.sResources.getColor(R.color.tempTargetBackground));
tempTargetView.setVisibility(View.VISIBLE);
tempTargetView.setText(Profile.toTargetRangeString(tempTarget.low, tempTarget.high, Constants.MGDL, units));
tempTargetView.setText(Profile.toTargetRangeString(tempTarget.low, tempTarget.high, Constants.MGDL, units) + " " + DateUtil.untilString(tempTarget.end()));
} else {
tempTargetView.setTextColor(Color.WHITE);
tempTargetView.setBackgroundColor(MainApp.sResources.getColor(R.color.tempTargetDisabledBackground));

View file

@ -226,7 +226,7 @@ public class DanaRFragment extends SubscriberFragment {
Long agoMsec = System.currentTimeMillis() - pump.lastBolusTime.getTime();
double agoHours = agoMsec / 60d / 60d / 1000d;
if (agoHours < 6) // max 6h back
lastBolusView.setText(DateUtil.timeString(pump.lastBolusTime) + " (" + DecimalFormatter.to1Decimal(agoHours) + " " + MainApp.sResources.getString(R.string.hoursago) + ") " + DecimalFormatter.to2Decimal(DanaRPump.getInstance().lastBolusAmount) + " U");
lastBolusView.setText(DateUtil.timeString(pump.lastBolusTime) + " " + DateUtil.sinceString(pump.lastBolusTime.getTime()) + " " + DecimalFormatter.to2Decimal(DanaRPump.getInstance().lastBolusAmount) + " U");
else lastBolusView.setText("");
}

View file

@ -146,4 +146,20 @@ public class DateUtil {
}
}
public static String timeFrameString(long timeInMillis){
long remainingTimeMinutes = timeInMillis/(1000*60);
long remainingTimeHours = remainingTimeMinutes/60;
remainingTimeMinutes = remainingTimeMinutes%60;
return "(" + ((remainingTimeHours >0)?(remainingTimeHours + "h "):"") + remainingTimeMinutes + "')";
}
public static String sinceString(long timestamp){
return timeFrameString(System.currentTimeMillis()-timestamp);
}
public static String untilString(long timestamp){
return timeFrameString(timestamp- System.currentTimeMillis());
}
}