Objectives styling

This commit is contained in:
TebbeUbben 2018-06-09 22:07:41 +02:00
parent ec5b0cc3f7
commit 005039effc
24 changed files with 625 additions and 596 deletions

View file

@ -5,6 +5,7 @@ import android.content.IntentFilter;
import android.content.res.Resources;
import android.os.SystemClock;
import android.support.annotation.Nullable;
import android.support.annotation.PluralsRes;
import android.support.v4.content.LocalBroadcastManager;
import com.crashlytics.android.Crashlytics;
@ -278,6 +279,10 @@ public class MainApp extends Application {
return sResources.getString(id, args);
}
public static String gq(@PluralsRes int id, int quantity, Object... args) {
return sResources.getQuantityString(id, quantity, args);
}
public static int gc(int id) {
return sResources.getColor(id);
}

View file

@ -4,12 +4,10 @@ import java.util.ArrayList;
import info.nightscout.androidaps.Constants;
import info.nightscout.androidaps.MainApp;
import info.nightscout.androidaps.interfaces.BgSourceInterface;
import info.nightscout.androidaps.interfaces.Constraint;
import info.nightscout.androidaps.interfaces.ConstraintsInterface;
import info.nightscout.androidaps.interfaces.PluginBase;
import info.nightscout.androidaps.interfaces.PluginType;
import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderPlugin;
/**
* Created by mike on 19.03.2018.
@ -25,7 +23,7 @@ public class ConstraintChecker implements ConstraintsInterface {
public Constraint<Boolean> isLoopInvokationAllowed() {
return isLoopInvokationAllowed(new Constraint<>(true));
return isLoopInvocationAllowed(new Constraint<>(true));
}
public Constraint<Boolean> isClosedLoopAllowed() {
@ -69,13 +67,13 @@ public class ConstraintChecker implements ConstraintsInterface {
}
@Override
public Constraint<Boolean> isLoopInvokationAllowed(Constraint<Boolean> value) {
public Constraint<Boolean> isLoopInvocationAllowed(Constraint<Boolean> value) {
ArrayList<PluginBase> constraintsPlugins = mainApp.getSpecificPluginsListByInterface(ConstraintsInterface.class);
for (PluginBase p : constraintsPlugins) {
ConstraintsInterface constraint = (ConstraintsInterface) p;
if (!p.isEnabled(PluginType.CONSTRAINTS)) continue;
constraint.isLoopInvokationAllowed(value);
constraint.isLoopInvocationAllowed(value);
}
return value;
}

View file

@ -7,7 +7,7 @@ import info.nightscout.androidaps.data.Profile;
*/
public interface ConstraintsInterface {
default Constraint<Boolean> isLoopInvokationAllowed(Constraint<Boolean> value) {
default Constraint<Boolean> isLoopInvocationAllowed(Constraint<Boolean> value) {
return value;
}

View file

@ -1,12 +1,13 @@
package info.nightscout.androidaps.plugins.ConstraintsObjectives;
import android.app.Activity;
import android.content.Context;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.support.annotation.NonNull;
import android.support.v4.content.ContextCompat;
import android.support.v7.widget.CardView;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.text.Html;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
@ -20,195 +21,20 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.Date;
import java.util.List;
import info.nightscout.androidaps.MainApp;
import info.nightscout.androidaps.R;
import info.nightscout.androidaps.plugins.Common.SubscriberFragment;
import info.nightscout.androidaps.plugins.ConstraintsObjectives.objectives.Objective;
import info.nightscout.utils.FabricPrivacy;
import info.nightscout.utils.T;
public class ObjectivesFragment extends SubscriberFragment {
private static Logger log = LoggerFactory.getLogger(ObjectivesFragment.class);
RecyclerView recyclerView;
LinearLayoutManager llm;
CheckBox enableFake;
LinearLayout fake_layout;
TextView reset;
public class RecyclerViewAdapter extends RecyclerView.Adapter<RecyclerViewAdapter.ObjectiveViewHolder> {
List<ObjectivesPlugin.Objective> objectives;
RecyclerViewAdapter(List<ObjectivesPlugin.Objective> objectives) {
this.objectives = objectives;
}
@Override
public ObjectiveViewHolder onCreateViewHolder(ViewGroup viewGroup, int viewType) {
View v = LayoutInflater.from(viewGroup.getContext()).inflate(R.layout.objectives_item, viewGroup, false);
return new ObjectiveViewHolder(v);
}
@Override
public void onBindViewHolder(ObjectiveViewHolder holder, int position) {
ObjectivesPlugin.Objective o = objectives.get(position);
ObjectivesPlugin.RequirementResult requirementsMet = ObjectivesPlugin.getPlugin().requirementsMet(position);
Context context = MainApp.instance().getApplicationContext();
holder.position.setText(String.valueOf(position + 1));
holder.objective.setText(o.objective);
holder.gate.setText(o.gate);
holder.duration.setText(MainApp.gs(R.string.objectives_minimalduration) + " " + o.durationInDays + " " + MainApp.gs(R.string.days));
holder.progress.setText(requirementsMet.comment);
holder.started.setText(o.started.toLocaleString());
holder.accomplished.setText(o.accomplished.toLocaleString());
holder.startButton.setTag(o);
holder.verifyButton.setTag(o);
holder.startButton.setOnClickListener(v -> {
ObjectivesPlugin.Objective o1 = (ObjectivesPlugin.Objective) v.getTag();
o1.started = new Date();
updateGUI();
ObjectivesPlugin.saveProgress();
});
holder.verifyButton.setOnClickListener(v -> {
ObjectivesPlugin.Objective o12 = (ObjectivesPlugin.Objective) v.getTag();
if (ObjectivesPlugin.getPlugin().requirementsMet(o12.num).done || enableFake.isChecked()) {
o12.accomplished = new Date();
updateGUI();
ObjectivesPlugin.saveProgress();
}
});
long prevObjectiveAccomplishedTime = position > 0 ?
objectives.get(position - 1).accomplished.getTime() : -1;
int phase = modifyVisibility(position, prevObjectiveAccomplishedTime,
o.started.getTime(), o.durationInDays,
o.accomplished.getTime(), requirementsMet.done, enableFake.isChecked());
switch (phase) {
case 0:
// Phase 0: previous not completed
holder.startedLayout.setVisibility(View.GONE);
holder.durationLayout.setVisibility(View.GONE);
holder.progressLayout.setVisibility(View.GONE);
holder.verifyLayout.setVisibility(View.GONE);
break;
case 1:
// Phase 1: not started
holder.durationLayout.setVisibility(View.GONE);
holder.progressLayout.setVisibility(View.GONE);
holder.verifyLayout.setVisibility(View.GONE);
holder.started.setVisibility(View.GONE);
break;
case 2:
// Phase 2: started, waiting for duration and met requirements
holder.startButton.setEnabled(false);
holder.verifyLayout.setVisibility(View.GONE);
break;
case 3:
// Phase 3: started, after duration, requirements met
holder.startButton.setEnabled(false);
holder.accomplished.setVisibility(View.INVISIBLE);
break;
case 4:
// Phase 4: verified
holder.gateLayout.setVisibility(View.GONE);
holder.startedLayout.setVisibility(View.GONE);
holder.durationLayout.setVisibility(View.GONE);
holder.progressLayout.setVisibility(View.GONE);
holder.verifyButton.setVisibility(View.INVISIBLE);
break;
default:
// should not happen
}
}
@Override
public int getItemCount() {
return objectives.size();
}
@Override
public void onAttachedToRecyclerView(RecyclerView recyclerView) {
super.onAttachedToRecyclerView(recyclerView);
}
public class ObjectiveViewHolder extends RecyclerView.ViewHolder {
CardView cv;
TextView position;
TextView objective;
LinearLayout gateLayout;
TextView gate;
TextView duration;
LinearLayout durationLayout;
TextView progress;
LinearLayout progressLayout;
TextView started;
Button startButton;
LinearLayout startedLayout;
TextView accomplished;
Button verifyButton;
LinearLayout verifyLayout;
ObjectiveViewHolder(View itemView) {
super(itemView);
cv = (CardView) itemView.findViewById(R.id.objectives_cardview);
position = (TextView) itemView.findViewById(R.id.objectives_position);
objective = (TextView) itemView.findViewById(R.id.objectives_objective);
durationLayout = (LinearLayout) itemView.findViewById(R.id.objectives_duration_linearlayout);
duration = (TextView) itemView.findViewById(R.id.objectives_duration);
progressLayout = (LinearLayout) itemView.findViewById(R.id.objectives_progresslayout);
progress = (TextView) itemView.findViewById(R.id.objectives_progress);
gateLayout = (LinearLayout) itemView.findViewById(R.id.objectives_gate_linearlayout);
gate = (TextView) itemView.findViewById(R.id.objectives_gate);
startedLayout = (LinearLayout) itemView.findViewById(R.id.objectives_start_linearlayout);
started = (TextView) itemView.findViewById(R.id.objectives_started);
startButton = (Button) itemView.findViewById(R.id.objectives_start);
verifyLayout = (LinearLayout) itemView.findViewById(R.id.objectives_verify_linearlayout);
accomplished = (TextView) itemView.findViewById(R.id.objectives_accomplished);
verifyButton = (Button) itemView.findViewById(R.id.objectives_verify);
}
}
}
/**
* returns an int, which represents the phase the current objective is at.
*
* this is mainly used for unit-testing the conditions
*
* @param currentPosition
* @param prevObjectiveAccomplishedTime
* @param objectiveStartedTime
* @param durationInDays
* @param objectiveAccomplishedTime
* @param requirementsMet
* @return
*/
public int modifyVisibility(int currentPosition,
long prevObjectiveAccomplishedTime,
long objectiveStartedTime, int durationInDays,
long objectiveAccomplishedTime, boolean requirementsMet,
boolean enableFakeValue) {
Long now = System.currentTimeMillis();
if (currentPosition > 0 && prevObjectiveAccomplishedTime == 0) {
return 0;
} else if (objectiveStartedTime == 0) {
return 1;
} else if (objectiveStartedTime > 0 && !enableFakeValue
&& objectiveAccomplishedTime == 0
&& !(objectiveStartedTime + T.days(durationInDays).msecs() < now && requirementsMet)) {
return 2;
} else if (objectiveAccomplishedTime == 0) {
return 3;
} else {
return 4;
}
}
ObjectivesAdapter objectivesAdapter = new ObjectivesAdapter();
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
@ -216,44 +42,17 @@ public class ObjectivesFragment extends SubscriberFragment {
try {
View view = inflater.inflate(R.layout.objectives_fragment, container, false);
recyclerView = (RecyclerView) view.findViewById(R.id.objectives_recyclerview);
recyclerView.setHasFixedSize(true);
llm = new LinearLayoutManager(view.getContext());
recyclerView.setLayoutManager(llm);
enableFake = (CheckBox) view.findViewById(R.id.objectives_fake);
fake_layout = (LinearLayout) view.findViewById(R.id.objectives_fake_layout);
reset = (TextView) view.findViewById(R.id.objectives_reset);
enableFake.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
updateGUI();
}
recyclerView = view.findViewById(R.id.objectives_recyclerview);
recyclerView.setLayoutManager(new LinearLayoutManager(view.getContext()));
recyclerView.setAdapter(objectivesAdapter);
enableFake = view.findViewById(R.id.objectives_fake);
reset = view.findViewById(R.id.objectives_reset);
enableFake.setOnClickListener(v -> updateGUI());
reset.setOnClickListener(v -> {
ObjectivesPlugin.getPlugin().reset();
ObjectivesPlugin.saveProgress();
updateGUI();
});
reset.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
ObjectivesPlugin.getPlugin().initializeData();
ObjectivesPlugin.saveProgress();
updateGUI();
}
});
// Add correct translations to array after app is initialized
ObjectivesPlugin.objectives.get(0).objective = MainApp.gs(R.string.objectives_0_objective);
ObjectivesPlugin.objectives.get(1).objective = MainApp.gs(R.string.objectives_1_objective);
ObjectivesPlugin.objectives.get(2).objective = MainApp.gs(R.string.objectives_2_objective);
ObjectivesPlugin.objectives.get(3).objective = MainApp.gs(R.string.objectives_3_objective);
ObjectivesPlugin.objectives.get(4).objective = MainApp.gs(R.string.objectives_4_objective);
ObjectivesPlugin.objectives.get(5).objective = MainApp.gs(R.string.objectives_5_objective);
ObjectivesPlugin.objectives.get(6).objective = MainApp.gs(R.string.objectives_6_objective);
ObjectivesPlugin.objectives.get(7).objective = MainApp.gs(R.string.objectives_7_objective);
ObjectivesPlugin.objectives.get(0).gate = MainApp.gs(R.string.objectives_0_gate);
ObjectivesPlugin.objectives.get(1).gate = MainApp.gs(R.string.objectives_1_gate);
ObjectivesPlugin.objectives.get(2).gate = MainApp.gs(R.string.objectives_2_gate);
ObjectivesPlugin.objectives.get(3).gate = MainApp.gs(R.string.objectives_3_gate);
ObjectivesPlugin.objectives.get(4).gate = MainApp.gs(R.string.objectives_4_gate);
ObjectivesPlugin.objectives.get(5).gate = MainApp.gs(R.string.objectives_5_gate);
ObjectivesPlugin.objectives.get(7).gate = MainApp.gs(R.string.objectives_7_gate);
updateGUI();
return view;
} catch (Exception e) {
@ -263,13 +62,99 @@ public class ObjectivesFragment extends SubscriberFragment {
return null;
}
private class ObjectivesAdapter extends RecyclerView.Adapter<ObjectivesAdapter.ViewHolder> {
@NonNull
@Override
public ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
return new ViewHolder(LayoutInflater.from(parent.getContext()).inflate(R.layout.objectives_item, parent, false));
}
@Override
public void onBindViewHolder(@NonNull ViewHolder holder, int position) {
Objective objective = ObjectivesPlugin.getObjectives().get(position);
holder.title.setText(MainApp.gs(R.string.nth_objective, position + 1));
if (objective.getObjective() != 0) {
holder.objective.setVisibility(View.VISIBLE);
holder.objective.setText(MainApp.gs(objective.getObjective()));
} else holder.objective.setVisibility(View.GONE);
if (objective.getGate() != 0) {
holder.gate.setVisibility(View.VISIBLE);
holder.gate.setText(MainApp.gs(objective.getGate()));
} else holder.gate.setVisibility(View.GONE);
if (!objective.isStarted() && !objective.isAccomplished()) {
holder.gate.setTextColor(0xFFFFFFFF);
holder.verify.setVisibility(View.GONE);
holder.progress.setVisibility(View.GONE);
if (position == 0 || ObjectivesPlugin.getObjectives().get(position - 1).isAccomplished())
holder.start.setVisibility(View.VISIBLE);
else holder.start.setVisibility(View.GONE);
} else if (objective.isAccomplished()) {
holder.gate.setTextColor(0xFF4CAF50);
holder.verify.setVisibility(View.GONE);
holder.progress.setVisibility(View.GONE);
holder.start.setVisibility(View.GONE);
} else if (objective.isStarted()) {
holder.gate.setTextColor(0xFFFFFFFF);
holder.verify.setVisibility(View.VISIBLE);
holder.verify.setEnabled(objective.isAccomplished() || enableFake.isChecked());
holder.start.setVisibility(View.GONE);
holder.progress.setVisibility(View.VISIBLE);
holder.progress.removeAllViews();
for (Objective.Task task : objective.getTasks()) {
if (task.shouldBeIgnored()) continue;
TextView textView = new TextView(holder.progress.getContext());
textView.setTextColor(0xFFFFFFFF);
String basicHTML = "%2$s: <font color=\"%1$s\"><b>%3$s</b></font>";
String formattedHTML = String.format(basicHTML, task.isCompleted() ? "#4CAF50" : "#FF9800", MainApp.gs(task.getTask()), task.getProgress());
textView.setText(Html.fromHtml(formattedHTML));
holder.progress.addView(textView, LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT);
}
}
holder.verify.setOnClickListener((view) -> {
objective.setAccomplishedOn(new Date());
updateGUI();
});
holder.start.setOnClickListener((view) -> {
objective.setStartedOn(new Date());
updateGUI();
});
}
@Override
public int getItemCount() {
return ObjectivesPlugin.getObjectives().size();
}
public class ViewHolder extends RecyclerView.ViewHolder {
public CardView cardView;
public TextView title;
public TextView objective;
public TextView gate;
public LinearLayout progress;
public Button verify;
public Button start;
public ViewHolder(View itemView) {
super(itemView);
cardView = (CardView) itemView;
title = itemView.findViewById(R.id.objective_title);
objective = itemView.findViewById(R.id.objective_objective);
gate = itemView.findViewById(R.id.objective_gate);
progress = itemView.findViewById(R.id.objective_progress);
verify = itemView.findViewById(R.id.objective_verify);
start = itemView.findViewById(R.id.objective_start);
}
}
}
@Override
public void updateGUI() {
Activity activity = getActivity();
if (activity != null)
activity.runOnUiThread(() -> {
RecyclerViewAdapter adapter = new RecyclerViewAdapter(ObjectivesPlugin.objectives);
recyclerView.setAdapter(adapter);
objectivesAdapter.notifyDataSetChanged();
});
}

