diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/constraints/objectives/ObjectivesFragment.java b/app/src/main/java/info/nightscout/androidaps/plugins/constraints/objectives/ObjectivesFragment.java index 7600c017c2..fa6e35ed34 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/constraints/objectives/ObjectivesFragment.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/constraints/objectives/ObjectivesFragment.java @@ -24,6 +24,7 @@ import info.nightscout.androidaps.MainApp; import info.nightscout.androidaps.R; import info.nightscout.androidaps.plugins.common.SubscriberFragment; import info.nightscout.androidaps.plugins.constraints.objectives.objectives.Objective; +import info.nightscout.androidaps.utils.DateUtil; import info.nightscout.androidaps.utils.FabricPrivacy; public class ObjectivesFragment extends SubscriberFragment { @@ -133,6 +134,7 @@ public class ObjectivesFragment extends SubscriberFragment { holder.gate.setTextColor(0xFFFFFFFF); holder.verify.setVisibility(View.GONE); holder.progress.setVisibility(View.GONE); + holder.accomplished.setVisibility(View.GONE); if (position == 0 || ObjectivesPlugin.getPlugin().getObjectives().get(position - 1).isAccomplished()) holder.start.setVisibility(View.VISIBLE); else holder.start.setVisibility(View.GONE); @@ -141,11 +143,13 @@ public class ObjectivesFragment extends SubscriberFragment { holder.verify.setVisibility(View.GONE); holder.progress.setVisibility(View.GONE); holder.start.setVisibility(View.GONE); + holder.accomplished.setVisibility(View.VISIBLE); } else if (objective.isStarted()) { holder.gate.setTextColor(0xFFFFFFFF); holder.verify.setVisibility(View.VISIBLE); holder.verify.setEnabled(objective.isCompleted() || enableFake.isChecked()); holder.start.setVisibility(View.GONE); + holder.accomplished.setVisibility(View.GONE); if(objective.isRevertable()) { holder.revert.setVisibility(View.VISIBLE); } @@ -161,6 +165,8 @@ public class ObjectivesFragment extends SubscriberFragment { holder.progress.addView(textView, LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT); } } + holder.accomplished.setText(MainApp.gs(R.string.accomplished, DateUtil.dateAndTimeString(objective.getAccomplishedOn()))); + holder.accomplished.setTextColor(0xFFC1C1C1); holder.verify.setOnClickListener((view) -> { objective.setAccomplishedOn(new Date()); notifyDataSetChanged(); @@ -198,6 +204,7 @@ public class ObjectivesFragment extends SubscriberFragment { public TextView title; public TextView objective; public TextView gate; + public TextView accomplished; public LinearLayout progress; public Button verify; public Button start; @@ -213,6 +220,7 @@ public class ObjectivesFragment extends SubscriberFragment { verify = itemView.findViewById(R.id.objective_verify); start = itemView.findViewById(R.id.objective_start); revert = itemView.findViewById(R.id.objective_back); + accomplished = itemView.findViewById(R.id.objective_accomplished); } } } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/constraints/objectives/objectives/Objective.java b/app/src/main/java/info/nightscout/androidaps/plugins/constraints/objectives/objectives/Objective.java index 55aba1b49f..936e028104 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/constraints/objectives/objectives/Objective.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/constraints/objectives/objectives/Objective.java @@ -76,6 +76,10 @@ public abstract class Objective { SP.putLong("Objectives" + number + "accomplished", accomplishedOn == null ? 0 : accomplishedOn.getTime()); } + public Date getAccomplishedOn() { + return accomplishedOn; + } + protected void setupTasks(List tasks) { } diff --git a/app/src/main/res/layout/objectives_item.xml b/app/src/main/res/layout/objectives_item.xml index 7a7f461433..d11992b13f 100644 --- a/app/src/main/res/layout/objectives_item.xml +++ b/app/src/main/res/layout/objectives_item.xml @@ -71,6 +71,15 @@ android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="@string/objectives_button_back" /> + + + diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 7af0131011..b19dbe0022 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -1605,6 +1605,7 @@ Bolus wizard performs calculation but only this part of calculated insulin is delivered. Useful with SMB algorithm. Loading ... Snooze + Accomplished: %1$s %1$d day