show upload profile button only when pump is capable to this
This commit is contained in:
parent
b2be49e631
commit
2f52091b67
|
@ -1,6 +1,7 @@
|
||||||
package info.nightscout.androidaps.plugins.CircadianPercentageProfile;
|
package info.nightscout.androidaps.plugins.CircadianPercentageProfile;
|
||||||
|
|
||||||
|
|
||||||
|
import android.app.Activity;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.support.v4.app.DialogFragment;
|
import android.support.v4.app.DialogFragment;
|
||||||
|
@ -19,10 +20,14 @@ import android.widget.LinearLayout;
|
||||||
import android.widget.RadioButton;
|
import android.widget.RadioButton;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
|
||||||
|
import com.squareup.otto.Subscribe;
|
||||||
|
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
|
import info.nightscout.androidaps.MainApp;
|
||||||
import info.nightscout.androidaps.R;
|
import info.nightscout.androidaps.R;
|
||||||
|
import info.nightscout.androidaps.events.EventInitializationChanged;
|
||||||
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.Dialogs.NewNSTreatmentDialog;
|
||||||
import info.nightscout.androidaps.plugins.Careportal.OptionsToShow;
|
import info.nightscout.androidaps.plugins.Careportal.OptionsToShow;
|
||||||
|
@ -60,8 +65,6 @@ public class CircadianPercentageProfileFragment extends Fragment implements Frag
|
||||||
BasalEditDialog basalEditDialog;
|
BasalEditDialog basalEditDialog;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public View onCreateView(LayoutInflater inflater, ViewGroup container,
|
public View onCreateView(LayoutInflater inflater, ViewGroup container,
|
||||||
Bundle savedInstanceState) {
|
Bundle savedInstanceState) {
|
||||||
|
@ -87,7 +90,6 @@ public class CircadianPercentageProfileFragment extends Fragment implements Frag
|
||||||
isfeditIcon = (ImageView) layout.findViewById(R.id.circadianpercentageprofile_isfedit);
|
isfeditIcon = (ImageView) layout.findViewById(R.id.circadianpercentageprofile_isfedit);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
mgdlView.setChecked(circadianPercentageProfilePlugin.mgdl);
|
mgdlView.setChecked(circadianPercentageProfilePlugin.mgdl);
|
||||||
mmolView.setChecked(circadianPercentageProfilePlugin.mmol);
|
mmolView.setChecked(circadianPercentageProfilePlugin.mmol);
|
||||||
diaView.setText(circadianPercentageProfilePlugin.dia.toString());
|
diaView.setText(circadianPercentageProfilePlugin.dia.toString());
|
||||||
|
@ -133,7 +135,7 @@ public class CircadianPercentageProfileFragment extends Fragment implements Frag
|
||||||
timeshiftView.setOnFocusChangeListener(new View.OnFocusChangeListener() {
|
timeshiftView.setOnFocusChangeListener(new View.OnFocusChangeListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onFocusChange(View view, boolean b) {
|
public void onFocusChange(View view, boolean b) {
|
||||||
if(b)
|
if (b)
|
||||||
ToastUtils.showToastInUiThread(getContext(), getString(R.string.timeshift_hint));
|
ToastUtils.showToastInUiThread(getContext(), getString(R.string.timeshift_hint));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -142,7 +144,7 @@ public class CircadianPercentageProfileFragment extends Fragment implements Frag
|
||||||
percentageView.setOnFocusChangeListener(new View.OnFocusChangeListener() {
|
percentageView.setOnFocusChangeListener(new View.OnFocusChangeListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onFocusChange(View view, boolean b) {
|
public void onFocusChange(View view, boolean b) {
|
||||||
if(b)
|
if (b)
|
||||||
ToastUtils.showToastInUiThread(getContext(), getString(R.string.percentagefactor_hint));
|
ToastUtils.showToastInUiThread(getContext(), getString(R.string.percentagefactor_hint));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -210,7 +212,7 @@ public class CircadianPercentageProfileFragment extends Fragment implements Frag
|
||||||
public void onTextChanged(CharSequence s, int start,
|
public void onTextChanged(CharSequence s, int start,
|
||||||
int before, int count) {
|
int before, int count) {
|
||||||
|
|
||||||
if(SafeParse.stringToInt(percentageView.getText().toString()) == 0) {
|
if (SafeParse.stringToInt(percentageView.getText().toString()) == 0) {
|
||||||
circadianPercentageProfilePlugin.percentage = 100;
|
circadianPercentageProfilePlugin.percentage = 100;
|
||||||
} else {
|
} else {
|
||||||
circadianPercentageProfilePlugin.percentage = SafeParse.stringToInt(percentageView.getText().toString());
|
circadianPercentageProfilePlugin.percentage = SafeParse.stringToInt(percentageView.getText().toString());
|
||||||
|
@ -232,6 +234,8 @@ public class CircadianPercentageProfileFragment extends Fragment implements Frag
|
||||||
percentageView.addTextChangedListener(textWatch);
|
percentageView.addTextChangedListener(textWatch);
|
||||||
timeshiftView.addTextChangedListener(textWatch);
|
timeshiftView.addTextChangedListener(textWatch);
|
||||||
|
|
||||||
|
onStatusEvent(null);
|
||||||
|
|
||||||
return layout;
|
return layout;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -242,7 +246,7 @@ public class CircadianPercentageProfileFragment extends Fragment implements Frag
|
||||||
sb.append("</h3>");
|
sb.append("</h3>");
|
||||||
sb.append("<h4>");
|
sb.append("<h4>");
|
||||||
sb.append(getString(R.string.nsprofileview_basal_label));
|
sb.append(getString(R.string.nsprofileview_basal_label));
|
||||||
sb.append( " ( ∑");
|
sb.append(" ( ∑");
|
||||||
sb.append(DecimalFormatter.to2Decimal(circadianPercentageProfilePlugin.percentageBasalSum()));
|
sb.append(DecimalFormatter.to2Decimal(circadianPercentageProfilePlugin.percentageBasalSum()));
|
||||||
sb.append("U )");
|
sb.append("U )");
|
||||||
sb.append("</h4> " + circadianPercentageProfilePlugin.basalString());
|
sb.append("</h4> " + circadianPercentageProfilePlugin.basalString());
|
||||||
|
@ -261,21 +265,21 @@ public class CircadianPercentageProfileFragment extends Fragment implements Frag
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onStop(){
|
public void onStop() {
|
||||||
super.onStop();
|
super.onStop();
|
||||||
if(basalEditDialog != null && basalEditDialog.isVisible()){
|
if (basalEditDialog != null && basalEditDialog.isVisible()) {
|
||||||
basalEditDialog.dismiss();
|
basalEditDialog.dismiss();
|
||||||
}
|
}
|
||||||
basalEditDialog = null;
|
basalEditDialog = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class BasalEditDialog extends DialogFragment{
|
public static class BasalEditDialog extends DialogFragment {
|
||||||
|
|
||||||
private double[] values;
|
private double[] values;
|
||||||
private String title;
|
private String title;
|
||||||
private CircadianPercentageProfileFragment fragment;
|
private CircadianPercentageProfileFragment fragment;
|
||||||
|
|
||||||
public void setup(double[] values, String title, CircadianPercentageProfileFragment fragment){
|
public void setup(double[] values, String title, CircadianPercentageProfileFragment fragment) {
|
||||||
this.values = values;
|
this.values = values;
|
||||||
this.title = title;
|
this.title = title;
|
||||||
this.fragment = fragment;
|
this.fragment = fragment;
|
||||||
|
@ -289,23 +293,24 @@ public class CircadianPercentageProfileFragment extends Fragment implements Frag
|
||||||
final EditText[] editTexts = new EditText[24];
|
final EditText[] editTexts = new EditText[24];
|
||||||
for (int i = 0; i < 24; i++) {
|
for (int i = 0; i < 24; i++) {
|
||||||
View childview = inflater.inflate(R.layout.circadianpercentageprofile_listelement, container, false);
|
View childview = inflater.inflate(R.layout.circadianpercentageprofile_listelement, container, false);
|
||||||
((TextView)childview.findViewById(R.id.basal_time_elem)).setText((i<10?"0":"") + i + ":00: ");
|
((TextView) childview.findViewById(R.id.basal_time_elem)).setText((i < 10 ? "0" : "") + i + ":00: ");
|
||||||
|
|
||||||
ImageView copyprevbutton = (ImageView)childview.findViewById(R.id.basal_copyprev_elem);
|
ImageView copyprevbutton = (ImageView) childview.findViewById(R.id.basal_copyprev_elem);
|
||||||
|
|
||||||
if(i==0){
|
if (i == 0) {
|
||||||
copyprevbutton.setVisibility(View.INVISIBLE);;
|
copyprevbutton.setVisibility(View.INVISIBLE);
|
||||||
|
;
|
||||||
} else {
|
} else {
|
||||||
final int j = i; //needs to be final to be passed to inner class.
|
final int j = i; //needs to be final to be passed to inner class.
|
||||||
copyprevbutton.setOnClickListener(new View.OnClickListener() {
|
copyprevbutton.setOnClickListener(new View.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View view) {
|
public void onClick(View view) {
|
||||||
editTexts[j].setText(editTexts[j-1].getText());
|
editTexts[j].setText(editTexts[j - 1].getText());
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
editTexts[i] = ((EditText) childview.findViewById(R.id.basal_edittext_elem));
|
editTexts[i] = ((EditText) childview.findViewById(R.id.basal_edittext_elem));
|
||||||
editTexts[i].setText(DecimalFormatter.to2Decimal(values[i]));
|
editTexts[i].setText(DecimalFormatter.to2Decimal(values[i]));
|
||||||
list.addView(childview);
|
list.addView(childview);
|
||||||
}
|
}
|
||||||
|
@ -315,8 +320,8 @@ public class CircadianPercentageProfileFragment extends Fragment implements Frag
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View view) {
|
public void onClick(View view) {
|
||||||
for (int i = 0; i < 24; i++) {
|
for (int i = 0; i < 24; i++) {
|
||||||
if (editTexts[i].getText().length()!= 0){
|
if (editTexts[i].getText().length() != 0) {
|
||||||
values[i]= SafeParse.stringToDouble(editTexts[i].getText().toString()) ;
|
values[i] = SafeParse.stringToDouble(editTexts[i].getText().toString());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
fragment.updateProfileInfo();
|
fragment.updateProfileInfo();
|
||||||
|
@ -334,11 +339,34 @@ public class CircadianPercentageProfileFragment extends Fragment implements Frag
|
||||||
|
|
||||||
return view;
|
return view;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onPause() {
|
||||||
|
super.onPause();
|
||||||
|
MainApp.bus().unregister(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onResume() {
|
||||||
|
super.onResume();
|
||||||
|
MainApp.bus().register(this);
|
||||||
|
onStatusEvent(null);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Subscribe
|
||||||
|
public void onStatusEvent(final EventInitializationChanged e) {
|
||||||
}
|
Activity activity = getActivity();
|
||||||
|
if (activity != null)
|
||||||
|
activity.runOnUiThread(new Runnable() {
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
if (!MainApp.getConfigBuilder().isInitialized() || !MainApp.getConfigBuilder().getPumpDescription().isSetBasalProfileCapable) {
|
||||||
|
profileswitchButton.setVisibility(View.GONE);
|
||||||
|
} else {
|
||||||
|
profileswitchButton.setVisibility(View.VISIBLE);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -57,7 +57,7 @@ public class MDIPlugin implements PluginBase, PumpInterface {
|
||||||
pumpDescription.highTempPercentDuration = 0;
|
pumpDescription.highTempPercentDuration = 0;
|
||||||
pumpDescription.highTempAbsoluteDuration = 0;
|
pumpDescription.highTempAbsoluteDuration = 0;
|
||||||
|
|
||||||
pumpDescription.isSetBasalProfileCapable = true;
|
pumpDescription.isSetBasalProfileCapable = false;
|
||||||
pumpDescription.basalStep = 0d;
|
pumpDescription.basalStep = 0d;
|
||||||
pumpDescription.basalMinimumRate = 0d;
|
pumpDescription.basalMinimumRate = 0d;
|
||||||
|
|
||||||
|
|
|
@ -136,6 +136,9 @@ public class SimpleProfileFragment extends Fragment implements FragmentBase {
|
||||||
basalView.addTextChangedListener(textWatch);
|
basalView.addTextChangedListener(textWatch);
|
||||||
targetlowView.addTextChangedListener(textWatch);
|
targetlowView.addTextChangedListener(textWatch);
|
||||||
targethighView.addTextChangedListener(textWatch);
|
targethighView.addTextChangedListener(textWatch);
|
||||||
|
|
||||||
|
onStatusEvent(null);
|
||||||
|
|
||||||
return layout;
|
return layout;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -149,6 +152,7 @@ public class SimpleProfileFragment extends Fragment implements FragmentBase {
|
||||||
public void onResume() {
|
public void onResume() {
|
||||||
super.onResume();
|
super.onResume();
|
||||||
MainApp.bus().register(this);
|
MainApp.bus().register(this);
|
||||||
|
onStatusEvent(null);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Subscribe
|
@Subscribe
|
||||||
|
@ -158,7 +162,7 @@ public class SimpleProfileFragment extends Fragment implements FragmentBase {
|
||||||
activity.runOnUiThread(new Runnable() {
|
activity.runOnUiThread(new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
if (!MainApp.getConfigBuilder().isInitialized()) {
|
if (!MainApp.getConfigBuilder().isInitialized() || !MainApp.getConfigBuilder().getPumpDescription().isSetBasalProfileCapable) {
|
||||||
profileswitchButton.setVisibility(View.GONE);
|
profileswitchButton.setVisibility(View.GONE);
|
||||||
} else {
|
} else {
|
||||||
profileswitchButton.setVisibility(View.VISIBLE);
|
profileswitchButton.setVisibility(View.VISIBLE);
|
||||||
|
|
Loading…
Reference in a new issue