Constrains interface
This commit is contained in:
parent
26724ecbda
commit
ddb1868018
|
@ -0,0 +1,7 @@
|
||||||
|
package info.nightscout.androidaps.interfaces;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Created by mike on 15.06.2016.
|
||||||
|
*/
|
||||||
|
public interface ConstrainsInterface {
|
||||||
|
}
|
|
@ -12,6 +12,7 @@ public interface PluginBase {
|
||||||
int PROFILE = 4;
|
int PROFILE = 4;
|
||||||
int APS = 5;
|
int APS = 5;
|
||||||
int PUMP = 6;
|
int PUMP = 6;
|
||||||
|
int CONSTRAINS = 7;
|
||||||
|
|
||||||
public int getType();
|
public int getType();
|
||||||
|
|
||||||
|
|
|
@ -12,6 +12,7 @@ import android.view.ViewGroup;
|
||||||
import android.widget.AdapterView;
|
import android.widget.AdapterView;
|
||||||
import android.widget.ArrayAdapter;
|
import android.widget.ArrayAdapter;
|
||||||
import android.widget.CheckBox;
|
import android.widget.CheckBox;
|
||||||
|
import android.widget.ListAdapter;
|
||||||
import android.widget.ListView;
|
import android.widget.ListView;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
import android.widget.Toast;
|
import android.widget.Toast;
|
||||||
|
@ -52,6 +53,7 @@ public class ConfigBuilderFragment extends Fragment implements PluginBase, PumpI
|
||||||
ListView tempsListView;
|
ListView tempsListView;
|
||||||
ListView profileListView;
|
ListView profileListView;
|
||||||
ListView apsListView;
|
ListView apsListView;
|
||||||
|
ListView constrainsListView;
|
||||||
ListView generalListView;
|
ListView generalListView;
|
||||||
|
|
||||||
PluginCustomAdapter pumpDataAdapter = null;
|
PluginCustomAdapter pumpDataAdapter = null;
|
||||||
|
@ -59,6 +61,7 @@ public class ConfigBuilderFragment extends Fragment implements PluginBase, PumpI
|
||||||
PluginCustomAdapter tempsDataAdapter = null;
|
PluginCustomAdapter tempsDataAdapter = null;
|
||||||
PluginCustomAdapter profileDataAdapter = null;
|
PluginCustomAdapter profileDataAdapter = null;
|
||||||
PluginCustomAdapter apsDataAdapter = null;
|
PluginCustomAdapter apsDataAdapter = null;
|
||||||
|
PluginCustomAdapter constrainsDataAdapter = null;
|
||||||
PluginCustomAdapter generalDataAdapter = null;
|
PluginCustomAdapter generalDataAdapter = null;
|
||||||
|
|
||||||
|
|
||||||
|
@ -102,6 +105,7 @@ public class ConfigBuilderFragment extends Fragment implements PluginBase, PumpI
|
||||||
tempsListView = (ListView) view.findViewById(R.id.configbuilder_tempslistview);
|
tempsListView = (ListView) view.findViewById(R.id.configbuilder_tempslistview);
|
||||||
profileListView = (ListView) view.findViewById(R.id.configbuilder_profilelistview);
|
profileListView = (ListView) view.findViewById(R.id.configbuilder_profilelistview);
|
||||||
apsListView = (ListView) view.findViewById(R.id.configbuilder_apslistview);
|
apsListView = (ListView) view.findViewById(R.id.configbuilder_apslistview);
|
||||||
|
constrainsListView = (ListView) view.findViewById(R.id.configbuilder_constrainslistview);
|
||||||
generalListView = (ListView) view.findViewById(R.id.configbuilder_generallistview);
|
generalListView = (ListView) view.findViewById(R.id.configbuilder_generallistview);
|
||||||
|
|
||||||
setViews();
|
setViews();
|
||||||
|
@ -111,28 +115,26 @@ public class ConfigBuilderFragment extends Fragment implements PluginBase, PumpI
|
||||||
void setViews() {
|
void setViews() {
|
||||||
pumpDataAdapter = new PluginCustomAdapter(getContext(), R.layout.configbuilder_simpleitem, MainActivity.getSpecificPluginsList(PluginBase.PUMP));
|
pumpDataAdapter = new PluginCustomAdapter(getContext(), R.layout.configbuilder_simpleitem, MainActivity.getSpecificPluginsList(PluginBase.PUMP));
|
||||||
pumpListView.setAdapter(pumpDataAdapter);
|
pumpListView.setAdapter(pumpDataAdapter);
|
||||||
|
setListViewHeightBasedOnChildren(pumpListView);
|
||||||
treatmentsDataAdapter = new PluginCustomAdapter(getContext(), R.layout.configbuilder_simpleitem, MainActivity.getSpecificPluginsList(PluginBase.TREATMENT));
|
treatmentsDataAdapter = new PluginCustomAdapter(getContext(), R.layout.configbuilder_simpleitem, MainActivity.getSpecificPluginsList(PluginBase.TREATMENT));
|
||||||
treatmentsListView.setAdapter(treatmentsDataAdapter);
|
treatmentsListView.setAdapter(treatmentsDataAdapter);
|
||||||
|
setListViewHeightBasedOnChildren(treatmentsListView);
|
||||||
tempsDataAdapter = new PluginCustomAdapter(getContext(), R.layout.configbuilder_simpleitem, MainActivity.getSpecificPluginsList(PluginBase.TEMPBASAL));
|
tempsDataAdapter = new PluginCustomAdapter(getContext(), R.layout.configbuilder_simpleitem, MainActivity.getSpecificPluginsList(PluginBase.TEMPBASAL));
|
||||||
tempsListView.setAdapter(tempsDataAdapter);
|
tempsListView.setAdapter(tempsDataAdapter);
|
||||||
|
setListViewHeightBasedOnChildren(tempsListView);
|
||||||
profileDataAdapter = new PluginCustomAdapter(getContext(), R.layout.configbuilder_simpleitem, MainActivity.getSpecificPluginsList(PluginBase.PROFILE));
|
profileDataAdapter = new PluginCustomAdapter(getContext(), R.layout.configbuilder_simpleitem, MainActivity.getSpecificPluginsList(PluginBase.PROFILE));
|
||||||
profileListView.setAdapter(profileDataAdapter);
|
profileListView.setAdapter(profileDataAdapter);
|
||||||
|
setListViewHeightBasedOnChildren(profileListView);
|
||||||
apsDataAdapter = new PluginCustomAdapter(getContext(), R.layout.configbuilder_simpleitem, MainActivity.getSpecificPluginsList(PluginBase.APS));
|
apsDataAdapter = new PluginCustomAdapter(getContext(), R.layout.configbuilder_simpleitem, MainActivity.getSpecificPluginsList(PluginBase.APS));
|
||||||
apsListView.setAdapter(apsDataAdapter);
|
apsListView.setAdapter(apsDataAdapter);
|
||||||
|
setListViewHeightBasedOnChildren(apsListView);
|
||||||
|
constrainsDataAdapter = new PluginCustomAdapter(getContext(), R.layout.configbuilder_simpleitem, MainActivity.getSpecificPluginsList(PluginBase.CONSTRAINS));
|
||||||
|
constrainsListView.setAdapter(constrainsDataAdapter);
|
||||||
|
setListViewHeightBasedOnChildren(constrainsListView);
|
||||||
generalDataAdapter = new PluginCustomAdapter(getContext(), R.layout.configbuilder_simpleitem, MainActivity.getSpecificPluginsList(PluginBase.GENERAL));
|
generalDataAdapter = new PluginCustomAdapter(getContext(), R.layout.configbuilder_simpleitem, MainActivity.getSpecificPluginsList(PluginBase.GENERAL));
|
||||||
generalListView.setAdapter(generalDataAdapter);
|
generalListView.setAdapter(generalDataAdapter);
|
||||||
|
setListViewHeightBasedOnChildren(generalListView);
|
||||||
|
|
||||||
|
|
||||||
apsListView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
|
|
||||||
public void onItemClick(AdapterView<?> parent, View view,
|
|
||||||
int position, long id) {
|
|
||||||
// When clicked, show a toast with the TextView text
|
|
||||||
PluginBase plugin = (PluginBase) parent.getItemAtPosition(position);
|
|
||||||
Toast.makeText(MainApp.instance().getApplicationContext(),
|
|
||||||
"Clicked on Row: " + plugin.getName(),
|
|
||||||
Toast.LENGTH_LONG).show();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -307,10 +309,6 @@ public class ConfigBuilderFragment extends Fragment implements PluginBase, PumpI
|
||||||
public void onClick(View v) {
|
public void onClick(View v) {
|
||||||
CheckBox cb = (CheckBox) v;
|
CheckBox cb = (CheckBox) v;
|
||||||
PluginBase plugin = (PluginBase) cb.getTag();
|
PluginBase plugin = (PluginBase) cb.getTag();
|
||||||
Toast.makeText(MainApp.instance().getApplicationContext(),
|
|
||||||
"Clicked on ENABLED: " + plugin.getName() +
|
|
||||||
" is " + cb.isChecked(),
|
|
||||||
Toast.LENGTH_LONG).show();
|
|
||||||
plugin.setFragmentEnabled(cb.isChecked());
|
plugin.setFragmentEnabled(cb.isChecked());
|
||||||
onEnabledCategoryChanged(plugin);
|
onEnabledCategoryChanged(plugin);
|
||||||
}
|
}
|
||||||
|
@ -320,10 +318,6 @@ public class ConfigBuilderFragment extends Fragment implements PluginBase, PumpI
|
||||||
public void onClick(View v) {
|
public void onClick(View v) {
|
||||||
CheckBox cb = (CheckBox) v;
|
CheckBox cb = (CheckBox) v;
|
||||||
PluginBase plugin = (PluginBase) cb.getTag();
|
PluginBase plugin = (PluginBase) cb.getTag();
|
||||||
Toast.makeText(MainApp.instance().getApplicationContext(),
|
|
||||||
"Clicked on VISIBLE: " + plugin.getName() +
|
|
||||||
" is " + cb.isChecked(),
|
|
||||||
Toast.LENGTH_LONG).show();
|
|
||||||
plugin.setFragmentVisible(cb.isChecked());
|
plugin.setFragmentVisible(cb.isChecked());
|
||||||
MainApp.bus().post(new EventRefreshGui());
|
MainApp.bus().post(new EventRefreshGui());
|
||||||
storeSettings();
|
storeSettings();
|
||||||
|
@ -350,6 +344,8 @@ public class ConfigBuilderFragment extends Fragment implements PluginBase, PumpI
|
||||||
if (type == PluginBase.PUMP || type == PluginBase.TREATMENT || type == PluginBase.TEMPBASAL || type == PluginBase.PROFILE)
|
if (type == PluginBase.PUMP || type == PluginBase.TREATMENT || type == PluginBase.TEMPBASAL || type == PluginBase.PROFILE)
|
||||||
if (pluginList.size() < 2)
|
if (pluginList.size() < 2)
|
||||||
holder.checkboxEnabled.setEnabled(false);
|
holder.checkboxEnabled.setEnabled(false);
|
||||||
|
if (type == PluginBase.CONSTRAINS)
|
||||||
|
holder.checkboxEnabled.setEnabled(false);
|
||||||
|
|
||||||
return convertView;
|
return convertView;
|
||||||
|
|
||||||
|
@ -378,6 +374,7 @@ public class ConfigBuilderFragment extends Fragment implements PluginBase, PumpI
|
||||||
// Multiple selection allowed
|
// Multiple selection allowed
|
||||||
case PluginBase.APS:
|
case PluginBase.APS:
|
||||||
case PluginBase.GENERAL:
|
case PluginBase.GENERAL:
|
||||||
|
case PluginBase.CONSTRAINS:
|
||||||
break;
|
break;
|
||||||
// Single selection allowed
|
// Single selection allowed
|
||||||
case PluginBase.PROFILE:
|
case PluginBase.PROFILE:
|
||||||
|
@ -409,6 +406,7 @@ public class ConfigBuilderFragment extends Fragment implements PluginBase, PumpI
|
||||||
// Multiple selection allowed
|
// Multiple selection allowed
|
||||||
case PluginBase.APS:
|
case PluginBase.APS:
|
||||||
case PluginBase.GENERAL:
|
case PluginBase.GENERAL:
|
||||||
|
case PluginBase.CONSTRAINS:
|
||||||
break;
|
break;
|
||||||
// Single selection allowed
|
// Single selection allowed
|
||||||
case PluginBase.PROFILE:
|
case PluginBase.PROFILE:
|
||||||
|
@ -480,5 +478,29 @@ public class ConfigBuilderFragment extends Fragment implements PluginBase, PumpI
|
||||||
verifySelectionInCategories();
|
verifySelectionInCategories();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/****
|
||||||
|
* Method for Setting the Height of the ListView dynamically.
|
||||||
|
* *** Hack to fix the issue of not showing all the items of the ListView
|
||||||
|
* *** when placed inside a ScrollView
|
||||||
|
****/
|
||||||
|
public static void setListViewHeightBasedOnChildren(ListView listView) {
|
||||||
|
ListAdapter listAdapter = listView.getAdapter();
|
||||||
|
if (listAdapter == null)
|
||||||
|
return;
|
||||||
|
|
||||||
|
int desiredWidth = View.MeasureSpec.makeMeasureSpec(listView.getWidth(), View.MeasureSpec.UNSPECIFIED);
|
||||||
|
int totalHeight = 0;
|
||||||
|
View view = null;
|
||||||
|
for (int i = 0; i < listAdapter.getCount(); i++) {
|
||||||
|
view = listAdapter.getView(i, view, listView);
|
||||||
|
if (i == 0)
|
||||||
|
view.setLayoutParams(new ViewGroup.LayoutParams(desiredWidth, ViewGroup.LayoutParams.WRAP_CONTENT));
|
||||||
|
|
||||||
|
view.measure(desiredWidth, View.MeasureSpec.UNSPECIFIED);
|
||||||
|
totalHeight += view.getMeasuredHeight();
|
||||||
|
}
|
||||||
|
ViewGroup.LayoutParams params = listView.getLayoutParams();
|
||||||
|
params.height = totalHeight + (listView.getDividerHeight() * (listAdapter.getCount() - 1));
|
||||||
|
listView.setLayoutParams(params);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
package info.nightscout.androidaps.plugins.Objectives;
|
package info.nightscout.androidaps.plugins.Objectives;
|
||||||
|
|
||||||
|
import android.content.Context;
|
||||||
|
import android.content.SharedPreferences;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.support.v4.app.Fragment;
|
import android.support.v4.app.Fragment;
|
||||||
import android.support.v7.widget.CardView;
|
import android.support.v7.widget.CardView;
|
||||||
|
@ -8,25 +10,38 @@ import android.support.v7.widget.RecyclerView;
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
|
import android.widget.Button;
|
||||||
|
import android.widget.CheckBox;
|
||||||
|
import android.widget.LinearLayout;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
import info.nightscout.androidaps.Config;
|
||||||
import info.nightscout.androidaps.MainApp;
|
import info.nightscout.androidaps.MainApp;
|
||||||
import info.nightscout.androidaps.R;
|
import info.nightscout.androidaps.R;
|
||||||
|
import info.nightscout.androidaps.interfaces.ConstrainsInterface;
|
||||||
import info.nightscout.androidaps.interfaces.PluginBase;
|
import info.nightscout.androidaps.interfaces.PluginBase;
|
||||||
|
|
||||||
public class ObjectivesFragment extends Fragment implements PluginBase {
|
public class ObjectivesFragment extends Fragment implements View.OnClickListener, PluginBase, ConstrainsInterface {
|
||||||
|
private static Logger log = LoggerFactory.getLogger(ObjectivesFragment.class);
|
||||||
|
|
||||||
RecyclerView recyclerView;
|
RecyclerView recyclerView;
|
||||||
LinearLayoutManager llm;
|
LinearLayoutManager llm;
|
||||||
|
CheckBox enableFakeTime;
|
||||||
|
|
||||||
boolean fragmentVisible = true;
|
boolean fragmentVisible = true;
|
||||||
|
|
||||||
|
String PREFS_NAME = "Objectives";
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getType() {
|
public int getType() {
|
||||||
return PluginBase.GENERAL;
|
return PluginBase.CONSTRAINS;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -58,6 +73,15 @@ public class ObjectivesFragment extends Fragment implements PluginBase {
|
||||||
this.fragmentVisible = fragmentVisible;
|
this.fragmentVisible = fragmentVisible;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onClick(View v) {
|
||||||
|
int id = v.getId();
|
||||||
|
switch (id) {
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
class Objective {
|
class Objective {
|
||||||
String objective;
|
String objective;
|
||||||
String gate;
|
String gate;
|
||||||
|
@ -95,13 +119,41 @@ public class ObjectivesFragment extends Fragment implements PluginBase {
|
||||||
new Date(0, 0, 0), 1, new Date(0, 0, 0)));
|
new Date(0, 0, 0), 1, new Date(0, 0, 0)));
|
||||||
objectives.add(new Objective("Adjust basals and ratios if needed, and then enable auto-sens",
|
objectives.add(new Objective("Adjust basals and ratios if needed, and then enable auto-sens",
|
||||||
"1 week successful daytime looping with regular carb entry",
|
"1 week successful daytime looping with regular carb entry",
|
||||||
new Date(0, 0, 0), 1, new Date(0, 0, 0)));
|
new Date(0, 0, 0), 7, new Date(0, 0, 0)));
|
||||||
objectives.add(new Objective("Enabling additional features for daytime use, such as advanced meal assist",
|
objectives.add(new Objective("Enabling additional features for daytime use, such as advanced meal assist",
|
||||||
"",
|
"",
|
||||||
new Date(0, 0, 0), 1, new Date(0, 0, 0)));
|
new Date(0, 0, 0), 1, new Date(0, 0, 0)));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class RecyclerViewAdapter extends RecyclerView.Adapter<RecyclerViewAdapter.ObjectiveViewHolder> {
|
void saveProgress() {
|
||||||
|
SharedPreferences settings = MainApp.instance().getApplicationContext().getSharedPreferences(PREFS_NAME, 0);
|
||||||
|
SharedPreferences.Editor editor = settings.edit();
|
||||||
|
for (int num = 0; num < objectives.size(); num++) {
|
||||||
|
Objective o = objectives.get(num);
|
||||||
|
editor.putLong(num + "started", o.started.getTime());
|
||||||
|
editor.putLong(num + "accomplished", o.accomplished.getTime());
|
||||||
|
}
|
||||||
|
editor.commit();
|
||||||
|
if (Config.logPrefsChange)
|
||||||
|
log.debug("Objectives stored");
|
||||||
|
}
|
||||||
|
|
||||||
|
void loadProgress() {
|
||||||
|
SharedPreferences settings = MainApp.instance().getApplicationContext().getSharedPreferences(PREFS_NAME, 0);
|
||||||
|
for (int num = 0; num < objectives.size(); num++) {
|
||||||
|
Objective o = objectives.get(num);
|
||||||
|
o.started = new Date(settings.getLong(num + "started", 0));
|
||||||
|
o.accomplished = new Date(settings.getLong(num + "accomplished", 0));
|
||||||
|
}
|
||||||
|
if (Config.logPrefsChange)
|
||||||
|
log.debug("Objectives loaded");
|
||||||
|
}
|
||||||
|
|
||||||
|
boolean isAPSEnabledAtAll() {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public class RecyclerViewAdapter extends RecyclerView.Adapter<RecyclerViewAdapter.ObjectiveViewHolder> {
|
||||||
|
|
||||||
List<Objective> objectives;
|
List<Objective> objectives;
|
||||||
|
|
||||||
|
@ -118,11 +170,61 @@ public class ObjectivesFragment extends Fragment implements PluginBase {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onBindViewHolder(ObjectiveViewHolder holder, int position) {
|
public void onBindViewHolder(ObjectiveViewHolder holder, int position) {
|
||||||
|
Objective o = objectives.get(position);
|
||||||
|
Context context = MainApp.instance().getApplicationContext();
|
||||||
holder.position.setText(String.valueOf(position + 1));
|
holder.position.setText(String.valueOf(position + 1));
|
||||||
holder.objective.setText(objectives.get(position).objective);
|
holder.objective.setText(o.objective);
|
||||||
holder.gate.setText(objectives.get(position).gate);
|
holder.gate.setText(o.gate);
|
||||||
holder.started.setText(objectives.get(position).started.toString());
|
holder.duration.setText(context.getString(R.string.minimalduration) + " " + o.durationInDays + " " + context.getString(R.string.days));
|
||||||
holder.accomplished.setText(objectives.get(position).accomplished.toString());
|
holder.started.setText(o.started.toLocaleString());
|
||||||
|
holder.accomplished.setText(o.accomplished.toLocaleString());
|
||||||
|
|
||||||
|
holder.startButton.setTag(o);
|
||||||
|
holder.verifyButton.setTag(o);
|
||||||
|
|
||||||
|
holder.startButton.setOnClickListener(new View.OnClickListener() {
|
||||||
|
public void onClick(View v) {
|
||||||
|
Objective o = (Objective) v.getTag();
|
||||||
|
o.started = new Date();
|
||||||
|
updateView();
|
||||||
|
//saveProgress();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
holder.verifyButton.setOnClickListener(new View.OnClickListener() {
|
||||||
|
public void onClick(View v) {
|
||||||
|
Objective o = (Objective) v.getTag();
|
||||||
|
o.accomplished = new Date();
|
||||||
|
updateView();
|
||||||
|
//saveProgress();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
Long now = new Date().getTime();
|
||||||
|
if (position > 0 && objectives.get(position - 1).accomplished.getTime() == 0) {
|
||||||
|
// Phase 0: previous not completed
|
||||||
|
holder.startedLayout.setVisibility(View.GONE);
|
||||||
|
holder.durationLayout.setVisibility(View.GONE);
|
||||||
|
holder.verifyLayout.setVisibility(View.GONE);
|
||||||
|
} else if (o.started.getTime() == 0) {
|
||||||
|
// Phase 1: not started
|
||||||
|
holder.durationLayout.setVisibility(View.GONE);
|
||||||
|
holder.verifyLayout.setVisibility(View.GONE);
|
||||||
|
holder.started.setVisibility(View.GONE);
|
||||||
|
} else if (o.started.getTime() > 0 && !enableFakeTime.isChecked() && o.accomplished.getTime() == 0 && o.started.getTime() + o.durationInDays * 24 * 60 * 60 * 1000 > now) {
|
||||||
|
// Phase 2: started, waiting for duration
|
||||||
|
holder.startButton.setEnabled(false);
|
||||||
|
holder.verifyLayout.setVisibility(View.GONE);
|
||||||
|
} else if (o.accomplished.getTime() == 0 ) {
|
||||||
|
// Phase 3: started, after duration
|
||||||
|
holder.startButton.setEnabled(false);
|
||||||
|
holder.accomplished.setVisibility(View.INVISIBLE);
|
||||||
|
} else {
|
||||||
|
// Phase 4: verified
|
||||||
|
holder.gateLayout.setVisibility(View.GONE);
|
||||||
|
holder.startedLayout.setVisibility(View.GONE);
|
||||||
|
holder.durationLayout.setVisibility(View.GONE);
|
||||||
|
holder.verifyButton.setVisibility(View.INVISIBLE);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -135,22 +237,36 @@ public class ObjectivesFragment extends Fragment implements PluginBase {
|
||||||
super.onAttachedToRecyclerView(recyclerView);
|
super.onAttachedToRecyclerView(recyclerView);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class ObjectiveViewHolder extends RecyclerView.ViewHolder {
|
public class ObjectiveViewHolder extends RecyclerView.ViewHolder {
|
||||||
CardView cv;
|
CardView cv;
|
||||||
TextView position;
|
TextView position;
|
||||||
TextView objective;
|
TextView objective;
|
||||||
|
LinearLayout gateLayout;
|
||||||
TextView gate;
|
TextView gate;
|
||||||
|
TextView duration;
|
||||||
|
LinearLayout durationLayout;
|
||||||
TextView started;
|
TextView started;
|
||||||
|
Button startButton;
|
||||||
|
LinearLayout startedLayout;
|
||||||
TextView accomplished;
|
TextView accomplished;
|
||||||
|
Button verifyButton;
|
||||||
|
LinearLayout verifyLayout;
|
||||||
|
|
||||||
ObjectiveViewHolder(View itemView) {
|
ObjectiveViewHolder(View itemView) {
|
||||||
super(itemView);
|
super(itemView);
|
||||||
cv = (CardView) itemView.findViewById(R.id.objectives_cardview);
|
cv = (CardView) itemView.findViewById(R.id.objectives_cardview);
|
||||||
position = (TextView) itemView.findViewById(R.id.objectives_position);
|
position = (TextView) itemView.findViewById(R.id.objectives_position);
|
||||||
objective = (TextView) itemView.findViewById(R.id.objectives_objective);
|
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);
|
||||||
|
gateLayout = (LinearLayout) itemView.findViewById(R.id.objectives_gate_linearlayout);
|
||||||
gate = (TextView) itemView.findViewById(R.id.objectives_gate);
|
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);
|
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);
|
accomplished = (TextView) itemView.findViewById(R.id.objectives_accomplished);
|
||||||
|
verifyButton = (Button) itemView.findViewById(R.id.objectives_verify);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -158,6 +274,7 @@ public class ObjectivesFragment extends Fragment implements PluginBase {
|
||||||
public ObjectivesFragment() {
|
public ObjectivesFragment() {
|
||||||
super();
|
super();
|
||||||
initializeData();
|
initializeData();
|
||||||
|
loadProgress();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static ObjectivesFragment newInstance() {
|
public static ObjectivesFragment newInstance() {
|
||||||
|
@ -179,11 +296,20 @@ public class ObjectivesFragment extends Fragment implements PluginBase {
|
||||||
recyclerView.setHasFixedSize(true);
|
recyclerView.setHasFixedSize(true);
|
||||||
llm = new LinearLayoutManager(view.getContext());
|
llm = new LinearLayoutManager(view.getContext());
|
||||||
recyclerView.setLayoutManager(llm);
|
recyclerView.setLayoutManager(llm);
|
||||||
|
enableFakeTime = (CheckBox) view.findViewById(R.id.objectives_faketime);
|
||||||
RecyclerViewAdapter adapter = new RecyclerViewAdapter(objectives);
|
enableFakeTime.setOnClickListener(new View.OnClickListener() {
|
||||||
recyclerView.setAdapter(adapter);
|
public void onClick(View v) {
|
||||||
|
updateView();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
updateView();
|
||||||
|
|
||||||
return view;
|
return view;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void updateView() {
|
||||||
|
RecyclerViewAdapter adapter = new RecyclerViewAdapter(objectives);
|
||||||
|
recyclerView.setAdapter(adapter);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,6 +4,10 @@
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
tools:context="info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderFragment">
|
tools:context="info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderFragment">
|
||||||
|
|
||||||
|
<ScrollView
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent">
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
|
@ -14,7 +18,8 @@
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:text="@string/configbuilder_pump"
|
android:text="@string/configbuilder_pump"
|
||||||
android:textAppearance="?android:attr/textAppearanceMedium"
|
android:textAppearance="?android:attr/textAppearanceMedium"
|
||||||
android:textStyle="bold" />
|
android:textStyle="bold"
|
||||||
|
android:layout_marginLeft="5dp" />
|
||||||
|
|
||||||
<ListView
|
<ListView
|
||||||
android:id="@+id/configbuilder_pumplistview"
|
android:id="@+id/configbuilder_pumplistview"
|
||||||
|
@ -29,7 +34,8 @@
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:text="@string/configbuilder_treatments"
|
android:text="@string/configbuilder_treatments"
|
||||||
android:textAppearance="?android:attr/textAppearanceMedium"
|
android:textAppearance="?android:attr/textAppearanceMedium"
|
||||||
android:textStyle="bold" />
|
android:textStyle="bold"
|
||||||
|
android:layout_marginLeft="5dp" />
|
||||||
|
|
||||||
<ListView
|
<ListView
|
||||||
android:id="@+id/configbuilder_treatmentslistview"
|
android:id="@+id/configbuilder_treatmentslistview"
|
||||||
|
@ -44,7 +50,8 @@
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:text="@string/configbuilder_tempbasals"
|
android:text="@string/configbuilder_tempbasals"
|
||||||
android:textAppearance="?android:attr/textAppearanceMedium"
|
android:textAppearance="?android:attr/textAppearanceMedium"
|
||||||
android:textStyle="bold" />
|
android:textStyle="bold"
|
||||||
|
android:layout_marginLeft="5dp" />
|
||||||
|
|
||||||
<ListView
|
<ListView
|
||||||
android:id="@+id/configbuilder_tempslistview"
|
android:id="@+id/configbuilder_tempslistview"
|
||||||
|
@ -59,7 +66,8 @@
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:text="@string/configbuilder_profile"
|
android:text="@string/configbuilder_profile"
|
||||||
android:textAppearance="?android:attr/textAppearanceMedium"
|
android:textAppearance="?android:attr/textAppearanceMedium"
|
||||||
android:textStyle="bold" />
|
android:textStyle="bold"
|
||||||
|
android:layout_marginLeft="5dp" />
|
||||||
|
|
||||||
<ListView
|
<ListView
|
||||||
android:id="@+id/configbuilder_profilelistview"
|
android:id="@+id/configbuilder_profilelistview"
|
||||||
|
@ -74,7 +82,8 @@
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:text="@string/configbuilder_aps"
|
android:text="@string/configbuilder_aps"
|
||||||
android:textAppearance="?android:attr/textAppearanceMedium"
|
android:textAppearance="?android:attr/textAppearanceMedium"
|
||||||
android:textStyle="bold" />
|
android:textStyle="bold"
|
||||||
|
android:layout_marginLeft="5dp" />
|
||||||
|
|
||||||
<ListView
|
<ListView
|
||||||
android:id="@+id/configbuilder_apslistview"
|
android:id="@+id/configbuilder_apslistview"
|
||||||
|
@ -84,12 +93,29 @@
|
||||||
android:layout_marginRight="10dp"
|
android:layout_marginRight="10dp"
|
||||||
android:background="@color/cardColorBackground" />
|
android:background="@color/cardColorBackground" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:text="@string/configbuilder_constrains"
|
||||||
|
android:textAppearance="?android:attr/textAppearanceMedium"
|
||||||
|
android:textStyle="bold"
|
||||||
|
android:layout_marginLeft="5dp" />
|
||||||
|
|
||||||
|
<ListView
|
||||||
|
android:id="@+id/configbuilder_constrainslistview"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginLeft="10dp"
|
||||||
|
android:layout_marginRight="10dp"
|
||||||
|
android:background="@color/cardColorBackground" />
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:text="@string/configbuilder_general"
|
android:text="@string/configbuilder_general"
|
||||||
android:textAppearance="?android:attr/textAppearanceMedium"
|
android:textAppearance="?android:attr/textAppearanceMedium"
|
||||||
android:textStyle="bold" />
|
android:textStyle="bold"
|
||||||
|
android:layout_marginLeft="5dp" />
|
||||||
|
|
||||||
<ListView
|
<ListView
|
||||||
android:id="@+id/configbuilder_generallistview"
|
android:id="@+id/configbuilder_generallistview"
|
||||||
|
@ -99,5 +125,5 @@
|
||||||
android:layout_marginRight="10dp"
|
android:layout_marginRight="10dp"
|
||||||
android:background="@color/cardColorBackground" />
|
android:background="@color/cardColorBackground" />
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
</ScrollView>
|
||||||
</FrameLayout>
|
</FrameLayout>
|
||||||
|
|
|
@ -1,10 +1,6 @@
|
||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
|
||||||
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
|
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="match_parent">
|
|
||||||
|
|
||||||
<LinearLayout
|
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:orientation="horizontal">
|
android:orientation="horizontal">
|
||||||
|
@ -27,7 +23,7 @@
|
||||||
android:layout_gravity="center"
|
android:layout_gravity="center"
|
||||||
android:focusable="false"
|
android:focusable="false"
|
||||||
android:focusableInTouchMode="false"
|
android:focusableInTouchMode="false"
|
||||||
android:text="Visible" />
|
android:text="Show" />
|
||||||
|
|
||||||
<ImageView
|
<ImageView
|
||||||
android:id="@+id/configbuilder_simpleitem_upimage"
|
android:id="@+id/configbuilder_simpleitem_upimage"
|
||||||
|
@ -46,4 +42,3 @@
|
||||||
|
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
</ScrollView>
|
|
|
@ -4,12 +4,24 @@
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
tools:context=".plugins.Objectives.ObjectivesFragment">
|
tools:context=".plugins.Objectives.ObjectivesFragment">
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:orientation="vertical"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent">
|
||||||
|
|
||||||
|
<CheckBox
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:text="Enable fake time"
|
||||||
|
android:id="@+id/objectives_faketime" />
|
||||||
|
|
||||||
<android.support.v7.widget.RecyclerView
|
<android.support.v7.widget.RecyclerView
|
||||||
android:id="@+id/objectives_recyclerview"
|
android:id="@+id/objectives_recyclerview"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent">
|
android:layout_height="match_parent">
|
||||||
|
|
||||||
</android.support.v7.widget.RecyclerView>
|
</android.support.v7.widget.RecyclerView>
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
|
||||||
</FrameLayout>
|
</FrameLayout>
|
||||||
|
|
|
@ -68,7 +68,8 @@
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:orientation="horizontal">
|
android:orientation="horizontal"
|
||||||
|
android:id="@+id/objectives_gate_linearlayout">
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/objectives_gate_label"
|
android:id="@+id/objectives_gate_label"
|
||||||
|
@ -93,7 +94,8 @@
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:orientation="horizontal">
|
android:orientation="horizontal"
|
||||||
|
android:id="@+id/objectives_start_linearlayout">
|
||||||
|
|
||||||
<Button
|
<Button
|
||||||
android:id="@+id/objectives_start"
|
android:id="@+id/objectives_start"
|
||||||
|
@ -109,10 +111,23 @@
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:orientation="horizontal"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
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
|
<LinearLayout
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:orientation="horizontal">
|
android:orientation="horizontal"
|
||||||
|
android:id="@+id/objectives_verify_linearlayout">
|
||||||
|
|
||||||
<Button
|
<Button
|
||||||
android:id="@+id/objectives_verify"
|
android:id="@+id/objectives_verify"
|
||||||
|
|
|
@ -105,5 +105,8 @@
|
||||||
<string name="configbuilder_profile">Profile</string>
|
<string name="configbuilder_profile">Profile</string>
|
||||||
<string name="configbuilder_aps">APS</string>
|
<string name="configbuilder_aps">APS</string>
|
||||||
<string name="configbuilder_general">General</string>
|
<string name="configbuilder_general">General</string>
|
||||||
|
<string name="days">days</string>
|
||||||
|
<string name="minimalduration">Minimal duration</string>
|
||||||
|
<string name="configbuilder_constrains">Constrains</string>
|
||||||
|
|
||||||
</resources>
|
</resources>
|
||||||
|
|
Loading…
Reference in a new issue