Merge pull request #334 from AdrianLxM/colored-activetemp

Colored activetemp
This commit is contained in:
Milos Kozak 2017-08-03 09:11:30 +02:00 committed by GitHub
commit 541a261dda
5 changed files with 47 additions and 44 deletions

View file

@ -289,17 +289,17 @@ public class TemporaryBasal implements Interval {
Profile profile = MainApp.getConfigBuilder().getProfile();
Double currentBasalRate = profile.getBasal();
double rate = (currentBasalRate == null)?0d:(currentBasalRate+netExtendedRate);
return DecimalFormatter.to2Decimal(rate) + "U/h ("+DecimalFormatter.to2Decimal(netExtendedRate)+"E) @" +
return getCalcuatedPercentageIfNeeded() + DecimalFormatter.to2Decimal(rate) + "U/h ("+DecimalFormatter.to2Decimal(netExtendedRate)+"E) @" +
DateUtil.timeString(date) +
" " + getRealDuration() + "/" + durationInMinutes + "min";
" " + getRealDuration() + "/" + durationInMinutes + "'";
} else if (isAbsolute) {
return DecimalFormatter.to2Decimal(absoluteRate) + "U/h @" +
DateUtil.timeString(date) +
" " + getRealDuration() + "/" + durationInMinutes + "min";
" " + getRealDuration() + "/" + durationInMinutes + "'";
} else { // percent
return percentRate + "% @" +
DateUtil.timeString(date) +
" " + getRealDuration() + "/" + durationInMinutes + "min";
" " + getRealDuration() + "/" + durationInMinutes + "'";
}
}
@ -330,6 +330,31 @@ public class TemporaryBasal implements Interval {
}
}
private String getCalcuatedPercentageIfNeeded(){
if (isAbsolute || isFakeExtended) {
double rate = 0d;
if (isFakeExtended) {
Profile profile = MainApp.getConfigBuilder().getProfile();
Double currentBasalRate = profile.getBasal();
rate = (currentBasalRate == null)?0d:(currentBasalRate+netExtendedRate);
} else if (isAbsolute){
rate = absoluteRate;
}
if(SP.getBoolean(R.string.key_danar_visualizeextendedaspercentage, false) && SP.getBoolean(R.string.key_danar_useextended, false)){
Profile profile = MainApp.getConfigBuilder().getProfile();
if(profile != null) {
double basal = profile.getBasal();
if(basal != 0){
return Math.round(rate*100d/basal) + "% ";
}
}
}
}
return "";
}
public String toStringVeryShort() {
if (isAbsolute || isFakeExtended) {

View file

@ -214,6 +214,17 @@ public class ActionsFragment extends SubscriberFragment implements View.OnClickL
});
}
break;
case R.id.actions_canceltempbasal:
if (MainApp.getConfigBuilder().isInHistoryRealTempBasalInProgress()) {
sHandler.post(new Runnable() {
@Override
public void run() {
pump.cancelTempBasal(true);
Answers.getInstance().logCustom(new CustomEvent("CancelTemp"));
}
});
}
break;
case R.id.actions_settempbasal:
NewTempBasalDialog newTempDialog = new NewTempBasalDialog();
newTempDialog.show(manager, "NewTempDialog");

View file

@ -583,18 +583,6 @@ public class OverviewFragment extends Fragment implements View.OnClickListener,
NewTreatmentDialog treatmentDialogFragment = new NewTreatmentDialog();
treatmentDialogFragment.show(manager, "TreatmentDialog");
break;
case R.id.overview_canceltempbutton:
final PumpInterface pump = MainApp.getConfigBuilder();
if (MainApp.getConfigBuilder().isTempBasalInProgress()) {
sHandler.post(new Runnable() {
@Override
public void run() {
pump.cancelTempBasal(true);
Answers.getInstance().logCustom(new CustomEvent("CancelTemp"));
}
});
}
break;
case R.id.overview_pumpstatus:
if (MainApp.getConfigBuilder().isSuspended() || !MainApp.getConfigBuilder().isInitialized())
sHandler.post(new Runnable() {
@ -1044,6 +1032,13 @@ public class OverviewFragment extends Fragment implements View.OnClickListener,
basalText += "(" + DecimalFormatter.to2Decimal(pump.getBaseBasalRate()) + "U/h)";
}
}
if (activeTemp != null) {
baseBasalView.setTextColor(MainApp.sResources.getColor(R.color.basal));
} else {
baseBasalView.setTextColor(Color.WHITE);
}
baseBasalView.setText(basalText);
final ExtendedBolus extendedBolus = MainApp.getConfigBuilder().getExtendedBolusFromHistory(System.currentTimeMillis());

View file

@ -756,20 +756,6 @@
android:textSize="10sp"
android:visibility="gone" />
<Button
android:id="@+id/overview_canceltempbutton"
style="?android:attr/buttonStyle"
android:layout_width="0px"
android:layout_height="fill_parent"
android:layout_weight="0.5"
android:drawableTop="@drawable/icon_cancelbasal"
android:paddingLeft="0dp"
android:paddingRight="0dp"
android:text="Cancel temp basal"
android:textColor="@color/colorCancelTempButton"
android:textSize="10sp"
android:visibility="gone" />
</LinearLayout>
</LinearLayout>

View file

@ -433,20 +433,6 @@
android:textSize="10sp"
android:visibility="gone" />
<Button
android:id="@+id/overview_canceltempbutton"
style="?android:attr/buttonStyle"
android:layout_width="0px"
android:layout_height="fill_parent"
android:layout_weight="0.5"
android:drawableTop="@drawable/icon_cancelbasal"
android:paddingLeft="0dp"
android:paddingRight="0dp"
android:text="Cancel temp basal"
android:textColor="@color/colorCancelTempButton"
android:textSize="10sp"
android:visibility="gone" />
</LinearLayout>
</LinearLayout>