diff --git a/app/src/main/java/info/nightscout/androidaps/MainApp.java b/app/src/main/java/info/nightscout/androidaps/MainApp.java index 45aff91654..7f2ccb0ba7 100644 --- a/app/src/main/java/info/nightscout/androidaps/MainApp.java +++ b/app/src/main/java/info/nightscout/androidaps/MainApp.java @@ -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); } diff --git a/app/src/main/java/info/nightscout/androidaps/data/ConstraintChecker.java b/app/src/main/java/info/nightscout/androidaps/data/ConstraintChecker.java index 3161cb19f3..bfbbfedbd1 100644 --- a/app/src/main/java/info/nightscout/androidaps/data/ConstraintChecker.java +++ b/app/src/main/java/info/nightscout/androidaps/data/ConstraintChecker.java @@ -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 isLoopInvokationAllowed() { - return isLoopInvokationAllowed(new Constraint<>(true)); + return isLoopInvocationAllowed(new Constraint<>(true)); } public Constraint isClosedLoopAllowed() { @@ -69,13 +67,13 @@ public class ConstraintChecker implements ConstraintsInterface { } @Override - public Constraint isLoopInvokationAllowed(Constraint value) { + public Constraint isLoopInvocationAllowed(Constraint value) { ArrayList 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; } diff --git a/app/src/main/java/info/nightscout/androidaps/interfaces/ConstraintsInterface.java b/app/src/main/java/info/nightscout/androidaps/interfaces/ConstraintsInterface.java index a1daa08a56..820170dc0f 100644 --- a/app/src/main/java/info/nightscout/androidaps/interfaces/ConstraintsInterface.java +++ b/app/src/main/java/info/nightscout/androidaps/interfaces/ConstraintsInterface.java @@ -7,7 +7,7 @@ import info.nightscout.androidaps.data.Profile; */ public interface ConstraintsInterface { - default Constraint isLoopInvokationAllowed(Constraint value) { + default Constraint isLoopInvocationAllowed(Constraint value) { return value; } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/ConstraintsObjectives/ObjectivesFragment.java b/app/src/main/java/info/nightscout/androidaps/plugins/ConstraintsObjectives/ObjectivesFragment.java index 4f2cfa65e0..86f312e1df 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/ConstraintsObjectives/ObjectivesFragment.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/ConstraintsObjectives/ObjectivesFragment.java @@ -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 { - - List objectives; - - RecyclerViewAdapter(List 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 { + + @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: %3$s"; + 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(); }); } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/ConstraintsObjectives/ObjectivesPlugin.java b/app/src/main/java/info/nightscout/androidaps/plugins/ConstraintsObjectives/ObjectivesPlugin.java index 010bb1277a..a67f694eb8 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/ConstraintsObjectives/ObjectivesPlugin.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/ConstraintsObjectives/ObjectivesPlugin.java @@ -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 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 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 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 getObjectives() { + return objectives; + } + /** * Constraints interface **/ @Override - public Constraint isLoopInvokationAllowed(Constraint value) { + public Constraint isLoopInvocationAllowed(Constraint 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 applyMaxIOBConstraints(Constraint 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; } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/ConstraintsObjectives/objectives/Objective.java b/app/src/main/java/info/nightscout/androidaps/plugins/ConstraintsObjectives/objectives/Objective.java new file mode 100644 index 0000000000..6443e0d3f1 --- /dev/null +++ b/app/src/main/java/info/nightscout/androidaps/plugins/ConstraintsObjectives/objectives/Objective.java @@ -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 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 tasks) { + + } + + public List 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); + } + } + +} diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/ConstraintsObjectives/objectives/Objective1.java b/app/src/main/java/info/nightscout/androidaps/plugins/ConstraintsObjectives/objectives/Objective1.java new file mode 100644 index 0000000000..e374126b11 --- /dev/null +++ b/app/src/main/java/info/nightscout/androidaps/plugins/ConstraintsObjectives/objectives/Objective1.java @@ -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 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; + } + }); + } +} diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/ConstraintsObjectives/objectives/Objective2.java b/app/src/main/java/info/nightscout/androidaps/plugins/ConstraintsObjectives/objectives/Objective2.java new file mode 100644 index 0000000000..305f00ec6f --- /dev/null +++ b/app/src/main/java/info/nightscout/androidaps/plugins/ConstraintsObjectives/objectives/Objective2.java @@ -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 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; + } + }); + } +} diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/ConstraintsObjectives/objectives/Objective3.java b/app/src/main/java/info/nightscout/androidaps/plugins/ConstraintsObjectives/objectives/Objective3.java new file mode 100644 index 0000000000..8a84e3c83c --- /dev/null +++ b/app/src/main/java/info/nightscout/androidaps/plugins/ConstraintsObjectives/objectives/Objective3.java @@ -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); + } +} diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/ConstraintsObjectives/objectives/Objective4.java b/app/src/main/java/info/nightscout/androidaps/plugins/ConstraintsObjectives/objectives/Objective4.java new file mode 100644 index 0000000000..7700c94cb6 --- /dev/null +++ b/app/src/main/java/info/nightscout/androidaps/plugins/ConstraintsObjectives/objectives/Objective4.java @@ -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 tasks) { + tasks.add(new MinimumDurationTask(5L * 24L * 60L * 60L * 1000L)); + tasks.add(new Task(R.string.closedmodeenabled) { + @Override + public boolean isCompleted() { + Constraint closedLoopEnabled = new Constraint<>(true); + SafetyPlugin.getPlugin().isClosedLoopAllowed(closedLoopEnabled); + return closedLoopEnabled.value(); + } + }); + } +} diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/ConstraintsObjectives/objectives/Objective5.java b/app/src/main/java/info/nightscout/androidaps/plugins/ConstraintsObjectives/objectives/Objective5.java new file mode 100644 index 0000000000..563a114e05 --- /dev/null +++ b/app/src/main/java/info/nightscout/androidaps/plugins/ConstraintsObjectives/objectives/Objective5.java @@ -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 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; + } + }); + } +} diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/ConstraintsObjectives/objectives/Objective6.java b/app/src/main/java/info/nightscout/androidaps/plugins/ConstraintsObjectives/objectives/Objective6.java new file mode 100644 index 0000000000..7106d7522b --- /dev/null +++ b/app/src/main/java/info/nightscout/androidaps/plugins/ConstraintsObjectives/objectives/Objective6.java @@ -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 tasks) { + tasks.add(new MinimumDurationTask(7L * 24L * 60L * 60L * 1000L)); + } +} diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/ConstraintsObjectives/objectives/Objective7.java b/app/src/main/java/info/nightscout/androidaps/plugins/ConstraintsObjectives/objectives/Objective7.java new file mode 100644 index 0000000000..cfd041bf13 --- /dev/null +++ b/app/src/main/java/info/nightscout/androidaps/plugins/ConstraintsObjectives/objectives/Objective7.java @@ -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 tasks) { + tasks.add(new MinimumDurationTask(28L * 24L * 60L * 60L * 1000L)); + } +} diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/ConstraintsObjectives/objectives/Objective8.java b/app/src/main/java/info/nightscout/androidaps/plugins/ConstraintsObjectives/objectives/Objective8.java new file mode 100644 index 0000000000..70d75fd900 --- /dev/null +++ b/app/src/main/java/info/nightscout/androidaps/plugins/ConstraintsObjectives/objectives/Objective8.java @@ -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 tasks) { + tasks.add(new MinimumDurationTask(28L * 24L * 60L * 60L * 1000L)); + } +} diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/ConstraintsSafety/SafetyPlugin.java b/app/src/main/java/info/nightscout/androidaps/plugins/ConstraintsSafety/SafetyPlugin.java index 6a9613e92a..3d17970edc 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/ConstraintsSafety/SafetyPlugin.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/ConstraintsSafety/SafetyPlugin.java @@ -49,7 +49,7 @@ public class SafetyPlugin extends PluginBase implements ConstraintsInterface { * Constraints interface **/ @Override - public Constraint isLoopInvokationAllowed(Constraint value) { + public Constraint isLoopInvocationAllowed(Constraint value) { if (!ConfigBuilderPlugin.getActivePump().getPumpDescription().isTempBasalCapable) value.set(false, MainApp.gs(R.string.pumpisnottempbasalcapable), this); return value; diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpCombo/ComboPlugin.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpCombo/ComboPlugin.java index b1f2b076ae..e591551f55 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpCombo/ComboPlugin.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpCombo/ComboPlugin.java @@ -1357,7 +1357,7 @@ public class ComboPlugin extends PluginBase implements PumpInterface, Constraint private boolean validBasalRateProfileSelectedOnPump = true; @Override - public Constraint isLoopInvokationAllowed(Constraint value) { + public Constraint isLoopInvocationAllowed(Constraint value) { if (!validBasalRateProfileSelectedOnPump) value.set(false, MainApp.gs(R.string.novalidbasalrate), this); return value; diff --git a/app/src/main/java/info/nightscout/utils/HardLimits.java b/app/src/main/java/info/nightscout/utils/HardLimits.java index 8e1a05db0d..ed58687f8f 100644 --- a/app/src/main/java/info/nightscout/utils/HardLimits.java +++ b/app/src/main/java/info/nightscout/utils/HardLimits.java @@ -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}; diff --git a/app/src/main/res/layout/objectives_fragment.xml b/app/src/main/res/layout/objectives_fragment.xml index ea2028f5b4..8f984be622 100644 --- a/app/src/main/res/layout/objectives_fragment.xml +++ b/app/src/main/res/layout/objectives_fragment.xml @@ -1,46 +1,41 @@ - + android:layout_height="wrap_content" + android:gravity="center_vertical" + android:orientation="horizontal" + android:paddingLeft="16dp" + android:paddingRight="16dp" + android:paddingTop="16dp" + android:visibility="gone"> - + android:layout_marginRight="16dp" + android:layout_weight="1" + android:text="Enable fake time and progress" /> - - - - - - - - +