commit
1822f2a6c0
32 changed files with 1704 additions and 149 deletions
|
@ -44,7 +44,7 @@ android {
|
||||||
minSdkVersion 21
|
minSdkVersion 21
|
||||||
targetSdkVersion 23
|
targetSdkVersion 23
|
||||||
versionCode 1100
|
versionCode 1100
|
||||||
versionName "1.1"
|
versionName "1.1c"
|
||||||
buildConfigField "String", "BUILDVERSION", generateGitBuild()
|
buildConfigField "String", "BUILDVERSION", generateGitBuild()
|
||||||
}
|
}
|
||||||
lintOptions {
|
lintOptions {
|
||||||
|
|
|
@ -36,6 +36,8 @@
|
||||||
<activity android:name=".AgreementActivity" />
|
<activity android:name=".AgreementActivity" />
|
||||||
<activity android:name=".plugins.DanaR.History.DanaRHistoryActivity" />
|
<activity android:name=".plugins.DanaR.History.DanaRHistoryActivity" />
|
||||||
<activity android:name=".plugins.DanaRKorean.History.DanaRHistoryActivity" />
|
<activity android:name=".plugins.DanaRKorean.History.DanaRHistoryActivity" />
|
||||||
|
<activity android:name=".plugins.DanaR.History.DanaRStatsActivity" />
|
||||||
|
<activity android:name=".plugins.DanaRKorean.History.DanaRStatsActivity" />
|
||||||
<activity android:name=".plugins.Overview.activities.QuickWizardListActivity">
|
<activity android:name=".plugins.Overview.activities.QuickWizardListActivity">
|
||||||
<intent-filter>
|
<intent-filter>
|
||||||
<action android:name="info.nightscout.androidaps.plugins.Overview.activities.QuickWizardListActivity" />
|
<action android:name="info.nightscout.androidaps.plugins.Overview.activities.QuickWizardListActivity" />
|
||||||
|
|
|
@ -42,4 +42,23 @@ public class Constants {
|
||||||
// Circadian Percentage Profile
|
// Circadian Percentage Profile
|
||||||
public static final int CPP_MIN_PERCENTAGE = 50;
|
public static final int CPP_MIN_PERCENTAGE = 50;
|
||||||
public static final int CPP_MAX_PERCENTAGE = 200;
|
public static final int CPP_MAX_PERCENTAGE = 200;
|
||||||
|
|
||||||
|
|
||||||
|
public static final String MAX_BG_DEFAULT_MGDL = "180";
|
||||||
|
public static final String MAX_BG_DEFAULT_MMOL = "10";
|
||||||
|
public static final String MIN_BG_DEFAULT_MGDL = "100";
|
||||||
|
public static final String MIN_BG_DEFAULT_MMOL = "5";
|
||||||
|
public static final String TARGET_BG_DEFAULT_MGDL = "150";
|
||||||
|
public static final String TARGET_BG_DEFAULT_MMOL = "7";
|
||||||
|
|
||||||
|
// Very Hard Limits Ranges
|
||||||
|
// First value is the Lowest and second value is the Highest a Limit can define
|
||||||
|
public static final int[] VERY_HARD_LIMIT_MIN_BG = {72,180};
|
||||||
|
public static final int[] VERY_HARD_LIMIT_MAX_BG = {99,270};
|
||||||
|
public static final int[] VERY_HARD_LIMIT_TARGET_BG = {80,200};
|
||||||
|
|
||||||
|
// Very Hard Limits Ranges for Temp Targets
|
||||||
|
public static final int[] VERY_HARD_LIMIT_TEMP_MIN_BG = {72,180};
|
||||||
|
public static final int[] VERY_HARD_LIMIT_TEMP_MAX_BG = {72,270};
|
||||||
|
public static final int[] VERY_HARD_LIMIT_TEMP_TARGET_BG = {72,200};
|
||||||
}
|
}
|
||||||
|
|
|
@ -370,6 +370,7 @@ public class NewNSTreatmentDialog extends DialogFragment implements View.OnClick
|
||||||
String enteredBy = SP.getString("careportal_enteredby", "");
|
String enteredBy = SP.getString("careportal_enteredby", "");
|
||||||
JSONObject data = new JSONObject();
|
JSONObject data = new JSONObject();
|
||||||
try {
|
try {
|
||||||
|
boolean allowZeroDuration = false;
|
||||||
data.put("created_at", DateUtil.toISOString(eventTime));
|
data.put("created_at", DateUtil.toISOString(eventTime));
|
||||||
switch (options.eventType) {
|
switch (options.eventType) {
|
||||||
case R.id.careportal_bgcheck:
|
case R.id.careportal_bgcheck:
|
||||||
|
@ -431,6 +432,7 @@ public class NewNSTreatmentDialog extends DialogFragment implements View.OnClick
|
||||||
break;
|
break;
|
||||||
case R.id.careportal_temptarget:
|
case R.id.careportal_temptarget:
|
||||||
data.put("eventType", "Temporary Target");
|
data.put("eventType", "Temporary Target");
|
||||||
|
allowZeroDuration = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (SafeParse.stringToDouble(bgInputEdit.getText().toString()) != 0d) {
|
if (SafeParse.stringToDouble(bgInputEdit.getText().toString()) != 0d) {
|
||||||
|
@ -443,7 +445,7 @@ public class NewNSTreatmentDialog extends DialogFragment implements View.OnClick
|
||||||
data.put("carbs", SafeParse.stringToDouble(carbsEdit.getText().toString()));
|
data.put("carbs", SafeParse.stringToDouble(carbsEdit.getText().toString()));
|
||||||
if (SafeParse.stringToDouble(insulinEdit.getText().toString()) != 0d)
|
if (SafeParse.stringToDouble(insulinEdit.getText().toString()) != 0d)
|
||||||
data.put("insulin", SafeParse.stringToDouble(insulinEdit.getText().toString()));
|
data.put("insulin", SafeParse.stringToDouble(insulinEdit.getText().toString()));
|
||||||
if (SafeParse.stringToDouble(durationeEdit.getText().toString()) != 0d)
|
if (allowZeroDuration || SafeParse.stringToDouble(durationeEdit.getText().toString()) != 0d)
|
||||||
data.put("duration", SafeParse.stringToDouble(durationeEdit.getText().toString()));
|
data.put("duration", SafeParse.stringToDouble(durationeEdit.getText().toString()));
|
||||||
if (layoutPercent.getVisibility() != View.GONE)
|
if (layoutPercent.getVisibility() != View.GONE)
|
||||||
data.put("percent", SafeParse.stringToDouble(percentEdit.getText().toString()));
|
data.put("percent", SafeParse.stringToDouble(percentEdit.getText().toString()));
|
||||||
|
@ -607,7 +609,10 @@ public class NewNSTreatmentDialog extends DialogFragment implements View.OnClick
|
||||||
ConfigBuilderPlugin.uploadCareportalEntryToNS(data);
|
ConfigBuilderPlugin.uploadCareportalEntryToNS(data);
|
||||||
}
|
}
|
||||||
if (options.executeTempTarget) {
|
if (options.executeTempTarget) {
|
||||||
if (data.has("targetBottom") && data.has("targetTop")) {
|
|
||||||
|
|
||||||
|
try {
|
||||||
|
if ((data.has("targetBottom") && data.has("targetTop")) || (data.has("duration")&& data.getInt("duration") == 0)) {
|
||||||
sHandler.post(new Runnable() {
|
sHandler.post(new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
|
@ -616,8 +621,13 @@ public class NewNSTreatmentDialog extends DialogFragment implements View.OnClick
|
||||||
tempTarget.timeStart = eventTime;
|
tempTarget.timeStart = eventTime;
|
||||||
tempTarget.duration = data.getInt("duration");
|
tempTarget.duration = data.getInt("duration");
|
||||||
tempTarget.reason = data.getString("reason");
|
tempTarget.reason = data.getString("reason");
|
||||||
|
if(tempTarget.duration != 0) {
|
||||||
tempTarget.low = NSProfile.toMgdl(data.getDouble("targetBottom"), MainApp.getConfigBuilder().getActiveProfile().getProfile().getUnits());
|
tempTarget.low = NSProfile.toMgdl(data.getDouble("targetBottom"), MainApp.getConfigBuilder().getActiveProfile().getProfile().getUnits());
|
||||||
tempTarget.high = NSProfile.toMgdl(data.getDouble("targetTop"), MainApp.getConfigBuilder().getActiveProfile().getProfile().getUnits());
|
tempTarget.high = NSProfile.toMgdl(data.getDouble("targetTop"), MainApp.getConfigBuilder().getActiveProfile().getProfile().getUnits());
|
||||||
|
} else {
|
||||||
|
tempTarget.low = 0;
|
||||||
|
tempTarget.high = 0;
|
||||||
|
}
|
||||||
tempTarget.setTimeIndex(tempTarget.getTimeIndex());
|
tempTarget.setTimeIndex(tempTarget.getTimeIndex());
|
||||||
Dao<TempTarget, Long> dao = MainApp.getDbHelper().getDaoTempTargets();
|
Dao<TempTarget, Long> dao = MainApp.getDbHelper().getDaoTempTargets();
|
||||||
log.debug("Creating new TempTarget db record: " + tempTarget.log());
|
log.debug("Creating new TempTarget db record: " + tempTarget.log());
|
||||||
|
@ -632,6 +642,9 @@ public class NewNSTreatmentDialog extends DialogFragment implements View.OnClick
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
} catch (JSONException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
ConfigBuilderPlugin.uploadCareportalEntryToNS(data);
|
ConfigBuilderPlugin.uploadCareportalEntryToNS(data);
|
||||||
}
|
}
|
||||||
|
|
|
@ -29,6 +29,7 @@ import info.nightscout.androidaps.events.EventTempBasalChange;
|
||||||
import info.nightscout.androidaps.interfaces.FragmentBase;
|
import info.nightscout.androidaps.interfaces.FragmentBase;
|
||||||
import info.nightscout.androidaps.plugins.DanaR.Dialogs.ProfileViewDialog;
|
import info.nightscout.androidaps.plugins.DanaR.Dialogs.ProfileViewDialog;
|
||||||
import info.nightscout.androidaps.plugins.DanaR.History.DanaRHistoryActivity;
|
import info.nightscout.androidaps.plugins.DanaR.History.DanaRHistoryActivity;
|
||||||
|
import info.nightscout.androidaps.plugins.DanaR.History.DanaRStatsActivity;
|
||||||
import info.nightscout.androidaps.plugins.DanaR.events.EventDanaRConnectionStatus;
|
import info.nightscout.androidaps.plugins.DanaR.events.EventDanaRConnectionStatus;
|
||||||
import info.nightscout.androidaps.plugins.DanaR.events.EventDanaRNewStatus;
|
import info.nightscout.androidaps.plugins.DanaR.events.EventDanaRNewStatus;
|
||||||
import info.nightscout.utils.DateUtil;
|
import info.nightscout.utils.DateUtil;
|
||||||
|
@ -65,6 +66,8 @@ public class DanaRFragment extends Fragment implements FragmentBase {
|
||||||
TextView iobView;
|
TextView iobView;
|
||||||
Button viewProfileButton;
|
Button viewProfileButton;
|
||||||
Button historyButton;
|
Button historyButton;
|
||||||
|
Button statsButton;
|
||||||
|
|
||||||
|
|
||||||
public DanaRFragment() {
|
public DanaRFragment() {
|
||||||
if (sHandlerThread == null) {
|
if (sHandlerThread == null) {
|
||||||
|
@ -105,6 +108,8 @@ public class DanaRFragment extends Fragment implements FragmentBase {
|
||||||
iobView = (TextView) view.findViewById(R.id.danar_iob);
|
iobView = (TextView) view.findViewById(R.id.danar_iob);
|
||||||
viewProfileButton = (Button) view.findViewById(R.id.danar_viewprofile);
|
viewProfileButton = (Button) view.findViewById(R.id.danar_viewprofile);
|
||||||
historyButton = (Button) view.findViewById(R.id.danar_history);
|
historyButton = (Button) view.findViewById(R.id.danar_history);
|
||||||
|
statsButton = (Button) view.findViewById(R.id.danar_stats);
|
||||||
|
|
||||||
|
|
||||||
viewProfileButton.setOnClickListener(new View.OnClickListener() {
|
viewProfileButton.setOnClickListener(new View.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
|
@ -122,6 +127,13 @@ public class DanaRFragment extends Fragment implements FragmentBase {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
statsButton.setOnClickListener(new View.OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(View v) {
|
||||||
|
startActivity(new Intent(getContext(), DanaRStatsActivity.class));
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
btConnectionView.setOnClickListener(new View.OnClickListener() {
|
btConnectionView.setOnClickListener(new View.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View v) {
|
public void onClick(View v) {
|
||||||
|
|
|
@ -252,7 +252,7 @@ public class DanaRPlugin implements PluginBase, PumpInterface, ConstraintsInterf
|
||||||
for (int h = 0; h < basalValues; h++) {
|
for (int h = 0; h < basalValues; h++) {
|
||||||
Double pumpValue = pump.pumpProfiles[pump.activeProfile][h];
|
Double pumpValue = pump.pumpProfiles[pump.activeProfile][h];
|
||||||
Double profileValue = profile.getBasal(h * basalIncrement);
|
Double profileValue = profile.getBasal(h * basalIncrement);
|
||||||
if (!pumpValue.equals(profileValue)) {
|
if (Math.abs(pumpValue - profileValue) > getPumpDescription().basalStep) {
|
||||||
log.debug("Diff found. Hour: " + h + " Pump: " + pumpValue + " Profile: " + profileValue);
|
log.debug("Diff found. Hour: " + h + " Pump: " + pumpValue + " Profile: " + profileValue);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,570 @@
|
||||||
|
package info.nightscout.androidaps.plugins.DanaR.History;
|
||||||
|
|
||||||
|
import android.app.Activity;
|
||||||
|
import android.content.ComponentName;
|
||||||
|
import android.content.Context;
|
||||||
|
import android.content.Intent;
|
||||||
|
import android.content.ServiceConnection;
|
||||||
|
import android.content.SharedPreferences;
|
||||||
|
import android.graphics.Color;
|
||||||
|
import android.graphics.Rect;
|
||||||
|
import android.os.Bundle;
|
||||||
|
import android.os.Handler;
|
||||||
|
import android.os.HandlerThread;
|
||||||
|
import android.os.IBinder;
|
||||||
|
import android.preference.PreferenceManager;
|
||||||
|
import android.support.v7.widget.LinearLayoutManager;
|
||||||
|
import android.text.TextUtils;
|
||||||
|
import android.view.KeyEvent;
|
||||||
|
import android.view.MotionEvent;
|
||||||
|
import android.view.View;
|
||||||
|
import android.view.WindowManager;
|
||||||
|
import android.view.inputmethod.EditorInfo;
|
||||||
|
import android.view.inputmethod.InputMethodManager;
|
||||||
|
import android.widget.Button;
|
||||||
|
import android.widget.EditText;
|
||||||
|
import android.widget.TableLayout;
|
||||||
|
import android.widget.TableRow;
|
||||||
|
import android.widget.TextView;
|
||||||
|
|
||||||
|
import com.j256.ormlite.dao.Dao;
|
||||||
|
import com.j256.ormlite.stmt.PreparedQuery;
|
||||||
|
import com.j256.ormlite.stmt.QueryBuilder;
|
||||||
|
import com.j256.ormlite.stmt.Where;
|
||||||
|
import com.squareup.otto.Subscribe;
|
||||||
|
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
|
import java.sql.SQLException;
|
||||||
|
import java.text.DateFormat;
|
||||||
|
import java.text.DecimalFormat;
|
||||||
|
import java.text.SimpleDateFormat;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.Date;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import info.nightscout.androidaps.MainApp;
|
||||||
|
import info.nightscout.androidaps.R;
|
||||||
|
import info.nightscout.androidaps.db.DanaRHistoryRecord;
|
||||||
|
import info.nightscout.androidaps.interfaces.ProfileInterface;
|
||||||
|
import info.nightscout.androidaps.plugins.CircadianPercentageProfile.CircadianPercentageProfilePlugin;
|
||||||
|
import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderPlugin;
|
||||||
|
import info.nightscout.androidaps.plugins.DanaR.Services.ExecutionService;
|
||||||
|
import info.nightscout.androidaps.plugins.DanaR.comm.RecordTypes;
|
||||||
|
import info.nightscout.androidaps.plugins.DanaR.events.EventDanaRConnectionStatus;
|
||||||
|
import info.nightscout.androidaps.plugins.DanaR.events.EventDanaRSyncStatus;
|
||||||
|
import info.nightscout.utils.DecimalFormatter;
|
||||||
|
import info.nightscout.utils.ToastUtils;
|
||||||
|
|
||||||
|
public class DanaRStatsActivity extends Activity {
|
||||||
|
private static Logger log = LoggerFactory.getLogger(DanaRStatsActivity.class);
|
||||||
|
|
||||||
|
private boolean mBounded;
|
||||||
|
private static ExecutionService mExecutionService;
|
||||||
|
|
||||||
|
private Handler mHandler;
|
||||||
|
private static HandlerThread mHandlerThread;
|
||||||
|
|
||||||
|
TextView statusView, statsMessage,totalBaseBasal2;
|
||||||
|
EditText totalBaseBasal;
|
||||||
|
Button reloadButton;
|
||||||
|
LinearLayoutManager llm;
|
||||||
|
TableLayout tl,ctl,etl;
|
||||||
|
String TBB;
|
||||||
|
double magicNumber;
|
||||||
|
DecimalFormat decimalFormat;
|
||||||
|
|
||||||
|
List<DanaRHistoryRecord> historyList = new ArrayList<>();
|
||||||
|
|
||||||
|
public DanaRStatsActivity() {
|
||||||
|
super();
|
||||||
|
mHandlerThread = new HandlerThread(DanaRStatsActivity.class.getSimpleName());
|
||||||
|
mHandlerThread.start();
|
||||||
|
this.mHandler = new Handler(mHandlerThread.getLooper());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onStart() {
|
||||||
|
super.onStart();
|
||||||
|
Intent intent = new Intent(this, ExecutionService.class);
|
||||||
|
bindService(intent, mConnection, Context.BIND_AUTO_CREATE);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onResume() {
|
||||||
|
super.onResume();
|
||||||
|
MainApp.bus().register(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onPause() {
|
||||||
|
super.onPause();
|
||||||
|
MainApp.bus().unregister(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onStop() {
|
||||||
|
super.onStop();
|
||||||
|
if (mBounded) {
|
||||||
|
unbindService(mConnection);
|
||||||
|
mBounded = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean dispatchTouchEvent(MotionEvent event) {
|
||||||
|
if (event.getAction() == MotionEvent.ACTION_DOWN) {
|
||||||
|
View myView = getCurrentFocus();
|
||||||
|
if ( myView instanceof EditText) {
|
||||||
|
Rect rect = new Rect();
|
||||||
|
myView.getGlobalVisibleRect(rect);
|
||||||
|
if (!rect.contains((int)event.getRawX(), (int)event.getRawY())) {
|
||||||
|
myView.clearFocus();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return super.dispatchTouchEvent( event );
|
||||||
|
}
|
||||||
|
|
||||||
|
ServiceConnection mConnection = new ServiceConnection() {
|
||||||
|
|
||||||
|
public void onServiceDisconnected(ComponentName name) {
|
||||||
|
log.debug("Service is disconnected");
|
||||||
|
mBounded = false;
|
||||||
|
mExecutionService = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void onServiceConnected(ComponentName name, IBinder service) {
|
||||||
|
log.debug("Service is connected");
|
||||||
|
mBounded = true;
|
||||||
|
ExecutionService.LocalBinder mLocalBinder = (ExecutionService.LocalBinder) service;
|
||||||
|
mExecutionService = mLocalBinder.getServiceInstance();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
|
super.onCreate(savedInstanceState);
|
||||||
|
setContentView(R.layout.danar_statsactivity);
|
||||||
|
getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_PAN);
|
||||||
|
statusView = (TextView) findViewById(R.id.danar_stats_connection_status);
|
||||||
|
reloadButton = (Button) findViewById(R.id.danar_statsreload);
|
||||||
|
totalBaseBasal = (EditText) findViewById(R.id.danar_stats_editTotalBaseBasal);
|
||||||
|
totalBaseBasal2 = (TextView) findViewById(R.id.danar_stats_editTotalBaseBasal2);
|
||||||
|
statsMessage = (TextView) findViewById(R.id.danar_stats_Message);
|
||||||
|
|
||||||
|
statusView.setVisibility(View.GONE);
|
||||||
|
statsMessage.setVisibility(View.GONE);
|
||||||
|
|
||||||
|
totalBaseBasal2.setEnabled(false);
|
||||||
|
totalBaseBasal2.setClickable(false);
|
||||||
|
totalBaseBasal2.setFocusable(false);
|
||||||
|
totalBaseBasal2.setInputType(0);
|
||||||
|
|
||||||
|
decimalFormat = new DecimalFormat("0.000");
|
||||||
|
llm = new LinearLayoutManager(this);
|
||||||
|
|
||||||
|
final SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(this);
|
||||||
|
TBB = preferences.getString("TBB", "10.00");
|
||||||
|
totalBaseBasal.setText(TBB);
|
||||||
|
|
||||||
|
ProfileInterface pi = ConfigBuilderPlugin.getActiveProfile();
|
||||||
|
if (pi != null && pi instanceof CircadianPercentageProfilePlugin){
|
||||||
|
double cppTBB = ((CircadianPercentageProfilePlugin)pi).baseBasalSum();
|
||||||
|
totalBaseBasal.setText(decimalFormat.format(cppTBB));
|
||||||
|
SharedPreferences.Editor edit = preferences.edit();
|
||||||
|
edit.putString("TBB",totalBaseBasal.getText().toString());
|
||||||
|
edit.commit();
|
||||||
|
TBB = preferences.getString("TBB", "");
|
||||||
|
}
|
||||||
|
|
||||||
|
// stats table
|
||||||
|
tl = (TableLayout) findViewById(R.id.main_table);
|
||||||
|
TableRow tr_head = new TableRow(this);
|
||||||
|
tr_head.setBackgroundColor(Color.DKGRAY);
|
||||||
|
tr_head.setLayoutParams(new TableLayout.LayoutParams(
|
||||||
|
TableLayout.LayoutParams.FILL_PARENT,
|
||||||
|
TableLayout.LayoutParams.WRAP_CONTENT));
|
||||||
|
|
||||||
|
TextView label_date = new TextView(this);
|
||||||
|
label_date.setText(getString(R.string.danar_stats_date));
|
||||||
|
label_date.setTextColor(Color.WHITE);
|
||||||
|
tr_head.addView(label_date);
|
||||||
|
|
||||||
|
TextView label_basalrate = new TextView(this);
|
||||||
|
label_basalrate.setText(getString(R.string.danar_stats_basalrate));
|
||||||
|
label_basalrate.setTextColor(Color.WHITE);
|
||||||
|
tr_head.addView(label_basalrate);
|
||||||
|
|
||||||
|
TextView label_bolus = new TextView(this);
|
||||||
|
label_bolus.setText(getString(R.string.danar_stats_bolus));
|
||||||
|
label_bolus.setTextColor(Color.WHITE);
|
||||||
|
tr_head.addView(label_bolus);
|
||||||
|
|
||||||
|
TextView label_tdd = new TextView(this);
|
||||||
|
label_tdd.setText(getString(R.string.danar_stats_tdd));
|
||||||
|
label_tdd.setTextColor(Color.WHITE);
|
||||||
|
tr_head.addView(label_tdd);
|
||||||
|
|
||||||
|
TextView label_ratio = new TextView(this);
|
||||||
|
label_ratio.setText(getString(R.string.danar_stats_ratio));
|
||||||
|
label_ratio.setTextColor(Color.WHITE);
|
||||||
|
tr_head.addView(label_ratio);
|
||||||
|
|
||||||
|
// add stats headers to tables
|
||||||
|
tl.addView(tr_head, new TableLayout.LayoutParams(
|
||||||
|
TableLayout.LayoutParams.FILL_PARENT,
|
||||||
|
TableLayout.LayoutParams.WRAP_CONTENT));
|
||||||
|
|
||||||
|
// cumulative table
|
||||||
|
ctl = (TableLayout) findViewById(R.id.cumulative_table);
|
||||||
|
TableRow ctr_head = new TableRow(this);
|
||||||
|
ctr_head.setBackgroundColor(Color.DKGRAY);
|
||||||
|
ctr_head.setLayoutParams(new TableLayout.LayoutParams(
|
||||||
|
TableLayout.LayoutParams.FILL_PARENT,
|
||||||
|
TableLayout.LayoutParams.WRAP_CONTENT));
|
||||||
|
|
||||||
|
TextView label_cum_amount_days = new TextView(this);
|
||||||
|
label_cum_amount_days.setText(getString(R.string.danar_stats_amount_days));
|
||||||
|
label_cum_amount_days.setTextColor(Color.WHITE);
|
||||||
|
ctr_head.addView(label_cum_amount_days);
|
||||||
|
|
||||||
|
TextView label_cum_tdd = new TextView(this);
|
||||||
|
label_cum_tdd.setText(getString(R.string.danar_stats_tdd));
|
||||||
|
label_cum_tdd.setTextColor(Color.WHITE);
|
||||||
|
ctr_head.addView(label_cum_tdd);
|
||||||
|
|
||||||
|
TextView label_cum_ratio = new TextView(this);
|
||||||
|
label_cum_ratio.setText(getString(R.string.danar_stats_ratio));
|
||||||
|
label_cum_ratio.setTextColor(Color.WHITE);
|
||||||
|
ctr_head.addView(label_cum_ratio);
|
||||||
|
|
||||||
|
// add cummulative headers to tables
|
||||||
|
ctl.addView(ctr_head, new TableLayout.LayoutParams(
|
||||||
|
TableLayout.LayoutParams.FILL_PARENT,
|
||||||
|
TableLayout.LayoutParams.WRAP_CONTENT));
|
||||||
|
|
||||||
|
// expontial table
|
||||||
|
etl = (TableLayout) findViewById(R.id.expweight_table);
|
||||||
|
TableRow etr_head = new TableRow(this);
|
||||||
|
etr_head.setBackgroundColor(Color.DKGRAY);
|
||||||
|
etr_head.setLayoutParams(new TableLayout.LayoutParams(
|
||||||
|
TableLayout.LayoutParams.FILL_PARENT,
|
||||||
|
TableLayout.LayoutParams.WRAP_CONTENT));
|
||||||
|
|
||||||
|
TextView label_exp_weight = new TextView(this);
|
||||||
|
label_exp_weight.setText(getString(R.string.danar_stats_weight));
|
||||||
|
label_exp_weight.setTextColor(Color.WHITE);
|
||||||
|
etr_head.addView(label_exp_weight);
|
||||||
|
|
||||||
|
TextView label_exp_tdd = new TextView(this);
|
||||||
|
label_exp_tdd.setText(getString(R.string.danar_stats_tdd));
|
||||||
|
label_exp_tdd.setTextColor(Color.WHITE);
|
||||||
|
etr_head.addView(label_exp_tdd);
|
||||||
|
|
||||||
|
TextView label_exp_ratio = new TextView(this);
|
||||||
|
label_exp_ratio.setText(getString(R.string.danar_stats_ratio));
|
||||||
|
label_exp_ratio.setTextColor(Color.WHITE);
|
||||||
|
etr_head.addView(label_exp_ratio);
|
||||||
|
|
||||||
|
// add expontial headers to tables
|
||||||
|
etl.addView(etr_head, new TableLayout.LayoutParams(
|
||||||
|
TableLayout.LayoutParams.FILL_PARENT,
|
||||||
|
TableLayout.LayoutParams.WRAP_CONTENT));
|
||||||
|
|
||||||
|
reloadButton.setOnClickListener(new View.OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(View v) {
|
||||||
|
if (mExecutionService.isConnected() || mExecutionService.isConnecting()) {
|
||||||
|
ToastUtils.showToastInUiThread(MainApp.instance().getApplicationContext(), getString(R.string.pumpbusy));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
mHandler.post(new Runnable() {
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
runOnUiThread(new Runnable() {
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
reloadButton.setVisibility(View.GONE);
|
||||||
|
statusView.setVisibility(View.VISIBLE);
|
||||||
|
statsMessage.setVisibility(View.VISIBLE);
|
||||||
|
statsMessage.setText(getString(R.string.danar_stats_warning_Message));
|
||||||
|
}
|
||||||
|
});
|
||||||
|
mExecutionService.loadHistory(RecordTypes.RECORD_TYPE_DAILY);
|
||||||
|
loadDataFromDB(RecordTypes.RECORD_TYPE_DAILY);
|
||||||
|
runOnUiThread(new Runnable() {
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
reloadButton.setVisibility(View.VISIBLE);
|
||||||
|
statusView.setVisibility(View.GONE);
|
||||||
|
statsMessage.setVisibility(View.GONE);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
totalBaseBasal.setOnEditorActionListener(new TextView.OnEditorActionListener() {
|
||||||
|
@Override
|
||||||
|
public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
|
||||||
|
if(actionId== EditorInfo.IME_ACTION_DONE){
|
||||||
|
totalBaseBasal.clearFocus();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
totalBaseBasal.setOnFocusChangeListener(new View.OnFocusChangeListener() {
|
||||||
|
@Override
|
||||||
|
public void onFocusChange(View v, boolean hasFocus) {
|
||||||
|
if(hasFocus){
|
||||||
|
totalBaseBasal.getText().clear();
|
||||||
|
} else {
|
||||||
|
SharedPreferences.Editor edit = preferences.edit();
|
||||||
|
edit.putString("TBB",totalBaseBasal.getText().toString());
|
||||||
|
edit.commit();
|
||||||
|
TBB = preferences.getString("TBB", "");
|
||||||
|
loadDataFromDB(RecordTypes.RECORD_TYPE_DAILY);
|
||||||
|
InputMethodManager imm = (InputMethodManager) getSystemService(INPUT_METHOD_SERVICE);
|
||||||
|
imm.hideSoftInputFromWindow(totalBaseBasal.getWindowToken(), 0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
loadDataFromDB(RecordTypes.RECORD_TYPE_DAILY);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void loadDataFromDB(byte type) {
|
||||||
|
try {
|
||||||
|
Dao<DanaRHistoryRecord, String> dao = MainApp.getDbHelper().getDaoDanaRHistory();
|
||||||
|
QueryBuilder<DanaRHistoryRecord, String> queryBuilder = dao.queryBuilder();
|
||||||
|
queryBuilder.orderBy("recordDate", false);
|
||||||
|
Where where = queryBuilder.where();
|
||||||
|
where.eq("recordCode", type);
|
||||||
|
queryBuilder.limit(10L);
|
||||||
|
PreparedQuery<DanaRHistoryRecord> preparedQuery = queryBuilder.prepare();
|
||||||
|
historyList = dao.query(preparedQuery);
|
||||||
|
} catch (SQLException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
historyList = new ArrayList<>();
|
||||||
|
}
|
||||||
|
runOnUiThread(new Runnable() {
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
cleanTable(tl);
|
||||||
|
cleanTable(ctl);
|
||||||
|
cleanTable(etl);
|
||||||
|
DateFormat df = new SimpleDateFormat("dd.MM.");
|
||||||
|
|
||||||
|
if(TextUtils.isEmpty(TBB)) {
|
||||||
|
totalBaseBasal.setError("Please Enter Total Base Basal");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
magicNumber = Double.parseDouble(TBB);
|
||||||
|
}
|
||||||
|
|
||||||
|
magicNumber *=2;
|
||||||
|
totalBaseBasal2.setText(decimalFormat.format(magicNumber));
|
||||||
|
|
||||||
|
int i = 0;
|
||||||
|
double sum = 0d;
|
||||||
|
double weighted03 = 0d;
|
||||||
|
double weighted05 = 0d;
|
||||||
|
double weighted07 = 0d;
|
||||||
|
|
||||||
|
for (DanaRHistoryRecord record: historyList) {
|
||||||
|
double tdd= record.getRecordDailyBolus() + record.getRecordDailyBasal();
|
||||||
|
|
||||||
|
// Create the table row
|
||||||
|
TableRow tr = new TableRow(DanaRStatsActivity.this);
|
||||||
|
if(i%2!=0) tr.setBackgroundColor(Color.DKGRAY);
|
||||||
|
tr.setId(100+i);
|
||||||
|
tr.setLayoutParams(new TableLayout.LayoutParams(
|
||||||
|
TableLayout.LayoutParams.FILL_PARENT,
|
||||||
|
TableLayout.LayoutParams.WRAP_CONTENT));
|
||||||
|
|
||||||
|
// Here create the TextView dynamically
|
||||||
|
TextView labelDATE = new TextView(DanaRStatsActivity.this);
|
||||||
|
labelDATE.setId(200+i);
|
||||||
|
labelDATE.setText(df.format(new Date(record.getRecordDate())));
|
||||||
|
labelDATE.setTextColor(Color.WHITE);
|
||||||
|
tr.addView(labelDATE);
|
||||||
|
|
||||||
|
TextView labelBASAL = new TextView(DanaRStatsActivity.this);
|
||||||
|
labelBASAL.setId(300+i);
|
||||||
|
labelBASAL.setText(DecimalFormatter.to2Decimal(record.getRecordDailyBasal()) + " U");
|
||||||
|
labelBASAL.setTextColor(Color.WHITE);
|
||||||
|
tr.addView(labelBASAL);
|
||||||
|
|
||||||
|
TextView labelBOLUS = new TextView(DanaRStatsActivity.this);
|
||||||
|
labelBOLUS.setId(400+i);
|
||||||
|
labelBOLUS.setText(DecimalFormatter.to2Decimal(record.getRecordDailyBolus()) + " U");
|
||||||
|
labelBOLUS.setTextColor(Color.WHITE);
|
||||||
|
tr.addView(labelBOLUS);
|
||||||
|
|
||||||
|
TextView labelTDD = new TextView(DanaRStatsActivity.this);
|
||||||
|
labelTDD.setId(500+i);
|
||||||
|
labelTDD.setText(DecimalFormatter.to2Decimal(tdd) + " U");
|
||||||
|
labelTDD.setTextColor(Color.WHITE);
|
||||||
|
tr.addView(labelTDD);
|
||||||
|
|
||||||
|
TextView labelRATIO = new TextView(DanaRStatsActivity.this);
|
||||||
|
labelRATIO.setId(600+i);
|
||||||
|
labelRATIO.setText(Math.round(100*tdd/magicNumber) +" %");
|
||||||
|
labelRATIO.setTextColor(Color.WHITE);
|
||||||
|
tr.addView(labelRATIO);
|
||||||
|
|
||||||
|
// add stats rows to tables
|
||||||
|
tl.addView(tr, new TableLayout.LayoutParams(
|
||||||
|
TableLayout.LayoutParams.FILL_PARENT,
|
||||||
|
TableLayout.LayoutParams.WRAP_CONTENT));
|
||||||
|
|
||||||
|
sum = sum + tdd;
|
||||||
|
i++;
|
||||||
|
|
||||||
|
// Create the cumtable row
|
||||||
|
TableRow ctr = new TableRow(DanaRStatsActivity.this);
|
||||||
|
if(i%2==0) ctr.setBackgroundColor(Color.DKGRAY);
|
||||||
|
ctr.setId(700+i);
|
||||||
|
ctr.setLayoutParams(new TableLayout.LayoutParams(
|
||||||
|
TableLayout.LayoutParams.FILL_PARENT,
|
||||||
|
TableLayout.LayoutParams.WRAP_CONTENT));
|
||||||
|
|
||||||
|
// Here create the TextView dynamically
|
||||||
|
TextView labelDAYS = new TextView(DanaRStatsActivity.this);
|
||||||
|
labelDAYS.setId(800+i);
|
||||||
|
labelDAYS.setText("" + i);
|
||||||
|
labelDAYS.setTextColor(Color.WHITE);
|
||||||
|
ctr.addView(labelDAYS);
|
||||||
|
|
||||||
|
TextView labelCUMTDD = new TextView(DanaRStatsActivity.this);
|
||||||
|
labelCUMTDD.setId(900+i);
|
||||||
|
labelCUMTDD.setText(DecimalFormatter.to2Decimal(sum/i) + " U");
|
||||||
|
labelCUMTDD.setTextColor(Color.WHITE);
|
||||||
|
ctr.addView(labelCUMTDD);
|
||||||
|
|
||||||
|
TextView labelCUMRATIO = new TextView(DanaRStatsActivity.this);
|
||||||
|
labelCUMRATIO.setId(1000+i);
|
||||||
|
labelCUMRATIO.setText(Math.round(100*sum/i/magicNumber) + " %");
|
||||||
|
labelCUMRATIO.setTextColor(Color.WHITE);
|
||||||
|
ctr.addView(labelCUMRATIO);
|
||||||
|
|
||||||
|
// add cummulative rows to tables
|
||||||
|
ctl.addView(ctr, new TableLayout.LayoutParams(
|
||||||
|
TableLayout.LayoutParams.FILL_PARENT,
|
||||||
|
TableLayout.LayoutParams.WRAP_CONTENT));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (historyList.size()<3 || !(df.format(new Date(historyList.get(0).getRecordDate())).equals(df.format(new Date(System.currentTimeMillis() - 1000*60*60*24))))){
|
||||||
|
statsMessage.setVisibility(View.VISIBLE);
|
||||||
|
statsMessage.setText(getString(R.string.danar_stats_olddata_Message));
|
||||||
|
|
||||||
|
} else {
|
||||||
|
tl.setBackgroundColor(Color.TRANSPARENT);
|
||||||
|
}
|
||||||
|
|
||||||
|
Collections.reverse(historyList);
|
||||||
|
|
||||||
|
i = 0;
|
||||||
|
|
||||||
|
for (DanaRHistoryRecord record: historyList) {
|
||||||
|
double tdd= record.getRecordDailyBolus() + record.getRecordDailyBasal();
|
||||||
|
if(i == 0 ) {
|
||||||
|
weighted03 = tdd;
|
||||||
|
weighted05 = tdd;
|
||||||
|
weighted07 = tdd;
|
||||||
|
|
||||||
|
} else {
|
||||||
|
weighted07 = (weighted07*0.3 + tdd*0.7);
|
||||||
|
weighted05 = (weighted05*0.5 + tdd*0.5);
|
||||||
|
weighted03 = (weighted03*0.7 + tdd*0.3);
|
||||||
|
}
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Create the exptable row
|
||||||
|
TableRow etr = new TableRow(DanaRStatsActivity.this);
|
||||||
|
if(i%2!=0) etr.setBackgroundColor(Color.DKGRAY);
|
||||||
|
etr.setId(1100+i);
|
||||||
|
etr.setLayoutParams(new TableLayout.LayoutParams(
|
||||||
|
TableLayout.LayoutParams.FILL_PARENT,
|
||||||
|
TableLayout.LayoutParams.WRAP_CONTENT));
|
||||||
|
|
||||||
|
// Here create the TextView dynamically
|
||||||
|
TextView labelWEIGHT = new TextView(DanaRStatsActivity.this);
|
||||||
|
labelWEIGHT.setId(1200+i);
|
||||||
|
labelWEIGHT.setText("0.3\n" + "0.5\n" + "0.7");
|
||||||
|
labelWEIGHT.setTextColor(Color.WHITE);
|
||||||
|
etr.addView(labelWEIGHT);
|
||||||
|
|
||||||
|
TextView labelEXPTDD = new TextView(DanaRStatsActivity.this);
|
||||||
|
labelEXPTDD.setId(1300+i);
|
||||||
|
labelEXPTDD.setText(DecimalFormatter.to2Decimal(weighted03)
|
||||||
|
+ " U\n" + DecimalFormatter.to2Decimal(weighted05)
|
||||||
|
+ " U\n" + DecimalFormatter.to2Decimal(weighted07) + " U");
|
||||||
|
labelEXPTDD.setTextColor(Color.WHITE);
|
||||||
|
etr.addView(labelEXPTDD);
|
||||||
|
|
||||||
|
TextView labelEXPRATIO = new TextView(DanaRStatsActivity.this);
|
||||||
|
labelEXPRATIO.setId(1400+i);
|
||||||
|
labelEXPRATIO.setText(Math.round(100*weighted03/magicNumber) +" %\n"
|
||||||
|
+ Math.round(100*weighted05/magicNumber) +" %\n"
|
||||||
|
+ Math.round(100*weighted07/magicNumber) +" %");
|
||||||
|
labelEXPRATIO.setTextColor(Color.WHITE);
|
||||||
|
etr.addView(labelEXPRATIO);
|
||||||
|
|
||||||
|
// add exponentail rows to tables
|
||||||
|
etl.addView(etr, new TableLayout.LayoutParams(
|
||||||
|
TableLayout.LayoutParams.FILL_PARENT,
|
||||||
|
TableLayout.LayoutParams.WRAP_CONTENT));
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
private void cleanTable(TableLayout table) {
|
||||||
|
int childCount = table.getChildCount();
|
||||||
|
// Remove all rows except the first one
|
||||||
|
if (childCount > 1) {
|
||||||
|
table.removeViews(1, childCount - 1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Subscribe
|
||||||
|
public void onStatusEvent(final EventDanaRSyncStatus s) {
|
||||||
|
log.debug("EventDanaRSyncStatus: " + s.message);
|
||||||
|
runOnUiThread(
|
||||||
|
new Runnable() {
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
statusView.setText(s.message);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
@Subscribe
|
||||||
|
public void onStatusEvent(final EventDanaRConnectionStatus c) {
|
||||||
|
runOnUiThread(
|
||||||
|
new Runnable() {
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
if (c.sStatus == EventDanaRConnectionStatus.CONNECTING) {
|
||||||
|
statusView.setText(String.format(getString(R.string.danar_history_connectingfor), c.sSecondsElapsed));
|
||||||
|
log.debug("EventDanaRConnectionStatus: " + "Connecting for " + c.sSecondsElapsed + "s");
|
||||||
|
} else if (c.sStatus == EventDanaRConnectionStatus.CONNECTED) {
|
||||||
|
statusView.setText(MainApp.sResources.getString(R.string.connected));
|
||||||
|
log.debug("EventDanaRConnectionStatus: Connected");
|
||||||
|
} else {
|
||||||
|
statusView.setText(MainApp.sResources.getString(R.string.disconnected));
|
||||||
|
log.debug("EventDanaRConnectionStatus: Disconnected");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
|
@ -31,6 +31,7 @@ import info.nightscout.androidaps.plugins.DanaR.Dialogs.ProfileViewDialog;
|
||||||
import info.nightscout.androidaps.plugins.DanaR.events.EventDanaRConnectionStatus;
|
import info.nightscout.androidaps.plugins.DanaR.events.EventDanaRConnectionStatus;
|
||||||
import info.nightscout.androidaps.plugins.DanaR.events.EventDanaRNewStatus;
|
import info.nightscout.androidaps.plugins.DanaR.events.EventDanaRNewStatus;
|
||||||
import info.nightscout.androidaps.plugins.DanaRKorean.History.DanaRHistoryActivity;
|
import info.nightscout.androidaps.plugins.DanaRKorean.History.DanaRHistoryActivity;
|
||||||
|
import info.nightscout.androidaps.plugins.DanaRKorean.History.DanaRStatsActivity;
|
||||||
import info.nightscout.utils.DateUtil;
|
import info.nightscout.utils.DateUtil;
|
||||||
import info.nightscout.utils.DecimalFormatter;
|
import info.nightscout.utils.DecimalFormatter;
|
||||||
import info.nightscout.utils.SetWarnColor;
|
import info.nightscout.utils.SetWarnColor;
|
||||||
|
@ -62,6 +63,8 @@ public class DanaRKoreanFragment extends Fragment implements FragmentBase {
|
||||||
TextView iobView;
|
TextView iobView;
|
||||||
Button viewProfileButton;
|
Button viewProfileButton;
|
||||||
Button historyButton;
|
Button historyButton;
|
||||||
|
Button statsButton;
|
||||||
|
|
||||||
|
|
||||||
public DanaRKoreanFragment() {
|
public DanaRKoreanFragment() {
|
||||||
if (sHandlerThread == null) {
|
if (sHandlerThread == null) {
|
||||||
|
@ -102,6 +105,8 @@ public class DanaRKoreanFragment extends Fragment implements FragmentBase {
|
||||||
iobView = (TextView) view.findViewById(R.id.danar_iob);
|
iobView = (TextView) view.findViewById(R.id.danar_iob);
|
||||||
viewProfileButton = (Button) view.findViewById(R.id.danar_viewprofile);
|
viewProfileButton = (Button) view.findViewById(R.id.danar_viewprofile);
|
||||||
historyButton = (Button) view.findViewById(R.id.danar_history);
|
historyButton = (Button) view.findViewById(R.id.danar_history);
|
||||||
|
statsButton = (Button) view.findViewById(R.id.danar_stats);
|
||||||
|
|
||||||
|
|
||||||
viewProfileButton.setOnClickListener(new View.OnClickListener() {
|
viewProfileButton.setOnClickListener(new View.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
|
@ -119,6 +124,13 @@ public class DanaRKoreanFragment extends Fragment implements FragmentBase {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
statsButton.setOnClickListener(new View.OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(View v) {
|
||||||
|
startActivity(new Intent(getContext(), DanaRStatsActivity.class));
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
btConnectionView.setOnClickListener(new View.OnClickListener() {
|
btConnectionView.setOnClickListener(new View.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View v) {
|
public void onClick(View v) {
|
||||||
|
|
|
@ -0,0 +1,570 @@
|
||||||
|
package info.nightscout.androidaps.plugins.DanaRKorean.History;
|
||||||
|
|
||||||
|
import android.app.Activity;
|
||||||
|
import android.content.ComponentName;
|
||||||
|
import android.content.Context;
|
||||||
|
import android.content.Intent;
|
||||||
|
import android.content.ServiceConnection;
|
||||||
|
import android.content.SharedPreferences;
|
||||||
|
import android.graphics.Color;
|
||||||
|
import android.graphics.Rect;
|
||||||
|
import android.os.Bundle;
|
||||||
|
import android.os.Handler;
|
||||||
|
import android.os.HandlerThread;
|
||||||
|
import android.os.IBinder;
|
||||||
|
import android.preference.PreferenceManager;
|
||||||
|
import android.support.v7.widget.LinearLayoutManager;
|
||||||
|
import android.text.TextUtils;
|
||||||
|
import android.view.KeyEvent;
|
||||||
|
import android.view.MotionEvent;
|
||||||
|
import android.view.View;
|
||||||
|
import android.view.WindowManager;
|
||||||
|
import android.view.inputmethod.EditorInfo;
|
||||||
|
import android.view.inputmethod.InputMethodManager;
|
||||||
|
import android.widget.Button;
|
||||||
|
import android.widget.EditText;
|
||||||
|
import android.widget.TableLayout;
|
||||||
|
import android.widget.TableRow;
|
||||||
|
import android.widget.TextView;
|
||||||
|
|
||||||
|
import com.j256.ormlite.dao.Dao;
|
||||||
|
import com.j256.ormlite.stmt.PreparedQuery;
|
||||||
|
import com.j256.ormlite.stmt.QueryBuilder;
|
||||||
|
import com.j256.ormlite.stmt.Where;
|
||||||
|
import com.squareup.otto.Subscribe;
|
||||||
|
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
|
import java.sql.SQLException;
|
||||||
|
import java.text.DateFormat;
|
||||||
|
import java.text.DecimalFormat;
|
||||||
|
import java.text.SimpleDateFormat;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.Date;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import info.nightscout.androidaps.MainApp;
|
||||||
|
import info.nightscout.androidaps.R;
|
||||||
|
import info.nightscout.androidaps.db.DanaRHistoryRecord;
|
||||||
|
import info.nightscout.androidaps.interfaces.ProfileInterface;
|
||||||
|
import info.nightscout.androidaps.plugins.CircadianPercentageProfile.CircadianPercentageProfilePlugin;
|
||||||
|
import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderPlugin;
|
||||||
|
import info.nightscout.androidaps.plugins.DanaR.comm.RecordTypes;
|
||||||
|
import info.nightscout.androidaps.plugins.DanaR.events.EventDanaRConnectionStatus;
|
||||||
|
import info.nightscout.androidaps.plugins.DanaR.events.EventDanaRSyncStatus;
|
||||||
|
import info.nightscout.androidaps.plugins.DanaRKorean.Services.ExecutionService;
|
||||||
|
import info.nightscout.utils.DecimalFormatter;
|
||||||
|
import info.nightscout.utils.ToastUtils;
|
||||||
|
|
||||||
|
public class DanaRStatsActivity extends Activity {
|
||||||
|
private static Logger log = LoggerFactory.getLogger(DanaRStatsActivity.class);
|
||||||
|
|
||||||
|
private boolean mBounded;
|
||||||
|
private static ExecutionService mExecutionService;
|
||||||
|
|
||||||
|
private Handler mHandler;
|
||||||
|
private static HandlerThread mHandlerThread;
|
||||||
|
|
||||||
|
TextView statusView, statsMessage,totalBaseBasal2;
|
||||||
|
EditText totalBaseBasal;
|
||||||
|
Button reloadButton;
|
||||||
|
LinearLayoutManager llm;
|
||||||
|
TableLayout tl,ctl,etl;
|
||||||
|
String TBB;
|
||||||
|
double magicNumber;
|
||||||
|
DecimalFormat decimalFormat;
|
||||||
|
|
||||||
|
List<DanaRHistoryRecord> historyList = new ArrayList<>();
|
||||||
|
|
||||||
|
public DanaRStatsActivity() {
|
||||||
|
super();
|
||||||
|
mHandlerThread = new HandlerThread(DanaRStatsActivity.class.getSimpleName());
|
||||||
|
mHandlerThread.start();
|
||||||
|
this.mHandler = new Handler(mHandlerThread.getLooper());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onStart() {
|
||||||
|
super.onStart();
|
||||||
|
Intent intent = new Intent(this, ExecutionService.class);
|
||||||
|
bindService(intent, mConnection, Context.BIND_AUTO_CREATE);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onResume() {
|
||||||
|
super.onResume();
|
||||||
|
MainApp.bus().register(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onPause() {
|
||||||
|
super.onPause();
|
||||||
|
MainApp.bus().unregister(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onStop() {
|
||||||
|
super.onStop();
|
||||||
|
if (mBounded) {
|
||||||
|
unbindService(mConnection);
|
||||||
|
mBounded = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean dispatchTouchEvent(MotionEvent event) {
|
||||||
|
if (event.getAction() == MotionEvent.ACTION_DOWN) {
|
||||||
|
View myView = getCurrentFocus();
|
||||||
|
if ( myView instanceof EditText) {
|
||||||
|
Rect rect = new Rect();
|
||||||
|
myView.getGlobalVisibleRect(rect);
|
||||||
|
if (!rect.contains((int)event.getRawX(), (int)event.getRawY())) {
|
||||||
|
myView.clearFocus();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return super.dispatchTouchEvent( event );
|
||||||
|
}
|
||||||
|
|
||||||
|
ServiceConnection mConnection = new ServiceConnection() {
|
||||||
|
|
||||||
|
public void onServiceDisconnected(ComponentName name) {
|
||||||
|
log.debug("Service is disconnected");
|
||||||
|
mBounded = false;
|
||||||
|
mExecutionService = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void onServiceConnected(ComponentName name, IBinder service) {
|
||||||
|
log.debug("Service is connected");
|
||||||
|
mBounded = true;
|
||||||
|
ExecutionService.LocalBinder mLocalBinder = (ExecutionService.LocalBinder) service;
|
||||||
|
mExecutionService = mLocalBinder.getServiceInstance();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
|
super.onCreate(savedInstanceState);
|
||||||
|
setContentView(R.layout.danar_statsactivity);
|
||||||
|
getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_PAN);
|
||||||
|
statusView = (TextView) findViewById(R.id.danar_stats_connection_status);
|
||||||
|
reloadButton = (Button) findViewById(R.id.danar_statsreload);
|
||||||
|
totalBaseBasal = (EditText) findViewById(R.id.danar_stats_editTotalBaseBasal);
|
||||||
|
totalBaseBasal2 = (TextView) findViewById(R.id.danar_stats_editTotalBaseBasal2);
|
||||||
|
statsMessage = (TextView) findViewById(R.id.danar_stats_Message);
|
||||||
|
|
||||||
|
statusView.setVisibility(View.GONE);
|
||||||
|
statsMessage.setVisibility(View.GONE);
|
||||||
|
|
||||||
|
totalBaseBasal2.setEnabled(false);
|
||||||
|
totalBaseBasal2.setClickable(false);
|
||||||
|
totalBaseBasal2.setFocusable(false);
|
||||||
|
totalBaseBasal2.setInputType(0);
|
||||||
|
|
||||||
|
decimalFormat = new DecimalFormat("0.000");
|
||||||
|
llm = new LinearLayoutManager(this);
|
||||||
|
|
||||||
|
final SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(this);
|
||||||
|
TBB = preferences.getString("TBB", "10.00");
|
||||||
|
totalBaseBasal.setText(TBB);
|
||||||
|
|
||||||
|
ProfileInterface pi = ConfigBuilderPlugin.getActiveProfile();
|
||||||
|
if (pi != null && pi instanceof CircadianPercentageProfilePlugin){
|
||||||
|
double cppTBB = ((CircadianPercentageProfilePlugin)pi).baseBasalSum();
|
||||||
|
totalBaseBasal.setText(decimalFormat.format(cppTBB));
|
||||||
|
SharedPreferences.Editor edit = preferences.edit();
|
||||||
|
edit.putString("TBB",totalBaseBasal.getText().toString());
|
||||||
|
edit.commit();
|
||||||
|
TBB = preferences.getString("TBB", "");
|
||||||
|
}
|
||||||
|
|
||||||
|
// stats table
|
||||||
|
tl = (TableLayout) findViewById(R.id.main_table);
|
||||||
|
TableRow tr_head = new TableRow(this);
|
||||||
|
tr_head.setBackgroundColor(Color.DKGRAY);
|
||||||
|
tr_head.setLayoutParams(new TableLayout.LayoutParams(
|
||||||
|
TableLayout.LayoutParams.FILL_PARENT,
|
||||||
|
TableLayout.LayoutParams.WRAP_CONTENT));
|
||||||
|
|
||||||
|
TextView label_date = new TextView(this);
|
||||||
|
label_date.setText(getString(R.string.danar_stats_date));
|
||||||
|
label_date.setTextColor(Color.WHITE);
|
||||||
|
tr_head.addView(label_date);
|
||||||
|
|
||||||
|
TextView label_basalrate = new TextView(this);
|
||||||
|
label_basalrate.setText(getString(R.string.danar_stats_basalrate));
|
||||||
|
label_basalrate.setTextColor(Color.WHITE);
|
||||||
|
tr_head.addView(label_basalrate);
|
||||||
|
|
||||||
|
TextView label_bolus = new TextView(this);
|
||||||
|
label_bolus.setText(getString(R.string.danar_stats_bolus));
|
||||||
|
label_bolus.setTextColor(Color.WHITE);
|
||||||
|
tr_head.addView(label_bolus);
|
||||||
|
|
||||||
|
TextView label_tdd = new TextView(this);
|
||||||
|
label_tdd.setText(getString(R.string.danar_stats_tdd));
|
||||||
|
label_tdd.setTextColor(Color.WHITE);
|
||||||
|
tr_head.addView(label_tdd);
|
||||||
|
|
||||||
|
TextView label_ratio = new TextView(this);
|
||||||
|
label_ratio.setText(getString(R.string.danar_stats_ratio));
|
||||||
|
label_ratio.setTextColor(Color.WHITE);
|
||||||
|
tr_head.addView(label_ratio);
|
||||||
|
|
||||||
|
// add stats headers to tables
|
||||||
|
tl.addView(tr_head, new TableLayout.LayoutParams(
|
||||||
|
TableLayout.LayoutParams.FILL_PARENT,
|
||||||
|
TableLayout.LayoutParams.WRAP_CONTENT));
|
||||||
|
|
||||||
|
// cumulative table
|
||||||
|
ctl = (TableLayout) findViewById(R.id.cumulative_table);
|
||||||
|
TableRow ctr_head = new TableRow(this);
|
||||||
|
ctr_head.setBackgroundColor(Color.DKGRAY);
|
||||||
|
ctr_head.setLayoutParams(new TableLayout.LayoutParams(
|
||||||
|
TableLayout.LayoutParams.FILL_PARENT,
|
||||||
|
TableLayout.LayoutParams.WRAP_CONTENT));
|
||||||
|
|
||||||
|
TextView label_cum_amount_days = new TextView(this);
|
||||||
|
label_cum_amount_days.setText(getString(R.string.danar_stats_amount_days));
|
||||||
|
label_cum_amount_days.setTextColor(Color.WHITE);
|
||||||
|
ctr_head.addView(label_cum_amount_days);
|
||||||
|
|
||||||
|
TextView label_cum_tdd = new TextView(this);
|
||||||
|
label_cum_tdd.setText(getString(R.string.danar_stats_tdd));
|
||||||
|
label_cum_tdd.setTextColor(Color.WHITE);
|
||||||
|
ctr_head.addView(label_cum_tdd);
|
||||||
|
|
||||||
|
TextView label_cum_ratio = new TextView(this);
|
||||||
|
label_cum_ratio.setText(getString(R.string.danar_stats_ratio));
|
||||||
|
label_cum_ratio.setTextColor(Color.WHITE);
|
||||||
|
ctr_head.addView(label_cum_ratio);
|
||||||
|
|
||||||
|
// add cummulative headers to tables
|
||||||
|
ctl.addView(ctr_head, new TableLayout.LayoutParams(
|
||||||
|
TableLayout.LayoutParams.FILL_PARENT,
|
||||||
|
TableLayout.LayoutParams.WRAP_CONTENT));
|
||||||
|
|
||||||
|
// expontial table
|
||||||
|
etl = (TableLayout) findViewById(R.id.expweight_table);
|
||||||
|
TableRow etr_head = new TableRow(this);
|
||||||
|
etr_head.setBackgroundColor(Color.DKGRAY);
|
||||||
|
etr_head.setLayoutParams(new TableLayout.LayoutParams(
|
||||||
|
TableLayout.LayoutParams.FILL_PARENT,
|
||||||
|
TableLayout.LayoutParams.WRAP_CONTENT));
|
||||||
|
|
||||||
|
TextView label_exp_weight = new TextView(this);
|
||||||
|
label_exp_weight.setText(getString(R.string.danar_stats_weight));
|
||||||
|
label_exp_weight.setTextColor(Color.WHITE);
|
||||||
|
etr_head.addView(label_exp_weight);
|
||||||
|
|
||||||
|
TextView label_exp_tdd = new TextView(this);
|
||||||
|
label_exp_tdd.setText(getString(R.string.danar_stats_tdd));
|
||||||
|
label_exp_tdd.setTextColor(Color.WHITE);
|
||||||
|
etr_head.addView(label_exp_tdd);
|
||||||
|
|
||||||
|
TextView label_exp_ratio = new TextView(this);
|
||||||
|
label_exp_ratio.setText(getString(R.string.danar_stats_ratio));
|
||||||
|
label_exp_ratio.setTextColor(Color.WHITE);
|
||||||
|
etr_head.addView(label_exp_ratio);
|
||||||
|
|
||||||
|
// add expontial headers to tables
|
||||||
|
etl.addView(etr_head, new TableLayout.LayoutParams(
|
||||||
|
TableLayout.LayoutParams.FILL_PARENT,
|
||||||
|
TableLayout.LayoutParams.WRAP_CONTENT));
|
||||||
|
|
||||||
|
reloadButton.setOnClickListener(new View.OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(View v) {
|
||||||
|
if (mExecutionService.isConnected() || mExecutionService.isConnecting()) {
|
||||||
|
ToastUtils.showToastInUiThread(MainApp.instance().getApplicationContext(), getString(R.string.pumpbusy));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
mHandler.post(new Runnable() {
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
runOnUiThread(new Runnable() {
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
reloadButton.setVisibility(View.GONE);
|
||||||
|
statusView.setVisibility(View.VISIBLE);
|
||||||
|
statsMessage.setVisibility(View.VISIBLE);
|
||||||
|
statsMessage.setText(getString(R.string.danar_stats_warning_Message));
|
||||||
|
}
|
||||||
|
});
|
||||||
|
mExecutionService.loadHistory(RecordTypes.RECORD_TYPE_DAILY);
|
||||||
|
loadDataFromDB(RecordTypes.RECORD_TYPE_DAILY);
|
||||||
|
runOnUiThread(new Runnable() {
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
reloadButton.setVisibility(View.VISIBLE);
|
||||||
|
statusView.setVisibility(View.GONE);
|
||||||
|
statsMessage.setVisibility(View.GONE);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
totalBaseBasal.setOnEditorActionListener(new TextView.OnEditorActionListener() {
|
||||||
|
@Override
|
||||||
|
public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
|
||||||
|
if(actionId== EditorInfo.IME_ACTION_DONE){
|
||||||
|
totalBaseBasal.clearFocus();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
totalBaseBasal.setOnFocusChangeListener(new View.OnFocusChangeListener() {
|
||||||
|
@Override
|
||||||
|
public void onFocusChange(View v, boolean hasFocus) {
|
||||||
|
if(hasFocus){
|
||||||
|
totalBaseBasal.getText().clear();
|
||||||
|
} else {
|
||||||
|
SharedPreferences.Editor edit = preferences.edit();
|
||||||
|
edit.putString("TBB",totalBaseBasal.getText().toString());
|
||||||
|
edit.commit();
|
||||||
|
TBB = preferences.getString("TBB", "");
|
||||||
|
loadDataFromDB(RecordTypes.RECORD_TYPE_DAILY);
|
||||||
|
InputMethodManager imm = (InputMethodManager) getSystemService(INPUT_METHOD_SERVICE);
|
||||||
|
imm.hideSoftInputFromWindow(totalBaseBasal.getWindowToken(), 0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
loadDataFromDB(RecordTypes.RECORD_TYPE_DAILY);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void loadDataFromDB(byte type) {
|
||||||
|
try {
|
||||||
|
Dao<DanaRHistoryRecord, String> dao = MainApp.getDbHelper().getDaoDanaRHistory();
|
||||||
|
QueryBuilder<DanaRHistoryRecord, String> queryBuilder = dao.queryBuilder();
|
||||||
|
queryBuilder.orderBy("recordDate", false);
|
||||||
|
Where where = queryBuilder.where();
|
||||||
|
where.eq("recordCode", type);
|
||||||
|
queryBuilder.limit(10L);
|
||||||
|
PreparedQuery<DanaRHistoryRecord> preparedQuery = queryBuilder.prepare();
|
||||||
|
historyList = dao.query(preparedQuery);
|
||||||
|
} catch (SQLException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
historyList = new ArrayList<>();
|
||||||
|
}
|
||||||
|
runOnUiThread(new Runnable() {
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
cleanTable(tl);
|
||||||
|
cleanTable(ctl);
|
||||||
|
cleanTable(etl);
|
||||||
|
DateFormat df = new SimpleDateFormat("dd.MM.");
|
||||||
|
|
||||||
|
if(TextUtils.isEmpty(TBB)) {
|
||||||
|
totalBaseBasal.setError("Please Enter Total Base Basal");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
magicNumber = Double.parseDouble(TBB);
|
||||||
|
}
|
||||||
|
|
||||||
|
magicNumber *=2;
|
||||||
|
totalBaseBasal2.setText(decimalFormat.format(magicNumber));
|
||||||
|
|
||||||
|
int i = 0;
|
||||||
|
double sum = 0d;
|
||||||
|
double weighted03 = 0d;
|
||||||
|
double weighted05 = 0d;
|
||||||
|
double weighted07 = 0d;
|
||||||
|
|
||||||
|
for (DanaRHistoryRecord record: historyList) {
|
||||||
|
double tdd= record.getRecordDailyBolus() + record.getRecordDailyBasal();
|
||||||
|
|
||||||
|
// Create the table row
|
||||||
|
TableRow tr = new TableRow(DanaRStatsActivity.this);
|
||||||
|
if(i%2!=0) tr.setBackgroundColor(Color.DKGRAY);
|
||||||
|
tr.setId(100+i);
|
||||||
|
tr.setLayoutParams(new TableLayout.LayoutParams(
|
||||||
|
TableLayout.LayoutParams.FILL_PARENT,
|
||||||
|
TableLayout.LayoutParams.WRAP_CONTENT));
|
||||||
|
|
||||||
|
// Here create the TextView dynamically
|
||||||
|
TextView labelDATE = new TextView(DanaRStatsActivity.this);
|
||||||
|
labelDATE.setId(200+i);
|
||||||
|
labelDATE.setText(df.format(new Date(record.getRecordDate())));
|
||||||
|
labelDATE.setTextColor(Color.WHITE);
|
||||||
|
tr.addView(labelDATE);
|
||||||
|
|
||||||
|
TextView labelBASAL = new TextView(DanaRStatsActivity.this);
|
||||||
|
labelBASAL.setId(300+i);
|
||||||
|
labelBASAL.setText(DecimalFormatter.to2Decimal(record.getRecordDailyBasal()) + " U");
|
||||||
|
labelBASAL.setTextColor(Color.WHITE);
|
||||||
|
tr.addView(labelBASAL);
|
||||||
|
|
||||||
|
TextView labelBOLUS = new TextView(DanaRStatsActivity.this);
|
||||||
|
labelBOLUS.setId(400+i);
|
||||||
|
labelBOLUS.setText(DecimalFormatter.to2Decimal(record.getRecordDailyBolus()) + " U");
|
||||||
|
labelBOLUS.setTextColor(Color.WHITE);
|
||||||
|
tr.addView(labelBOLUS);
|
||||||
|
|
||||||
|
TextView labelTDD = new TextView(DanaRStatsActivity.this);
|
||||||
|
labelTDD.setId(500+i);
|
||||||
|
labelTDD.setText(DecimalFormatter.to2Decimal(tdd) + " U");
|
||||||
|
labelTDD.setTextColor(Color.WHITE);
|
||||||
|
tr.addView(labelTDD);
|
||||||
|
|
||||||
|
TextView labelRATIO = new TextView(DanaRStatsActivity.this);
|
||||||
|
labelRATIO.setId(600+i);
|
||||||
|
labelRATIO.setText(Math.round(100*tdd/magicNumber) +" %");
|
||||||
|
labelRATIO.setTextColor(Color.WHITE);
|
||||||
|
tr.addView(labelRATIO);
|
||||||
|
|
||||||
|
// add stats rows to tables
|
||||||
|
tl.addView(tr, new TableLayout.LayoutParams(
|
||||||
|
TableLayout.LayoutParams.FILL_PARENT,
|
||||||
|
TableLayout.LayoutParams.WRAP_CONTENT));
|
||||||
|
|
||||||
|
sum = sum + tdd;
|
||||||
|
i++;
|
||||||
|
|
||||||
|
// Create the cumtable row
|
||||||
|
TableRow ctr = new TableRow(DanaRStatsActivity.this);
|
||||||
|
if(i%2==0) ctr.setBackgroundColor(Color.DKGRAY);
|
||||||
|
ctr.setId(700+i);
|
||||||
|
ctr.setLayoutParams(new TableLayout.LayoutParams(
|
||||||
|
TableLayout.LayoutParams.FILL_PARENT,
|
||||||
|
TableLayout.LayoutParams.WRAP_CONTENT));
|
||||||
|
|
||||||
|
// Here create the TextView dynamically
|
||||||
|
TextView labelDAYS = new TextView(DanaRStatsActivity.this);
|
||||||
|
labelDAYS.setId(800+i);
|
||||||
|
labelDAYS.setText("" + i);
|
||||||
|
labelDAYS.setTextColor(Color.WHITE);
|
||||||
|
ctr.addView(labelDAYS);
|
||||||
|
|
||||||
|
TextView labelCUMTDD = new TextView(DanaRStatsActivity.this);
|
||||||
|
labelCUMTDD.setId(900+i);
|
||||||
|
labelCUMTDD.setText(DecimalFormatter.to2Decimal(sum/i) + " U");
|
||||||
|
labelCUMTDD.setTextColor(Color.WHITE);
|
||||||
|
ctr.addView(labelCUMTDD);
|
||||||
|
|
||||||
|
TextView labelCUMRATIO = new TextView(DanaRStatsActivity.this);
|
||||||
|
labelCUMRATIO.setId(1000+i);
|
||||||
|
labelCUMRATIO.setText(Math.round(100*sum/i/magicNumber) + " %");
|
||||||
|
labelCUMRATIO.setTextColor(Color.WHITE);
|
||||||
|
ctr.addView(labelCUMRATIO);
|
||||||
|
|
||||||
|
// add cummulative rows to tables
|
||||||
|
ctl.addView(ctr, new TableLayout.LayoutParams(
|
||||||
|
TableLayout.LayoutParams.FILL_PARENT,
|
||||||
|
TableLayout.LayoutParams.WRAP_CONTENT));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (historyList.size()<3 || !(df.format(new Date(historyList.get(0).getRecordDate())).equals(df.format(new Date(System.currentTimeMillis() - 1000*60*60*24))))){
|
||||||
|
statsMessage.setVisibility(View.VISIBLE);
|
||||||
|
statsMessage.setText(getString(R.string.danar_stats_olddata_Message));
|
||||||
|
|
||||||
|
} else {
|
||||||
|
tl.setBackgroundColor(Color.TRANSPARENT);
|
||||||
|
}
|
||||||
|
|
||||||
|
Collections.reverse(historyList);
|
||||||
|
|
||||||
|
i = 0;
|
||||||
|
|
||||||
|
for (DanaRHistoryRecord record: historyList) {
|
||||||
|
double tdd= record.getRecordDailyBolus() + record.getRecordDailyBasal();
|
||||||
|
if(i == 0 ) {
|
||||||
|
weighted03 = tdd;
|
||||||
|
weighted05 = tdd;
|
||||||
|
weighted07 = tdd;
|
||||||
|
|
||||||
|
} else {
|
||||||
|
weighted07 = (weighted07*0.3 + tdd*0.7);
|
||||||
|
weighted05 = (weighted05*0.5 + tdd*0.5);
|
||||||
|
weighted03 = (weighted03*0.7 + tdd*0.3);
|
||||||
|
}
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Create the exptable row
|
||||||
|
TableRow etr = new TableRow(DanaRStatsActivity.this);
|
||||||
|
if(i%2!=0) etr.setBackgroundColor(Color.DKGRAY);
|
||||||
|
etr.setId(1100+i);
|
||||||
|
etr.setLayoutParams(new TableLayout.LayoutParams(
|
||||||
|
TableLayout.LayoutParams.FILL_PARENT,
|
||||||
|
TableLayout.LayoutParams.WRAP_CONTENT));
|
||||||
|
|
||||||
|
// Here create the TextView dynamically
|
||||||
|
TextView labelWEIGHT = new TextView(DanaRStatsActivity.this);
|
||||||
|
labelWEIGHT.setId(1200+i);
|
||||||
|
labelWEIGHT.setText("0.3\n" + "0.5\n" + "0.7");
|
||||||
|
labelWEIGHT.setTextColor(Color.WHITE);
|
||||||
|
etr.addView(labelWEIGHT);
|
||||||
|
|
||||||
|
TextView labelEXPTDD = new TextView(DanaRStatsActivity.this);
|
||||||
|
labelEXPTDD.setId(1300+i);
|
||||||
|
labelEXPTDD.setText(DecimalFormatter.to2Decimal(weighted03)
|
||||||
|
+ " U\n" + DecimalFormatter.to2Decimal(weighted05)
|
||||||
|
+ " U\n" + DecimalFormatter.to2Decimal(weighted07) + " U");
|
||||||
|
labelEXPTDD.setTextColor(Color.WHITE);
|
||||||
|
etr.addView(labelEXPTDD);
|
||||||
|
|
||||||
|
TextView labelEXPRATIO = new TextView(DanaRStatsActivity.this);
|
||||||
|
labelEXPRATIO.setId(1400+i);
|
||||||
|
labelEXPRATIO.setText(Math.round(100*weighted03/magicNumber) +" %\n"
|
||||||
|
+ Math.round(100*weighted05/magicNumber) +" %\n"
|
||||||
|
+ Math.round(100*weighted07/magicNumber) +" %");
|
||||||
|
labelEXPRATIO.setTextColor(Color.WHITE);
|
||||||
|
etr.addView(labelEXPRATIO);
|
||||||
|
|
||||||
|
// add exponentail rows to tables
|
||||||
|
etl.addView(etr, new TableLayout.LayoutParams(
|
||||||
|
TableLayout.LayoutParams.FILL_PARENT,
|
||||||
|
TableLayout.LayoutParams.WRAP_CONTENT));
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
private void cleanTable(TableLayout table) {
|
||||||
|
int childCount = table.getChildCount();
|
||||||
|
// Remove all rows except the first one
|
||||||
|
if (childCount > 1) {
|
||||||
|
table.removeViews(1, childCount - 1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Subscribe
|
||||||
|
public void onStatusEvent(final EventDanaRSyncStatus s) {
|
||||||
|
log.debug("EventDanaRSyncStatus: " + s.message);
|
||||||
|
runOnUiThread(
|
||||||
|
new Runnable() {
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
statusView.setText(s.message);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
@Subscribe
|
||||||
|
public void onStatusEvent(final EventDanaRConnectionStatus c) {
|
||||||
|
runOnUiThread(
|
||||||
|
new Runnable() {
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
if (c.sStatus == EventDanaRConnectionStatus.CONNECTING) {
|
||||||
|
statusView.setText(String.format(getString(R.string.danar_history_connectingfor), c.sSecondsElapsed));
|
||||||
|
log.debug("EventDanaRConnectionStatus: " + "Connecting for " + c.sSecondsElapsed + "s");
|
||||||
|
} else if (c.sStatus == EventDanaRConnectionStatus.CONNECTED) {
|
||||||
|
statusView.setText(MainApp.sResources.getString(R.string.connected));
|
||||||
|
log.debug("EventDanaRConnectionStatus: Connected");
|
||||||
|
} else {
|
||||||
|
statusView.setText(MainApp.sResources.getString(R.string.disconnected));
|
||||||
|
log.debug("EventDanaRConnectionStatus: Disconnected");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
|
@ -76,7 +76,7 @@ public class Autosens {
|
||||||
double[] bgis = new double[bucketed_data.size() - 2];
|
double[] bgis = new double[bucketed_data.size() - 2];
|
||||||
double[] deviations = new double[bucketed_data.size() - 2];
|
double[] deviations = new double[bucketed_data.size() - 2];
|
||||||
|
|
||||||
String debugString = "";
|
String pastSensitivity = "";
|
||||||
for (int i = 0; i < bucketed_data.size() - 3; ++i) {
|
for (int i = 0; i < bucketed_data.size() - 3; ++i) {
|
||||||
long bgTime = bucketed_data.get(i).timeIndex;
|
long bgTime = bucketed_data.get(i).timeIndex;
|
||||||
int secondsFromMidnight = NSProfile.secondsFromMidnight(new Date(bgTime));
|
int secondsFromMidnight = NSProfile.secondsFromMidnight(new Date(bgTime));
|
||||||
|
@ -108,20 +108,21 @@ public class Autosens {
|
||||||
// Exclude large positive deviations (carb absorption) from autosens
|
// Exclude large positive deviations (carb absorption) from autosens
|
||||||
if (avgDelta - bgi < 6) {
|
if (avgDelta - bgi < 6) {
|
||||||
if (deviation > 0) {
|
if (deviation > 0) {
|
||||||
debugString += "+";
|
pastSensitivity += "+";
|
||||||
} else if (deviation == 0) {
|
} else if (deviation == 0) {
|
||||||
debugString += "=";
|
pastSensitivity += "=";
|
||||||
} else {
|
} else {
|
||||||
debugString += "-";
|
pastSensitivity += "-";
|
||||||
}
|
}
|
||||||
avgDeltas[i] = avgDelta;
|
avgDeltas[i] = avgDelta;
|
||||||
bgis[i] = bgi;
|
bgis[i] = bgi;
|
||||||
deviations[i] = deviation;
|
deviations[i] = deviation;
|
||||||
deviationSum += deviation;
|
deviationSum += deviation;
|
||||||
} else {
|
} else {
|
||||||
debugString += ">";
|
pastSensitivity += ">";
|
||||||
//console.error(bgTime);
|
//console.error(bgTime);
|
||||||
}
|
}
|
||||||
|
//log.debug("TIME: " + new Date(bgTime).toString() + " BG: " + bg + " SENS: " + sens + " DELTA: " + delta + " AVGDELTA: " + avgDelta + " IOB: " + iob.iob + " ACTIVITY: " + iob.activity + " BGI: " + bgi + " DEVIATION: " + deviation);
|
||||||
|
|
||||||
// if bgTime is more recent than mealTime
|
// if bgTime is more recent than mealTime
|
||||||
if (bgTime > mealTime) {
|
if (bgTime > mealTime) {
|
||||||
|
@ -134,7 +135,7 @@ public class Autosens {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//console.error("");
|
//console.error("");
|
||||||
log.debug(debugString);
|
log.debug(pastSensitivity);
|
||||||
//console.log(JSON.stringify(avgDeltas));
|
//console.log(JSON.stringify(avgDeltas));
|
||||||
//console.log(JSON.stringify(bgis));
|
//console.log(JSON.stringify(bgis));
|
||||||
Arrays.sort(avgDeltas);
|
Arrays.sort(avgDeltas);
|
||||||
|
@ -157,15 +158,17 @@ public class Autosens {
|
||||||
//console.error("Mean deviation: "+average.toFixed(2));
|
//console.error("Mean deviation: "+average.toFixed(2));
|
||||||
double basalOff = 0;
|
double basalOff = 0;
|
||||||
|
|
||||||
|
String sensResult = "";
|
||||||
if (pSensitive < 0) { // sensitive
|
if (pSensitive < 0) { // sensitive
|
||||||
basalOff = pSensitive * (60 / 5) / NSProfile.toMgdl(profile.getIsf(NSProfile.secondsFromMidnight()), profile.getUnits());
|
basalOff = pSensitive * (60 / 5) / NSProfile.toMgdl(profile.getIsf(NSProfile.secondsFromMidnight()), profile.getUnits());
|
||||||
log.debug("Excess insulin sensitivity detected: ");
|
sensResult = "Excess insulin sensitivity detected";
|
||||||
} else if (pResistant > 0) { // resistant
|
} else if (pResistant > 0) { // resistant
|
||||||
basalOff = pResistant * (60 / 5) / NSProfile.toMgdl(profile.getIsf(NSProfile.secondsFromMidnight()), profile.getUnits());
|
basalOff = pResistant * (60 / 5) / NSProfile.toMgdl(profile.getIsf(NSProfile.secondsFromMidnight()), profile.getUnits());
|
||||||
log.debug("Excess insulin resistance detected: ");
|
sensResult = "Excess insulin resistance detected";
|
||||||
} else {
|
} else {
|
||||||
log.debug("Sensitivity normal.");
|
sensResult = "Sensitivity normal";
|
||||||
}
|
}
|
||||||
|
log.debug(sensResult);
|
||||||
double ratio = 1 + (basalOff / profile.getMaxDailyBasal());
|
double ratio = 1 + (basalOff / profile.getMaxDailyBasal());
|
||||||
|
|
||||||
// don't adjust more than 1.5x
|
// don't adjust more than 1.5x
|
||||||
|
@ -173,8 +176,10 @@ public class Autosens {
|
||||||
ratio = Math.max(ratio, Constants.AUTOSENS_MIN);
|
ratio = Math.max(ratio, Constants.AUTOSENS_MIN);
|
||||||
ratio = Math.min(ratio, Constants.AUTOSENS_MAX);
|
ratio = Math.min(ratio, Constants.AUTOSENS_MAX);
|
||||||
|
|
||||||
|
String ratioLimit = "";
|
||||||
if (ratio != rawRatio) {
|
if (ratio != rawRatio) {
|
||||||
log.debug("Ratio limited from " + rawRatio + " to " + ratio);
|
ratioLimit = "Ratio limited from " + rawRatio + " to " + ratio;
|
||||||
|
log.debug(ratioLimit);
|
||||||
}
|
}
|
||||||
|
|
||||||
double newisf = Math.round(NSProfile.toMgdl(profile.getIsf(NSProfile.secondsFromMidnight()), profile.getUnits()) / ratio);
|
double newisf = Math.round(NSProfile.toMgdl(profile.getIsf(NSProfile.secondsFromMidnight()), profile.getUnits()) / ratio);
|
||||||
|
@ -187,6 +192,9 @@ public class Autosens {
|
||||||
AutosensResult output = new AutosensResult();
|
AutosensResult output = new AutosensResult();
|
||||||
output.ratio = Round.roundTo(ratio, 0.01);
|
output.ratio = Round.roundTo(ratio, 0.01);
|
||||||
output.carbsAbsorbed = Round.roundTo(carbsAbsorbed, 0.01);
|
output.carbsAbsorbed = Round.roundTo(carbsAbsorbed, 0.01);
|
||||||
|
output.pastSensitivity = pastSensitivity;
|
||||||
|
output.ratioLimit = ratioLimit;
|
||||||
|
output.sensResult = sensResult;
|
||||||
return output;
|
return output;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,9 +1,30 @@
|
||||||
package info.nightscout.androidaps.plugins.OpenAPSAMA;
|
package info.nightscout.androidaps.plugins.OpenAPSAMA;
|
||||||
|
|
||||||
|
import org.json.JSONException;
|
||||||
|
import org.json.JSONObject;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by mike on 06.01.2017.
|
* Created by mike on 06.01.2017.
|
||||||
*/
|
*/
|
||||||
public class AutosensResult {
|
public class AutosensResult {
|
||||||
public double ratio;
|
public double ratio;
|
||||||
public double carbsAbsorbed;
|
public double carbsAbsorbed;
|
||||||
|
public String sensResult;
|
||||||
|
public String pastSensitivity;
|
||||||
|
public String ratioLimit;
|
||||||
|
|
||||||
|
public JSONObject json() {
|
||||||
|
JSONObject ret = new JSONObject();
|
||||||
|
try {
|
||||||
|
ret.put("ratio", ratio);
|
||||||
|
ret.put("ratioLimit", ratioLimit);
|
||||||
|
ret.put("pastSensitivity", pastSensitivity);
|
||||||
|
ret.put("sensResult", sensResult);
|
||||||
|
ret.put("ratio", ratio);
|
||||||
|
} catch (JSONException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -125,12 +125,14 @@ public class OpenAPSAMAFragment extends Fragment implements View.OnClickListener
|
||||||
}
|
}
|
||||||
profileView.setText(JSONFormatter.format(determineBasalAdapterAMAJS.getProfileParam()));
|
profileView.setText(JSONFormatter.format(determineBasalAdapterAMAJS.getProfileParam()));
|
||||||
mealDataView.setText(JSONFormatter.format(determineBasalAdapterAMAJS.getMealDataParam()));
|
mealDataView.setText(JSONFormatter.format(determineBasalAdapterAMAJS.getMealDataParam()));
|
||||||
autosensDataView.setText(JSONFormatter.format(determineBasalAdapterAMAJS.getAutosensDataParam()));
|
|
||||||
scriptdebugView.setText(determineBasalAdapterAMAJS.getScriptDebug());
|
scriptdebugView.setText(determineBasalAdapterAMAJS.getScriptDebug());
|
||||||
}
|
}
|
||||||
if (getPlugin().lastAPSRun != null) {
|
if (getPlugin().lastAPSRun != null) {
|
||||||
lastRunView.setText(getPlugin().lastAPSRun.toLocaleString());
|
lastRunView.setText(getPlugin().lastAPSRun.toLocaleString());
|
||||||
}
|
}
|
||||||
|
if (getPlugin().lastAutosensResult != null) {
|
||||||
|
autosensDataView.setText(JSONFormatter.format(getPlugin().lastAutosensResult.json()));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -45,6 +45,7 @@ public class OpenAPSAMAPlugin implements PluginBase, APSInterface {
|
||||||
DetermineBasalAdapterAMAJS lastDetermineBasalAdapterAMAJS = null;
|
DetermineBasalAdapterAMAJS lastDetermineBasalAdapterAMAJS = null;
|
||||||
Date lastAPSRun = null;
|
Date lastAPSRun = null;
|
||||||
DetermineBasalResultAMA lastAPSResult = null;
|
DetermineBasalResultAMA lastAPSResult = null;
|
||||||
|
AutosensResult lastAutosensResult = null;
|
||||||
|
|
||||||
boolean fragmentEnabled = false;
|
boolean fragmentEnabled = false;
|
||||||
boolean fragmentVisible = true;
|
boolean fragmentVisible = true;
|
||||||
|
@ -146,13 +147,13 @@ public class OpenAPSAMAPlugin implements PluginBase, APSInterface {
|
||||||
SharedPreferences SP = PreferenceManager.getDefaultSharedPreferences(MainApp.instance().getApplicationContext());
|
SharedPreferences SP = PreferenceManager.getDefaultSharedPreferences(MainApp.instance().getApplicationContext());
|
||||||
String units = profile.getUnits();
|
String units = profile.getUnits();
|
||||||
|
|
||||||
String maxBgDefault = "180";
|
String maxBgDefault = Constants.MAX_BG_DEFAULT_MGDL;
|
||||||
String minBgDefault = "100";
|
String minBgDefault = Constants.MIN_BG_DEFAULT_MGDL;
|
||||||
String targetBgDefault = "150";
|
String targetBgDefault = Constants.TARGET_BG_DEFAULT_MGDL;
|
||||||
if (!units.equals(Constants.MGDL)) {
|
if (!units.equals(Constants.MGDL)) {
|
||||||
maxBgDefault = "10";
|
maxBgDefault = Constants.MAX_BG_DEFAULT_MMOL;
|
||||||
minBgDefault = "5";
|
minBgDefault = Constants.MIN_BG_DEFAULT_MMOL;
|
||||||
targetBgDefault = "7";
|
targetBgDefault = Constants.TARGET_BG_DEFAULT_MMOL;
|
||||||
}
|
}
|
||||||
|
|
||||||
Date now = new Date();
|
Date now = new Date();
|
||||||
|
@ -172,9 +173,9 @@ public class OpenAPSAMAPlugin implements PluginBase, APSInterface {
|
||||||
|
|
||||||
maxIob = MainApp.getConfigBuilder().applyMaxIOBConstraints(maxIob);
|
maxIob = MainApp.getConfigBuilder().applyMaxIOBConstraints(maxIob);
|
||||||
|
|
||||||
minBg = verifyHardLimits(minBg, "minBg", 72, 180);
|
minBg = verifyHardLimits(minBg, "minBg", Constants.VERY_HARD_LIMIT_MIN_BG[0], Constants.VERY_HARD_LIMIT_MIN_BG[1]);
|
||||||
maxBg = verifyHardLimits(maxBg, "maxBg", 100, 270);
|
maxBg = verifyHardLimits(maxBg, "maxBg", Constants.VERY_HARD_LIMIT_MAX_BG[0], Constants.VERY_HARD_LIMIT_MAX_BG[1]);
|
||||||
targetBg = verifyHardLimits(targetBg, "targetBg", 80, 200);
|
targetBg = verifyHardLimits(targetBg, "targetBg", Constants.VERY_HARD_LIMIT_TARGET_BG[0], Constants.VERY_HARD_LIMIT_TARGET_BG[1]);
|
||||||
|
|
||||||
boolean isTempTarget = false;
|
boolean isTempTarget = false;
|
||||||
TempTargetRangePlugin tempTargetRangePlugin = (TempTargetRangePlugin) MainApp.getSpecificPlugin(TempTargetRangePlugin.class);
|
TempTargetRangePlugin tempTargetRangePlugin = (TempTargetRangePlugin) MainApp.getSpecificPlugin(TempTargetRangePlugin.class);
|
||||||
|
@ -182,9 +183,9 @@ public class OpenAPSAMAPlugin implements PluginBase, APSInterface {
|
||||||
TempTarget tempTarget = tempTargetRangePlugin.getTempTargetInProgress(new Date().getTime());
|
TempTarget tempTarget = tempTargetRangePlugin.getTempTargetInProgress(new Date().getTime());
|
||||||
if (tempTarget != null) {
|
if (tempTarget != null) {
|
||||||
isTempTarget = true;
|
isTempTarget = true;
|
||||||
minBg = verifyHardLimits(tempTarget.low, "minBg", 72, 180);
|
minBg = verifyHardLimits(tempTarget.low, "minBg", Constants.VERY_HARD_LIMIT_TEMP_MIN_BG[0], Constants.VERY_HARD_LIMIT_TEMP_MIN_BG[1]);
|
||||||
maxBg = verifyHardLimits(tempTarget.high, "maxBg", 72, 270);
|
maxBg = verifyHardLimits(tempTarget.high, "maxBg", Constants.VERY_HARD_LIMIT_TEMP_MAX_BG[0], Constants.VERY_HARD_LIMIT_TEMP_MAX_BG[1]);
|
||||||
targetBg = verifyHardLimits((tempTarget.low + tempTarget.high) / 2, "targetBg", 72, 200);
|
targetBg = verifyHardLimits((tempTarget.low + tempTarget.high) / 2, "targetBg", Constants.VERY_HARD_LIMIT_TEMP_TARGET_BG[0], Constants.VERY_HARD_LIMIT_TEMP_TARGET_BG[1]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -202,10 +203,10 @@ public class OpenAPSAMAPlugin implements PluginBase, APSInterface {
|
||||||
long oldestDataAvailable = MainApp.getConfigBuilder().getActiveTempBasals().oldestDataAvaialable();
|
long oldestDataAvailable = MainApp.getConfigBuilder().getActiveTempBasals().oldestDataAvaialable();
|
||||||
List<BgReading> bgReadings = MainApp.getDbHelper().getBgreadingsDataFromTime(Math.max(oldestDataAvailable, (long) (new Date().getTime() - 60 * 60 * 1000L * (24 + profile.getDia()))), false);
|
List<BgReading> bgReadings = MainApp.getDbHelper().getBgreadingsDataFromTime(Math.max(oldestDataAvailable, (long) (new Date().getTime() - 60 * 60 * 1000L * (24 + profile.getDia()))), false);
|
||||||
log.debug("Limiting data to oldest available temps: " + new Date(oldestDataAvailable).toString() + " (" + bgReadings.size() + " records)");
|
log.debug("Limiting data to oldest available temps: " + new Date(oldestDataAvailable).toString() + " (" + bgReadings.size() + " records)");
|
||||||
AutosensResult autosensResult = Autosens.detectSensitivityandCarbAbsorption(bgReadings, new Date().getTime());
|
lastAutosensResult = Autosens.detectSensitivityandCarbAbsorption(bgReadings, new Date().getTime());
|
||||||
|
|
||||||
determineBasalAdapterAMAJS.setData(profile, maxIob, maxBasal, minBg, maxBg, targetBg, pump, iobArray, glucoseStatus, mealData,
|
determineBasalAdapterAMAJS.setData(profile, maxIob, maxBasal, minBg, maxBg, targetBg, pump, iobArray, glucoseStatus, mealData,
|
||||||
autosensResult.ratio, //autosensDataRatio
|
lastAutosensResult.ratio, //autosensDataRatio
|
||||||
isTempTarget,
|
isTempTarget,
|
||||||
Constants.MIN_5M_CARBIMPACT //min_5m_carbimpact
|
Constants.MIN_5M_CARBIMPACT //min_5m_carbimpact
|
||||||
);
|
);
|
||||||
|
@ -247,15 +248,18 @@ public class OpenAPSAMAPlugin implements PluginBase, APSInterface {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Double verifyHardLimits(Double value, String valueName, double lowLimit, double highLimit) {
|
public static Double verifyHardLimits(Double value, String valueName, double lowLimit, double highLimit) {
|
||||||
if (value < lowLimit || value > highLimit) {
|
Double newvalue = value;
|
||||||
|
if (newvalue < lowLimit || newvalue > highLimit) {
|
||||||
|
newvalue = Math.max(newvalue, lowLimit);
|
||||||
|
newvalue = Math.min(newvalue, highLimit);
|
||||||
String msg = String.format(MainApp.sResources.getString(R.string.openapsma_valueoutofrange), valueName);
|
String msg = String.format(MainApp.sResources.getString(R.string.openapsma_valueoutofrange), valueName);
|
||||||
|
msg += ".\n";
|
||||||
|
msg += String.format(MainApp.sResources.getString(R.string.openapsma_valuelimitedto), value, newvalue);
|
||||||
log.error(msg);
|
log.error(msg);
|
||||||
MainApp.getConfigBuilder().uploadError(msg);
|
MainApp.getConfigBuilder().uploadError(msg);
|
||||||
ToastUtils.showToastInUiThread(MainApp.instance().getApplicationContext(), msg, R.raw.error);
|
ToastUtils.showToastInUiThread(MainApp.instance().getApplicationContext(), msg, R.raw.error);
|
||||||
value = Math.max(value, lowLimit);
|
|
||||||
value = Math.min(value, highLimit);
|
|
||||||
}
|
}
|
||||||
return value;
|
return newvalue;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -34,6 +34,9 @@ import info.nightscout.utils.Round;
|
||||||
import info.nightscout.utils.SafeParse;
|
import info.nightscout.utils.SafeParse;
|
||||||
import info.nightscout.utils.ToastUtils;
|
import info.nightscout.utils.ToastUtils;
|
||||||
|
|
||||||
|
import static info.nightscout.androidaps.plugins.OpenAPSAMA.OpenAPSAMAPlugin.checkOnlyHardLimits;
|
||||||
|
import static info.nightscout.androidaps.plugins.OpenAPSAMA.OpenAPSAMAPlugin.verifyHardLimits;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by mike on 05.08.2016.
|
* Created by mike on 05.08.2016.
|
||||||
*/
|
*/
|
||||||
|
@ -145,13 +148,13 @@ public class OpenAPSMAPlugin implements PluginBase, APSInterface {
|
||||||
SharedPreferences SP = PreferenceManager.getDefaultSharedPreferences(MainApp.instance().getApplicationContext());
|
SharedPreferences SP = PreferenceManager.getDefaultSharedPreferences(MainApp.instance().getApplicationContext());
|
||||||
String units = profile.getUnits();
|
String units = profile.getUnits();
|
||||||
|
|
||||||
String maxBgDefault = "180";
|
String maxBgDefault = Constants.MAX_BG_DEFAULT_MGDL;
|
||||||
String minBgDefault = "100";
|
String minBgDefault = Constants.MIN_BG_DEFAULT_MGDL;
|
||||||
String targetBgDefault = "150";
|
String targetBgDefault = Constants.TARGET_BG_DEFAULT_MGDL;
|
||||||
if (!units.equals(Constants.MGDL)) {
|
if (!units.equals(Constants.MGDL)) {
|
||||||
maxBgDefault = "10";
|
maxBgDefault = Constants.MAX_BG_DEFAULT_MMOL;
|
||||||
minBgDefault = "5";
|
minBgDefault = Constants.MIN_BG_DEFAULT_MMOL;
|
||||||
targetBgDefault = "7";
|
targetBgDefault = Constants.TARGET_BG_DEFAULT_MMOL;
|
||||||
}
|
}
|
||||||
|
|
||||||
Date now = new Date();
|
Date now = new Date();
|
||||||
|
@ -178,17 +181,17 @@ public class OpenAPSMAPlugin implements PluginBase, APSInterface {
|
||||||
|
|
||||||
maxIob = MainApp.getConfigBuilder().applyMaxIOBConstraints(maxIob);
|
maxIob = MainApp.getConfigBuilder().applyMaxIOBConstraints(maxIob);
|
||||||
|
|
||||||
minBg = verifyHardLimits(minBg, "minBg", 72, 180);
|
minBg = verifyHardLimits(minBg, "minBg", Constants.VERY_HARD_LIMIT_MIN_BG[0], Constants.VERY_HARD_LIMIT_MIN_BG[1]);
|
||||||
maxBg = verifyHardLimits(maxBg, "maxBg", 100, 270);
|
maxBg = verifyHardLimits(maxBg, "maxBg", Constants.VERY_HARD_LIMIT_MAX_BG[0], Constants.VERY_HARD_LIMIT_MAX_BG[1]);
|
||||||
targetBg = verifyHardLimits(targetBg, "targetBg", 80, 200);
|
targetBg = verifyHardLimits(targetBg, "targetBg", Constants.VERY_HARD_LIMIT_TARGET_BG[0], Constants.VERY_HARD_LIMIT_TARGET_BG[1]);
|
||||||
|
|
||||||
TempTargetRangePlugin tempTargetRangePlugin = (TempTargetRangePlugin) MainApp.getSpecificPlugin(TempTargetRangePlugin.class);
|
TempTargetRangePlugin tempTargetRangePlugin = (TempTargetRangePlugin) MainApp.getSpecificPlugin(TempTargetRangePlugin.class);
|
||||||
if (tempTargetRangePlugin != null && tempTargetRangePlugin.isEnabled(PluginBase.GENERAL)) {
|
if (tempTargetRangePlugin != null && tempTargetRangePlugin.isEnabled(PluginBase.GENERAL)) {
|
||||||
TempTarget tempTarget = tempTargetRangePlugin.getTempTargetInProgress(new Date().getTime());
|
TempTarget tempTarget = tempTargetRangePlugin.getTempTargetInProgress(new Date().getTime());
|
||||||
if (tempTarget != null) {
|
if (tempTarget != null) {
|
||||||
minBg = verifyHardLimits(tempTarget.low, "minBg", 72, 180);
|
minBg = verifyHardLimits(tempTarget.low, "minBg", Constants.VERY_HARD_LIMIT_TEMP_MIN_BG[0], Constants.VERY_HARD_LIMIT_TEMP_MIN_BG[1]);
|
||||||
maxBg = verifyHardLimits(tempTarget.high, "maxBg", 72, 270);
|
maxBg = verifyHardLimits(tempTarget.high, "maxBg", Constants.VERY_HARD_LIMIT_TEMP_MAX_BG[0], Constants.VERY_HARD_LIMIT_TEMP_MAX_BG[1]);
|
||||||
targetBg = verifyHardLimits((tempTarget.low + tempTarget.high) / 2, "targetBg", 72, 200);
|
targetBg = verifyHardLimits((tempTarget.low + tempTarget.high) / 2, "targetBg", Constants.VERY_HARD_LIMIT_TEMP_TARGET_BG[0], Constants.VERY_HARD_LIMIT_TEMP_TARGET_BG[1]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -235,21 +238,5 @@ public class OpenAPSMAPlugin implements PluginBase, APSInterface {
|
||||||
//deviceStatus.suggested = determineBasalResultMA.json;
|
//deviceStatus.suggested = determineBasalResultMA.json;
|
||||||
}
|
}
|
||||||
|
|
||||||
// safety checks
|
|
||||||
public static boolean checkOnlyHardLimits(Double value, String valueName, double lowLimit, double highLimit) {
|
|
||||||
return value.equals(verifyHardLimits(value, valueName, lowLimit, highLimit));
|
|
||||||
}
|
|
||||||
|
|
||||||
public static Double verifyHardLimits(Double value, String valueName, double lowLimit, double highLimit) {
|
|
||||||
if (value < lowLimit || value > highLimit) {
|
|
||||||
String msg = String.format(MainApp.sResources.getString(R.string.openapsma_valueoutofrange), valueName);
|
|
||||||
log.error(msg);
|
|
||||||
MainApp.getConfigBuilder().uploadError(msg);
|
|
||||||
ToastUtils.showToastInUiThread(MainApp.instance().getApplicationContext(), msg, R.raw.error);
|
|
||||||
value = Math.max(value, lowLimit);
|
|
||||||
value = Math.min(value, highLimit);
|
|
||||||
}
|
|
||||||
return value;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -83,6 +83,7 @@ import info.nightscout.androidaps.plugins.Overview.graphExtensions.PointsWithLab
|
||||||
import info.nightscout.androidaps.plugins.Overview.graphExtensions.TimeAsXAxisLabelFormatter;
|
import info.nightscout.androidaps.plugins.Overview.graphExtensions.TimeAsXAxisLabelFormatter;
|
||||||
import info.nightscout.androidaps.plugins.TempBasals.TempBasalsPlugin;
|
import info.nightscout.androidaps.plugins.TempBasals.TempBasalsPlugin;
|
||||||
import info.nightscout.androidaps.plugins.TempTargetRange.TempTargetRangePlugin;
|
import info.nightscout.androidaps.plugins.TempTargetRange.TempTargetRangePlugin;
|
||||||
|
import info.nightscout.androidaps.plugins.TempTargetRange.events.EventTempTargetRangeChange;
|
||||||
import info.nightscout.client.data.NSProfile;
|
import info.nightscout.client.data.NSProfile;
|
||||||
import info.nightscout.utils.BolusWizard;
|
import info.nightscout.utils.BolusWizard;
|
||||||
import info.nightscout.utils.DateUtil;
|
import info.nightscout.utils.DateUtil;
|
||||||
|
@ -113,6 +114,7 @@ public class OverviewFragment extends Fragment {
|
||||||
TextView iobView;
|
TextView iobView;
|
||||||
TextView apsModeView;
|
TextView apsModeView;
|
||||||
TextView tempTargetView;
|
TextView tempTargetView;
|
||||||
|
TextView initializingView;
|
||||||
GraphView bgGraph;
|
GraphView bgGraph;
|
||||||
CheckBox showPredictionView;
|
CheckBox showPredictionView;
|
||||||
|
|
||||||
|
@ -121,7 +123,6 @@ public class OverviewFragment extends Fragment {
|
||||||
|
|
||||||
LinearLayout cancelTempLayout;
|
LinearLayout cancelTempLayout;
|
||||||
LinearLayout acceptTempLayout;
|
LinearLayout acceptTempLayout;
|
||||||
LinearLayout quickWizardLayout;
|
|
||||||
Button cancelTempButton;
|
Button cancelTempButton;
|
||||||
Button treatmentButton;
|
Button treatmentButton;
|
||||||
Button wizardButton;
|
Button wizardButton;
|
||||||
|
@ -158,6 +159,7 @@ public class OverviewFragment extends Fragment {
|
||||||
baseBasalView = (TextView) view.findViewById(R.id.overview_basebasal);
|
baseBasalView = (TextView) view.findViewById(R.id.overview_basebasal);
|
||||||
basalLayout = (LinearLayout) view.findViewById(R.id.overview_basallayout);
|
basalLayout = (LinearLayout) view.findViewById(R.id.overview_basallayout);
|
||||||
activeProfileView = (TextView) view.findViewById(R.id.overview_activeprofile);
|
activeProfileView = (TextView) view.findViewById(R.id.overview_activeprofile);
|
||||||
|
initializingView = (TextView) view.findViewById(R.id.overview_initializing);
|
||||||
|
|
||||||
iobView = (TextView) view.findViewById(R.id.overview_iob);
|
iobView = (TextView) view.findViewById(R.id.overview_iob);
|
||||||
apsModeView = (TextView) view.findViewById(R.id.overview_apsmode);
|
apsModeView = (TextView) view.findViewById(R.id.overview_apsmode);
|
||||||
|
@ -171,7 +173,6 @@ public class OverviewFragment extends Fragment {
|
||||||
acceptTempButton = (Button) view.findViewById(R.id.overview_accepttempbutton);
|
acceptTempButton = (Button) view.findViewById(R.id.overview_accepttempbutton);
|
||||||
acceptTempLayout = (LinearLayout) view.findViewById(R.id.overview_accepttemplayout);
|
acceptTempLayout = (LinearLayout) view.findViewById(R.id.overview_accepttemplayout);
|
||||||
quickWizardButton = (Button) view.findViewById(R.id.overview_quickwizard);
|
quickWizardButton = (Button) view.findViewById(R.id.overview_quickwizard);
|
||||||
quickWizardLayout = (LinearLayout) view.findViewById(R.id.overview_quickwizardlayout);
|
|
||||||
showPredictionView = (CheckBox) view.findViewById(R.id.overview_showprediction);
|
showPredictionView = (CheckBox) view.findViewById(R.id.overview_showprediction);
|
||||||
|
|
||||||
notificationsView = (RecyclerView) view.findViewById(R.id.overview_notifications);
|
notificationsView = (RecyclerView) view.findViewById(R.id.overview_notifications);
|
||||||
|
@ -285,7 +286,7 @@ public class OverviewFragment extends Fragment {
|
||||||
|
|
||||||
QuickWizard.QuickWizardEntry quickWizardEntry = getPlugin().quickWizard.getActive();
|
QuickWizard.QuickWizardEntry quickWizardEntry = getPlugin().quickWizard.getActive();
|
||||||
if (quickWizardEntry != null && lastBG != null) {
|
if (quickWizardEntry != null && lastBG != null) {
|
||||||
quickWizardLayout.setVisibility(View.VISIBLE);
|
quickWizardButton.setVisibility(View.VISIBLE);
|
||||||
String text = MainApp.sResources.getString(R.string.bolus) + ": " + quickWizardEntry.buttonText();
|
String text = MainApp.sResources.getString(R.string.bolus) + ": " + quickWizardEntry.buttonText();
|
||||||
BolusWizard wizard = new BolusWizard();
|
BolusWizard wizard = new BolusWizard();
|
||||||
wizard.doCalc(profile.getDefaultProfile(), quickWizardEntry.carbs(), lastBG.valueToUnits(profile.getUnits()), 0d, true, true);
|
wizard.doCalc(profile.getDefaultProfile(), quickWizardEntry.carbs(), lastBG.valueToUnits(profile.getUnits()), 0d, true, true);
|
||||||
|
@ -431,6 +432,9 @@ public class OverviewFragment extends Fragment {
|
||||||
@Subscribe
|
@Subscribe
|
||||||
public void onStatusEvent(final EventNewBasalProfile ev) { updateGUIIfVisible(); }
|
public void onStatusEvent(final EventNewBasalProfile ev) { updateGUIIfVisible(); }
|
||||||
|
|
||||||
|
@Subscribe
|
||||||
|
public void onStatusEvent(final EventTempTargetRangeChange ev) {updateGUIIfVisible();}
|
||||||
|
|
||||||
@Subscribe
|
@Subscribe
|
||||||
public void onStatusEvent(final EventNewNotification n) { updateNotifications(); }
|
public void onStatusEvent(final EventNewNotification n) { updateNotifications(); }
|
||||||
|
|
||||||
|
@ -464,8 +468,14 @@ public class OverviewFragment extends Fragment {
|
||||||
updateNotifications();
|
updateNotifications();
|
||||||
BgReading actualBG = MainApp.getDbHelper().actualBg();
|
BgReading actualBG = MainApp.getDbHelper().actualBg();
|
||||||
BgReading lastBG = MainApp.getDbHelper().lastBg();
|
BgReading lastBG = MainApp.getDbHelper().lastBg();
|
||||||
if (MainApp.getConfigBuilder() == null || MainApp.getConfigBuilder().getActiveProfile() == null || MainApp.getConfigBuilder().getActiveProfile().getProfile() == null) // app not initialized yet
|
|
||||||
|
if (MainApp.getConfigBuilder() == null || MainApp.getConfigBuilder().getActiveProfile() == null || MainApp.getConfigBuilder().getActiveProfile().getProfile() == null) {// app not initialized yet
|
||||||
|
initializingView.setText(R.string.noprofileset);
|
||||||
|
initializingView.setVisibility(View.VISIBLE);
|
||||||
return;
|
return;
|
||||||
|
} else {
|
||||||
|
initializingView.setVisibility(View.GONE);
|
||||||
|
}
|
||||||
|
|
||||||
// Skip if not initialized yet
|
// Skip if not initialized yet
|
||||||
if (bgGraph == null)
|
if (bgGraph == null)
|
||||||
|
@ -526,11 +536,25 @@ public class OverviewFragment extends Fragment {
|
||||||
if (tempTargetRangePlugin != null && tempTargetRangePlugin.isEnabled(PluginBase.GENERAL)) {
|
if (tempTargetRangePlugin != null && tempTargetRangePlugin.isEnabled(PluginBase.GENERAL)) {
|
||||||
TempTarget tempTarget = tempTargetRangePlugin.getTempTargetInProgress(new Date().getTime());
|
TempTarget tempTarget = tempTargetRangePlugin.getTempTargetInProgress(new Date().getTime());
|
||||||
if (tempTarget != null) {
|
if (tempTarget != null) {
|
||||||
|
tempTargetView.setTextColor(Color.BLACK);
|
||||||
|
tempTargetView.setBackgroundResource(R.drawable.temptargetborder);
|
||||||
tempTargetView.setVisibility(View.VISIBLE);
|
tempTargetView.setVisibility(View.VISIBLE);
|
||||||
tempTargetView.setText(NSProfile.toUnitsString(tempTarget.low, NSProfile.fromMgdlToUnits(tempTarget.low, profile.getUnits()), profile.getUnits()) + " - " + NSProfile.toUnitsString(tempTarget.high, NSProfile.fromMgdlToUnits(tempTarget.high, profile.getUnits()), profile.getUnits()));
|
tempTargetView.setText(NSProfile.toUnitsString(tempTarget.low, NSProfile.fromMgdlToUnits(tempTarget.low, profile.getUnits()), profile.getUnits()) + " - " + NSProfile.toUnitsString(tempTarget.high, NSProfile.fromMgdlToUnits(tempTarget.high, profile.getUnits()), profile.getUnits()));
|
||||||
} else {
|
} else {
|
||||||
tempTargetView.setVisibility(View.GONE);
|
|
||||||
|
String maxBgDefault = Constants.MAX_BG_DEFAULT_MGDL;
|
||||||
|
String minBgDefault = Constants.MIN_BG_DEFAULT_MGDL;
|
||||||
|
if (!profile.getUnits().equals(Constants.MGDL)) {
|
||||||
|
maxBgDefault = Constants.MAX_BG_DEFAULT_MMOL;
|
||||||
|
minBgDefault = Constants.MIN_BG_DEFAULT_MMOL;
|
||||||
}
|
}
|
||||||
|
tempTargetView.setTextColor(Color.WHITE);
|
||||||
|
tempTargetView.setBackgroundResource(R.drawable.temptargetborderdisabled);
|
||||||
|
tempTargetView.setText(prefs.getString("openapsma_min_bg", minBgDefault) + " - " + prefs.getString("openapsma_max_bg", maxBgDefault));
|
||||||
|
tempTargetView.setVisibility(View.VISIBLE);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
tempTargetView.setVisibility(View.GONE);
|
||||||
}
|
}
|
||||||
|
|
||||||
// **** Temp button ****
|
// **** Temp button ****
|
||||||
|
@ -583,34 +607,39 @@ public class OverviewFragment extends Fragment {
|
||||||
});
|
});
|
||||||
activeProfileView.setLongClickable(true);
|
activeProfileView.setLongClickable(true);
|
||||||
|
|
||||||
if (profile == null || !pump.isInitialized()) {
|
|
||||||
// disable all treatment buttons because we are not able to check constraints without profile
|
|
||||||
wizardButton.setVisibility(View.INVISIBLE);
|
|
||||||
treatmentButton.setVisibility(View.INVISIBLE);
|
|
||||||
return;
|
|
||||||
} else {
|
|
||||||
wizardButton.setVisibility(View.VISIBLE);
|
|
||||||
treatmentButton.setVisibility(View.VISIBLE);
|
|
||||||
}
|
|
||||||
|
|
||||||
String units = profile.getUnits();
|
tempTargetView.setOnLongClickListener(new View.OnLongClickListener() {
|
||||||
|
@Override
|
||||||
|
public boolean onLongClick(View view) {
|
||||||
|
view.performHapticFeedback(HapticFeedbackConstants.LONG_PRESS);
|
||||||
|
NewNSTreatmentDialog newTTDialog = new NewNSTreatmentDialog();
|
||||||
|
final OptionsToShow temptarget = new OptionsToShow(R.id.careportal_temptarget, R.string.careportal_temptarget, false, false, false, false, true, false, false, false, false, true);
|
||||||
|
temptarget.executeTempTarget = true;
|
||||||
|
newTTDialog.setOptions(temptarget);
|
||||||
|
newTTDialog.show(getFragmentManager(), "NewNSTreatmentDialog");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
tempTargetView.setLongClickable(true);
|
||||||
|
|
||||||
// QuickWizard button
|
// QuickWizard button
|
||||||
QuickWizard.QuickWizardEntry quickWizardEntry = getPlugin().quickWizard.getActive();
|
QuickWizard.QuickWizardEntry quickWizardEntry = getPlugin().quickWizard.getActive();
|
||||||
if (quickWizardEntry != null && lastBG != null && pump.isInitialized()) {
|
if (quickWizardEntry != null && lastBG != null && pump.isInitialized()) {
|
||||||
quickWizardLayout.setVisibility(View.VISIBLE);
|
quickWizardButton.setVisibility(View.VISIBLE);
|
||||||
String text = MainApp.sResources.getString(R.string.bolus) + ": " + quickWizardEntry.buttonText() + " " + DecimalFormatter.to0Decimal(quickWizardEntry.carbs()) + "g";
|
String text = MainApp.sResources.getString(R.string.bolus) + ": " + quickWizardEntry.buttonText() + " " + DecimalFormatter.to0Decimal(quickWizardEntry.carbs()) + "g";
|
||||||
BolusWizard wizard = new BolusWizard();
|
BolusWizard wizard = new BolusWizard();
|
||||||
wizard.doCalc(profile.getDefaultProfile(), quickWizardEntry.carbs(), lastBG.valueToUnits(profile.getUnits()), 0d, true, true);
|
wizard.doCalc(profile.getDefaultProfile(), quickWizardEntry.carbs(), lastBG.valueToUnits(profile.getUnits()), 0d, true, true);
|
||||||
text += " " + DecimalFormatter.to2Decimal(wizard.calculatedTotalInsulin) + "U";
|
text += " " + DecimalFormatter.to2Decimal(wizard.calculatedTotalInsulin) + "U";
|
||||||
quickWizardButton.setText(text);
|
quickWizardButton.setText(text);
|
||||||
if (wizard.calculatedTotalInsulin <= 0)
|
if (wizard.calculatedTotalInsulin <= 0)
|
||||||
quickWizardLayout.setVisibility(View.GONE);
|
quickWizardButton.setVisibility(View.GONE);
|
||||||
} else
|
} else
|
||||||
quickWizardLayout.setVisibility(View.GONE);
|
quickWizardButton.setVisibility(View.GONE);
|
||||||
|
|
||||||
|
String units = profile.getUnits();
|
||||||
|
|
||||||
// **** BG value ****
|
// **** BG value ****
|
||||||
if (lastBG != null && bgView != null) {
|
if (lastBG != null) {
|
||||||
bgView.setText(lastBG.valueToUnitsToString(profile.getUnits()));
|
bgView.setText(lastBG.valueToUnitsToString(profile.getUnits()));
|
||||||
arrowView.setText(lastBG.directionToSymbol());
|
arrowView.setText(lastBG.directionToSymbol());
|
||||||
GlucoseStatus glucoseStatus = GlucoseStatus.getGlucoseStatusData();
|
GlucoseStatus glucoseStatus = GlucoseStatus.getGlucoseStatusData();
|
||||||
|
@ -885,6 +914,21 @@ public class OverviewFragment extends Fragment {
|
||||||
bgGraph.getSecondScale().setMaxY(maxBgValue / lowLine * maxBasalValueFound * 1.2d);
|
bgGraph.getSecondScale().setMaxY(maxBgValue / lowLine * maxBasalValueFound * 1.2d);
|
||||||
bgGraph.getGridLabelRenderer().setVerticalLabelsSecondScaleColor(MainApp.instance().getResources().getColor(R.color.background_material_dark)); // same color as backround = hide
|
bgGraph.getGridLabelRenderer().setVerticalLabelsSecondScaleColor(MainApp.instance().getResources().getColor(R.color.background_material_dark)); // same color as backround = hide
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Pump not initialized message
|
||||||
|
if (!pump.isInitialized()) {
|
||||||
|
// disable all treatment buttons because we are not able to check constraints without profile
|
||||||
|
wizardButton.setVisibility(View.INVISIBLE);
|
||||||
|
treatmentButton.setVisibility(View.INVISIBLE);
|
||||||
|
quickWizardButton.setVisibility(View.INVISIBLE);
|
||||||
|
initializingView.setText(R.string.waitingforpump);
|
||||||
|
initializingView.setVisibility(View.VISIBLE);
|
||||||
|
} else {
|
||||||
|
wizardButton.setVisibility(View.VISIBLE);
|
||||||
|
treatmentButton.setVisibility(View.VISIBLE);
|
||||||
|
initializingView.setVisibility(View.GONE);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//Notifications
|
//Notifications
|
||||||
|
|
|
@ -180,6 +180,7 @@ public class TempBasalsPlugin implements PluginBase, TempBasalsInterface {
|
||||||
if (useExtendedBoluses) {
|
if (useExtendedBoluses) {
|
||||||
for (Integer pos = 0; pos < extendedBoluses.size(); pos++) {
|
for (Integer pos = 0; pos < extendedBoluses.size(); pos++) {
|
||||||
TempBasal t = extendedBoluses.get(pos);
|
TempBasal t = extendedBoluses.get(pos);
|
||||||
|
if (t.timeStart.getTime() > time) continue;
|
||||||
IobTotal calc = t.iobCalc(now);
|
IobTotal calc = t.iobCalc(now);
|
||||||
total.plus(calc);
|
total.plus(calc);
|
||||||
}
|
}
|
||||||
|
|
|
@ -83,6 +83,12 @@ public class TempTargetRangeFragment extends Fragment implements View.OnClickLis
|
||||||
holder.reason.setText(tempTarget.reason);
|
holder.reason.setText(tempTarget.reason);
|
||||||
if (tempTarget.isInProgress())
|
if (tempTarget.isInProgress())
|
||||||
holder.dateLinearLayout.setBackgroundColor(MainApp.instance().getResources().getColor(R.color.colorInProgress));
|
holder.dateLinearLayout.setBackgroundColor(MainApp.instance().getResources().getColor(R.color.colorInProgress));
|
||||||
|
else if (tempTarget.duration == 0){
|
||||||
|
holder.low.setText("");
|
||||||
|
holder.high.setText("");
|
||||||
|
holder.duration.setText(R.string.cancel);
|
||||||
|
holder.dateLinearLayout.setBackgroundColor(MainApp.instance().getResources().getColor(R.color.notificationUrgent));
|
||||||
|
}
|
||||||
else
|
else
|
||||||
holder.dateLinearLayout.setBackgroundColor(MainApp.instance().getResources().getColor(R.color.cardColorBackground));
|
holder.dateLinearLayout.setBackgroundColor(MainApp.instance().getResources().getColor(R.color.cardColorBackground));
|
||||||
holder.remove.setTag(tempTarget);
|
holder.remove.setTag(tempTarget);
|
||||||
|
@ -128,14 +134,15 @@ public class TempTargetRangeFragment extends Fragment implements View.OnClickLis
|
||||||
final Context finalContext = context;
|
final Context finalContext = context;
|
||||||
switch (v.getId()) {
|
switch (v.getId()) {
|
||||||
case R.id.temptargetrange_remove:
|
case R.id.temptargetrange_remove:
|
||||||
final String _id = tempTarget._id;
|
|
||||||
if (_id != null && !_id.equals("")) {
|
|
||||||
AlertDialog.Builder builder = new AlertDialog.Builder(context);
|
AlertDialog.Builder builder = new AlertDialog.Builder(context);
|
||||||
builder.setTitle(MainApp.sResources.getString(R.string.confirmation));
|
builder.setTitle(MainApp.sResources.getString(R.string.confirmation));
|
||||||
builder.setMessage(MainApp.sResources.getString(R.string.removerecord) + "\n" + _id);
|
builder.setMessage(MainApp.sResources.getString(R.string.removerecord) + "\n" + DateUtil.dateAndTimeString(tempTarget.timeStart));
|
||||||
builder.setPositiveButton(MainApp.sResources.getString(R.string.ok), new DialogInterface.OnClickListener() {
|
builder.setPositiveButton(MainApp.sResources.getString(R.string.ok), new DialogInterface.OnClickListener() {
|
||||||
public void onClick(DialogInterface dialog, int id) {
|
public void onClick(DialogInterface dialog, int id) {
|
||||||
|
final String _id = tempTarget._id;
|
||||||
|
if (_id != null && !_id.equals("")) {
|
||||||
MainApp.getConfigBuilder().removeCareportalEntryFromNS(_id);
|
MainApp.getConfigBuilder().removeCareportalEntryFromNS(_id);
|
||||||
|
}
|
||||||
try {
|
try {
|
||||||
Dao<TempTarget, Long> daoTempTargets = MainApp.getDbHelper().getDaoTempTargets();
|
Dao<TempTarget, Long> daoTempTargets = MainApp.getDbHelper().getDaoTempTargets();
|
||||||
daoTempTargets.delete(tempTarget);
|
daoTempTargets.delete(tempTarget);
|
||||||
|
@ -147,7 +154,6 @@ public class TempTargetRangeFragment extends Fragment implements View.OnClickLis
|
||||||
});
|
});
|
||||||
builder.setNegativeButton(MainApp.sResources.getString(R.string.cancel), null);
|
builder.setNegativeButton(MainApp.sResources.getString(R.string.cancel), null);
|
||||||
builder.show();
|
builder.show();
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -182,8 +188,8 @@ public class TempTargetRangeFragment extends Fragment implements View.OnClickLis
|
||||||
case R.id.temptargetrange_refreshfromnightscout:
|
case R.id.temptargetrange_refreshfromnightscout:
|
||||||
SharedPreferences SP = PreferenceManager.getDefaultSharedPreferences(getContext());
|
SharedPreferences SP = PreferenceManager.getDefaultSharedPreferences(getContext());
|
||||||
boolean nsUploadOnly = SP.getBoolean("ns_upload_only", false);
|
boolean nsUploadOnly = SP.getBoolean("ns_upload_only", false);
|
||||||
if(nsUploadOnly){
|
if (nsUploadOnly) {
|
||||||
ToastUtils.showToastInUiThread(getContext(),this.getContext().getString(R.string.ns_upload_only_enabled));
|
ToastUtils.showToastInUiThread(getContext(), this.getContext().getString(R.string.ns_upload_only_enabled));
|
||||||
} else {
|
} else {
|
||||||
AlertDialog.Builder builder = new AlertDialog.Builder(this.getContext());
|
AlertDialog.Builder builder = new AlertDialog.Builder(this.getContext());
|
||||||
builder.setTitle(this.getContext().getString(R.string.confirmation));
|
builder.setTitle(this.getContext().getString(R.string.confirmation));
|
||||||
|
|
|
@ -91,7 +91,10 @@ public class TempTargetRangePlugin implements PluginBase {
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
public TempTarget getTempTargetInProgress(long time) {
|
public TempTarget getTempTargetInProgress(long time) {
|
||||||
for (int i = tempTargets.size() - 1; i >= 0; i--) {
|
for (int i = 0; i < tempTargets.size(); i++) {
|
||||||
|
// a zero-duration temp target will cancel all prior targets
|
||||||
|
if (tempTargets.get(i).duration == 0) return null;
|
||||||
|
|
||||||
if (tempTargets.get(i).timeStart.getTime() > time) continue;
|
if (tempTargets.get(i).timeStart.getTime() > time) continue;
|
||||||
if (tempTargets.get(i).getPlannedTimeEnd().getTime() >= time) return tempTargets.get(i);
|
if (tempTargets.get(i).getPlannedTimeEnd().getTime() >= time) return tempTargets.get(i);
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,7 @@
|
||||||
|
<shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle" >
|
||||||
|
<solid android:color="@color/colorPrimaryDark" />
|
||||||
|
<stroke android:width="1dip" android:color="@android:color/white"/>
|
||||||
|
<corners
|
||||||
|
android:radius="2dp" >
|
||||||
|
</corners>
|
||||||
|
</shape>
|
7
app/src/main/res/drawable/initializingborder.xml
Normal file
7
app/src/main/res/drawable/initializingborder.xml
Normal file
|
@ -0,0 +1,7 @@
|
||||||
|
<shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle" >
|
||||||
|
<solid android:color="@color/colorInitializingBorder" />
|
||||||
|
<stroke android:width="1dip" android:color="@android:color/white"/>
|
||||||
|
<corners
|
||||||
|
android:radius="2dp" >
|
||||||
|
</corners>
|
||||||
|
</shape>
|
|
@ -32,8 +32,8 @@
|
||||||
android:layout_marginRight="10dp"
|
android:layout_marginRight="10dp"
|
||||||
android:layout_marginTop="3dp"
|
android:layout_marginTop="3dp"
|
||||||
android:layout_weight="0.5"
|
android:layout_weight="0.5"
|
||||||
android:text="@string/careportal_temptarget"
|
android:text="@string/careportal_temporarytarget"
|
||||||
android:textColor="@color/colorTempTargetButton" />
|
android:textColor="@color/colorWizardButton" />
|
||||||
|
|
||||||
<Button
|
<Button
|
||||||
android:id="@+id/actions_settempbasal"
|
android:id="@+id/actions_settempbasal"
|
||||||
|
|
|
@ -269,6 +269,12 @@
|
||||||
android:text="@string/danar_history"
|
android:text="@string/danar_history"
|
||||||
android:id="@+id/danar_history"
|
android:id="@+id/danar_history"
|
||||||
android:layout_weight="1" />
|
android:layout_weight="1" />
|
||||||
|
<Button
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:text="@string/danar_stats"
|
||||||
|
android:id="@+id/danar_stats"
|
||||||
|
android:layout_weight="1" />
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
|
|
209
app/src/main/res/layout/danar_statsactivity.xml
Normal file
209
app/src/main/res/layout/danar_statsactivity.xml
Normal file
|
@ -0,0 +1,209 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
|
android:layout_width="fill_parent"
|
||||||
|
android:layout_height="fill_parent"
|
||||||
|
android:paddingBottom="@dimen/activity_vertical_margin"
|
||||||
|
android:paddingTop="@dimen/activity_vertical_margin"
|
||||||
|
tools:context=".plugins.DanaR.History.DanaRHistoryActivity">
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:id="@+id/danar_statstop"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_alignParentTop="true"
|
||||||
|
android:focusable="true"
|
||||||
|
android:focusableInTouchMode="true"
|
||||||
|
android:orientation="horizontal">
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
<ScrollView
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:layout_alignParentStart="true">
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:orientation="vertical">
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_weight="1"
|
||||||
|
android:gravity="center_horizontal"
|
||||||
|
android:textColor="@color/mdtp_white"
|
||||||
|
android:background="@drawable/pillborder"
|
||||||
|
android:text="@string/danar_stats" />
|
||||||
|
|
||||||
|
<TableLayout
|
||||||
|
android:stretchColumns="0,1,2,3,4"
|
||||||
|
android:id="@+id/main_table"
|
||||||
|
android:layout_weight="1"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_width="match_parent">
|
||||||
|
</TableLayout>
|
||||||
|
|
||||||
|
<Space
|
||||||
|
android:layout_width="10dp"
|
||||||
|
android:layout_height="10dp" />
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:orientation="horizontal"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:layout_weight="1">
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:orientation="vertical"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content">
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:layout_width="150dp"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:textColor="@color/mdtp_white"
|
||||||
|
android:background="@drawable/pillborder"
|
||||||
|
android:gravity="center_horizontal"
|
||||||
|
android:text="@string/danar_stats_cumulative_tdd" />
|
||||||
|
|
||||||
|
<TableLayout
|
||||||
|
android:stretchColumns="0,1,2"
|
||||||
|
android:id="@+id/cumulative_table"
|
||||||
|
android:layout_height="0dp"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_weight="1">
|
||||||
|
|
||||||
|
</TableLayout>
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
<Space
|
||||||
|
android:layout_width="10dp"
|
||||||
|
android:layout_height="10dp" />
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:orientation="vertical"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:focusable="true"
|
||||||
|
android:focusableInTouchMode="true">
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:gravity="center_horizontal"
|
||||||
|
android:textColor="@color/mdtp_white"
|
||||||
|
android:background="@drawable/pillborder"
|
||||||
|
android:text="@string/danar_stats_expweight" />
|
||||||
|
|
||||||
|
<TableLayout
|
||||||
|
android:stretchColumns="0,1,2"
|
||||||
|
android:id="@+id/expweight_table"
|
||||||
|
android:layout_height="0dp"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_weight="1">
|
||||||
|
</TableLayout>
|
||||||
|
|
||||||
|
<Space
|
||||||
|
android:layout_width="10dp"
|
||||||
|
android:layout_height="10dp" />
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:orientation="horizontal"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent">
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:text="@string/danar_stats_tbb"
|
||||||
|
android:labelFor="@+id/danar_stats_editTotalBaseBasal"
|
||||||
|
android:layout_width="0dp"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:id="@+id/danar_stats_editTotalBaseBasal_label"
|
||||||
|
android:gravity="left"
|
||||||
|
android:layout_weight="1" />
|
||||||
|
|
||||||
|
<EditText
|
||||||
|
android:layout_width="70dp"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:inputType="numberDecimal"
|
||||||
|
android:layout_marginRight="10dp"
|
||||||
|
android:gravity="center_vertical|center_horizontal"
|
||||||
|
android:textAppearance="?android:attr/textAppearanceMedium"
|
||||||
|
android:textColor="@color/mdtp_white"
|
||||||
|
android:background="@drawable/pillborder"
|
||||||
|
android:id="@+id/danar_stats_editTotalBaseBasal" />
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:orientation="horizontal"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent">
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:text="@string/danar_stats_tbb2"
|
||||||
|
android:labelFor="@+id/danar_stats_editTotalBaseBasal2"
|
||||||
|
android:layout_width="0dp"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:id="@+id/danar_stats_editTotalBaseBasal2_label"
|
||||||
|
android:gravity="left"
|
||||||
|
android:layout_weight="1" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:layout_width="70dp"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:textAppearance="?android:attr/textAppearanceMedium"
|
||||||
|
android:gravity="center_vertical|center_horizontal"
|
||||||
|
android:layout_marginRight="10dp"
|
||||||
|
android:textColor="@color/mdtp_white"
|
||||||
|
android:id="@+id/danar_stats_editTotalBaseBasal2" />
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
|
</LinearLayout>
|
||||||
|
</LinearLayout>
|
||||||
|
</LinearLayout>
|
||||||
|
</ScrollView>
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:id="@+id/danar_historybuttons"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_alignParentBottom="true"
|
||||||
|
android:orientation="horizontal">
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:orientation="vertical"
|
||||||
|
android:layout_width="0dp"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:gravity="center_vertical|center_horizontal"
|
||||||
|
android:layout_weight="1">
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/danar_stats_connection_status"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_gravity="center_horizontal"
|
||||||
|
android:gravity="center_horizontal" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/danar_stats_Message"
|
||||||
|
android:layout_width="350dp"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:textSize="15sp"
|
||||||
|
android:textStyle="bold"
|
||||||
|
android:textColor="#ff0000"
|
||||||
|
android:background="@drawable/pillborder"
|
||||||
|
android:paddingLeft="10dp"
|
||||||
|
android:paddingRight="10dp"
|
||||||
|
android:text="@string/danar_stats_warning_Message" />
|
||||||
|
|
||||||
|
<Button
|
||||||
|
android:id="@+id/danar_statsreload"
|
||||||
|
android:layout_width="200dp"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:textColor="@color/mdtp_white"
|
||||||
|
android:background="@drawable/pillborder"
|
||||||
|
android:text="@string/danar_historyreload" />
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
|
</LinearLayout>
|
||||||
|
</RelativeLayout>
|
|
@ -17,7 +17,7 @@
|
||||||
android:id="@+id/profileview_noprofile"
|
android:id="@+id/profileview_noprofile"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:text="@string/nsprofileview_noprofile_text"
|
android:text="@string/noprofileset"
|
||||||
android:textAppearance="?android:attr/textAppearanceLarge"
|
android:textAppearance="?android:attr/textAppearanceLarge"
|
||||||
android:textColor="@android:color/holo_red_light"
|
android:textColor="@android:color/holo_red_light"
|
||||||
android:textStyle="bold"
|
android:textStyle="bold"
|
||||||
|
|
|
@ -21,15 +21,16 @@
|
||||||
</android.support.v7.widget.RecyclerView>
|
</android.support.v7.widget.RecyclerView>
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:orientation="horizontal"
|
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
|
android:orientation="horizontal"
|
||||||
android:paddingTop="2dp">
|
android:paddingTop="2dp">
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/overview_apsmode"
|
android:id="@+id/overview_apsmode"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
|
android:layout_marginLeft="10dp"
|
||||||
android:layout_marginRight="10dp"
|
android:layout_marginRight="10dp"
|
||||||
android:background="@drawable/loopmodeborder"
|
android:background="@drawable/loopmodeborder"
|
||||||
android:gravity="center_vertical|center_horizontal"
|
android:gravity="center_vertical|center_horizontal"
|
||||||
|
@ -37,7 +38,8 @@
|
||||||
android:paddingRight="10dp"
|
android:paddingRight="10dp"
|
||||||
android:text="Open Loop"
|
android:text="Open Loop"
|
||||||
android:textAppearance="?android:attr/textAppearanceSmall"
|
android:textAppearance="?android:attr/textAppearanceSmall"
|
||||||
android:layout_weight="0.2" />
|
android:layout_weight="0.1" />
|
||||||
|
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/overview_activeprofile"
|
android:id="@+id/overview_activeprofile"
|
||||||
|
@ -45,14 +47,14 @@
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_gravity="right"
|
android:layout_gravity="right"
|
||||||
android:layout_marginRight="10dp"
|
android:layout_marginRight="10dp"
|
||||||
|
android:layout_weight="0.5"
|
||||||
android:background="@drawable/pillborder"
|
android:background="@drawable/pillborder"
|
||||||
android:gravity="center_vertical|center_horizontal"
|
android:gravity="center_vertical|center_horizontal"
|
||||||
android:text="Profile"
|
|
||||||
android:paddingLeft="10dp"
|
android:paddingLeft="10dp"
|
||||||
android:paddingRight="10dp"
|
android:paddingRight="10dp"
|
||||||
|
android:text="Profile"
|
||||||
android:textAppearance="?android:attr/textAppearanceMedium"
|
android:textAppearance="?android:attr/textAppearanceMedium"
|
||||||
android:textColor="@color/colorProfileSwitchButton"
|
android:textColor="@color/colorProfileSwitchButton" />
|
||||||
android:layout_weight="0.5" />
|
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/overview_temptarget"
|
android:id="@+id/overview_temptarget"
|
||||||
|
@ -70,10 +72,28 @@
|
||||||
android:layout_weight="0.2" />
|
android:layout_weight="0.2" />
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:orientation="horizontal"
|
||||||
|
android:paddingTop="2dp">
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/overview_initializing"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:background="@drawable/initializingborder"
|
||||||
|
android:gravity="center_vertical|center_horizontal"
|
||||||
|
android:text="@string/initializing"
|
||||||
|
android:textAppearance="?android:attr/textAppearanceMedium"
|
||||||
|
android:layout_marginTop="10dp" />
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
<LinearLayout
|
<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"
|
||||||
|
android:gravity="center_horizontal">
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/overview_bg"
|
android:id="@+id/overview_bg"
|
||||||
|
@ -90,13 +110,13 @@
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_gravity="top|left"
|
android:layout_gravity="top|left"
|
||||||
|
android:layout_marginTop="-15dp"
|
||||||
android:gravity="center_vertical"
|
android:gravity="center_vertical"
|
||||||
android:paddingLeft="-5dp"
|
android:paddingLeft="-5dp"
|
||||||
android:paddingRight="-10dp"
|
android:paddingRight="-10dp"
|
||||||
android:text="→"
|
android:text="→"
|
||||||
android:textSize="70dp"
|
android:textSize="70dp"
|
||||||
android:textStyle="bold"
|
android:textStyle="bold" />
|
||||||
android:layout_marginTop="-15dp" />
|
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
|
@ -134,9 +154,9 @@
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
|
android:id="@+id/overview_basallayout"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:id="@+id/overview_basallayout"
|
|
||||||
android:gravity="center_horizontal"
|
android:gravity="center_horizontal"
|
||||||
android:orientation="horizontal">
|
android:orientation="horizontal">
|
||||||
|
|
||||||
|
@ -178,11 +198,11 @@
|
||||||
android:layout_height="160dip" />
|
android:layout_height="160dip" />
|
||||||
|
|
||||||
<CheckBox
|
<CheckBox
|
||||||
|
android:id="@+id/overview_showprediction"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:id="@+id/overview_showprediction"
|
android:layout_alignParentEnd="true"
|
||||||
android:layout_alignParentTop="true"
|
android:layout_alignParentTop="true" />
|
||||||
android:layout_alignParentEnd="true" />
|
|
||||||
</RelativeLayout>
|
</RelativeLayout>
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
|
@ -259,7 +279,6 @@
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:id="@+id/overview_quickwizardlayout"
|
|
||||||
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">
|
||||||
|
|
|
@ -89,7 +89,7 @@
|
||||||
<string name="nsprofileview_basal_label">Базални стойности:</string>
|
<string name="nsprofileview_basal_label">Базални стойности:</string>
|
||||||
<string name="nsprofileview_dia_label">DIA (Време на действие на инсулина):</string>
|
<string name="nsprofileview_dia_label">DIA (Време на действие на инсулина):</string>
|
||||||
<string name="nsprofileview_ic_label">IC (Инсулин/въглехидр.):</string>
|
<string name="nsprofileview_ic_label">IC (Инсулин/въглехидр.):</string>
|
||||||
<string name="nsprofileview_noprofile_text">НЕ Е ЗАДАДЕН ПРОФИЛ</string>
|
<string name="noprofileset">НЕ Е ЗАДАДЕН ПРОФИЛ</string>
|
||||||
<string name="nsprofileview_target_label">Целeва КЗ:</string>
|
<string name="nsprofileview_target_label">Целeва КЗ:</string>
|
||||||
<string name="nsprofileview_units_label">Единици:</string>
|
<string name="nsprofileview_units_label">Единици:</string>
|
||||||
<string name="objectives">Цели</string>
|
<string name="objectives">Цели</string>
|
||||||
|
|
|
@ -89,7 +89,7 @@
|
||||||
<string name="nsprofileview_basal_label">Bazál:</string>
|
<string name="nsprofileview_basal_label">Bazál:</string>
|
||||||
<string name="nsprofileview_dia_label">Trvání inzulínu:</string>
|
<string name="nsprofileview_dia_label">Trvání inzulínu:</string>
|
||||||
<string name="nsprofileview_ic_label">Inzulínosacharidový poměr:</string>
|
<string name="nsprofileview_ic_label">Inzulínosacharidový poměr:</string>
|
||||||
<string name="nsprofileview_noprofile_text">ŽÁDNÝ PROFIL NENASTAVEN</string>
|
<string name="noprofileset">ŽÁDNÝ PROFIL NENASTAVEN</string>
|
||||||
<string name="nsprofileview_target_label">Cíl:</string>
|
<string name="nsprofileview_target_label">Cíl:</string>
|
||||||
<string name="nsprofileview_units_label">Jednotky:</string>
|
<string name="nsprofileview_units_label">Jednotky:</string>
|
||||||
<string name="objectives">Cíle</string>
|
<string name="objectives">Cíle</string>
|
||||||
|
@ -385,4 +385,20 @@
|
||||||
<string name="ongoingnotificaction">Průběžné oznámení</string>
|
<string name="ongoingnotificaction">Průběžné oznámení</string>
|
||||||
<string name="old_data">ZASTARALÉ</string>
|
<string name="old_data">ZASTARALÉ</string>
|
||||||
<string name="localprofile">Místní profil</string>
|
<string name="localprofile">Místní profil</string>
|
||||||
|
<string name="activity">Aktivita</string>
|
||||||
|
<string name="array_of_elements">Pole %d prvků. Aktuální hodnota:</string>
|
||||||
|
<string name="eatingsoon">Před jídlem</string>
|
||||||
|
<string name="el_lang">Řečtina</string>
|
||||||
|
<string name="initializing">Inicializuji ...</string>
|
||||||
|
<string name="long_avgdelta">Dlouhodobý průměr</string>
|
||||||
|
<string name="openapsama">OpenAPS AMA</string>
|
||||||
|
<string name="openapsama_useautosens">Používat autodetekci senzitivity</string>
|
||||||
|
<string name="openapsma_autosensdata_label">Data detekce senzitivity</string>
|
||||||
|
<string name="openapsma_scriptdebugdata_label">Ladící informace</string>
|
||||||
|
<string name="openapsma_valuelimitedto" formatted="false">%.2f omezeno na %.2f</string>
|
||||||
|
<string name="refreshtemptargetsfromnightscout">Opravdu aktualizovat dočasné cíle z NS</string>
|
||||||
|
<string name="removerecord">Odstranit záznam:</string>
|
||||||
|
<string name="short_avgdelta">Krátkodobý průměr</string>
|
||||||
|
<string name="temptargetrange">Dočasný cíl</string>
|
||||||
|
<string name="temptargetrange_refreshfromnightscout">Obnovit dočasné cíle z NS</string>
|
||||||
</resources>
|
</resources>
|
||||||
|
|
|
@ -142,7 +142,7 @@
|
||||||
<string name="objectives_gate_label_string">Gate:</string>
|
<string name="objectives_gate_label_string">Gate:</string>
|
||||||
<string name="objectives_objective_label_string">Objective:</string>
|
<string name="objectives_objective_label_string">Objective:</string>
|
||||||
<string name="objectives">Zielsetzungen</string>
|
<string name="objectives">Zielsetzungen</string>
|
||||||
<string name="nsprofileview_noprofile_text">KEIN PROFIL GESETZT</string>
|
<string name="noprofileset">KEIN PROFIL GESETZT</string>
|
||||||
<string name="nsclientnotinstalled">NSClient nicht installiert. Record lost!</string>
|
<string name="nsclientnotinstalled">NSClient nicht installiert. Record lost!</string>
|
||||||
<string name="ns_sync_use_absolute_title">Verwende absolute statt prozentuelle Basalwerte beim Upload zu NightScout</string>
|
<string name="ns_sync_use_absolute_title">Verwende absolute statt prozentuelle Basalwerte beim Upload zu NightScout</string>
|
||||||
<string name="noprofile">Bisher noch kein Profil von NS geladen</string>
|
<string name="noprofile">Bisher noch kein Profil von NS geladen</string>
|
||||||
|
|
|
@ -25,7 +25,7 @@
|
||||||
<string name="nsprofileview_isf_label">ISF (Factor Sensibilidad Insulina):</string>
|
<string name="nsprofileview_isf_label">ISF (Factor Sensibilidad Insulina):</string>
|
||||||
<string name="nsprofileview_basal_label">Dosis Basal:</string>
|
<string name="nsprofileview_basal_label">Dosis Basal:</string>
|
||||||
<string name="nsprofileview_target_label">Objetivo:</string>
|
<string name="nsprofileview_target_label">Objetivo:</string>
|
||||||
<string name="nsprofileview_noprofile_text">PERFIL NO ACTIVO</string>
|
<string name="noprofileset">PERFIL NO ACTIVO</string>
|
||||||
<string name="treatments_insulin_label_string">Insulina:</string>
|
<string name="treatments_insulin_label_string">Insulina:</string>
|
||||||
<string name="treatments_carbs_label_string">Carbohidratos:</string>
|
<string name="treatments_carbs_label_string">Carbohidratos:</string>
|
||||||
<string name="treatments_iob_label_string">IOB:</string>
|
<string name="treatments_iob_label_string">IOB:</string>
|
||||||
|
|
|
@ -26,7 +26,7 @@
|
||||||
<string name="nsprofileview_isf_label">인슐린 민감도(ISF):</string>
|
<string name="nsprofileview_isf_label">인슐린 민감도(ISF):</string>
|
||||||
<string name="nsprofileview_basal_label">기초주입:</string>
|
<string name="nsprofileview_basal_label">기초주입:</string>
|
||||||
<string name="nsprofileview_target_label">목표:</string>
|
<string name="nsprofileview_target_label">목표:</string>
|
||||||
<string name="nsprofileview_noprofile_text">NO PROFILE SET</string>
|
<string name="noprofileset">NO PROFILE SET</string>
|
||||||
<string name="treatments_insulin_label_string">인슐린:</string>
|
<string name="treatments_insulin_label_string">인슐린:</string>
|
||||||
<string name="treatments_carbs_label_string">탄수화물:</string>
|
<string name="treatments_carbs_label_string">탄수화물:</string>
|
||||||
<string name="treatments_iob_label_string">IOB:</string>
|
<string name="treatments_iob_label_string">IOB:</string>
|
||||||
|
|
|
@ -3,6 +3,7 @@
|
||||||
<color name="colorPrimary">#3F51B5</color>
|
<color name="colorPrimary">#3F51B5</color>
|
||||||
<color name="colorPrimaryDark">#303F9F</color>
|
<color name="colorPrimaryDark">#303F9F</color>
|
||||||
<color name="colorAccent">#FF4081</color>
|
<color name="colorAccent">#FF4081</color>
|
||||||
|
<color name="colorInitializingBorder">#ff2630</color>
|
||||||
|
|
||||||
<color name="cardColorBackground">#121212</color>
|
<color name="cardColorBackground">#121212</color>
|
||||||
<color name="cardObjectiveText">#779ECB</color>
|
<color name="cardObjectiveText">#779ECB</color>
|
||||||
|
|
|
@ -27,7 +27,7 @@
|
||||||
<string name="nsprofileview_isf_label">ISF:</string>
|
<string name="nsprofileview_isf_label">ISF:</string>
|
||||||
<string name="nsprofileview_basal_label">Basal:</string>
|
<string name="nsprofileview_basal_label">Basal:</string>
|
||||||
<string name="nsprofileview_target_label">Target:</string>
|
<string name="nsprofileview_target_label">Target:</string>
|
||||||
<string name="nsprofileview_noprofile_text">NO PROFILE SET</string>
|
<string name="noprofileset">NO PROFILE SET</string>
|
||||||
<string name="treatments_insulin_label_string">Insulin:</string>
|
<string name="treatments_insulin_label_string">Insulin:</string>
|
||||||
<string name="treatments_carbs_label_string">Carbs:</string>
|
<string name="treatments_carbs_label_string">Carbs:</string>
|
||||||
<string name="treatments_iob_label_string">IOB:</string>
|
<string name="treatments_iob_label_string">IOB:</string>
|
||||||
|
@ -319,6 +319,7 @@
|
||||||
<string name="smscommunicator_loophasbeenenabled">Loop has been enabled</string>
|
<string name="smscommunicator_loophasbeenenabled">Loop has been enabled</string>
|
||||||
<string name="smscommunicator_loopisdisabled">Loop is disabled</string>
|
<string name="smscommunicator_loopisdisabled">Loop is disabled</string>
|
||||||
<string name="smscommunicator_loopisenabled">Loop is enabled</string>
|
<string name="smscommunicator_loopisenabled">Loop is enabled</string>
|
||||||
|
<string name="openapsma_valuelimitedto" formatted="false">%.2f limited to %.2f</string>
|
||||||
<string name="openapsma_valueoutofrange" formatted="false">Value %s is out of hard limits</string>
|
<string name="openapsma_valueoutofrange" formatted="false">Value %s is out of hard limits</string>
|
||||||
<string name="smscommunicator_remotebasalnotallowed">Remote basal setting is not allowed</string>
|
<string name="smscommunicator_remotebasalnotallowed">Remote basal setting is not allowed</string>
|
||||||
<string name="smscommunicator_basalreplywithcode" formatted="false">To start basal %.2fU/h reply with code %s</string>
|
<string name="smscommunicator_basalreplywithcode" formatted="false">To start basal %.2fU/h reply with code %s</string>
|
||||||
|
@ -408,8 +409,23 @@
|
||||||
<string name="openapsama_useautosens">Use AMA autosens feature</string>
|
<string name="openapsama_useautosens">Use AMA autosens feature</string>
|
||||||
<string name="temptargetrange">Temp Target</string>
|
<string name="temptargetrange">Temp Target</string>
|
||||||
<string name="temptargetrange_refreshfromnightscout">Refresh temp targets from NS</string>
|
<string name="temptargetrange_refreshfromnightscout">Refresh temp targets from NS</string>
|
||||||
<string name="careportal_temptarget">Temporary Target</string>
|
|
||||||
<string name="eatingsoon">Eating Soon</string>
|
<string name="eatingsoon">Eating Soon</string>
|
||||||
<string name="activity">Activity</string>
|
<string name="activity">Activity</string>
|
||||||
<string name="removerecord">Remove record:</string>
|
<string name="removerecord">Remove record:</string>
|
||||||
|
<string name="danar_stats">DanaR Stats</string>
|
||||||
|
<string name="danar_stats_cumulative_tdd">Cumulative TDD</string>
|
||||||
|
<string name="danar_stats_expweight">Exponentially Weighted TDD</string>
|
||||||
|
<string name="danar_stats_basalrate">Basal</string>
|
||||||
|
<string name="danar_stats_bolus">Bolus</string>
|
||||||
|
<string name="danar_stats_tdd">TDD</string>
|
||||||
|
<string name="danar_stats_date">Date</string>
|
||||||
|
<string name="danar_stats_ratio">Ratio</string>
|
||||||
|
<string name="danar_stats_amount_days"># Days</string>
|
||||||
|
<string name="danar_stats_weight">Weight</string>
|
||||||
|
<string name="danar_stats_warning_Message">Possibly inaccurate if using boluses for priming/filling!</string>
|
||||||
|
<string name="danar_stats_olddata_Message">Old Data Please Press "RELOAD"</string>
|
||||||
|
<string name="danar_stats_tbb">Total Base Basal</string>
|
||||||
|
<string name="danar_stats_tbb2">Total Base Basal ²</string>
|
||||||
|
<string name="initializing">Initializing ...</string>
|
||||||
|
<string name="careportal_temptarget">Temporary Target</string>
|
||||||
</resources>
|
</resources>
|
||||||
|
|
Loading…
Reference in a new issue