objectives: links for another tasks

This commit is contained in:
Milos Kozak 2019-09-25 14:33:23 +02:00
parent be13b5f39e
commit 4d9088b63e
6 changed files with 105 additions and 90 deletions

View file

@ -168,10 +168,17 @@ class ObjectivesFragment : Fragment() {
holder.progress.removeAllViews() holder.progress.removeAllViews()
for (task in objective.tasks) { for (task in objective.tasks) {
if (task.shouldBeIgnored()) continue if (task.shouldBeIgnored()) continue
// name
val name = TextView(holder.progress.context) val name = TextView(holder.progress.context)
name.text = MainApp.gs(task.task) + ":" name.text = MainApp.gs(task.task) + ":"
name.setTextColor(-0x1) name.setTextColor(-0x1)
holder.progress.addView(name, LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT) holder.progress.addView(name, LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT)
// hint
task.hints.forEach { h ->
if (!task.isCompleted)
holder.progress.addView(h.generate(context))
}
// state
val state = TextView(holder.progress.context) val state = TextView(holder.progress.context)
state.setTextColor(-0x1) state.setTextColor(-0x1)
val basicHTML = "<font color=\"%1\$s\"><b>%2\$s</b></font>" val basicHTML = "<font color=\"%1\$s\"><b>%2\$s</b></font>"
@ -183,13 +190,14 @@ class ObjectivesFragment : Fragment() {
state.setOnClickListener { state.setOnClickListener {
val dialog = ObjectivesExamDialog() val dialog = ObjectivesExamDialog()
val bundle = Bundle() val bundle = Bundle()
val position = objective.tasks.indexOf(task) val taskPosition = objective.tasks.indexOf(task)
bundle.putInt("currentTask", position) bundle.putInt("currentTask", taskPosition)
dialog.arguments = bundle dialog.arguments = bundle
ObjectivesExamDialog.objective = objective ObjectivesExamDialog.objective = objective
fragmentManager?.let { dialog.show(it, "ObjectivesFragment") } fragmentManager?.let { dialog.show(it, "ObjectivesFragment") }
} }
} }
// horizontal line
val separator = View(holder.progress.context) val separator = View(holder.progress.context)
separator.setBackgroundColor(Color.DKGRAY) separator.setBackgroundColor(Color.DKGRAY)
holder.progress.addView(separator, LinearLayout.LayoutParams.MATCH_PARENT, 2) holder.progress.addView(separator, LinearLayout.LayoutParams.MATCH_PARENT, 2)

View file

@ -70,8 +70,7 @@ class ObjectivesExamDialog : DialogFragment() {
// Hints // Hints
objectives_exam_hints.removeAllViews() objectives_exam_hints.removeAllViews()
for (h in task.hints) { for (h in task.hints) {
val hint: Hint = h as Hint; objectives_exam_hints.addView(h.generate(context))
objectives_exam_hints.addView(hint.generate(context))
} }
// Disabled to // Disabled to
objectives_exam_disabledto.text = MainApp.gs(R.string.answerdisabledto, DateUtil.timeString(task.disabledTo)) objectives_exam_disabledto.text = MainApp.gs(R.string.answerdisabledto, DateUtil.timeString(task.disabledTo))

View file

@ -100,6 +100,7 @@ public abstract class Objective {
@StringRes @StringRes
private int task; private int task;
private Objective objective; private Objective objective;
ArrayList<Hint> hints = new ArrayList<>();
public Task(@StringRes int task) { public Task(@StringRes int task) {
this.task = task; this.task = task;
@ -119,6 +120,15 @@ public abstract class Objective {
return MainApp.gs(isCompleted() ? R.string.completed_well_done : R.string.not_completed_yet); return MainApp.gs(isCompleted() ? R.string.completed_well_done : R.string.not_completed_yet);
} }
Task hint(Hint hint) {
hints.add(hint);
return this;
}
public ArrayList<Hint> getHints() {
return hints;
}
public boolean shouldBeIgnored() { public boolean shouldBeIgnored() {
return false; return false;
} }
@ -157,8 +167,7 @@ public abstract class Objective {
public class ExamTask extends Task { public class ExamTask extends Task {
@StringRes @StringRes
int question; int question;
List hints = new ArrayList<>(); ArrayList<Option> options = new ArrayList<>();
List options = new ArrayList<>();
private String spIdentifier; private String spIdentifier;
private boolean answered; private boolean answered;
private long disabledTo; private long disabledTo;
@ -198,11 +207,6 @@ public abstract class Objective {
return this; return this;
} }
ExamTask hint(Hint hint) {
hints.add(hint);
return this;
}
public @StringRes int getQuestion() { public @StringRes int getQuestion() {
return question; return question;
} }
@ -211,10 +215,6 @@ public abstract class Objective {
return options; return options;
} }
public List getHints() {
return hints;
}
@Override @Override
public boolean isCompleted() { public boolean isCompleted() {
return answered; return answered;

View file

@ -4,7 +4,6 @@ import java.util.List;
import info.nightscout.androidaps.R; import info.nightscout.androidaps.R;
import info.nightscout.androidaps.interfaces.PluginType; import info.nightscout.androidaps.interfaces.PluginType;
import info.nightscout.androidaps.plugins.constraints.objectives.ObjectivesPlugin;
import info.nightscout.androidaps.plugins.general.actions.ActionsPlugin; import info.nightscout.androidaps.plugins.general.actions.ActionsPlugin;
import info.nightscout.androidaps.utils.SP; import info.nightscout.androidaps.utils.SP;
@ -28,36 +27,36 @@ public class Objective1 extends Objective {
public boolean isCompleted() { public boolean isCompleted() {
return SP.getBoolean(R.string.key_objectiveusedisconnect, false); return SP.getBoolean(R.string.key_objectiveusedisconnect, false);
} }
}); }.hint(new Hint(R.string.disconnectpump_hint)));
tasks.add(new Task(R.string.objectives_usereconnectpump) { tasks.add(new Task(R.string.objectives_usereconnectpump) {
@Override @Override
public boolean isCompleted() { public boolean isCompleted() {
return SP.getBoolean(R.string.key_objectiveusereconnect, false); return SP.getBoolean(R.string.key_objectiveusereconnect, false);
} }
}); }.hint(new Hint(R.string.disconnectpump_hint)));
tasks.add(new Task(R.string.objectives_usetemptarget) { tasks.add(new Task(R.string.objectives_usetemptarget) {
@Override @Override
public boolean isCompleted() { public boolean isCompleted() {
return SP.getBoolean(R.string.key_objectiveusetemptarget, false); return SP.getBoolean(R.string.key_objectiveusetemptarget, false);
} }
}); }.hint(new Hint(R.string.usetemptarget_hint)));
tasks.add(new Task(R.string.objectives_useactions) { tasks.add(new Task(R.string.objectives_useactions) {
@Override @Override
public boolean isCompleted() { public boolean isCompleted() {
return SP.getBoolean(R.string.key_objectiveuseactions, false) && ActionsPlugin.INSTANCE.isEnabled(PluginType.GENERAL) && ActionsPlugin.INSTANCE.isFragmentVisible(); return SP.getBoolean(R.string.key_objectiveuseactions, false) && ActionsPlugin.INSTANCE.isEnabled(PluginType.GENERAL) && ActionsPlugin.INSTANCE.isFragmentVisible();
} }
}); }.hint(new Hint(R.string.useaction_hint)));
tasks.add(new Task(R.string.objectives_useloop) { tasks.add(new Task(R.string.objectives_useloop) {
@Override @Override
public boolean isCompleted() { public boolean isCompleted() {
return SP.getBoolean(R.string.key_objectiveuseloop, false); return SP.getBoolean(R.string.key_objectiveuseloop, false);
} }
}); }.hint(new Hint(R.string.useaction_hint)));
tasks.add(new Task(R.string.objectives_usescale) { tasks.add(new Task(R.string.objectives_usescale) {
@Override @Override
public boolean isCompleted() { public boolean isCompleted() {
return SP.getBoolean(R.string.key_objectiveusescale, false); return SP.getBoolean(R.string.key_objectiveusescale, false);
} }
}); }.hint(new Hint(R.string.usescale_hint)));
} }
} }

View file

@ -0,0 +1,77 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="key_objectiveuseprofileswitch" translatable="false">ObjectivesProfileSwitchUsed</string>
<string name="key_objectiveusedisconnect" translatable="false">ObjectivesDisconnectUsed</string>
<string name="key_objectiveusereconnect" translatable="false">ObjectivesReconnectUsed</string>
<string name="key_objectiveusetemptarget" translatable="false">ObjectivesTempTargetUsed</string>
<string name="key_objectiveuseactions" translatable="false">ObjectivesActionsUsed</string>
<string name="key_objectiveuseloop" translatable="false">ObjectivesLoopUsed</string>
<string name="key_objectiveusescale" translatable="false">ObjectivesScaleUsed</string>
<string name="key_objectives_request_code" translatable="false">objectives_request_code</string>
<string name="key_ObjectivesbgIsAvailableInNS" translatable="false">ObjectivesbgIsAvailableInNS</string>
<string name="key_ObjectivespumpStatusIsAvailableInNS" translatable="false">ObjectivespumpStatusIsAvailableInNS</string>
<string name="key_ObjectivesmanualEnacts" translatable="false">ObjectivesmanualEnacts</string>
<string name="objectives_button_back">Back</string>
<string name="objectives_button_start">Start</string>
<string name="objectives_button_verify">Verify</string>
<string name="nth_objective">%1$d. Objective</string>
<string name="objectivenotstarted">Objective %1$d not started</string>
<string name="objectivenotfinished">Objective %1$d not finished</string>
<string name="objectives_0_objective">Setting up visualization and monitoring, and analyzing basals and ratios</string>
<string name="objectives_0_gate">Verify that BG is available in Nightscout, and pump insulin data is being uploaded</string>
<string name="objectives_openloop_objective">Starting on an open loop</string>
<string name="objectives_openloop_gate">Run in Open Loop mode for a few days and manually enact lots of temp basals. Set up and use temporary and default temporary targets (e.g. for activity or hypo treatment carbs)</string>
<string name="objectives_maxbasal_objective">Understanding your open loop, including its temp basal recommendations</string>
<string name="objectives_maxbasal_gate">Based on that experience, decide what max basal should be, and set it on the pump and preferences</string>
<string name="objectives_maxiobzero_objective">Starting to close the loop with Low Glucose Suspend</string>
<string name="objectives_maxiobzero_gate">Run in closed loop with max IOB = 0 for a few days without too many LGS events</string>
<string name="objectives_maxiob_objective">Tuning the closed loop, raising max IOB above 0 and gradually lowering BG targets</string>
<string name="objectives_maxiob_gate">Run for a few days, and at least one night with no low BG alarms, before dropping BG</string>
<string name="objectives_autosens_objective">Adjust basals and ratios if needed, and then enable auto-sens</string>
<string name="objectives_autosens_gate">1 week successful daytime looping with regular carb entry</string>
<string name="objectives_ama_objective">Enabling additional features for daytime use, such as advanced meal assist</string>
<string name="objectives_smb_objective">Enabling additional features for daytime use, such as SMB</string>
<string name="objectives_smb_gate">You must read the wiki and rise maxIOB to get SMBs working fine! A good start is maxIOB=average mealbolus + 3 x max daily basal</string>
<string name="objectives_bgavailableinns">BG available in NS</string>
<string name="objectives_pumpstatusavailableinns">Pump status available in NS</string>
<string name="objectives_manualenacts">Manual enacts</string>
<string name="accomplished">Accomplished: %1$s</string>
<string name="objectives_usage_objective">Learn how to control AndroidAPS</string>
<string name="objectives_usage_gate">Perform different actions in AndroidAPS</string>
<string name="objectives_useprofileswitch">Set profile 90% for 10 min (Long-press profile name on Overview)</string>
<string name="objectives_usedisconnectpump">Simulate shower. Disconnect pump for 1h (Long-press on Open Loop)</string>
<string name="objectives_usereconnectpump">... and reconnect back the same way</string>
<string name="objectives_usetemptarget">Create custom temporary target with 10 min duration (Long-press on your current target)</string>
<string name="objectives_useactions">In Config Builder enable Actions plugin, make it visible and display its content from top menu</string>
<string name="objectives_useloop">Display content of Loop plugin</string>
<string name="objectives_usescale">Use scale function by long-pressing BG chart</string>
<string name="objectives_button_enter">Enter</string>
<string name="enter_code_obtained_from_developers_to_bypass_the_rest_of_objectives">Enter code obtained from developers to bypass the rest of objectives</string>
<string name="codeaccepted">Code accepted</string>
<string name="codeinvalid">Code invalid</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="requestcode">Request code: %1$s</string>
<string name="objectives_hint">(check all correct answers)</string>
<string name="disconnectpump_hint">https://androidaps.readthedocs.io/en/latest/EN/Getting-Started/FAQ.html#what-to-do-when-taking-a-shower-or-bath</string>
<string name="usetemptarget_hint">https://androidaps.readthedocs.io/en/latest/EN/Getting-Started/Screenshots.html#the-homescreen</string>
<string name="useaction_hint">https://androidaps.readthedocs.io/en/latest/EN/Getting-Started/Screenshots.html#config-builder</string>
<string name="usescale_hint">https://androidaps.readthedocs.io/en/latest/EN/Getting-Started/Screenshots.html#the-homescreen</string>
<plurals name="objective_days">
<item quantity="one">%1$d day</item>
<item quantity="other">%1$d days</item>
</plurals>
<plurals name="objective_hours">
<item quantity="one">%1$d hour</item>
<item quantity="other">%1$d hours</item>
</plurals>
<plurals name="objective_minutes">
<item quantity="one">%1$d minute</item>
<item quantity="other">%1$d minutes</item>
</plurals>
</resources>

View file

@ -79,9 +79,6 @@
<string name="description_xdrip_status_line">Show information about your loop on your xDrip+ watchface.</string> <string name="description_xdrip_status_line">Show information about your loop on your xDrip+ watchface.</string>
<string name="description_sms_communicator">Remote control AndroidAPS using SMS commands.</string> <string name="description_sms_communicator">Remote control AndroidAPS using SMS commands.</string>
<string name="objectives_button_back">Back</string>
<string name="objectives_button_start">Start</string>
<string name="objectives_button_verify">Verify</string>
<string name="nsprofileview_units_label">Units</string> <string name="nsprofileview_units_label">Units</string>
<string name="nsprofileview_dia_label">DIA</string> <string name="nsprofileview_dia_label">DIA</string>
<string name="nsprofileview_ic_label">IC</string> <string name="nsprofileview_ic_label">IC</string>
@ -205,9 +202,6 @@
<string name="unsupportedclientver">Unsupported version of NSClient</string> <string name="unsupportedclientver">Unsupported version of NSClient</string>
<string name="unsupportednsversion">Unsupported version of Nightscout</string> <string name="unsupportednsversion">Unsupported version of Nightscout</string>
<string name="nsclientnotinstalled">NSClient not installed. Record lost!</string> <string name="nsclientnotinstalled">NSClient not installed. Record lost!</string>
<string name="objectives_bgavailableinns">BG available in NS</string>
<string name="objectives_pumpstatusavailableinns">Pump status available in NS</string>
<string name="objectives_manualenacts">Manual enacts</string>
<string name="loopdisabled">LOOP DISABLED BY CONSTRAINTS</string> <string name="loopdisabled">LOOP DISABLED BY CONSTRAINTS</string>
<string name="treatments_wizard_basaliob_label">Basal IOB</string> <string name="treatments_wizard_basaliob_label">Basal IOB</string>
<string name="bolusconstraintapplied">Bolus constraint applied</string> <string name="bolusconstraintapplied">Bolus constraint applied</string>
@ -348,21 +342,6 @@
<string name="overview_bolusprogress_stoppressed">STOP PRESSED</string> <string name="overview_bolusprogress_stoppressed">STOP PRESSED</string>
<string name="waitingforpump">Waiting for pump</string> <string name="waitingforpump">Waiting for pump</string>
<string name="overview_bolusprogress_goingtodeliver">Going to deliver %1$.2fU</string> <string name="overview_bolusprogress_goingtodeliver">Going to deliver %1$.2fU</string>
<string name="objectives_0_objective">Setting up visualization and monitoring, and analyzing basals and ratios</string>
<string name="objectives_0_gate">Verify that BG is available in Nightscout, and pump insulin data is being uploaded</string>
<string name="objectives_openloop_objective">Starting on an open loop</string>
<string name="objectives_openloop_gate">Run in Open Loop mode for a few days and manually enact lots of temp basals. Set up and use temporary and default temporary targets (e.g. for activity or hypo treatment carbs)</string>
<string name="objectives_maxbasal_objective">Understanding your open loop, including its temp basal recommendations</string>
<string name="objectives_maxbasal_gate">Based on that experience, decide what max basal should be, and set it on the pump and preferences</string>
<string name="objectives_maxiobzero_objective">Starting to close the loop with Low Glucose Suspend</string>
<string name="objectives_maxiobzero_gate">Run in closed loop with max IOB = 0 for a few days without too many LGS events</string>
<string name="objectives_maxiob_objective">Tuning the closed loop, raising max IOB above 0 and gradually lowering BG targets</string>
<string name="objectives_maxiob_gate">Run for a few days, and at least one night with no low BG alarms, before dropping BG</string>
<string name="objectives_autosens_objective">Adjust basals and ratios if needed, and then enable auto-sens</string>
<string name="objectives_autosens_gate">1 week successful daytime looping with regular carb entry</string>
<string name="objectives_ama_objective">Enabling additional features for daytime use, such as advanced meal assist</string>
<string name="objectives_smb_objective">Enabling additional features for daytime use, such as SMB</string>
<string name="objectives_smb_gate">You must read the wiki and rise maxIOB to get SMBs working fine! A good start is maxIOB=average mealbolus + 3 x max daily basal</string>
<string name="youareonallowedlimit">You reached allowed limit</string> <string name="youareonallowedlimit">You reached allowed limit</string>
<string name="noprofileselected">No profile selected</string> <string name="noprofileselected">No profile selected</string>
<string name="smscommunicator_loophasbeendisabled">Loop has been disabled</string> <string name="smscommunicator_loophasbeendisabled">Loop has been disabled</string>
@ -993,8 +972,6 @@
<string name="profileswitch_ismissing">ProfileSwitch missing. Please do a profile switch or press \"Activate Profile\" in the LocalProfile.</string> <string name="profileswitch_ismissing">ProfileSwitch missing. Please do a profile switch or press \"Activate Profile\" in the LocalProfile.</string>
<string name="combo_bolus_count">Bolus count</string> <string name="combo_bolus_count">Bolus count</string>
<string name="combo_tbr_count">TBR count</string> <string name="combo_tbr_count">TBR count</string>
<string name="objectivenotstarted">Objective %1$d not started</string>
<string name="objectivenotfinished">Objective %1$d not finished</string>
<string name="pumpisnottempbasalcapable">Pump is not temp basal capable</string> <string name="pumpisnottempbasalcapable">Pump is not temp basal capable</string>
<string name="novalidbasalrate">No valid basal rate read from pump</string> <string name="novalidbasalrate">No valid basal rate read from pump</string>
<string name="closedmodedisabledinpreferences">Closed loop mode disabled in preferences</string> <string name="closedmodedisabledinpreferences">Closed loop mode disabled in preferences</string>
@ -1142,7 +1119,6 @@
<string name="completed_well_done">Completed, well done!</string> <string name="completed_well_done">Completed, well done!</string>
<string name="not_completed_yet">Not completed yet</string> <string name="not_completed_yet">Not completed yet</string>
<string name="time_elapsed">Time elapsed</string> <string name="time_elapsed">Time elapsed</string>
<string name="nth_objective">%1$d. Objective</string>
<string name="poctech">Poctech</string> <string name="poctech">Poctech</string>
<string name="description_source_poctech">Receive BG values from Poctech app</string> <string name="description_source_poctech">Receive BG values from Poctech app</string>
<string name="description_source_tomato">Receive BG values from Tomato app (MiaoMiao device)</string> <string name="description_source_tomato">Receive BG values from Tomato app (MiaoMiao device)</string>
@ -1607,50 +1583,6 @@
<string name="deliverpartofboluswizard">Bolus wizard performs calculation but only this part of calculated insulin is delivered. Useful with SMB algorithm.</string> <string name="deliverpartofboluswizard">Bolus wizard performs calculation but only this part of calculated insulin is delivered. Useful with SMB algorithm.</string>
<string name="loading">Loading ...</string> <string name="loading">Loading ...</string>
<string name="snooze">Snooze</string> <string name="snooze">Snooze</string>
<string name="accomplished">Accomplished: %1$s</string>
<string name="objectives_usage_objective">Learn how to control AndroidAPS</string>
<string name="objectives_usage_gate">Perform different actions in AndroidAPS</string>
<string name="objectives_useprofileswitch">Set profile 90% for 10 min (Long-press profile name on Overview)</string>
<string name="key_objectiveuseprofileswitch" translatable="false">ObjectivesProfileSwitchUsed</string>
<string name="key_objectiveusedisconnect" translatable="false">ObjectivesDisconnectUsed</string>
<string name="key_objectiveusereconnect" translatable="false">ObjectivesReconnectUsed</string>
<string name="key_objectiveusetemptarget" translatable="false">ObjectivesTempTargetUsed</string>
<string name="key_objectiveuseactions" translatable="false">ObjectivesActionsUsed</string>
<string name="key_objectiveuseloop" translatable="false">ObjectivesLoopUsed</string>
<string name="key_objectiveusescale" translatable="false">ObjectivesScaleUsed</string>
<string name="objectives_usedisconnectpump">Simulate shower. Disconnect pump for 1h (Long-press on Open Loop)</string>
<string name="objectives_usereconnectpump">... and reconnect back the same way</string>
<string name="objectives_usetemptarget">Create custom temporary target with 10 min duration (Long-press on your current target)</string>
<string name="objectives_useactions">In Config Builder enable Actions plugin, make it visible and display its content from top menu</string>
<string name="objectives_useloop">Display content of Loop plugin</string>
<string name="objectives_usescale">Use scale function by long-pressing BG chart</string>
<string name="objectives_button_enter">Enter</string>
<string name="enter_code_obtained_from_developers_to_bypass_the_rest_of_objectives">Enter code obtained from developers to bypass the rest of objectives</string>
<string name="codeaccepted">Code accepted</string>
<string name="codeinvalid">Code invalid</string>
<string name="key_ObjectivesbgIsAvailableInNS" translatable="false">ObjectivesbgIsAvailableInNS</string>
<string name="key_ObjectivespumpStatusIsAvailableInNS" translatable="false">ObjectivespumpStatusIsAvailableInNS</string>
<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="close">Close</string>
<string name="key_objectives_request_code" translatable="false">objectives_request_code</string>
<string name="requestcode">Request code: %1$s</string>
<string name="objectives_hint">(check all correct answers)</string>
<plurals name="objective_days">
<item quantity="one">%1$d day</item>
<item quantity="other">%1$d days</item>
</plurals>
<plurals name="objective_hours">
<item quantity="one">%1$d hour</item>
<item quantity="other">%1$d hours</item>
</plurals>
<plurals name="objective_minutes">
<item quantity="one">%1$d minute</item>
<item quantity="other">%1$d minutes</item>
</plurals>
</resources> </resources>