CPP html-ify and send to pump button
This commit is contained in:
parent
a57a864c24
commit
2c5b20a721
3 changed files with 45 additions and 10 deletions
|
@ -4,10 +4,12 @@ package info.nightscout.androidaps.plugins.CircadianPercentageProfile;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.support.v4.app.Fragment;
|
import android.support.v4.app.Fragment;
|
||||||
import android.text.Editable;
|
import android.text.Editable;
|
||||||
|
import android.text.Html;
|
||||||
import android.text.TextWatcher;
|
import android.text.TextWatcher;
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
|
import android.widget.Button;
|
||||||
import android.widget.EditText;
|
import android.widget.EditText;
|
||||||
import android.widget.RadioButton;
|
import android.widget.RadioButton;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
@ -17,6 +19,8 @@ import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
import info.nightscout.androidaps.R;
|
import info.nightscout.androidaps.R;
|
||||||
import info.nightscout.androidaps.interfaces.FragmentBase;
|
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;
|
import info.nightscout.utils.SafeParse;
|
||||||
|
|
||||||
public class CircadianPercentageProfileFragment extends Fragment implements FragmentBase {
|
public class CircadianPercentageProfileFragment extends Fragment implements FragmentBase {
|
||||||
|
@ -38,6 +42,7 @@ public class CircadianPercentageProfileFragment extends Fragment implements Frag
|
||||||
EditText timeshiftView;
|
EditText timeshiftView;
|
||||||
TextView profileView;
|
TextView profileView;
|
||||||
TextView baseprofileView;
|
TextView baseprofileView;
|
||||||
|
Button profileswitchButton;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -55,6 +60,7 @@ public class CircadianPercentageProfileFragment extends Fragment implements Frag
|
||||||
timeshiftView = (EditText) layout.findViewById(R.id.circadianpercentageprofile_timeshift);
|
timeshiftView = (EditText) layout.findViewById(R.id.circadianpercentageprofile_timeshift);
|
||||||
profileView = (TextView) layout.findViewById(R.id.circadianpercentageprofile_profileview);
|
profileView = (TextView) layout.findViewById(R.id.circadianpercentageprofile_profileview);
|
||||||
baseprofileView = (TextView) layout.findViewById(R.id.circadianpercentageprofile_baseprofileview);
|
baseprofileView = (TextView) layout.findViewById(R.id.circadianpercentageprofile_baseprofileview);
|
||||||
|
profileswitchButton = (Button) layout.findViewById(R.id.circadianpercentageprofile_profileswitch);
|
||||||
|
|
||||||
mgdlView.setChecked(circadianPercentageProfilePlugin.mgdl);
|
mgdlView.setChecked(circadianPercentageProfilePlugin.mgdl);
|
||||||
mmolView.setChecked(circadianPercentageProfilePlugin.mmol);
|
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() {
|
TextWatcher textWatch = new TextWatcher() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -123,10 +140,14 @@ public class CircadianPercentageProfileFragment extends Fragment implements Frag
|
||||||
}
|
}
|
||||||
|
|
||||||
private void updateProfileInfo() {
|
private void updateProfileInfo() {
|
||||||
profileView.setText("Active Profile:\n");
|
StringBuilder sb = new StringBuilder();
|
||||||
profileView.append("Basal: " + circadianPercentageProfilePlugin.basalString() + "\n");
|
sb.append("<h3>");
|
||||||
profileView.append("IC: " + circadianPercentageProfilePlugin.icString() + "\n");
|
sb.append("Active Profile:");
|
||||||
profileView.append("ISF: " + circadianPercentageProfilePlugin.isfString() + "\n");
|
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.setText("Base Profile:\n");
|
||||||
baseprofileView.append("Basal: " + circadianPercentageProfilePlugin.baseBasalString() + "\n");
|
baseprofileView.append("Basal: " + circadianPercentageProfilePlugin.baseBasalString() + "\n");
|
||||||
|
|
|
@ -270,12 +270,12 @@ public class CircadianPercentageProfilePlugin implements PluginBase, ProfileInte
|
||||||
|
|
||||||
private static String profileString(double[] values, int timeshift, int percentage){
|
private static String profileString(double[] values, int timeshift, int percentage){
|
||||||
StringBuilder sb = new StringBuilder();
|
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));
|
sb.append(DecimalFormatter.to2Decimal(values[(timeshift+0)%24]*percentage/100d));
|
||||||
double prevVal = values[(timeshift+0)%24];
|
double prevVal = values[(timeshift+0)%24];
|
||||||
for (int i = 1; i < 24; i++) {
|
for (int i = 1; i < 24; i++) {
|
||||||
if(prevVal != values[(timeshift+i)%24]){
|
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));
|
sb.append(DecimalFormatter.to2Decimal(values[(timeshift+i)%24]*percentage/100d));
|
||||||
prevVal = values[(timeshift+i)%24];
|
prevVal = values[(timeshift+i)%24];
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,8 +18,8 @@
|
||||||
android:id="@+id/circadianpercentageprofile_profileview"
|
android:id="@+id/circadianpercentageprofile_profileview"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_marginLeft="10dp"
|
android:layout_margin="6dp"
|
||||||
android:layout_marginRight="10dp"
|
android:padding="6dp"
|
||||||
android:background="@color/cardColorBackground"
|
android:background="@color/cardColorBackground"
|
||||||
android:text="Profile View"
|
android:text="Profile View"
|
||||||
android:textAppearance="?android:attr/textAppearanceSmall" />
|
android:textAppearance="?android:attr/textAppearanceSmall" />
|
||||||
|
@ -80,13 +80,27 @@
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
</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
|
<TextView
|
||||||
android:id="@+id/circadianpercentageprofile_baseprofileview"
|
android:id="@+id/circadianpercentageprofile_baseprofileview"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_marginLeft="10dp"
|
android:layout_margin="6dp"
|
||||||
android:layout_marginRight="10dp"
|
android:padding="6dp"
|
||||||
android:background="@color/cardColorBackground"
|
android:background="@color/cardColorBackground"
|
||||||
android:text="Profile View"
|
android:text="Profile View"
|
||||||
android:textAppearance="?android:attr/textAppearanceSmall" />
|
android:textAppearance="?android:attr/textAppearanceSmall" />
|
||||||
|
|
Loading…
Reference in a new issue