View file

@ -1,20 +1,14 @@
package info.nightscout.androidaps.plugins.ConstraintsObjectives;
import android.content.SharedPreferences;
import android.preference.PreferenceManager;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import info.nightscout.androidaps.Config;
import info.nightscout.androidaps.MainApp;
import info.nightscout.androidaps.R;
import info.nightscout.androidaps.db.DatabaseHelper;
import info.nightscout.androidaps.interfaces.APSInterface;
import info.nightscout.androidaps.interfaces.Constraint;
import info.nightscout.androidaps.interfaces.ConstraintsInterface;
import info.nightscout.androidaps.interfaces.PluginBase;
@ -23,12 +17,15 @@ import info.nightscout.androidaps.interfaces.PluginType;
import info.nightscout.androidaps.interfaces.PumpInterface;
import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderPlugin;
import info.nightscout.androidaps.plugins.ConstraintsObjectives.events.EventObjectivesSaved;
import info.nightscout.androidaps.plugins.ConstraintsSafety.SafetyPlugin;
import info.nightscout.androidaps.plugins.Loop.LoopPlugin;
import info.nightscout.androidaps.plugins.NSClientInternal.NSClientPlugin;
import info.nightscout.androidaps.plugins.PumpVirtual.VirtualPumpPlugin;
import info.nightscout.androidaps.plugins.Treatments.TreatmentsPlugin;
import info.nightscout.utils.DateUtil;
import info.nightscout.androidaps.plugins.ConstraintsObjectives.objectives.Objective;
import info.nightscout.androidaps.plugins.ConstraintsObjectives.objectives.Objective1;
import info.nightscout.androidaps.plugins.ConstraintsObjectives.objectives.Objective2;
import info.nightscout.androidaps.plugins.ConstraintsObjectives.objectives.Objective3;
import info.nightscout.androidaps.plugins.ConstraintsObjectives.objectives.Objective4;
import info.nightscout.androidaps.plugins.ConstraintsObjectives.objectives.Objective5;
import info.nightscout.androidaps.plugins.ConstraintsObjectives.objectives.Objective6;
import info.nightscout.androidaps.plugins.ConstraintsObjectives.objectives.Objective7;
import info.nightscout.androidaps.plugins.ConstraintsObjectives.objectives.Objective8;
import info.nightscout.utils.SP;
/**
@ -39,6 +36,11 @@ public class ObjectivesPlugin extends PluginBase implements ConstraintsInterface
private static ObjectivesPlugin objectivesPlugin;
public static List<Objective> objectives = new ArrayList<>();
public static boolean bgIsAvailableInNS = false;
public static boolean pumpStatusIsAvailableInNS = false;
public static Integer manualEnacts = 0;
public static ObjectivesPlugin getPlugin() {
if (objectivesPlugin == null) {
objectivesPlugin = new ObjectivesPlugin();
@ -46,8 +48,6 @@ public class ObjectivesPlugin extends PluginBase implements ConstraintsInterface
return objectivesPlugin;
}
public static List<Objective> objectives;
private ObjectivesPlugin() {
super(new PluginDescription()
.mainType(PluginType.CONSTRAINTS)
@ -58,7 +58,7 @@ public class ObjectivesPlugin extends PluginBase implements ConstraintsInterface
.shortName(R.string.objectives_shortname)
.description(R.string.description_objectives)
);
initializeData();
setupObjectives();
loadProgress();
}
@ -68,187 +68,38 @@ public class ObjectivesPlugin extends PluginBase implements ConstraintsInterface
return pump == null || pump.getPumpDescription().isTempBasalCapable;
}
public class Objective {
Integer num;
String objective;
String gate;
Date started;
Integer durationInDays;
Date accomplished;
Objective(Integer num, String objective, String gate, Date started, Integer durationInDays, Date accomplished) {
this.num = num;
this.objective = objective;
this.gate = gate;
this.started = started;
this.durationInDays = durationInDays;
this.accomplished = accomplished;
}
public void setStarted(Date started) {
this.started = started;
}
public boolean isStarted() {
return started.getTime() > 0;
}
boolean isFinished() {
return accomplished.getTime() != 0;
}
private void setupObjectives() {
objectives.add(new Objective1());
objectives.add(new Objective2());
objectives.add(new Objective3());
objectives.add(new Objective4());
objectives.add(new Objective5());
objectives.add(new Objective6());
objectives.add(new Objective7());
objectives.add(new Objective8());
}
// Objective 0
public static boolean bgIsAvailableInNS = false;
public static boolean pumpStatusIsAvailableInNS = false;
// Objective 1
public static Integer manualEnacts = 0;
private static final Integer manualEnactsNeeded = 20;
class RequirementResult {
boolean done = false;
String comment = "";
RequirementResult(boolean done, String comment) {
this.done = done;
this.comment = comment;
public void reset() {
for (Objective objective : objectives) {
objective.setStartedOn(null);
objective.setAccomplishedOn(null);
}
}
private String yesOrNo(boolean yes) {
if (yes) return "";
else return "---";
}
RequirementResult requirementsMet(Integer objNum) {
switch (objNum) {
case 0:
boolean isVirtualPump = VirtualPumpPlugin.getPlugin().isEnabled(PluginType.PUMP);
boolean vpUploadEnabled = SP.getBoolean("virtualpump_uploadstatus", false);
boolean vpUploadNeeded = !isVirtualPump || vpUploadEnabled;
boolean hasBGData = DatabaseHelper.lastBg() != null;
boolean apsEnabled = false;
APSInterface usedAPS = ConfigBuilderPlugin.getActiveAPS();
if (usedAPS != null && ((PluginBase) usedAPS).isEnabled(PluginType.APS))
apsEnabled = true;
boolean profileSwitchExists = TreatmentsPlugin.getPlugin().getProfileSwitchFromHistory(DateUtil.now()) != null;
return new RequirementResult(hasBGData && bgIsAvailableInNS && pumpStatusIsAvailableInNS && NSClientPlugin.getPlugin().hasWritePermission() && LoopPlugin.getPlugin().isEnabled(PluginType.LOOP) && apsEnabled && vpUploadNeeded && profileSwitchExists,
MainApp.gs(R.string.objectives_bgavailableinns) + ": " + yesOrNo(bgIsAvailableInNS)
+ "\n" + MainApp.gs(R.string.nsclienthaswritepermission) + ": " + yesOrNo(NSClientPlugin.getPlugin().hasWritePermission())
+ (isVirtualPump ? "\n" + MainApp.gs(R.string.virtualpump_uploadstatus_title) + ": " + yesOrNo(vpUploadEnabled) : "")
+ "\n" + MainApp.gs(R.string.objectives_pumpstatusavailableinns) + ": " + yesOrNo(pumpStatusIsAvailableInNS)
+ "\n" + MainApp.gs(R.string.hasbgdata) + ": " + yesOrNo(hasBGData)
+ "\n" + MainApp.gs(R.string.loopenabled) + ": " + yesOrNo(LoopPlugin.getPlugin().isEnabled(PluginType.LOOP))
+ "\n" + MainApp.gs(R.string.apsselected) + ": " + yesOrNo(apsEnabled)
+ "\n" + MainApp.gs(R.string.activate_profile) + ": " + yesOrNo(profileSwitchExists)
);
case 1:
return new RequirementResult(manualEnacts >= manualEnactsNeeded,
MainApp.gs(R.string.objectives_manualenacts) + ": " + manualEnacts + "/" + manualEnactsNeeded);
case 2:
return new RequirementResult(true, "");
case 3:
Constraint<Boolean> closedLoopEnabled = new Constraint<>(true);
SafetyPlugin.getPlugin().isClosedLoopAllowed(closedLoopEnabled);
return new RequirementResult(closedLoopEnabled.value(), MainApp.gs(R.string.closedmodeenabled) + ": " + yesOrNo(closedLoopEnabled.value()));
case 4:
double maxIOB = MainApp.getConstraintChecker().getMaxIOBAllowed().value();
boolean maxIobSet = maxIOB > 0;
return new RequirementResult(maxIobSet, MainApp.gs(R.string.maxiobset) + ": " + yesOrNo(maxIobSet));
default:
return new RequirementResult(true, "");
}
}
void initializeData() {
bgIsAvailableInNS = false;
pumpStatusIsAvailableInNS = false;
manualEnacts = 0;
objectives = new ArrayList<>();
objectives.add(new Objective(0,
MainApp.gs(R.string.objectives_0_objective),
MainApp.gs(R.string.objectives_0_gate),
new Date(0),
0, // 0 day
new Date(0)));
objectives.add(new Objective(1,
MainApp.gs(R.string.objectives_1_objective),
MainApp.gs(R.string.objectives_1_gate),
new Date(0),
7, // 7 days
new Date(0)));
objectives.add(new Objective(2,
MainApp.gs(R.string.objectives_2_objective),
MainApp.gs(R.string.objectives_2_gate),
new Date(0),
0, // 0 days
new Date(0)));
objectives.add(new Objective(3,
MainApp.gs(R.string.objectives_3_objective),
MainApp.gs(R.string.objectives_3_gate),
new Date(0),
5, // 5 days
new Date(0)));
objectives.add(new Objective(4,
MainApp.gs(R.string.objectives_4_objective),
MainApp.gs(R.string.objectives_4_gate),
new Date(0),
1,
new Date(0)));
objectives.add(new Objective(5,
MainApp.gs(R.string.objectives_5_objective),
MainApp.gs(R.string.objectives_5_gate),
new Date(0),
7,
new Date(0)));
objectives.add(new Objective(6,
MainApp.gs(R.string.objectives_6_objective),
"",
new Date(0),
28,
new Date(0)));
objectives.add(new Objective(7,
MainApp.gs(R.string.objectives_7_objective),
"",
new Date(0),
28,
new Date(0)));
saveProgress();
}
public static void saveProgress() {
if (objectives != null) {
SharedPreferences settings = PreferenceManager.getDefaultSharedPreferences(MainApp.instance().getApplicationContext());
SharedPreferences.Editor editor = settings.edit();
for (int num = 0; num < objectives.size(); num++) {
Objective o = objectives.get(num);
editor.putString("Objectives" + num + "started", Long.toString(o.started.getTime()));
editor.putString("Objectives" + num + "accomplished", Long.toString(o.accomplished.getTime()));
}
editor.putBoolean("Objectives" + "bgIsAvailableInNS", bgIsAvailableInNS);
editor.putBoolean("Objectives" + "pumpStatusIsAvailableInNS", pumpStatusIsAvailableInNS);
editor.putString("Objectives" + "manualEnacts", Integer.toString(manualEnacts));
editor.apply();
if (Config.logPrefsChange)
log.debug("Objectives stored");
MainApp.bus().post(new EventObjectivesSaved());
}
SP.putBoolean("Objectives" + "bgIsAvailableInNS", bgIsAvailableInNS);
SP.putBoolean("Objectives" + "pumpStatusIsAvailableInNS", pumpStatusIsAvailableInNS);
SP.putString("Objectives" + "manualEnacts", Integer.toString(manualEnacts));
if (Config.logPrefsChange)
log.debug("Objectives stored");
MainApp.bus().post(new EventObjectivesSaved());
}
private void loadProgress() {
for (int num = 0; num < objectives.size(); num++) {
Objective o = objectives.get(num);
try {
o.started = new Date(SP.getLong("Objectives" + num + "started", 0L));
o.accomplished = new Date(SP.getLong("Objectives" + num + "accomplished", 0L));
} catch (Exception e) {
log.error("Unhandled exception", e);
}
}
bgIsAvailableInNS = SP.getBoolean("Objectives" + "bgIsAvailableInNS", false);
pumpStatusIsAvailableInNS = SP.getBoolean("Objectives" + "pumpStatusIsAvailableInNS", false);
try {
@ -260,11 +111,15 @@ public class ObjectivesPlugin extends PluginBase implements ConstraintsInterface
log.debug("Objectives loaded");
}
public static List<Objective> getObjectives() {
return objectives;
}
/**
* Constraints interface
**/
@Override
public Constraint<Boolean> isLoopInvokationAllowed(Constraint<Boolean> value) {
public Constraint<Boolean> isLoopInvocationAllowed(Constraint<Boolean> value) {
if (!objectives.get(0).isStarted())
value.set(false, String.format(MainApp.gs(R.string.objectivenotstarted), 1), this);
return value;
@ -300,7 +155,7 @@ public class ObjectivesPlugin extends PluginBase implements ConstraintsInterface
@Override
public Constraint<Double> applyMaxIOBConstraints(Constraint<Double> maxIob) {
if (objectives.get(3).isStarted() && !objectives.get(3).isFinished())
if (objectives.get(3).isStarted() && !objectives.get(3).isAccomplished())
maxIob.set(0d, String.format(MainApp.gs(R.string.objectivenotfinished), 4), this);
return maxIob;
}

View file

@ -0,0 +1,137 @@
package info.nightscout.androidaps.plugins.ConstraintsObjectives.objectives;
import android.support.annotation.StringRes;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import info.nightscout.androidaps.MainApp;
import info.nightscout.androidaps.R;
import info.nightscout.utils.SP;
public abstract class Objective {
private int number;
@StringRes
private int objective;
@StringRes
private int gate;
private Date startedOn;
private Date accomplishedOn;
private List<Task> tasks = new ArrayList<>();
public Objective(int number, @StringRes int objective, @StringRes int gate) {
this.number = number;
this.objective = objective;
this.gate = gate;
startedOn = new Date(SP.getLong("Objectives" + number + "started", 0L));
if (startedOn.getTime() == 0L) startedOn = null;
accomplishedOn = new Date(SP.getLong("Objectives" + number + "accomplished", 0L));
if (accomplishedOn.getTime() == 0L) accomplishedOn = null;
setupTasks(tasks);
for (Task task : tasks) task.objective = this;
}
public boolean isAccomplished() {
boolean completed = true;
for (Task task : tasks) {
if (!task.shouldBeIgnored() && !task.isCompleted()) {
completed = false;
break;
}
}
return startedOn != null && (accomplishedOn != null || completed);
}
public boolean isStarted() {
return startedOn != null && accomplishedOn == null;
}
public Date getStartedOn() {
return startedOn;
}
public int getObjective() {
return objective;
}
public int getGate() {
return gate;
}
public void setStartedOn(Date startedOn) {
this.startedOn = startedOn;
SP.putLong("Objectives" + number + "started", startedOn == null ? 0 : startedOn.getTime());
}
public void setAccomplishedOn(Date accomplishedOn) {
this.accomplishedOn = accomplishedOn;
SP.putLong("Objectives" + number + "accomplished", accomplishedOn == null ? 0 : accomplishedOn.getTime());
}
protected void setupTasks(List<Task> tasks) {
}
public List<Task> getTasks() {
return tasks;
}
public abstract class Task {
@StringRes
private int task;
private Objective objective;
public Task(@StringRes int task) {
this.task = task;
}
public int getTask() {
return task;
}
protected Objective getObjective() {
return objective;
}
public abstract boolean isCompleted();
public String getProgress() {
return MainApp.gs(isCompleted() ? R.string.completed_well_done : R.string.not_completed_yet);
}
public boolean shouldBeIgnored() {
return false;
}
}
public class MinimumDurationTask extends Task {
private long minimumDuration;
public MinimumDurationTask(long minimumDuration) {
super(R.string.time_leftover);
this.minimumDuration = minimumDuration;
}
@Override
public boolean isCompleted() {
return getObjective().isStarted() && System.currentTimeMillis() - getObjective().getStartedOn().getTime() >= minimumDuration;
}
@Override
public String getProgress() {
long timeLeftover = minimumDuration - (System.currentTimeMillis() - getObjective().getStartedOn().getTime());
int days = (int) (minimumDuration / (24L * 60L * 60L * 1000L));
int hours = (int) (minimumDuration / (60L * 60L * 1000L));
int minutes = (int) (minimumDuration / (60L * 1000L));
if (days > 0) return MainApp.gq(R.plurals.objective_days, days, days);
else if (hours > 0) return MainApp.gq(R.plurals.objective_hours, hours, hours);
else if (minutes > 0) return MainApp.gq(R.plurals.objective_minutes, minutes, minutes);
else if (timeLeftover > 0) return MainApp.gq(R.plurals.objective_minutes, 1, 1);
else return MainApp.gs(R.string.time_none);
}
}
}

View file

@ -0,0 +1,84 @@
package info.nightscout.androidaps.plugins.ConstraintsObjectives.objectives;
import java.util.List;
import info.nightscout.androidaps.R;
import info.nightscout.androidaps.db.DatabaseHelper;
import info.nightscout.androidaps.interfaces.APSInterface;
import info.nightscout.androidaps.interfaces.PluginBase;
import info.nightscout.androidaps.interfaces.PluginType;
import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderPlugin;
import info.nightscout.androidaps.plugins.ConstraintsObjectives.ObjectivesPlugin;
import info.nightscout.androidaps.plugins.Loop.LoopPlugin;
import info.nightscout.androidaps.plugins.NSClientInternal.NSClientPlugin;
import info.nightscout.androidaps.plugins.PumpVirtual.VirtualPumpPlugin;
import info.nightscout.androidaps.plugins.Treatments.TreatmentsPlugin;
import info.nightscout.utils.DateUtil;
import info.nightscout.utils.SP;
public class Objective1 extends Objective {
public Objective1() {
super(0, R.string.objectives_0_objective, R.string.objectives_0_gate);
}
@Override
protected void setupTasks(List<Task> tasks) {
tasks.add(new Task(R.string.objectives_bgavailableinns) {
@Override
public boolean isCompleted() {
return ObjectivesPlugin.bgIsAvailableInNS;
}
});
tasks.add(new Task(R.string.nsclienthaswritepermission) {
@Override
public boolean isCompleted() {
return NSClientPlugin.getPlugin().hasWritePermission();
}
});
tasks.add(new Task(R.string.virtualpump_uploadstatus_title) {
@Override
public boolean isCompleted() {
return SP.getBoolean("virtualpump_uploadstatus", false);
}
@Override
public boolean shouldBeIgnored() {
return !VirtualPumpPlugin.getPlugin().isEnabled(PluginType.PUMP);
}
});
tasks.add(new Task(R.string.objectives_pumpstatusavailableinns) {
@Override
public boolean isCompleted() {
return ObjectivesPlugin.pumpStatusIsAvailableInNS;
}
});
tasks.add(new Task(R.string.hasbgdata) {
@Override
public boolean isCompleted() {
return DatabaseHelper.lastBg() != null;
}
});
tasks.add(new Task(R.string.loopenabled) {
@Override
public boolean isCompleted() {
return LoopPlugin.getPlugin().isEnabled(PluginType.LOOP);
}
});
tasks.add(new Task(R.string.apsselected) {
@Override
public boolean isCompleted() {
APSInterface usedAPS = ConfigBuilderPlugin.getActiveAPS();
if (usedAPS != null && ((PluginBase) usedAPS).isEnabled(PluginType.APS))
return true;
return false;
}
});
tasks.add(new Task(R.string.activate_profile) {
@Override
public boolean isCompleted() {
return TreatmentsPlugin.getPlugin().getProfileSwitchFromHistory(DateUtil.now()) != null;
}
});
}
}

View file

@ -0,0 +1,33 @@
package info.nightscout.androidaps.plugins.ConstraintsObjectives.objectives;
import java.util.List;
import info.nightscout.androidaps.MainApp;
import info.nightscout.androidaps.R;
import info.nightscout.androidaps.plugins.ConstraintsObjectives.ObjectivesPlugin;
public class Objective2 extends Objective {
public static final int MANUAL_ENACTS_NEEDED = 20;
public Objective2() {
super(1, R.string.objectives_1_objective, R.string.objectives_1_gate);
}
@Override
protected void setupTasks(List<Task> tasks) {
tasks.add(new MinimumDurationTask(7L * 24L * 60L * 60L * 1000L));
tasks.add(new Task(R.string.objectives_manualenacts) {
@Override
public boolean isCompleted() {
return ObjectivesPlugin.manualEnacts >= MANUAL_ENACTS_NEEDED;
}
@Override
public String getProgress() {
if (ObjectivesPlugin.manualEnacts >= MANUAL_ENACTS_NEEDED) return MainApp.gs(R.string.completed_well_done);
else return ObjectivesPlugin.manualEnacts + " / " + MANUAL_ENACTS_NEEDED;
}
});
}
}

View file

@ -0,0 +1,10 @@
package info.nightscout.androidaps.plugins.ConstraintsObjectives.objectives;
import info.nightscout.androidaps.R;
public class Objective3 extends Objective {
public Objective3() {
super(2, R.string.objectives_2_objective, R.string.objectives_2_gate);
}
}

View file

@ -0,0 +1,27 @@
package info.nightscout.androidaps.plugins.ConstraintsObjectives.objectives;
import java.util.List;
import info.nightscout.androidaps.R;
import info.nightscout.androidaps.interfaces.Constraint;
import info.nightscout.androidaps.plugins.ConstraintsSafety.SafetyPlugin;
public class Objective4 extends Objective {
public Objective4() {
super(3, R.string.objectives_3_objective, R.string.objectives_4_gate);
}
@Override
protected void setupTasks(List<Task> tasks) {
tasks.add(new MinimumDurationTask(5L * 24L * 60L * 60L * 1000L));
tasks.add(new Task(R.string.closedmodeenabled) {
@Override
public boolean isCompleted() {
Constraint<Boolean> closedLoopEnabled = new Constraint<>(true);
SafetyPlugin.getPlugin().isClosedLoopAllowed(closedLoopEnabled);
return closedLoopEnabled.value();
}
});
}
}

View file

@ -0,0 +1,25 @@
package info.nightscout.androidaps.plugins.ConstraintsObjectives.objectives;
import java.util.List;
import info.nightscout.androidaps.MainApp;
import info.nightscout.androidaps.R;
public class Objective5 extends Objective {
public Objective5() {
super(4, R.string.objectives_4_objective, R.string.objectives_4_gate);
}
@Override
protected void setupTasks(List<Task> tasks) {
tasks.add(new MinimumDurationTask(24L * 60L * 60L * 1000L));
tasks.add(new Task(R.string.maxiobset) {
@Override
public boolean isCompleted() {
double maxIOB = MainApp.getConstraintChecker().getMaxIOBAllowed().value();
return maxIOB > 0;
}
});
}
}

View file

@ -0,0 +1,17 @@
package info.nightscout.androidaps.plugins.ConstraintsObjectives.objectives;
import java.util.List;
import info.nightscout.androidaps.R;
public class Objective6 extends Objective {
public Objective6() {
super(5, R.string.objectives_5_objective, R.string.objectives_5_gate);
}
@Override
protected void setupTasks(List<Task> tasks) {
tasks.add(new MinimumDurationTask(7L * 24L * 60L * 60L * 1000L));
}
}

View file

@ -0,0 +1,17 @@
package info.nightscout.androidaps.plugins.ConstraintsObjectives.objectives;
import java.util.List;
import info.nightscout.androidaps.R;
public class Objective7 extends Objective {
public Objective7() {
super(6, R.string.objectives_6_objective, 0);
}
@Override
protected void setupTasks(List<Task> tasks) {
tasks.add(new MinimumDurationTask(28L * 24L * 60L * 60L * 1000L));
}
}

View file

@ -0,0 +1,17 @@
package info.nightscout.androidaps.plugins.ConstraintsObjectives.objectives;
import java.util.List;
import info.nightscout.androidaps.R;
public class Objective8 extends Objective {
public Objective8() {
super(7, R.string.objectives_7_objective, 0);
}
@Override
protected void setupTasks(List<Task> tasks) {
tasks.add(new MinimumDurationTask(28L * 24L * 60L * 60L * 1000L));
}
}

View file

@ -49,7 +49,7 @@ public class SafetyPlugin extends PluginBase implements ConstraintsInterface {
* Constraints interface
**/
@Override
public Constraint<Boolean> isLoopInvokationAllowed(Constraint<Boolean> value) {
public Constraint<Boolean> isLoopInvocationAllowed(Constraint<Boolean> value) {
if (!ConfigBuilderPlugin.getActivePump().getPumpDescription().isTempBasalCapable)
value.set(false, MainApp.gs(R.string.pumpisnottempbasalcapable), this);
return value;

View file

@ -1357,7 +1357,7 @@ public class ComboPlugin extends PluginBase implements PumpInterface, Constraint
private boolean validBasalRateProfileSelectedOnPump = true;
@Override
public Constraint<Boolean> isLoopInvokationAllowed(Constraint<Boolean> value) {
public Constraint<Boolean> isLoopInvocationAllowed(Constraint<Boolean> value) {
if (!validBasalRateProfileSelectedOnPump)
value.set(false, MainApp.gs(R.string.novalidbasalrate), this);
return value;

View file

@ -40,7 +40,7 @@ public class HardLimits {
public static final double MAXISF = 720; // mgdl
public static final double[] MAXIOB_AMA = {3, 5, 7, 12};
public static final double[] MAXIOB_SMB = {3, 7, 12, 25};
public static final double[] MAXIOB_SMB = {3, 7, 20, 25};
public static final double[] MAXBASAL = {2, 5, 10, 12};

View file

@ -1,46 +1,41 @@
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingTop="2dp"
android:orientation="vertical"
tools:context=".plugins.ConstraintsObjectives.ObjectivesFragment">
<LinearLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">
android:layout_height="wrap_content"
android:gravity="center_vertical"
android:orientation="horizontal"
android:paddingLeft="16dp"
android:paddingRight="16dp"
android:paddingTop="16dp"
android:visibility="gone">
<LinearLayout
android:orientation="horizontal"
android:layout_width="match_parent"
<CheckBox
android:id="@+id/objectives_fake"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:id="@+id/objectives_fake_layout"
android:visibility="gone">
android:layout_marginRight="16dp"
android:layout_weight="1"
android:text="Enable fake time and progress" />
<CheckBox
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Enable fake time and progress"
android:id="@+id/objectives_fake" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Reset"
android:id="@+id/objectives_reset"
android:textColor="#fef900"
android:gravity="right"
android:layout_weight="0.5"
android:layout_marginRight="10dp" />
</LinearLayout>
<android.support.v7.widget.RecyclerView
android:id="@+id/objectives_recyclerview"
android:layout_width="match_parent"
android:layout_height="match_parent">
</android.support.v7.widget.RecyclerView>
<Button
android:id="@+id/objectives_reset"
style="@style/Widget.AppCompat.Button.Borderless.Colored"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Reset" />
</LinearLayout>
</FrameLayout>
<android.support.v7.widget.RecyclerView
android:id="@+id/objectives_recyclerview"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:clipToPadding="false"
android:paddingBottom="16dp" />
</LinearLayout>

View file

@ -1,162 +1,70 @@
<?xml version="1.0" encoding="utf-8"?>
<android.support.v7.widget.CardView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:card_view="http://schemas.android.com/apk/res-auto"
android:id="@+id/objectives_cardview"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/objective_cardview"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
card_view:cardBackgroundColor="@color/cardColorBackground"
card_view:cardCornerRadius="6dp"
card_view:cardUseCompatPadding="true"
card_view:contentPadding="6dp">
android:layout_marginLeft="16dp"
android:layout_marginRight="16dp"
android:layout_marginTop="16dp"
app:cardBackgroundColor="@color/colorPrimary"
app:cardCornerRadius="2dp"
app:cardUseCompatPadding="true"
app:contentPadding="16dp">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<TextView
android:id="@+id/objective_title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:fontFamily="sans-serif-medium"
android:textColor="#FFFFFF"
android:textSize="20sp"
tools:text="1. Title" />
<TextView
android:id="@+id/objective_objective"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="8dp"
android:textColor="#FFFFFF"
tools:text="Objective" />
<TextView
android:id="@+id/objective_gate"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="8dp"
android:textColor="#FFFFFF"
android:textStyle="bold"
tools:text="Gate" />
<LinearLayout
android:id="@+id/objective_progress"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:orientation="horizontal">
android:layout_marginTop="8dp"
android:orientation="vertical" />
<TextView
android:id="@+id/objectives_position"
android:layout_width="30dp"
android:layout_height="30dp"
android:background="@drawable/circle"
android:gravity="center"
android:shadowRadius="10.0"
android:text="1"
android:textColor="@color/cardObjectiveText"
android:textSize="18sp" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:baselineAligned="true"
android:orientation="horizontal">
<TextView
android:id="@+id/objectives_objective_label"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="top"
android:paddingRight="10dp"
android:text="@string/objectives_objective_label_string"
android:textAppearance="?android:attr/textAppearanceLarge"
android:textColor="@color/cardObjectiveText"
android:textStyle="bold" />
<TextView
android:id="@+id/objectives_objective"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:maxLines="4"
android:minLines="1"
android:text=""
android:textColor="@color/cardObjectiveText"
android:textStyle="bold" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal"
android:id="@+id/objectives_gate_linearlayout">
<TextView
android:id="@+id/objectives_gate_label"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="top"
android:paddingRight="10dp"
android:text="@string/objectives_gate_label_string"
android:textAppearance="?android:attr/textAppearanceLarge" />
<TextView
android:id="@+id/objectives_gate"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:maxLines="4"
android:minLines="1"
android:text="" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal"
android:id="@+id/objectives_start_linearlayout">
<Button
android:id="@+id/objectives_start"
style="?android:attr/buttonStyle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/objectives_button_start" />
<TextView
android:id="@+id/objectives_started"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
</LinearLayout>
<LinearLayout
android:orientation="horizontal"
android:layout_width="match_parent"
<Button
android:id="@+id/objective_verify"
style="@style/Widget.AppCompat.Button.Borderless.Colored"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/objectives_duration_linearlayout">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/objectives_duration" />
</LinearLayout>
<LinearLayout
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/objectives_progresslayout">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/objectives_progress" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal"
android:id="@+id/objectives_verify_linearlayout">
<Button
android:id="@+id/objectives_verify"
style="?android:attr/buttonStyle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/objectives_button_verify" />
<TextView
android:id="@+id/objectives_accomplished"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
</LinearLayout>
android:text="@string/objectives_button_verify" />
<Button
android:id="@+id/objective_start"
style="@style/Widget.AppCompat.Button.Borderless.Colored"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/objectives_button_start" />
</LinearLayout>
</android.support.v7.widget.CardView>

View file

@ -1139,4 +1139,24 @@
<string name="open_navigation">Open navigation</string>
<string name="close_navigation">Close navigation</string>
<string name="nav_plugin_preferences">Plugin preferences</string>
<string name="completed_well_done">Completed, well done!</string>
<string name="not_completed_yet">Not completed yet</string>
<string name="time_leftover">Time leftover</string>
<string name="time_none">None</string>
<string name="nth_objective">%1$d. Objective</string>
<plurals name="objective_days">
<item quantity="one">%d day</item>
<item quantity="other">%d days</item>
</plurals>
<plurals name="objective_hours">
<item quantity="one">%d hour</item>
<item quantity="other">%d hours</item>
</plurals>
<plurals name="objective_minutes">
<item quantity="one">%d minute</item>
<item quantity="other">%d minutes</item>
</plurals>
</resources>

View file

@ -27,6 +27,4 @@
<style name="ButtonSmallFontStyle">
<item name="android:textSize">10sp</item>
</style>
<!-- Preferences -->
</resources>

View file

@ -13,7 +13,6 @@ import java.util.Date;
import info.AAPSMocker;
import info.nightscout.androidaps.MainApp;
import info.nightscout.androidaps.interfaces.Constraint;
import info.nightscout.androidaps.interfaces.PluginType;
import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderPlugin;
import info.nightscout.utils.SP;
@ -32,7 +31,7 @@ public class ObjectivesPluginTest {
objectivesPlugin.objectives.get(0).setStarted(new Date(0));
Constraint<Boolean> c = new Constraint<>(true);
c = objectivesPlugin.isLoopInvokationAllowed(c);
c = objectivesPlugin.isLoopInvocationAllowed(c);
Assert.assertEquals("Objectives: Objective 1 not started", c.getReasons());
Assert.assertEquals(Boolean.FALSE, c.value());
objectivesPlugin.objectives.get(0).setStarted(new Date());

View file

@ -19,7 +19,6 @@ import info.nightscout.androidaps.interfaces.PluginType;
import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderPlugin;
import info.nightscout.androidaps.plugins.OpenAPSAMA.OpenAPSAMAPlugin;
import info.nightscout.androidaps.plugins.OpenAPSMA.OpenAPSMAPlugin;
import info.nightscout.androidaps.plugins.OpenAPSSMB.OpenAPSSMBPlugin;
import info.nightscout.androidaps.plugins.PumpVirtual.VirtualPumpPlugin;
import info.nightscout.androidaps.plugins.Source.SourceGlimpPlugin;
import info.nightscout.utils.SP;
@ -42,7 +41,7 @@ public class SafetyPluginTest {
pump.getPumpDescription().isTempBasalCapable = false;
Constraint<Boolean> c = new Constraint<>(true);
c = safetyPlugin.isLoopInvokationAllowed(c);
c = safetyPlugin.isLoopInvocationAllowed(c);
Assert.assertEquals("Safety: Pump is not temp basal capable", c.getReasons());
Assert.assertEquals(Boolean.FALSE, c.value());
}

View file

@ -32,7 +32,7 @@ public class ComboPluginTest {
comboPlugin.setValidBasalRateProfileSelectedOnPump(false);
Constraint<Boolean> c = new Constraint<>(true);
c = comboPlugin.isLoopInvokationAllowed(c);
c = comboPlugin.isLoopInvocationAllowed(c);
Assert.assertEquals("Combo: No valid basal rate read from pump", c.getReasons());
Assert.assertEquals(Boolean.FALSE, c.value());
comboPlugin.setPluginEnabled(PluginType.PUMP, false);