commit
0e6a93df90
10 changed files with 395 additions and 65 deletions
|
@ -33,6 +33,8 @@ import org.slf4j.LoggerFactory;
|
||||||
import info.nightscout.androidaps.MainApp;
|
import info.nightscout.androidaps.MainApp;
|
||||||
import info.nightscout.androidaps.R;
|
import info.nightscout.androidaps.R;
|
||||||
import info.nightscout.androidaps.events.EventInitializationChanged;
|
import info.nightscout.androidaps.events.EventInitializationChanged;
|
||||||
|
import info.nightscout.androidaps.events.EventNewBasalProfile;
|
||||||
|
import info.nightscout.androidaps.events.EventProfileSwitchChange;
|
||||||
import info.nightscout.androidaps.interfaces.PumpInterface;
|
import info.nightscout.androidaps.interfaces.PumpInterface;
|
||||||
import info.nightscout.androidaps.plugins.Careportal.CareportalFragment;
|
import info.nightscout.androidaps.plugins.Careportal.CareportalFragment;
|
||||||
import info.nightscout.androidaps.plugins.Careportal.Dialogs.NewNSTreatmentDialog;
|
import info.nightscout.androidaps.plugins.Careportal.Dialogs.NewNSTreatmentDialog;
|
||||||
|
@ -75,6 +77,50 @@ public class CircadianPercentageProfileFragment extends Fragment {
|
||||||
static Boolean percentageViewHint = true;
|
static Boolean percentageViewHint = true;
|
||||||
static Boolean timeshiftViewHint = true;
|
static Boolean timeshiftViewHint = true;
|
||||||
|
|
||||||
|
TextWatcher textWatch = new TextWatcher() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void afterTextChanged(Editable s) {
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void beforeTextChanged(CharSequence s, int start,
|
||||||
|
int count, int after) {
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onTextChanged(CharSequence s, int start,
|
||||||
|
int before, int count) {
|
||||||
|
|
||||||
|
if (percentageView.testValidity()) {
|
||||||
|
if (SafeParse.stringToInt(percentageView.getText().toString()) == 0) {
|
||||||
|
circadianPercentageProfilePlugin.percentage = 100;
|
||||||
|
} else {
|
||||||
|
circadianPercentageProfilePlugin.percentage = SafeParse.stringToInt(percentageView.getText().toString());
|
||||||
|
}
|
||||||
|
updateProfileInfo();
|
||||||
|
}
|
||||||
|
if (timeshiftView.testValidity()) {
|
||||||
|
circadianPercentageProfilePlugin.timeshift = SafeParse.stringToInt(timeshiftView.getText().toString());
|
||||||
|
updateProfileInfo();
|
||||||
|
}
|
||||||
|
if (diaView.testValidity()) {
|
||||||
|
circadianPercentageProfilePlugin.dia = SafeParse.stringToDouble(diaView.getText().toString());
|
||||||
|
updateProfileInfo();
|
||||||
|
}
|
||||||
|
if (targethighView.testValidity()) {
|
||||||
|
circadianPercentageProfilePlugin.targetLow = SafeParse.stringToDouble(targetlowView.getText().toString());
|
||||||
|
updateProfileInfo();
|
||||||
|
}
|
||||||
|
if (targetlowView.testValidity()) {
|
||||||
|
circadianPercentageProfilePlugin.targetHigh = SafeParse.stringToDouble(targethighView.getText().toString());
|
||||||
|
updateProfileInfo();
|
||||||
|
}
|
||||||
|
circadianPercentageProfilePlugin.storeSettings();
|
||||||
|
updateProfileInfo();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public View onCreateView(LayoutInflater inflater, ViewGroup container,
|
public View onCreateView(LayoutInflater inflater, ViewGroup container,
|
||||||
Bundle savedInstanceState) {
|
Bundle savedInstanceState) {
|
||||||
|
@ -106,16 +152,6 @@ public class CircadianPercentageProfileFragment extends Fragment {
|
||||||
layout.findViewById(R.id.circadianpercentageprofile_baseprofilebasal_layout).setVisibility(View.GONE);
|
layout.findViewById(R.id.circadianpercentageprofile_baseprofilebasal_layout).setVisibility(View.GONE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
mgdlView.setChecked(circadianPercentageProfilePlugin.mgdl);
|
|
||||||
mmolView.setChecked(circadianPercentageProfilePlugin.mmol);
|
|
||||||
diaView.setText(circadianPercentageProfilePlugin.dia.toString());
|
|
||||||
targetlowView.setText(circadianPercentageProfilePlugin.targetLow.toString());
|
|
||||||
targethighView.setText(circadianPercentageProfilePlugin.targetHigh.toString());
|
|
||||||
percentageView.setText("" + circadianPercentageProfilePlugin.percentage);
|
|
||||||
timeshiftView.setText("" + circadianPercentageProfilePlugin.timeshift);
|
|
||||||
updateProfileInfo();
|
|
||||||
|
|
||||||
mgdlView.setOnClickListener(new View.OnClickListener() {
|
mgdlView.setOnClickListener(new View.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View v) {
|
public void onClick(View v) {
|
||||||
|
@ -266,49 +302,6 @@ public class CircadianPercentageProfileFragment extends Fragment {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
TextWatcher textWatch = new TextWatcher() {
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void afterTextChanged(Editable s) {
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void beforeTextChanged(CharSequence s, int start,
|
|
||||||
int count, int after) {
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onTextChanged(CharSequence s, int start,
|
|
||||||
int before, int count) {
|
|
||||||
|
|
||||||
if (percentageView.testValidity()) {
|
|
||||||
if (SafeParse.stringToInt(percentageView.getText().toString()) == 0) {
|
|
||||||
circadianPercentageProfilePlugin.percentage = 100;
|
|
||||||
} else {
|
|
||||||
circadianPercentageProfilePlugin.percentage = SafeParse.stringToInt(percentageView.getText().toString());
|
|
||||||
}
|
|
||||||
updateProfileInfo();
|
|
||||||
}
|
|
||||||
if (timeshiftView.testValidity()) {
|
|
||||||
circadianPercentageProfilePlugin.timeshift = SafeParse.stringToInt(timeshiftView.getText().toString());
|
|
||||||
updateProfileInfo();
|
|
||||||
}
|
|
||||||
if (diaView.testValidity()) {
|
|
||||||
circadianPercentageProfilePlugin.dia = SafeParse.stringToDouble(diaView.getText().toString());
|
|
||||||
updateProfileInfo();
|
|
||||||
}
|
|
||||||
if (targethighView.testValidity()) {
|
|
||||||
circadianPercentageProfilePlugin.targetLow = SafeParse.stringToDouble(targetlowView.getText().toString());
|
|
||||||
updateProfileInfo();
|
|
||||||
}
|
|
||||||
if (targetlowView.testValidity()) {
|
|
||||||
circadianPercentageProfilePlugin.targetHigh = SafeParse.stringToDouble(targethighView.getText().toString());
|
|
||||||
updateProfileInfo();
|
|
||||||
}
|
|
||||||
circadianPercentageProfilePlugin.storeSettings();
|
|
||||||
updateProfileInfo();
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
diaView.addTextChangedListener(textWatch);
|
diaView.addTextChangedListener(textWatch);
|
||||||
targetlowView.addTextChangedListener(textWatch);
|
targetlowView.addTextChangedListener(textWatch);
|
||||||
|
@ -316,11 +309,41 @@ public class CircadianPercentageProfileFragment extends Fragment {
|
||||||
percentageView.addTextChangedListener(textWatch);
|
percentageView.addTextChangedListener(textWatch);
|
||||||
timeshiftView.addTextChangedListener(textWatch);
|
timeshiftView.addTextChangedListener(textWatch);
|
||||||
|
|
||||||
onStatusEvent(null);
|
updateGui();
|
||||||
|
|
||||||
|
onStatusEvent(new EventInitializationChanged());
|
||||||
|
|
||||||
return layout;
|
return layout;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void updateGui() {
|
||||||
|
|
||||||
|
|
||||||
|
updateProfileInfo();
|
||||||
|
|
||||||
|
diaView.removeTextChangedListener(textWatch);
|
||||||
|
targetlowView.removeTextChangedListener(textWatch);
|
||||||
|
targethighView.removeTextChangedListener(textWatch);
|
||||||
|
percentageView.removeTextChangedListener(textWatch);
|
||||||
|
timeshiftView.removeTextChangedListener(textWatch);
|
||||||
|
|
||||||
|
mgdlView.setChecked(circadianPercentageProfilePlugin.mgdl);
|
||||||
|
mmolView.setChecked(circadianPercentageProfilePlugin.mmol);
|
||||||
|
diaView.setText(circadianPercentageProfilePlugin.dia.toString());
|
||||||
|
targetlowView.setText(circadianPercentageProfilePlugin.targetLow.toString());
|
||||||
|
targethighView.setText(circadianPercentageProfilePlugin.targetHigh.toString());
|
||||||
|
percentageView.setText("" + circadianPercentageProfilePlugin.percentage);
|
||||||
|
timeshiftView.setText("" + circadianPercentageProfilePlugin.timeshift);
|
||||||
|
|
||||||
|
|
||||||
|
diaView.addTextChangedListener(textWatch);
|
||||||
|
targetlowView.addTextChangedListener(textWatch);
|
||||||
|
targethighView.addTextChangedListener(textWatch);
|
||||||
|
percentageView.addTextChangedListener(textWatch);
|
||||||
|
timeshiftView.addTextChangedListener(textWatch);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
private void customSnackbar(View view, final String Msg, Object snackbarCaller) {
|
private void customSnackbar(View view, final String Msg, Object snackbarCaller) {
|
||||||
if(mSnackBar!= null) mSnackBar.dismiss();
|
if(mSnackBar!= null) mSnackBar.dismiss();
|
||||||
|
|
||||||
|
@ -469,8 +492,9 @@ public class CircadianPercentageProfileFragment extends Fragment {
|
||||||
@Override
|
@Override
|
||||||
public void onResume() {
|
public void onResume() {
|
||||||
super.onResume();
|
super.onResume();
|
||||||
|
updateGui();
|
||||||
MainApp.bus().register(this);
|
MainApp.bus().register(this);
|
||||||
onStatusEvent(null);
|
onStatusEvent(new EventInitializationChanged());
|
||||||
fl.requestFocusFromTouch();
|
fl.requestFocusFromTouch();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -489,4 +513,17 @@ public class CircadianPercentageProfileFragment extends Fragment {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Subscribe
|
||||||
|
public void onStatusEvent(final EventProfileSwitchChange e) {
|
||||||
|
Activity activity = getActivity();
|
||||||
|
if (activity != null)
|
||||||
|
activity.runOnUiThread(new Runnable() {
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
updateGui();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,9 +15,12 @@ import info.nightscout.androidaps.Config;
|
||||||
import info.nightscout.androidaps.Constants;
|
import info.nightscout.androidaps.Constants;
|
||||||
import info.nightscout.androidaps.MainApp;
|
import info.nightscout.androidaps.MainApp;
|
||||||
import info.nightscout.androidaps.R;
|
import info.nightscout.androidaps.R;
|
||||||
|
import info.nightscout.androidaps.data.Profile;
|
||||||
import info.nightscout.androidaps.interfaces.PluginBase;
|
import info.nightscout.androidaps.interfaces.PluginBase;
|
||||||
import info.nightscout.androidaps.interfaces.ProfileInterface;
|
import info.nightscout.androidaps.interfaces.ProfileInterface;
|
||||||
import info.nightscout.androidaps.data.ProfileStore;
|
import info.nightscout.androidaps.data.ProfileStore;
|
||||||
|
import info.nightscout.androidaps.interfaces.PumpInterface;
|
||||||
|
import info.nightscout.androidaps.plugins.Careportal.Dialogs.NewNSTreatmentDialog;
|
||||||
import info.nightscout.utils.DecimalFormatter;
|
import info.nightscout.utils.DecimalFormatter;
|
||||||
import info.nightscout.utils.NSUpload;
|
import info.nightscout.utils.NSUpload;
|
||||||
import info.nightscout.utils.SP;
|
import info.nightscout.utils.SP;
|
||||||
|
@ -159,6 +162,55 @@ public class CircadianPercentageProfilePlugin implements PluginBase, ProfileInte
|
||||||
createConvertedProfile();
|
createConvertedProfile();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String externallySetParameters(int timeshift, int percentage) {
|
||||||
|
|
||||||
|
String msg = "";
|
||||||
|
|
||||||
|
if (!fragmentEnabled){
|
||||||
|
msg+= "NO CPP!" + "\n";
|
||||||
|
}
|
||||||
|
|
||||||
|
//check for validity
|
||||||
|
if (percentage < Constants.CPP_MIN_PERCENTAGE || percentage > Constants.CPP_MAX_PERCENTAGE) {
|
||||||
|
msg+= String.format(MainApp.sResources.getString(R.string.openapsma_valueoutofrange), "Profile-Percentage") + "\n";
|
||||||
|
}
|
||||||
|
if (timeshift < 0 || timeshift > 23) {
|
||||||
|
msg+= String.format(MainApp.sResources.getString(R.string.openapsma_valueoutofrange), "Profile-Timeshift") + "\n";
|
||||||
|
}
|
||||||
|
if(!SP.getBoolean("syncprofiletopump", false)){
|
||||||
|
msg+= MainApp.sResources.getString(R.string.syncprofiletopump_title) + " " + MainApp.sResources.getString(R.string.cpp_sync_setting_missing) + "\n";
|
||||||
|
}
|
||||||
|
final PumpInterface pump = MainApp.getConfigBuilder();
|
||||||
|
final Profile profile = MainApp.getConfigBuilder().getProfile();
|
||||||
|
|
||||||
|
if (pump == null || profile == null || profile.getBasal() == null){
|
||||||
|
msg+= MainApp.sResources.getString(R.string.cpp_notloadedplugins) + "\n";
|
||||||
|
}
|
||||||
|
if(!"".equals(msg)) {
|
||||||
|
msg += MainApp.sResources.getString(R.string.cpp_valuesnotstored);
|
||||||
|
return msg;
|
||||||
|
}
|
||||||
|
|
||||||
|
//store profile
|
||||||
|
this.timeshift= timeshift;
|
||||||
|
this.percentage = percentage;
|
||||||
|
storeSettings();
|
||||||
|
|
||||||
|
|
||||||
|
//send profile to pumpe
|
||||||
|
new NewNSTreatmentDialog(); //init
|
||||||
|
NewNSTreatmentDialog.doProfileSwitch(this.getProfile(), this.getProfileName(), 0);
|
||||||
|
|
||||||
|
//return formatted string
|
||||||
|
/*msg += "%: " + this.percentage + " h: +" + this.timeshift;
|
||||||
|
msg += "\n";
|
||||||
|
msg += "\nBasal:\n" + basalString() + "\n";
|
||||||
|
msg += "\nISF:\n" + isfString() + "\n";
|
||||||
|
msg += "\nIC:\n" + isfString() + "\n";*/
|
||||||
|
|
||||||
|
return msg;
|
||||||
|
}
|
||||||
|
|
||||||
private void createConvertedProfile() {
|
private void createConvertedProfile() {
|
||||||
JSONObject json = new JSONObject();
|
JSONObject json = new JSONObject();
|
||||||
JSONObject store = new JSONObject();
|
JSONObject store = new JSONObject();
|
||||||
|
@ -304,4 +356,11 @@ public class CircadianPercentageProfilePlugin implements PluginBase, ProfileInte
|
||||||
return sb.toString();
|
return sb.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public int getPercentage() {
|
||||||
|
return percentage;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getTimeshift() {
|
||||||
|
return timeshift;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,6 +24,7 @@ import info.nightscout.androidaps.plugins.Actions.dialogs.FillDialog;
|
||||||
import info.nightscout.androidaps.plugins.Loop.APSResult;
|
import info.nightscout.androidaps.plugins.Loop.APSResult;
|
||||||
import info.nightscout.androidaps.plugins.Loop.LoopPlugin;
|
import info.nightscout.androidaps.plugins.Loop.LoopPlugin;
|
||||||
import info.nightscout.androidaps.data.Profile;
|
import info.nightscout.androidaps.data.Profile;
|
||||||
|
import info.nightscout.androidaps.plugins.ProfileCircadianPercentage.CircadianPercentageProfilePlugin;
|
||||||
import info.nightscout.utils.BolusWizard;
|
import info.nightscout.utils.BolusWizard;
|
||||||
import info.nightscout.utils.DateUtil;
|
import info.nightscout.utils.DateUtil;
|
||||||
import info.nightscout.utils.DecimalFormatter;
|
import info.nightscout.utils.DecimalFormatter;
|
||||||
|
@ -225,7 +226,38 @@ public class ActionStringHandler {
|
||||||
|
|
||||||
lastBolusWizard = bolusWizard;
|
lastBolusWizard = bolusWizard;
|
||||||
|
|
||||||
} else return;
|
} else if("opencpp".equals(act[0])){
|
||||||
|
Object activeProfile = MainApp.getConfigBuilder().getActiveProfileInterface();
|
||||||
|
CircadianPercentageProfilePlugin cpp = (CircadianPercentageProfilePlugin) MainApp.getSpecificPlugin(CircadianPercentageProfilePlugin.class);
|
||||||
|
|
||||||
|
if(cpp == null || activeProfile==null || cpp != activeProfile){
|
||||||
|
sendError("CPP not activated!");
|
||||||
|
return;
|
||||||
|
} else {
|
||||||
|
// read CPP values
|
||||||
|
rTitle = "opencpp";
|
||||||
|
rMessage = "opencpp";
|
||||||
|
rAction = "opencpp" + " " + cpp.getPercentage() + " " + cpp.getTimeshift();
|
||||||
|
}
|
||||||
|
|
||||||
|
} else if("cppset".equals(act[0])){
|
||||||
|
Object activeProfile = MainApp.getConfigBuilder().getActiveProfileInterface();
|
||||||
|
CircadianPercentageProfilePlugin cpp = (CircadianPercentageProfilePlugin) MainApp.getSpecificPlugin(CircadianPercentageProfilePlugin.class);
|
||||||
|
|
||||||
|
if(cpp == null || activeProfile==null || cpp != activeProfile){
|
||||||
|
sendError("CPP not activated!");
|
||||||
|
return;
|
||||||
|
} else {
|
||||||
|
// read CPP values
|
||||||
|
rMessage = "CPP:" + "\n\n"+
|
||||||
|
"Timeshift: " + act[1] + "\n" +
|
||||||
|
"Percentage: " + act[2] + "%";
|
||||||
|
rAction = actionstring;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
else return;
|
||||||
|
|
||||||
|
|
||||||
// send result
|
// send result
|
||||||
WearFragment.getPlugin(MainApp.instance()).requestActionConfirmation(rTitle, rMessage, rAction);
|
WearFragment.getPlugin(MainApp.instance()).requestActionConfirmation(rTitle, rMessage, rAction);
|
||||||
|
@ -379,10 +411,32 @@ public class ActionStringHandler {
|
||||||
double insulin = SafeParse.stringToDouble(act[1]);
|
double insulin = SafeParse.stringToDouble(act[1]);
|
||||||
int carbs = SafeParse.stringToInt(act[2]);
|
int carbs = SafeParse.stringToInt(act[2]);
|
||||||
doBolus(insulin, carbs);
|
doBolus(insulin, carbs);
|
||||||
|
} else if ("cppset".equals(act[0])) {
|
||||||
|
int timeshift = SafeParse.stringToInt(act[1]);
|
||||||
|
int percentage = SafeParse.stringToInt(act[2]);
|
||||||
|
setCPP(percentage, timeshift);
|
||||||
}
|
}
|
||||||
lastBolusWizard = null;
|
lastBolusWizard = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static void setCPP(int percentage, int timeshift) {
|
||||||
|
Object activeProfile = MainApp.getConfigBuilder().getActiveProfileInterface();
|
||||||
|
CircadianPercentageProfilePlugin cpp = (CircadianPercentageProfilePlugin) MainApp.getSpecificPlugin(CircadianPercentageProfilePlugin.class);
|
||||||
|
|
||||||
|
if(cpp == null || activeProfile==null || cpp != activeProfile){
|
||||||
|
sendError("CPP not activated!");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
String msg = cpp.externallySetParameters(timeshift, percentage);
|
||||||
|
if(msg != null && !"".equals(msg)){
|
||||||
|
String rTitle = "STATUS";
|
||||||
|
String rAction = "statusmessage";
|
||||||
|
WearFragment.getPlugin(MainApp.instance()).requestActionConfirmation(rTitle, msg, rAction);
|
||||||
|
lastSentTimestamp = System.currentTimeMillis();
|
||||||
|
lastConfirmActionString = rAction;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private static void generateTempTarget(int duration, double low, double high) {
|
private static void generateTempTarget(int duration, double low, double high) {
|
||||||
TempTarget tempTarget = new TempTarget();
|
TempTarget tempTarget = new TempTarget();
|
||||||
tempTarget.date = System.currentTimeMillis();
|
tempTarget.date = System.currentTimeMillis();
|
||||||
|
|
|
@ -19,6 +19,9 @@ import com.google.android.gms.wearable.PutDataRequest;
|
||||||
import com.google.android.gms.wearable.Wearable;
|
import com.google.android.gms.wearable.Wearable;
|
||||||
import com.google.android.gms.wearable.WearableListenerService;
|
import com.google.android.gms.wearable.WearableListenerService;
|
||||||
|
|
||||||
|
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;
|
||||||
|
@ -37,6 +40,7 @@ import info.nightscout.androidaps.interfaces.TreatmentsInterface;
|
||||||
import info.nightscout.androidaps.plugins.Loop.LoopPlugin;
|
import info.nightscout.androidaps.plugins.Loop.LoopPlugin;
|
||||||
import info.nightscout.androidaps.data.Profile;
|
import info.nightscout.androidaps.data.Profile;
|
||||||
import info.nightscout.androidaps.plugins.Overview.OverviewPlugin;
|
import info.nightscout.androidaps.plugins.Overview.OverviewPlugin;
|
||||||
|
import info.nightscout.androidaps.plugins.ProfileCircadianPercentage.CircadianPercentageProfilePlugin;
|
||||||
import info.nightscout.androidaps.plugins.Wear.ActionStringHandler;
|
import info.nightscout.androidaps.plugins.Wear.ActionStringHandler;
|
||||||
import info.nightscout.androidaps.plugins.Wear.WearPlugin;
|
import info.nightscout.androidaps.plugins.Wear.WearPlugin;
|
||||||
import info.nightscout.utils.DecimalFormatter;
|
import info.nightscout.utils.DecimalFormatter;
|
||||||
|
@ -72,6 +76,9 @@ public class WatchUpdaterService extends WearableListenerService implements
|
||||||
SharedPreferences mPrefs;
|
SharedPreferences mPrefs;
|
||||||
private static boolean lastLoopStatus;
|
private static boolean lastLoopStatus;
|
||||||
|
|
||||||
|
private static Logger log = LoggerFactory.getLogger(CircadianPercentageProfilePlugin.class);
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onCreate() {
|
public void onCreate() {
|
||||||
mPrefs = PreferenceManager.getDefaultSharedPreferences(getApplicationContext());
|
mPrefs = PreferenceManager.getDefaultSharedPreferences(getApplicationContext());
|
||||||
|
@ -169,13 +176,13 @@ public class WatchUpdaterService extends WearableListenerService implements
|
||||||
|
|
||||||
if (event != null && event.getPath().equals(WEARABLE_INITIATE_ACTIONSTRING_PATH)) {
|
if (event != null && event.getPath().equals(WEARABLE_INITIATE_ACTIONSTRING_PATH)) {
|
||||||
String actionstring = new String(event.getData());
|
String actionstring = new String(event.getData());
|
||||||
ToastUtils.showToastInUiThread(this, "Wear: " + actionstring);
|
log.debug("Wear: " + actionstring);
|
||||||
ActionStringHandler.handleInitiate(actionstring);
|
ActionStringHandler.handleInitiate(actionstring);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (event != null && event.getPath().equals(WEARABLE_CONFIRM_ACTIONSTRING_PATH)) {
|
if (event != null && event.getPath().equals(WEARABLE_CONFIRM_ACTIONSTRING_PATH)) {
|
||||||
String actionstring = new String(event.getData());
|
String actionstring = new String(event.getData());
|
||||||
ToastUtils.showToastInUiThread(this, "Wear Confirm: " + actionstring);
|
log.debug("Wear Confirm: " + actionstring);
|
||||||
ActionStringHandler.handleConfirmation(actionstring);
|
ActionStringHandler.handleConfirmation(actionstring);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -497,7 +504,7 @@ public class WatchUpdaterService extends WearableListenerService implements
|
||||||
dataMapRequest.getDataMap().putString("message", message);
|
dataMapRequest.getDataMap().putString("message", message);
|
||||||
dataMapRequest.getDataMap().putString("actionstring", actionstring);
|
dataMapRequest.getDataMap().putString("actionstring", actionstring);
|
||||||
|
|
||||||
ToastUtils.showToastInUiThread(this, "Requesting confirmation from wear: " + actionstring);
|
log.debug("Requesting confirmation from wear: " + actionstring);
|
||||||
|
|
||||||
PutDataRequest putDataRequest = dataMapRequest.asPutDataRequest();
|
PutDataRequest putDataRequest = dataMapRequest.asPutDataRequest();
|
||||||
Wearable.DataApi.putDataItem(googleApiClient, putDataRequest);
|
Wearable.DataApi.putDataItem(googleApiClient, putDataRequest);
|
||||||
|
|
|
@ -680,4 +680,7 @@
|
||||||
<string name="sensitivityweightedaverage">Sensitivity WeightedAverage</string>
|
<string name="sensitivityweightedaverage">Sensitivity WeightedAverage</string>
|
||||||
<string name="mdtp_ok">OK</string>
|
<string name="mdtp_ok">OK</string>
|
||||||
<string name="mdtp_cancel">Cancel</string>
|
<string name="mdtp_cancel">Cancel</string>
|
||||||
|
<string name="cpp_sync_setting_missing">needs to be activated to send values to the pump!</string>
|
||||||
|
<string name="cpp_notloadedplugins">Not all profiles loaded!</string>
|
||||||
|
<string name="cpp_valuesnotstored">Values not stored!</string>
|
||||||
</resources>
|
</resources>
|
||||||
|
|
|
@ -140,6 +140,10 @@
|
||||||
android:name=".interaction.actions.BolusActivity"
|
android:name=".interaction.actions.BolusActivity"
|
||||||
android:label="Bolus">
|
android:label="Bolus">
|
||||||
</activity>
|
</activity>
|
||||||
|
<activity
|
||||||
|
android:name=".interaction.actions.CPPActivity"
|
||||||
|
android:label="CPP">
|
||||||
|
</activity>
|
||||||
<activity
|
<activity
|
||||||
android:name=".interaction.actions.FillActivity"
|
android:name=".interaction.actions.FillActivity"
|
||||||
android:label="Fill">
|
android:label="Fill">
|
||||||
|
|
|
@ -26,6 +26,8 @@ import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
import info.nightscout.androidaps.interaction.AAPSPreferences;
|
import info.nightscout.androidaps.interaction.AAPSPreferences;
|
||||||
import info.nightscout.androidaps.R;
|
import info.nightscout.androidaps.R;
|
||||||
|
import info.nightscout.androidaps.interaction.actions.CPPActivity;
|
||||||
|
import info.nightscout.androidaps.interaction.utils.SafeParse;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by emmablack on 12/26/14.
|
* Created by emmablack on 12/26/14.
|
||||||
|
@ -252,7 +254,21 @@ public class ListenerService extends WearableListenerService implements GoogleAp
|
||||||
String title = DataMapItem.fromDataItem(event.getDataItem()).getDataMap().getString("title");
|
String title = DataMapItem.fromDataItem(event.getDataItem()).getDataMap().getString("title");
|
||||||
String message = DataMapItem.fromDataItem(event.getDataItem()).getDataMap().getString("message");
|
String message = DataMapItem.fromDataItem(event.getDataItem()).getDataMap().getString("message");
|
||||||
String actionstring = DataMapItem.fromDataItem(event.getDataItem()).getDataMap().getString("actionstring");
|
String actionstring = DataMapItem.fromDataItem(event.getDataItem()).getDataMap().getString("actionstring");
|
||||||
showConfirmationDialog(title, message, actionstring);
|
|
||||||
|
if("opencpp".equals(title) && actionstring.startsWith("opencpp")){
|
||||||
|
String[] act = actionstring.split("\\s+");
|
||||||
|
Intent intent = new Intent(this, CPPActivity.class);
|
||||||
|
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||||
|
//TODO adrian: parse actionstring and add parameters
|
||||||
|
Bundle params = new Bundle();
|
||||||
|
params.putInt("percentage", SafeParse.stringToInt(act[1]));
|
||||||
|
params.putInt("timeshift", SafeParse.stringToInt(act[2]));
|
||||||
|
intent.putExtras(params);
|
||||||
|
startActivity(intent);
|
||||||
|
} else {
|
||||||
|
showConfirmationDialog(title, message, actionstring);
|
||||||
|
}
|
||||||
|
|
||||||
}else if (path.equals(NEW_STATUS_PATH)) {
|
}else if (path.equals(NEW_STATUS_PATH)) {
|
||||||
dataMap = DataMapItem.fromDataItem(event.getDataItem()).getDataMap();
|
dataMap = DataMapItem.fromDataItem(event.getDataItem()).getDataMap();
|
||||||
Intent messageIntent = new Intent();
|
Intent messageIntent = new Intent();
|
||||||
|
|
|
@ -0,0 +1,133 @@
|
||||||
|
package info.nightscout.androidaps.interaction.actions;
|
||||||
|
|
||||||
|
|
||||||
|
import android.content.res.Resources;
|
||||||
|
import android.os.Bundle;
|
||||||
|
import android.support.wearable.view.DotsPageIndicator;
|
||||||
|
import android.support.wearable.view.GridPagerAdapter;
|
||||||
|
import android.support.wearable.view.GridViewPager;
|
||||||
|
import android.view.LayoutInflater;
|
||||||
|
import android.view.View;
|
||||||
|
import android.view.ViewGroup;
|
||||||
|
import android.widget.ImageView;
|
||||||
|
|
||||||
|
import java.text.DecimalFormat;
|
||||||
|
|
||||||
|
import info.nightscout.androidaps.R;
|
||||||
|
import info.nightscout.androidaps.data.ListenerService;
|
||||||
|
import info.nightscout.androidaps.interaction.utils.PlusMinusEditText;
|
||||||
|
import info.nightscout.androidaps.interaction.utils.SafeParse;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Created by adrian on 09/02/17.
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
public class CPPActivity extends ViewSelectorActivity {
|
||||||
|
|
||||||
|
PlusMinusEditText editPercentage;
|
||||||
|
PlusMinusEditText editTimeshift;
|
||||||
|
|
||||||
|
int percentage = -1;
|
||||||
|
int timeshift = -1;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
|
super.onCreate(savedInstanceState);
|
||||||
|
|
||||||
|
Bundle extras = getIntent().getExtras();
|
||||||
|
percentage = extras.getInt("percentage", -1);
|
||||||
|
timeshift = extras.getInt("timeshift", -1);
|
||||||
|
|
||||||
|
if (percentage ==-1 || timeshift ==-1){
|
||||||
|
finish(); return;
|
||||||
|
}
|
||||||
|
|
||||||
|
setContentView(R.layout.grid_layout);
|
||||||
|
final Resources res = getResources();
|
||||||
|
final GridViewPager pager = (GridViewPager) findViewById(R.id.pager);
|
||||||
|
|
||||||
|
pager.setAdapter(new MyGridViewPagerAdapter());
|
||||||
|
DotsPageIndicator dotsPageIndicator = (DotsPageIndicator) findViewById(R.id.page_indicator);
|
||||||
|
dotsPageIndicator.setPager(pager);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onPause() {
|
||||||
|
super.onPause();
|
||||||
|
finish();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private class MyGridViewPagerAdapter extends GridPagerAdapter {
|
||||||
|
@Override
|
||||||
|
public int getColumnCount(int arg0) {
|
||||||
|
return 3;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getRowCount() {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Object instantiateItem(ViewGroup container, int row, int col) {
|
||||||
|
|
||||||
|
if(col == 0){
|
||||||
|
final View view = getInflatedPlusMinusView(container);
|
||||||
|
double def = timeshift;
|
||||||
|
if (editTimeshift != null){
|
||||||
|
def = SafeParse.stringToDouble(editTimeshift.editText.getText().toString());
|
||||||
|
}
|
||||||
|
editTimeshift = new PlusMinusEditText(view, R.id.amountfield, R.id.plusbutton, R.id.minusbutton, def, 0d, 23d, 1d, new DecimalFormat("0"), true, true);
|
||||||
|
setLabelToPlusMinusView(view, "timeshift");
|
||||||
|
container.addView(view);
|
||||||
|
return view;
|
||||||
|
} else if(col == 1){
|
||||||
|
final View view = getInflatedPlusMinusView(container);
|
||||||
|
double def = percentage;
|
||||||
|
if (editPercentage != null){
|
||||||
|
def = SafeParse.stringToDouble(editPercentage.editText.getText().toString());
|
||||||
|
}
|
||||||
|
editPercentage = new PlusMinusEditText(view, R.id.amountfield, R.id.plusbutton, R.id.minusbutton, def, 50d, 150d, 1d, new DecimalFormat("0"), false);
|
||||||
|
setLabelToPlusMinusView(view, "percentage");
|
||||||
|
container.addView(view);
|
||||||
|
return view;
|
||||||
|
} else {
|
||||||
|
|
||||||
|
final View view = LayoutInflater.from(getApplicationContext()).inflate(R.layout.action_send_item, container, false);
|
||||||
|
final ImageView confirmbutton = (ImageView) view.findViewById(R.id.confirmbutton);
|
||||||
|
confirmbutton.setOnClickListener(new View.OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(View v) {
|
||||||
|
|
||||||
|
//check if it can happen that the fagment is never created that hold data?
|
||||||
|
// (you have to swipe past them anyways - but still)
|
||||||
|
|
||||||
|
String actionstring = "cppset " +SafeParse.stringToInt(editTimeshift.editText.getText().toString())
|
||||||
|
+ " " + SafeParse.stringToInt(editPercentage.editText.getText().toString());
|
||||||
|
ListenerService.initiateAction(CPPActivity.this, actionstring);
|
||||||
|
finish();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
container.addView(view);
|
||||||
|
return view;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void destroyItem(ViewGroup container, int row, int col, Object view) {
|
||||||
|
// Handle this to get the data before the view is destroyed?
|
||||||
|
// Object should still be kept by this, just setup for reinit?
|
||||||
|
container.removeView((View)view);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isViewFromObject(View view, Object object) {
|
||||||
|
return view==object;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
|
@ -15,6 +15,7 @@ public class StatusMenuActivity extends MenuListActivity {
|
||||||
"Pump",
|
"Pump",
|
||||||
"Loop",
|
"Loop",
|
||||||
"Targets",
|
"Targets",
|
||||||
|
"CPP",
|
||||||
"OAPS Result"};
|
"OAPS Result"};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -33,6 +34,9 @@ public class StatusMenuActivity extends MenuListActivity {
|
||||||
ListenerService.initiateAction(this, "status targets");
|
ListenerService.initiateAction(this, "status targets");
|
||||||
break;
|
break;
|
||||||
case 3:
|
case 3:
|
||||||
|
ListenerService.initiateAction(this, "opencpp");
|
||||||
|
break;
|
||||||
|
case 4:
|
||||||
ListenerService.initiateAction(this, "status oapsresult");
|
ListenerService.initiateAction(this, "status oapsresult");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
|
@ -31,6 +31,7 @@ public class PlusMinusEditText implements View.OnKeyListener,
|
||||||
Double step = 1d;
|
Double step = 1d;
|
||||||
NumberFormat formater;
|
NumberFormat formater;
|
||||||
boolean allowZero = false;
|
boolean allowZero = false;
|
||||||
|
boolean roundRobin;
|
||||||
|
|
||||||
private Handler mHandler;
|
private Handler mHandler;
|
||||||
private ScheduledExecutorService mUpdater;
|
private ScheduledExecutorService mUpdater;
|
||||||
|
@ -65,6 +66,10 @@ public class PlusMinusEditText implements View.OnKeyListener,
|
||||||
private static final int MSG_DEC = 1;
|
private static final int MSG_DEC = 1;
|
||||||
|
|
||||||
public PlusMinusEditText(View view, int editTextID, int plusID, int minusID, Double initValue, Double minValue, Double maxValue, Double step, NumberFormat formater, boolean allowZero) {
|
public PlusMinusEditText(View view, int editTextID, int plusID, int minusID, Double initValue, Double minValue, Double maxValue, Double step, NumberFormat formater, boolean allowZero) {
|
||||||
|
this( view, editTextID, plusID, minusID, initValue, minValue, maxValue, step, formater, allowZero, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
public PlusMinusEditText(View view, int editTextID, int plusID, int minusID, Double initValue, Double minValue, Double maxValue, Double step, NumberFormat formater, boolean allowZero, boolean roundRobin) {
|
||||||
editText = (TextView) view.findViewById(editTextID);
|
editText = (TextView) view.findViewById(editTextID);
|
||||||
minusImage = (ImageView) view.findViewById(minusID);
|
minusImage = (ImageView) view.findViewById(minusID);
|
||||||
plusImage = (ImageView) view.findViewById(plusID);
|
plusImage = (ImageView) view.findViewById(plusID);
|
||||||
|
@ -75,6 +80,7 @@ public class PlusMinusEditText implements View.OnKeyListener,
|
||||||
this.step = step;
|
this.step = step;
|
||||||
this.formater = formater;
|
this.formater = formater;
|
||||||
this.allowZero = allowZero;
|
this.allowZero = allowZero;
|
||||||
|
this.roundRobin = roundRobin;
|
||||||
|
|
||||||
mHandler = new Handler() {
|
mHandler = new Handler() {
|
||||||
@Override
|
@Override
|
||||||
|
@ -112,12 +118,15 @@ public class PlusMinusEditText implements View.OnKeyListener,
|
||||||
public void setStep(Double step) {
|
public void setStep(Double step) {
|
||||||
this.step = step;
|
this.step = step;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void inc(int multiplier) {
|
private void inc(int multiplier) {
|
||||||
value += step * multiplier;
|
value += step * multiplier;
|
||||||
if (value > maxValue) {
|
if (value > maxValue) {
|
||||||
value = maxValue;
|
if(roundRobin){
|
||||||
stopUpdating();
|
value = minValue;
|
||||||
|
} else {
|
||||||
|
value = maxValue;
|
||||||
|
stopUpdating();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
updateEditText();
|
updateEditText();
|
||||||
}
|
}
|
||||||
|
@ -125,8 +134,12 @@ public class PlusMinusEditText implements View.OnKeyListener,
|
||||||
private void dec( int multiplier) {
|
private void dec( int multiplier) {
|
||||||
value -= step * multiplier;
|
value -= step * multiplier;
|
||||||
if (value < minValue) {
|
if (value < minValue) {
|
||||||
value = minValue;
|
if(roundRobin){
|
||||||
stopUpdating();
|
value = maxValue;
|
||||||
|
} else {
|
||||||
|
value = minValue;
|
||||||
|
stopUpdating();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
updateEditText();
|
updateEditText();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue