Merge branch 'objectives' of https://github.com/MilosKozak/AndroidAPS into objectives
This commit is contained in:
commit
9de293acc0
|
@ -218,11 +218,9 @@ public class MainApp extends Application {
|
|||
pluginsList.add(StatuslinePlugin.initPlugin(this));
|
||||
pluginsList.add(PersistentNotificationPlugin.getPlugin());
|
||||
pluginsList.add(NSClientPlugin.getPlugin());
|
||||
if (engineeringMode)
|
||||
pluginsList.add(TidepoolPlugin.INSTANCE);
|
||||
// if (engineeringMode) pluginsList.add(TidepoolPlugin.INSTANCE);
|
||||
pluginsList.add(MaintenancePlugin.initPlugin(this));
|
||||
if (engineeringMode)
|
||||
pluginsList.add(AutomationPlugin.INSTANCE);
|
||||
pluginsList.add(AutomationPlugin.INSTANCE);
|
||||
|
||||
pluginsList.add(ConfigBuilderPlugin.getPlugin());
|
||||
|
||||
|
|
|
@ -290,7 +290,7 @@ public class LoopPlugin extends PluginBase {
|
|||
|
||||
Profile profile = ProfileFunctions.getInstance().getProfile();
|
||||
|
||||
if (!ProfileFunctions.getInstance().isProfileValid("Loop")) {
|
||||
if (profile == null || !ProfileFunctions.getInstance().isProfileValid("Loop")) {
|
||||
if (L.isEnabled(L.APS))
|
||||
log.debug(MainApp.gs(R.string.noprofileselected));
|
||||
RxBus.INSTANCE.send(new EventLoopSetLastRunGui(MainApp.gs(R.string.noprofileselected)));
|
||||
|
|
|
@ -18,17 +18,24 @@ import androidx.recyclerview.widget.LinearSmoothScroller
|
|||
import androidx.recyclerview.widget.RecyclerView
|
||||
import info.nightscout.androidaps.MainApp
|
||||
import info.nightscout.androidaps.R
|
||||
import info.nightscout.androidaps.plugins.bus.RxBus
|
||||
import info.nightscout.androidaps.plugins.constraints.objectives.activities.ObjectivesExamDialog
|
||||
import info.nightscout.androidaps.plugins.constraints.objectives.objectives.Objective
|
||||
import info.nightscout.androidaps.plugins.constraints.objectives.events.EventObjectivesUpdateGui
|
||||
import info.nightscout.androidaps.plugins.constraints.objectives.objectives.Objective.ExamTask
|
||||
import info.nightscout.androidaps.utils.DateUtil
|
||||
import info.nightscout.androidaps.utils.FabricPrivacy
|
||||
import info.nightscout.androidaps.utils.HtmlHelper
|
||||
import info.nightscout.androidaps.utils.SP
|
||||
import io.reactivex.android.schedulers.AndroidSchedulers
|
||||
import io.reactivex.disposables.CompositeDisposable
|
||||
import kotlinx.android.synthetic.main.objectives_fragment.*
|
||||
|
||||
class ObjectivesFragment : Fragment() {
|
||||
private val objectivesAdapter = ObjectivesAdapter()
|
||||
private val handler = Handler(Looper.getMainLooper())
|
||||
|
||||
private var disposable: CompositeDisposable = CompositeDisposable()
|
||||
|
||||
private val objectiveUpdater = object : Runnable {
|
||||
override fun run() {
|
||||
handler.postDelayed(this, (60 * 1000).toLong())
|
||||
|
@ -56,6 +63,26 @@ class ObjectivesFragment : Fragment() {
|
|||
startUpdateTimer()
|
||||
}
|
||||
|
||||
@Synchronized
|
||||
override fun onResume() {
|
||||
super.onResume()
|
||||
disposable.add(RxBus
|
||||
.toObservable(EventObjectivesUpdateGui::class.java)
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe({
|
||||
objectives_recyclerview.adapter?.notifyDataSetChanged()
|
||||
}, {
|
||||
FabricPrivacy.logException(it)
|
||||
})
|
||||
)
|
||||
}
|
||||
|
||||
@Synchronized
|
||||
override fun onPause() {
|
||||
super.onPause()
|
||||
disposable.clear()
|
||||
}
|
||||
|
||||
@Synchronized
|
||||
override fun onDestroyView() {
|
||||
super.onDestroyView()
|
||||
|
@ -152,9 +179,13 @@ class ObjectivesFragment : Fragment() {
|
|||
state.text = HtmlHelper.fromHtml(formattedHTML)
|
||||
state.gravity = Gravity.END
|
||||
holder.progress.addView(state, LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT)
|
||||
if (task is ExamTask) {
|
||||
if (task is ExamTask) {
|
||||
state.setOnClickListener {
|
||||
val dialog = ObjectivesExamDialog();
|
||||
val dialog = ObjectivesExamDialog()
|
||||
val bundle = Bundle()
|
||||
val position = objective.tasks.indexOf(task)
|
||||
bundle.putInt("currentTask", position)
|
||||
dialog.arguments = bundle
|
||||
ObjectivesExamDialog.objective = objective
|
||||
fragmentManager?.let { dialog.show(it, "ObjectivesFragment") }
|
||||
}
|
||||
|
@ -189,6 +220,11 @@ class ObjectivesFragment : Fragment() {
|
|||
scrollToCurrentObjective()
|
||||
}
|
||||
if (objective.hasSpecialInput && !objective.isAccomplished && objective.isStarted) {
|
||||
// generate random request code if none exists
|
||||
val request = SP.getString(R.string.key_objectives_request_code, String.format("%1$05d", (Math.random() * 99999).toInt()))
|
||||
SP.putString(R.string.key_objectives_request_code, request)
|
||||
holder.requestCode.text = MainApp.gs(R.string.requestcode, request)
|
||||
holder.requestCode.visibility = View.VISIBLE
|
||||
holder.enterButton.visibility = View.VISIBLE
|
||||
holder.input.visibility = View.VISIBLE
|
||||
holder.inputHint.visibility = View.VISIBLE
|
||||
|
@ -201,6 +237,7 @@ class ObjectivesFragment : Fragment() {
|
|||
holder.enterButton.visibility = View.GONE
|
||||
holder.input.visibility = View.GONE
|
||||
holder.inputHint.visibility = View.GONE
|
||||
holder.requestCode.visibility = View.GONE
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -221,6 +258,7 @@ class ObjectivesFragment : Fragment() {
|
|||
val inputHint: TextView = itemView.findViewById(R.id.objective_inputhint)
|
||||
val input: EditText = itemView.findViewById(R.id.objective_input)
|
||||
val enterButton: Button = itemView.findViewById(R.id.objective_enterbutton)
|
||||
val requestCode: TextView = itemView.findViewById(R.id.objective_requestcode)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -102,9 +102,10 @@ object ObjectivesPlugin : PluginBase(PluginDescription()
|
|||
}
|
||||
|
||||
fun completeObjectives(activity: Activity, request: String) {
|
||||
val requestCode = SP.getString(R.string.key_objectives_request_code, "")
|
||||
var url = SP.getString(R.string.key_nsclientinternal_url, "").toLowerCase()
|
||||
if (!url.endsWith("\"")) url = "$url/"
|
||||
val hashNS = Hashing.sha1().hashString(url + BuildConfig.APPLICATION_ID, Charsets.UTF_8).toString()
|
||||
val hashNS = Hashing.sha1().hashString(url + BuildConfig.APPLICATION_ID + "/" + requestCode, Charsets.UTF_8).toString()
|
||||
if (request.equals(hashNS.substring(0, 10), ignoreCase = true)) {
|
||||
SP.putLong("Objectives_" + "openloop" + "_started", DateUtil.now())
|
||||
SP.putLong("Objectives_" + "openloop" + "_accomplished", DateUtil.now())
|
||||
|
|
|
@ -5,15 +5,23 @@ import android.view.LayoutInflater
|
|||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import androidx.fragment.app.DialogFragment
|
||||
import info.nightscout.androidaps.MainApp
|
||||
import info.nightscout.androidaps.R
|
||||
import info.nightscout.androidaps.plugins.bus.RxBus
|
||||
import info.nightscout.androidaps.plugins.constraints.objectives.events.EventObjectivesUpdateGui
|
||||
import info.nightscout.androidaps.plugins.constraints.objectives.objectives.Objective
|
||||
import info.nightscout.androidaps.plugins.constraints.objectives.objectives.Objective.*
|
||||
import info.nightscout.androidaps.utils.DateUtil
|
||||
import info.nightscout.androidaps.utils.OKDialog
|
||||
import info.nightscout.androidaps.utils.T
|
||||
import info.nightscout.androidaps.utils.ToastUtils
|
||||
import kotlinx.android.synthetic.main.objectives_exam_fragment.*
|
||||
|
||||
class ObjectivesExamDialog : DialogFragment() {
|
||||
companion object {
|
||||
var objective: Objective? = null
|
||||
}
|
||||
|
||||
var currentTask = 0
|
||||
|
||||
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?,
|
||||
|
@ -23,20 +31,31 @@ class ObjectivesExamDialog : DialogFragment() {
|
|||
currentTask = bundle.getInt("currentTask", 0)
|
||||
}
|
||||
|
||||
dialog.setCanceledOnTouchOutside(false)
|
||||
return inflater.inflate(R.layout.objectives_exam_fragment, container, false)
|
||||
}
|
||||
|
||||
override fun onStart() {
|
||||
super.onStart()
|
||||
dialog.setCanceledOnTouchOutside(false)
|
||||
dialog.window?.setLayout(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
|
||||
}
|
||||
|
||||
override fun onResume() {
|
||||
super.onResume()
|
||||
updateGui()
|
||||
}
|
||||
|
||||
override fun onSaveInstanceState(bundle: Bundle) {
|
||||
super.onSaveInstanceState(bundle)
|
||||
bundle.putInt("currentTask", currentTask)
|
||||
}
|
||||
|
||||
fun updateGui() {
|
||||
objective?.let { objective ->
|
||||
val task: ExamTask = objective.tasks[currentTask] as ExamTask
|
||||
objectives_exam_name.setText(task.task)
|
||||
objectives_exam_question.setText(task.question)
|
||||
// Options
|
||||
objectives_exam_options.removeAllViews()
|
||||
for (o in task.options) {
|
||||
val option: Option = o as Option;
|
||||
|
@ -48,11 +67,17 @@ class ObjectivesExamDialog : DialogFragment() {
|
|||
}
|
||||
objectives_exam_options.addView(cb)
|
||||
}
|
||||
// Hints
|
||||
objectives_exam_hints.removeAllViews()
|
||||
for (h in task.hints) {
|
||||
val hint: Hint = h as Hint;
|
||||
objectives_exam_hints.addView(hint.generate(context))
|
||||
}
|
||||
// Disabled to
|
||||
objectives_exam_disabledto.text = MainApp.gs(R.string.answerdisabledto, DateUtil.timeString(task.disabledTo))
|
||||
objectives_exam_disabledto.visibility = if (task.isEnabledAnswer) View.GONE else View.VISIBLE
|
||||
// Buttons
|
||||
objectives_exam_verify.isEnabled = !task.answered && task.isEnabledAnswer
|
||||
objectives_exam_verify.setOnClickListener {
|
||||
var result = true
|
||||
for (o in task.options) {
|
||||
|
@ -60,18 +85,48 @@ class ObjectivesExamDialog : DialogFragment() {
|
|||
result = result && option.evaluate()
|
||||
}
|
||||
task.setAnswered(result);
|
||||
if (!result) {
|
||||
task.disabledTo = DateUtil.now() + T.hours(1).msecs()
|
||||
ToastUtils.showToastInUiThread(context, R.string.wronganswer)
|
||||
} else task.disabledTo = 0
|
||||
updateGui()
|
||||
RxBus.send(EventObjectivesUpdateGui())
|
||||
}
|
||||
cancel.setOnClickListener { dismiss() }
|
||||
close.setOnClickListener { dismiss() }
|
||||
objectives_exam_reset.setOnClickListener {
|
||||
task.answered = false
|
||||
//task.disabledTo = 0
|
||||
updateGui()
|
||||
RxBus.send(EventObjectivesUpdateGui())
|
||||
}
|
||||
objectives_back_button.isEnabled = currentTask != 0
|
||||
objectives_back_button.setOnClickListener {
|
||||
currentTask--
|
||||
updateGui()
|
||||
}
|
||||
objectives_next_button.isEnabled = currentTask != objective.tasks.size - 1
|
||||
objectives_next_button.setOnClickListener {
|
||||
currentTask++
|
||||
updateGui()
|
||||
}
|
||||
|
||||
objectives_next_unanswered_button.isEnabled = !objective.isCompleted
|
||||
objectives_next_unanswered_button.setOnClickListener {
|
||||
for (i in (currentTask + 1)..(objective.tasks.size - 1)) {
|
||||
if (!objective.tasks[i].isCompleted) {
|
||||
currentTask = i
|
||||
updateGui()
|
||||
return@setOnClickListener
|
||||
}
|
||||
}
|
||||
for (i in 0..currentTask) {
|
||||
if (!objective.tasks[i].isCompleted) {
|
||||
currentTask = i
|
||||
updateGui()
|
||||
return@setOnClickListener
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override fun onSaveInstanceState(bundle: Bundle) {
|
||||
super.onSaveInstanceState(bundle)
|
||||
bundle.putInt("currentTask", currentTask)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,5 @@
|
|||
package info.nightscout.androidaps.plugins.constraints.objectives.events
|
||||
|
||||
import info.nightscout.androidaps.events.EventUpdateGui
|
||||
|
||||
class EventObjectivesUpdateGui : EventUpdateGui()
|
|
@ -14,6 +14,7 @@ import java.util.List;
|
|||
|
||||
import info.nightscout.androidaps.MainApp;
|
||||
import info.nightscout.androidaps.R;
|
||||
import info.nightscout.androidaps.utils.DateUtil;
|
||||
import info.nightscout.androidaps.utils.SP;
|
||||
import info.nightscout.androidaps.utils.T;
|
||||
|
||||
|
@ -160,12 +161,27 @@ public abstract class Objective {
|
|||
List options = new ArrayList<>();
|
||||
private String spIdentifier;
|
||||
private boolean answered;
|
||||
private long disabledTo;
|
||||
|
||||
ExamTask(@StringRes int task, @StringRes int question, String spIdentifier) {
|
||||
super(task);
|
||||
this.question = question;
|
||||
this.spIdentifier = spIdentifier;
|
||||
answered = SP.getBoolean("ExamTask_" + spIdentifier, false);
|
||||
disabledTo = SP.getLong("DisabledTo_" + spIdentifier, 0L);
|
||||
}
|
||||
|
||||
public void setDisabledTo(long newState) {
|
||||
disabledTo = newState;
|
||||
SP.putLong("DisabledTo_" + spIdentifier, disabledTo);
|
||||
}
|
||||
|
||||
public long getDisabledTo() {
|
||||
return disabledTo;
|
||||
}
|
||||
|
||||
public boolean isEnabledAnswer() {
|
||||
return disabledTo < DateUtil.now();
|
||||
}
|
||||
|
||||
public void setAnswered(boolean newState) {
|
||||
|
|
|
@ -3,9 +3,6 @@ package info.nightscout.androidaps.plugins.constraints.objectives.objectives;
|
|||
import java.util.List;
|
||||
|
||||
import info.nightscout.androidaps.R;
|
||||
import info.nightscout.androidaps.interfaces.PluginType;
|
||||
import info.nightscout.androidaps.plugins.general.actions.ActionsPlugin;
|
||||
import info.nightscout.androidaps.utils.SP;
|
||||
|
||||
public class Objective2 extends Objective {
|
||||
|
||||
|
@ -16,12 +13,25 @@ public class Objective2 extends Objective {
|
|||
|
||||
@Override
|
||||
protected void setupTasks(List<Task> tasks) {
|
||||
tasks.add(new ExamTask(R.string.meaningofdia, R.string.whatmeansdia,"dia")
|
||||
.option(new Option(R.string.minimumis3h, false))
|
||||
.option(new Option(R.string.minimumis5h, true))
|
||||
.option(new Option(R.string.meaningisequaltodiapump, false))
|
||||
.option(new Option(R.string.valuemustbedetermined, true))
|
||||
.hint(new Hint(R.string.diahint1))
|
||||
tasks.add(new ExamTask(R.string.dia_meaningofdia, R.string.dia_whatmeansdia,"dia")
|
||||
.option(new Option(R.string.dia_minimumis3h, false))
|
||||
.option(new Option(R.string.dia_minimumis5h, true))
|
||||
.option(new Option(R.string.dia_meaningisequaltodiapump, false))
|
||||
.option(new Option(R.string.dia_valuemustbedetermined, true))
|
||||
.hint(new Hint(R.string.dia_hint1))
|
||||
);
|
||||
tasks.add(new ExamTask(R.string.hypott, R.string.hypott_whenhypott,"hypott")
|
||||
.option(new Option(R.string.hypott_goinglow, true))
|
||||
.option(new Option(R.string.hypott_havinglow, true))
|
||||
.option(new Option(R.string.hypott_notlowanymorebutrising, false))
|
||||
.option(new Option(R.string.hypott_havehadalowbg, false))
|
||||
.hint(new Hint(R.string.hypott_hint1))
|
||||
);
|
||||
tasks.add(new ExamTask(R.string.offlineprofile, R.string.offlineprofile_whatprofile,"offlineprofile")
|
||||
.option(new Option(R.string.localprofile, true))
|
||||
.option(new Option(R.string.nsprofile, false))
|
||||
.option(new Option(R.string.offlineprofile_nsprofile, true))
|
||||
.hint(new Hint(R.string.offlineprofile_hint1))
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -84,14 +84,13 @@ class EventListAdapter extends RecyclerView.Adapter<EventListAdapter.ViewHolder>
|
|||
// enabled event
|
||||
holder.enabled.setOnCheckedChangeListener((buttonView, isChecked) -> {
|
||||
event.setEnabled(isChecked);
|
||||
notifyDataSetChanged();
|
||||
RxBus.INSTANCE.send(new EventAutomationDataChanged());
|
||||
});
|
||||
|
||||
// remove event
|
||||
holder.iconTrash.setOnClickListener(v -> {
|
||||
mEventList.remove(event);
|
||||
notifyDataSetChanged();
|
||||
RxBus.INSTANCE.send(new EventAutomationDataChanged());
|
||||
});
|
||||
|
||||
// edit event
|
||||
|
|
|
@ -71,7 +71,7 @@ public class ActionStartTempTarget extends Action {
|
|||
int unitResId = value.getUnits().equals(Constants.MGDL) ? R.string.mgdl : R.string.mmol;
|
||||
|
||||
new LayoutBuilder()
|
||||
.add(new LabelWithElement(MainApp.gs(R.string.careportal_temporarytarget), MainApp.gs(unitResId), value))
|
||||
.add(new LabelWithElement(MainApp.gs(R.string.careportal_temporarytarget) + " [" + MainApp.gs(unitResId) + "]", "", value))
|
||||
.add(new LabelWithElement(MainApp.gs(R.string.careportal_newnstreatment_duration_min_label), "", duration))
|
||||
.build(root);
|
||||
}
|
||||
|
|
|
@ -25,8 +25,8 @@ public class InputDouble extends Element {
|
|||
};
|
||||
|
||||
private double value;
|
||||
double minValue;
|
||||
double maxValue;
|
||||
private double minValue;
|
||||
private double maxValue;
|
||||
private double step;
|
||||
private DecimalFormat decimalFormat;
|
||||
|
||||
|
|
|
@ -20,6 +20,11 @@ public class InputDuration extends Element {
|
|||
this.value = value;
|
||||
}
|
||||
|
||||
public InputDuration(InputDuration another) {
|
||||
unit = another.unit;
|
||||
value = another.value;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addToLayout(LinearLayout root) {
|
||||
NumberPicker numberPicker = new NumberPicker(root.getContext(), null);
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
package info.nightscout.androidaps.plugins.general.automation.elements;
|
||||
|
||||
import android.text.Editable;
|
||||
import android.text.TextWatcher;
|
||||
import android.widget.LinearLayout;
|
||||
|
||||
import java.text.DecimalFormat;
|
||||
|
@ -17,6 +19,22 @@ public class InputTempTarget extends Element {
|
|||
private double step;
|
||||
private DecimalFormat decimalFormat;
|
||||
|
||||
private final TextWatcher textWatcher = new TextWatcher() {
|
||||
@Override
|
||||
public void afterTextChanged(Editable s) {
|
||||
value = Math.max(minValue, value);
|
||||
value = Math.min(maxValue, value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onTextChanged(CharSequence s, int start, int before, int count) {
|
||||
}
|
||||
};
|
||||
|
||||
public InputTempTarget() {
|
||||
super();
|
||||
setUnits(ProfileFunctions.getInstance().getProfileUnits());
|
||||
|
@ -36,7 +54,7 @@ public class InputTempTarget extends Element {
|
|||
@Override
|
||||
public void addToLayout(LinearLayout root) {
|
||||
NumberPicker numberPicker = new NumberPicker(root.getContext(), null);
|
||||
numberPicker.setParams(value, minValue, maxValue, step, decimalFormat, true, null, null);
|
||||
numberPicker.setParams(value, minValue, maxValue, step, decimalFormat, true, null, textWatcher);
|
||||
numberPicker.setOnValueChangedListener(value -> this.value = value);
|
||||
root.addView(numberPicker);
|
||||
}
|
||||
|
|
|
@ -3,6 +3,7 @@ package info.nightscout.androidaps.plugins.general.automation.elements;
|
|||
import android.graphics.Typeface;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.TableLayout;
|
||||
import android.widget.TextView;
|
||||
|
||||
import info.nightscout.androidaps.MainApp;
|
||||
|
@ -37,6 +38,10 @@ public class LabelWithElement extends Element {
|
|||
textViewPre.setTypeface(textViewPre.getTypeface(), Typeface.BOLD);
|
||||
layout.addView(textViewPre);
|
||||
|
||||
TextView spacer = new TextView(root.getContext());
|
||||
spacer.setLayoutParams(new TableLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT, 1f));
|
||||
layout.addView(spacer);
|
||||
|
||||
// add element to layout
|
||||
element.addToLayout(layout);
|
||||
|
||||
|
|
|
@ -11,8 +11,6 @@ import org.json.JSONObject;
|
|||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.text.DecimalFormat;
|
||||
|
||||
import info.nightscout.androidaps.MainApp;
|
||||
import info.nightscout.androidaps.R;
|
||||
import info.nightscout.androidaps.logging.L;
|
||||
|
@ -28,9 +26,7 @@ import info.nightscout.androidaps.utils.T;
|
|||
|
||||
public class TriggerBolusAgo extends Trigger {
|
||||
private static Logger log = LoggerFactory.getLogger(L.AUTOMATION);
|
||||
private final double step = 1;
|
||||
private DecimalFormat decimalFormat = new DecimalFormat("1");
|
||||
public InputDuration minutesAgo = new InputDuration(0, InputDuration.TimeUnit.MINUTES);
|
||||
private InputDuration minutesAgo = new InputDuration(0, InputDuration.TimeUnit.MINUTES);
|
||||
private Comparator comparator = new Comparator();
|
||||
|
||||
public TriggerBolusAgo() {
|
||||
|
@ -39,7 +35,7 @@ public class TriggerBolusAgo extends Trigger {
|
|||
|
||||
private TriggerBolusAgo(TriggerBolusAgo triggerBolusAgo) {
|
||||
super();
|
||||
minutesAgo = new InputDuration(triggerBolusAgo.minutesAgo.getMinutes(), InputDuration.TimeUnit.MINUTES);
|
||||
minutesAgo = new InputDuration(triggerBolusAgo.minutesAgo);
|
||||
lastRun = triggerBolusAgo.lastRun;
|
||||
comparator = new Comparator(triggerBolusAgo.comparator);
|
||||
}
|
||||
|
|
|
@ -32,10 +32,8 @@ import info.nightscout.androidaps.utils.T;
|
|||
public class TriggerCOB extends Trigger {
|
||||
private static Logger log = LoggerFactory.getLogger(L.AUTOMATION);
|
||||
private final int minValue = 0;
|
||||
private final int maxValue = (int) (SP.getInt(R.string.key_treatmentssafety_maxcarbs, 48));
|
||||
private final double step = 1;
|
||||
private DecimalFormat decimalFormat = new DecimalFormat("1");
|
||||
private InputDouble value = new InputDouble(0, (double) minValue, (double) maxValue, step, decimalFormat);
|
||||
private final int maxValue = SP.getInt(R.string.key_treatmentssafety_maxcarbs, 48);
|
||||
private InputDouble value = new InputDouble(0, (double) minValue, (double) maxValue, 1, new DecimalFormat("1"));
|
||||
private Comparator comparator = new Comparator();
|
||||
|
||||
public TriggerCOB() {
|
||||
|
|
|
@ -51,10 +51,11 @@ public class TriggerDelta extends Trigger {
|
|||
|
||||
private TriggerDelta(TriggerDelta triggerDelta) {
|
||||
super();
|
||||
this.units = ProfileFunctions.getInstance().getProfileUnits();
|
||||
initializer();
|
||||
value = triggerDelta.value;
|
||||
lastRun = triggerDelta.lastRun;
|
||||
this.units = triggerDelta.units;
|
||||
deltaType = triggerDelta.deltaType;
|
||||
value = new InputDelta(triggerDelta.value);
|
||||
comparator = new Comparator(triggerDelta.comparator);
|
||||
}
|
||||
|
||||
public double getValue() {
|
||||
|
@ -68,7 +69,7 @@ public class TriggerDelta extends Trigger {
|
|||
if (units.equals(Constants.MMOL))
|
||||
value = new InputDelta(0, -MMOL_MAX, MMOL_MAX, 0.1d, new DecimalFormat("0.1"), DeltaType.DELTA);
|
||||
else
|
||||
value = new InputDelta(0, -MGDL_MAX, MGDL_MAX, 0.1d, new DecimalFormat("1"), DeltaType.DELTA);
|
||||
value = new InputDelta(0, -MGDL_MAX, MGDL_MAX, 1d, new DecimalFormat("1"), DeltaType.DELTA);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -51,10 +51,11 @@ public class TriggerLocation extends Trigger {
|
|||
|
||||
private TriggerLocation(TriggerLocation triggerLocation) {
|
||||
super();
|
||||
latitude = new InputDouble(triggerLocation.latitude.getValue(), -90d, +90d, 0.00001d, new DecimalFormat("0.00000"));
|
||||
longitude = new InputDouble(triggerLocation.longitude.getValue(), -180d, +180d, 0.00001d, new DecimalFormat("0.00000"));
|
||||
distance = new InputDouble(200d, 0, 100000, 10d, new DecimalFormat("0"));
|
||||
latitude = new InputDouble(triggerLocation.latitude);
|
||||
longitude = new InputDouble(triggerLocation.longitude);
|
||||
distance = new InputDouble(triggerLocation.distance);
|
||||
lastRun = triggerLocation.lastRun;
|
||||
name = triggerLocation.name;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -4,12 +4,12 @@
|
|||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:padding="15dp"
|
||||
tools:context=".plugins.constraints.objectives.activities.ObjectivesExamDialog">
|
||||
|
||||
<androidx.constraintlayout.widget.ConstraintLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content">
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_margin="10dp">
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/objectives_exam_options"
|
||||
|
@ -27,24 +27,20 @@
|
|||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="16dp"
|
||||
android:layout_marginBottom="10dp"
|
||||
android:orientation="vertical"
|
||||
app:layout_constraintTop_toBottomOf="@+id/objectives_exam_options"
|
||||
tools:layout_editor_absoluteX="3dp">
|
||||
|
||||
</LinearLayout>
|
||||
tools:layout_editor_absoluteX="3dp" />
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/objectives_buttons"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="8dp"
|
||||
android:background="#3C3C3C"
|
||||
android:orientation="horizontal"
|
||||
app:layout_constraintTop_toBottomOf="@+id/objectives_exam_hints">
|
||||
|
||||
<Button
|
||||
android:id="@+id/cancel"
|
||||
style="@style/Widget.AppCompat.Button.Borderless.Colored"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/cancel" />
|
||||
android:padding="4dp"
|
||||
app:layout_constraintTop_toBottomOf="@+id/objectives_exam_disabledto">
|
||||
|
||||
<Button
|
||||
android:id="@+id/objectives_exam_reset"
|
||||
|
@ -53,12 +49,26 @@
|
|||
android:layout_height="wrap_content"
|
||||
android:text="@string/reset" />
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:text="" />
|
||||
|
||||
<Button
|
||||
android:id="@+id/close"
|
||||
style="@style/Widget.AppCompat.Button.Borderless.Colored"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/close" />
|
||||
|
||||
<Button
|
||||
android:id="@+id/objectives_exam_verify"
|
||||
style="@style/Widget.AppCompat.Button.Borderless.Colored"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/objectives_button_verify" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<TextView
|
||||
|
@ -69,17 +79,69 @@
|
|||
android:text="Question"
|
||||
android:textAppearance="@style/TextAppearance.AppCompat.Medium"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@+id/objectives_exam_name" />
|
||||
app:layout_constraintTop_toBottomOf="@id/objectives_exam_name" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/objectives_exam_name"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="Name"
|
||||
android:textAppearance="@style/TextAppearance.AppCompat.Large"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/objectives_exam_disabledto"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="8dp"
|
||||
android:text="Disabled to:"
|
||||
android:textColor="#FF5722"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@+id/objectives_exam_hints" />
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/objectives_navigation"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="2dp"
|
||||
android:background="#3C3C3C"
|
||||
android:orientation="horizontal"
|
||||
android:padding="4dp"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@+id/objectives_buttons">
|
||||
|
||||
<Button
|
||||
android:id="@+id/objectives_back_button"
|
||||
style="@style/Widget.AppCompat.Button.Borderless.Colored"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/previous_button" />
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:text="" />
|
||||
|
||||
<Button
|
||||
android:id="@+id/objectives_next_button"
|
||||
style="@style/Widget.AppCompat.Button.Borderless.Colored"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/next_button" />
|
||||
|
||||
<Button
|
||||
android:id="@+id/objectives_next_unanswered_button"
|
||||
style="@style/Widget.AppCompat.Button.Borderless.Colored"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/unfinshed_button" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
|
||||
</ScrollView>
|
||||
|
|
|
@ -80,6 +80,12 @@
|
|||
android:layout_height="wrap_content"
|
||||
android:text="@string/enter_code_obtained_from_developers_to_bypass_the_rest_of_objectives" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/objective_requestcode"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="Request code: XXXXX" />
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
|
|
|
@ -1,11 +1,23 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
<string name="whatmeansdia">What is true about DIA?</string>
|
||||
<string name="meaningofdia">Meaning of DIA</string>
|
||||
<string name="minimumis3h">minimum is 3 hours</string>
|
||||
<string name="minimumis5h">minimum is 5 hours</string>
|
||||
<string name="diahint1">https://androidaps.readthedocs.io/en/latest/CROWDIN/he/Configuration/Config-Builder.html?#insulin</string>
|
||||
<string name="meaningisequaltodiapump">meaning is equal to DIA parameter used in pumps</string>
|
||||
<string name="valuemustbedetermined">correct value must be determined</string>
|
||||
<string name="dia_whatmeansdia">What is true about DIA?</string>
|
||||
<string name="dia_meaningofdia">Meaning of DIA</string>
|
||||
<string name="dia_minimumis3h">minimum is 3 hours</string>
|
||||
<string name="dia_minimumis5h">minimum is 5 hours</string>
|
||||
<string name="dia_hint1">https://androidaps.readthedocs.io/en/latest/EN/Configuration/Config-Builder.html?#insulin</string>
|
||||
<string name="dia_meaningisequaltodiapump">meaning is equal to DIA parameter used in pumps</string>
|
||||
<string name="dia_valuemustbedetermined">correct value must be determined</string>
|
||||
<string name="hypott">Hypo temp target</string>
|
||||
<string name="hypott_whenhypott">When should you do a hypo TT?</string>
|
||||
<string name="hypott_goinglow">you are going low</string>
|
||||
<string name="hypott_havinglow">your already have a low bg</string>
|
||||
<string name="hypott_notlowanymorebutrising">your not low anymore, but your BG is rising because of the (right!) amount of hypo treatments</string>
|
||||
<string name="hypott_bgisrising">your bg is rising, has just reached the target BG but there is still too much IOB left</string>
|
||||
<string name="hypott_havehadalowbg">you have had a low bg a while ago, but it got you in a hyper</string>
|
||||
<string name="hypott_hint1">https://androidaps.readthedocs.io/en/latest/EN/Usage/temptarget.html</string>
|
||||
<string name="offlineprofile_whatprofile">Which profile can be used and configured offline</string>
|
||||
<string name="offlineprofile">Offline profile</string>
|
||||
<string name="offlineprofile_nsprofile">NS Profile can be used but not configured</string>
|
||||
<string name="offlineprofile_hint1">https://androidaps.readthedocs.io/en/latest/EN/Configuration/Config-Builder.html#profile</string>
|
||||
|
||||
</resources>
|
||||
|
|
|
@ -1631,6 +1631,12 @@
|
|||
<string name="key_ObjectivesmanualEnacts" translatable="false">ObjectivesmanualEnacts</string>
|
||||
<string name="objectives_exam_objective">Prove your knowledge</string>
|
||||
<string name="objectives_exam_gate">Study and answer questions correctly</string>
|
||||
<string name="answerdisabledto">Answering disabled to: %1$s</string>
|
||||
<string name="wronganswer">Wrong answer!</string>
|
||||
<string name="unfinshed_button">Next unfinished</string>
|
||||
<string name="close">Close</string>
|
||||
<string name="key_objectives_request_code" translatable="false">objectives_request_code</string>
|
||||
<string name="requestcode">Request code: %1$s</string>
|
||||
|
||||
<plurals name="objective_days">
|
||||
<item quantity="one">%1$d day</item>
|
||||
|
|
Loading…
Reference in a new issue