Merge branch 'dev' of https://github.com/MilosKozak/AndroidAPS into dev
This commit is contained in:
commit
4db82fd275
|
@ -14,6 +14,7 @@ import android.text.format.DateFormat;
|
||||||
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.AdapterView;
|
||||||
import android.widget.ArrayAdapter;
|
import android.widget.ArrayAdapter;
|
||||||
import android.widget.CompoundButton;
|
import android.widget.CompoundButton;
|
||||||
import android.widget.EditText;
|
import android.widget.EditText;
|
||||||
|
@ -194,19 +195,55 @@ public class NewNSTreatmentDialog extends DialogFragment implements View.OnClick
|
||||||
profileSpinner.setSelection(p);
|
profileSpinner.setSelection(p);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
final Double bg = Profile.fromMgdlToUnits(GlucoseStatus.getGlucoseStatusData() != null ? GlucoseStatus.getGlucoseStatusData().glucose : 0d, profile != null ? profile.getUnits() : Constants.MGDL);
|
||||||
|
|
||||||
// temp target
|
// temp target
|
||||||
ArrayList<CharSequence> reasonList = new ArrayList<CharSequence>();
|
final ArrayList<CharSequence> reasonList = new ArrayList<CharSequence>();
|
||||||
|
reasonList.add(MainApp.sResources.getString(R.string.manual));
|
||||||
reasonList.add(MainApp.sResources.getString(R.string.eatingsoon));
|
reasonList.add(MainApp.sResources.getString(R.string.eatingsoon));
|
||||||
reasonList.add(MainApp.sResources.getString(R.string.activity));
|
reasonList.add(MainApp.sResources.getString(R.string.activity));
|
||||||
reasonList.add(MainApp.sResources.getString(R.string.manual));
|
|
||||||
ArrayAdapter<CharSequence> adapterReason = new ArrayAdapter<CharSequence>(getContext(),
|
ArrayAdapter<CharSequence> adapterReason = new ArrayAdapter<CharSequence>(getContext(),
|
||||||
R.layout.spinner_centered, reasonList);
|
R.layout.spinner_centered, reasonList);
|
||||||
reasonSpinner.setAdapter(adapterReason);
|
reasonSpinner.setAdapter(adapterReason);
|
||||||
|
reasonSpinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
|
||||||
|
@Override
|
||||||
|
public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
|
||||||
|
double defaultDuration = 0;
|
||||||
|
double defaultTarget = 0;
|
||||||
|
if(profile!=null){
|
||||||
|
defaultTarget = bg.doubleValue();
|
||||||
|
}
|
||||||
|
boolean erase = false;
|
||||||
|
|
||||||
|
if(MainApp.sResources.getString(R.string.eatingsoon).equals(reasonList.get(position))){
|
||||||
|
defaultDuration = SP.getDouble(R.string.key_eatingsoon_duration, 0d);
|
||||||
|
defaultTarget = SP.getDouble(R.string.key_eatingsoon_target, 0d);;
|
||||||
|
} else if (MainApp.sResources.getString(R.string.activity).equals(reasonList.get(position))){
|
||||||
|
defaultDuration = SP.getDouble(R.string.key_activity_duration, 0d);;
|
||||||
|
defaultTarget = SP.getDouble(R.string.key_activity_target, 0d);;
|
||||||
|
} else {
|
||||||
|
defaultDuration = 0;
|
||||||
|
erase = true;
|
||||||
|
}
|
||||||
|
if(defaultTarget != 0 || erase){
|
||||||
|
editTemptarget.setValue(defaultTarget);
|
||||||
|
}
|
||||||
|
if(defaultDuration != 0){
|
||||||
|
editDuration.setValue(defaultDuration);
|
||||||
|
} else if (erase){
|
||||||
|
editDuration.setValue(0d);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onNothingSelected(AdapterView<?> parent) {
|
||||||
|
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
// bg
|
// bg
|
||||||
bgUnitsView.setText(units);
|
bgUnitsView.setText(units);
|
||||||
|
|
||||||
Double bg = Profile.fromMgdlToUnits(GlucoseStatus.getGlucoseStatusData() != null ? GlucoseStatus.getGlucoseStatusData().glucose : 0d, profile != null ? profile.getUnits() : Constants.MGDL);
|
|
||||||
editBg = (NumberPicker) view.findViewById(R.id.careportal_newnstreatment_bginput);
|
editBg = (NumberPicker) view.findViewById(R.id.careportal_newnstreatment_bginput);
|
||||||
editTemptarget = (NumberPicker) view.findViewById(R.id.careportal_newnstreatment_temptarget);
|
editTemptarget = (NumberPicker) view.findViewById(R.id.careportal_newnstreatment_temptarget);
|
||||||
if (profile == null) {
|
if (profile == null) {
|
||||||
|
|
|
@ -506,7 +506,7 @@ public class DanaRPlugin implements PluginBase, PumpInterface, DanaRInterface, C
|
||||||
}
|
}
|
||||||
if (percent > getPumpDescription().maxTempPercent)
|
if (percent > getPumpDescription().maxTempPercent)
|
||||||
percent = getPumpDescription().maxTempPercent;
|
percent = getPumpDescription().maxTempPercent;
|
||||||
TemporaryBasal runningTB = MainApp.getConfigBuilder().getTempBasalFromHistory(System.currentTimeMillis());
|
TemporaryBasal runningTB = MainApp.getConfigBuilder().getRealTempBasalFromHistory(System.currentTimeMillis());
|
||||||
if (runningTB != null && runningTB.percentRate == percent) {
|
if (runningTB != null && runningTB.percentRate == percent) {
|
||||||
result.enacted = false;
|
result.enacted = false;
|
||||||
result.success = true;
|
result.success = true;
|
||||||
|
|
|
@ -503,7 +503,7 @@ public class DanaRKoreanPlugin implements PluginBase, PumpInterface, DanaRInterf
|
||||||
}
|
}
|
||||||
if (percent > getPumpDescription().maxTempPercent)
|
if (percent > getPumpDescription().maxTempPercent)
|
||||||
percent = getPumpDescription().maxTempPercent;
|
percent = getPumpDescription().maxTempPercent;
|
||||||
TemporaryBasal runningTB = MainApp.getConfigBuilder().getTempBasalFromHistory(System.currentTimeMillis());
|
TemporaryBasal runningTB = MainApp.getConfigBuilder().getRealTempBasalFromHistory(System.currentTimeMillis());
|
||||||
if (runningTB != null && runningTB.percentRate == percent) {
|
if (runningTB != null && runningTB.percentRate == percent) {
|
||||||
result.enacted = false;
|
result.enacted = false;
|
||||||
result.success = true;
|
result.success = true;
|
||||||
|
|
|
@ -429,7 +429,7 @@ public class DanaRv2Plugin implements PluginBase, PumpInterface, DanaRInterface,
|
||||||
}
|
}
|
||||||
if (percent > getPumpDescription().maxTempPercent)
|
if (percent > getPumpDescription().maxTempPercent)
|
||||||
percent = getPumpDescription().maxTempPercent;
|
percent = getPumpDescription().maxTempPercent;
|
||||||
TemporaryBasal runningTB = MainApp.getConfigBuilder().getTempBasalFromHistory(System.currentTimeMillis());
|
TemporaryBasal runningTB = MainApp.getConfigBuilder().getRealTempBasalFromHistory(System.currentTimeMillis());
|
||||||
if (runningTB != null && runningTB.percentRate == percent) {
|
if (runningTB != null && runningTB.percentRate == percent) {
|
||||||
result.enacted = false;
|
result.enacted = false;
|
||||||
result.success = true;
|
result.success = true;
|
||||||
|
|
|
@ -3,6 +3,7 @@ package info.nightscout.utils;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.os.Handler;
|
import android.os.Handler;
|
||||||
import android.os.Message;
|
import android.os.Message;
|
||||||
|
import android.text.Editable;
|
||||||
import android.text.TextWatcher;
|
import android.text.TextWatcher;
|
||||||
import android.util.AttributeSet;
|
import android.util.AttributeSet;
|
||||||
import android.view.KeyEvent;
|
import android.view.KeyEvent;
|
||||||
|
@ -119,6 +120,22 @@ public class NumberPicker extends LinearLayout implements View.OnKeyListener,
|
||||||
plusButton.setOnTouchListener(this);
|
plusButton.setOnTouchListener(this);
|
||||||
plusButton.setOnKeyListener(this);
|
plusButton.setOnKeyListener(this);
|
||||||
plusButton.setOnClickListener(this);
|
plusButton.setOnClickListener(this);
|
||||||
|
this.addTextChangedListener(new TextWatcher() {
|
||||||
|
@Override
|
||||||
|
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onTextChanged(CharSequence s, int start, int before, int count) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void afterTextChanged(Editable s) {
|
||||||
|
value = SafeParse.stringToDouble(editText.getText().toString());
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public void removeTextChangedListener(TextWatcher textWatcher) {
|
public void removeTextChangedListener(TextWatcher textWatcher) {
|
||||||
|
|
|
@ -707,5 +707,14 @@
|
||||||
<string name="key_wizard_include_trend_bg">wizard_include_trend_bg</string>
|
<string name="key_wizard_include_trend_bg">wizard_include_trend_bg</string>
|
||||||
<string name="key_wizard_include_bolus_iob">wizard_include_bolus_iob</string>
|
<string name="key_wizard_include_bolus_iob">wizard_include_bolus_iob</string>
|
||||||
<string name="key_wizard_include_basal_iob">wizard_include_basal_iob</string>
|
<string name="key_wizard_include_basal_iob">wizard_include_basal_iob</string>
|
||||||
|
<string name="default_temptargets">Default Temp-Targets</string>
|
||||||
|
<string name="eatingsoon_duration">eatingsoon duration</string>
|
||||||
|
<string name="eatingsoon_target">eatingsoon target</string>
|
||||||
|
<string name="activity_duration">activity duration</string>
|
||||||
|
<string name="activity_target">activity target</string>
|
||||||
|
<string name="key_eatingsoon_duration">eatingsoon_duration</string>
|
||||||
|
<string name="key_eatingsoon_target">eatingsoon_target</string>
|
||||||
|
<string name="key_activity_duration">activity_duration</string>
|
||||||
|
<string name="key_activity_target">activity_target</string>
|
||||||
</resources>
|
</resources>
|
||||||
|
|
||||||
|
|
|
@ -3,6 +3,33 @@
|
||||||
<PreferenceCategory
|
<PreferenceCategory
|
||||||
android:key="others"
|
android:key="others"
|
||||||
android:title="@string/othersettings_title">
|
android:title="@string/othersettings_title">
|
||||||
|
<PreferenceScreen
|
||||||
|
android:title="@string/default_temptargets">
|
||||||
|
<EditTextPreference
|
||||||
|
android:title="@string/eatingsoon_duration"
|
||||||
|
android:key="@string/key_eatingsoon_duration"
|
||||||
|
android:defaultValue="0"
|
||||||
|
android:inputType="number">
|
||||||
|
</EditTextPreference>
|
||||||
|
<EditTextPreference
|
||||||
|
android:title="@string/eatingsoon_target"
|
||||||
|
android:key="@string/key_eatingsoon_target"
|
||||||
|
android:defaultValue="0"
|
||||||
|
android:inputType="numberDecimal">
|
||||||
|
</EditTextPreference>
|
||||||
|
<EditTextPreference
|
||||||
|
android:title="@string/activity_duration"
|
||||||
|
android:key="@string/key_activity_duration"
|
||||||
|
android:defaultValue="0"
|
||||||
|
android:inputType="number">
|
||||||
|
</EditTextPreference>
|
||||||
|
<EditTextPreference
|
||||||
|
android:title="@string/activity_target"
|
||||||
|
android:key="@string/key_activity_target"
|
||||||
|
android:defaultValue="0"
|
||||||
|
android:inputType="numberDecimal">
|
||||||
|
</EditTextPreference>
|
||||||
|
</PreferenceScreen>
|
||||||
<PreferenceScreen
|
<PreferenceScreen
|
||||||
android:title="@string/fillbolus_title">
|
android:title="@string/fillbolus_title">
|
||||||
<EditTextPreference
|
<EditTextPreference
|
||||||
|
|
Loading…
Reference in a new issue