wear wizard including bg and iob toggles
|
@ -292,7 +292,7 @@ public class OverviewFragment extends Fragment {
|
|||
|
||||
final JSONObject boluscalcJSON = new JSONObject();
|
||||
try {
|
||||
boluscalcJSON.put("eventTime", DateUtil.toISOString(new Date()));
|
||||
boluscalcJSON.put("eventTime", DateUtil.toISOString(new Date()));
|
||||
boluscalcJSON.put("targetBGLow", wizard.targetBGLow);
|
||||
boluscalcJSON.put("targetBGHigh", wizard.targetBGHigh);
|
||||
boluscalcJSON.put("isf", wizard.sens);
|
||||
|
|
|
@ -1,15 +1,29 @@
|
|||
package info.nightscout.androidaps.plugins.Wear;
|
||||
|
||||
import android.content.DialogInterface;
|
||||
import android.content.SharedPreferences;
|
||||
import android.os.Handler;
|
||||
import android.os.HandlerThread;
|
||||
import android.preference.PreferenceManager;
|
||||
import android.support.v7.app.AlertDialog;
|
||||
import android.view.View;
|
||||
|
||||
import org.json.JSONException;
|
||||
import org.json.JSONObject;
|
||||
|
||||
import java.text.DecimalFormat;
|
||||
import java.util.Date;
|
||||
|
||||
import info.nightscout.androidaps.MainApp;
|
||||
import info.nightscout.androidaps.R;
|
||||
import info.nightscout.androidaps.data.PumpEnactResult;
|
||||
import info.nightscout.androidaps.db.BgReading;
|
||||
import info.nightscout.androidaps.plugins.Actions.dialogs.FillDialog;
|
||||
import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderPlugin;
|
||||
import info.nightscout.androidaps.plugins.Overview.QuickWizard;
|
||||
import info.nightscout.client.data.NSProfile;
|
||||
import info.nightscout.utils.BolusWizard;
|
||||
import info.nightscout.utils.DateUtil;
|
||||
import info.nightscout.utils.DecimalFormatter;
|
||||
import info.nightscout.utils.SafeParse;
|
||||
import info.nightscout.utils.ToastUtils;
|
||||
|
@ -60,7 +74,15 @@ public class ActionStringHandler {
|
|||
|
||||
rAction += "fill " + insulinAfterConstraints;
|
||||
|
||||
} else if(false){
|
||||
} else if ("wizard".equals(act[0])) {
|
||||
Integer carbsBeforeConstraints = SafeParse.stringToInt(act[1]);
|
||||
Integer carbsAfterConstraints = MainApp.getConfigBuilder().applyCarbsConstraints(carbsBeforeConstraints);
|
||||
//TODO: wizard calculation
|
||||
return;
|
||||
|
||||
}
|
||||
|
||||
else if(false){
|
||||
//... add more actions
|
||||
|
||||
} else return;
|
||||
|
@ -121,6 +143,4 @@ public class ActionStringHandler {
|
|||
lastSentTimestamp = System.currentTimeMillis();
|
||||
lastConfirmActionString = null;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -162,8 +162,6 @@ public class WatchUpdaterService extends WearableListenerService implements
|
|||
}
|
||||
|
||||
if (event != null && event.getPath().equals(WEARABLE_INITIATE_ACTIONSTRING_PATH)) {
|
||||
ToastUtils.showToastInUiThread(this, "INITIATE1");
|
||||
|
||||
String actionstring = new String(event.getData());
|
||||
ToastUtils.showToastInUiThread(this, "INITIATE: " + actionstring);
|
||||
ActionStringHandler.handleInitiate(actionstring);
|
||||
|
|
|
@ -29,6 +29,10 @@ public class WizardActivity extends Activity {
|
|||
|
||||
PlusMinusEditText editCarbs;
|
||||
|
||||
boolean useBG;
|
||||
boolean includeBolusIOB;
|
||||
boolean includeBasalIOB;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
|
@ -52,7 +56,7 @@ public class WizardActivity extends Activity {
|
|||
private class MyGridViewPagerAdapter extends GridPagerAdapter {
|
||||
@Override
|
||||
public int getColumnCount(int arg0) {
|
||||
return 2;
|
||||
return 5;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -70,6 +74,63 @@ public class WizardActivity extends Activity {
|
|||
editCarbs = new PlusMinusEditText(view, R.id.amountfield, R.id.plusbutton, R.id.minusbutton, 0d, 0d, 100d, 1d, new DecimalFormat("0"), false);
|
||||
container.addView(view);
|
||||
return view;
|
||||
} else if(col == 1){
|
||||
final View view = LayoutInflater.from(getApplicationContext()).inflate(R.layout.action_toggle_item, container, false);
|
||||
final TextView textView = (TextView) view.findViewById(R.id.label);
|
||||
textView.setText("include BG?");
|
||||
|
||||
final ImageView togglebutton = (ImageView) view.findViewById(R.id.togglebutton);
|
||||
togglebutton.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
useBG = !useBG;
|
||||
if(useBG){
|
||||
togglebutton.setImageResource(R.drawable.ic_toggle_on);
|
||||
} else {
|
||||
togglebutton.setImageResource(R.drawable.ic_toggle_off);
|
||||
}
|
||||
}
|
||||
});
|
||||
container.addView(view);
|
||||
return view;
|
||||
} else if(col == 2){
|
||||
final View view = LayoutInflater.from(getApplicationContext()).inflate(R.layout.action_toggle_item, container, false);
|
||||
final TextView textView = (TextView) view.findViewById(R.id.label);
|
||||
textView.setText("Bolus IOB?");
|
||||
|
||||
final ImageView togglebutton = (ImageView) view.findViewById(R.id.togglebutton);
|
||||
togglebutton.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
includeBolusIOB = !includeBolusIOB;
|
||||
if(includeBolusIOB){
|
||||
togglebutton.setImageResource(R.drawable.ic_toggle_on);
|
||||
} else {
|
||||
togglebutton.setImageResource(R.drawable.ic_toggle_off);
|
||||
}
|
||||
}
|
||||
});
|
||||
container.addView(view);
|
||||
return view;
|
||||
} else if(col == 3){
|
||||
final View view = LayoutInflater.from(getApplicationContext()).inflate(R.layout.action_toggle_item, container, false);
|
||||
final TextView textView = (TextView) view.findViewById(R.id.label);
|
||||
textView.setText("Basal IOB?");
|
||||
|
||||
final ImageView togglebutton = (ImageView) view.findViewById(R.id.togglebutton);
|
||||
togglebutton.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
includeBasalIOB = !includeBasalIOB;
|
||||
if(includeBasalIOB){
|
||||
togglebutton.setImageResource(R.drawable.ic_toggle_on);
|
||||
} else {
|
||||
togglebutton.setImageResource(R.drawable.ic_toggle_off);
|
||||
}
|
||||
}
|
||||
});
|
||||
container.addView(view);
|
||||
return view;
|
||||
} else {
|
||||
|
||||
final View view = LayoutInflater.from(getApplicationContext()).inflate(R.layout.action_send_item, container, false);
|
||||
|
@ -78,10 +139,13 @@ public class WizardActivity extends Activity {
|
|||
@Override
|
||||
public void onClick(View v) {
|
||||
|
||||
//TODO: check if it can happen that the fagment is never created that hold data
|
||||
//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 = "wizard " + SafeParse.stringToInt(editCarbs.editText.getText().toString());;
|
||||
String actionstring = "wizard " + SafeParse.stringToInt(editCarbs.editText.getText().toString())
|
||||
+ " " + useBG
|
||||
+ " " + includeBolusIOB
|
||||
+ " " + includeBasalIOB;
|
||||
ListenerService.initiateAction(WizardActivity.this, actionstring);
|
||||
finish();
|
||||
}
|
||||
|
@ -93,7 +157,8 @@ public class WizardActivity extends Activity {
|
|||
|
||||
@Override
|
||||
public void destroyItem(ViewGroup container, int row, int col, Object view) {
|
||||
//TODO: Handle this to get the data before the view is destroyed?
|
||||
// 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);
|
||||
}
|
||||
|
||||
|
|
BIN
wear/src/main/res/drawable-hdpi/ic_toggle_off.png
Normal file
After Width: | Height: | Size: 250 B |
BIN
wear/src/main/res/drawable-hdpi/ic_toggle_on.png
Normal file
After Width: | Height: | Size: 396 B |
BIN
wear/src/main/res/drawable-mdpi/ic_toggle_off.png
Normal file
After Width: | Height: | Size: 184 B |
BIN
wear/src/main/res/drawable-mdpi/ic_toggle_on.png
Normal file
After Width: | Height: | Size: 279 B |
BIN
wear/src/main/res/drawable-xhdpi/ic_toggle_off.png
Normal file
After Width: | Height: | Size: 295 B |
BIN
wear/src/main/res/drawable-xhdpi/ic_toggle_on.png
Normal file
After Width: | Height: | Size: 478 B |
BIN
wear/src/main/res/drawable-xxhdpi/ic_toggle_off.png
Normal file
After Width: | Height: | Size: 488 B |
BIN
wear/src/main/res/drawable-xxhdpi/ic_toggle_on.png
Normal file
After Width: | Height: | Size: 790 B |
41
wear/src/main/res/layout/action_toggle_item.xml
Normal file
|
@ -0,0 +1,41 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:orientation="vertical" android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
|
||||
|
||||
<LinearLayout
|
||||
android:orientation="vertical"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_gravity="center"
|
||||
android:gravity="center">
|
||||
<TextView
|
||||
android:id="@+id/label"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center"
|
||||
android:text="label"
|
||||
android:textAppearance="?android:attr/textAppearanceMedium"
|
||||
android:gravity="center"/>
|
||||
<ImageView
|
||||
android:id="@+id/togglebutton"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center"
|
||||
android:background="@drawable/circle"
|
||||
android:backgroundTint="#ffffff"
|
||||
android:src="@drawable/ic_toggle_off"
|
||||
android:tint="#ffffff"
|
||||
android:padding="25sp"/>
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center"
|
||||
android:text=" "
|
||||
android:textAppearance="?android:attr/textAppearanceMedium"
|
||||
android:gravity="center"/>
|
||||
</LinearLayout>
|
||||
|
||||
|
||||
</RelativeLayout>
|