CPP html-ify and send to pump button

This commit is contained in:
AdrianLxM 2016-11-13 05:30:46 +01:00
parent a57a864c24
commit 2c5b20a721
3 changed files with 45 additions and 10 deletions

View file

@ -4,10 +4,12 @@ package info.nightscout.androidaps.plugins.CircadianPercentageProfile;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.text.Editable;
import android.text.Html;
import android.text.TextWatcher;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.EditText;
import android.widget.RadioButton;
import android.widget.TextView;
@ -17,6 +19,8 @@ import org.slf4j.LoggerFactory;
import info.nightscout.androidaps.R;
import info.nightscout.androidaps.interfaces.FragmentBase;
import info.nightscout.androidaps.plugins.Careportal.Dialogs.NewNSTreatmentDialog;
import info.nightscout.androidaps.plugins.Careportal.OptionsToShow;
import info.nightscout.utils.SafeParse;
public class CircadianPercentageProfileFragment extends Fragment implements FragmentBase {
@ -38,6 +42,7 @@ public class CircadianPercentageProfileFragment extends Fragment implements Frag
EditText timeshiftView;
TextView profileView;
TextView baseprofileView;
Button profileswitchButton;
@ -55,6 +60,7 @@ public class CircadianPercentageProfileFragment extends Fragment implements Frag
timeshiftView = (EditText) layout.findViewById(R.id.circadianpercentageprofile_timeshift);
profileView = (TextView) layout.findViewById(R.id.circadianpercentageprofile_profileview);
baseprofileView = (TextView) layout.findViewById(R.id.circadianpercentageprofile_baseprofileview);
profileswitchButton = (Button) layout.findViewById(R.id.circadianpercentageprofile_profileswitch);
mgdlView.setChecked(circadianPercentageProfilePlugin.mgdl);
mmolView.setChecked(circadianPercentageProfilePlugin.mmol);
@ -87,6 +93,17 @@ public class CircadianPercentageProfileFragment extends Fragment implements Frag
}
});
profileswitchButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
NewNSTreatmentDialog newDialog = new NewNSTreatmentDialog();
final OptionsToShow profileswitch = new OptionsToShow(R.id.careportal_profileswitch, R.string.careportal_profileswitch, true, false, false, false, false, false, false, true, false);
profileswitch.executeProfileSwitch = true;
newDialog.setOptions(profileswitch);
newDialog.show(getFragmentManager(), "NewNSTreatmentDialog");
}
});
TextWatcher textWatch = new TextWatcher() {
@Override
@ -123,10 +140,14 @@ public class CircadianPercentageProfileFragment extends Fragment implements Frag
}
private void updateProfileInfo() {
profileView.setText("Active Profile:\n");
profileView.append("Basal: " + circadianPercentageProfilePlugin.basalString() + "\n");
profileView.append("IC: " + circadianPercentageProfilePlugin.icString() + "\n");
profileView.append("ISF: " + circadianPercentageProfilePlugin.isfString() + "\n");
StringBuilder sb = new StringBuilder();
sb.append("<h3>");
sb.append("Active Profile:");
sb.append("</h3>");
sb.append("<h4>Basal:</h4> " + circadianPercentageProfilePlugin.basalString());
sb.append("<h4>IC:</h4> " + circadianPercentageProfilePlugin.icString());
sb.append("<h4>ISF:</h4> " + circadianPercentageProfilePlugin.isfString());
profileView.setText(Html.fromHtml(sb.toString()));
baseprofileView.setText("Base Profile:\n");
baseprofileView.append("Basal: " + circadianPercentageProfilePlugin.baseBasalString() + "\n");

View file

@ -270,12 +270,12 @@ public class CircadianPercentageProfilePlugin implements PluginBase, ProfileInte
private static String profileString(double[] values, int timeshift, int percentage){
StringBuilder sb = new StringBuilder();
sb.append(0); sb.append("h: ");
sb.append("<b>"); sb.append(0); sb.append("h: "); sb.append("</b>");
sb.append(DecimalFormatter.to2Decimal(values[(timeshift+0)%24]*percentage/100d));
double prevVal = values[(timeshift+0)%24];
for (int i = 1; i < 24; i++) {
if(prevVal != values[(timeshift+i)%24]){
sb.append(", "); sb.append(i); sb.append("h: ");
sb.append(", ");sb.append("<b>"); sb.append(i); sb.append("h: ");sb.append("</b>");
sb.append(DecimalFormatter.to2Decimal(values[(timeshift+i)%24]*percentage/100d));
prevVal = values[(timeshift+i)%24];
}

View file

@ -18,8 +18,8 @@
android:id="@+id/circadianpercentageprofile_profileview"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:layout_margin="6dp"
android:padding="6dp"
android:background="@color/cardColorBackground"
android:text="Profile View"
android:textAppearance="?android:attr/textAppearanceSmall" />
@ -80,13 +80,27 @@
</LinearLayout>
</LinearLayout>
<Button
android:id="@+id/circadianpercentageprofile_profileswitch"
style="?android:attr/buttonStyle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="3dp"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:layout_marginTop="3dp"
android:paddingLeft="10dp"
android:paddingRight="10dp"
android:text="SEND TO PUMP"
android:layout_gravity="center_horizontal"
android:textColor="@color/colorProfileSwitchButton" />
<TextView
android:id="@+id/circadianpercentageprofile_baseprofileview"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:layout_margin="6dp"
android:padding="6dp"
android:background="@color/cardColorBackground"
android:text="Profile View"
android:textAppearance="?android:attr/textAppearanceSmall" />