show accomplished

This commit is contained in:
Milos Kozak 2019-09-01 10:33:17 +02:00
parent 0de7413427
commit 3274f372ef
4 changed files with 22 additions and 0 deletions

View file

@ -24,6 +24,7 @@ import info.nightscout.androidaps.MainApp;
import info.nightscout.androidaps.R; import info.nightscout.androidaps.R;
import info.nightscout.androidaps.plugins.common.SubscriberFragment; import info.nightscout.androidaps.plugins.common.SubscriberFragment;
import info.nightscout.androidaps.plugins.constraints.objectives.objectives.Objective; import info.nightscout.androidaps.plugins.constraints.objectives.objectives.Objective;
import info.nightscout.androidaps.utils.DateUtil;
import info.nightscout.androidaps.utils.FabricPrivacy; import info.nightscout.androidaps.utils.FabricPrivacy;
public class ObjectivesFragment extends SubscriberFragment { public class ObjectivesFragment extends SubscriberFragment {
@ -133,6 +134,7 @@ public class ObjectivesFragment extends SubscriberFragment {
holder.gate.setTextColor(0xFFFFFFFF); holder.gate.setTextColor(0xFFFFFFFF);
holder.verify.setVisibility(View.GONE); holder.verify.setVisibility(View.GONE);
holder.progress.setVisibility(View.GONE); holder.progress.setVisibility(View.GONE);
holder.accomplished.setVisibility(View.GONE);
if (position == 0 || ObjectivesPlugin.getPlugin().getObjectives().get(position - 1).isAccomplished()) if (position == 0 || ObjectivesPlugin.getPlugin().getObjectives().get(position - 1).isAccomplished())
holder.start.setVisibility(View.VISIBLE); holder.start.setVisibility(View.VISIBLE);
else holder.start.setVisibility(View.GONE); else holder.start.setVisibility(View.GONE);
@ -141,11 +143,13 @@ public class ObjectivesFragment extends SubscriberFragment {
holder.verify.setVisibility(View.GONE); holder.verify.setVisibility(View.GONE);
holder.progress.setVisibility(View.GONE); holder.progress.setVisibility(View.GONE);
holder.start.setVisibility(View.GONE); holder.start.setVisibility(View.GONE);
holder.accomplished.setVisibility(View.VISIBLE);
} else if (objective.isStarted()) { } else if (objective.isStarted()) {
holder.gate.setTextColor(0xFFFFFFFF); holder.gate.setTextColor(0xFFFFFFFF);
holder.verify.setVisibility(View.VISIBLE); holder.verify.setVisibility(View.VISIBLE);
holder.verify.setEnabled(objective.isCompleted() || enableFake.isChecked()); holder.verify.setEnabled(objective.isCompleted() || enableFake.isChecked());
holder.start.setVisibility(View.GONE); holder.start.setVisibility(View.GONE);
holder.accomplished.setVisibility(View.GONE);
if(objective.isRevertable()) { if(objective.isRevertable()) {
holder.revert.setVisibility(View.VISIBLE); 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.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) -> { holder.verify.setOnClickListener((view) -> {
objective.setAccomplishedOn(new Date()); objective.setAccomplishedOn(new Date());
notifyDataSetChanged(); notifyDataSetChanged();
@ -198,6 +204,7 @@ public class ObjectivesFragment extends SubscriberFragment {
public TextView title; public TextView title;
public TextView objective; public TextView objective;
public TextView gate; public TextView gate;
public TextView accomplished;
public LinearLayout progress; public LinearLayout progress;
public Button verify; public Button verify;
public Button start; public Button start;
@ -213,6 +220,7 @@ public class ObjectivesFragment extends SubscriberFragment {
verify = itemView.findViewById(R.id.objective_verify); verify = itemView.findViewById(R.id.objective_verify);
start = itemView.findViewById(R.id.objective_start); start = itemView.findViewById(R.id.objective_start);
revert = itemView.findViewById(R.id.objective_back); revert = itemView.findViewById(R.id.objective_back);
accomplished = itemView.findViewById(R.id.objective_accomplished);
} }
} }
} }

View file

@ -76,6 +76,10 @@ public abstract class Objective {
SP.putLong("Objectives" + number + "accomplished", accomplishedOn == null ? 0 : accomplishedOn.getTime()); SP.putLong("Objectives" + number + "accomplished", accomplishedOn == null ? 0 : accomplishedOn.getTime());
} }
public Date getAccomplishedOn() {
return accomplishedOn;
}
protected void setupTasks(List<Task> tasks) { protected void setupTasks(List<Task> tasks) {
} }

View file

@ -71,6 +71,15 @@
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:text="@string/objectives_button_back" /> android:text="@string/objectives_button_back" />
<TextView
android:id="@+id/objective_accomplished"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="8dp"
android:textColor="#FFFFFF"
tools:text="Accomplished" />
</LinearLayout> </LinearLayout>
</androidx.cardview.widget.CardView> </androidx.cardview.widget.CardView>

View file

@ -1605,6 +1605,7 @@
<string name="deliverpartofboluswizard">Bolus wizard performs calculation but only this part of calculated insulin is delivered. Useful with SMB algorithm.</string> <string name="deliverpartofboluswizard">Bolus wizard performs calculation but only this part of calculated insulin is delivered. Useful with SMB algorithm.</string>
<string name="loading">Loading ...</string> <string name="loading">Loading ...</string>
<string name="snooze">Snooze</string> <string name="snooze">Snooze</string>
<string name="accomplished">Accomplished: %1$s</string>
<plurals name="objective_days"> <plurals name="objective_days">
<item quantity="one">%1$d day</item> <item quantity="one">%1$d day</item>