Merge branch 'dev' of https://github.com/MilosKozak/AndroidAPS into dev
This commit is contained in:
commit
63ad0704fa
|
@ -39,6 +39,7 @@ import info.nightscout.androidaps.events.EventAppExit;
|
|||
import info.nightscout.androidaps.events.EventPreferenceChange;
|
||||
import info.nightscout.androidaps.events.EventRefreshGui;
|
||||
import info.nightscout.androidaps.interfaces.PluginBase;
|
||||
import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderPlugin;
|
||||
import info.nightscout.androidaps.tabs.SlidingTabLayout;
|
||||
import info.nightscout.androidaps.tabs.TabPageAdapter;
|
||||
import info.nightscout.utils.ImportExportPrefs;
|
||||
|
@ -300,7 +301,9 @@ public class MainActivity extends AppCompatActivity implements View.OnClickListe
|
|||
builder.setIcon(R.mipmap.yellowowl);
|
||||
else
|
||||
builder.setIcon(R.mipmap.blueowl);
|
||||
builder.setMessage("Build: " + BuildConfig.BUILDVERSION);
|
||||
String message = "Build: " + BuildConfig.BUILDVERSION + "\n";
|
||||
message += MainApp.sResources.getString(R.string.configbuilder_nightscoutversion_label) + " " + ConfigBuilderPlugin.nightscoutVersionName;
|
||||
builder.setMessage(message);
|
||||
builder.setPositiveButton(MainApp.sResources.getString(R.string.ok), null);
|
||||
AlertDialog alertDialog = builder.create();
|
||||
alertDialog.show();
|
||||
|
|
|
@ -26,10 +26,10 @@ import info.nightscout.androidaps.plugins.Careportal.CareportalFragment;
|
|||
import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderFragment;
|
||||
import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderPlugin;
|
||||
import info.nightscout.androidaps.plugins.ConstraintsObjectives.ObjectivesFragment;
|
||||
import info.nightscout.androidaps.plugins.ConstraintsSafety.SafetyFragment;
|
||||
import info.nightscout.androidaps.plugins.ConstraintsSafety.SafetyPlugin;
|
||||
import info.nightscout.androidaps.plugins.InsulinFastacting.InsulinFastactingFragment;
|
||||
import info.nightscout.androidaps.plugins.InsulinFastactingProlonged.InsulinFastactingProlongedFragment;
|
||||
import info.nightscout.androidaps.plugins.IobCobCalculator.IobCobCalculatorFragment;
|
||||
import info.nightscout.androidaps.plugins.IobCobCalculator.IobCobCalculatorPlugin;
|
||||
import info.nightscout.androidaps.plugins.Loop.LoopFragment;
|
||||
import info.nightscout.androidaps.plugins.NSClientInternal.NSClientInternalFragment;
|
||||
import info.nightscout.androidaps.plugins.OpenAPSAMA.OpenAPSAMAFragment;
|
||||
|
@ -46,17 +46,18 @@ import info.nightscout.androidaps.plugins.PumpDanaRKorean.DanaRKoreanFragment;
|
|||
import info.nightscout.androidaps.plugins.PumpDanaRKorean.services.DanaRKoreanExecutionService;
|
||||
import info.nightscout.androidaps.plugins.PumpDanaRv2.DanaRv2Fragment;
|
||||
import info.nightscout.androidaps.plugins.PumpDanaRv2.services.DanaRv2ExecutionService;
|
||||
import info.nightscout.androidaps.plugins.PumpMDI.MDIFragment;
|
||||
import info.nightscout.androidaps.plugins.PumpVirtual.VirtualPumpFragment;
|
||||
import info.nightscout.androidaps.plugins.PumpMDI.MDIPlugin;
|
||||
import info.nightscout.androidaps.plugins.PumpVirtual.VirtualPumpPlugin;
|
||||
import info.nightscout.androidaps.plugins.SensitivityMK.SensitivityMKPlugin;
|
||||
import info.nightscout.androidaps.plugins.SensitivityOref0.SensitivityOref0Plugin;
|
||||
import info.nightscout.androidaps.plugins.SmsCommunicator.SmsCommunicatorFragment;
|
||||
import info.nightscout.androidaps.plugins.SourceGlimp.SourceGlimpFragment;
|
||||
import info.nightscout.androidaps.plugins.SourceMM640g.SourceMM640gFragment;
|
||||
import info.nightscout.androidaps.plugins.SourceNSClient.SourceNSClientFragment;
|
||||
import info.nightscout.androidaps.plugins.SourceXdrip.SourceXdripFragment;
|
||||
import info.nightscout.androidaps.plugins.SourceGlimp.SourceGlimpPlugin;
|
||||
import info.nightscout.androidaps.plugins.SourceMM640g.SourceMM640gPlugin;
|
||||
import info.nightscout.androidaps.plugins.SourceNSClient.SourceNSClientPlugin;
|
||||
import info.nightscout.androidaps.plugins.SourceXdrip.SourceXdripPlugin;
|
||||
import info.nightscout.androidaps.plugins.Treatments.TreatmentsFragment;
|
||||
import info.nightscout.androidaps.plugins.Wear.WearFragment;
|
||||
import info.nightscout.androidaps.plugins.XDripStatusline.StatuslineFragment;
|
||||
import info.nightscout.androidaps.plugins.XDripStatusline.StatuslinePlugin;
|
||||
import info.nightscout.androidaps.receivers.KeepAliveReceiver;
|
||||
import info.nightscout.utils.NSUpload;
|
||||
import io.fabric.sdk.android.Fabric;
|
||||
|
@ -94,15 +95,17 @@ public class MainApp extends Application {
|
|||
pluginsList = new ArrayList<>();
|
||||
// Register all tabs in app here
|
||||
pluginsList.add(OverviewFragment.getPlugin());
|
||||
pluginsList.add(IobCobCalculatorFragment.getPlugin());
|
||||
pluginsList.add(IobCobCalculatorPlugin.getPlugin());
|
||||
if (Config.ACTION) pluginsList.add(ActionsFragment.getPlugin());
|
||||
pluginsList.add(InsulinFastactingFragment.getPlugin());
|
||||
pluginsList.add(InsulinFastactingProlongedFragment.getPlugin());
|
||||
pluginsList.add(SensitivityOref0Plugin.getPlugin());
|
||||
pluginsList.add(SensitivityMKPlugin.getPlugin());
|
||||
if (Config.DANAR) pluginsList.add(DanaRFragment.getPlugin());
|
||||
if (Config.DANAR) pluginsList.add(DanaRKoreanFragment.getPlugin());
|
||||
if (Config.DANARv2) pluginsList.add(DanaRv2Fragment.getPlugin());
|
||||
pluginsList.add(CareportalFragment.getPlugin());
|
||||
if (Config.MDI) pluginsList.add(MDIFragment.getPlugin());
|
||||
if (Config.MDI) pluginsList.add(MDIPlugin.getPlugin());
|
||||
if (Config.VIRTUALPUMP) pluginsList.add(VirtualPumpPlugin.getInstance());
|
||||
if (Config.LOOPENABLED) pluginsList.add(LoopFragment.getPlugin());
|
||||
if (Config.OPENAPSENABLED) pluginsList.add(OpenAPSMAFragment.getPlugin());
|
||||
|
@ -113,19 +116,19 @@ public class MainApp extends Application {
|
|||
if (Config.OTHERPROFILES)
|
||||
pluginsList.add(CircadianPercentageProfileFragment.getPlugin());
|
||||
pluginsList.add(TreatmentsFragment.getPlugin());
|
||||
if (Config.SAFETY) pluginsList.add(SafetyFragment.getPlugin());
|
||||
if (Config.SAFETY) pluginsList.add(SafetyPlugin.getPlugin());
|
||||
if (Config.APS) pluginsList.add(ObjectivesFragment.getPlugin());
|
||||
if (!Config.NSCLIENT)
|
||||
pluginsList.add(SourceXdripFragment.getPlugin());
|
||||
pluginsList.add(SourceNSClientFragment.getPlugin());
|
||||
pluginsList.add(SourceXdripPlugin.getPlugin());
|
||||
pluginsList.add(SourceNSClientPlugin.getPlugin());
|
||||
if (!Config.NSCLIENT)
|
||||
pluginsList.add(SourceMM640gFragment.getPlugin());
|
||||
pluginsList.add(SourceMM640gPlugin.getPlugin());
|
||||
if (!Config.NSCLIENT)
|
||||
pluginsList.add(SourceGlimpFragment.getPlugin());
|
||||
pluginsList.add(SourceGlimpPlugin.getPlugin());
|
||||
if (Config.SMSCOMMUNICATORENABLED) pluginsList.add(SmsCommunicatorFragment.getPlugin());
|
||||
|
||||
if (Config.WEAR) pluginsList.add(WearFragment.getPlugin(this));
|
||||
pluginsList.add(StatuslineFragment.getPlugin(this));
|
||||
pluginsList.add(StatuslinePlugin.getPlugin(this));
|
||||
pluginsList.add(new PersistentNotificationPlugin(this));
|
||||
pluginsList.add(NSClientInternalFragment.getPlugin());
|
||||
|
||||
|
|
|
@ -21,6 +21,7 @@ import info.nightscout.androidaps.plugins.NSClientInternal.NSClientInternalPlugi
|
|||
import info.nightscout.androidaps.plugins.OpenAPSAMA.OpenAPSAMAPlugin;
|
||||
import info.nightscout.androidaps.plugins.PumpDanaRv2.DanaRv2Plugin;
|
||||
import info.nightscout.androidaps.plugins.PumpVirtual.VirtualPumpPlugin;
|
||||
import info.nightscout.androidaps.plugins.SensitivityMK.SensitivityMKPlugin;
|
||||
import info.nightscout.androidaps.plugins.Wear.WearPlugin;
|
||||
import info.nightscout.androidaps.plugins.XDripStatusline.StatuslinePlugin;
|
||||
import info.nightscout.utils.LocaleHelper;
|
||||
|
@ -105,6 +106,8 @@ public class PreferencesActivity extends PreferenceActivity implements SharedPre
|
|||
if (MainApp.getSpecificPlugin(OpenAPSAMAPlugin.class) != null && MainApp.getSpecificPlugin(OpenAPSAMAPlugin.class).isEnabled(PluginBase.APS))
|
||||
addPreferencesFromResource(R.xml.pref_openapsama);
|
||||
}
|
||||
if (MainApp.getSpecificPlugin(SensitivityMKPlugin.class) != null && MainApp.getSpecificPlugin(SensitivityMKPlugin.class).isEnabled(PluginBase.SENSITIVITY))
|
||||
addPreferencesFromResource(R.xml.pref_absorption);
|
||||
if (Config.ALLPREFERENCES) {
|
||||
addPreferencesFromResource(R.xml.pref_profile);
|
||||
}
|
||||
|
@ -134,8 +137,8 @@ public class PreferencesActivity extends PreferenceActivity implements SharedPre
|
|||
addPreferencesFromResource(R.xml.pref_smscommunicator);
|
||||
if (Config.ALLPREFERENCES) {
|
||||
addPreferencesFromResource(R.xml.pref_others);
|
||||
addPreferencesFromResource(R.xml.pref_advanced);
|
||||
}
|
||||
addPreferencesFromResource(R.xml.pref_advanced);
|
||||
|
||||
if (Config.WEAR) {
|
||||
WearPlugin wearPlugin = (WearPlugin) MainApp.getSpecificPlugin(WearPlugin.class);
|
||||
|
|
|
@ -10,6 +10,7 @@ import java.util.Date;
|
|||
import java.util.Objects;
|
||||
|
||||
import info.nightscout.androidaps.MainApp;
|
||||
import info.nightscout.androidaps.R;
|
||||
import info.nightscout.androidaps.data.Iob;
|
||||
import info.nightscout.androidaps.data.IobTotal;
|
||||
import info.nightscout.androidaps.data.Profile;
|
||||
|
@ -18,6 +19,7 @@ import info.nightscout.androidaps.interfaces.Interval;
|
|||
import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderPlugin;
|
||||
import info.nightscout.utils.DateUtil;
|
||||
import info.nightscout.utils.DecimalFormatter;
|
||||
import info.nightscout.utils.SP;
|
||||
|
||||
/**
|
||||
* Created by mike on 21.05.2017.
|
||||
|
@ -271,6 +273,15 @@ public class TemporaryBasal implements Interval {
|
|||
|
||||
public String toStringShort() {
|
||||
if (isAbsolute) {
|
||||
if(SP.getBoolean(R.string.key_danar_visualizeextendedaspercentage, false) && SP.getBoolean(R.string.key_danar_useextended, false)){
|
||||
Profile profile = MainApp.getConfigBuilder().getProfile();
|
||||
if(profile != null) {
|
||||
double basal = profile.getBasal(System.currentTimeMillis());
|
||||
if(basal != 0){
|
||||
return Math.round(absoluteRate*100d/basal) + "% ";
|
||||
}
|
||||
}
|
||||
}
|
||||
return DecimalFormatter.to2Decimal(absoluteRate) + "U/h ";
|
||||
} else { // percent
|
||||
return percentRate + "% ";
|
||||
|
|
|
@ -8,7 +8,7 @@ import java.util.Date;
|
|||
public interface PluginBase {
|
||||
int GENERAL = 1;
|
||||
int TREATMENT = 2;
|
||||
//int TEMPBASAL = 3;
|
||||
int SENSITIVITY = 3;
|
||||
int PROFILE = 4;
|
||||
int APS = 5;
|
||||
int PUMP = 6;
|
||||
|
|
|
@ -0,0 +1,11 @@
|
|||
package info.nightscout.androidaps.interfaces;
|
||||
|
||||
import info.nightscout.androidaps.plugins.IobCobCalculator.AutosensResult;
|
||||
|
||||
/**
|
||||
* Created by mike on 24.06.2017.
|
||||
*/
|
||||
|
||||
public interface SensitivityInterface {
|
||||
AutosensResult detectSensitivity(long fromTime, long toTime);
|
||||
}
|
|
@ -169,14 +169,14 @@ public class ActionsFragment extends Fragment implements View.OnClickListener {
|
|||
NewNSTreatmentDialog newDialog = new NewNSTreatmentDialog();
|
||||
final OptionsToShow profileswitch = CareportalFragment.profileswitch;
|
||||
profileswitch.executeProfileSwitch = true;
|
||||
newDialog.setOptions(profileswitch);
|
||||
newDialog.setOptions(profileswitch, R.string.careportal_profileswitch);
|
||||
newDialog.show(manager, "NewNSTreatmentDialog");
|
||||
break;
|
||||
case R.id.actions_temptarget:
|
||||
NewNSTreatmentDialog newTTDialog = new NewNSTreatmentDialog();
|
||||
final OptionsToShow temptarget = CareportalFragment.temptarget;
|
||||
temptarget.executeTempTarget = true;
|
||||
newTTDialog.setOptions(temptarget);
|
||||
newTTDialog.setOptions(temptarget, R.string.careportal_temporarytarget);
|
||||
newTTDialog.show(manager, "NewNSTreatmentDialog");
|
||||
break;
|
||||
case R.id.actions_extendedbolus:
|
||||
|
|
|
@ -100,66 +100,66 @@ public class CareportalFragment extends Fragment implements View.OnClickListener
|
|||
NewNSTreatmentDialog newDialog = new NewNSTreatmentDialog();
|
||||
switch (id) {
|
||||
case R.id.careportal_bgcheck:
|
||||
newDialog.setOptions(bgcheck);
|
||||
newDialog.setOptions(bgcheck, R.string.careportal_bgcheck);
|
||||
break;
|
||||
case R.id.careportal_announcement:
|
||||
newDialog.setOptions(announcement);
|
||||
newDialog.setOptions(announcement, R.string.careportal_announcement);
|
||||
break;
|
||||
case R.id.careportal_cgmsensorinsert:
|
||||
newDialog.setOptions(sensorchange);
|
||||
newDialog.setOptions(sensorchange, R.string.careportal_cgmsensorinsert);
|
||||
break;
|
||||
case R.id.careportal_cgmsensorstart:
|
||||
newDialog.setOptions(sensorstart);
|
||||
newDialog.setOptions(sensorstart, R.string.careportal_cgmsensorstart);
|
||||
break;
|
||||
case R.id.careportal_combobolus:
|
||||
newDialog.setOptions(combobolus);
|
||||
newDialog.setOptions(combobolus, R.string.careportal_combobolus);
|
||||
break;
|
||||
case R.id.careportal_correctionbolus:
|
||||
newDialog.setOptions(correctionbolus);
|
||||
newDialog.setOptions(correctionbolus, R.string.careportal_correctionbolus);
|
||||
break;
|
||||
case R.id.careportal_carbscorrection:
|
||||
newDialog.setOptions(carbcorrection);
|
||||
newDialog.setOptions(carbcorrection, R.string.careportal_carbscorrection);
|
||||
break;
|
||||
case R.id.careportal_exercise:
|
||||
newDialog.setOptions(exercise);
|
||||
newDialog.setOptions(exercise, R.string.careportal_exercise);
|
||||
break;
|
||||
case R.id.careportal_insulincartridgechange:
|
||||
newDialog.setOptions(insulinchange);
|
||||
newDialog.setOptions(insulinchange, R.string.careportal_insulincartridgechange);
|
||||
break;
|
||||
case R.id.careportal_pumpbatterychange:
|
||||
newDialog.setOptions(pumpbatterychange);
|
||||
newDialog.setOptions(pumpbatterychange, R.string.careportal_pumpbatterychange);
|
||||
break;
|
||||
case R.id.careportal_mealbolus:
|
||||
newDialog.setOptions(mealbolus);
|
||||
newDialog.setOptions(mealbolus, R.string.careportal_mealbolus);
|
||||
break;
|
||||
case R.id.careportal_note:
|
||||
newDialog.setOptions(note);
|
||||
newDialog.setOptions(note, R.string.careportal_note);
|
||||
break;
|
||||
case R.id.careportal_profileswitch:
|
||||
profileswitch.executeProfileSwitch = false;
|
||||
newDialog.setOptions(profileswitch);
|
||||
newDialog.setOptions(profileswitch, R.string.careportal_profileswitch);
|
||||
break;
|
||||
case R.id.careportal_pumpsitechange:
|
||||
newDialog.setOptions(sitechange);
|
||||
newDialog.setOptions(sitechange, R.string.careportal_pumpsitechange);
|
||||
break;
|
||||
case R.id.careportal_question:
|
||||
newDialog.setOptions(question);
|
||||
newDialog.setOptions(question, R.string.careportal_question);
|
||||
break;
|
||||
case R.id.careportal_snackbolus:
|
||||
newDialog.setOptions(snackbolus);
|
||||
newDialog.setOptions(snackbolus, R.string.careportal_snackbolus);
|
||||
break;
|
||||
case R.id.careportal_tempbasalstart:
|
||||
newDialog.setOptions(tempbasalstart);
|
||||
newDialog.setOptions(tempbasalstart, R.string.careportal_tempbasalstart);
|
||||
break;
|
||||
case R.id.careportal_tempbasalend:
|
||||
newDialog.setOptions(tempbasalend);
|
||||
newDialog.setOptions(tempbasalend, R.string.careportal_tempbasalend);
|
||||
break;
|
||||
case R.id.careportal_openapsoffline:
|
||||
newDialog.setOptions(openapsoffline);
|
||||
newDialog.setOptions(openapsoffline, R.string.careportal_openapsoffline);
|
||||
break;
|
||||
case R.id.careportal_temporarytarget:
|
||||
temptarget.executeTempTarget = false;
|
||||
newDialog.setOptions(temptarget);
|
||||
newDialog.setOptions(temptarget, R.string.careportal_temporarytarget);
|
||||
break;
|
||||
default:
|
||||
newDialog = null;
|
||||
|
|
|
@ -15,12 +15,10 @@ import android.view.LayoutInflater;
|
|||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.ArrayAdapter;
|
||||
import android.widget.Button;
|
||||
import android.widget.CompoundButton;
|
||||
import android.widget.EditText;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.RadioButton;
|
||||
import android.widget.RelativeLayout;
|
||||
import android.widget.Spinner;
|
||||
import android.widget.TextView;
|
||||
|
||||
|
@ -44,6 +42,8 @@ import info.nightscout.androidaps.Constants;
|
|||
import info.nightscout.androidaps.MainApp;
|
||||
import info.nightscout.androidaps.R;
|
||||
import info.nightscout.androidaps.data.GlucoseStatus;
|
||||
import info.nightscout.androidaps.data.Profile;
|
||||
import info.nightscout.androidaps.data.ProfileStore;
|
||||
import info.nightscout.androidaps.db.CareportalEvent;
|
||||
import info.nightscout.androidaps.db.ProfileSwitch;
|
||||
import info.nightscout.androidaps.db.Source;
|
||||
|
@ -52,12 +52,10 @@ import info.nightscout.androidaps.events.EventNewBasalProfile;
|
|||
import info.nightscout.androidaps.interfaces.PumpInterface;
|
||||
import info.nightscout.androidaps.plugins.Careportal.OptionsToShow;
|
||||
import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderPlugin;
|
||||
import info.nightscout.androidaps.data.Profile;
|
||||
import info.nightscout.androidaps.data.ProfileStore;
|
||||
import info.nightscout.androidaps.plugins.ProfileCircadianPercentage.CircadianPercentageProfilePlugin;
|
||||
import info.nightscout.utils.DateUtil;
|
||||
import info.nightscout.utils.NSUpload;
|
||||
import info.nightscout.utils.PlusMinusEditText;
|
||||
import info.nightscout.utils.NumberPicker;
|
||||
import info.nightscout.utils.SP;
|
||||
import info.nightscout.utils.SafeParse;
|
||||
import info.nightscout.utils.Translator;
|
||||
|
@ -68,53 +66,44 @@ public class NewNSTreatmentDialog extends DialogFragment implements View.OnClick
|
|||
private Activity context;
|
||||
|
||||
private static OptionsToShow options;
|
||||
private static String event;
|
||||
|
||||
Profile profile;
|
||||
ProfileStore profileStore;
|
||||
String units;
|
||||
|
||||
RelativeLayout layoutBg;
|
||||
TextView eventTypeText;
|
||||
LinearLayout layoutBg;
|
||||
LinearLayout layoutBgSource;
|
||||
RelativeLayout layoutInsulin;
|
||||
RelativeLayout layoutCarbs;
|
||||
RelativeLayout layoutSplit;
|
||||
RelativeLayout layoutDuration;
|
||||
RelativeLayout layoutPercent;
|
||||
RelativeLayout layoutAbsolute;
|
||||
RelativeLayout layoutCarbTime;
|
||||
RelativeLayout layoutProfile;
|
||||
LinearLayout layoutInsulin;
|
||||
LinearLayout layoutCarbs;
|
||||
LinearLayout layoutSplit;
|
||||
LinearLayout layoutDuration;
|
||||
LinearLayout layoutPercent;
|
||||
LinearLayout layoutAbsolute;
|
||||
LinearLayout layoutCarbTime;
|
||||
LinearLayout layoutProfile;
|
||||
LinearLayout layoutTempTarget;
|
||||
Button dateButton;
|
||||
Button timeButton;
|
||||
Button okButton;
|
||||
Button cancelButton;
|
||||
TextView dateButton;
|
||||
TextView timeButton;
|
||||
|
||||
TextView bgUnitsView;
|
||||
RadioButton meterRadioButton;
|
||||
RadioButton sensorRadioButton;
|
||||
RadioButton otherRadioButton;
|
||||
EditText notesEdit;
|
||||
EditText bgInputEdit;
|
||||
EditText insulinEdit;
|
||||
EditText carbsEdit;
|
||||
EditText percentEdit;
|
||||
EditText absoluteEdit;
|
||||
EditText durationeEdit;
|
||||
EditText carbTimeEdit;
|
||||
EditText splitEdit;
|
||||
Spinner profileSpinner;
|
||||
EditText low;
|
||||
EditText high;
|
||||
Spinner reasonSpinner;
|
||||
|
||||
PlusMinusEditText editBg;
|
||||
PlusMinusEditText editCarbs;
|
||||
PlusMinusEditText editInsulin;
|
||||
PlusMinusEditText editSplit;
|
||||
PlusMinusEditText editDuration;
|
||||
PlusMinusEditText editPercent;
|
||||
PlusMinusEditText editAbsolute;
|
||||
PlusMinusEditText editCarbTime;
|
||||
NumberPicker editBg;
|
||||
NumberPicker editCarbs;
|
||||
NumberPicker editInsulin;
|
||||
NumberPicker editSplit;
|
||||
NumberPicker editDuration;
|
||||
NumberPicker editPercent;
|
||||
NumberPicker editAbsolute;
|
||||
NumberPicker editCarbTime;
|
||||
NumberPicker editTemptarget;
|
||||
|
||||
Date eventTime;
|
||||
|
||||
|
@ -122,8 +111,9 @@ public class NewNSTreatmentDialog extends DialogFragment implements View.OnClick
|
|||
private static HandlerThread sHandlerThread;
|
||||
|
||||
|
||||
public void setOptions(OptionsToShow options) {
|
||||
public void setOptions(OptionsToShow options, int event) {
|
||||
this.options = options;
|
||||
this.event = MainApp.sResources.getString(event);
|
||||
}
|
||||
|
||||
public NewNSTreatmentDialog() {
|
||||
|
@ -154,88 +144,44 @@ public class NewNSTreatmentDialog extends DialogFragment implements View.OnClick
|
|||
setStyle(DialogFragment.STYLE_NORMAL, getTheme());
|
||||
View view = inflater.inflate(R.layout.careportal_newnstreatment_dialog, container, false);
|
||||
|
||||
layoutBg = (RelativeLayout) view.findViewById(R.id.careportal_newnstreatment_bg_layout);
|
||||
layoutBg = (LinearLayout) view.findViewById(R.id.careportal_newnstreatment_bg_layout);
|
||||
layoutBgSource = (LinearLayout) view.findViewById(R.id.careportal_newnstreatment_bgsource_layout);
|
||||
layoutInsulin = (RelativeLayout) view.findViewById(R.id.careportal_newnstreatment_insulin_layout);
|
||||
layoutCarbs = (RelativeLayout) view.findViewById(R.id.careportal_newnstreatment_carbs_layout);
|
||||
layoutSplit = (RelativeLayout) view.findViewById(R.id.careportal_newnstreatment_split_layout);
|
||||
layoutDuration = (RelativeLayout) view.findViewById(R.id.careportal_newnstreatment_duration_layout);
|
||||
layoutPercent = (RelativeLayout) view.findViewById(R.id.careportal_newnstreatment_percent_layout);
|
||||
layoutAbsolute = (RelativeLayout) view.findViewById(R.id.careportal_newnstreatment_absolute_layout);
|
||||
layoutCarbTime = (RelativeLayout) view.findViewById(R.id.careportal_newnstreatment_carbtime_layout);
|
||||
layoutProfile = (RelativeLayout) view.findViewById(R.id.careportal_newnstreatment_profile_layout);
|
||||
layoutInsulin = (LinearLayout) view.findViewById(R.id.careportal_newnstreatment_insulin_layout);
|
||||
layoutCarbs = (LinearLayout) view.findViewById(R.id.careportal_newnstreatment_carbs_layout);
|
||||
layoutSplit = (LinearLayout) view.findViewById(R.id.careportal_newnstreatment_split_layout);
|
||||
layoutDuration = (LinearLayout) view.findViewById(R.id.careportal_newnstreatment_duration_layout);
|
||||
layoutPercent = (LinearLayout) view.findViewById(R.id.careportal_newnstreatment_percent_layout);
|
||||
layoutAbsolute = (LinearLayout) view.findViewById(R.id.careportal_newnstreatment_absolute_layout);
|
||||
layoutCarbTime = (LinearLayout) view.findViewById(R.id.careportal_newnstreatment_carbtime_layout);
|
||||
layoutProfile = (LinearLayout) view.findViewById(R.id.careportal_newnstreatment_profile_layout);
|
||||
layoutTempTarget = (LinearLayout) view.findViewById(R.id.careportal_newnstreatment_temptarget_layout);
|
||||
|
||||
eventTypeText = (TextView) view.findViewById(R.id.careportal_newnstreatment_eventtype);
|
||||
eventTypeText.setText(event);
|
||||
bgUnitsView = (TextView) view.findViewById(R.id.careportal_newnstreatment_bgunits);
|
||||
meterRadioButton = (RadioButton) view.findViewById(R.id.careportal_newnstreatment_meter);
|
||||
sensorRadioButton = (RadioButton) view.findViewById(R.id.careportal_newnstreatment_sensor);
|
||||
otherRadioButton = (RadioButton) view.findViewById(R.id.careportal_newnstreatment_other);
|
||||
profileSpinner = (Spinner) view.findViewById(R.id.careportal_newnstreatment_profile);
|
||||
|
||||
bgInputEdit = (EditText) view.findViewById(R.id.careportal_newnstreatment_bginput);
|
||||
insulinEdit = (EditText) view.findViewById(R.id.careportal_newnstreatment_insulininput);
|
||||
carbsEdit = (EditText) view.findViewById(R.id.careportal_newnstreatment_carbsinput);
|
||||
percentEdit = (EditText) view.findViewById(R.id.careportal_newnstreatment_percentinput);
|
||||
percentEdit.addTextChangedListener(new TextWatcher() {
|
||||
@Override
|
||||
public void afterTextChanged(Editable s) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void beforeTextChanged(CharSequence s, int start,
|
||||
int count, int after) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onTextChanged(CharSequence s, int start,
|
||||
int before, int count) {
|
||||
layoutPercent.setVisibility(View.VISIBLE);
|
||||
layoutAbsolute.setVisibility(View.GONE);
|
||||
}
|
||||
});
|
||||
absoluteEdit = (EditText) view.findViewById(R.id.careportal_newnstreatment_absoluteinput);
|
||||
absoluteEdit.addTextChangedListener(new TextWatcher() {
|
||||
@Override
|
||||
public void afterTextChanged(Editable s) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void beforeTextChanged(CharSequence s, int start,
|
||||
int count, int after) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onTextChanged(CharSequence s, int start,
|
||||
int before, int count) {
|
||||
layoutPercent.setVisibility(View.GONE);
|
||||
layoutAbsolute.setVisibility(View.VISIBLE);
|
||||
}
|
||||
});
|
||||
durationeEdit = (EditText) view.findViewById(R.id.careportal_newnstreatment_durationinput);
|
||||
carbTimeEdit = (EditText) view.findViewById(R.id.careportal_newnstreatment_carbtimeinput);
|
||||
notesEdit = (EditText) view.findViewById(R.id.careportal_newnstreatment_notes);
|
||||
splitEdit = (EditText) view.findViewById(R.id.careportal_newnstreatment_splitinput);
|
||||
|
||||
reasonSpinner = (Spinner) view.findViewById(R.id.careportal_newnstreatment_temptarget_reason);
|
||||
low = (EditText) view.findViewById(R.id.careportal_temptarget_low);
|
||||
high = (EditText) view.findViewById(R.id.careportal_temptarget_high);
|
||||
|
||||
eventTime = new Date();
|
||||
dateButton = (Button) view.findViewById(R.id.careportal_newnstreatment_eventdate);
|
||||
timeButton = (Button) view.findViewById(R.id.careportal_newnstreatment_eventtime);
|
||||
dateButton = (TextView) view.findViewById(R.id.careportal_newnstreatment_eventdate);
|
||||
timeButton = (TextView) view.findViewById(R.id.careportal_newnstreatment_eventtime);
|
||||
dateButton.setText(DateUtil.dateString(eventTime));
|
||||
timeButton.setText(DateUtil.timeString(eventTime));
|
||||
dateButton.setOnClickListener(this);
|
||||
timeButton.setOnClickListener(this);
|
||||
|
||||
okButton = (Button) view.findViewById(R.id.ok);
|
||||
okButton.setOnClickListener(this);
|
||||
cancelButton = (Button) view.findViewById(R.id.cancel);
|
||||
cancelButton.setOnClickListener(this);
|
||||
view.findViewById(R.id.ok).setOnClickListener(this);
|
||||
view.findViewById(R.id.cancel).setOnClickListener(this);
|
||||
|
||||
// profile
|
||||
profile = MainApp.getConfigBuilder().getProfile();
|
||||
profileStore = MainApp.getConfigBuilder().getActiveProfileInterface().getProfile();
|
||||
profileStore = ConfigBuilderPlugin.getActiveProfileInterface().getProfile();
|
||||
ArrayList<CharSequence> profileList;
|
||||
units = profile.getUnits();
|
||||
profileList = profileStore.getProfileList();
|
||||
|
@ -260,25 +206,20 @@ public class NewNSTreatmentDialog extends DialogFragment implements View.OnClick
|
|||
// bg
|
||||
bgUnitsView.setText(units);
|
||||
|
||||
// Set BG if not old
|
||||
// BgReading lastBg = MainApp.getDbHelper().lastBg();
|
||||
// Double lastBgValue = 0d;
|
||||
// if (lastBg != null) {
|
||||
// lastBgValue = lastBg.valueToUnits(units);
|
||||
// sensorRadioButton.setChecked(true);
|
||||
// } else {
|
||||
// meterRadioButton.setChecked(true);
|
||||
// }
|
||||
|
||||
Double bg = Profile.fromMgdlToUnits(GlucoseStatus.getGlucoseStatusData() != null ? GlucoseStatus.getGlucoseStatusData().glucose : 0d, profile != null ? profile.getUnits() : Constants.MGDL);
|
||||
if (profile == null)
|
||||
editBg = new PlusMinusEditText(view, R.id.careportal_newnstreatment_bginput, R.id.careportal_newnstreatment_bg_plus, R.id.careportal_newnstreatment_bg_minus, bg, 0d, 500d, 0.1d, new DecimalFormat("0.0"), false);
|
||||
else if (profile.getUnits().equals(Constants.MMOL))
|
||||
editBg = new PlusMinusEditText(view, R.id.careportal_newnstreatment_bginput, R.id.careportal_newnstreatment_bg_plus, R.id.careportal_newnstreatment_bg_minus, bg, 0d, 30d, 0.1d, new DecimalFormat("0.0"), false);
|
||||
else
|
||||
editBg = new PlusMinusEditText(view, R.id.careportal_newnstreatment_bginput, R.id.careportal_newnstreatment_bg_plus, R.id.careportal_newnstreatment_bg_minus, bg, 0d, 500d, 1d, new DecimalFormat("0"), false);
|
||||
bgInputEdit.addTextChangedListener(new TextWatcher() {
|
||||
|
||||
editBg = (NumberPicker) view.findViewById(R.id.careportal_newnstreatment_bginput);
|
||||
editTemptarget = (NumberPicker) view.findViewById(R.id.careportal_newnstreatment_temptarget);
|
||||
if (profile == null) {
|
||||
editBg.setParams(bg, 0d, 500d, 0.1d, new DecimalFormat("0.0"), false);
|
||||
editTemptarget.setParams(bg, 0d, 500d, 0.1d, new DecimalFormat("0.0"), false);
|
||||
} else if (profile.getUnits().equals(Constants.MMOL)) {
|
||||
editBg.setParams(bg, 0d, 30d, 0.1d, new DecimalFormat("0.0"), false);
|
||||
editTemptarget.setParams(bg, 0d, 30d, 0.1d, new DecimalFormat("0.0"), false);
|
||||
} else {
|
||||
editBg.setParams(bg, 0d, 500d, 1d, new DecimalFormat("0"), false);
|
||||
editTemptarget.setParams(bg, 0d, 500d, 1d, new DecimalFormat("0"), false);
|
||||
}
|
||||
editBg.addTextChangedListener(new TextWatcher() {
|
||||
public void afterTextChanged(Editable s) {
|
||||
}
|
||||
|
||||
|
@ -289,6 +230,7 @@ public class NewNSTreatmentDialog extends DialogFragment implements View.OnClick
|
|||
if (sensorRadioButton.isChecked()) meterRadioButton.setChecked(true);
|
||||
}
|
||||
});
|
||||
|
||||
sensorRadioButton.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
|
||||
@Override
|
||||
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
|
||||
|
@ -298,21 +240,63 @@ public class NewNSTreatmentDialog extends DialogFragment implements View.OnClick
|
|||
});
|
||||
|
||||
Integer maxCarbs = MainApp.getConfigBuilder().applyCarbsConstraints(Constants.carbsOnlyForCheckLimit);
|
||||
editCarbs = new PlusMinusEditText(view, R.id.careportal_newnstreatment_carbsinput, R.id.careportal_newnstreatment_carbs_plus, R.id.careportal_newnstreatment_carbs_minus, 0d, 0d, (double) maxCarbs, 1d, new DecimalFormat("0"), false);
|
||||
editCarbs = (NumberPicker) view.findViewById(R.id.careportal_newnstreatment_carbsinput);
|
||||
editCarbs.setParams(0d, 0d, (double) maxCarbs, 1d, new DecimalFormat("0"), false);
|
||||
|
||||
Double maxInsulin = MainApp.getConfigBuilder().applyBolusConstraints(Constants.bolusOnlyForCheckLimit);
|
||||
editInsulin = new PlusMinusEditText(view, R.id.careportal_newnstreatment_insulininput, R.id.careportal_newnstreatment_insulin_plus, R.id.careportal_newnstreatment_insulin_minus, 0d, 0d, maxInsulin, 0.05d, new DecimalFormat("0.00"), false);
|
||||
editInsulin = (NumberPicker) view.findViewById(R.id.careportal_newnstreatment_insulininput);
|
||||
editInsulin.setParams(0d, 0d, maxInsulin, 0.05d, new DecimalFormat("0.00"), false);
|
||||
|
||||
editSplit = new PlusMinusEditText(view, R.id.careportal_newnstreatment_splitinput, R.id.careportal_newnstreatment_split_plus, R.id.careportal_newnstreatment_split_minus, 100d, 0d, 100d, 5d, new DecimalFormat("0"), true);
|
||||
editDuration = new PlusMinusEditText(view, R.id.careportal_newnstreatment_durationinput, R.id.careportal_newnstreatment_duration_plus, R.id.careportal_newnstreatment_duration_minus, 0d, 0d, 24 * 60d, 10d, new DecimalFormat("0"), false);
|
||||
editSplit = (NumberPicker) view.findViewById(R.id.careportal_newnstreatment_splitinput);
|
||||
editSplit.setParams(100d, 0d, 100d, 5d, new DecimalFormat("0"), true);
|
||||
editDuration = (NumberPicker) view.findViewById(R.id.careportal_newnstreatment_durationinput);
|
||||
editDuration.setParams(0d, 0d, 24 * 60d, 10d, new DecimalFormat("0"), false);
|
||||
|
||||
Integer maxPercent = MainApp.getConfigBuilder().applyBasalConstraints(Constants.basalPercentOnlyForCheckLimit);
|
||||
editPercent = new PlusMinusEditText(view, R.id.careportal_newnstreatment_percentinput, R.id.careportal_newnstreatment_percent_plus, R.id.careportal_newnstreatment_percent_minus, 0d, 0d, (double) maxPercent, 5d, new DecimalFormat("0"), true);
|
||||
editPercent = (NumberPicker) view.findViewById(R.id.careportal_newnstreatment_percentinput);
|
||||
editPercent.setParams(0d, 0d, (double) maxPercent, 5d, new DecimalFormat("0"), true);
|
||||
editPercent.addTextChangedListener(new TextWatcher() {
|
||||
@Override
|
||||
public void afterTextChanged(Editable s) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void beforeTextChanged(CharSequence s, int start,
|
||||
int count, int after) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onTextChanged(CharSequence s, int start,
|
||||
int before, int count) {
|
||||
layoutPercent.setVisibility(View.VISIBLE);
|
||||
layoutAbsolute.setVisibility(View.GONE);
|
||||
}
|
||||
});
|
||||
|
||||
Double maxAbsolute = MainApp.getConfigBuilder().applyBasalConstraints(Constants.basalAbsoluteOnlyForCheckLimit);
|
||||
editAbsolute = new PlusMinusEditText(view, R.id.careportal_newnstreatment_absoluteinput, R.id.careportal_newnstreatment_absolute_plus, R.id.careportal_newnstreatment_absolute_minus, 0d, 0d, maxAbsolute, 0.05d, new DecimalFormat("0.00"), true);
|
||||
editAbsolute = (NumberPicker) view.findViewById(R.id.careportal_newnstreatment_absoluteinput);
|
||||
editAbsolute.setParams(0d, 0d, maxAbsolute, 0.05d, new DecimalFormat("0.00"), true);
|
||||
editAbsolute.addTextChangedListener(new TextWatcher() {
|
||||
@Override
|
||||
public void afterTextChanged(Editable s) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void beforeTextChanged(CharSequence s, int start,
|
||||
int count, int after) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onTextChanged(CharSequence s, int start,
|
||||
int before, int count) {
|
||||
layoutPercent.setVisibility(View.GONE);
|
||||
layoutAbsolute.setVisibility(View.VISIBLE);
|
||||
}
|
||||
});
|
||||
|
||||
editCarbTime = (NumberPicker) view.findViewById(R.id.careportal_newnstreatment_carbtimeinput);
|
||||
editCarbTime.setParams(0d, -60d, 60d, 5d, new DecimalFormat("0"), false);
|
||||
|
||||
editCarbTime = new PlusMinusEditText(view, R.id.careportal_newnstreatment_carbtimeinput, R.id.careportal_newnstreatment_carbtime_plus, R.id.careportal_newnstreatment_carbtime_minus, 0d, -60d, 60d, 5d, new DecimalFormat("0"), false);
|
||||
|
||||
showOrHide(layoutBg, options.bg);
|
||||
showOrHide(layoutBgSource, options.bg);
|
||||
|
@ -329,13 +313,6 @@ public class NewNSTreatmentDialog extends DialogFragment implements View.OnClick
|
|||
return view;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onResume() {
|
||||
super.onResume();
|
||||
if (getDialog() != null)
|
||||
getDialog().getWindow().setLayout(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
Calendar calendar = Calendar.getInstance();
|
||||
|
@ -353,7 +330,6 @@ public class NewNSTreatmentDialog extends DialogFragment implements View.OnClick
|
|||
dpd.show(context.getFragmentManager(), "Datepickerdialog");
|
||||
break;
|
||||
case R.id.careportal_newnstreatment_eventtime:
|
||||
android.text.format.DateFormat df = new android.text.format.DateFormat();
|
||||
TimePickerDialog tpd = TimePickerDialog.newInstance(
|
||||
this,
|
||||
calendar.get(Calendar.HOUR_OF_DAY),
|
||||
|
@ -417,8 +393,8 @@ public class NewNSTreatmentDialog extends DialogFragment implements View.OnClick
|
|||
data.put("eventType", "Sensor Start");
|
||||
break;
|
||||
case R.id.careportal_combobolus:
|
||||
data.put("splitNow", SafeParse.stringToDouble(splitEdit.getText().toString()));
|
||||
data.put("splitExt", 100 - SafeParse.stringToDouble(splitEdit.getText().toString()));
|
||||
data.put("splitNow", SafeParse.stringToDouble(editSplit.getText()));
|
||||
data.put("splitExt", 100 - SafeParse.stringToDouble(editSplit.getText()));
|
||||
data.put("eventType", CareportalEvent.COMBOBOLUS);
|
||||
break;
|
||||
case R.id.careportal_correctionbolus:
|
||||
|
@ -468,42 +444,42 @@ public class NewNSTreatmentDialog extends DialogFragment implements View.OnClick
|
|||
data.put("eventType", CareportalEvent.TEMPORARYTARGET);
|
||||
if (!reasonSpinner.getSelectedItem().toString().equals(""))
|
||||
data.put("reason", reasonSpinner.getSelectedItem().toString());
|
||||
if (SafeParse.stringToDouble(low.getText().toString()) != 0d)
|
||||
data.put("targetBottom", SafeParse.stringToDouble(low.getText().toString()));
|
||||
if (SafeParse.stringToDouble(high.getText().toString()) != 0d)
|
||||
data.put("targetTop", SafeParse.stringToDouble(high.getText().toString()));
|
||||
if (SafeParse.stringToDouble(editTemptarget.getText()) != 0d) {
|
||||
data.put("targetBottom", SafeParse.stringToDouble(editTemptarget.getText()));
|
||||
data.put("targetTop", SafeParse.stringToDouble(editTemptarget.getText()));
|
||||
}
|
||||
allowZeroDuration = true;
|
||||
break;
|
||||
}
|
||||
if (SafeParse.stringToDouble(bgInputEdit.getText().toString()) != 0d) {
|
||||
data.put("glucose", SafeParse.stringToDouble(bgInputEdit.getText().toString()));
|
||||
if (SafeParse.stringToDouble(editBg.getText()) != 0d) {
|
||||
data.put("glucose", SafeParse.stringToDouble(editBg.getText()));
|
||||
if (meterRadioButton.isChecked()) data.put("glucoseType", "Finger");
|
||||
if (sensorRadioButton.isChecked()) data.put("glucoseType", "Sensor");
|
||||
if (otherRadioButton.isChecked()) data.put("glucoseType", "Manual");
|
||||
}
|
||||
if (SafeParse.stringToDouble(carbsEdit.getText().toString()) != 0d)
|
||||
data.put("carbs", SafeParse.stringToDouble(carbsEdit.getText().toString()));
|
||||
if (SafeParse.stringToDouble(insulinEdit.getText().toString()) != 0d)
|
||||
data.put("insulin", SafeParse.stringToDouble(insulinEdit.getText().toString()));
|
||||
if (allowZeroDuration || SafeParse.stringToDouble(durationeEdit.getText().toString()) != 0d)
|
||||
data.put("duration", SafeParse.stringToDouble(durationeEdit.getText().toString()));
|
||||
if (SafeParse.stringToDouble(editCarbs.getText()) != 0d)
|
||||
data.put("carbs", SafeParse.stringToDouble(editCarbs.getText()));
|
||||
if (SafeParse.stringToDouble(editInsulin.getText()) != 0d)
|
||||
data.put("insulin", SafeParse.stringToDouble(editInsulin.getText()));
|
||||
if (allowZeroDuration || SafeParse.stringToDouble(editDuration.getText()) != 0d)
|
||||
data.put("duration", SafeParse.stringToDouble(editDuration.getText()));
|
||||
if (layoutPercent.getVisibility() != View.GONE)
|
||||
data.put("percent", SafeParse.stringToDouble(percentEdit.getText().toString()));
|
||||
data.put("percent", SafeParse.stringToDouble(editPercent.getText()));
|
||||
if (layoutAbsolute.getVisibility() != View.GONE)
|
||||
data.put("absolute", SafeParse.stringToDouble(absoluteEdit.getText().toString()));
|
||||
data.put("absolute", SafeParse.stringToDouble(editAbsolute.getText()));
|
||||
if (options.profile && profileSpinner.getSelectedItem() != null)
|
||||
data.put("profile", profileSpinner.getSelectedItem().toString());
|
||||
if (SafeParse.stringToDouble(carbTimeEdit.getText().toString()) != 0d)
|
||||
data.put("preBolus", SafeParse.stringToDouble(carbTimeEdit.getText().toString()));
|
||||
if (SafeParse.stringToDouble(editCarbTime.getText()) != 0d)
|
||||
data.put("preBolus", SafeParse.stringToDouble(editCarbTime.getText()));
|
||||
if (!notesEdit.getText().toString().equals(""))
|
||||
data.put("notes", notesEdit.getText().toString());
|
||||
data.put("units", units);
|
||||
if (!enteredBy.equals("")) data.put("enteredBy", enteredBy);
|
||||
if (options.eventType == R.id.careportal_combobolus) {
|
||||
Double enteredInsulin = SafeParse.stringToDouble(insulinEdit.getText().toString());
|
||||
Double enteredInsulin = SafeParse.stringToDouble(editInsulin.getText());
|
||||
data.put("enteredinsulin", enteredInsulin);
|
||||
data.put("insulin", enteredInsulin * SafeParse.stringToDouble(splitEdit.getText().toString()) / 100);
|
||||
data.put("relative", enteredInsulin * (100 - SafeParse.stringToDouble(splitEdit.getText().toString())) / 100 / SafeParse.stringToDouble(durationeEdit.getText().toString()) * 60);
|
||||
data.put("insulin", enteredInsulin * SafeParse.stringToDouble(editInsulin.getText()) / 100);
|
||||
data.put("relative", enteredInsulin * (100 - SafeParse.stringToDouble(editSplit.getText())) / 100 / SafeParse.stringToDouble(editDuration.getText()) * 60);
|
||||
}
|
||||
} catch (JSONException e) {
|
||||
e.printStackTrace();
|
||||
|
|
|
@ -34,9 +34,11 @@ import info.nightscout.androidaps.interfaces.InsulinInterface;
|
|||
import info.nightscout.androidaps.interfaces.PluginBase;
|
||||
import info.nightscout.androidaps.interfaces.ProfileInterface;
|
||||
import info.nightscout.androidaps.interfaces.PumpInterface;
|
||||
import info.nightscout.androidaps.interfaces.SensitivityInterface;
|
||||
import info.nightscout.androidaps.plugins.InsulinFastacting.InsulinFastactingPlugin;
|
||||
import info.nightscout.androidaps.plugins.ProfileNS.NSProfilePlugin;
|
||||
import info.nightscout.androidaps.plugins.PumpVirtual.VirtualPumpPlugin;
|
||||
import info.nightscout.androidaps.plugins.SensitivityOref0.SensitivityOref0Plugin;
|
||||
import info.nightscout.utils.PasswordProtection;
|
||||
|
||||
|
||||
|
@ -49,6 +51,7 @@ public class ConfigBuilderFragment extends Fragment {
|
|||
}
|
||||
|
||||
ListView insulinListView;
|
||||
ListView sensitivityListView;
|
||||
ListView bgsourceListView;
|
||||
TextView bgsourceLabel;
|
||||
ListView pumpListView;
|
||||
|
@ -64,13 +67,12 @@ public class ConfigBuilderFragment extends Fragment {
|
|||
ListView constraintsListView;
|
||||
TextView constraintsLabel;
|
||||
ListView generalListView;
|
||||
TextView nsclientVerView;
|
||||
TextView nightscoutVerView;
|
||||
|
||||
LinearLayout mainLayout;
|
||||
Button unlock;
|
||||
|
||||
PluginCustomAdapter insulinDataAdapter = null;
|
||||
PluginCustomAdapter sensivityDataAdapter = null;
|
||||
PluginCustomAdapter bgsourceDataAdapter = null;
|
||||
PluginCustomAdapter pumpDataAdapter = null;
|
||||
PluginCustomAdapter loopDataAdapter = null;
|
||||
|
@ -96,6 +98,7 @@ public class ConfigBuilderFragment extends Fragment {
|
|||
smallWidth = screen_width < Constants.SMALL_WIDTH;
|
||||
|
||||
insulinListView = (ListView) view.findViewById(R.id.configbuilder_insulinlistview);
|
||||
sensitivityListView = (ListView) view.findViewById(R.id.configbuilder_sensitivitylistview);
|
||||
bgsourceListView = (ListView) view.findViewById(R.id.configbuilder_bgsourcelistview);
|
||||
bgsourceLabel = (TextView) view.findViewById(R.id.configbuilder_bgsourcelabel);
|
||||
pumpListView = (ListView) view.findViewById(R.id.configbuilder_pumplistview);
|
||||
|
@ -111,17 +114,10 @@ public class ConfigBuilderFragment extends Fragment {
|
|||
constraintsListView = (ListView) view.findViewById(R.id.configbuilder_constraintslistview);
|
||||
constraintsLabel = (TextView) view.findViewById(R.id.configbuilder_constraintslabel);
|
||||
generalListView = (ListView) view.findViewById(R.id.configbuilder_generallistview);
|
||||
nsclientVerView = (TextView) view.findViewById(R.id.configbuilder_nsclientversion);
|
||||
nightscoutVerView = (TextView) view.findViewById(R.id.configbuilder_nightscoutversion);
|
||||
|
||||
mainLayout = (LinearLayout) view.findViewById(R.id.configbuilder_mainlayout);
|
||||
unlock = (Button) view.findViewById(R.id.configbuilder_unlock);
|
||||
|
||||
nsclientVerView.setText(ConfigBuilderPlugin.nsClientVersionName);
|
||||
nightscoutVerView.setText(ConfigBuilderPlugin.nightscoutVersionName);
|
||||
if (ConfigBuilderPlugin.nsClientVersionCode < 117) nsclientVerView.setTextColor(Color.RED);
|
||||
if (ConfigBuilderPlugin.nightscoutVersionCode < 900)
|
||||
nightscoutVerView.setTextColor(Color.RED);
|
||||
setViews();
|
||||
|
||||
if (PasswordProtection.isLocked("settings_password")) {
|
||||
|
@ -178,6 +174,9 @@ public class ConfigBuilderFragment extends Fragment {
|
|||
setListViewHeightBasedOnChildren(apsListView);
|
||||
if (MainApp.getSpecificPluginsVisibleInList(PluginBase.APS).size() == 0)
|
||||
apsLabel.setVisibility(View.GONE);
|
||||
sensivityDataAdapter = new PluginCustomAdapter(getContext(), smallWidth?R.layout.configbuilder_smallitem :R.layout.configbuilder_simpleitem, MainApp.getSpecificPluginsVisibleInListByInterface(SensitivityInterface.class, PluginBase.SENSITIVITY), PluginBase.SENSITIVITY);
|
||||
sensitivityListView.setAdapter(sensivityDataAdapter);
|
||||
setListViewHeightBasedOnChildren(sensitivityListView);
|
||||
constraintsDataAdapter = new PluginCustomAdapter(getContext(), smallWidth?R.layout.configbuilder_smallitem :R.layout.configbuilder_simpleitem, MainApp.getSpecificPluginsVisibleInListByInterface(ConstraintsInterface.class, PluginBase.BGSOURCE), PluginBase.CONSTRAINTS);
|
||||
constraintsListView.setAdapter(constraintsDataAdapter);
|
||||
setListViewHeightBasedOnChildren(constraintsListView);
|
||||
|
@ -277,7 +276,7 @@ public class ConfigBuilderFragment extends Fragment {
|
|||
}
|
||||
|
||||
// Hide enabled control and force enabled plugin if there is only one plugin available
|
||||
if (type == PluginBase.INSULIN || type == PluginBase.PUMP || type == PluginBase.TREATMENT || type == PluginBase.PROFILE)
|
||||
if (type == PluginBase.INSULIN || type == PluginBase.PUMP || type == PluginBase.TREATMENT || type == PluginBase.PROFILE || type == PluginBase.SENSITIVITY)
|
||||
if (pluginList.size() < 2) {
|
||||
holder.checkboxEnabled.setEnabled(false);
|
||||
plugin.setFragmentEnabled(type, true);
|
||||
|
@ -326,6 +325,9 @@ public class ConfigBuilderFragment extends Fragment {
|
|||
case PluginBase.INSULIN:
|
||||
pluginsInCategory = MainApp.getSpecificPluginsListByInterface(InsulinInterface.class);
|
||||
break;
|
||||
case PluginBase.SENSITIVITY:
|
||||
pluginsInCategory = MainApp.getSpecificPluginsListByInterface(SensitivityInterface.class);
|
||||
break;
|
||||
case PluginBase.APS:
|
||||
pluginsInCategory = MainApp.getSpecificPluginsListByInterface(APSInterface.class);
|
||||
break;
|
||||
|
@ -356,6 +358,8 @@ public class ConfigBuilderFragment extends Fragment {
|
|||
MainApp.getSpecificPlugin(VirtualPumpPlugin.class).setFragmentEnabled(type, true);
|
||||
else if (type == PluginBase.INSULIN)
|
||||
MainApp.getSpecificPlugin(InsulinFastactingPlugin.class).setFragmentEnabled(type, true);
|
||||
else if (type == PluginBase.SENSITIVITY)
|
||||
MainApp.getSpecificPlugin(SensitivityOref0Plugin.class).setFragmentEnabled(type, true);
|
||||
else if (type == PluginBase.PROFILE)
|
||||
MainApp.getSpecificPlugin(NSProfilePlugin.class).setFragmentEnabled(type, true);
|
||||
else
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package info.nightscout.androidaps.plugins.ConfigBuilder;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.SharedPreferences;
|
||||
import android.os.PowerManager;
|
||||
import android.preference.PreferenceManager;
|
||||
|
@ -40,16 +41,19 @@ import info.nightscout.androidaps.interfaces.PluginBase;
|
|||
import info.nightscout.androidaps.interfaces.ProfileInterface;
|
||||
import info.nightscout.androidaps.interfaces.PumpDescription;
|
||||
import info.nightscout.androidaps.interfaces.PumpInterface;
|
||||
import info.nightscout.androidaps.interfaces.SensitivityInterface;
|
||||
import info.nightscout.androidaps.interfaces.TreatmentsInterface;
|
||||
import info.nightscout.androidaps.plugins.Loop.APSResult;
|
||||
import info.nightscout.androidaps.plugins.Loop.LoopPlugin;
|
||||
import info.nightscout.androidaps.plugins.Overview.Dialogs.BolusProgressDialog;
|
||||
import info.nightscout.androidaps.plugins.Overview.Dialogs.BolusProgressHelperActivity;
|
||||
import info.nightscout.androidaps.plugins.Overview.Notification;
|
||||
import info.nightscout.androidaps.plugins.Overview.events.EventDismissBolusprogressIfRunning;
|
||||
import info.nightscout.androidaps.plugins.Overview.events.EventDismissNotification;
|
||||
import info.nightscout.androidaps.plugins.Overview.events.EventNewNotification;
|
||||
import info.nightscout.androidaps.plugins.PumpVirtual.VirtualPumpPlugin;
|
||||
import info.nightscout.utils.NSUpload;
|
||||
import info.nightscout.utils.SP;
|
||||
|
||||
/**
|
||||
* Created by mike on 05.08.2016.
|
||||
|
@ -64,6 +68,7 @@ public class ConfigBuilderPlugin implements PluginBase, PumpInterface, Constrain
|
|||
private static APSInterface activeAPS;
|
||||
private static LoopPlugin activeLoop;
|
||||
private static InsulinInterface activeInsulin;
|
||||
private static SensitivityInterface activeSensitivity;
|
||||
|
||||
static public String nightscoutVersionName = "";
|
||||
static public Integer nightscoutVersionCode = 0;
|
||||
|
@ -212,11 +217,16 @@ public class ConfigBuilderPlugin implements PluginBase, PumpInterface, Constrain
|
|||
return activePump;
|
||||
}
|
||||
|
||||
public static SensitivityInterface getActiveSensitivity() {
|
||||
return activeSensitivity;
|
||||
}
|
||||
|
||||
void logPluginStatus() {
|
||||
for (PluginBase p : pluginList) {
|
||||
log.debug(p.getName() + ":" +
|
||||
(p.isEnabled(1) ? " GENERAL" : "") +
|
||||
(p.isEnabled(2) ? " TREATMENT" : "") +
|
||||
(p.isEnabled(3) ? " SENSITIVITY" : "") +
|
||||
(p.isEnabled(4) ? " PROFILE" : "") +
|
||||
(p.isEnabled(5) ? " APS" : "") +
|
||||
(p.isEnabled(6) ? " PUMP" : "") +
|
||||
|
@ -255,6 +265,17 @@ public class ConfigBuilderPlugin implements PluginBase, PumpInterface, Constrain
|
|||
}
|
||||
}
|
||||
|
||||
// PluginBase.SENSITIVITY
|
||||
pluginsInCategory = MainApp.getSpecificPluginsListByInterface(SensitivityInterface.class);
|
||||
activeSensitivity = (SensitivityInterface) getTheOneEnabledInArray(pluginsInCategory, PluginBase.SENSITIVITY);
|
||||
if (Config.logConfigBuilder)
|
||||
log.debug("Selected sensitivity interface: " + ((PluginBase) activeSensitivity).getName());
|
||||
for (PluginBase p : pluginsInCategory) {
|
||||
if (!p.getName().equals(((PluginBase) activeSensitivity).getName())) {
|
||||
p.setFragmentVisible(PluginBase.SENSITIVITY, false);
|
||||
}
|
||||
}
|
||||
|
||||
// PluginBase.PROFILE
|
||||
pluginsInCategory = MainApp.getSpecificPluginsListByInterface(ProfileInterface.class);
|
||||
activeProfile = (ProfileInterface) getTheOneEnabledInArray(pluginsInCategory, PluginBase.PROFILE);
|
||||
|
@ -410,43 +431,6 @@ public class ConfigBuilderPlugin implements PluginBase, PumpInterface, Constrain
|
|||
return 0d;
|
||||
}
|
||||
|
||||
/*
|
||||
public PumpEnactResult deliverTreatmentFromBolusWizard(InsulinInterface insulinType, Context context, Double insulin, Integer carbs, Double glucose, String glucoseType, int carbTime, JSONObject boluscalc) {
|
||||
mWakeLock.acquire();
|
||||
PumpEnactResult result;
|
||||
insulin = applyBolusConstraints(insulin);
|
||||
carbs = applyCarbsConstraints(carbs);
|
||||
|
||||
BolusProgressDialog bolusProgressDialog = null;
|
||||
if (context != null) {
|
||||
bolusProgressDialog = new BolusProgressDialog();
|
||||
bolusProgressDialog.setInsulin(insulin);
|
||||
bolusProgressDialog.show(((AppCompatActivity) context).getSupportFragmentManager(), "BolusProgress");
|
||||
}
|
||||
|
||||
MainApp.bus().post(new EventBolusRequested(insulin));
|
||||
|
||||
result = activePump.deliverTreatment(insulinType, insulin, carbs, context);
|
||||
|
||||
BolusProgressDialog.bolusEnded = true;
|
||||
|
||||
MainApp.bus().post(new EventDismissBolusprogressIfRunning(result));
|
||||
|
||||
if (result.success) {
|
||||
Treatment t = new Treatment(insulinType);
|
||||
t.insulin = result.bolusDelivered;
|
||||
if (carbTime == 0)
|
||||
t.carbs = (double) result.carbsDelivered; // with different carbTime record will come back from nightscout
|
||||
t.date = System.currentTimeMillis();
|
||||
t.mealBolus = result.carbsDelivered > 0;
|
||||
addToHistoryTreatment(t);
|
||||
t.carbs = (double) result.carbsDelivered;
|
||||
NSUpload.uploadBolusWizardRecord(t, glucose, glucoseType, carbTime, boluscalc);
|
||||
}
|
||||
mWakeLock.release();
|
||||
return result;
|
||||
}
|
||||
*/
|
||||
@Override
|
||||
public PumpEnactResult deliverTreatment(DetailedBolusInfo detailedBolusInfo) {
|
||||
mWakeLock.acquire();
|
||||
|
@ -459,8 +443,15 @@ public class ConfigBuilderPlugin implements PluginBase, PumpInterface, Constrain
|
|||
bolusProgressDialog = new BolusProgressDialog();
|
||||
bolusProgressDialog.setInsulin(detailedBolusInfo.insulin);
|
||||
bolusProgressDialog.show(((AppCompatActivity) detailedBolusInfo.context).getSupportFragmentManager(), "BolusProgress");
|
||||
} else {
|
||||
Intent i = new Intent();
|
||||
i.putExtra("insulin", detailedBolusInfo.insulin);
|
||||
i.setClass(MainApp.instance(), BolusProgressHelperActivity.class);
|
||||
i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||
MainApp.instance().startActivity(i);
|
||||
}
|
||||
|
||||
|
||||
MainApp.bus().post(new EventBolusRequested(detailedBolusInfo.insulin));
|
||||
|
||||
result = activePump.deliverTreatment(detailedBolusInfo);
|
||||
|
@ -472,56 +463,6 @@ public class ConfigBuilderPlugin implements PluginBase, PumpInterface, Constrain
|
|||
return result;
|
||||
}
|
||||
|
||||
/*
|
||||
@Override
|
||||
public PumpEnactResult deliverTreatment(InsulinInterface insulinType, Double insulin, Integer carbs, Context context) {
|
||||
return deliverTreatment(insulinType, insulin, carbs, context, true);
|
||||
}
|
||||
|
||||
public PumpEnactResult deliverTreatment(InsulinInterface insulinType, Double insulin, Integer carbs, Context context, boolean createTreatment) {
|
||||
mWakeLock.acquire();
|
||||
PumpEnactResult result;
|
||||
insulin = applyBolusConstraints(insulin);
|
||||
carbs = applyCarbsConstraints(carbs);
|
||||
|
||||
BolusProgressDialog bolusProgressDialog = null;
|
||||
if (context != null) {
|
||||
bolusProgressDialog = new BolusProgressDialog();
|
||||
bolusProgressDialog.setInsulin(insulin);
|
||||
bolusProgressDialog.show(((AppCompatActivity) context).getSupportFragmentManager(), "BolusProgress");
|
||||
} else {
|
||||
Intent i = new Intent();
|
||||
i.putExtra("insulin", insulin.doubleValue());
|
||||
i.setClass(MainApp.instance(), BolusProgressHelperActivity.class);
|
||||
i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||
MainApp.instance().startActivity(i);
|
||||
}
|
||||
|
||||
MainApp.bus().post(new EventBolusRequested(insulin));
|
||||
|
||||
result = activePump.deliverTreatment(insulinType, insulin, carbs, context);
|
||||
|
||||
BolusProgressDialog.bolusEnded = true;
|
||||
|
||||
MainApp.bus().post(new EventDismissBolusprogressIfRunning(result));
|
||||
|
||||
if (Config.logCongigBuilderActions)
|
||||
log.debug("deliverTreatment insulin: " + insulin + " carbs: " + carbs + " success: " + result.success + " enacted: " + result.enacted + " bolusDelivered: " + result.bolusDelivered);
|
||||
|
||||
if (result.success && createTreatment) {
|
||||
Treatment t = new Treatment(insulinType);
|
||||
t.insulin = result.bolusDelivered;
|
||||
t.carbs = (double) result.carbsDelivered;
|
||||
t.date = System.currentTimeMillis();
|
||||
t.mealBolus = t.carbs > 0;
|
||||
addToHistoryTreatment(t);
|
||||
NSUpload.uploadTreatment(t);
|
||||
}
|
||||
mWakeLock.release();
|
||||
return result;
|
||||
}
|
||||
|
||||
*/
|
||||
@Override
|
||||
public void stopBolusDelivering() {
|
||||
activePump.stopBolusDelivering();
|
||||
|
@ -1016,19 +957,22 @@ public class ConfigBuilderPlugin implements PluginBase, PumpInterface, Constrain
|
|||
if (activeTreatments == null)
|
||||
return null; //app not initialized
|
||||
//log.debug("Profile for: " + new Date(time).toLocaleString() + " : " + getProfileName(time));
|
||||
ProfileSwitch profileSwitch = getProfileSwitchFromHistory(time);
|
||||
if (profileSwitch != null) {
|
||||
if (profileSwitch.profileJson != null) {
|
||||
return profileSwitch.getProfileObject();
|
||||
} else if (activeProfile.getProfile() != null){
|
||||
Profile profile = activeProfile.getProfile().getSpecificProfile(profileSwitch.profileName);
|
||||
if (profile != null)
|
||||
return profile;
|
||||
boolean ignoreProfileSwitchEvents = SP.getBoolean(R.string.key_do_not_track_profile_switch, false);
|
||||
if (!ignoreProfileSwitchEvents) {
|
||||
ProfileSwitch profileSwitch = getProfileSwitchFromHistory(time);
|
||||
if (profileSwitch != null) {
|
||||
if (profileSwitch.profileJson != null) {
|
||||
return profileSwitch.getProfileObject();
|
||||
} else if (activeProfile.getProfile() != null) {
|
||||
Profile profile = activeProfile.getProfile().getSpecificProfile(profileSwitch.profileName);
|
||||
if (profile != null)
|
||||
return profile;
|
||||
}
|
||||
}
|
||||
// Unable to determine profile, failover to default
|
||||
if (activeProfile.getProfile() == null)
|
||||
return null; //app not initialized
|
||||
}
|
||||
// Unable to determine profile, failover to default
|
||||
if (activeProfile.getProfile() == null)
|
||||
return null; //app not initialized
|
||||
Profile defaultProfile = activeProfile.getProfile().getDefaultProfile();
|
||||
if (defaultProfile != null)
|
||||
return defaultProfile;
|
||||
|
|
|
@ -1,17 +0,0 @@
|
|||
package info.nightscout.androidaps.plugins.ConstraintsSafety;
|
||||
|
||||
|
||||
import android.support.v4.app.Fragment;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
public class SafetyFragment extends Fragment {
|
||||
private static Logger log = LoggerFactory.getLogger(SafetyFragment.class);
|
||||
|
||||
private static SafetyPlugin safetyPlugin = new SafetyPlugin();
|
||||
|
||||
public static SafetyPlugin getPlugin() {
|
||||
return safetyPlugin;
|
||||
}
|
||||
}
|
|
@ -21,9 +21,17 @@ import info.nightscout.utils.SP;
|
|||
public class SafetyPlugin implements PluginBase, ConstraintsInterface {
|
||||
private static Logger log = LoggerFactory.getLogger(SafetyPlugin.class);
|
||||
|
||||
static SafetyPlugin plugin = null;
|
||||
|
||||
public static SafetyPlugin getPlugin() {
|
||||
if (plugin == null)
|
||||
plugin = new SafetyPlugin();
|
||||
return plugin;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getFragmentClass() {
|
||||
return SafetyFragment.class.getName();
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -1,28 +1,95 @@
|
|||
package info.nightscout.androidaps.plugins.IobCobCalculator;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
import info.nightscout.androidaps.MainApp;
|
||||
import info.nightscout.androidaps.R;
|
||||
import info.nightscout.androidaps.data.Profile;
|
||||
import info.nightscout.androidaps.db.Treatment;
|
||||
import info.nightscout.androidaps.interfaces.PluginBase;
|
||||
import info.nightscout.androidaps.plugins.SensitivityMK.SensitivityMKPlugin;
|
||||
import info.nightscout.utils.SP;
|
||||
|
||||
/**
|
||||
* Created by mike on 25.04.2017.
|
||||
*/
|
||||
|
||||
public class AutosensData {
|
||||
long time = 0L;
|
||||
private static Logger log = LoggerFactory.getLogger(AutosensData.class);
|
||||
|
||||
static class CarbsInPast {
|
||||
long time = 0L;
|
||||
double carbs = 0d;
|
||||
double min5minCarbImpact = 0d;
|
||||
double remaining = 0d;
|
||||
|
||||
public CarbsInPast(Treatment t) {
|
||||
time = t.date;
|
||||
carbs = t.carbs;
|
||||
remaining = t.carbs;
|
||||
if (MainApp.getSpecificPlugin(SensitivityMKPlugin.class) != null && MainApp.getSpecificPlugin(SensitivityMKPlugin.class).isEnabled(PluginBase.SENSITIVITY)) {
|
||||
double maxAbsorptionHours = SP.getDouble(R.string.key_absorption_maxtime, 4d);
|
||||
Profile profile = MainApp.getConfigBuilder().getProfile(t.date);
|
||||
double sens = Profile.toMgdl(profile.getIsf(t.date), profile.getUnits());
|
||||
double ic = profile.getIc(t.date);
|
||||
min5minCarbImpact = t.carbs / (maxAbsorptionHours * 60 / 5) * sens / ic;
|
||||
log.debug("Min 5m carbs impact for " + carbs + "g @" + new Date(t.date).toLocaleString() + " for " + maxAbsorptionHours + "h calculated to " + min5minCarbImpact + " ISF: " + sens + " IC: " + ic);
|
||||
} else {
|
||||
min5minCarbImpact = SP.getDouble("openapsama_min_5m_carbimpact", 3.0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public long time = 0L;
|
||||
public String pastSensitivity = "";
|
||||
public double deviation = 0d;
|
||||
boolean calculateWithDeviation = false;
|
||||
boolean nonCarbsDeviation = false;
|
||||
public boolean nonEqualDeviation = false;
|
||||
List<CarbsInPast> activeCarbsList = new ArrayList<>();
|
||||
double absorbed = 0d;
|
||||
public double carbsFromBolus = 0d;
|
||||
public double cob = 0;
|
||||
public double bgi = 0d;
|
||||
public double delta = 0d;
|
||||
|
||||
public double autosensRatio = 1d;
|
||||
|
||||
public String log(long time) {
|
||||
return "AutosensData: " + new Date(time).toLocaleString() + " " + pastSensitivity + " Delta=" + delta + " Bgi=" + bgi + " Deviation=" + deviation + " Absorbed=" + absorbed + " CarbsFromBolus=" + carbsFromBolus + " COB=" + cob;
|
||||
return "AutosensData: " + new Date(time).toLocaleString() + " " + pastSensitivity + " Delta=" + delta + " Bgi=" + bgi + " Deviation=" + deviation + " Absorbed=" + absorbed + " CarbsFromBolus=" + carbsFromBolus + " COB=" + cob + " autosensRatio=" + autosensRatio;
|
||||
}
|
||||
|
||||
public int minOld() {
|
||||
return (int) ((System.currentTimeMillis() - time) / 1000 / 60);
|
||||
}
|
||||
|
||||
// remove carbs older than 4h
|
||||
public void removeOldCarbs(long toTime) {
|
||||
for (int i = 0; i < activeCarbsList.size(); i++) {
|
||||
CarbsInPast c = activeCarbsList.get(i);
|
||||
if (c.time + 4 * 60 * 60 * 1000L < toTime) {
|
||||
activeCarbsList.remove(i--);
|
||||
if (c.remaining > 0)
|
||||
cob -= c.remaining;
|
||||
log.debug("Removing carbs at "+ new Date(toTime).toLocaleString() + " + after 4h :" + new Date(c.time).toLocaleString());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void substractAbosorbedCarbs() {
|
||||
double ac = absorbed;
|
||||
for (int i = 0; i < activeCarbsList.size() && ac > 0; i++) {
|
||||
CarbsInPast c = activeCarbsList.get(i);
|
||||
if (c.remaining > 0) {
|
||||
double sub = Math.min(ac, c.remaining);
|
||||
c.remaining -= sub;
|
||||
ac -= sub;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,16 +0,0 @@
|
|||
package info.nightscout.androidaps.plugins.IobCobCalculator;
|
||||
|
||||
import android.support.v4.app.Fragment;
|
||||
|
||||
/**
|
||||
* Created by adrian on 17/11/16.
|
||||
*/
|
||||
|
||||
public class IobCobCalculatorFragment extends Fragment {
|
||||
|
||||
private static IobCobCalculatorPlugin iobCobCalculatorPlugin = new IobCobCalculatorPlugin();
|
||||
|
||||
public static IobCobCalculatorPlugin getPlugin() {
|
||||
return iobCobCalculatorPlugin;
|
||||
}
|
||||
}
|
|
@ -19,14 +19,18 @@ import java.util.List;
|
|||
import info.nightscout.androidaps.Config;
|
||||
import info.nightscout.androidaps.Constants;
|
||||
import info.nightscout.androidaps.MainApp;
|
||||
import info.nightscout.androidaps.R;
|
||||
import info.nightscout.androidaps.data.IobTotal;
|
||||
import info.nightscout.androidaps.data.Profile;
|
||||
import info.nightscout.androidaps.db.BgReading;
|
||||
import info.nightscout.androidaps.db.TemporaryBasal;
|
||||
import info.nightscout.androidaps.db.Treatment;
|
||||
import info.nightscout.androidaps.events.EventConfigBuilderChange;
|
||||
import info.nightscout.androidaps.events.EventNewBG;
|
||||
import info.nightscout.androidaps.events.EventNewBasalProfile;
|
||||
import info.nightscout.androidaps.events.EventPreferenceChange;
|
||||
import info.nightscout.androidaps.interfaces.PluginBase;
|
||||
import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderPlugin;
|
||||
import info.nightscout.androidaps.plugins.IobCobCalculator.events.BasalData;
|
||||
import info.nightscout.androidaps.plugins.IobCobCalculator.events.EventAutosensCalculationFinished;
|
||||
import info.nightscout.androidaps.plugins.IobCobCalculator.events.EventNewHistoryData;
|
||||
|
@ -53,7 +57,23 @@ public class IobCobCalculatorPlugin implements PluginBase {
|
|||
private static Handler sHandler = null;
|
||||
private static HandlerThread sHandlerThread = null;
|
||||
|
||||
private static Object dataLock = new Object();
|
||||
private static final Object dataLock = new Object();
|
||||
|
||||
private static IobCobCalculatorPlugin plugin = null;
|
||||
|
||||
public static IobCobCalculatorPlugin getPlugin() {
|
||||
if (plugin == null)
|
||||
plugin = new IobCobCalculatorPlugin();
|
||||
return plugin;
|
||||
}
|
||||
|
||||
public static LongSparseArray<AutosensData> getAutosensDataTable() {
|
||||
return autosensDataTable;
|
||||
}
|
||||
|
||||
public static List<BgReading> getBucketedData() {
|
||||
return bucketed_data;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getType() {
|
||||
|
@ -62,7 +82,7 @@ public class IobCobCalculatorPlugin implements PluginBase {
|
|||
|
||||
@Override
|
||||
public String getFragmentClass() {
|
||||
return IobCobCalculatorFragment.class.getName();
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -110,7 +130,7 @@ public class IobCobCalculatorPlugin implements PluginBase {
|
|||
|
||||
}
|
||||
|
||||
public IobCobCalculatorPlugin() {
|
||||
IobCobCalculatorPlugin() {
|
||||
MainApp.bus().register(this);
|
||||
if (sHandlerThread == null) {
|
||||
sHandlerThread = new HandlerThread(IobCobCalculatorPlugin.class.getSimpleName());
|
||||
|
@ -188,14 +208,14 @@ public class IobCobCalculatorPlugin implements PluginBase {
|
|||
}
|
||||
}
|
||||
|
||||
public void createBucketedData() {
|
||||
private void createBucketedData() {
|
||||
if (isAbout5minData())
|
||||
createBucketedData5min();
|
||||
else
|
||||
createBucketedDataRecalculated();
|
||||
}
|
||||
|
||||
public void createBucketedDataRecalculated() {
|
||||
private void createBucketedDataRecalculated() {
|
||||
synchronized (dataLock) {
|
||||
if (bgReadings == null || bgReadings.size() < 3) {
|
||||
bucketed_data = null;
|
||||
|
@ -300,12 +320,14 @@ public class IobCobCalculatorPlugin implements PluginBase {
|
|||
//log.debug("Releasing createBucketedData");
|
||||
}
|
||||
|
||||
public void calculateSensitivityData() {
|
||||
private void calculateSensitivityData() {
|
||||
if (MainApp.getConfigBuilder() == null)
|
||||
return; // app still initializing
|
||||
if (MainApp.getConfigBuilder().getProfile() == null)
|
||||
return; // app still initializing
|
||||
//log.debug("Locking calculateSensitivityData");
|
||||
long oldestTimeWithData = oldestDataAvailable();
|
||||
|
||||
synchronized (dataLock) {
|
||||
|
||||
if (bucketed_data == null || bucketed_data.size() < 3) {
|
||||
|
@ -333,6 +355,10 @@ public class IobCobCalculatorPlugin implements PluginBase {
|
|||
|
||||
AutosensData autosensData = new AutosensData();
|
||||
autosensData.time = bgTime;
|
||||
if (previous != null)
|
||||
autosensData.activeCarbsList = new ArrayList<>(previous.activeCarbsList);
|
||||
else
|
||||
autosensData.activeCarbsList = new ArrayList<>();
|
||||
|
||||
//console.error(bgTime , bucketed_data[i].glucose);
|
||||
double bg;
|
||||
|
@ -353,17 +379,28 @@ public class IobCobCalculatorPlugin implements PluginBase {
|
|||
List<Treatment> recentTreatments = MainApp.getConfigBuilder().getTreatments5MinBackFromHistory(bgTime);
|
||||
for (int ir = 0; ir < recentTreatments.size(); ir++) {
|
||||
autosensData.carbsFromBolus += recentTreatments.get(ir).carbs;
|
||||
autosensData.activeCarbsList.add(new AutosensData.CarbsInPast(recentTreatments.get(ir)));
|
||||
}
|
||||
|
||||
|
||||
// if we are absorbing carbs
|
||||
if (previous != null && previous.cob > 0) {
|
||||
// calculate sum of min carb impact from all active treatments
|
||||
double totalMinCarbsImpact = 0d;
|
||||
for (int ii = 0; ii < autosensData.activeCarbsList.size(); ++ii) {
|
||||
AutosensData.CarbsInPast c = autosensData.activeCarbsList.get(ii);
|
||||
totalMinCarbsImpact += c.min5minCarbImpact;
|
||||
}
|
||||
|
||||
// figure out how many carbs that represents
|
||||
// but always assume at least 3mg/dL/5m (default) absorption
|
||||
double ci = Math.max(deviation, SP.getDouble("openapsama_min_5m_carbimpact", 3.0));
|
||||
// but always assume at least 3mg/dL/5m (default) absorption per active treatment
|
||||
double ci = Math.max(deviation, totalMinCarbsImpact);
|
||||
autosensData.absorbed = ci * profile.getIc(bgTime) / sens;
|
||||
// and add that to the running total carbsAbsorbed
|
||||
autosensData.cob = Math.max(previous.cob - autosensData.absorbed, 0d);
|
||||
autosensData.substractAbosorbedCarbs();
|
||||
}
|
||||
autosensData.removeOldCarbs(bgTime);
|
||||
autosensData.cob += autosensData.carbsFromBolus;
|
||||
autosensData.deviation = deviation;
|
||||
autosensData.bgi = bgi;
|
||||
|
@ -373,12 +410,14 @@ public class IobCobCalculatorPlugin implements PluginBase {
|
|||
if (autosensData.cob <= 0) {
|
||||
if (Math.abs(deviation) < Constants.DEVIATION_TO_BE_EQUAL) {
|
||||
autosensData.pastSensitivity += "=";
|
||||
autosensData.nonEqualDeviation = true;
|
||||
} else if (deviation > 0) {
|
||||
autosensData.pastSensitivity += "+";
|
||||
autosensData.nonEqualDeviation = true;
|
||||
} else {
|
||||
autosensData.pastSensitivity += "-";
|
||||
}
|
||||
autosensData.calculateWithDeviation = true;
|
||||
autosensData.nonCarbsDeviation = true;
|
||||
} else {
|
||||
autosensData.pastSensitivity += "C";
|
||||
}
|
||||
|
@ -386,6 +425,7 @@ public class IobCobCalculatorPlugin implements PluginBase {
|
|||
|
||||
previous = autosensData;
|
||||
autosensDataTable.put(bgTime, autosensData);
|
||||
autosensData.autosensRatio = detectSensitivity(oldestTimeWithData, bgTime).ratio;
|
||||
if (Config.logAutosensData)
|
||||
log.debug(autosensData.log(bgTime));
|
||||
}
|
||||
|
@ -394,6 +434,15 @@ public class IobCobCalculatorPlugin implements PluginBase {
|
|||
//log.debug("Releasing calculateSensitivityData");
|
||||
}
|
||||
|
||||
public static long oldestDataAvailable() {
|
||||
long now = System.currentTimeMillis();
|
||||
|
||||
long oldestDataAvailable = MainApp.getConfigBuilder().oldestDataAvailable();
|
||||
long getBGDataFrom = Math.max(oldestDataAvailable, (long) (now - 60 * 60 * 1000L * (24 + MainApp.getConfigBuilder().getProfile().getDia())));
|
||||
log.debug("Limiting data to oldest available temps: " + new Date(oldestDataAvailable).toString());
|
||||
return getBGDataFrom;
|
||||
}
|
||||
|
||||
public static IobTotal calulateFromTreatmentsAndTemps(long time) {
|
||||
long now = System.currentTimeMillis();
|
||||
time = roundUpTime(time);
|
||||
|
@ -449,6 +498,7 @@ public class IobCobCalculatorPlugin implements PluginBase {
|
|||
return retval;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public static AutosensData getAutosensData(long time) {
|
||||
long now = System.currentTimeMillis();
|
||||
if (time > now)
|
||||
|
@ -467,6 +517,7 @@ public class IobCobCalculatorPlugin implements PluginBase {
|
|||
}
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public static AutosensData getLastAutosensData() {
|
||||
if (autosensDataTable.size() < 1)
|
||||
return null;
|
||||
|
@ -495,104 +546,15 @@ public class IobCobCalculatorPlugin implements PluginBase {
|
|||
return array;
|
||||
}
|
||||
|
||||
public static AutosensResult detectSensitivity(long fromTime) {
|
||||
//log.debug("Locking detectSensitivity");
|
||||
public static AutosensResult detectSensitivityWithLock(long fromTime, long toTime) {
|
||||
synchronized (dataLock) {
|
||||
if (autosensDataTable == null || autosensDataTable.size() < 4) {
|
||||
log.debug("No autosens data available");
|
||||
return new AutosensResult();
|
||||
}
|
||||
|
||||
AutosensData current = getLastAutosensData();
|
||||
if (current == null) {
|
||||
log.debug("No current autosens data available");
|
||||
return new AutosensResult();
|
||||
}
|
||||
|
||||
|
||||
List<Double> deviationsArray = new ArrayList<>();
|
||||
String pastSensitivity = "";
|
||||
int index = 0;
|
||||
while (index < autosensDataTable.size()) {
|
||||
AutosensData autosensData = autosensDataTable.valueAt(index);
|
||||
|
||||
if (autosensData.time < fromTime) {
|
||||
index++;
|
||||
continue;
|
||||
}
|
||||
|
||||
if (autosensData.calculateWithDeviation)
|
||||
deviationsArray.add(autosensData.deviation);
|
||||
|
||||
pastSensitivity += autosensData.pastSensitivity;
|
||||
int secondsFromMidnight = Profile.secondsFromMidnight(autosensData.time);
|
||||
if (secondsFromMidnight % 3600 < 2.5 * 60 || secondsFromMidnight % 3600 > 57.5 * 60) {
|
||||
pastSensitivity += "(" + Math.round(secondsFromMidnight / 3600d) + ")";
|
||||
}
|
||||
index++;
|
||||
}
|
||||
|
||||
Double[] deviations = new Double[deviationsArray.size()];
|
||||
deviations = deviationsArray.toArray(deviations);
|
||||
|
||||
Profile profile = MainApp.getConfigBuilder().getProfile();
|
||||
|
||||
double sens = profile.getIsf();
|
||||
|
||||
double ratio = 1;
|
||||
String ratioLimit = "";
|
||||
String sensResult = "";
|
||||
|
||||
log.debug("Records: " + index + " " + pastSensitivity);
|
||||
Arrays.sort(deviations);
|
||||
|
||||
for (double i = 0.9; i > 0.1; i = i - 0.02) {
|
||||
if (percentile(deviations, (i + 0.02)) >= 0 && percentile(deviations, i) < 0) {
|
||||
log.debug(Math.round(100 * i) + "% of non-meal deviations negative (target 45%-50%)");
|
||||
}
|
||||
}
|
||||
double pSensitive = percentile(deviations, 0.50);
|
||||
double pResistant = percentile(deviations, 0.45);
|
||||
|
||||
double basalOff = 0;
|
||||
|
||||
if (pSensitive < 0) { // sensitive
|
||||
basalOff = pSensitive * (60 / 5) / Profile.toMgdl(sens, profile.getUnits());
|
||||
sensResult = "Excess insulin sensitivity detected";
|
||||
} else if (pResistant > 0) { // resistant
|
||||
basalOff = pResistant * (60 / 5) / Profile.toMgdl(sens, profile.getUnits());
|
||||
sensResult = "Excess insulin resistance detected";
|
||||
} else {
|
||||
sensResult = "Sensitivity normal";
|
||||
}
|
||||
log.debug(sensResult);
|
||||
ratio = 1 + (basalOff / profile.getMaxDailyBasal());
|
||||
|
||||
double rawRatio = ratio;
|
||||
ratio = Math.max(ratio, SafeParse.stringToDouble(SP.getString("openapsama_autosens_min", "0.7")));
|
||||
ratio = Math.min(ratio, SafeParse.stringToDouble(SP.getString("openapsama_autosens_max", "1.2")));
|
||||
|
||||
if (ratio != rawRatio) {
|
||||
ratioLimit = "Ratio limited from " + rawRatio + " to " + ratio;
|
||||
log.debug(ratioLimit);
|
||||
}
|
||||
|
||||
double newisf = Math.round(Profile.toMgdl(sens, profile.getUnits()) / ratio);
|
||||
if (ratio != 1) {
|
||||
log.debug("ISF adjusted from " + Profile.toMgdl(sens, profile.getUnits()) + " to " + newisf);
|
||||
}
|
||||
|
||||
AutosensResult output = new AutosensResult();
|
||||
output.ratio = Round.roundTo(ratio, 0.01);
|
||||
output.carbsAbsorbed = Round.roundTo(current.cob, 0.01);
|
||||
output.pastSensitivity = pastSensitivity;
|
||||
output.ratioLimit = ratioLimit;
|
||||
output.sensResult = sensResult;
|
||||
return output;
|
||||
return detectSensitivity(fromTime, toTime);
|
||||
}
|
||||
//log.debug("Releasing detectSensitivity");
|
||||
}
|
||||
|
||||
private static AutosensResult detectSensitivity(long fromTime, long toTime) {
|
||||
return ConfigBuilderPlugin.getActiveSensitivity().detectSensitivity(fromTime, toTime);
|
||||
}
|
||||
|
||||
public static JSONArray convertToJSONArray(IobTotal[] iobArray) {
|
||||
JSONArray array = new JSONArray();
|
||||
|
@ -638,6 +600,41 @@ public class IobCobCalculatorPlugin implements PluginBase {
|
|||
});
|
||||
}
|
||||
|
||||
@Subscribe
|
||||
public void onStatusEvent(EventPreferenceChange ev) {
|
||||
if (ev.isChanged(R.string.key_openapsama_autosens_period) ||
|
||||
ev.isChanged(R.string.key_age) ||
|
||||
ev.isChanged(R.string.key_absorption_maxtime)
|
||||
) {
|
||||
synchronized (dataLock) {
|
||||
log.debug("Invalidating cached data because of preference change. IOB: " + iobTable.size() + " Autosens: " + autosensDataTable.size() + " records");
|
||||
iobTable = new LongSparseArray<>();
|
||||
autosensDataTable = new LongSparseArray<>();
|
||||
}
|
||||
sHandler.post(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
calculateSensitivityData();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@Subscribe
|
||||
public void onStatusEvent(EventConfigBuilderChange ev) {
|
||||
synchronized (dataLock) {
|
||||
log.debug("Invalidating cached data because of configuration change. IOB: " + iobTable.size() + " Autosens: " + autosensDataTable.size() + " records");
|
||||
iobTable = new LongSparseArray<>();
|
||||
autosensDataTable = new LongSparseArray<>();
|
||||
}
|
||||
sHandler.post(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
calculateSensitivityData();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// When historical data is changed (comming from NS etc) finished calculations after this date must be invalidated
|
||||
@Subscribe
|
||||
public void onNewHistoryData(EventNewHistoryData ev) {
|
||||
|
|
|
@ -214,14 +214,9 @@ public class OpenAPSAMAPlugin implements PluginBase, APSInterface {
|
|||
if (!checkOnlyHardLimits(profile.getMaxDailyBasal(), "max_daily_basal", 0.1, 10)) return;
|
||||
if (!checkOnlyHardLimits(pump.getBaseBasalRate(), "current_basal", 0.01, 5)) return;
|
||||
|
||||
long oldestDataAvailable = MainApp.getConfigBuilder().oldestDataAvailable();
|
||||
long getBGDataFrom = Math.max(oldestDataAvailable, (long) (System.currentTimeMillis() - 60 * 60 * 1000L * (24 + profile.getDia())));
|
||||
log.debug("Limiting data to oldest available temps: " + new Date(oldestDataAvailable).toString());
|
||||
|
||||
startPart = new Date();
|
||||
if (MainApp.getConfigBuilder().isAMAModeEnabled()) {
|
||||
//lastAutosensResult = Autosens.detectSensitivityandCarbAbsorption(getBGDataFrom, null);
|
||||
lastAutosensResult = IobCobCalculatorPlugin.detectSensitivity(getBGDataFrom);
|
||||
lastAutosensResult = IobCobCalculatorPlugin.detectSensitivityWithLock(IobCobCalculatorPlugin.oldestDataAvailable(), System.currentTimeMillis());
|
||||
} else {
|
||||
lastAutosensResult = new AutosensResult();
|
||||
}
|
||||
|
|
|
@ -71,7 +71,7 @@ public class BolusProgressDialog extends DialogFragment implements View.OnClickL
|
|||
public void onResume() {
|
||||
super.onResume();
|
||||
if (getDialog() != null)
|
||||
getDialog().getWindow().setLayout(1000, ViewGroup.LayoutParams.WRAP_CONTENT);
|
||||
getDialog().getWindow().setLayout(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
|
||||
MainApp.bus().register(this);
|
||||
running = true;
|
||||
if (bolusEnded) dismiss();
|
||||
|
|
|
@ -21,7 +21,6 @@ import android.widget.ArrayAdapter;
|
|||
import android.widget.Button;
|
||||
import android.widget.CheckBox;
|
||||
import android.widget.CompoundButton;
|
||||
import android.widget.EditText;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.Spinner;
|
||||
import android.widget.TextView;
|
||||
|
@ -62,7 +61,6 @@ import info.nightscout.utils.DateUtil;
|
|||
import info.nightscout.utils.DecimalFormatter;
|
||||
import info.nightscout.utils.NumberPicker;
|
||||
import info.nightscout.utils.OKDialog;
|
||||
import info.nightscout.utils.PlusMinusEditText;
|
||||
import info.nightscout.utils.SP;
|
||||
import info.nightscout.utils.SafeParse;
|
||||
import info.nightscout.utils.ToastUtils;
|
||||
|
@ -521,7 +519,7 @@ public class WizardDialog extends DialogFragment implements OnClickListener, Com
|
|||
if (calculatedTotalInsulin > 0d || calculatedCarbs > 0d) {
|
||||
String insulinText = calculatedTotalInsulin > 0d ? (DecimalFormatter.to2Decimal(calculatedTotalInsulin) + "U") : "";
|
||||
String carbsText = calculatedCarbs > 0d ? (DecimalFormatter.to0Decimal(calculatedCarbs) + "g") : "";
|
||||
total.setText(getString(R.string.send) + " " + insulinText + " " + carbsText);
|
||||
total.setText(getString(R.string.result) + ": " + insulinText + " " + carbsText);
|
||||
okButton.setVisibility(View.VISIBLE);
|
||||
} else {
|
||||
total.setText(getString(R.string.missing) + " " + DecimalFormatter.to0Decimal(wizard.carbsEquivalent) + "g");
|
||||
|
|
|
@ -169,6 +169,7 @@ public class OverviewFragment extends Fragment implements View.OnClickListener,
|
|||
CheckBox showIobView;
|
||||
CheckBox showCobView;
|
||||
CheckBox showDeviationsView;
|
||||
CheckBox showRatiosView;
|
||||
|
||||
RecyclerView notificationsView;
|
||||
LinearLayoutManager llm;
|
||||
|
@ -284,36 +285,25 @@ public class OverviewFragment extends Fragment implements View.OnClickListener,
|
|||
showIobView = (CheckBox) view.findViewById(R.id.overview_showiob);
|
||||
showCobView = (CheckBox) view.findViewById(R.id.overview_showcob);
|
||||
showDeviationsView = (CheckBox) view.findViewById(R.id.overview_showdeviations);
|
||||
showRatiosView = (CheckBox) view.findViewById(R.id.overview_showratios);
|
||||
showPredictionView.setChecked(SP.getBoolean("showprediction", false));
|
||||
showBasalsView.setChecked(SP.getBoolean("showbasals", true));
|
||||
showIobView.setChecked(SP.getBoolean("showiob", false));
|
||||
showCobView.setChecked(SP.getBoolean("showcob", false));
|
||||
showDeviationsView.setChecked(SP.getBoolean("showdeviations", false));
|
||||
showRatiosView.setChecked(SP.getBoolean("showratios", false));
|
||||
showPredictionView.setOnCheckedChangeListener(this);
|
||||
showBasalsView.setOnCheckedChangeListener(this);
|
||||
showIobView.setOnCheckedChangeListener(this);
|
||||
showCobView.setOnCheckedChangeListener(this);
|
||||
showDeviationsView.setOnCheckedChangeListener(this);
|
||||
showRatiosView.setOnCheckedChangeListener(this);
|
||||
|
||||
notificationsView = (RecyclerView) view.findViewById(R.id.overview_notifications);
|
||||
notificationsView.setHasFixedSize(true);
|
||||
llm = new LinearLayoutManager(view.getContext());
|
||||
notificationsView.setLayoutManager(llm);
|
||||
/*
|
||||
final LinearLayout graphs = (LinearLayout)view.findViewById(R.id.overview_graphs_layout);
|
||||
ViewTreeObserver observer = graphs.getViewTreeObserver();
|
||||
observer.addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {
|
||||
@Override
|
||||
public void onGlobalLayout() {
|
||||
log.debug("Height: " + graphs.getHeight());
|
||||
graphs.getViewTreeObserver().removeGlobalOnLayoutListener(
|
||||
this);
|
||||
int heightNeeded = Math.max(320, graphs.getHeight() - 200);
|
||||
if (heightNeeded != bgGraph.getHeight())
|
||||
bgGraph.setLayoutParams(new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, heightNeeded));
|
||||
}
|
||||
});
|
||||
*/
|
||||
|
||||
bgGraph.getGridLabelRenderer().setGridColor(MainApp.sResources.getColor(R.color.graphgrid));
|
||||
bgGraph.getGridLabelRenderer().reloadStyles();
|
||||
iobGraph.getGridLabelRenderer().setGridColor(MainApp.sResources.getColor(R.color.graphgrid));
|
||||
|
@ -323,11 +313,14 @@ public class OverviewFragment extends Fragment implements View.OnClickListener,
|
|||
iobGraph.getGridLabelRenderer().setLabelVerticalWidth(50);
|
||||
iobGraph.getGridLabelRenderer().setNumVerticalLabels(5);
|
||||
|
||||
rangeToDisplay = SP.getInt(R.string.key_rangetodisplay, 6);
|
||||
|
||||
bgGraph.setOnLongClickListener(new View.OnLongClickListener() {
|
||||
@Override
|
||||
public boolean onLongClick(View v) {
|
||||
rangeToDisplay += 6;
|
||||
rangeToDisplay = rangeToDisplay > 24 ? 6 : rangeToDisplay;
|
||||
SP.putInt(R.string.key_rangetodisplay, rangeToDisplay);
|
||||
updateGUI("rangeChange");
|
||||
return false;
|
||||
}
|
||||
|
@ -367,34 +360,29 @@ public class OverviewFragment extends Fragment implements View.OnClickListener,
|
|||
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
|
||||
switch (buttonView.getId()) {
|
||||
case R.id.overview_showprediction:
|
||||
SP.putBoolean("showprediction", showPredictionView.isChecked());
|
||||
updateGUI("onPredictionCheckedChanged");
|
||||
break;
|
||||
case R.id.overview_showbasals:
|
||||
SP.putBoolean("showbasals", showBasalsView.isChecked());
|
||||
updateGUI("onBasalsCheckedChanged");
|
||||
break;
|
||||
case R.id.overview_showiob:
|
||||
SP.putBoolean("showiob", showIobView.isChecked());
|
||||
updateGUI("onIobCheckedChanged");
|
||||
break;
|
||||
case R.id.overview_showcob:
|
||||
showDeviationsView.setOnCheckedChangeListener(null);
|
||||
showDeviationsView.setChecked(false);
|
||||
showDeviationsView.setOnCheckedChangeListener(this);
|
||||
SP.putBoolean("showcob", showCobView.isChecked());
|
||||
SP.putBoolean("showdeviations", showDeviationsView.isChecked());
|
||||
updateGUI("onCobCheckedChanged");
|
||||
break;
|
||||
case R.id.overview_showdeviations:
|
||||
showCobView.setOnCheckedChangeListener(null);
|
||||
showCobView.setChecked(false);
|
||||
showCobView.setOnCheckedChangeListener(this);
|
||||
SP.putBoolean("showcob", showCobView.isChecked());
|
||||
SP.putBoolean("showdeviations", showDeviationsView.isChecked());
|
||||
updateGUI("onDeviationsCheckedChanged");
|
||||
break;
|
||||
case R.id.overview_showratios:
|
||||
break;
|
||||
}
|
||||
SP.putBoolean("showiob", showIobView.isChecked());
|
||||
SP.putBoolean("showprediction", showPredictionView.isChecked());
|
||||
SP.putBoolean("showbasals", showBasalsView.isChecked());
|
||||
SP.putBoolean("showcob", showCobView.isChecked());
|
||||
SP.putBoolean("showdeviations", showDeviationsView.isChecked());
|
||||
SP.putBoolean("showratios", showRatiosView.isChecked());
|
||||
scheduleUpdateGUI("onGraphCheckboxesCheckedChanged");
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -1038,7 +1026,7 @@ public class OverviewFragment extends Fragment implements View.OnClickListener,
|
|||
NewNSTreatmentDialog newDialog = new NewNSTreatmentDialog();
|
||||
final OptionsToShow profileswitch = CareportalFragment.profileswitch;
|
||||
profileswitch.executeProfileSwitch = true;
|
||||
newDialog.setOptions(profileswitch);
|
||||
newDialog.setOptions(profileswitch, R.string.careportal_profileswitch);
|
||||
newDialog.show(getFragmentManager(), "NewNSTreatmentDialog");
|
||||
return true;
|
||||
}
|
||||
|
@ -1053,7 +1041,7 @@ public class OverviewFragment extends Fragment implements View.OnClickListener,
|
|||
NewNSTreatmentDialog newTTDialog = new NewNSTreatmentDialog();
|
||||
final OptionsToShow temptarget = CareportalFragment.temptarget;
|
||||
temptarget.executeTempTarget = true;
|
||||
newTTDialog.setOptions(temptarget);
|
||||
newTTDialog.setOptions(temptarget, R.string.careportal_temporarytarget);
|
||||
newTTDialog.show(getFragmentManager(), "NewNSTreatmentDialog");
|
||||
return true;
|
||||
}
|
||||
|
@ -1343,15 +1331,18 @@ public class OverviewFragment extends Fragment implements View.OnClickListener,
|
|||
FixedLineGraphSeries<DataPoint> iobSeries;
|
||||
FixedLineGraphSeries<DataPoint> cobSeries;
|
||||
BarGraphSeries<DeviationDataPoint> devSeries;
|
||||
LineGraphSeries<DataPoint> ratioSeries;
|
||||
Double maxIobValueFound = 0d;
|
||||
Double maxCobValueFound = 0d;
|
||||
Double maxDevValueFound = 0d;
|
||||
Double maxRatioValueFound = 0d;
|
||||
|
||||
if (showIobView.isChecked() || showCobView.isChecked() || showDeviationsView.isChecked()) {
|
||||
if (showIobView.isChecked() || showCobView.isChecked() || showDeviationsView.isChecked() || showRatiosView.isChecked()) {
|
||||
//Date start = new Date();
|
||||
List<DataPoint> iobArray = new ArrayList<>();
|
||||
List<DataPoint> cobArray = new ArrayList<>();
|
||||
List<DeviationDataPoint> devArray = new ArrayList<>();
|
||||
List<DataPoint> ratioArray = new ArrayList<>();
|
||||
double lastIob = 0;
|
||||
int lastCob = 0;
|
||||
for (long time = fromTime; time <= now; time += 5 * 60 * 1000L) {
|
||||
|
@ -1365,7 +1356,7 @@ public class OverviewFragment extends Fragment implements View.OnClickListener,
|
|||
lastIob = iob;
|
||||
}
|
||||
}
|
||||
if (showCobView.isChecked() || showDeviationsView.isChecked()) {
|
||||
if (showCobView.isChecked() || showDeviationsView.isChecked() || showRatiosView.isChecked()) {
|
||||
AutosensData autosensData = IobCobCalculatorPlugin.getAutosensData(time);
|
||||
if (autosensData != null && showCobView.isChecked()) {
|
||||
int cob = (int) autosensData.cob;
|
||||
|
@ -1385,6 +1376,10 @@ public class OverviewFragment extends Fragment implements View.OnClickListener,
|
|||
devArray.add(new DeviationDataPoint(time, autosensData.deviation, color));
|
||||
maxDevValueFound = Math.max(maxDevValueFound, Math.abs(autosensData.deviation));
|
||||
}
|
||||
if (autosensData != null && showRatiosView.isChecked()) {
|
||||
ratioArray.add(new DataPoint(time, autosensData.autosensRatio));
|
||||
maxRatioValueFound = Math.max(maxRatioValueFound, Math.abs(autosensData.autosensRatio));
|
||||
}
|
||||
}
|
||||
}
|
||||
//Profiler.log(log, "IOB processed", start);
|
||||
|
@ -1397,18 +1392,49 @@ public class OverviewFragment extends Fragment implements View.OnClickListener,
|
|||
iobSeries.setThickness(3);
|
||||
|
||||
|
||||
if (showIobView.isChecked() && (showCobView.isChecked() || showDeviationsView.isChecked())) {
|
||||
List<DataPoint> cobArrayRescaled = new ArrayList<>();
|
||||
List<DeviationDataPoint> devArrayRescaled = new ArrayList<>();
|
||||
for (int ci = 0; ci < cobArray.size(); ci++) {
|
||||
cobArrayRescaled.add(new DataPoint(cobArray.get(ci).getX(), cobArray.get(ci).getY() * maxIobValueFound / maxCobValueFound / 2));
|
||||
}
|
||||
for (int ci = 0; ci < devArray.size(); ci++) {
|
||||
devArrayRescaled.add(new DeviationDataPoint(devArray.get(ci).getX(), devArray.get(ci).getY() * maxIobValueFound / maxDevValueFound, devArray.get(ci).color));
|
||||
}
|
||||
cobArray = cobArrayRescaled;
|
||||
devArray = devArrayRescaled;
|
||||
Double maxByScale = null;
|
||||
int graphsToShow = 0;
|
||||
if (showIobView.isChecked()) {
|
||||
if (maxByScale == null) maxByScale = maxIobValueFound;
|
||||
graphsToShow++;
|
||||
}
|
||||
if (showCobView.isChecked()) {
|
||||
if (maxByScale == null) maxByScale = maxCobValueFound;
|
||||
graphsToShow++;
|
||||
}
|
||||
if (showDeviationsView.isChecked()) {
|
||||
if (maxByScale == null) maxByScale = maxDevValueFound;
|
||||
graphsToShow++;
|
||||
}
|
||||
if (showRatiosView.isChecked()) {
|
||||
if (maxByScale == null) maxByScale = maxRatioValueFound;
|
||||
graphsToShow++;
|
||||
}
|
||||
|
||||
if (graphsToShow > 1) {
|
||||
if (!maxByScale.equals(maxCobValueFound)) {
|
||||
List<DataPoint> cobArrayRescaled = new ArrayList<>();
|
||||
for (int ci = 0; ci < cobArray.size(); ci++) {
|
||||
cobArrayRescaled.add(new DataPoint(cobArray.get(ci).getX(), cobArray.get(ci).getY() * maxByScale / maxCobValueFound / 2));
|
||||
}
|
||||
cobArray = cobArrayRescaled;
|
||||
}
|
||||
if (!maxByScale.equals(maxDevValueFound)) {
|
||||
List<DeviationDataPoint> devArrayRescaled = new ArrayList<>();
|
||||
for (int ci = 0; ci < devArray.size(); ci++) {
|
||||
devArrayRescaled.add(new DeviationDataPoint(devArray.get(ci).getX(), devArray.get(ci).getY() * maxByScale / maxDevValueFound, devArray.get(ci).color));
|
||||
}
|
||||
devArray = devArrayRescaled;
|
||||
}
|
||||
if (!maxByScale.equals(maxRatioValueFound)) {
|
||||
List<DataPoint> ratioArrayRescaled = new ArrayList<>();
|
||||
for (int ci = 0; ci < ratioArray.size(); ci++) {
|
||||
ratioArrayRescaled.add(new DataPoint(ratioArray.get(ci).getX(), (ratioArray.get(ci).getY() - 1) * maxByScale / maxRatioValueFound));
|
||||
}
|
||||
ratioArray = ratioArrayRescaled;
|
||||
}
|
||||
}
|
||||
|
||||
// COB
|
||||
DataPoint[] cobData = new DataPoint[cobArray.size()];
|
||||
cobData = cobArray.toArray(cobData);
|
||||
|
@ -1428,9 +1454,13 @@ public class OverviewFragment extends Fragment implements View.OnClickListener,
|
|||
return data.color;
|
||||
}
|
||||
});
|
||||
//devSeries.setBackgroundColor(0xB0FFFFFF & MainApp.sResources.getColor(R.color.cob)); //50%
|
||||
//devSeries.setColor(MainApp.sResources.getColor(R.color.cob));
|
||||
//devSeries.setThickness(3);
|
||||
|
||||
// RATIOS
|
||||
DataPoint[] ratioData = new DataPoint[ratioArray.size()];
|
||||
ratioData = ratioArray.toArray(ratioData);
|
||||
ratioSeries = new LineGraphSeries<>(ratioData);
|
||||
ratioSeries.setColor(MainApp.sResources.getColor(R.color.ratio));
|
||||
ratioSeries.setThickness(3);
|
||||
|
||||
iobGraph.getSeries().clear();
|
||||
|
||||
|
@ -1443,6 +1473,9 @@ public class OverviewFragment extends Fragment implements View.OnClickListener,
|
|||
if (showDeviationsView.isChecked() && devData.length > 0) {
|
||||
addSeriesWithoutInvalidate(devSeries, iobGraph);
|
||||
}
|
||||
if (showRatiosView.isChecked() && ratioData.length > 0) {
|
||||
addSeriesWithoutInvalidate(ratioSeries, iobGraph);
|
||||
}
|
||||
iobGraph.setVisibility(View.VISIBLE);
|
||||
} else {
|
||||
iobGraph.setVisibility(View.GONE);
|
||||
|
@ -1504,7 +1537,7 @@ public class OverviewFragment extends Fragment implements View.OnClickListener,
|
|||
maxBgValue = Profile.fromMgdlToUnits(maxBgValue, units);
|
||||
maxBgValue = units.equals(Constants.MGDL) ? Round.roundTo(maxBgValue, 40d) + 80 : Round.roundTo(maxBgValue, 2d) + 4;
|
||||
if (highLine > maxBgValue) maxBgValue = highLine;
|
||||
Integer numOfHorizLines = units.equals(Constants.MGDL) ? (int) (maxBgValue / 40 + 1) : (int) (maxBgValue / 2 + 1);
|
||||
Integer numOfVertLines = units.equals(Constants.MGDL) ? (int) (maxBgValue / 40 + 1) : (int) (maxBgValue / 2 + 1);
|
||||
|
||||
DataPointWithLabelInterface[] bg = new DataPointWithLabelInterface[bgListArray.size()];
|
||||
bg = bgListArray.toArray(bg);
|
||||
|
@ -1572,7 +1605,7 @@ public class OverviewFragment extends Fragment implements View.OnClickListener,
|
|||
bgGraph.getViewport().setMaxY(maxBgValue);
|
||||
bgGraph.getViewport().setMinY(0);
|
||||
bgGraph.getViewport().setYAxisBoundsManual(true);
|
||||
bgGraph.getGridLabelRenderer().setNumVerticalLabels(numOfHorizLines);
|
||||
bgGraph.getGridLabelRenderer().setNumVerticalLabels(numOfVertLines);
|
||||
|
||||
// set second scale
|
||||
if (pump.getPumpDescription().isTempBasalCapable && showBasalsView.isChecked()) {
|
||||
|
@ -1645,20 +1678,18 @@ public class OverviewFragment extends Fragment implements View.OnClickListener,
|
|||
|
||||
|
||||
//Notifications
|
||||
public static class RecyclerViewAdapter extends RecyclerView.Adapter<RecyclerViewAdapter.NotificationsViewHolder> {
|
||||
static class RecyclerViewAdapter extends RecyclerView.Adapter<RecyclerViewAdapter.NotificationsViewHolder> {
|
||||
|
||||
List<Notification> notificationsList;
|
||||
|
||||
RecyclerViewAdapter(List<Notification> notificationsList) {
|
||||
this.notificationsList = notificationsList;
|
||||
log.debug("RecyclerViewAdapter");
|
||||
}
|
||||
|
||||
@Override
|
||||
public NotificationsViewHolder onCreateViewHolder(ViewGroup viewGroup, int viewType) {
|
||||
View v = LayoutInflater.from(viewGroup.getContext()).inflate(R.layout.overview_notification_item, viewGroup, false);
|
||||
NotificationsViewHolder notificationsViewHolder = new NotificationsViewHolder(v);
|
||||
return notificationsViewHolder;
|
||||
return new NotificationsViewHolder(v);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -1689,7 +1720,7 @@ public class OverviewFragment extends Fragment implements View.OnClickListener,
|
|||
super.onAttachedToRecyclerView(recyclerView);
|
||||
}
|
||||
|
||||
public static class NotificationsViewHolder extends RecyclerView.ViewHolder implements View.OnClickListener {
|
||||
static class NotificationsViewHolder extends RecyclerView.ViewHolder implements View.OnClickListener {
|
||||
CardView cv;
|
||||
TextView time;
|
||||
TextView text;
|
||||
|
|
|
@ -23,10 +23,8 @@ public class TimeAsXAxisLabelFormatter extends DefaultLabelFormatter {
|
|||
public String formatLabel(double value, boolean isValueX) {
|
||||
if (isValueX) {
|
||||
// format as date
|
||||
Calendar calendar = Calendar.getInstance();
|
||||
calendar.setTimeInMillis((long) value);
|
||||
DateFormat dateFormat = new SimpleDateFormat(mFormat);
|
||||
return dateFormat.format(calendar.getTimeInMillis());
|
||||
return dateFormat.format((long) value);
|
||||
} else {
|
||||
return super.formatLabel(value, isValueX);
|
||||
}
|
||||
|
|
|
@ -1,12 +0,0 @@
|
|||
package info.nightscout.androidaps.plugins.Persistentnotification;
|
||||
|
||||
import android.support.v4.app.Fragment;
|
||||
|
||||
/**
|
||||
* Created by adrian on 23/12/16.
|
||||
*/
|
||||
|
||||
public class PersistentNotificationFragment extends Fragment {
|
||||
|
||||
|
||||
}
|
|
@ -54,7 +54,7 @@ public class PersistentNotificationPlugin implements PluginBase {
|
|||
|
||||
@Override
|
||||
public String getFragmentClass() {
|
||||
return PersistentNotificationFragment.class.getName();
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -143,7 +143,7 @@ public class CircadianPercentageProfileFragment extends Fragment {
|
|||
NewNSTreatmentDialog newDialog = new NewNSTreatmentDialog();
|
||||
final OptionsToShow profileswitch = CareportalFragment.profileswitch;
|
||||
profileswitch.executeProfileSwitch = true;
|
||||
newDialog.setOptions(profileswitch);
|
||||
newDialog.setOptions(profileswitch, R.string.careportal_profileswitch);
|
||||
newDialog.show(getFragmentManager(), "NewNSTreatmentDialog");
|
||||
}
|
||||
});
|
||||
|
|
|
@ -104,7 +104,7 @@ public class LocalProfileFragment extends Fragment {
|
|||
NewNSTreatmentDialog newDialog = new NewNSTreatmentDialog();
|
||||
final OptionsToShow profileswitch = CareportalFragment.profileswitch;
|
||||
profileswitch.executeProfileSwitch = true;
|
||||
newDialog.setOptions(profileswitch);
|
||||
newDialog.setOptions(profileswitch, R.string.careportal_profileswitch);
|
||||
newDialog.show(getFragmentManager(), "NewNSTreatmentDialog");
|
||||
}
|
||||
});
|
||||
|
|
|
@ -102,7 +102,7 @@ public class SimpleProfileFragment extends Fragment {
|
|||
NewNSTreatmentDialog newDialog = new NewNSTreatmentDialog();
|
||||
final OptionsToShow profileswitch = CareportalFragment.profileswitch;
|
||||
profileswitch.executeProfileSwitch = true;
|
||||
newDialog.setOptions(profileswitch);
|
||||
newDialog.setOptions(profileswitch, R.string.careportal_profileswitch);
|
||||
newDialog.show(getFragmentManager(), "NewNSTreatmentDialog");
|
||||
}
|
||||
});
|
||||
|
|
|
@ -35,7 +35,9 @@ import java.text.DecimalFormat;
|
|||
import java.text.SimpleDateFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.Comparator;
|
||||
import java.util.Date;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
|
||||
import info.nightscout.androidaps.MainApp;
|
||||
|
@ -73,6 +75,7 @@ public class DanaRStatsActivity extends Activity {
|
|||
DecimalFormat decimalFormat;
|
||||
|
||||
List<DanaRHistoryRecord> historyList = new ArrayList<>();
|
||||
List<DanaRHistoryRecord> dummies;
|
||||
|
||||
public DanaRStatsActivity() {
|
||||
super();
|
||||
|
@ -302,6 +305,34 @@ public class DanaRStatsActivity extends Activity {
|
|||
private void loadDataFromDB(byte type) {
|
||||
historyList = MainApp.getDbHelper().getDanaRHistoryRecordsByType(type);
|
||||
|
||||
//only use newest 10
|
||||
historyList = historyList.subList(0, Math.min(10, historyList.size()));
|
||||
|
||||
//fill single gaps
|
||||
dummies = new LinkedList();
|
||||
DateFormat df = new SimpleDateFormat("dd.MM.");
|
||||
for(int i = 0; i < historyList.size()-1; i++){
|
||||
DanaRHistoryRecord elem1 = historyList.get(i);
|
||||
DanaRHistoryRecord elem2 = historyList.get(i+1);
|
||||
|
||||
if (!df.format(new Date(elem1.recordDate)).equals(df.format(new Date(elem2.recordDate + 25*60*60*1000)))){
|
||||
DanaRHistoryRecord dummy = new DanaRHistoryRecord();
|
||||
dummy.recordDate = elem1.recordDate - 24*60*60*1000;
|
||||
dummy.recordDailyBasal = elem1.recordDailyBasal/2;
|
||||
dummy.recordDailyBolus = elem1.recordDailyBolus/2;
|
||||
dummies.add(dummy);
|
||||
elem1.recordDailyBasal /= 2;
|
||||
elem1.recordDailyBolus /= 2;
|
||||
}
|
||||
}
|
||||
historyList.addAll(dummies);
|
||||
Collections.sort(historyList, new Comparator<DanaRHistoryRecord>() {
|
||||
@Override
|
||||
public int compare(DanaRHistoryRecord lhs, DanaRHistoryRecord rhs) {
|
||||
return (int) (rhs.recordDate-lhs.recordDate);
|
||||
}
|
||||
});
|
||||
|
||||
runOnUiThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
|
@ -332,6 +363,9 @@ public class DanaRStatsActivity extends Activity {
|
|||
// Create the table row
|
||||
TableRow tr = new TableRow(DanaRStatsActivity.this);
|
||||
if (i % 2 != 0) tr.setBackgroundColor(Color.DKGRAY);
|
||||
if(dummies.contains(record)){
|
||||
tr.setBackgroundColor(Color.argb(125, 255, 0, 0));
|
||||
}
|
||||
tr.setId(100 + i);
|
||||
tr.setLayoutParams(new TableLayout.LayoutParams(
|
||||
TableLayout.LayoutParams.MATCH_PARENT,
|
||||
|
|
|
@ -1,12 +0,0 @@
|
|||
package info.nightscout.androidaps.plugins.PumpMDI;
|
||||
|
||||
|
||||
import android.support.v4.app.Fragment;
|
||||
|
||||
public class MDIFragment extends Fragment {
|
||||
private static MDIPlugin mdiPlugin = new MDIPlugin();
|
||||
|
||||
public static MDIPlugin getPlugin() {
|
||||
return mdiPlugin;
|
||||
}
|
||||
}
|
|
@ -12,11 +12,11 @@ import info.nightscout.androidaps.Config;
|
|||
import info.nightscout.androidaps.MainApp;
|
||||
import info.nightscout.androidaps.R;
|
||||
import info.nightscout.androidaps.data.DetailedBolusInfo;
|
||||
import info.nightscout.androidaps.data.Profile;
|
||||
import info.nightscout.androidaps.data.PumpEnactResult;
|
||||
import info.nightscout.androidaps.interfaces.PluginBase;
|
||||
import info.nightscout.androidaps.interfaces.PumpDescription;
|
||||
import info.nightscout.androidaps.interfaces.PumpInterface;
|
||||
import info.nightscout.androidaps.data.Profile;
|
||||
import info.nightscout.utils.DateUtil;
|
||||
|
||||
/**
|
||||
|
@ -30,6 +30,14 @@ public class MDIPlugin implements PluginBase, PumpInterface {
|
|||
|
||||
PumpDescription pumpDescription = new PumpDescription();
|
||||
|
||||
static MDIPlugin plugin = null;
|
||||
|
||||
public static MDIPlugin getPlugin() {
|
||||
if (plugin == null)
|
||||
plugin = new MDIPlugin();
|
||||
return plugin;
|
||||
}
|
||||
|
||||
public MDIPlugin() {
|
||||
pumpDescription.isBolusCapable = true;
|
||||
pumpDescription.bolusStep = 0.5d;
|
||||
|
@ -42,7 +50,7 @@ public class MDIPlugin implements PluginBase, PumpInterface {
|
|||
|
||||
@Override
|
||||
public String getFragmentClass() {
|
||||
return MDIFragment.class.getName();
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -0,0 +1,200 @@
|
|||
package info.nightscout.androidaps.plugins.SensitivityMK;
|
||||
|
||||
import android.support.v4.util.LongSparseArray;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
import info.nightscout.androidaps.MainApp;
|
||||
import info.nightscout.androidaps.R;
|
||||
import info.nightscout.androidaps.data.Profile;
|
||||
import info.nightscout.androidaps.interfaces.PluginBase;
|
||||
import info.nightscout.androidaps.interfaces.SensitivityInterface;
|
||||
import info.nightscout.androidaps.plugins.IobCobCalculator.AutosensData;
|
||||
import info.nightscout.androidaps.plugins.IobCobCalculator.AutosensResult;
|
||||
import info.nightscout.androidaps.plugins.IobCobCalculator.IobCobCalculatorPlugin;
|
||||
import info.nightscout.utils.Round;
|
||||
import info.nightscout.utils.SP;
|
||||
import info.nightscout.utils.SafeParse;
|
||||
|
||||
/**
|
||||
* Created by mike on 24.06.2017.
|
||||
*/
|
||||
|
||||
public class SensitivityMKPlugin implements PluginBase, SensitivityInterface{
|
||||
private static Logger log = LoggerFactory.getLogger(SensitivityMKPlugin.class);
|
||||
|
||||
private static boolean fragmentEnabled = true;
|
||||
private static boolean fragmentVisible = false;
|
||||
|
||||
static SensitivityMKPlugin plugin = null;
|
||||
|
||||
public static SensitivityMKPlugin getPlugin() {
|
||||
if (plugin == null)
|
||||
plugin = new SensitivityMKPlugin();
|
||||
return plugin;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getType() {
|
||||
return SENSITIVITY;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getFragmentClass() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return MainApp.sResources.getString(R.string.sensitivitymk);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getNameShort() {
|
||||
return MainApp.sResources.getString(R.string.sensitivity_shortname);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isEnabled(int type) {
|
||||
return type == SENSITIVITY && fragmentEnabled;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isVisibleInTabs(int type) {
|
||||
return type == SENSITIVITY && fragmentVisible;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canBeHidden(int type) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasFragment() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean showInList(int type) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setFragmentEnabled(int type, boolean fragmentEnabled) {
|
||||
if (type == SENSITIVITY) this.fragmentEnabled = fragmentEnabled;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setFragmentVisible(int type, boolean fragmentVisible) {
|
||||
if (type == SENSITIVITY) this.fragmentVisible = fragmentVisible;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public AutosensResult detectSensitivity(long fromTime, long toTime) {
|
||||
LongSparseArray<AutosensData> autosensDataTable = IobCobCalculatorPlugin.getAutosensDataTable();
|
||||
|
||||
String age = SP.getString(R.string.key_age, "");
|
||||
int defaultHours = 24;
|
||||
if (age.equals(MainApp.sResources.getString(R.string.key_adult))) defaultHours = 24;
|
||||
if (age.equals(MainApp.sResources.getString(R.string.key_teenage))) defaultHours = 4;
|
||||
if (age.equals(MainApp.sResources.getString(R.string.key_child))) defaultHours = 4;
|
||||
int hoursForDetection = SP.getInt(R.string.key_openapsama_autosens_period, defaultHours);
|
||||
|
||||
long now = System.currentTimeMillis();
|
||||
|
||||
if (autosensDataTable == null || autosensDataTable.size() < 4) {
|
||||
log.debug("No autosens data available");
|
||||
return new AutosensResult();
|
||||
}
|
||||
|
||||
AutosensData current = IobCobCalculatorPlugin.getAutosensData(toTime);
|
||||
if (current == null) {
|
||||
log.debug("No autosens data available");
|
||||
return new AutosensResult();
|
||||
}
|
||||
|
||||
|
||||
List<Double> deviationsArray = new ArrayList<>();
|
||||
String pastSensitivity = "";
|
||||
int index = 0;
|
||||
while (index < autosensDataTable.size()) {
|
||||
AutosensData autosensData = autosensDataTable.valueAt(index);
|
||||
|
||||
if (autosensData.time < fromTime) {
|
||||
index++;
|
||||
continue;
|
||||
}
|
||||
|
||||
if (autosensData.time > toTime) {
|
||||
index++;
|
||||
continue;
|
||||
}
|
||||
|
||||
if (autosensData.time > now - hoursForDetection * 60 * 60 * 1000L)
|
||||
deviationsArray.add(autosensData.nonEqualDeviation ? autosensData.deviation : 0d);
|
||||
if (deviationsArray.size() > hoursForDetection * 60 / 5)
|
||||
deviationsArray.remove(0);
|
||||
|
||||
|
||||
pastSensitivity += autosensData.pastSensitivity;
|
||||
int secondsFromMidnight = Profile.secondsFromMidnight(autosensData.time);
|
||||
if (secondsFromMidnight % 3600 < 2.5 * 60 || secondsFromMidnight % 3600 > 57.5 * 60) {
|
||||
pastSensitivity += "(" + Math.round(secondsFromMidnight / 3600d) + ")";
|
||||
}
|
||||
index++;
|
||||
}
|
||||
|
||||
Double[] deviations = new Double[deviationsArray.size()];
|
||||
deviations = deviationsArray.toArray(deviations);
|
||||
|
||||
Profile profile = MainApp.getConfigBuilder().getProfile();
|
||||
|
||||
double sens = profile.getIsf();
|
||||
|
||||
String ratioLimit = "";
|
||||
String sensResult = "";
|
||||
|
||||
log.debug("Records: " + index + " " + pastSensitivity);
|
||||
Arrays.sort(deviations);
|
||||
|
||||
double percentile = IobCobCalculatorPlugin.percentile(deviations, 0.50);
|
||||
double basalOff = percentile * (60 / 5) / Profile.toMgdl(sens, profile.getUnits());
|
||||
double ratio = 1 + (basalOff / profile.getMaxDailyBasal());
|
||||
|
||||
if (percentile < 0) { // sensitive
|
||||
sensResult = "Excess insulin sensitivity detected";
|
||||
} else if (percentile > 0) { // resistant
|
||||
sensResult = "Excess insulin resistance detected";
|
||||
} else {
|
||||
sensResult = "Sensitivity normal";
|
||||
}
|
||||
|
||||
log.debug(sensResult);
|
||||
|
||||
double rawRatio = ratio;
|
||||
ratio = Math.max(ratio, SafeParse.stringToDouble(SP.getString("openapsama_autosens_min", "0.7")));
|
||||
ratio = Math.min(ratio, SafeParse.stringToDouble(SP.getString("openapsama_autosens_max", "1.2")));
|
||||
|
||||
if (ratio != rawRatio) {
|
||||
ratioLimit = "Ratio limited from " + rawRatio + " to " + ratio;
|
||||
log.debug(ratioLimit);
|
||||
}
|
||||
|
||||
log.error("Sensitivity to: " + new Date(toTime).toLocaleString() + " percentile: " + percentile);
|
||||
|
||||
AutosensResult output = new AutosensResult();
|
||||
output.ratio = Round.roundTo(ratio, 0.01);
|
||||
output.carbsAbsorbed = Round.roundTo(current.cob, 0.01);
|
||||
output.pastSensitivity = pastSensitivity;
|
||||
output.ratioLimit = ratioLimit;
|
||||
output.sensResult = sensResult;
|
||||
return output;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,210 @@
|
|||
package info.nightscout.androidaps.plugins.SensitivityOref0;
|
||||
|
||||
import android.support.v4.util.LongSparseArray;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import info.nightscout.androidaps.MainApp;
|
||||
import info.nightscout.androidaps.R;
|
||||
import info.nightscout.androidaps.data.Profile;
|
||||
import info.nightscout.androidaps.interfaces.PluginBase;
|
||||
import info.nightscout.androidaps.interfaces.SensitivityInterface;
|
||||
import info.nightscout.androidaps.plugins.IobCobCalculator.AutosensData;
|
||||
import info.nightscout.androidaps.plugins.IobCobCalculator.AutosensResult;
|
||||
import info.nightscout.androidaps.plugins.IobCobCalculator.IobCobCalculatorPlugin;
|
||||
import info.nightscout.utils.Round;
|
||||
import info.nightscout.utils.SP;
|
||||
import info.nightscout.utils.SafeParse;
|
||||
|
||||
/**
|
||||
* Created by mike on 24.06.2017.
|
||||
*/
|
||||
|
||||
public class SensitivityOref0Plugin implements PluginBase, SensitivityInterface {
|
||||
private static Logger log = LoggerFactory.getLogger(IobCobCalculatorPlugin.class);
|
||||
|
||||
private static boolean fragmentEnabled = true;
|
||||
private static boolean fragmentVisible = false;
|
||||
|
||||
static SensitivityOref0Plugin plugin = null;
|
||||
|
||||
public static SensitivityOref0Plugin getPlugin() {
|
||||
if (plugin == null)
|
||||
plugin = new SensitivityOref0Plugin();
|
||||
return plugin;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getType() {
|
||||
return SENSITIVITY;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getFragmentClass() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return MainApp.sResources.getString(R.string.sensitivityoref0);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getNameShort() {
|
||||
return MainApp.sResources.getString(R.string.sensitivity_shortname);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isEnabled(int type) {
|
||||
return type == SENSITIVITY && fragmentEnabled;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isVisibleInTabs(int type) {
|
||||
return type == SENSITIVITY && fragmentVisible;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canBeHidden(int type) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasFragment() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean showInList(int type) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setFragmentEnabled(int type, boolean fragmentEnabled) {
|
||||
if (type == SENSITIVITY) this.fragmentEnabled = fragmentEnabled;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setFragmentVisible(int type, boolean fragmentVisible) {
|
||||
if (type == SENSITIVITY) this.fragmentVisible = fragmentVisible;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public AutosensResult detectSensitivity(long fromTime, long toTime) {
|
||||
LongSparseArray<AutosensData> autosensDataTable = IobCobCalculatorPlugin.getAutosensDataTable();
|
||||
|
||||
String age = SP.getString(R.string.key_age, "");
|
||||
int defaultHours = 24;
|
||||
if (age.equals(MainApp.sResources.getString(R.string.key_adult))) defaultHours = 24;
|
||||
if (age.equals(MainApp.sResources.getString(R.string.key_teenage))) defaultHours = 24;
|
||||
if (age.equals(MainApp.sResources.getString(R.string.key_child))) defaultHours = 24;
|
||||
int hoursForDetection = SP.getInt(R.string.key_openapsama_autosens_period, defaultHours);
|
||||
|
||||
long now = System.currentTimeMillis();
|
||||
|
||||
if (autosensDataTable == null || autosensDataTable.size() < 4) {
|
||||
log.debug("No autosens data available");
|
||||
return new AutosensResult();
|
||||
}
|
||||
|
||||
AutosensData current = IobCobCalculatorPlugin.getLastAutosensData();
|
||||
if (current == null) {
|
||||
log.debug("No current autosens data available");
|
||||
return new AutosensResult();
|
||||
}
|
||||
|
||||
|
||||
List<Double> deviationsArray = new ArrayList<>();
|
||||
String pastSensitivity = "";
|
||||
int index = 0;
|
||||
while (index < autosensDataTable.size()) {
|
||||
AutosensData autosensData = autosensDataTable.valueAt(index);
|
||||
|
||||
if (autosensData.time < fromTime) {
|
||||
index++;
|
||||
continue;
|
||||
}
|
||||
|
||||
if (autosensData.time > toTime) {
|
||||
index++;
|
||||
continue;
|
||||
}
|
||||
|
||||
if (autosensData.time > now - hoursForDetection * 60 * 60 * 1000L)
|
||||
deviationsArray.add(autosensData.nonEqualDeviation ? autosensData.deviation : 0d);
|
||||
if (deviationsArray.size() > hoursForDetection * 60 / 5)
|
||||
deviationsArray.remove(0);
|
||||
|
||||
pastSensitivity += autosensData.pastSensitivity;
|
||||
int secondsFromMidnight = Profile.secondsFromMidnight(autosensData.time);
|
||||
if (secondsFromMidnight % 3600 < 2.5 * 60 || secondsFromMidnight % 3600 > 57.5 * 60) {
|
||||
pastSensitivity += "(" + Math.round(secondsFromMidnight / 3600d) + ")";
|
||||
}
|
||||
index++;
|
||||
}
|
||||
|
||||
Double[] deviations = new Double[deviationsArray.size()];
|
||||
deviations = deviationsArray.toArray(deviations);
|
||||
|
||||
Profile profile = MainApp.getConfigBuilder().getProfile();
|
||||
|
||||
double sens = profile.getIsf();
|
||||
|
||||
double ratio = 1;
|
||||
String ratioLimit = "";
|
||||
String sensResult = "";
|
||||
|
||||
log.debug("Records: " + index + " " + pastSensitivity);
|
||||
Arrays.sort(deviations);
|
||||
|
||||
for (double i = 0.9; i > 0.1; i = i - 0.02) {
|
||||
if (IobCobCalculatorPlugin.percentile(deviations, (i + 0.02)) >= 0 && IobCobCalculatorPlugin.percentile(deviations, i) < 0) {
|
||||
log.debug(Math.round(100 * i) + "% of non-meal deviations negative (target 45%-50%)");
|
||||
}
|
||||
}
|
||||
double pSensitive = IobCobCalculatorPlugin.percentile(deviations, 0.50);
|
||||
double pResistant = IobCobCalculatorPlugin.percentile(deviations, 0.45);
|
||||
|
||||
double basalOff = 0;
|
||||
|
||||
if (pSensitive < 0) { // sensitive
|
||||
basalOff = pSensitive * (60 / 5) / Profile.toMgdl(sens, profile.getUnits());
|
||||
sensResult = "Excess insulin sensitivity detected";
|
||||
} else if (pResistant > 0) { // resistant
|
||||
basalOff = pResistant * (60 / 5) / Profile.toMgdl(sens, profile.getUnits());
|
||||
sensResult = "Excess insulin resistance detected";
|
||||
} else {
|
||||
sensResult = "Sensitivity normal";
|
||||
}
|
||||
log.debug(sensResult);
|
||||
ratio = 1 + (basalOff / profile.getMaxDailyBasal());
|
||||
|
||||
double rawRatio = ratio;
|
||||
ratio = Math.max(ratio, SafeParse.stringToDouble(SP.getString("openapsama_autosens_min", "0.7")));
|
||||
ratio = Math.min(ratio, SafeParse.stringToDouble(SP.getString("openapsama_autosens_max", "1.2")));
|
||||
|
||||
if (ratio != rawRatio) {
|
||||
ratioLimit = "Ratio limited from " + rawRatio + " to " + ratio;
|
||||
log.debug(ratioLimit);
|
||||
}
|
||||
|
||||
double newisf = Math.round(Profile.toMgdl(sens, profile.getUnits()) / ratio);
|
||||
if (ratio != 1) {
|
||||
log.debug("ISF adjusted from " + Profile.toMgdl(sens, profile.getUnits()) + " to " + newisf);
|
||||
}
|
||||
|
||||
AutosensResult output = new AutosensResult();
|
||||
output.ratio = Round.roundTo(ratio, 0.01);
|
||||
output.carbsAbsorbed = Round.roundTo(current.cob, 0.01);
|
||||
output.pastSensitivity = pastSensitivity;
|
||||
output.ratioLimit = ratioLimit;
|
||||
output.sensResult = sensResult;
|
||||
return output;
|
||||
}
|
||||
}
|
|
@ -1,14 +0,0 @@
|
|||
package info.nightscout.androidaps.plugins.SourceGlimp;
|
||||
|
||||
|
||||
import android.support.v4.app.Fragment;
|
||||
|
||||
public class SourceGlimpFragment extends Fragment {
|
||||
|
||||
private static SourceGlimpPlugin sourceGlimpPlugin = new SourceGlimpPlugin();
|
||||
|
||||
public static SourceGlimpPlugin getPlugin() {
|
||||
return sourceGlimpPlugin;
|
||||
}
|
||||
|
||||
}
|
|
@ -4,7 +4,6 @@ import info.nightscout.androidaps.MainApp;
|
|||
import info.nightscout.androidaps.R;
|
||||
import info.nightscout.androidaps.interfaces.BgSourceInterface;
|
||||
import info.nightscout.androidaps.interfaces.PluginBase;
|
||||
import info.nightscout.androidaps.plugins.SourceMM640g.SourceMM640gFragment;
|
||||
|
||||
/**
|
||||
* Created by mike on 05.08.2016.
|
||||
|
@ -12,9 +11,17 @@ import info.nightscout.androidaps.plugins.SourceMM640g.SourceMM640gFragment;
|
|||
public class SourceGlimpPlugin implements PluginBase, BgSourceInterface {
|
||||
boolean fragmentEnabled = false;
|
||||
|
||||
static SourceGlimpPlugin plugin = null;
|
||||
|
||||
public static SourceGlimpPlugin getPlugin() {
|
||||
if (plugin == null)
|
||||
plugin = new SourceGlimpPlugin();
|
||||
return plugin;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getFragmentClass() {
|
||||
return SourceGlimpFragment.class.getName();
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -1,14 +0,0 @@
|
|||
package info.nightscout.androidaps.plugins.SourceMM640g;
|
||||
|
||||
|
||||
import android.support.v4.app.Fragment;
|
||||
|
||||
public class SourceMM640gFragment extends Fragment {
|
||||
|
||||
private static SourceMM640gPlugin sourceMM640gPlugin = new SourceMM640gPlugin();
|
||||
|
||||
public static SourceMM640gPlugin getPlugin() {
|
||||
return sourceMM640gPlugin;
|
||||
}
|
||||
|
||||
}
|
|
@ -4,7 +4,7 @@ import info.nightscout.androidaps.MainApp;
|
|||
import info.nightscout.androidaps.R;
|
||||
import info.nightscout.androidaps.interfaces.BgSourceInterface;
|
||||
import info.nightscout.androidaps.interfaces.PluginBase;
|
||||
import info.nightscout.androidaps.plugins.SourceNSClient.SourceNSClientFragment;
|
||||
import info.nightscout.androidaps.plugins.SourceGlimp.SourceGlimpPlugin;
|
||||
|
||||
/**
|
||||
* Created by mike on 05.08.2016.
|
||||
|
@ -12,9 +12,17 @@ import info.nightscout.androidaps.plugins.SourceNSClient.SourceNSClientFragment;
|
|||
public class SourceMM640gPlugin implements PluginBase, BgSourceInterface {
|
||||
boolean fragmentEnabled = false;
|
||||
|
||||
static SourceGlimpPlugin plugin = null;
|
||||
|
||||
public static SourceGlimpPlugin getPlugin() {
|
||||
if (plugin == null)
|
||||
plugin = new SourceGlimpPlugin();
|
||||
return plugin;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getFragmentClass() {
|
||||
return SourceMM640gFragment.class.getName();
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -1,14 +0,0 @@
|
|||
package info.nightscout.androidaps.plugins.SourceNSClient;
|
||||
|
||||
|
||||
import android.support.v4.app.Fragment;
|
||||
|
||||
public class SourceNSClientFragment extends Fragment {
|
||||
|
||||
private static SourceNSClientPlugin sourceNSClientPlugin = new SourceNSClientPlugin();
|
||||
|
||||
public static SourceNSClientPlugin getPlugin() {
|
||||
return sourceNSClientPlugin;
|
||||
}
|
||||
|
||||
}
|
|
@ -12,9 +12,17 @@ import info.nightscout.androidaps.interfaces.PluginBase;
|
|||
public class SourceNSClientPlugin implements PluginBase, BgSourceInterface {
|
||||
boolean fragmentEnabled = true;
|
||||
|
||||
static SourceNSClientPlugin plugin = null;
|
||||
|
||||
public static SourceNSClientPlugin getPlugin() {
|
||||
if (plugin == null)
|
||||
plugin = new SourceNSClientPlugin();
|
||||
return plugin;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getFragmentClass() {
|
||||
return SourceNSClientFragment.class.getName();
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -1,13 +0,0 @@
|
|||
package info.nightscout.androidaps.plugins.SourceXdrip;
|
||||
|
||||
|
||||
import android.support.v4.app.Fragment;
|
||||
|
||||
public class SourceXdripFragment extends Fragment {
|
||||
|
||||
private static SourceXdripPlugin sourceXdripPlugin = new SourceXdripPlugin();
|
||||
|
||||
public static SourceXdripPlugin getPlugin() {
|
||||
return sourceXdripPlugin;
|
||||
}
|
||||
}
|
|
@ -4,16 +4,23 @@ import info.nightscout.androidaps.MainApp;
|
|||
import info.nightscout.androidaps.R;
|
||||
import info.nightscout.androidaps.interfaces.BgSourceInterface;
|
||||
import info.nightscout.androidaps.interfaces.PluginBase;
|
||||
import info.nightscout.androidaps.plugins.SourceNSClient.SourceNSClientFragment;
|
||||
|
||||
/**
|
||||
* Created by mike on 05.08.2016.
|
||||
*/
|
||||
public class SourceXdripPlugin implements PluginBase, BgSourceInterface {
|
||||
|
||||
static SourceXdripPlugin plugin = null;
|
||||
|
||||
public static SourceXdripPlugin getPlugin() {
|
||||
if (plugin == null)
|
||||
plugin = new SourceXdripPlugin();
|
||||
return plugin;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getFragmentClass() {
|
||||
return SourceNSClientFragment.class.getName();
|
||||
return null;
|
||||
}
|
||||
|
||||
private static boolean fragmentEnabled = false;
|
||||
|
|
|
@ -182,7 +182,7 @@ public class TreatmentsPlugin implements PluginBase, TreatmentsInterface {
|
|||
Iob tIOB = t.iobCalc(time, dia);
|
||||
total.iob += tIOB.iobContrib;
|
||||
total.activity += tIOB.activityContrib;
|
||||
Iob bIOB = t.iobCalc(time, dia / SP.getInt("openapsama_bolussnooze_dia_divisor", 2));
|
||||
Iob bIOB = t.iobCalc(time, dia / SP.getDouble("openapsama_bolussnooze_dia_divisor", 2.0));
|
||||
total.bolussnooze += bIOB.iobContrib;
|
||||
}
|
||||
|
||||
|
@ -242,7 +242,7 @@ public class TreatmentsPlugin implements PluginBase, TreatmentsInterface {
|
|||
List<Treatment> in5minback = new ArrayList<>();
|
||||
for (Integer pos = 0; pos < treatments.size(); pos++) {
|
||||
Treatment t = treatments.get(pos);
|
||||
if (t.date <= time && t.date > time - 5 * 60 * 1000)
|
||||
if (t.date <= time && t.date > time - 5 * 60 * 1000 && t.carbs > 0)
|
||||
in5minback.add(t);
|
||||
}
|
||||
return in5minback;
|
||||
|
|
|
@ -1,29 +0,0 @@
|
|||
package info.nightscout.androidaps.plugins.XDripStatusline;
|
||||
|
||||
import android.content.Context;
|
||||
import android.os.Bundle;
|
||||
import android.support.v4.app.Fragment;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
|
||||
import info.nightscout.androidaps.R;
|
||||
|
||||
/**
|
||||
* Created by adrian on 17/11/16.
|
||||
*/
|
||||
|
||||
public class StatuslineFragment extends Fragment {
|
||||
|
||||
private static StatuslinePlugin statuslinePlugin;
|
||||
|
||||
public static StatuslinePlugin getPlugin(Context ctx) {
|
||||
|
||||
if (statuslinePlugin == null) {
|
||||
statuslinePlugin = new StatuslinePlugin(ctx);
|
||||
}
|
||||
|
||||
return statuslinePlugin;
|
||||
}
|
||||
|
||||
}
|
|
@ -44,6 +44,17 @@ public class StatuslinePlugin implements PluginBase {
|
|||
private final Context ctx;
|
||||
SharedPreferences mPrefs;
|
||||
|
||||
private static StatuslinePlugin statuslinePlugin;
|
||||
|
||||
public static StatuslinePlugin getPlugin(Context ctx) {
|
||||
|
||||
if (statuslinePlugin == null) {
|
||||
statuslinePlugin = new StatuslinePlugin(ctx);
|
||||
}
|
||||
|
||||
return statuslinePlugin;
|
||||
}
|
||||
|
||||
StatuslinePlugin(Context ctx) {
|
||||
this.ctx = ctx;
|
||||
this.mPrefs = PreferenceManager.getDefaultSharedPreferences(ctx);
|
||||
|
@ -56,7 +67,7 @@ public class StatuslinePlugin implements PluginBase {
|
|||
|
||||
@Override
|
||||
public String getFragmentClass() {
|
||||
return StatuslineFragment.class.getName();
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -59,7 +59,7 @@ public class TabPageAdapter extends FragmentStatePagerAdapter {
|
|||
}
|
||||
|
||||
public void registerNewFragment(PluginBase plugin) {
|
||||
if (plugin.isVisibleInTabs(plugin.getType())) {
|
||||
if (plugin.hasFragment() && plugin.isVisibleInTabs(plugin.getType())) {
|
||||
visibleFragmentList.add(plugin);
|
||||
notifyDataSetChanged();
|
||||
}
|
||||
|
|
|
@ -49,11 +49,19 @@ public class SP {
|
|||
}
|
||||
|
||||
static public int getInt(int resourceID, Integer defaultValue) {
|
||||
return SafeParse.stringToInt(sharedPreferences.getString(MainApp.sResources.getString(resourceID), defaultValue.toString()));
|
||||
try {
|
||||
return sharedPreferences.getInt(MainApp.sResources.getString(resourceID), defaultValue);
|
||||
} catch (Exception e) {
|
||||
return SafeParse.stringToInt(sharedPreferences.getString(MainApp.sResources.getString(resourceID), defaultValue.toString()));
|
||||
}
|
||||
}
|
||||
|
||||
static public int getInt(String key, Integer defaultValue) {
|
||||
return SafeParse.stringToInt(sharedPreferences.getString(key, defaultValue.toString()));
|
||||
try {
|
||||
return sharedPreferences.getInt(key, defaultValue);
|
||||
} catch (Exception e) {
|
||||
return SafeParse.stringToInt(sharedPreferences.getString(key, defaultValue.toString()));
|
||||
}
|
||||
}
|
||||
|
||||
static public long getLong(int resourceID, Long defaultValue) {
|
||||
|
@ -92,6 +100,24 @@ public class SP {
|
|||
editor.apply();
|
||||
}
|
||||
|
||||
static public void putLong(int resourceID, long value) {
|
||||
SharedPreferences.Editor editor = sharedPreferences.edit();
|
||||
editor.putLong(MainApp.sResources.getString(resourceID), value);
|
||||
editor.apply();
|
||||
}
|
||||
|
||||
static public void putInt(String key, int value) {
|
||||
SharedPreferences.Editor editor = sharedPreferences.edit();
|
||||
editor.putInt(key, value);
|
||||
editor.apply();
|
||||
}
|
||||
|
||||
static public void putInt(int resourceID, int value) {
|
||||
SharedPreferences.Editor editor = sharedPreferences.edit();
|
||||
editor.putInt(MainApp.sResources.getString(resourceID), value);
|
||||
editor.apply();
|
||||
}
|
||||
|
||||
static public void putString(int resourceID, String value) {
|
||||
SharedPreferences.Editor editor = sharedPreferences.edit();
|
||||
editor.putString(MainApp.sResources.getString(resourceID), value);
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -41,7 +41,6 @@
|
|||
android:layout_marginRight="10dp"
|
||||
android:background="@color/cardColorBackground" />
|
||||
|
||||
|
||||
<TextView
|
||||
android:id="@+id/configbuilder_bgsourcelabel"
|
||||
android:layout_width="wrap_content"
|
||||
|
@ -77,6 +76,21 @@
|
|||
android:layout_marginRight="10dp"
|
||||
android:background="@color/cardColorBackground" />
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginLeft="5dp"
|
||||
android:text="@string/configbuilder_sensitivity"
|
||||
android:textAppearance="?android:attr/textAppearanceSmall"
|
||||
android:textStyle="bold" />
|
||||
|
||||
<ListView
|
||||
android:id="@+id/configbuilder_sensitivitylistview"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginLeft="10dp"
|
||||
android:layout_marginRight="10dp"
|
||||
android:background="@color/cardColorBackground" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/configbuilder_apslabel"
|
||||
|
@ -180,45 +194,6 @@
|
|||
android:layout_marginRight="10dp"
|
||||
android:background="@color/cardColorBackground" />
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="horizontal">
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/configbuilder_nsclientversion_label"
|
||||
android:textAppearance="?android:attr/textAppearanceSmall" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/configbuilder_nsclientversion"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginLeft="10dp"
|
||||
android:textAppearance="?android:attr/textAppearanceMedium" />
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginBottom="10dp"
|
||||
android:orientation="horizontal">
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/configbuilder_nightscoutversion_label"
|
||||
android:textAppearance="?android:attr/textAppearanceSmall" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/configbuilder_nightscoutversion"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginLeft="10dp"
|
||||
android:textAppearance="?android:attr/textAppearanceMedium" />
|
||||
</LinearLayout>
|
||||
|
||||
</LinearLayout>
|
||||
</LinearLayout>
|
||||
</ScrollView>
|
||||
|
|
|
@ -380,7 +380,7 @@
|
|||
android:layout_weight="2"
|
||||
android:gravity="center_horizontal"
|
||||
android:paddingRight="5dp"
|
||||
android:text="@string/openapsma_result_label"
|
||||
android:text="@string/result"
|
||||
android:textColor="@android:color/white"
|
||||
android:textSize="14sp" />
|
||||
|
||||
|
@ -451,7 +451,7 @@
|
|||
android:layout_weight="2"
|
||||
android:gravity="end"
|
||||
android:paddingRight="5dp"
|
||||
android:text="@string/openapsma_result_label"
|
||||
android:text="@string/result"
|
||||
android:textSize="14sp" />
|
||||
|
||||
<TextView
|
||||
|
|
|
@ -335,7 +335,7 @@
|
|||
android:layout_weight="2"
|
||||
android:gravity="center_horizontal"
|
||||
android:paddingRight="5dp"
|
||||
android:text="@string/openapsma_result_label"
|
||||
android:text="@string/result"
|
||||
android:textColor="@android:color/white"
|
||||
android:textSize="14sp" />
|
||||
|
||||
|
@ -361,7 +361,7 @@
|
|||
android:layout_weight="2"
|
||||
android:gravity="end"
|
||||
android:paddingRight="5dp"
|
||||
android:text="@string/openapsma_result_label"
|
||||
android:text="@string/result"
|
||||
android:textSize="14sp" />
|
||||
|
||||
<TextView
|
||||
|
|
|
@ -9,47 +9,43 @@
|
|||
<ScrollView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:orientation="vertical"
|
||||
android:padding="10dp">
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical">
|
||||
android:layout_gravity="center_horizontal"
|
||||
android:padding="10dp"
|
||||
android:text="@string/overview_calibration_bg_label"
|
||||
android:textAppearance="?android:attr/textAppearanceLarge" />
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_horizontal"
|
||||
android:padding="10dp"
|
||||
android:text="@string/overview_calibration_bg_label"
|
||||
android:textAppearance="?android:attr/textAppearanceLarge" />
|
||||
<TextView
|
||||
android:id="@+id/overview_calibration_units"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_horizontal"
|
||||
android:layout_marginBottom="10dp"
|
||||
android:textAppearance="?android:attr/textAppearanceSmall" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/overview_calibration_units"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_horizontal"
|
||||
android:layout_marginBottom="10dp"
|
||||
android:textAppearance="?android:attr/textAppearanceSmall" />
|
||||
|
||||
<info.nightscout.utils.NumberPicker
|
||||
android:id="@+id/overview_calibration_bg"
|
||||
android:layout_width="130dp"
|
||||
android:layout_height="40dp"
|
||||
android:layout_gravity="center_horizontal"
|
||||
android:layout_marginBottom="20dp"
|
||||
android:layout_marginLeft="30dp"
|
||||
android:layout_marginRight="30dp" />
|
||||
<info.nightscout.utils.NumberPicker
|
||||
android:id="@+id/overview_calibration_bg"
|
||||
android:layout_width="130dp"
|
||||
android:layout_height="40dp"
|
||||
android:layout_gravity="center_horizontal"
|
||||
android:layout_marginBottom="20dp"
|
||||
android:layout_marginLeft="30dp"
|
||||
android:layout_marginRight="30dp" />
|
||||
|
||||
|
||||
<include layout="@layout/mdtp_done_button" />
|
||||
|
||||
</LinearLayout>
|
||||
<include layout="@layout/mdtp_done_button" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
</ScrollView>
|
||||
|
||||
</FrameLayout>
|
|
@ -329,6 +329,22 @@
|
|||
android:layout_marginBottom="-5dp"
|
||||
android:layout_marginTop="-9dp"
|
||||
app:buttonTint="@color/deviations" />
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_horizontal"
|
||||
android:text="@string/ratio_short"
|
||||
android:textAppearance="?android:attr/textAppearanceSmall"
|
||||
android:textStyle="bold" />
|
||||
|
||||
<CheckBox
|
||||
android:id="@+id/overview_showratios"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginBottom="-5dp"
|
||||
android:layout_marginTop="-9dp" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
|
|
|
@ -324,6 +324,21 @@
|
|||
android:layout_marginTop="-9dp"
|
||||
app:buttonTint="@color/deviations" />
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_horizontal"
|
||||
android:text="@string/ratio_short"
|
||||
android:textAppearance="?android:attr/textAppearanceSmall"
|
||||
android:textStyle="bold" />
|
||||
|
||||
<CheckBox
|
||||
android:id="@+id/overview_showratios"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginBottom="-5dp"
|
||||
android:layout_marginTop="-9dp" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
|
|
|
@ -652,6 +652,22 @@
|
|||
android:layout_marginBottom="-5dp"
|
||||
android:layout_marginTop="-9dp"
|
||||
app:buttonTint="@color/deviations" />
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_horizontal"
|
||||
android:text="@string/ratio_short"
|
||||
android:textAppearance="?android:attr/textAppearanceSmall"
|
||||
android:textStyle="bold" />
|
||||
|
||||
<CheckBox
|
||||
android:id="@+id/overview_showratios"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginBottom="-5dp"
|
||||
android:layout_marginTop="-9dp" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
|
|
|
@ -11,7 +11,6 @@
|
|||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
|
||||
android:orientation="vertical">
|
||||
|
||||
<LinearLayout
|
||||
|
@ -202,11 +201,18 @@
|
|||
|
||||
<include layout="@layout/mdtp_done_button" />
|
||||
|
||||
<View
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="2dip"
|
||||
android:layout_marginBottom="5dp"
|
||||
android:layout_marginLeft="20dp"
|
||||
android:layout_marginTop="-15dp"
|
||||
android:background="@color/listdelimiter" />
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center"
|
||||
android:layout_marginTop="-20dp"
|
||||
android:orientation="horizontal">
|
||||
|
||||
<CheckBox
|
||||
|
|
|
@ -111,7 +111,7 @@
|
|||
<string name="openapsma_nopump">Няма данни за помпа</string>
|
||||
<string name="openapsma_profile_label">Профил</string>
|
||||
<string name="openapsma_request_label">Искане</string>
|
||||
<string name="openapsma_result_label">Резултат</string>
|
||||
<string name="result">Резултат</string>
|
||||
<string name="openapsma_run">Старт сега</string>
|
||||
<string name="openloop_newsuggestion">Достъпно е ново предложение</string>
|
||||
<string name="overview">Преглед</string>
|
||||
|
@ -171,7 +171,6 @@
|
|||
<string name="careportal_newnstreatment_glucosetype">КЗ тип</string>
|
||||
<string name="openapsma">OpenAPS MA</string>
|
||||
<string name="configbuilder_nightscoutversion_label">Nightscout версия:</string>
|
||||
<string name="configbuilder_nsclientversion_label">NSClient версия:</string>
|
||||
<string name="send">ИЗПРАТИ</string>
|
||||
<string name="missing">Липсва</string>
|
||||
<string name="enabled">Разрешено</string>
|
||||
|
|
|
@ -111,7 +111,7 @@
|
|||
<string name="openapsma_nopump">Žádná pumpa</string>
|
||||
<string name="openapsma_profile_label">Profil</string>
|
||||
<string name="openapsma_request_label">Požadavek</string>
|
||||
<string name="openapsma_result_label">Výsledek</string>
|
||||
<string name="result">Výsledek</string>
|
||||
<string name="openapsma_run">Sputit teď</string>
|
||||
<string name="openloop_newsuggestion">Dostupné nové doporučení</string>
|
||||
<string name="overview">Přehled</string>
|
||||
|
@ -172,7 +172,6 @@
|
|||
<string name="careportal_newnstreatment_glucosetype">Zadání glykémie</string>
|
||||
<string name="openapsma">OpenAPS MA</string>
|
||||
<string name="configbuilder_nightscoutversion_label">Verze Nightscoutu:</string>
|
||||
<string name="configbuilder_nsclientversion_label">Verze NSClienta:</string>
|
||||
<string name="send">POSLAT</string>
|
||||
<string name="missing">Chybí</string>
|
||||
<string name="enabled">Povolený</string>
|
||||
|
|
|
@ -53,7 +53,6 @@
|
|||
<string name="configbuilder_bgsource">BZ Quelle</string>
|
||||
<string name="configbuilder_loop">Loop</string>
|
||||
<string name="configbuilder_nightscoutversion_label">Nightscout Version:</string>
|
||||
<string name="configbuilder_nsclientversion_label">NSClient Version:</string>
|
||||
<string name="configbuilder_tempbasals">Temp Basals</string>
|
||||
<string name="delta">Delta</string>
|
||||
<string name="duration">Dauer</string>
|
||||
|
@ -124,7 +123,7 @@
|
|||
<string name="overview_extendedbolus_button">Extended Bolus</string>
|
||||
<string name="overview">Übersicht</string>
|
||||
<string name="openloop_newsuggestion">Neue Empfehlung verfügbar</string>
|
||||
<string name="openapsma_result_label">Ergebnis</string>
|
||||
<string name="result">Ergebnis</string>
|
||||
<string name="openapsma_request_label">Anfrage</string>
|
||||
<string name="openapsma_run">Run now</string>
|
||||
<string name="openapsma_nopump">Keine Pumpe verfügbar</string>
|
||||
|
|
|
@ -60,7 +60,7 @@
|
|||
<string name="openapsma_iobdata_label">IOB datos</string>
|
||||
<string name="openapsma_profile_label">Perfil</string>
|
||||
<string name="openapsma_mealdata_label">Datos de comidas</string>
|
||||
<string name="openapsma_result_label">Resultado</string>
|
||||
<string name="result">Resultado</string>
|
||||
<string name="openapsma_noglucosedata">No hay disponibles datos de glucosa</string>
|
||||
<string name="openapsma_noprofile">Sin perfil disponible</string>
|
||||
<string name="openapsma_nopump">No se dispone de bomba</string>
|
||||
|
@ -179,7 +179,6 @@
|
|||
<string name="noprofile">Pendiente carga perfil NS</string>
|
||||
<string name="overview_tempbasal_button">Basal Temporal</string>
|
||||
<string name="overview_extendedbolus_button">Bolo extendido</string>
|
||||
<string name="configbuilder_nsclientversion_label">NSClient versión:</string>
|
||||
<string name="configbuilder_nightscoutversion_label">Nightscout versión:</string>
|
||||
<string name="send">ENVIAR</string>
|
||||
<string name="missing">Faltan</string>
|
||||
|
|
|
@ -81,7 +81,6 @@
|
|||
<string name="configbuilder_insulin">Insulina</string>
|
||||
<string name="configbuilder_loop">Loop</string>
|
||||
<string name="configbuilder_nightscoutversion_label">Versione Nightscout</string>
|
||||
<string name="configbuilder_nsclientversion_label">Versione NSClient</string>
|
||||
<string name="configbuilder_profile">Profilo</string>
|
||||
<string name="configbuilder_pump">Microinfusore</string>
|
||||
<string name="configbuilder_shortname">Configurazione</string>
|
||||
|
@ -299,7 +298,7 @@
|
|||
<string name="dont_show_again">Non mostrarlo più</string>
|
||||
<string name="enablesuperbolus_summary">Abilita funzionalità superbolus nella procedura guidata. Non abilitare fino a quando non impari quello che realmente fa. PUÒ CAUSARE L\'INVERTIMENTO INSULINO SE USATO BLINDLY!</string>
|
||||
<string name="openapsma_request_label">Richiesta</string>
|
||||
<string name="openapsma_result_label">Esito</string>
|
||||
<string name="result">Esito</string>
|
||||
<string name="openapsma_run">Avvia ora</string>
|
||||
<string name="openloop">Apertura Loop</string>
|
||||
<string name="othersettings_title">Altro</string>
|
||||
|
|
|
@ -62,7 +62,7 @@
|
|||
<string name="openapsma_iobdata_label">IOB 데이터</string>
|
||||
<string name="openapsma_profile_label">프로파일</string>
|
||||
<string name="openapsma_mealdata_label">식사 데이터</string>
|
||||
<string name="openapsma_result_label">결과</string>
|
||||
<string name="result">결과</string>
|
||||
<string name="openapsma_noglucosedata">혈당 데이터 없음</string>
|
||||
<string name="openapsma_noprofile">프로파일 없음</string>
|
||||
<string name="openapsma_nopump">No pump available</string>
|
||||
|
@ -180,7 +180,6 @@
|
|||
<string name="noprofile">아직 NS에서 프로파일을 로드하지 못했습니다.</string>
|
||||
<string name="overview_tempbasal_button">임시기초주입</string>
|
||||
<string name="overview_extendedbolus_button">확장식사주입</string>
|
||||
<string name="configbuilder_nsclientversion_label">NSClient 버전:</string>
|
||||
<string name="configbuilder_nightscoutversion_label">Nightscout 버전:</string>
|
||||
<string name="send">보내기</string>
|
||||
<string name="missing">Missing</string>
|
||||
|
|
|
@ -97,7 +97,6 @@
|
|||
<string name="configbuilder_insulin">инсулин</string>
|
||||
<string name="configbuilder_loop">замкнутый цикл</string>
|
||||
<string name="configbuilder_nightscoutversion_label">версия Nightscout:</string>
|
||||
<string name="configbuilder_nsclientversion_label">версия NSClient:</string>
|
||||
<string name="configbuilder_profile">профиль</string>
|
||||
<string name="configbuilder_pump">помпа</string>
|
||||
<string name="configbuilder_shortname">КОНФ</string>
|
||||
|
@ -366,7 +365,7 @@
|
|||
<string name="openapsma_nopump">помпа недоступна</string>
|
||||
<string name="openapsma_profile_label">профиль</string>
|
||||
<string name="openapsma_request_label">запрос</string>
|
||||
<string name="openapsma_result_label">результат</string>
|
||||
<string name="result">результат</string>
|
||||
<string name="openapsma_run">выполнить сейчас</string>
|
||||
<string name="openapsma_scriptdebugdata_label">отладка скрипта</string>
|
||||
<string name="openapsma_target_bg">целевое значение для расчетов</string>
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
<color name="basal">#00ffff</color>
|
||||
<color name="iob">#FFFB8C00</color>
|
||||
<color name="cob">#8BC34A</color>
|
||||
<color name="ratio">#FFFFFF</color>
|
||||
<color name="inrange">#00FF00</color>
|
||||
<color name="low">#FF0000</color>
|
||||
<color name="high">#FFFF00</color>
|
||||
|
|
|
@ -63,7 +63,7 @@
|
|||
<string name="openapsma_iobdata_label">IOB data</string>
|
||||
<string name="openapsma_profile_label">Profile</string>
|
||||
<string name="openapsma_mealdata_label">Meal data</string>
|
||||
<string name="openapsma_result_label">Result</string>
|
||||
<string name="result">Result</string>
|
||||
<string name="openapsma_noglucosedata">No glucose data available</string>
|
||||
<string name="openapsma_noprofile">No profile available</string>
|
||||
<string name="openapsma_nopump">No pump available</string>
|
||||
|
@ -192,7 +192,6 @@
|
|||
<string name="noprofile">No profile loaded from NS yet</string>
|
||||
<string name="overview_tempbasal_button">TempBasal</string>
|
||||
<string name="overview_extendedbolus_button">Extended Bolus</string>
|
||||
<string name="configbuilder_nsclientversion_label">NSClient version:</string>
|
||||
<string name="configbuilder_nightscoutversion_label">Nightscout version:</string>
|
||||
<string name="send">SEND</string>
|
||||
<string name="missing">Missing</string>
|
||||
|
@ -532,6 +531,7 @@
|
|||
<string name="key_danar_bt_name" translatable="false">danar_bt_name</string>
|
||||
<string name="key_danar_password" translatable="false">danar_password</string>
|
||||
<string name="key_danar_useextended" translatable="false">danar_useextended</string>
|
||||
<string name="key_danar_visualizeextendedaspercentage" translatable="false">danar_visualizeextendedaspercentage"</string>
|
||||
<string name="key_danarprofile_dia" translatable="false">danarprofile_dia</string>
|
||||
<string name="clearlog">Clear log</string>
|
||||
<string name="key_nsclientinternal_autoscroll" translatable="false">nsclientinternal_autoscroll</string>
|
||||
|
@ -646,8 +646,25 @@
|
|||
<string name="nsalarm_urgentstaledata">Urgent stale data</string>
|
||||
<string name="nsalarm_staledatavalue_label">Stale data threshold [min]</string>
|
||||
<string name="nsalarm_urgent_staledatavalue_label">Urgent stale data threshold [min]</string>
|
||||
<string name="openapsama_autosens_period">Interval for autosens [h]</string>
|
||||
<string name="openapsama_autosens_period_summary">Amount of hours in the past for sensitivity detection (carbs absorption time is excluded)</string>
|
||||
<string name="key_openapsama_autosens_period" translatable="false">openapsama_autosens_period</string>
|
||||
<string name="ratio_short">RAT</string>
|
||||
<string name="key_do_not_track_profile_switch">do_not_track_profile_switch</string>
|
||||
<string name="do_not_track_profile_switch">Ignore profile switch events</string>
|
||||
<string name="do_not_track_profile_switch_summary">All profile switch events are ignoreg and active profile is always used</string>
|
||||
<string name="pump">Pump</string>
|
||||
<string name="openaps">OpenAPS</string>
|
||||
<string name="device">Device</string>
|
||||
<string name="uploader">Uploader</string>
|
||||
<string name="configbuilder_sensitivity">Sensitivity detection</string>
|
||||
<string name="sensitivity_shortname">SENS</string>
|
||||
<string name="sensitivityoref0">Sensitivity Oref0</string>
|
||||
<string name="sensitivitymk">Sensitivity MK</string>
|
||||
<string name="absorptionsettings_title">Absorption settings</string>
|
||||
<string name="key_absorption_maxtime" translatable="false">absorption_maxtime</string>
|
||||
<string name="absorption_maxtime_title">Meal max absorption time</string>
|
||||
<string name="absorption_maxtime_summary">Time in hours where is expected all carbs from meal will be absorbed</string>
|
||||
<string name="key_rangetodisplay" translatable="false">rangetodisplay</string>
|
||||
<string name="danar_visualizeextendedaspercentage_title">Visualize extended bolus as %</string>
|
||||
</resources>
|
||||
|
|
35
app/src/main/res/xml/pref_absorption.xml
Normal file
35
app/src/main/res/xml/pref_absorption.xml
Normal file
|
@ -0,0 +1,35 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:validate="http://schemas.android.com/apk/res-auto">
|
||||
<PreferenceCategory
|
||||
android:key="absorption"
|
||||
android:title="@string/absorptionsettings_title">
|
||||
<com.andreabaccega.widget.ValidatingEditTextPreference
|
||||
validate:testType="numericRange"
|
||||
validate:minNumber="1"
|
||||
validate:maxNumber="10"
|
||||
android:digits="0123456789.,"
|
||||
android:defaultValue="3"
|
||||
android:selectAllOnFocus="true"
|
||||
android:inputType="number"
|
||||
android:maxLines="20"
|
||||
android:title="@string/absorption_maxtime_title"
|
||||
android:dialogMessage="@string/absorption_maxtime_summary"
|
||||
android:key="@string/key_absorption_maxtime" />
|
||||
|
||||
<com.andreabaccega.widget.ValidatingEditTextPreference
|
||||
validate:maxNumber="24"
|
||||
validate:minNumber="4"
|
||||
validate:testType="numericRange"
|
||||
android:defaultValue="24"
|
||||
android:dialogMessage="@string/openapsama_autosens_period_summary"
|
||||
android:digits="0123456789"
|
||||
android:inputType="number"
|
||||
android:key="@string/key_openapsama_autosens_period"
|
||||
android:maxLines="20"
|
||||
android:selectAllOnFocus="true"
|
||||
android:singleLine="true"
|
||||
android:title="@string/openapsama_autosens_period" />
|
||||
|
||||
</PreferenceCategory>
|
||||
</PreferenceScreen>
|
|
@ -103,14 +103,14 @@
|
|||
android:title="@string/openapsama_autosens_adjusttargets"
|
||||
android:summary="@string/openapsama_autosens_adjusttargets_summary"/>
|
||||
<com.andreabaccega.widget.ValidatingEditTextPreference
|
||||
validate:testType="numericRange"
|
||||
validate:testType="floatNumericRange"
|
||||
validate:minNumber="1"
|
||||
validate:maxNumber="5"
|
||||
validate:maxNumber="10"
|
||||
android:digits="0123456789.,"
|
||||
android:defaultValue="2"
|
||||
android:selectAllOnFocus="true"
|
||||
android:singleLine="true"
|
||||
android:inputType="number"
|
||||
android:inputType="numberDecimal"
|
||||
android:maxLines="20"
|
||||
android:title="@string/openapsama_bolussnooze_dia_divisor"
|
||||
android:dialogMessage="@string/openapsama_bolussnooze_dia_divisor_summary"
|
||||
|
@ -128,6 +128,14 @@
|
|||
android:dialogMessage="@string/openapsama_min_5m_carbimpact_summary"
|
||||
android:key="openapsama_min_5m_carbimpact" />
|
||||
</PreferenceCategory>
|
||||
<PreferenceCategory
|
||||
android:title="@string/profile">
|
||||
<SwitchPreference
|
||||
android:defaultValue="false"
|
||||
android:key="@string/key_do_not_track_profile_switch"
|
||||
android:title="@string/do_not_track_profile_switch"
|
||||
android:summary="@string/do_not_track_profile_switch_summary"/>
|
||||
</PreferenceCategory>
|
||||
</PreferenceScreen>
|
||||
</PreferenceCategory>
|
||||
</PreferenceScreen>
|
||||
|
|
|
@ -17,6 +17,11 @@
|
|||
android:defaultValue="false"
|
||||
android:key="@string/key_danar_useextended"
|
||||
android:title="@string/danar_useextended_title" />
|
||||
<SwitchPreference
|
||||
android:defaultValue="false"
|
||||
android:dependency="@string/key_danar_useextended"
|
||||
android:key="@string/key_danar_visualizeextendedaspercentage"
|
||||
android:title="@string/danar_visualizeextendedaspercentage_title" />
|
||||
</PreferenceCategory>
|
||||
|
||||
</PreferenceScreen>
|
|
@ -1,5 +1,6 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:validate="http://schemas.android.com/apk/res-auto">
|
||||
<PreferenceCategory
|
||||
android:key="openapsama"
|
||||
android:title="@string/openapsama">
|
||||
|
|
|
@ -27,6 +27,7 @@ android {
|
|||
resValue "string", "label_xdrip", "AAPS"
|
||||
resValue "string", "label_xdrip_large", "AAPS(Large)"
|
||||
resValue "string", "label_xdrip_big_chart", "AAPS(BigChart)"
|
||||
resValue "string", "label_xdrip_no_chart", "AAPS(NoChart)"
|
||||
resValue "string", "label_xdrip_circle", "AAPS(Circle)"
|
||||
resValue "string", "label_xdrip_activity", "AAPS Prefs."
|
||||
resValue "string", "app_settings", "AAPS Settings"
|
||||
|
@ -39,6 +40,7 @@ android {
|
|||
resValue "string", "label_xdrip", "AAPS"
|
||||
resValue "string", "label_xdrip_large", "AAPS(Large)"
|
||||
resValue "string", "label_xdrip_big_chart", "AAPS(BigChart)"
|
||||
resValue "string", "label_xdrip_no_chart", "AAPS(NoChart)"
|
||||
resValue "string", "label_xdrip_circle", "AAPS(Circle)"
|
||||
resValue "string", "label_xdrip_activity", "AAPS Prefs."
|
||||
resValue "string", "app_settings", "AAPS Settings"
|
||||
|
|
|
@ -34,6 +34,24 @@
|
|||
<category android:name="com.google.android.wearable.watchface.category.WATCH_FACE" />
|
||||
</intent-filter>
|
||||
</service>
|
||||
<service
|
||||
android:name=".watchfaces.NOChart"
|
||||
android:allowEmbedded="true"
|
||||
android:label="@string/label_xdrip_no_chart"
|
||||
android:permission="android.permission.BIND_WALLPAPER">
|
||||
<meta-data
|
||||
android:name="android.service.wallpaper"
|
||||
android:resource="@xml/watch_face" />
|
||||
<meta-data
|
||||
android:name="com.google.android.wearable.watchface.preview"
|
||||
android:resource="@drawable/watchface_nochart" />
|
||||
|
||||
<intent-filter>
|
||||
<action android:name="android.service.wallpaper.WallpaperService" />
|
||||
|
||||
<category android:name="com.google.android.wearable.watchface.category.WATCH_FACE" />
|
||||
</intent-filter>
|
||||
</service>
|
||||
<service
|
||||
android:name=".watchfaces.Home"
|
||||
android:allowEmbedded="true"
|
||||
|
|
|
@ -0,0 +1,520 @@
|
|||
package info.nightscout.androidaps.watchfaces;
|
||||
|
||||
import android.content.BroadcastReceiver;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.IntentFilter;
|
||||
import android.content.SharedPreferences;
|
||||
import android.graphics.Canvas;
|
||||
import android.graphics.Color;
|
||||
import android.graphics.LinearGradient;
|
||||
import android.graphics.Matrix;
|
||||
import android.graphics.Paint;
|
||||
import android.graphics.Point;
|
||||
import android.graphics.Rect;
|
||||
import android.graphics.Shader;
|
||||
import android.os.Bundle;
|
||||
import android.os.PowerManager;
|
||||
import android.preference.PreferenceManager;
|
||||
import android.support.v4.content.ContextCompat;
|
||||
import android.support.v4.content.LocalBroadcastManager;
|
||||
import android.support.wearable.view.WatchViewStub;
|
||||
import android.support.wearable.watchface.WatchFaceStyle;
|
||||
import android.text.format.DateFormat;
|
||||
import android.util.Log;
|
||||
import android.view.Display;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.WindowInsets;
|
||||
import android.view.WindowManager;
|
||||
import android.widget.RelativeLayout;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.google.android.gms.wearable.DataMap;
|
||||
import com.ustwo.clockwise.common.WatchFaceTime;
|
||||
import com.ustwo.clockwise.common.WatchMode;
|
||||
import com.ustwo.clockwise.common.WatchShape;
|
||||
import com.ustwo.clockwise.wearable.WatchFace;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import info.nightscout.androidaps.R;
|
||||
import info.nightscout.androidaps.data.BasalWatchData;
|
||||
import info.nightscout.androidaps.data.BgWatchData;
|
||||
import info.nightscout.androidaps.data.ListenerService;
|
||||
import info.nightscout.androidaps.data.TempWatchData;
|
||||
import info.nightscout.androidaps.interaction.menus.MainMenuActivity;
|
||||
import lecho.lib.hellocharts.view.LineChartView;
|
||||
|
||||
/**
|
||||
* Created by adrianLxM.
|
||||
*/
|
||||
public class NOChart extends WatchFace implements SharedPreferences.OnSharedPreferenceChangeListener {
|
||||
public final static IntentFilter INTENT_FILTER;
|
||||
public TextView mTime, mSgv, mTimestamp, mDelta, mAvgDelta;
|
||||
public RelativeLayout mRelativeLayout;
|
||||
public long sgvLevel = 0;
|
||||
public int batteryLevel = 1;
|
||||
public int ageLevel = 1;
|
||||
public boolean lowResMode = false;
|
||||
public boolean layoutSet = false;
|
||||
public double datetime;
|
||||
public ArrayList<BgWatchData> bgDataList = new ArrayList<>();
|
||||
public ArrayList<TempWatchData> tempWatchDataList = new ArrayList<>();
|
||||
public ArrayList<BasalWatchData> basalWatchDataList = new ArrayList<>();
|
||||
public PowerManager.WakeLock wakeLock;
|
||||
public View layoutView;
|
||||
private final Point displaySize = new Point();
|
||||
private int specW, specH;
|
||||
private int animationAngle = 0;
|
||||
private boolean isAnimated = false;
|
||||
|
||||
private LocalBroadcastManager localBroadcastManager;
|
||||
private MessageReceiver messageReceiver;
|
||||
|
||||
protected SharedPreferences sharedPrefs;
|
||||
private String sgvString = "--";
|
||||
private String externalStatusString = "no status";
|
||||
private TextView statusView;
|
||||
private long sgvTapTime = 0l;
|
||||
|
||||
@Override
|
||||
public void onCreate() {
|
||||
super.onCreate();
|
||||
Display display = ((WindowManager) getSystemService(Context.WINDOW_SERVICE))
|
||||
.getDefaultDisplay();
|
||||
display.getSize(displaySize);
|
||||
wakeLock = ((PowerManager) getSystemService(Context.POWER_SERVICE)).newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, "Clock");
|
||||
|
||||
specW = View.MeasureSpec.makeMeasureSpec(displaySize.x,
|
||||
View.MeasureSpec.EXACTLY);
|
||||
specH = View.MeasureSpec.makeMeasureSpec(displaySize.y,
|
||||
View.MeasureSpec.EXACTLY);
|
||||
sharedPrefs = PreferenceManager
|
||||
.getDefaultSharedPreferences(this);
|
||||
sharedPrefs.registerOnSharedPreferenceChangeListener(this);
|
||||
LayoutInflater inflater = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE);
|
||||
layoutView = inflater.inflate(R.layout.activity_nochart, null);
|
||||
performViewSetup();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onLayout(WatchShape shape, Rect screenBounds, WindowInsets screenInsets) {
|
||||
super.onLayout(shape, screenBounds, screenInsets);
|
||||
layoutView.onApplyWindowInsets(screenInsets);
|
||||
}
|
||||
|
||||
public void performViewSetup() {
|
||||
final WatchViewStub stub = (WatchViewStub) layoutView.findViewById(R.id.watch_view_stub);
|
||||
IntentFilter messageFilter = new IntentFilter(Intent.ACTION_SEND);
|
||||
|
||||
messageReceiver = new MessageReceiver();
|
||||
localBroadcastManager = LocalBroadcastManager.getInstance(this);
|
||||
localBroadcastManager.registerReceiver(messageReceiver, messageFilter);
|
||||
|
||||
stub.setOnLayoutInflatedListener(new WatchViewStub.OnLayoutInflatedListener() {
|
||||
@Override
|
||||
public void onLayoutInflated(WatchViewStub stub) {
|
||||
mTime = (TextView) stub.findViewById(R.id.watch_time);
|
||||
mSgv = (TextView) stub.findViewById(R.id.sgv);
|
||||
mTimestamp = (TextView) stub.findViewById(R.id.timestamp);
|
||||
mDelta = (TextView) stub.findViewById(R.id.delta);
|
||||
mAvgDelta = (TextView) stub.findViewById(R.id.avgdelta);
|
||||
mRelativeLayout = (RelativeLayout) stub.findViewById(R.id.main_layout);
|
||||
statusView = (TextView) stub.findViewById(R.id.aps_status);
|
||||
layoutSet = true;
|
||||
showAgeAndStatus();
|
||||
mRelativeLayout.measure(specW, specH);
|
||||
mRelativeLayout.layout(0, 0, mRelativeLayout.getMeasuredWidth(),
|
||||
mRelativeLayout.getMeasuredHeight());
|
||||
}
|
||||
});
|
||||
ListenerService.requestData(this);
|
||||
wakeLock.acquire(50);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onTapCommand(int tapType, int x, int y, long eventTime) {
|
||||
|
||||
int extra = mSgv!=null?(mSgv.getRight() - mSgv.getLeft())/2:0;
|
||||
|
||||
if (tapType == TAP_TYPE_TAP&&
|
||||
x + extra >=mSgv.getLeft() &&
|
||||
x - extra <= mSgv.getRight()&&
|
||||
y >= mSgv.getTop() &&
|
||||
y <= mSgv.getBottom()){
|
||||
if (eventTime - sgvTapTime < 800){
|
||||
Intent intent = new Intent(this, MainMenuActivity.class);
|
||||
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||
startActivity(intent);
|
||||
}
|
||||
sgvTapTime = eventTime;
|
||||
}
|
||||
}
|
||||
|
||||
protected void onWatchModeChanged(WatchMode watchMode) {
|
||||
|
||||
if(lowResMode ^ isLowRes(watchMode)){ //if there was a change in lowResMode
|
||||
lowResMode = isLowRes(watchMode);
|
||||
setColor();
|
||||
} else if (! sharedPrefs.getBoolean("dark", true)){
|
||||
//in bright mode: different colours if active:
|
||||
setColor();
|
||||
}
|
||||
}
|
||||
|
||||
private boolean isLowRes(WatchMode watchMode) {
|
||||
return (watchMode == WatchMode.LOW_BIT) || (watchMode == WatchMode.LOW_BIT_BURN_IN) || (watchMode == WatchMode.LOW_BIT_BURN_IN);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected WatchFaceStyle getWatchFaceStyle(){
|
||||
return new WatchFaceStyle.Builder(this).setAcceptsTapEvents(true).build();
|
||||
}
|
||||
|
||||
|
||||
|
||||
public int ageLevel() {
|
||||
if(timeSince() <= (1000 * 60 * 12)) {
|
||||
return 1;
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
public double timeSince() {
|
||||
return System.currentTimeMillis() - datetime;
|
||||
}
|
||||
|
||||
public String readingAge(boolean shortString) {
|
||||
if (datetime == 0) { return shortString?"--'":"-- Minute ago"; }
|
||||
int minutesAgo = (int) Math.floor(timeSince()/(1000*60));
|
||||
if (minutesAgo == 1) {
|
||||
return minutesAgo + (shortString?"'":" Minute ago");
|
||||
}
|
||||
return minutesAgo + (shortString?"'":" Minutes ago");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDestroy() {
|
||||
if(localBroadcastManager != null && messageReceiver != null){
|
||||
localBroadcastManager.unregisterReceiver(messageReceiver);}
|
||||
if (sharedPrefs != null){
|
||||
sharedPrefs.unregisterOnSharedPreferenceChangeListener(this);
|
||||
}
|
||||
super.onDestroy();
|
||||
}
|
||||
|
||||
static {
|
||||
INTENT_FILTER = new IntentFilter();
|
||||
INTENT_FILTER.addAction(Intent.ACTION_TIME_TICK);
|
||||
INTENT_FILTER.addAction(Intent.ACTION_TIMEZONE_CHANGED);
|
||||
INTENT_FILTER.addAction(Intent.ACTION_TIME_CHANGED);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onDraw(Canvas canvas) {
|
||||
if(layoutSet) {
|
||||
this.mRelativeLayout.draw(canvas);
|
||||
Log.d("onDraw", "draw");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onTimeChanged(WatchFaceTime oldTime, WatchFaceTime newTime) {
|
||||
if (layoutSet && (newTime.hasHourChanged(oldTime) || newTime.hasMinuteChanged(oldTime))) {
|
||||
wakeLock.acquire(50);
|
||||
final java.text.DateFormat timeFormat = DateFormat.getTimeFormat(NOChart.this);
|
||||
mTime.setText(timeFormat.format(System.currentTimeMillis()));
|
||||
showAgeAndStatus();
|
||||
|
||||
if(ageLevel()<=0) {
|
||||
mSgv.setPaintFlags(mSgv.getPaintFlags() | Paint.STRIKE_THRU_TEXT_FLAG);
|
||||
} else {
|
||||
mSgv.setPaintFlags(mSgv.getPaintFlags() & ~Paint.STRIKE_THRU_TEXT_FLAG);
|
||||
}
|
||||
|
||||
missedReadingAlert();
|
||||
mRelativeLayout.measure(specW, specH);
|
||||
mRelativeLayout.layout(0, 0, mRelativeLayout.getMeasuredWidth(),
|
||||
mRelativeLayout.getMeasuredHeight());
|
||||
}
|
||||
}
|
||||
|
||||
public class MessageReceiver extends BroadcastReceiver {
|
||||
@Override
|
||||
public void onReceive(Context context, Intent intent) {
|
||||
Bundle bundle = intent.getBundleExtra("data");
|
||||
if (layoutSet && bundle !=null) {
|
||||
DataMap dataMap = DataMap.fromBundle(bundle);
|
||||
wakeLock.acquire(50);
|
||||
sgvLevel = dataMap.getLong("sgvLevel");
|
||||
batteryLevel = dataMap.getInt("batteryLevel");
|
||||
datetime = dataMap.getDouble("timestamp");
|
||||
sgvString = dataMap.getString("sgvString");
|
||||
mSgv.setText(dataMap.getString("sgvString"));
|
||||
|
||||
if(ageLevel()<=0) {
|
||||
mSgv.setPaintFlags(mSgv.getPaintFlags() | Paint.STRIKE_THRU_TEXT_FLAG);
|
||||
} else {
|
||||
mSgv.setPaintFlags(mSgv.getPaintFlags() & ~Paint.STRIKE_THRU_TEXT_FLAG);
|
||||
}
|
||||
|
||||
final java.text.DateFormat timeFormat = DateFormat.getTimeFormat(NOChart.this);
|
||||
mTime.setText(timeFormat.format(System.currentTimeMillis()));
|
||||
|
||||
showAgeAndStatus();
|
||||
|
||||
String delta = dataMap.getString("delta");
|
||||
|
||||
if (delta.endsWith(" mg/dl")) {
|
||||
mDelta.setText(delta.substring(0, delta.length() - 6));
|
||||
} else if (delta.endsWith(" mmol/l")||delta.endsWith(" mmol")) {
|
||||
mDelta.setText(delta.substring(0, delta.length() - 5));
|
||||
} else {
|
||||
mDelta.setText(delta);
|
||||
}
|
||||
|
||||
|
||||
String avgDelta = dataMap.getString("avgDelta");
|
||||
|
||||
if (delta.endsWith(" mg/dl")) {
|
||||
mAvgDelta.setText(avgDelta.substring(0, avgDelta.length() - 6));
|
||||
} else if (avgDelta.endsWith(" mmol/l")||avgDelta.endsWith(" mmol")) {
|
||||
mAvgDelta.setText(avgDelta.substring(0, avgDelta.length() - 5));
|
||||
} else {
|
||||
mAvgDelta.setText(avgDelta);
|
||||
}
|
||||
|
||||
mRelativeLayout.measure(specW, specH);
|
||||
mRelativeLayout.layout(0, 0, mRelativeLayout.getMeasuredWidth(),
|
||||
mRelativeLayout.getMeasuredHeight());
|
||||
invalidate();
|
||||
setColor();
|
||||
|
||||
//start animation?
|
||||
// dataMap.getDataMapArrayList("entries") == null -> not on "resend data".
|
||||
if (!lowResMode && (sharedPrefs.getBoolean("animation", false) && dataMap.getDataMapArrayList("entries") == null && (sgvString.equals("100") || sgvString.equals("5.5") || sgvString.equals("5,5")))) {
|
||||
startAnimation();
|
||||
}
|
||||
}
|
||||
//status
|
||||
bundle = intent.getBundleExtra("status");
|
||||
if (layoutSet && bundle != null) {
|
||||
DataMap dataMap = DataMap.fromBundle(bundle);
|
||||
wakeLock.acquire(50);
|
||||
externalStatusString = dataMap.getString("externalStatusString");
|
||||
|
||||
showAgeAndStatus();
|
||||
|
||||
mRelativeLayout.measure(specW, specH);
|
||||
mRelativeLayout.layout(0, 0, mRelativeLayout.getMeasuredWidth(),
|
||||
mRelativeLayout.getMeasuredHeight());
|
||||
invalidate();
|
||||
setColor();
|
||||
}
|
||||
//basals and temps
|
||||
bundle = intent.getBundleExtra("basals");
|
||||
if (layoutSet && bundle != null) {
|
||||
DataMap dataMap = DataMap.fromBundle(bundle);
|
||||
wakeLock.acquire(500);
|
||||
|
||||
loadBasalsAndTemps(dataMap);
|
||||
|
||||
mRelativeLayout.measure(specW, specH);
|
||||
mRelativeLayout.layout(0, 0, mRelativeLayout.getMeasuredWidth(),
|
||||
mRelativeLayout.getMeasuredHeight());
|
||||
invalidate();
|
||||
setColor();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void loadBasalsAndTemps(DataMap dataMap) {
|
||||
ArrayList<DataMap> temps = dataMap.getDataMapArrayList("temps");
|
||||
if (temps != null) {
|
||||
tempWatchDataList = new ArrayList<>();
|
||||
for (DataMap temp : temps) {
|
||||
TempWatchData twd = new TempWatchData();
|
||||
twd.startTime = temp.getLong("starttime");
|
||||
twd.startBasal = temp.getDouble("startBasal");
|
||||
twd.endTime = temp.getLong("endtime");
|
||||
twd.endBasal = temp.getDouble("endbasal");
|
||||
twd.amount = temp.getDouble("amount");
|
||||
tempWatchDataList.add(twd);
|
||||
}
|
||||
}
|
||||
ArrayList<DataMap> basals = dataMap.getDataMapArrayList("basals");
|
||||
if (basals != null) {
|
||||
basalWatchDataList = new ArrayList<>();
|
||||
for (DataMap basal : basals) {
|
||||
BasalWatchData bwd = new BasalWatchData();
|
||||
bwd.startTime = basal.getLong("starttime");
|
||||
bwd.endTime = basal.getLong("endtime");
|
||||
bwd.amount = basal.getDouble("amount");
|
||||
basalWatchDataList.add(bwd);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void showAgeAndStatus() {
|
||||
|
||||
if( mTimestamp != null){
|
||||
mTimestamp.setText(readingAge(true));
|
||||
}
|
||||
boolean showAvgDelta = sharedPrefs.getBoolean("showAvgDelta", true);
|
||||
|
||||
if(showAvgDelta){
|
||||
mAvgDelta.setVisibility(View.VISIBLE);
|
||||
} else {
|
||||
mAvgDelta.setVisibility(View.GONE);
|
||||
}
|
||||
statusView.setText(externalStatusString);
|
||||
statusView.setVisibility(View.VISIBLE);
|
||||
}
|
||||
|
||||
public void setColor() {
|
||||
if(lowResMode){
|
||||
setColorLowRes();
|
||||
} else if (sharedPrefs.getBoolean("dark", true)) {
|
||||
setColorDark();
|
||||
} else {
|
||||
setColorBright();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key){
|
||||
setColor();
|
||||
if(layoutSet){
|
||||
showAgeAndStatus();
|
||||
mRelativeLayout.measure(specW, specH);
|
||||
mRelativeLayout.layout(0, 0, mRelativeLayout.getMeasuredWidth(),
|
||||
mRelativeLayout.getMeasuredHeight());
|
||||
}
|
||||
invalidate();
|
||||
}
|
||||
|
||||
protected void updateRainbow() {
|
||||
animationAngle = (animationAngle + 1) % 360;
|
||||
//Animation matrix:
|
||||
int[] rainbow = {Color.RED, Color.YELLOW, Color.GREEN, Color.BLUE
|
||||
, Color.CYAN};
|
||||
Shader shader = new LinearGradient(0, 0, 0, 20, rainbow,
|
||||
null, Shader.TileMode.MIRROR);
|
||||
Matrix matrix = new Matrix();
|
||||
matrix.setRotate(animationAngle);
|
||||
shader.setLocalMatrix(matrix);
|
||||
mSgv.getPaint().setShader(shader);
|
||||
invalidate();
|
||||
}
|
||||
|
||||
private synchronized void setIsAnimated(boolean isAnimated) {
|
||||
this.isAnimated = isAnimated;
|
||||
}
|
||||
|
||||
void startAnimation() {
|
||||
Log.d("CircleWatchface", "start startAnimation");
|
||||
|
||||
Thread animator = new Thread() {
|
||||
|
||||
|
||||
public void run() {
|
||||
setIsAnimated(true);
|
||||
for (int i = 0; i <= 8 * 1000 / 40; i++) {
|
||||
updateRainbow();
|
||||
try {
|
||||
Thread.sleep(40);
|
||||
} catch (InterruptedException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
mSgv.getPaint().setShader(null);
|
||||
setIsAnimated(false);
|
||||
invalidate();
|
||||
setColor();
|
||||
|
||||
System.gc();
|
||||
}
|
||||
};
|
||||
|
||||
animator.start();
|
||||
}
|
||||
|
||||
protected void setColorLowRes() {
|
||||
mTime.setTextColor(ContextCompat.getColor(getApplicationContext(), R.color.dark_mTime));
|
||||
statusView.setTextColor(ContextCompat.getColor(getApplicationContext(), R.color.dark_statusView));
|
||||
mRelativeLayout.setBackgroundColor(ContextCompat.getColor(getApplicationContext(), R.color.dark_background));
|
||||
mSgv.setTextColor(ContextCompat.getColor(getApplicationContext(), R.color.dark_midColor));
|
||||
mDelta.setTextColor(ContextCompat.getColor(getApplicationContext(), R.color.dark_midColor));
|
||||
mAvgDelta.setTextColor(ContextCompat.getColor(getApplicationContext(), R.color.dark_midColor));
|
||||
mTimestamp.setTextColor(ContextCompat.getColor(getApplicationContext(), R.color.dark_Timestamp));
|
||||
}
|
||||
|
||||
protected void setColorDark() {
|
||||
mTime.setTextColor(ContextCompat.getColor(getApplicationContext(), R.color.dark_mTime));
|
||||
statusView.setTextColor(ContextCompat.getColor(getApplicationContext(), R.color.dark_statusView));
|
||||
mRelativeLayout.setBackgroundColor(ContextCompat.getColor(getApplicationContext(), R.color.dark_background));
|
||||
if (sgvLevel == 1) {
|
||||
mSgv.setTextColor(ContextCompat.getColor(getApplicationContext(), R.color.dark_highColor));
|
||||
mDelta.setTextColor(ContextCompat.getColor(getApplicationContext(), R.color.dark_highColor));
|
||||
mAvgDelta.setTextColor(ContextCompat.getColor(getApplicationContext(), R.color.dark_highColor));
|
||||
} else if (sgvLevel == 0) {
|
||||
mSgv.setTextColor(ContextCompat.getColor(getApplicationContext(), R.color.dark_midColor));
|
||||
mDelta.setTextColor(ContextCompat.getColor(getApplicationContext(), R.color.dark_midColor));
|
||||
mAvgDelta.setTextColor(ContextCompat.getColor(getApplicationContext(), R.color.dark_midColor));
|
||||
} else if (sgvLevel == -1) {
|
||||
mSgv.setTextColor(ContextCompat.getColor(getApplicationContext(), R.color.dark_lowColor));
|
||||
mDelta.setTextColor(ContextCompat.getColor(getApplicationContext(), R.color.dark_lowColor));
|
||||
mAvgDelta.setTextColor(ContextCompat.getColor(getApplicationContext(), R.color.dark_lowColor));
|
||||
}
|
||||
|
||||
if (ageLevel == 1) {
|
||||
mTimestamp.setTextColor(ContextCompat.getColor(getApplicationContext(), R.color.dark_Timestamp));
|
||||
} else {
|
||||
mTimestamp.setTextColor(ContextCompat.getColor(getApplicationContext(), R.color.dark_TimestampOld));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
protected void setColorBright() {
|
||||
|
||||
if (getCurrentWatchMode() == WatchMode.INTERACTIVE) {
|
||||
mTime.setTextColor(ContextCompat.getColor(getApplicationContext(), R.color.light_bigchart_time));
|
||||
statusView.setTextColor(ContextCompat.getColor(getApplicationContext(), R.color.light_bigchart_status));
|
||||
mRelativeLayout.setBackgroundColor(ContextCompat.getColor(getApplicationContext(), R.color.light_background));
|
||||
if (sgvLevel == 1) {
|
||||
mSgv.setTextColor(ContextCompat.getColor(getApplicationContext(), R.color.light_highColor));
|
||||
mDelta.setTextColor(ContextCompat.getColor(getApplicationContext(), R.color.light_highColor));
|
||||
mAvgDelta.setTextColor(ContextCompat.getColor(getApplicationContext(), R.color.light_highColor));
|
||||
} else if (sgvLevel == 0) {
|
||||
mSgv.setTextColor(ContextCompat.getColor(getApplicationContext(), R.color.light_midColor));
|
||||
mDelta.setTextColor(ContextCompat.getColor(getApplicationContext(), R.color.light_midColor));
|
||||
mAvgDelta.setTextColor(ContextCompat.getColor(getApplicationContext(), R.color.light_midColor));
|
||||
} else if (sgvLevel == -1) {
|
||||
mSgv.setTextColor(ContextCompat.getColor(getApplicationContext(), R.color.light_lowColor));
|
||||
mDelta.setTextColor(ContextCompat.getColor(getApplicationContext(), R.color.light_lowColor));
|
||||
mAvgDelta.setTextColor(ContextCompat.getColor(getApplicationContext(), R.color.light_lowColor));
|
||||
}
|
||||
|
||||
if (ageLevel == 1) {
|
||||
mTimestamp.setTextColor(ContextCompat.getColor(getApplicationContext(), R.color.light_mTimestamp1));
|
||||
} else {
|
||||
mTimestamp.setTextColor(ContextCompat.getColor(getApplicationContext(), R.color.light_mTimestamp));
|
||||
}
|
||||
} else {
|
||||
setColorDark();
|
||||
}
|
||||
}
|
||||
|
||||
public void missedReadingAlert() {
|
||||
int minutes_since = (int) Math.floor(timeSince()/(1000*60));
|
||||
if(minutes_since >= 16 && ((minutes_since - 16) % 5) == 0) {
|
||||
ListenerService.requestData(this); // attempt endTime recover missing data
|
||||
}
|
||||
}
|
||||
}
|
BIN
wear/src/main/res/drawable/watchface_nochart.png
Executable file
BIN
wear/src/main/res/drawable/watchface_nochart.png
Executable file
Binary file not shown.
After Width: | Height: | Size: 13 KiB |
12
wear/src/main/res/layout/activity_nochart.xml
Normal file
12
wear/src/main/res/layout/activity_nochart.xml
Normal file
|
@ -0,0 +1,12 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<android.support.wearable.view.WatchViewStub
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:id="@+id/watch_view_stub"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
app:rectLayout="@layout/rect_activity_nochart"
|
||||
app:roundLayout="@layout/round_activity_nochart"
|
||||
tools:context=".watchfaces.Home"
|
||||
tools:deviceIds="wear"/>
|
108
wear/src/main/res/layout/rect_activity_nochart.xml
Normal file
108
wear/src/main/res/layout/rect_activity_nochart.xml
Normal file
|
@ -0,0 +1,108 @@
|
|||
<?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="match_parent"
|
||||
android:layout_height="match_parent" tools:context=".watchfaces.Home" tools:deviceIds="wear_square"
|
||||
android:background="@color/black"
|
||||
android:id="@+id/main_layout">
|
||||
|
||||
<LinearLayout
|
||||
android:orientation="vertical"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:textAlignment="center"
|
||||
android:gravity="center_horizontal">
|
||||
|
||||
<LinearLayout
|
||||
android:orientation="horizontal"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:textAlignment="center"
|
||||
android:paddingTop="5dp"
|
||||
android:layout_gravity="center_horizontal"
|
||||
android:layout_marginTop="-5dp"
|
||||
android:gravity="center_horizontal">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/delta"
|
||||
android:textSize="40sp"
|
||||
android:text="---"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:textColor="#FFFFFF"
|
||||
android:layout_gravity="bottom"
|
||||
android:gravity="center_horizontal|bottom"
|
||||
android:layout_marginRight="5dp" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/sgv"
|
||||
android:textSize="55sp"
|
||||
android:text="---"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:textColor="#FFFFFF"
|
||||
android:layout_gravity="center_horizontal"
|
||||
android:gravity="center_horizontal" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/avgdelta"
|
||||
android:textSize="40sp"
|
||||
android:text="---"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:textColor="#FFFFFF"
|
||||
android:layout_gravity="bottom"
|
||||
android:gravity="center_horizontal|bottom"
|
||||
android:layout_marginLeft="5dp" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/aps_status"
|
||||
android:textSize="24sp"
|
||||
android:text="E xU/h IOB: x (x+x)"
|
||||
android:layout_width="wrap_content"
|
||||
android:textAlignment="center"
|
||||
android:textColor="#FFFFFF"
|
||||
android:layout_gravity="center_horizontal"
|
||||
android:layout_height="wrap_content"/>
|
||||
|
||||
<View
|
||||
android:id="@+id/chart"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="0dp"
|
||||
android:layout_gravity="bottom"
|
||||
android:layout_weight="1"
|
||||
android:gravity="center_horizontal" />
|
||||
|
||||
<LinearLayout
|
||||
android:orientation="horizontal"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:textAlignment="center"
|
||||
android:gravity="center_horizontal|bottom">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/watch_time"
|
||||
android:textSize="47sp"
|
||||
android:text="12:00"
|
||||
android:textColor="#FFFFFF"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:textAlignment="center"
|
||||
android:layout_marginRight="6dp"
|
||||
android:layout_gravity="center_horizontal" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/timestamp"
|
||||
android:textSize="35sp"
|
||||
android:text="-- '"
|
||||
android:layout_width="wrap_content"
|
||||
android:textAlignment="center"
|
||||
android:textColor="#FFFFFF"
|
||||
android:layout_gravity="center_horizontal"
|
||||
android:layout_height="wrap_content" />
|
||||
</LinearLayout>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
</RelativeLayout>
|
108
wear/src/main/res/layout/round_activity_nochart.xml
Normal file
108
wear/src/main/res/layout/round_activity_nochart.xml
Normal file
|
@ -0,0 +1,108 @@
|
|||
<?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="match_parent"
|
||||
android:layout_height="match_parent" tools:context=".watchfaces.Home" tools:deviceIds="wear_square"
|
||||
android:background="@color/black"
|
||||
android:id="@+id/main_layout">
|
||||
|
||||
<LinearLayout
|
||||
android:orientation="vertical"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:textAlignment="center"
|
||||
android:gravity="center_horizontal">
|
||||
|
||||
<LinearLayout
|
||||
android:orientation="horizontal"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:textAlignment="center"
|
||||
android:paddingTop="5dp"
|
||||
android:layout_gravity="center_horizontal"
|
||||
android:layout_marginTop="-5dp"
|
||||
android:gravity="center_horizontal">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/delta"
|
||||
android:textSize="40sp"
|
||||
android:text="---"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:textColor="#FFFFFF"
|
||||
android:layout_gravity="bottom"
|
||||
android:gravity="center_horizontal|bottom"
|
||||
android:layout_marginRight="5dp" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/sgv"
|
||||
android:textSize="55sp"
|
||||
android:text="---"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:textColor="#FFFFFF"
|
||||
android:layout_gravity="center_horizontal"
|
||||
android:gravity="center_horizontal" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/avgdelta"
|
||||
android:textSize="40sp"
|
||||
android:text="---"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:textColor="#FFFFFF"
|
||||
android:layout_gravity="bottom"
|
||||
android:gravity="center_horizontal|bottom"
|
||||
android:layout_marginLeft="5dp" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/aps_status"
|
||||
android:textSize="24sp"
|
||||
android:text="E xU/h IOB: x (x+x)"
|
||||
android:layout_width="wrap_content"
|
||||
android:textAlignment="center"
|
||||
android:textColor="#FFFFFF"
|
||||
android:layout_gravity="center_horizontal"
|
||||
android:layout_height="wrap_content"/>
|
||||
|
||||
<View
|
||||
android:id="@+id/chart"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="0dp"
|
||||
android:layout_gravity="bottom"
|
||||
android:layout_weight="1"
|
||||
android:gravity="center_horizontal" />
|
||||
|
||||
<LinearLayout
|
||||
android:orientation="horizontal"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:textAlignment="center"
|
||||
android:gravity="center_horizontal|bottom">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/watch_time"
|
||||
android:textSize="47sp"
|
||||
android:text="12:00"
|
||||
android:textColor="#FFFFFF"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:textAlignment="center"
|
||||
android:layout_marginRight="6dp"
|
||||
android:layout_gravity="center_horizontal" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/timestamp"
|
||||
android:textSize="35sp"
|
||||
android:text="-- '"
|
||||
android:layout_width="wrap_content"
|
||||
android:textAlignment="center"
|
||||
android:textColor="#FFFFFF"
|
||||
android:layout_gravity="center_horizontal"
|
||||
android:layout_height="wrap_content" />
|
||||
</LinearLayout>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
</RelativeLayout>
|
Loading…
Reference in a new issue