Merge pull request #490 from MilosKozak/tt-remaining
Show remaining time of TT
This commit is contained in:
commit
00152eaffa
|
@ -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));
|
||||
|
|
|
@ -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("");
|
||||
}
|
||||
|
||||
|
|
|
@ -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());
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue