commit
0ca6e96f39
|
@ -10,4 +10,6 @@ public class Config {
|
||||||
public static final boolean logIncommingData = true;
|
public static final boolean logIncommingData = true;
|
||||||
public static final boolean logAPSResult = true;
|
public static final boolean logAPSResult = true;
|
||||||
public static final boolean logPumpComm = true;
|
public static final boolean logPumpComm = true;
|
||||||
|
public static final boolean logPrefsChange = true;
|
||||||
|
public static final boolean logConfigBuilder = true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,13 +14,16 @@ import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.Iterator;
|
||||||
|
|
||||||
import info.nightscout.androidaps.events.EventRefreshGui;
|
import info.nightscout.androidaps.events.EventRefreshGui;
|
||||||
|
import info.nightscout.androidaps.interfaces.PluginBase;
|
||||||
import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderFragment;
|
import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderFragment;
|
||||||
import info.nightscout.androidaps.plugins.LowSuspend.LowSuspendFragment;
|
import info.nightscout.androidaps.plugins.LowSuspend.LowSuspendFragment;
|
||||||
|
import info.nightscout.androidaps.plugins.NSProfileViewer.NSProfileViewerFragment;
|
||||||
import info.nightscout.androidaps.plugins.OpenAPSMA.OpenAPSMAFragment;
|
import info.nightscout.androidaps.plugins.OpenAPSMA.OpenAPSMAFragment;
|
||||||
import info.nightscout.androidaps.plugins.Overview.OverviewFragment;
|
import info.nightscout.androidaps.plugins.Overview.OverviewFragment;
|
||||||
import info.nightscout.androidaps.plugins.ProfileViewer.ProfileViewerFragment;
|
import info.nightscout.androidaps.plugins.SimpleProfile.SimpleProfileFragment;
|
||||||
import info.nightscout.androidaps.plugins.TempBasals.TempBasalsFragment;
|
import info.nightscout.androidaps.plugins.TempBasals.TempBasalsFragment;
|
||||||
import info.nightscout.androidaps.plugins.Treatments.TreatmentsFragment;
|
import info.nightscout.androidaps.plugins.Treatments.TreatmentsFragment;
|
||||||
import info.nightscout.androidaps.plugins.VirtualPump.VirtualPumpFragment;
|
import info.nightscout.androidaps.plugins.VirtualPump.VirtualPumpFragment;
|
||||||
|
@ -35,44 +38,39 @@ public class MainActivity extends AppCompatActivity {
|
||||||
private ViewPager mPager;
|
private ViewPager mPager;
|
||||||
private static TabPageAdapter pageAdapter;
|
private static TabPageAdapter pageAdapter;
|
||||||
|
|
||||||
ArrayList<Fragment> pluginsList = new ArrayList<Fragment>();
|
private static ArrayList<PluginBase> pluginsList = new ArrayList<PluginBase>();
|
||||||
|
|
||||||
public static TreatmentsFragment treatmentsFragment;
|
private static ConfigBuilderFragment configBuilderFragment;
|
||||||
public static TempBasalsFragment tempBasalsFragment;
|
|
||||||
|
|
||||||
|
public static ConfigBuilderFragment getConfigBuilder() {
|
||||||
|
return configBuilderFragment;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
setContentView(R.layout.activity_main);
|
setContentView(R.layout.activity_main);
|
||||||
|
if (Config.logFunctionCalls)
|
||||||
|
log.debug("onCreate");
|
||||||
|
|
||||||
// Register all tabs in app here
|
// Register all tabs in app here
|
||||||
pluginsList.add(OverviewFragment.newInstance());
|
pluginsList.add(OverviewFragment.newInstance());
|
||||||
pluginsList.add((VirtualPumpFragment) MainApp.setActivePump(VirtualPumpFragment.newInstance()));
|
pluginsList.add(VirtualPumpFragment.newInstance());
|
||||||
pluginsList.add(LowSuspendFragment.newInstance());
|
pluginsList.add(LowSuspendFragment.newInstance());
|
||||||
pluginsList.add(OpenAPSMAFragment.newInstance());
|
pluginsList.add(OpenAPSMAFragment.newInstance());
|
||||||
pluginsList.add(treatmentsFragment = TreatmentsFragment.newInstance());
|
pluginsList.add(NSProfileViewerFragment.newInstance());
|
||||||
pluginsList.add(tempBasalsFragment = TempBasalsFragment.newInstance());
|
pluginsList.add(SimpleProfileFragment.newInstance());
|
||||||
pluginsList.add(ProfileViewerFragment.newInstance());
|
pluginsList.add(TreatmentsFragment.newInstance());
|
||||||
|
pluginsList.add(TempBasalsFragment.newInstance());
|
||||||
pluginsList.add(ObjectivesFragment.newInstance());
|
pluginsList.add(ObjectivesFragment.newInstance());
|
||||||
pluginsList.add(ConfigBuilderFragment.newInstance());
|
pluginsList.add(configBuilderFragment = ConfigBuilderFragment.newInstance());
|
||||||
|
|
||||||
/*
|
|
||||||
pageAdapter.registerNewFragment(OverviewFragment.newInstance());
|
|
||||||
pageAdapter.registerNewFragment((VirtualPumpFragment) MainApp.setActivePump(VirtualPumpFragment.newInstance()));
|
|
||||||
pageAdapter.registerNewFragment(LowSuspendFragment.newInstance());
|
|
||||||
pageAdapter.registerNewFragment(OpenAPSMAFragment.newInstance());
|
|
||||||
pageAdapter.registerNewFragment(treatmentsFragment = TreatmentsFragment.newInstance());
|
|
||||||
pageAdapter.registerNewFragment(tempBasalsFragment = TempBasalsFragment.newInstance());
|
|
||||||
pageAdapter.registerNewFragment(ProfileViewerFragment.newInstance());
|
|
||||||
pageAdapter.registerNewFragment(ObjectivesFragment.newInstance());
|
|
||||||
pageAdapter.registerNewFragment(ConfigBuilderFragment.newInstance());
|
|
||||||
*/
|
|
||||||
toolbar = (Toolbar) findViewById(R.id.toolbar);
|
toolbar = (Toolbar) findViewById(R.id.toolbar);
|
||||||
setSupportActionBar(toolbar);
|
setSupportActionBar(toolbar);
|
||||||
|
|
||||||
registerBus();
|
registerBus();
|
||||||
|
|
||||||
|
configBuilderFragment.initialize();
|
||||||
setUpTabs(false);
|
setUpTabs(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -83,8 +81,8 @@ public class MainActivity extends AppCompatActivity {
|
||||||
|
|
||||||
private void setUpTabs(boolean switchToLast) {
|
private void setUpTabs(boolean switchToLast) {
|
||||||
pageAdapter = new TabPageAdapter(getSupportFragmentManager());
|
pageAdapter = new TabPageAdapter(getSupportFragmentManager());
|
||||||
for(Fragment f: pluginsList) {
|
for (PluginBase f : pluginsList) {
|
||||||
pageAdapter.registerNewFragment(f);
|
pageAdapter.registerNewFragment((Fragment) f);
|
||||||
}
|
}
|
||||||
mPager = (ViewPager) findViewById(R.id.pager);
|
mPager = (ViewPager) findViewById(R.id.pager);
|
||||||
mPager.setAdapter(pageAdapter);
|
mPager.setAdapter(pageAdapter);
|
||||||
|
@ -120,4 +118,20 @@ public class MainActivity extends AppCompatActivity {
|
||||||
public static TabPageAdapter getPageAdapter() {
|
public static TabPageAdapter getPageAdapter() {
|
||||||
return pageAdapter;
|
return pageAdapter;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static ArrayList<PluginBase> getPluginsList() {
|
||||||
|
return pluginsList;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static ArrayList<PluginBase> getSpecificPluginsList(int type) {
|
||||||
|
ArrayList<PluginBase> newList = new ArrayList<PluginBase>();
|
||||||
|
|
||||||
|
Iterator<PluginBase> it = pluginsList.iterator();
|
||||||
|
while (it.hasNext()) {
|
||||||
|
PluginBase p = it.next();
|
||||||
|
if (p.getType() == type)
|
||||||
|
newList.add(p);
|
||||||
|
}
|
||||||
|
return newList;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,36 +1,23 @@
|
||||||
package info.nightscout.androidaps;
|
package info.nightscout.androidaps;
|
||||||
|
|
||||||
import android.app.Application;
|
import android.app.Application;
|
||||||
import android.content.SharedPreferences;
|
|
||||||
|
|
||||||
import com.j256.ormlite.android.apptools.OpenHelperManager;
|
import com.j256.ormlite.android.apptools.OpenHelperManager;
|
||||||
import com.squareup.otto.Bus;
|
import com.squareup.otto.Bus;
|
||||||
import com.squareup.otto.ThreadEnforcer;
|
import com.squareup.otto.ThreadEnforcer;
|
||||||
|
|
||||||
import org.json.JSONException;
|
|
||||||
import org.json.JSONObject;
|
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
import info.nightscout.androidaps.plugins.Pump;
|
|
||||||
import info.nightscout.client.data.NSProfile;
|
|
||||||
import info.nightscout.androidaps.db.DatabaseHelper;
|
import info.nightscout.androidaps.db.DatabaseHelper;
|
||||||
|
|
||||||
|
|
||||||
public class MainApp extends Application {
|
public class MainApp extends Application {
|
||||||
private static Logger log = LoggerFactory.getLogger(MainApp.class);
|
private static Logger log = LoggerFactory.getLogger(MainApp.class);
|
||||||
|
|
||||||
public static final String PREFS_NAME = "NightscoutProfile";
|
|
||||||
|
|
||||||
|
|
||||||
private static Bus sBus;
|
private static Bus sBus;
|
||||||
private static MainApp sInstance;
|
private static MainApp sInstance;
|
||||||
|
|
||||||
private static NSProfile nsProfile = null;
|
|
||||||
private static String activeProfile = null;
|
|
||||||
|
|
||||||
private static Pump activePump = null;
|
|
||||||
|
|
||||||
private static DatabaseHelper databaseHelper = null;
|
private static DatabaseHelper databaseHelper = null;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -39,21 +26,6 @@ public class MainApp extends Application {
|
||||||
|
|
||||||
sBus = new Bus(ThreadEnforcer.ANY);
|
sBus = new Bus(ThreadEnforcer.ANY);
|
||||||
sInstance = this;
|
sInstance = this;
|
||||||
|
|
||||||
log.debug("Loading stored profile");
|
|
||||||
SharedPreferences store = getSharedPreferences(PREFS_NAME, 0);
|
|
||||||
activeProfile = store.getString("activeProfile", null);
|
|
||||||
String profileString = store.getString("profile", null);
|
|
||||||
if (profileString != null) {
|
|
||||||
try {
|
|
||||||
log.debug("Loaded profile: " + profileString);
|
|
||||||
log.debug("Loaded active profile: " + activeProfile);
|
|
||||||
setNSProfile(new NSProfile(new JSONObject(profileString), activeProfile));
|
|
||||||
} catch (JSONException e) {
|
|
||||||
}
|
|
||||||
} else
|
|
||||||
log.debug("Stored profile not found");
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Bus bus() {
|
public static Bus bus() {
|
||||||
|
@ -82,27 +54,4 @@ public class MainApp extends Application {
|
||||||
super.onTerminate();
|
super.onTerminate();
|
||||||
databaseHelper.close();
|
databaseHelper.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static NSProfile getNSProfile() {
|
|
||||||
return nsProfile;
|
|
||||||
}
|
|
||||||
public static void setNSProfile(NSProfile profile) {
|
|
||||||
nsProfile = profile;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static String getActiveProfile() {
|
|
||||||
return activeProfile;
|
|
||||||
}
|
|
||||||
public static void setActiveProfile(String activeprofile) {
|
|
||||||
activeProfile = activeprofile;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static Pump getActivePump() {
|
|
||||||
return activePump;
|
|
||||||
}
|
|
||||||
public static Pump setActivePump(Pump activepump) {
|
|
||||||
activePump = activepump;
|
|
||||||
return activepump;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
|
@ -23,6 +23,7 @@ import java.sql.SQLException;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
import info.nightscout.androidaps.MainActivity;
|
||||||
import info.nightscout.androidaps.MainApp;
|
import info.nightscout.androidaps.MainApp;
|
||||||
import info.nightscout.androidaps.db.BgReading;
|
import info.nightscout.androidaps.db.BgReading;
|
||||||
import info.nightscout.androidaps.db.Treatment;
|
import info.nightscout.androidaps.db.Treatment;
|
||||||
|
@ -30,6 +31,7 @@ import info.nightscout.androidaps.events.EventNewBG;
|
||||||
import info.nightscout.androidaps.events.EventNewBasalProfile;
|
import info.nightscout.androidaps.events.EventNewBasalProfile;
|
||||||
import info.nightscout.androidaps.events.EventTreatmentChange;
|
import info.nightscout.androidaps.events.EventTreatmentChange;
|
||||||
import info.nightscout.androidaps.Config;
|
import info.nightscout.androidaps.Config;
|
||||||
|
import info.nightscout.androidaps.interfaces.PumpInterface;
|
||||||
import info.nightscout.client.data.NSProfile;
|
import info.nightscout.client.data.NSProfile;
|
||||||
import info.nightscout.client.data.NSSgv;
|
import info.nightscout.client.data.NSSgv;
|
||||||
|
|
||||||
|
@ -133,17 +135,16 @@ public class DataService extends IntentService {
|
||||||
String activeProfile = bundles.getString("activeprofile");
|
String activeProfile = bundles.getString("activeprofile");
|
||||||
String profile = bundles.getString("profile");
|
String profile = bundles.getString("profile");
|
||||||
NSProfile nsProfile = new NSProfile(new JSONObject(profile), activeProfile);
|
NSProfile nsProfile = new NSProfile(new JSONObject(profile), activeProfile);
|
||||||
MainApp.instance().setNSProfile(nsProfile);
|
EventNewBasalProfile event = new EventNewBasalProfile(nsProfile);
|
||||||
MainApp.instance().setActiveProfile(activeProfile);
|
PumpInterface pump = MainActivity.getConfigBuilder().getActivePump();
|
||||||
storeNSProfile();
|
if (pump != null) {
|
||||||
if (MainApp.getActivePump() != null) {
|
pump.setNewBasalProfile(nsProfile);
|
||||||
MainApp.getActivePump().setNewBasalProfile(MainApp.getNSProfile());
|
|
||||||
} else {
|
} else {
|
||||||
log.error("No active pump selected");
|
log.error("No active pump selected");
|
||||||
}
|
}
|
||||||
if (Config.logIncommingData)
|
if (Config.logIncommingData)
|
||||||
log.debug("Received profile: " + activeProfile + " " + profile);
|
log.debug("Received profile: " + activeProfile + " " + profile);
|
||||||
MainApp.bus().post(new EventNewBasalProfile());
|
MainApp.bus().post(event);
|
||||||
} catch (JSONException e) {
|
} catch (JSONException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
|
@ -325,14 +326,6 @@ public class DataService extends IntentService {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void storeNSProfile() {
|
|
||||||
SharedPreferences settings = MainApp.instance().getApplicationContext().getSharedPreferences(MainApp.instance().PREFS_NAME, 0);
|
|
||||||
SharedPreferences.Editor editor = settings.edit();
|
|
||||||
editor.putString("profile", MainApp.instance().getNSProfile().getData().toString());
|
|
||||||
editor.putString("activeProfile", MainApp.instance().getActiveProfile());
|
|
||||||
editor.commit();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
public static Treatment findById(String _id) {
|
public static Treatment findById(String _id) {
|
||||||
try {
|
try {
|
||||||
|
|
|
@ -10,6 +10,7 @@ import java.util.Calendar;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.TimeZone;
|
import java.util.TimeZone;
|
||||||
|
|
||||||
|
import info.nightscout.androidaps.MainActivity;
|
||||||
import info.nightscout.androidaps.MainApp;
|
import info.nightscout.androidaps.MainApp;
|
||||||
import info.nightscout.androidaps.data.Iob;
|
import info.nightscout.androidaps.data.Iob;
|
||||||
import info.nightscout.androidaps.plugins.OpenAPSMA.IobTotal;
|
import info.nightscout.androidaps.plugins.OpenAPSMA.IobTotal;
|
||||||
|
@ -55,7 +56,7 @@ public class TempBasal {
|
||||||
|
|
||||||
public IobTotal iobCalc(Date time) {
|
public IobTotal iobCalc(Date time) {
|
||||||
IobTotal result = new IobTotal();
|
IobTotal result = new IobTotal();
|
||||||
NSProfile profile = MainApp.getNSProfile();
|
NSProfile profile = MainActivity.getConfigBuilder().getActiveProfile().getProfile();
|
||||||
|
|
||||||
if (profile == null)
|
if (profile == null)
|
||||||
return result;
|
return result;
|
||||||
|
|
|
@ -1,8 +1,14 @@
|
||||||
package info.nightscout.androidaps.events;
|
package info.nightscout.androidaps.events;
|
||||||
|
|
||||||
|
import info.nightscout.client.data.NSProfile;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by mike on 04.06.2016.
|
* Created by mike on 04.06.2016.
|
||||||
*/
|
*/
|
||||||
public class EventNewBasalProfile {
|
public class EventNewBasalProfile {
|
||||||
// TODO: implement proper GUI update
|
public NSProfile newNSProfile = null;
|
||||||
|
|
||||||
|
public EventNewBasalProfile(NSProfile newProfile) {
|
||||||
|
newNSProfile = newProfile;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,11 +1,13 @@
|
||||||
package info.nightscout.androidaps.plugins;
|
package info.nightscout.androidaps.interfaces;
|
||||||
|
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
|
|
||||||
|
import info.nightscout.androidaps.plugins.APSResult;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by mike on 10.06.2016.
|
* Created by mike on 10.06.2016.
|
||||||
*/
|
*/
|
||||||
public interface APSBase {
|
public interface APSInterface {
|
||||||
public APSResult getLastAPSResult();
|
public APSResult getLastAPSResult();
|
||||||
public Date getLastAPSRun();
|
public Date getLastAPSRun();
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
package info.nightscout.androidaps.plugins;
|
package info.nightscout.androidaps.interfaces;
|
||||||
|
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
|
|
|
@ -0,0 +1,13 @@
|
||||||
|
package info.nightscout.androidaps.interfaces;
|
||||||
|
|
||||||
|
import android.support.annotation.Nullable;
|
||||||
|
|
||||||
|
import info.nightscout.client.data.NSProfile;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Created by mike on 14.06.2016.
|
||||||
|
*/
|
||||||
|
public interface ProfileInterface {
|
||||||
|
@Nullable
|
||||||
|
NSProfile getProfile();
|
||||||
|
}
|
|
@ -1,4 +1,4 @@
|
||||||
package info.nightscout.androidaps.plugins;
|
package info.nightscout.androidaps.interfaces;
|
||||||
|
|
||||||
import org.json.JSONObject;
|
import org.json.JSONObject;
|
||||||
|
|
||||||
|
@ -8,7 +8,7 @@ import info.nightscout.client.data.NSProfile;
|
||||||
/**
|
/**
|
||||||
* Created by mike on 04.06.2016.
|
* Created by mike on 04.06.2016.
|
||||||
*/
|
*/
|
||||||
public interface Pump {
|
public interface PumpInterface {
|
||||||
|
|
||||||
boolean isTempBasalInProgress();
|
boolean isTempBasalInProgress();
|
||||||
boolean isExtendedBoluslInProgress();
|
boolean isExtendedBoluslInProgress();
|
||||||
|
@ -30,5 +30,6 @@ public interface Pump {
|
||||||
Result cancelTempBasal();
|
Result cancelTempBasal();
|
||||||
Result cancelExtendedBolus();
|
Result cancelExtendedBolus();
|
||||||
|
|
||||||
|
// Status to be passed to NS
|
||||||
JSONObject getJSONStatus();
|
JSONObject getJSONStatus();
|
||||||
}
|
}
|
|
@ -0,0 +1,11 @@
|
||||||
|
package info.nightscout.androidaps.interfaces;
|
||||||
|
|
||||||
|
import info.nightscout.androidaps.plugins.OpenAPSMA.IobTotal;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Created by mike on 14.06.2016.
|
||||||
|
*/
|
||||||
|
public interface TempBasalsInterface {
|
||||||
|
void updateTotalIOBIfNeeded();
|
||||||
|
IobTotal getLastCalculation();
|
||||||
|
}
|
|
@ -0,0 +1,13 @@
|
||||||
|
package info.nightscout.androidaps.interfaces;
|
||||||
|
|
||||||
|
import info.nightscout.androidaps.plugins.OpenAPSMA.IobTotal;
|
||||||
|
import info.nightscout.androidaps.plugins.Treatments.TreatmentsFragment;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Created by mike on 14.06.2016.
|
||||||
|
*/
|
||||||
|
public interface TreatmentsInterface {
|
||||||
|
void updateTotalIOBIfNeeded();
|
||||||
|
IobTotal getLastCalculation();
|
||||||
|
TreatmentsFragment.MealData getMealData();
|
||||||
|
}
|
|
@ -2,7 +2,9 @@ package info.nightscout.androidaps.plugins.ConfigBuilder;
|
||||||
|
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
|
import android.content.SharedPreferences;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
|
import android.support.annotation.Nullable;
|
||||||
import android.support.v4.app.Fragment;
|
import android.support.v4.app.Fragment;
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
|
@ -14,23 +16,37 @@ import android.widget.ListView;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
import android.widget.Toast;
|
import android.widget.Toast;
|
||||||
|
|
||||||
|
import org.json.JSONException;
|
||||||
|
import org.json.JSONObject;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
|
||||||
|
import info.nightscout.androidaps.Config;
|
||||||
import info.nightscout.androidaps.MainActivity;
|
import info.nightscout.androidaps.MainActivity;
|
||||||
import info.nightscout.androidaps.MainApp;
|
import info.nightscout.androidaps.MainApp;
|
||||||
import info.nightscout.androidaps.R;
|
import info.nightscout.androidaps.R;
|
||||||
|
import info.nightscout.androidaps.data.Result;
|
||||||
|
import info.nightscout.androidaps.db.TempBasal;
|
||||||
import info.nightscout.androidaps.events.EventRefreshGui;
|
import info.nightscout.androidaps.events.EventRefreshGui;
|
||||||
import info.nightscout.androidaps.plugins.PluginBase;
|
import info.nightscout.androidaps.interfaces.PluginBase;
|
||||||
|
import info.nightscout.androidaps.interfaces.ProfileInterface;
|
||||||
|
import info.nightscout.androidaps.interfaces.PumpInterface;
|
||||||
|
import info.nightscout.androidaps.interfaces.TempBasalsInterface;
|
||||||
|
import info.nightscout.androidaps.interfaces.TreatmentsInterface;
|
||||||
|
import info.nightscout.androidaps.plugins.TempBasals.TempBasalsFragment;
|
||||||
|
import info.nightscout.androidaps.plugins.Treatments.TreatmentsFragment;
|
||||||
|
import info.nightscout.client.data.NSProfile;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A simple {@link Fragment} subclass.
|
* A simple {@link Fragment} subclass.
|
||||||
*/
|
*/
|
||||||
public class ConfigBuilderFragment extends Fragment implements PluginBase {
|
public class ConfigBuilderFragment extends Fragment implements PluginBase, PumpInterface {
|
||||||
private static Logger log = LoggerFactory.getLogger(ConfigBuilderFragment.class);
|
private static Logger log = LoggerFactory.getLogger(ConfigBuilderFragment.class);
|
||||||
|
|
||||||
|
private static final String PREFS_NAME = "Settings";
|
||||||
|
|
||||||
ListView pumpListView;
|
ListView pumpListView;
|
||||||
ListView treatmentsListView;
|
ListView treatmentsListView;
|
||||||
ListView tempsListView;
|
ListView tempsListView;
|
||||||
|
@ -46,6 +62,37 @@ public class ConfigBuilderFragment extends Fragment implements PluginBase {
|
||||||
PluginCustomAdapter generalDataAdapter = null;
|
PluginCustomAdapter generalDataAdapter = null;
|
||||||
|
|
||||||
|
|
||||||
|
PumpInterface activePump;
|
||||||
|
ProfileInterface activeProfile;
|
||||||
|
TreatmentsInterface activeTreatments;
|
||||||
|
TempBasalsInterface activeTempBasals;
|
||||||
|
|
||||||
|
ArrayList<PluginBase> pluginList;
|
||||||
|
|
||||||
|
public ConfigBuilderFragment() {
|
||||||
|
super();
|
||||||
|
registerBus();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void initialize() {
|
||||||
|
pluginList = MainActivity.getPluginsList();
|
||||||
|
loadSettings();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onCreate(Bundle savedInstanceState) {
|
||||||
|
super.onCreate(savedInstanceState);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void registerBus() {
|
||||||
|
try {
|
||||||
|
MainApp.bus().unregister(this);
|
||||||
|
} catch (RuntimeException x) {
|
||||||
|
// Ignore
|
||||||
|
}
|
||||||
|
MainApp.bus().register(this);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public View onCreateView(LayoutInflater inflater, ViewGroup container,
|
public View onCreateView(LayoutInflater inflater, ViewGroup container,
|
||||||
Bundle savedInstanceState) {
|
Bundle savedInstanceState) {
|
||||||
|
@ -57,19 +104,22 @@ public class ConfigBuilderFragment extends Fragment implements PluginBase {
|
||||||
apsListView = (ListView) view.findViewById(R.id.configbuilder_apslistview);
|
apsListView = (ListView) view.findViewById(R.id.configbuilder_apslistview);
|
||||||
generalListView = (ListView) view.findViewById(R.id.configbuilder_generallistview);
|
generalListView = (ListView) view.findViewById(R.id.configbuilder_generallistview);
|
||||||
|
|
||||||
//Array list of countries
|
setViews();
|
||||||
ArrayList<PluginBase> pluginList = MainActivity.getPageAdapter().getPluginsList();
|
return view;
|
||||||
pumpDataAdapter = new PluginCustomAdapter(getContext(), R.layout.configbuilder_simpleitem, MainActivity.getPageAdapter().getSpecificPluginsList(PluginBase.PUMP));
|
}
|
||||||
|
|
||||||
|
void setViews() {
|
||||||
|
pumpDataAdapter = new PluginCustomAdapter(getContext(), R.layout.configbuilder_simpleitem, MainActivity.getSpecificPluginsList(PluginBase.PUMP));
|
||||||
pumpListView.setAdapter(pumpDataAdapter);
|
pumpListView.setAdapter(pumpDataAdapter);
|
||||||
treatmentsDataAdapter = new PluginCustomAdapter(getContext(), R.layout.configbuilder_simpleitem, MainActivity.getPageAdapter().getSpecificPluginsList(PluginBase.TREATMENT));
|
treatmentsDataAdapter = new PluginCustomAdapter(getContext(), R.layout.configbuilder_simpleitem, MainActivity.getSpecificPluginsList(PluginBase.TREATMENT));
|
||||||
treatmentsListView.setAdapter(treatmentsDataAdapter);
|
treatmentsListView.setAdapter(treatmentsDataAdapter);
|
||||||
tempsDataAdapter = new PluginCustomAdapter(getContext(), R.layout.configbuilder_simpleitem, MainActivity.getPageAdapter().getSpecificPluginsList(PluginBase.TEMPBASAL));
|
tempsDataAdapter = new PluginCustomAdapter(getContext(), R.layout.configbuilder_simpleitem, MainActivity.getSpecificPluginsList(PluginBase.TEMPBASAL));
|
||||||
tempsListView.setAdapter(tempsDataAdapter);
|
tempsListView.setAdapter(tempsDataAdapter);
|
||||||
profileDataAdapter = new PluginCustomAdapter(getContext(), R.layout.configbuilder_simpleitem, MainActivity.getPageAdapter().getSpecificPluginsList(PluginBase.PROFILE));
|
profileDataAdapter = new PluginCustomAdapter(getContext(), R.layout.configbuilder_simpleitem, MainActivity.getSpecificPluginsList(PluginBase.PROFILE));
|
||||||
profileListView.setAdapter(profileDataAdapter);
|
profileListView.setAdapter(profileDataAdapter);
|
||||||
apsDataAdapter = new PluginCustomAdapter(getContext(), R.layout.configbuilder_simpleitem, MainActivity.getPageAdapter().getSpecificPluginsList(PluginBase.APS));
|
apsDataAdapter = new PluginCustomAdapter(getContext(), R.layout.configbuilder_simpleitem, MainActivity.getSpecificPluginsList(PluginBase.APS));
|
||||||
apsListView.setAdapter(apsDataAdapter);
|
apsListView.setAdapter(apsDataAdapter);
|
||||||
generalDataAdapter = new PluginCustomAdapter(getContext(), R.layout.configbuilder_simpleitem, MainActivity.getPageAdapter().getSpecificPluginsList(PluginBase.GENERAL));
|
generalDataAdapter = new PluginCustomAdapter(getContext(), R.layout.configbuilder_simpleitem, MainActivity.getSpecificPluginsList(PluginBase.GENERAL));
|
||||||
generalListView.setAdapter(generalDataAdapter);
|
generalListView.setAdapter(generalDataAdapter);
|
||||||
|
|
||||||
|
|
||||||
|
@ -83,10 +133,11 @@ public class ConfigBuilderFragment extends Fragment implements PluginBase {
|
||||||
Toast.LENGTH_LONG).show();
|
Toast.LENGTH_LONG).show();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
return view;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* PluginBase interface
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
public int getType() {
|
public int getType() {
|
||||||
return PluginBase.GENERAL;
|
return PluginBase.GENERAL;
|
||||||
|
@ -127,6 +178,100 @@ public class ConfigBuilderFragment extends Fragment implements PluginBase {
|
||||||
return fragment;
|
return fragment;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Pump interface
|
||||||
|
*
|
||||||
|
* Config builder return itself as a pump and check constrains before it passes command to pump driver
|
||||||
|
*/
|
||||||
|
@Nullable
|
||||||
|
public PumpInterface getActivePump() {
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isTempBasalInProgress() {
|
||||||
|
return activePump.isTempBasalInProgress();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isExtendedBoluslInProgress() {
|
||||||
|
return activePump.isExtendedBoluslInProgress();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Integer getBatteryPercent() {
|
||||||
|
return activePump.getBatteryPercent();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Integer getReservoirValue() {
|
||||||
|
return activePump.getReservoirValue();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setNewBasalProfile(NSProfile profile) {
|
||||||
|
activePump.setNewBasalProfile(profile);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public double getBaseBasalRate() {
|
||||||
|
return activePump.getBaseBasalRate();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public double getTempBasalAbsoluteRate() {
|
||||||
|
return activePump.getTempBasalAbsoluteRate();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public double getTempBasalRemainingMinutes() {
|
||||||
|
return activePump.getTempBasalRemainingMinutes();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Result deliverTreatment(Double insulin, Double carbs) {
|
||||||
|
// TODO: constrains here
|
||||||
|
return activePump.deliverTreatment(insulin, carbs);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Result setTempBasalAbsolute(Double absoluteRate, Integer durationInMinutes) {
|
||||||
|
// TODO: constrains here
|
||||||
|
return activePump.setTempBasalAbsolute(absoluteRate, durationInMinutes);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Result setTempBasalPercent(Integer percent, Integer durationInMinutes) {
|
||||||
|
// TODO: constrains here
|
||||||
|
return activePump.setTempBasalPercent(percent, durationInMinutes);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Result setExtendedBolus(Double insulin, Integer durationInMinutes) {
|
||||||
|
// TODO: constrains here
|
||||||
|
return activePump.setExtendedBolus(insulin, durationInMinutes);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Result cancelTempBasal() {
|
||||||
|
return activePump.cancelTempBasal();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Result cancelExtendedBolus() {
|
||||||
|
return activePump.cancelExtendedBolus();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public JSONObject getJSONStatus() {
|
||||||
|
return activePump.getJSONStatus();
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* ConfigBuilderFragment code
|
||||||
|
*/
|
||||||
|
|
||||||
private class PluginCustomAdapter extends ArrayAdapter<PluginBase> {
|
private class PluginCustomAdapter extends ArrayAdapter<PluginBase> {
|
||||||
|
|
||||||
private ArrayList<PluginBase> pluginList;
|
private ArrayList<PluginBase> pluginList;
|
||||||
|
@ -167,6 +312,7 @@ public class ConfigBuilderFragment extends Fragment implements PluginBase {
|
||||||
" is " + cb.isChecked(),
|
" is " + cb.isChecked(),
|
||||||
Toast.LENGTH_LONG).show();
|
Toast.LENGTH_LONG).show();
|
||||||
plugin.setFragmentEnabled(cb.isChecked());
|
plugin.setFragmentEnabled(cb.isChecked());
|
||||||
|
onEnabledCategoryChanged(plugin);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -180,6 +326,7 @@ public class ConfigBuilderFragment extends Fragment implements PluginBase {
|
||||||
Toast.LENGTH_LONG).show();
|
Toast.LENGTH_LONG).show();
|
||||||
plugin.setFragmentVisible(cb.isChecked());
|
plugin.setFragmentVisible(cb.isChecked());
|
||||||
MainApp.bus().post(new EventRefreshGui());
|
MainApp.bus().post(new EventRefreshGui());
|
||||||
|
storeSettings();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
|
@ -199,12 +346,139 @@ public class ConfigBuilderFragment extends Fragment implements PluginBase {
|
||||||
holder.checkboxVisible.setEnabled(false);
|
holder.checkboxVisible.setEnabled(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int type = plugin.getType();
|
||||||
|
if (type == PluginBase.PUMP || type == PluginBase.TREATMENT || type == PluginBase.TEMPBASAL || type == PluginBase.PROFILE)
|
||||||
|
if (pluginList.size() < 2)
|
||||||
|
holder.checkboxEnabled.setEnabled(false);
|
||||||
|
|
||||||
return convertView;
|
return convertView;
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void displayListView() {
|
@Nullable
|
||||||
|
public ProfileInterface getActiveProfile() {
|
||||||
|
return activeProfile;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
public TreatmentsInterface getActiveTreatments() {
|
||||||
|
return activeTreatments;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
public TempBasalsInterface getActiveTempBasals() {
|
||||||
|
return activeTempBasals;
|
||||||
|
}
|
||||||
|
|
||||||
|
void onEnabledCategoryChanged(PluginBase changedPlugin) {
|
||||||
|
int category = changedPlugin.getType();
|
||||||
|
ArrayList<PluginBase> pluginsInCategory = MainActivity.getSpecificPluginsList(category);
|
||||||
|
switch (category) {
|
||||||
|
// Multiple selection allowed
|
||||||
|
case PluginBase.APS:
|
||||||
|
case PluginBase.GENERAL:
|
||||||
|
break;
|
||||||
|
// Single selection allowed
|
||||||
|
case PluginBase.PROFILE:
|
||||||
|
case PluginBase.PUMP:
|
||||||
|
case PluginBase.TEMPBASAL:
|
||||||
|
case PluginBase.TREATMENT:
|
||||||
|
boolean newSelection = changedPlugin.isEnabled();
|
||||||
|
if (newSelection) { // new plugin selected -> disable others
|
||||||
|
for (PluginBase p : pluginsInCategory) {
|
||||||
|
if (p.getName().equals(changedPlugin.getName())) {
|
||||||
|
// this is new selected
|
||||||
|
} else {
|
||||||
|
p.setFragmentEnabled(false);
|
||||||
|
setViews();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else { // enable first plugin in list
|
||||||
|
pluginsInCategory.get(0).setFragmentEnabled(true);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
storeSettings();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void verifySelectionInCategories() {
|
||||||
|
for (int category : new int[]{PluginBase.GENERAL, PluginBase.APS, PluginBase.PROFILE, PluginBase.PUMP, PluginBase.TEMPBASAL, PluginBase.TREATMENT}) {
|
||||||
|
ArrayList<PluginBase> pluginsInCategory = MainActivity.getSpecificPluginsList(category);
|
||||||
|
switch (category) {
|
||||||
|
// Multiple selection allowed
|
||||||
|
case PluginBase.APS:
|
||||||
|
case PluginBase.GENERAL:
|
||||||
|
break;
|
||||||
|
// Single selection allowed
|
||||||
|
case PluginBase.PROFILE:
|
||||||
|
activeProfile = (ProfileInterface) getTheOneEnabledInArray(pluginsInCategory);
|
||||||
|
if (Config.logConfigBuilder)
|
||||||
|
log.debug("Selected profile interface: " + ((PluginBase) activeProfile).getName());
|
||||||
|
break;
|
||||||
|
case PluginBase.PUMP:
|
||||||
|
activePump = (PumpInterface) getTheOneEnabledInArray(pluginsInCategory);
|
||||||
|
if (Config.logConfigBuilder)
|
||||||
|
log.debug("Selected pump interface: " + ((PluginBase) activePump).getName());
|
||||||
|
break;
|
||||||
|
case PluginBase.TEMPBASAL:
|
||||||
|
activeTempBasals = (TempBasalsInterface) getTheOneEnabledInArray(pluginsInCategory);
|
||||||
|
if (Config.logConfigBuilder)
|
||||||
|
log.debug("Selected tempbasal interface: " + ((PluginBase) activeTempBasals).getName());
|
||||||
|
break;
|
||||||
|
case PluginBase.TREATMENT:
|
||||||
|
activeTreatments = (TreatmentsInterface) getTheOneEnabledInArray(pluginsInCategory);
|
||||||
|
if (Config.logConfigBuilder)
|
||||||
|
log.debug("Selected treatment interface: " + ((PluginBase) activeTreatments).getName());
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private PluginBase getTheOneEnabledInArray(ArrayList<PluginBase> pluginsInCategory) {
|
||||||
|
PluginBase found = null;
|
||||||
|
for (PluginBase p : pluginsInCategory) {
|
||||||
|
if (p.isEnabled() && found == null) {
|
||||||
|
found = p;
|
||||||
|
continue;
|
||||||
|
} else if (p.isEnabled()) {
|
||||||
|
// set others disabled
|
||||||
|
p.setFragmentEnabled(false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// If none enabled, enable first one
|
||||||
|
if (found == null)
|
||||||
|
found = pluginsInCategory.get(0);
|
||||||
|
return found;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void storeSettings() {
|
||||||
|
if (Config.logPrefsChange)
|
||||||
|
log.debug("Storing settings");
|
||||||
|
SharedPreferences settings = MainApp.instance().getApplicationContext().getSharedPreferences(PREFS_NAME, 0);
|
||||||
|
SharedPreferences.Editor editor = settings.edit();
|
||||||
|
|
||||||
|
for (PluginBase p : pluginList) {
|
||||||
|
editor.putBoolean(p.getName() + "Enabled", p.isEnabled());
|
||||||
|
editor.putBoolean(p.getName() + "Visible", p.isVisibleInTabs());
|
||||||
|
}
|
||||||
|
editor.commit();
|
||||||
|
verifySelectionInCategories();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void loadSettings() {
|
||||||
|
if (Config.logPrefsChange)
|
||||||
|
log.debug("Loading stored settings");
|
||||||
|
SharedPreferences settings = MainApp.instance().getApplicationContext().getSharedPreferences(PREFS_NAME, 0);
|
||||||
|
for (PluginBase p : pluginList) {
|
||||||
|
if (settings.contains(p.getName() + "Enabled"))
|
||||||
|
p.setFragmentEnabled(settings.getBoolean(p.getName() + "Enabled", true));
|
||||||
|
if (settings.contains(p.getName() + "Visible"))
|
||||||
|
p.setFragmentVisible(settings.getBoolean(p.getName() + "Visible", true));
|
||||||
|
}
|
||||||
|
verifySelectionInCategories();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
|
@ -21,17 +21,18 @@ import java.util.Date;
|
||||||
|
|
||||||
import info.nightscout.androidaps.Config;
|
import info.nightscout.androidaps.Config;
|
||||||
import info.nightscout.androidaps.Constants;
|
import info.nightscout.androidaps.Constants;
|
||||||
|
import info.nightscout.androidaps.MainActivity;
|
||||||
import info.nightscout.androidaps.MainApp;
|
import info.nightscout.androidaps.MainApp;
|
||||||
import info.nightscout.androidaps.R;
|
import info.nightscout.androidaps.R;
|
||||||
import info.nightscout.androidaps.plugins.Pump;
|
import info.nightscout.androidaps.interfaces.PumpInterface;
|
||||||
import info.nightscout.androidaps.db.DatabaseHelper;
|
import info.nightscout.androidaps.db.DatabaseHelper;
|
||||||
import info.nightscout.androidaps.events.EventNewBG;
|
import info.nightscout.androidaps.events.EventNewBG;
|
||||||
import info.nightscout.androidaps.plugins.APSBase;
|
import info.nightscout.androidaps.interfaces.APSInterface;
|
||||||
import info.nightscout.androidaps.plugins.APSResult;
|
import info.nightscout.androidaps.plugins.APSResult;
|
||||||
import info.nightscout.androidaps.plugins.PluginBase;
|
import info.nightscout.androidaps.interfaces.PluginBase;
|
||||||
import info.nightscout.client.data.NSProfile;
|
import info.nightscout.client.data.NSProfile;
|
||||||
|
|
||||||
public class LowSuspendFragment extends Fragment implements View.OnClickListener, PluginBase, APSBase {
|
public class LowSuspendFragment extends Fragment implements View.OnClickListener, PluginBase, APSInterface {
|
||||||
private static Logger log = LoggerFactory.getLogger(LowSuspendFragment.class);
|
private static Logger log = LoggerFactory.getLogger(LowSuspendFragment.class);
|
||||||
|
|
||||||
Button run;
|
Button run;
|
||||||
|
@ -47,6 +48,11 @@ public class LowSuspendFragment extends Fragment implements View.OnClickListener
|
||||||
boolean fragmentEnabled = false;
|
boolean fragmentEnabled = false;
|
||||||
boolean fragmentVisible = true;
|
boolean fragmentVisible = true;
|
||||||
|
|
||||||
|
public LowSuspendFragment() {
|
||||||
|
super();
|
||||||
|
registerBus();
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getName() {
|
public String getName() {
|
||||||
return MainApp.instance().getString(R.string.lowsuspend);
|
return MainApp.instance().getString(R.string.lowsuspend);
|
||||||
|
@ -100,7 +106,6 @@ public class LowSuspendFragment extends Fragment implements View.OnClickListener
|
||||||
@Override
|
@Override
|
||||||
public void onCreate(Bundle savedInstanceState) {
|
public void onCreate(Bundle savedInstanceState) {
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
registerBus();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -157,8 +162,8 @@ public class LowSuspendFragment extends Fragment implements View.OnClickListener
|
||||||
SharedPreferences SP = PreferenceManager.getDefaultSharedPreferences(MainApp.instance().getApplicationContext());
|
SharedPreferences SP = PreferenceManager.getDefaultSharedPreferences(MainApp.instance().getApplicationContext());
|
||||||
DatabaseHelper.GlucoseStatus glucoseStatus = MainApp.getDbHelper().getGlucoseStatusData();
|
DatabaseHelper.GlucoseStatus glucoseStatus = MainApp.getDbHelper().getGlucoseStatusData();
|
||||||
DecimalFormat formatNumber1decimalplaces = new DecimalFormat("0.0");
|
DecimalFormat formatNumber1decimalplaces = new DecimalFormat("0.0");
|
||||||
NSProfile profile = MainApp.getNSProfile();
|
NSProfile profile = MainActivity.getConfigBuilder().getActiveProfile().getProfile();
|
||||||
Pump pump = MainApp.getActivePump();
|
PumpInterface pump = MainActivity.getConfigBuilder().getActivePump();
|
||||||
|
|
||||||
if (glucoseStatus == null) {
|
if (glucoseStatus == null) {
|
||||||
resultView.setText(getString(R.string.openapsma_noglucosedata));
|
resultView.setText(getString(R.string.openapsma_noglucosedata));
|
||||||
|
@ -179,7 +184,7 @@ public class LowSuspendFragment extends Fragment implements View.OnClickListener
|
||||||
}
|
}
|
||||||
|
|
||||||
String minBgDefault = "90";
|
String minBgDefault = "90";
|
||||||
if (!MainApp.getNSProfile().getUnits().equals(Constants.MGDL)) {
|
if (!profile.getUnits().equals(Constants.MGDL)) {
|
||||||
minBgDefault = "5";
|
minBgDefault = "5";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,9 @@
|
||||||
package info.nightscout.androidaps.plugins.ProfileViewer;
|
package info.nightscout.androidaps.plugins.NSProfileViewer;
|
||||||
|
|
||||||
import android.app.Activity;
|
import android.app.Activity;
|
||||||
|
import android.content.SharedPreferences;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
|
import android.support.annotation.Nullable;
|
||||||
import android.support.v4.app.Fragment;
|
import android.support.v4.app.Fragment;
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
|
@ -10,19 +12,23 @@ import android.widget.TextView;
|
||||||
|
|
||||||
import com.squareup.otto.Subscribe;
|
import com.squareup.otto.Subscribe;
|
||||||
|
|
||||||
|
import org.json.JSONException;
|
||||||
|
import org.json.JSONObject;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
import java.text.DecimalFormat;
|
import java.text.DecimalFormat;
|
||||||
|
|
||||||
|
import info.nightscout.androidaps.Config;
|
||||||
import info.nightscout.androidaps.MainApp;
|
import info.nightscout.androidaps.MainApp;
|
||||||
import info.nightscout.androidaps.R;
|
import info.nightscout.androidaps.R;
|
||||||
import info.nightscout.androidaps.events.EventNewBasalProfile;
|
import info.nightscout.androidaps.events.EventNewBasalProfile;
|
||||||
import info.nightscout.androidaps.plugins.PluginBase;
|
import info.nightscout.androidaps.interfaces.PluginBase;
|
||||||
|
import info.nightscout.androidaps.interfaces.ProfileInterface;
|
||||||
import info.nightscout.client.data.NSProfile;
|
import info.nightscout.client.data.NSProfile;
|
||||||
|
|
||||||
public class ProfileViewerFragment extends Fragment implements PluginBase {
|
public class NSProfileViewerFragment extends Fragment implements PluginBase, ProfileInterface {
|
||||||
private static Logger log = LoggerFactory.getLogger(ProfileViewerFragment.class);
|
private static Logger log = LoggerFactory.getLogger(NSProfileViewerFragment.class);
|
||||||
|
|
||||||
private static TextView noProfile;
|
private static TextView noProfile;
|
||||||
private static TextView units;
|
private static TextView units;
|
||||||
|
@ -33,11 +39,20 @@ public class ProfileViewerFragment extends Fragment implements PluginBase {
|
||||||
private static TextView basal;
|
private static TextView basal;
|
||||||
private static TextView target;
|
private static TextView target;
|
||||||
|
|
||||||
|
private static final String PREFS_NAME = "NightscoutProfile";
|
||||||
private static DecimalFormat formatNumber2decimalplaces = new DecimalFormat("0.00");
|
private static DecimalFormat formatNumber2decimalplaces = new DecimalFormat("0.00");
|
||||||
|
|
||||||
boolean fragmentEnabled = true;
|
boolean fragmentEnabled = true;
|
||||||
boolean fragmentVisible = true;
|
boolean fragmentVisible = true;
|
||||||
|
|
||||||
|
NSProfile profile = null;
|
||||||
|
|
||||||
|
public NSProfileViewerFragment () {
|
||||||
|
super();
|
||||||
|
loadNSProfile();
|
||||||
|
registerBus();
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getName() {
|
public String getName() {
|
||||||
return MainApp.instance().getString(R.string.profileviewer);
|
return MainApp.instance().getString(R.string.profileviewer);
|
||||||
|
@ -73,21 +88,15 @@ public class ProfileViewerFragment extends Fragment implements PluginBase {
|
||||||
return PluginBase.PROFILE;
|
return PluginBase.PROFILE;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static ProfileViewerFragment newInstance(String param1, String param2) {
|
|
||||||
ProfileViewerFragment fragment = new ProfileViewerFragment();
|
|
||||||
return fragment;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onCreate(Bundle savedInstanceState) {
|
public void onCreate(Bundle savedInstanceState) {
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
registerBus();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public View onCreateView(LayoutInflater inflater, ViewGroup container,
|
public View onCreateView(LayoutInflater inflater, ViewGroup container,
|
||||||
Bundle savedInstanceState) {
|
Bundle savedInstanceState) {
|
||||||
View layout = inflater.inflate(R.layout.profileviewer_fragment, container, false);
|
View layout = inflater.inflate(R.layout.nsprofileviewer_fragment, container, false);
|
||||||
|
|
||||||
noProfile = (TextView) layout.findViewById(R.id.profileview_noprofile);
|
noProfile = (TextView) layout.findViewById(R.id.profileview_noprofile);
|
||||||
units = (TextView) layout.findViewById(R.id.profileview_units);
|
units = (TextView) layout.findViewById(R.id.profileview_units);
|
||||||
|
@ -102,13 +111,12 @@ public class ProfileViewerFragment extends Fragment implements PluginBase {
|
||||||
return layout;
|
return layout;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static ProfileViewerFragment newInstance() {
|
public static NSProfileViewerFragment newInstance() {
|
||||||
ProfileViewerFragment fragment = new ProfileViewerFragment();
|
NSProfileViewerFragment fragment = new NSProfileViewerFragment();
|
||||||
return fragment;
|
return fragment;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setContent() {
|
private void setContent() {
|
||||||
NSProfile profile = MainApp.getNSProfile();
|
|
||||||
if (profile == null) {
|
if (profile == null) {
|
||||||
noProfile.setVisibility(View.VISIBLE);
|
noProfile.setVisibility(View.VISIBLE);
|
||||||
return;
|
return;
|
||||||
|
@ -135,6 +143,8 @@ public class ProfileViewerFragment extends Fragment implements PluginBase {
|
||||||
|
|
||||||
@Subscribe
|
@Subscribe
|
||||||
public void onStatusEvent(final EventNewBasalProfile ev) {
|
public void onStatusEvent(final EventNewBasalProfile ev) {
|
||||||
|
profile = new NSProfile(ev.newNSProfile.getData(), ev.newNSProfile.getActiveProfile());
|
||||||
|
storeNSProfile();
|
||||||
Activity activity = getActivity();
|
Activity activity = getActivity();
|
||||||
if (activity != null)
|
if (activity != null)
|
||||||
activity.runOnUiThread(new Runnable() {
|
activity.runOnUiThread(new Runnable() {
|
||||||
|
@ -146,4 +156,44 @@ public class ProfileViewerFragment extends Fragment implements PluginBase {
|
||||||
else
|
else
|
||||||
log.debug("EventNewBG: Activity is null");
|
log.debug("EventNewBG: Activity is null");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void storeNSProfile() {
|
||||||
|
SharedPreferences settings = MainApp.instance().getApplicationContext().getSharedPreferences(PREFS_NAME, 0);
|
||||||
|
SharedPreferences.Editor editor = settings.edit();
|
||||||
|
editor.putString("profile", profile.getData().toString());
|
||||||
|
editor.putString("activeProfile", profile.getActiveProfile());
|
||||||
|
editor.commit();
|
||||||
|
if (Config.logPrefsChange)
|
||||||
|
log.debug("Storing profile");
|
||||||
|
}
|
||||||
|
|
||||||
|
private void loadNSProfile() {
|
||||||
|
if (Config.logPrefsChange)
|
||||||
|
log.debug("Loading stored profile");
|
||||||
|
SharedPreferences store = MainApp.instance().getApplicationContext().getSharedPreferences(PREFS_NAME, 0);
|
||||||
|
String activeProfile = store.getString("activeProfile", null);
|
||||||
|
String profileString = store.getString("profile", null);
|
||||||
|
if (profileString != null) {
|
||||||
|
if (Config.logPrefsChange) {
|
||||||
|
log.debug("Loaded profile: " + profileString);
|
||||||
|
log.debug("Loaded active profile: " + activeProfile);
|
||||||
|
try {
|
||||||
|
profile = new NSProfile(new JSONObject(profileString), activeProfile);
|
||||||
|
} catch (JSONException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
profile = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (Config.logPrefsChange) {
|
||||||
|
log.debug("Stored profile not found");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
@Override
|
||||||
|
public NSProfile getProfile() {
|
||||||
|
return profile;
|
||||||
|
}
|
||||||
}
|
}
|
|
@ -16,7 +16,7 @@ import java.util.List;
|
||||||
|
|
||||||
import info.nightscout.androidaps.MainApp;
|
import info.nightscout.androidaps.MainApp;
|
||||||
import info.nightscout.androidaps.R;
|
import info.nightscout.androidaps.R;
|
||||||
import info.nightscout.androidaps.plugins.PluginBase;
|
import info.nightscout.androidaps.interfaces.PluginBase;
|
||||||
|
|
||||||
public class ObjectivesFragment extends Fragment implements PluginBase {
|
public class ObjectivesFragment extends Fragment implements PluginBase {
|
||||||
RecyclerView recyclerView;
|
RecyclerView recyclerView;
|
||||||
|
|
|
@ -13,7 +13,7 @@ import org.slf4j.LoggerFactory;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
|
||||||
import info.nightscout.androidaps.Config;
|
import info.nightscout.androidaps.Config;
|
||||||
import info.nightscout.androidaps.plugins.Pump;
|
import info.nightscout.androidaps.interfaces.PumpInterface;
|
||||||
import info.nightscout.androidaps.db.DatabaseHelper;
|
import info.nightscout.androidaps.db.DatabaseHelper;
|
||||||
import info.nightscout.androidaps.plugins.ScriptReader;
|
import info.nightscout.androidaps.plugins.ScriptReader;
|
||||||
import info.nightscout.androidaps.plugins.Treatments.TreatmentsFragment;
|
import info.nightscout.androidaps.plugins.Treatments.TreatmentsFragment;
|
||||||
|
@ -204,7 +204,7 @@ public class DetermineBasalAdapterJS {
|
||||||
double maxBasal,
|
double maxBasal,
|
||||||
double minBg,
|
double minBg,
|
||||||
double maxBg,
|
double maxBg,
|
||||||
Pump pump,
|
PumpInterface pump,
|
||||||
IobTotal iobData,
|
IobTotal iobData,
|
||||||
DatabaseHelper.GlucoseStatus glucoseStatus,
|
DatabaseHelper.GlucoseStatus glucoseStatus,
|
||||||
TreatmentsFragment.MealData mealData) {
|
TreatmentsFragment.MealData mealData) {
|
||||||
|
|
|
@ -25,19 +25,22 @@ import info.nightscout.androidaps.Constants;
|
||||||
import info.nightscout.androidaps.MainActivity;
|
import info.nightscout.androidaps.MainActivity;
|
||||||
import info.nightscout.androidaps.MainApp;
|
import info.nightscout.androidaps.MainApp;
|
||||||
import info.nightscout.androidaps.R;
|
import info.nightscout.androidaps.R;
|
||||||
import info.nightscout.androidaps.plugins.Pump;
|
import info.nightscout.androidaps.db.TempBasal;
|
||||||
|
import info.nightscout.androidaps.interfaces.PumpInterface;
|
||||||
import info.nightscout.androidaps.db.DatabaseHelper;
|
import info.nightscout.androidaps.db.DatabaseHelper;
|
||||||
import info.nightscout.androidaps.events.EventNewBG;
|
import info.nightscout.androidaps.events.EventNewBG;
|
||||||
import info.nightscout.androidaps.events.EventTreatmentChange;
|
import info.nightscout.androidaps.events.EventTreatmentChange;
|
||||||
import info.nightscout.androidaps.plugins.APSBase;
|
import info.nightscout.androidaps.interfaces.APSInterface;
|
||||||
|
import info.nightscout.androidaps.interfaces.TempBasalsInterface;
|
||||||
|
import info.nightscout.androidaps.interfaces.TreatmentsInterface;
|
||||||
import info.nightscout.androidaps.plugins.APSResult;
|
import info.nightscout.androidaps.plugins.APSResult;
|
||||||
import info.nightscout.androidaps.plugins.PluginBase;
|
import info.nightscout.androidaps.interfaces.PluginBase;
|
||||||
import info.nightscout.androidaps.plugins.ScriptReader;
|
import info.nightscout.androidaps.plugins.ScriptReader;
|
||||||
import info.nightscout.androidaps.plugins.Treatments.TreatmentsFragment;
|
import info.nightscout.androidaps.plugins.Treatments.TreatmentsFragment;
|
||||||
import info.nightscout.client.data.NSProfile;
|
import info.nightscout.client.data.NSProfile;
|
||||||
import info.nightscout.utils.DateUtil;
|
import info.nightscout.utils.DateUtil;
|
||||||
|
|
||||||
public class OpenAPSMAFragment extends Fragment implements View.OnClickListener, PluginBase, APSBase {
|
public class OpenAPSMAFragment extends Fragment implements View.OnClickListener, PluginBase, APSInterface {
|
||||||
private static Logger log = LoggerFactory.getLogger(OpenAPSMAFragment.class);
|
private static Logger log = LoggerFactory.getLogger(OpenAPSMAFragment.class);
|
||||||
|
|
||||||
Button run;
|
Button run;
|
||||||
|
@ -56,6 +59,11 @@ public class OpenAPSMAFragment extends Fragment implements View.OnClickListener,
|
||||||
boolean fragmentEnabled = false;
|
boolean fragmentEnabled = false;
|
||||||
boolean fragmentVisible = true;
|
boolean fragmentVisible = true;
|
||||||
|
|
||||||
|
public OpenAPSMAFragment() {
|
||||||
|
super();
|
||||||
|
registerBus();
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getName() {
|
public String getName() {
|
||||||
return MainApp.instance().getString(R.string.openapsma);
|
return MainApp.instance().getString(R.string.openapsma);
|
||||||
|
@ -109,7 +117,6 @@ public class OpenAPSMAFragment extends Fragment implements View.OnClickListener,
|
||||||
@Override
|
@Override
|
||||||
public void onCreate(Bundle savedInstanceState) {
|
public void onCreate(Bundle savedInstanceState) {
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
registerBus();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -189,8 +196,8 @@ public class OpenAPSMAFragment extends Fragment implements View.OnClickListener,
|
||||||
}
|
}
|
||||||
|
|
||||||
DatabaseHelper.GlucoseStatus glucoseStatus = MainApp.getDbHelper().getGlucoseStatusData();
|
DatabaseHelper.GlucoseStatus glucoseStatus = MainApp.getDbHelper().getGlucoseStatusData();
|
||||||
NSProfile profile = MainApp.getNSProfile();
|
NSProfile profile = MainActivity.getConfigBuilder().getActiveProfile().getProfile();
|
||||||
Pump pump = MainApp.getActivePump();
|
PumpInterface pump = MainActivity.getConfigBuilder().getActivePump();
|
||||||
|
|
||||||
if (glucoseStatus == null) {
|
if (glucoseStatus == null) {
|
||||||
resultView.setText(getString(R.string.openapsma_noglucosedata));
|
resultView.setText(getString(R.string.openapsma_noglucosedata));
|
||||||
|
@ -227,14 +234,16 @@ public class OpenAPSMAFragment extends Fragment implements View.OnClickListener,
|
||||||
double minBg = NSProfile.toMgdl(Double.parseDouble(SP.getString("min_bg", minBgDefault).replace(",", ".")), units);
|
double minBg = NSProfile.toMgdl(Double.parseDouble(SP.getString("min_bg", minBgDefault).replace(",", ".")), units);
|
||||||
double maxBg = NSProfile.toMgdl(Double.parseDouble(SP.getString("max_bg", maxBgDefault).replace(",", ".")), units);
|
double maxBg = NSProfile.toMgdl(Double.parseDouble(SP.getString("max_bg", maxBgDefault).replace(",", ".")), units);
|
||||||
|
|
||||||
MainActivity.treatmentsFragment.updateTotalIOBIfNeeded();
|
TreatmentsInterface treatments = MainActivity.getConfigBuilder().getActiveTreatments();
|
||||||
MainActivity.tempBasalsFragment.updateTotalIOBIfNeeded();
|
TempBasalsInterface tempBasals = MainActivity.getConfigBuilder().getActiveTempBasals();
|
||||||
IobTotal bolusIob = MainActivity.treatmentsFragment.lastCalculation;
|
treatments.updateTotalIOBIfNeeded();
|
||||||
IobTotal basalIob = MainActivity.tempBasalsFragment.lastCalculation;
|
tempBasals.updateTotalIOBIfNeeded();
|
||||||
|
IobTotal bolusIob = treatments.getLastCalculation();
|
||||||
|
IobTotal basalIob = tempBasals.getLastCalculation();
|
||||||
|
|
||||||
IobTotal iobTotal = IobTotal.combine(bolusIob, basalIob);
|
IobTotal iobTotal = IobTotal.combine(bolusIob, basalIob);
|
||||||
|
|
||||||
TreatmentsFragment.MealData mealData = MainActivity.treatmentsFragment.getMealData();
|
TreatmentsFragment.MealData mealData = treatments.getMealData();
|
||||||
|
|
||||||
determineBasalAdapterJS.setData(profile, maxIob, maxBasal, minBg, maxBg, pump, iobTotal, glucoseStatus, mealData);
|
determineBasalAdapterJS.setData(profile, maxIob, maxBasal, minBg, maxBg, pump, iobTotal, glucoseStatus, mealData);
|
||||||
|
|
||||||
|
|
|
@ -26,13 +26,14 @@ import java.util.Iterator;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import info.nightscout.androidaps.Constants;
|
import info.nightscout.androidaps.Constants;
|
||||||
|
import info.nightscout.androidaps.MainActivity;
|
||||||
import info.nightscout.androidaps.MainApp;
|
import info.nightscout.androidaps.MainApp;
|
||||||
import info.nightscout.androidaps.R;
|
import info.nightscout.androidaps.R;
|
||||||
import info.nightscout.androidaps.db.BgReading;
|
import info.nightscout.androidaps.db.BgReading;
|
||||||
import info.nightscout.androidaps.db.DatabaseHelper;
|
import info.nightscout.androidaps.db.DatabaseHelper;
|
||||||
import info.nightscout.androidaps.events.EventNewBG;
|
import info.nightscout.androidaps.events.EventNewBG;
|
||||||
import info.nightscout.androidaps.events.EventTempBasalChange;
|
import info.nightscout.androidaps.events.EventTempBasalChange;
|
||||||
import info.nightscout.androidaps.plugins.PluginBase;
|
import info.nightscout.androidaps.interfaces.PluginBase;
|
||||||
import info.nightscout.client.data.NSProfile;
|
import info.nightscout.client.data.NSProfile;
|
||||||
|
|
||||||
|
|
||||||
|
@ -44,6 +45,11 @@ public class OverviewFragment extends Fragment implements PluginBase {
|
||||||
TextView deltaView;
|
TextView deltaView;
|
||||||
GraphView bgGraph;
|
GraphView bgGraph;
|
||||||
|
|
||||||
|
public OverviewFragment() {
|
||||||
|
super();
|
||||||
|
registerBus();
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getName() {
|
public String getName() {
|
||||||
return MainApp.instance().getString(R.string.overview);
|
return MainApp.instance().getString(R.string.overview);
|
||||||
|
@ -87,7 +93,6 @@ public class OverviewFragment extends Fragment implements PluginBase {
|
||||||
@Override
|
@Override
|
||||||
public void onCreate(Bundle savedInstanceState) {
|
public void onCreate(Bundle savedInstanceState) {
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
registerBus();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -112,10 +117,12 @@ public class OverviewFragment extends Fragment implements PluginBase {
|
||||||
MainApp.bus().register(this);
|
MainApp.bus().register(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void updateData() {
|
public void updateData() {
|
||||||
BgReading actualBG = MainApp.getDbHelper().actualBg();
|
BgReading actualBG = MainApp.getDbHelper().actualBg();
|
||||||
BgReading lastBG = MainApp.getDbHelper().lastBg();
|
BgReading lastBG = MainApp.getDbHelper().lastBg();
|
||||||
NSProfile profile = MainApp.getNSProfile();
|
if (MainActivity.getConfigBuilder() == null || MainActivity.getConfigBuilder().getActiveProfile() == null) // app not initialized yet
|
||||||
|
return;
|
||||||
|
NSProfile profile = MainActivity.getConfigBuilder().getActiveProfile().getProfile();
|
||||||
if (profile == null)
|
if (profile == null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,96 @@
|
||||||
|
package info.nightscout.androidaps.plugins.SimpleProfile;
|
||||||
|
|
||||||
|
|
||||||
|
import android.os.Bundle;
|
||||||
|
import android.support.v4.app.Fragment;
|
||||||
|
import android.view.LayoutInflater;
|
||||||
|
import android.view.View;
|
||||||
|
import android.view.ViewGroup;
|
||||||
|
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
|
import info.nightscout.androidaps.MainApp;
|
||||||
|
import info.nightscout.androidaps.R;
|
||||||
|
import info.nightscout.androidaps.interfaces.PluginBase;
|
||||||
|
import info.nightscout.androidaps.interfaces.ProfileInterface;
|
||||||
|
import info.nightscout.client.data.NSProfile;
|
||||||
|
|
||||||
|
public class SimpleProfileFragment extends Fragment implements PluginBase, ProfileInterface {
|
||||||
|
private static Logger log = LoggerFactory.getLogger(SimpleProfileFragment.class);
|
||||||
|
|
||||||
|
boolean fragmentEnabled = true;
|
||||||
|
boolean fragmentVisible = true;
|
||||||
|
|
||||||
|
public SimpleProfileFragment() {
|
||||||
|
super();
|
||||||
|
registerBus();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getType() {
|
||||||
|
return PluginBase.PROFILE;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getName() {
|
||||||
|
return MainApp.instance().getString(R.string.simpleprofile);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isEnabled() {
|
||||||
|
return fragmentEnabled;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isVisibleInTabs() {
|
||||||
|
return fragmentVisible;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean canBeHidden() {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setFragmentEnabled(boolean fragmentEnabled) {
|
||||||
|
this.fragmentEnabled = fragmentEnabled;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setFragmentVisible(boolean fragmentVisible) {
|
||||||
|
this.fragmentVisible = fragmentVisible;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onCreate(Bundle savedInstanceState) {
|
||||||
|
super.onCreate(savedInstanceState);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public View onCreateView(LayoutInflater inflater, ViewGroup container,
|
||||||
|
Bundle savedInstanceState) {
|
||||||
|
View layout = inflater.inflate(R.layout.simpleprofile_fragment, container, false);
|
||||||
|
|
||||||
|
return layout;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static SimpleProfileFragment newInstance() {
|
||||||
|
SimpleProfileFragment fragment = new SimpleProfileFragment();
|
||||||
|
return fragment;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void registerBus() {
|
||||||
|
try {
|
||||||
|
MainApp.bus().unregister(this);
|
||||||
|
} catch (RuntimeException x) {
|
||||||
|
// Ignore
|
||||||
|
}
|
||||||
|
MainApp.bus().register(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public NSProfile getProfile() {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
|
@ -32,11 +32,12 @@ import info.nightscout.androidaps.R;
|
||||||
import info.nightscout.androidaps.db.TempBasal;
|
import info.nightscout.androidaps.db.TempBasal;
|
||||||
import info.nightscout.androidaps.events.EventNewBG;
|
import info.nightscout.androidaps.events.EventNewBG;
|
||||||
import info.nightscout.androidaps.events.EventTempBasalChange;
|
import info.nightscout.androidaps.events.EventTempBasalChange;
|
||||||
|
import info.nightscout.androidaps.interfaces.TempBasalsInterface;
|
||||||
import info.nightscout.androidaps.plugins.OpenAPSMA.IobTotal;
|
import info.nightscout.androidaps.plugins.OpenAPSMA.IobTotal;
|
||||||
import info.nightscout.androidaps.plugins.PluginBase;
|
import info.nightscout.androidaps.interfaces.PluginBase;
|
||||||
|
|
||||||
|
|
||||||
public class TempBasalsFragment extends Fragment implements PluginBase {
|
public class TempBasalsFragment extends Fragment implements PluginBase, TempBasalsInterface {
|
||||||
private static Logger log = LoggerFactory.getLogger(TempBasalsFragment.class);
|
private static Logger log = LoggerFactory.getLogger(TempBasalsFragment.class);
|
||||||
|
|
||||||
RecyclerView recyclerView;
|
RecyclerView recyclerView;
|
||||||
|
@ -118,7 +119,6 @@ public class TempBasalsFragment extends Fragment implements PluginBase {
|
||||||
if (recyclerView != null) {
|
if (recyclerView != null) {
|
||||||
recyclerView.swapAdapter(new RecyclerViewAdapter(tempBasals), false);
|
recyclerView.swapAdapter(new RecyclerViewAdapter(tempBasals), false);
|
||||||
}
|
}
|
||||||
updateTotalIOB();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -130,6 +130,11 @@ public class TempBasalsFragment extends Fragment implements PluginBase {
|
||||||
updateTotalIOB();
|
updateTotalIOB();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public IobTotal getLastCalculation() {
|
||||||
|
return lastCalculation;
|
||||||
|
}
|
||||||
|
|
||||||
private void updateTotalIOB() {
|
private void updateTotalIOB() {
|
||||||
Date now = new Date();
|
Date now = new Date();
|
||||||
IobTotal total = new IobTotal();
|
IobTotal total = new IobTotal();
|
||||||
|
@ -223,6 +228,7 @@ public class TempBasalsFragment extends Fragment implements PluginBase {
|
||||||
|
|
||||||
public TempBasalsFragment() {
|
public TempBasalsFragment() {
|
||||||
super();
|
super();
|
||||||
|
registerBus();
|
||||||
initializeData();
|
initializeData();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -234,7 +240,6 @@ public class TempBasalsFragment extends Fragment implements PluginBase {
|
||||||
@Override
|
@Override
|
||||||
public void onCreate(Bundle savedInstanceState) {
|
public void onCreate(Bundle savedInstanceState) {
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
registerBus();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -10,31 +10,16 @@ import android.view.View.OnClickListener;
|
||||||
import android.widget.Button;
|
import android.widget.Button;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
|
||||||
|
import info.nightscout.androidaps.MainActivity;
|
||||||
import info.nightscout.androidaps.MainApp;
|
import info.nightscout.androidaps.MainApp;
|
||||||
import info.nightscout.androidaps.R;
|
import info.nightscout.androidaps.R;
|
||||||
|
|
||||||
public class NewTreatmentDialogFragment extends DialogFragment implements OnClickListener {
|
public class NewTreatmentDialogFragment extends DialogFragment implements OnClickListener {
|
||||||
|
|
||||||
Button deliverButton;
|
Button deliverButton;
|
||||||
Communicator communicator;
|
|
||||||
TextView insulin;
|
TextView insulin;
|
||||||
TextView carbs;
|
TextView carbs;
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onAttach(Activity activity) {
|
|
||||||
|
|
||||||
super.onAttach(activity);
|
|
||||||
|
|
||||||
if (activity instanceof Communicator) {
|
|
||||||
communicator = (Communicator) getActivity();
|
|
||||||
|
|
||||||
} else {
|
|
||||||
throw new ClassCastException(activity.toString()
|
|
||||||
+ " must implemenet NewTreatmentDialogFragment.Communicator");
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public View onCreateView(LayoutInflater inflater, ViewGroup container,
|
public View onCreateView(LayoutInflater inflater, ViewGroup container,
|
||||||
Bundle savedInstanceState) {
|
Bundle savedInstanceState) {
|
||||||
|
@ -70,15 +55,11 @@ public class NewTreatmentDialogFragment extends DialogFragment implements OnClic
|
||||||
this.carbs.setText("");
|
this.carbs.setText("");
|
||||||
} else if (insulin > 0d || carbs > 0d) {
|
} else if (insulin > 0d || carbs > 0d) {
|
||||||
dismiss();
|
dismiss();
|
||||||
communicator.treatmentDeliverRequest(insulin, carbs);
|
MainActivity.getConfigBuilder().getActivePump().deliverTreatment(insulin, carbs);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public interface Communicator {
|
|
||||||
void treatmentDeliverRequest(Double insulin, Double carbs);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
|
@ -24,6 +24,8 @@ import info.nightscout.androidaps.R;
|
||||||
import info.nightscout.androidaps.data.Iob;
|
import info.nightscout.androidaps.data.Iob;
|
||||||
import info.nightscout.androidaps.db.BgReading;
|
import info.nightscout.androidaps.db.BgReading;
|
||||||
import info.nightscout.androidaps.db.Treatment;
|
import info.nightscout.androidaps.db.Treatment;
|
||||||
|
import info.nightscout.androidaps.interfaces.TempBasalsInterface;
|
||||||
|
import info.nightscout.androidaps.interfaces.TreatmentsInterface;
|
||||||
import info.nightscout.androidaps.plugins.OpenAPSMA.IobTotal;
|
import info.nightscout.androidaps.plugins.OpenAPSMA.IobTotal;
|
||||||
import info.nightscout.androidaps.plugins.Treatments.TreatmentsFragment;
|
import info.nightscout.androidaps.plugins.Treatments.TreatmentsFragment;
|
||||||
import info.nightscout.client.data.NSProfile;
|
import info.nightscout.client.data.NSProfile;
|
||||||
|
@ -32,7 +34,6 @@ import info.nightscout.utils.*;
|
||||||
public class WizardDialogFragment extends DialogFragment implements OnClickListener {
|
public class WizardDialogFragment extends DialogFragment implements OnClickListener {
|
||||||
|
|
||||||
Button wizardDialogDeliverButton;
|
Button wizardDialogDeliverButton;
|
||||||
Communicator communicator;
|
|
||||||
TextView correctionInput;
|
TextView correctionInput;
|
||||||
TextView carbsInput;
|
TextView carbsInput;
|
||||||
TextView bgInput;
|
TextView bgInput;
|
||||||
|
@ -70,21 +71,6 @@ public class WizardDialogFragment extends DialogFragment implements OnClickListe
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onAttach(Activity activity) {
|
|
||||||
|
|
||||||
super.onAttach(activity);
|
|
||||||
|
|
||||||
if (activity instanceof Communicator) {
|
|
||||||
communicator = (Communicator) getActivity();
|
|
||||||
|
|
||||||
} else {
|
|
||||||
throw new ClassCastException(activity.toString()
|
|
||||||
+ " must implemenet WizardDialogFragment.Communicator");
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public View onCreateView(LayoutInflater inflater, ViewGroup container,
|
public View onCreateView(LayoutInflater inflater, ViewGroup container,
|
||||||
Bundle savedInstanceState) {
|
Bundle savedInstanceState) {
|
||||||
|
@ -129,7 +115,7 @@ public class WizardDialogFragment extends DialogFragment implements OnClickListe
|
||||||
case R.id.treatments_wizard_deliverButton:
|
case R.id.treatments_wizard_deliverButton:
|
||||||
if (calculatedTotalInsulin > 0d || calculatedCarbs > 0d){
|
if (calculatedTotalInsulin > 0d || calculatedCarbs > 0d){
|
||||||
dismiss();
|
dismiss();
|
||||||
communicator.treatmentDialogDeliver(calculatedTotalInsulin, calculatedCarbs);
|
MainActivity.getConfigBuilder().getActivePump().deliverTreatment(calculatedTotalInsulin, calculatedCarbs);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -139,8 +125,9 @@ public class WizardDialogFragment extends DialogFragment implements OnClickListe
|
||||||
private void initDialog() {
|
private void initDialog() {
|
||||||
SharedPreferences SP = PreferenceManager.getDefaultSharedPreferences(MainApp.instance().getApplicationContext());
|
SharedPreferences SP = PreferenceManager.getDefaultSharedPreferences(MainApp.instance().getApplicationContext());
|
||||||
String units = SP.getString("ns_units", Constants.MGDL);
|
String units = SP.getString("ns_units", Constants.MGDL);
|
||||||
|
NSProfile profile = MainActivity.getConfigBuilder().getActiveProfile().getProfile();
|
||||||
|
|
||||||
if (MainApp.getNSProfile() == null) {
|
if (profile == null) {
|
||||||
ToastUtils.showToastInUiThread(MainApp.instance().getApplicationContext(), "No profile loaded from NS yet");
|
ToastUtils.showToastInUiThread(MainApp.instance().getApplicationContext(), "No profile loaded from NS yet");
|
||||||
dismiss();
|
dismiss();
|
||||||
return;
|
return;
|
||||||
|
@ -153,9 +140,9 @@ public class WizardDialogFragment extends DialogFragment implements OnClickListe
|
||||||
Double lastBgValue = lastBg.valueToUnits(units);
|
Double lastBgValue = lastBg.valueToUnits(units);
|
||||||
|
|
||||||
if (lastBg != null) {
|
if (lastBg != null) {
|
||||||
Double sens = MainApp.getNSProfile().getIsf(MainApp.getNSProfile().secondsFromMidnight());
|
Double sens = profile.getIsf(NSProfile.secondsFromMidnight());
|
||||||
Double targetBGLow = MainApp.getNSProfile().getTargetLow(MainApp.getNSProfile().secondsFromMidnight());
|
Double targetBGLow = profile.getTargetLow(NSProfile.secondsFromMidnight());
|
||||||
Double targetBGHigh = MainApp.getNSProfile().getTargetHigh(MainApp.getNSProfile().secondsFromMidnight());
|
Double targetBGHigh = profile.getTargetHigh(NSProfile.secondsFromMidnight());
|
||||||
Double bgDiff;
|
Double bgDiff;
|
||||||
if (lastBgValue <= targetBGLow) {
|
if (lastBgValue <= targetBGLow) {
|
||||||
bgDiff = lastBgValue - targetBGLow;
|
bgDiff = lastBgValue - targetBGLow;
|
||||||
|
@ -173,11 +160,13 @@ public class WizardDialogFragment extends DialogFragment implements OnClickListe
|
||||||
}
|
}
|
||||||
|
|
||||||
// IOB calculation
|
// IOB calculation
|
||||||
MainActivity.treatmentsFragment.updateTotalIOBIfNeeded();
|
TreatmentsInterface treatments = MainActivity.getConfigBuilder().getActiveTreatments();
|
||||||
MainActivity.tempBasalsFragment.updateTotalIOBIfNeeded();
|
TempBasalsInterface tempBasals = MainActivity.getConfigBuilder().getActiveTempBasals();
|
||||||
|
treatments.updateTotalIOBIfNeeded();
|
||||||
|
tempBasals.updateTotalIOBIfNeeded();
|
||||||
|
IobTotal bolusIob = treatments.getLastCalculation();
|
||||||
|
IobTotal basalIob = tempBasals.getLastCalculation();
|
||||||
|
|
||||||
IobTotal bolusIob = MainActivity.treatmentsFragment.lastCalculation;
|
|
||||||
IobTotal basalIob = MainActivity.tempBasalsFragment.lastCalculation;
|
|
||||||
Double iobTotal = bolusIob.iob + basalIob.iob;
|
Double iobTotal = bolusIob.iob + basalIob.iob;
|
||||||
iobInsulin.setText("-" + numberFormat.format(iobTotal) + "U");
|
iobInsulin.setText("-" + numberFormat.format(iobTotal) + "U");
|
||||||
|
|
||||||
|
@ -192,7 +181,7 @@ public class WizardDialogFragment extends DialogFragment implements OnClickListe
|
||||||
Double maxcarbs = Double.parseDouble(SP.getString("safety_maxcarbs", "48"));
|
Double maxcarbs = Double.parseDouble(SP.getString("safety_maxcarbs", "48"));
|
||||||
String units = SP.getString("ns_units", Constants.MGDL);
|
String units = SP.getString("ns_units", Constants.MGDL);
|
||||||
|
|
||||||
NSProfile profile = MainApp.instance().getNSProfile();
|
NSProfile profile = MainActivity.getConfigBuilder().getActiveProfile().getProfile();
|
||||||
|
|
||||||
// Entered values
|
// Entered values
|
||||||
String i_bg = this.bgInput.getText().toString().replace("," , ".");
|
String i_bg = this.bgInput.getText().toString().replace("," , ".");
|
||||||
|
@ -218,9 +207,9 @@ public class WizardDialogFragment extends DialogFragment implements OnClickListe
|
||||||
|
|
||||||
|
|
||||||
// Insulin from BG
|
// Insulin from BG
|
||||||
Double sens = profile.getIsf(MainApp.getNSProfile().secondsFromMidnight());
|
Double sens = profile.getIsf(NSProfile.secondsFromMidnight());
|
||||||
Double targetBGLow = profile.getTargetLow(MainApp.getNSProfile().secondsFromMidnight());
|
Double targetBGLow = profile.getTargetLow(NSProfile.secondsFromMidnight());
|
||||||
Double targetBGHigh = profile.getTargetHigh(MainApp.getNSProfile().secondsFromMidnight());
|
Double targetBGHigh = profile.getTargetHigh(NSProfile.secondsFromMidnight());
|
||||||
Double bgDiff;
|
Double bgDiff;
|
||||||
if (c_bg <= targetBGLow) {
|
if (c_bg <= targetBGLow) {
|
||||||
bgDiff = c_bg - targetBGLow;
|
bgDiff = c_bg - targetBGLow;
|
||||||
|
@ -232,17 +221,19 @@ public class WizardDialogFragment extends DialogFragment implements OnClickListe
|
||||||
bgInsulin.setText(numberFormat.format(insulinFromBG) + "U");
|
bgInsulin.setText(numberFormat.format(insulinFromBG) + "U");
|
||||||
|
|
||||||
// Insuling from carbs
|
// Insuling from carbs
|
||||||
Double ic = profile.getIc(MainApp.getNSProfile().secondsFromMidnight());
|
Double ic = profile.getIc(NSProfile.secondsFromMidnight());
|
||||||
Double insulinFromCarbs = c_carbs / ic;
|
Double insulinFromCarbs = c_carbs / ic;
|
||||||
carbs.setText(intFormat.format(c_carbs) + "g IC: " + intFormat.format(ic));
|
carbs.setText(intFormat.format(c_carbs) + "g IC: " + intFormat.format(ic));
|
||||||
carbsInsulin.setText(numberFormat.format(insulinFromCarbs) + "U");
|
carbsInsulin.setText(numberFormat.format(insulinFromCarbs) + "U");
|
||||||
|
|
||||||
// Insulin from IOB
|
// Insulin from IOB
|
||||||
MainActivity.treatmentsFragment.updateTotalIOBIfNeeded();
|
TreatmentsInterface treatments = MainActivity.getConfigBuilder().getActiveTreatments();
|
||||||
MainActivity.tempBasalsFragment.updateTotalIOBIfNeeded();
|
TempBasalsInterface tempBasals = MainActivity.getConfigBuilder().getActiveTempBasals();
|
||||||
|
treatments.updateTotalIOBIfNeeded();
|
||||||
|
tempBasals.updateTotalIOBIfNeeded();
|
||||||
|
IobTotal bolusIob = treatments.getLastCalculation();
|
||||||
|
IobTotal basalIob = tempBasals.getLastCalculation();
|
||||||
|
|
||||||
IobTotal bolusIob = MainActivity.treatmentsFragment.lastCalculation;
|
|
||||||
IobTotal basalIob = MainActivity.tempBasalsFragment.lastCalculation;
|
|
||||||
Double iobTotal = bolusIob.iob + basalIob.iob;
|
Double iobTotal = bolusIob.iob + basalIob.iob;
|
||||||
Double insulingFromIOB = iobCheckbox.isChecked() ? iobTotal : 0d;
|
Double insulingFromIOB = iobCheckbox.isChecked() ? iobTotal : 0d;
|
||||||
iobInsulin.setText("-" + numberFormat.format(insulingFromIOB) + "U");
|
iobInsulin.setText("-" + numberFormat.format(insulingFromIOB) + "U");
|
||||||
|
@ -288,9 +279,4 @@ public class WizardDialogFragment extends DialogFragment implements OnClickListe
|
||||||
}
|
}
|
||||||
return 0d;
|
return 0d;
|
||||||
}
|
}
|
||||||
|
|
||||||
public interface Communicator {
|
|
||||||
void treatmentDialogDeliver(Double insulin, Double carbs);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
|
@ -31,19 +31,20 @@ import java.util.Date;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
|
|
||||||
|
import info.nightscout.androidaps.MainActivity;
|
||||||
import info.nightscout.androidaps.MainApp;
|
import info.nightscout.androidaps.MainApp;
|
||||||
import info.nightscout.androidaps.R;
|
import info.nightscout.androidaps.R;
|
||||||
import info.nightscout.androidaps.data.Iob;
|
import info.nightscout.androidaps.data.Iob;
|
||||||
import info.nightscout.androidaps.db.Treatment;
|
import info.nightscout.androidaps.db.Treatment;
|
||||||
import info.nightscout.androidaps.events.EventNewBG;
|
import info.nightscout.androidaps.events.EventNewBG;
|
||||||
import info.nightscout.androidaps.events.EventTreatmentChange;
|
import info.nightscout.androidaps.events.EventTreatmentChange;
|
||||||
|
import info.nightscout.androidaps.interfaces.TreatmentsInterface;
|
||||||
import info.nightscout.androidaps.plugins.OpenAPSMA.IobTotal;
|
import info.nightscout.androidaps.plugins.OpenAPSMA.IobTotal;
|
||||||
import info.nightscout.androidaps.plugins.PluginBase;
|
import info.nightscout.androidaps.interfaces.PluginBase;
|
||||||
import info.nightscout.androidaps.plugins.Treatments.Dialogs.NewTreatmentDialogFragment;
|
|
||||||
import info.nightscout.androidaps.Services.Intents;
|
import info.nightscout.androidaps.Services.Intents;
|
||||||
import info.nightscout.client.data.NSProfile;
|
import info.nightscout.client.data.NSProfile;
|
||||||
|
|
||||||
public class TreatmentsFragment extends Fragment implements View.OnClickListener, NewTreatmentDialogFragment.Communicator, PluginBase {
|
public class TreatmentsFragment extends Fragment implements View.OnClickListener, PluginBase, TreatmentsInterface {
|
||||||
private static Logger log = LoggerFactory.getLogger(TreatmentsFragment.class);
|
private static Logger log = LoggerFactory.getLogger(TreatmentsFragment.class);
|
||||||
|
|
||||||
RecyclerView recyclerView;
|
RecyclerView recyclerView;
|
||||||
|
@ -53,8 +54,8 @@ public class TreatmentsFragment extends Fragment implements View.OnClickListener
|
||||||
TextView activityTotal;
|
TextView activityTotal;
|
||||||
Button refreshFromNS;
|
Button refreshFromNS;
|
||||||
|
|
||||||
public long lastCalculationTimestamp = 0;
|
private long lastCalculationTimestamp = 0;
|
||||||
public IobTotal lastCalculation;
|
private IobTotal lastCalculation;
|
||||||
|
|
||||||
private static DecimalFormat formatNumber0decimalplaces = new DecimalFormat("0");
|
private static DecimalFormat formatNumber0decimalplaces = new DecimalFormat("0");
|
||||||
private static DecimalFormat formatNumber2decimalplaces = new DecimalFormat("0.00");
|
private static DecimalFormat formatNumber2decimalplaces = new DecimalFormat("0.00");
|
||||||
|
@ -115,22 +116,29 @@ public class TreatmentsFragment extends Fragment implements View.OnClickListener
|
||||||
if (recyclerView != null) {
|
if (recyclerView != null) {
|
||||||
recyclerView.swapAdapter(new RecyclerViewAdapter(treatments), false);
|
recyclerView.swapAdapter(new RecyclerViewAdapter(treatments), false);
|
||||||
}
|
}
|
||||||
updateTotalIOB();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Recalculate IOB if value is older than 1 minute
|
* Recalculate IOB if value is older than 1 minute
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public void updateTotalIOBIfNeeded() {
|
public void updateTotalIOBIfNeeded() {
|
||||||
if (lastCalculationTimestamp > new Date().getTime() - 60 * 1000)
|
if (lastCalculationTimestamp > new Date().getTime() - 60 * 1000)
|
||||||
return;
|
return;
|
||||||
updateTotalIOB();
|
updateTotalIOB();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public IobTotal getLastCalculation() {
|
||||||
|
return lastCalculation;
|
||||||
|
}
|
||||||
|
|
||||||
private void updateTotalIOB() {
|
private void updateTotalIOB() {
|
||||||
IobTotal total = new IobTotal();
|
IobTotal total = new IobTotal();
|
||||||
|
|
||||||
NSProfile profile = MainApp.getNSProfile();
|
if (MainActivity.getConfigBuilder() == null || MainActivity.getConfigBuilder().getActiveProfile() == null) // app not initialized yet
|
||||||
|
return;
|
||||||
|
NSProfile profile = MainActivity.getConfigBuilder().getActiveProfile().getProfile();
|
||||||
if (profile == null) {
|
if (profile == null) {
|
||||||
lastCalculation = total;
|
lastCalculation = total;
|
||||||
return;
|
return;
|
||||||
|
@ -161,9 +169,10 @@ public class TreatmentsFragment extends Fragment implements View.OnClickListener
|
||||||
public double carbs = 0d;
|
public double carbs = 0d;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public MealData getMealData() {
|
public MealData getMealData() {
|
||||||
MealData result = new MealData();
|
MealData result = new MealData();
|
||||||
NSProfile profile = MainApp.getNSProfile();
|
NSProfile profile = MainActivity.getConfigBuilder().getActiveProfile().getProfile();
|
||||||
if (profile == null)
|
if (profile == null)
|
||||||
return result;
|
return result;
|
||||||
|
|
||||||
|
@ -200,7 +209,9 @@ public class TreatmentsFragment extends Fragment implements View.OnClickListener
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onBindViewHolder(TreatmentsViewHolder holder, int position) {
|
public void onBindViewHolder(TreatmentsViewHolder holder, int position) {
|
||||||
NSProfile profile = MainApp.getNSProfile();
|
if (MainActivity.getConfigBuilder() == null || MainActivity.getConfigBuilder().getActiveProfile() == null) // app not initialized yet
|
||||||
|
return;
|
||||||
|
NSProfile profile = MainActivity.getConfigBuilder().getActiveProfile().getProfile();
|
||||||
if (profile == null)
|
if (profile == null)
|
||||||
return;
|
return;
|
||||||
// TODO: implement locales
|
// TODO: implement locales
|
||||||
|
@ -245,6 +256,7 @@ public class TreatmentsFragment extends Fragment implements View.OnClickListener
|
||||||
|
|
||||||
public TreatmentsFragment() {
|
public TreatmentsFragment() {
|
||||||
super();
|
super();
|
||||||
|
registerBus();
|
||||||
initializeData();
|
initializeData();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -256,7 +268,6 @@ public class TreatmentsFragment extends Fragment implements View.OnClickListener
|
||||||
@Override
|
@Override
|
||||||
public void onCreate(Bundle savedInstanceState) {
|
public void onCreate(Bundle savedInstanceState) {
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
registerBus();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -348,10 +359,4 @@ public class TreatmentsFragment extends Fragment implements View.OnClickListener
|
||||||
if (isVisibleToUser)
|
if (isVisibleToUser)
|
||||||
updateTotalIOBIfNeeded();
|
updateTotalIOBIfNeeded();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void treatmentDeliverRequest(Double insulin, Double carbs) {
|
|
||||||
// TODO: implement treatment delivery
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,17 +20,18 @@ import java.text.SimpleDateFormat;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
|
|
||||||
import info.nightscout.androidaps.Config;
|
import info.nightscout.androidaps.Config;
|
||||||
|
import info.nightscout.androidaps.MainActivity;
|
||||||
import info.nightscout.androidaps.MainApp;
|
import info.nightscout.androidaps.MainApp;
|
||||||
import info.nightscout.androidaps.R;
|
import info.nightscout.androidaps.R;
|
||||||
import info.nightscout.androidaps.plugins.Pump;
|
import info.nightscout.androidaps.interfaces.PumpInterface;
|
||||||
import info.nightscout.androidaps.data.Result;
|
import info.nightscout.androidaps.data.Result;
|
||||||
import info.nightscout.androidaps.db.TempBasal;
|
import info.nightscout.androidaps.db.TempBasal;
|
||||||
import info.nightscout.androidaps.db.Treatment;
|
import info.nightscout.androidaps.db.Treatment;
|
||||||
import info.nightscout.androidaps.plugins.PluginBase;
|
import info.nightscout.androidaps.interfaces.PluginBase;
|
||||||
import info.nightscout.client.data.NSProfile;
|
import info.nightscout.client.data.NSProfile;
|
||||||
import info.nightscout.utils.DateUtil;
|
import info.nightscout.utils.DateUtil;
|
||||||
|
|
||||||
public class VirtualPumpFragment extends Fragment implements PluginBase, Pump {
|
public class VirtualPumpFragment extends Fragment implements PluginBase, PumpInterface {
|
||||||
private static Logger log = LoggerFactory.getLogger(VirtualPumpFragment.class);
|
private static Logger log = LoggerFactory.getLogger(VirtualPumpFragment.class);
|
||||||
|
|
||||||
Double defaultBasalValue = 0.2d;
|
Double defaultBasalValue = 0.2d;
|
||||||
|
@ -102,7 +103,7 @@ public class VirtualPumpFragment extends Fragment implements PluginBase, Pump {
|
||||||
extendedBolusView = (TextView) view.findViewById(R.id.virtualpump_extendedbolus);
|
extendedBolusView = (TextView) view.findViewById(R.id.virtualpump_extendedbolus);
|
||||||
batteryView = (TextView) view.findViewById(R.id.virtualpump_battery);
|
batteryView = (TextView) view.findViewById(R.id.virtualpump_battery);
|
||||||
reservoirView = (TextView) view.findViewById(R.id.virtualpump_reservoir);
|
reservoirView = (TextView) view.findViewById(R.id.virtualpump_reservoir);
|
||||||
updateView();
|
|
||||||
return view;
|
return view;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -137,6 +138,14 @@ public class VirtualPumpFragment extends Fragment implements PluginBase, Pump {
|
||||||
reservoirView.setText(getReservoirValue() + "U");
|
reservoirView.setText(getReservoirValue() + "U");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setUserVisibleHint(boolean isVisibleToUser) {
|
||||||
|
super.setUserVisibleHint(isVisibleToUser);
|
||||||
|
|
||||||
|
if (isVisibleToUser)
|
||||||
|
updateView();
|
||||||
|
}
|
||||||
|
|
||||||
void checkForExpiredTempsAndExtended() {
|
void checkForExpiredTempsAndExtended() {
|
||||||
long now = new Date().getTime();
|
long now = new Date().getTime();
|
||||||
if (isTempBasalInProgress()) {
|
if (isTempBasalInProgress()) {
|
||||||
|
@ -193,12 +202,12 @@ public class VirtualPumpFragment extends Fragment implements PluginBase, Pump {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setNewBasalProfile(NSProfile profile) {
|
public void setNewBasalProfile(NSProfile profile) {
|
||||||
// Do nothing here. we are using MainApp.getNSProfile();
|
// Do nothing here. we are using MainActivity.getConfigBuilder().getActiveProfile().getProfile();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public double getBaseBasalRate() {
|
public double getBaseBasalRate() {
|
||||||
NSProfile profile = MainApp.getNSProfile();
|
NSProfile profile = MainActivity.getConfigBuilder().getActiveProfile().getProfile();
|
||||||
if (profile == null)
|
if (profile == null)
|
||||||
return defaultBasalValue;
|
return defaultBasalValue;
|
||||||
return profile.getBasal(profile.secondsFromMidnight());
|
return profile.getBasal(profile.secondsFromMidnight());
|
||||||
|
@ -211,7 +220,7 @@ public class VirtualPumpFragment extends Fragment implements PluginBase, Pump {
|
||||||
if (tempBasal.isAbsolute) {
|
if (tempBasal.isAbsolute) {
|
||||||
return tempBasal.absolute;
|
return tempBasal.absolute;
|
||||||
} else {
|
} else {
|
||||||
NSProfile profile = MainApp.getNSProfile();
|
NSProfile profile = MainActivity.getConfigBuilder().getActiveProfile().getProfile();
|
||||||
if (profile == null)
|
if (profile == null)
|
||||||
return defaultBasalValue;
|
return defaultBasalValue;
|
||||||
Double baseRate = profile.getBasal(profile.secondsFromMidnight());
|
Double baseRate = profile.getBasal(profile.secondsFromMidnight());
|
||||||
|
@ -247,6 +256,7 @@ public class VirtualPumpFragment extends Fragment implements PluginBase, Pump {
|
||||||
}
|
}
|
||||||
if (Config.logPumpComm)
|
if (Config.logPumpComm)
|
||||||
log.debug("Delivering treatment: " + t + " " + result);
|
log.debug("Delivering treatment: " + t + " " + result);
|
||||||
|
updateView();
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -272,6 +282,7 @@ public class VirtualPumpFragment extends Fragment implements PluginBase, Pump {
|
||||||
}
|
}
|
||||||
if (Config.logPumpComm)
|
if (Config.logPumpComm)
|
||||||
log.debug("Setting temp basal absolute: " + result);
|
log.debug("Setting temp basal absolute: " + result);
|
||||||
|
updateView();
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -297,6 +308,7 @@ public class VirtualPumpFragment extends Fragment implements PluginBase, Pump {
|
||||||
}
|
}
|
||||||
if (Config.logPumpComm)
|
if (Config.logPumpComm)
|
||||||
log.debug("Settings temp basal percent: " + result);
|
log.debug("Settings temp basal percent: " + result);
|
||||||
|
updateView();
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -322,6 +334,7 @@ public class VirtualPumpFragment extends Fragment implements PluginBase, Pump {
|
||||||
}
|
}
|
||||||
if (Config.logPumpComm)
|
if (Config.logPumpComm)
|
||||||
log.debug("Setting extended bolus: " + result);
|
log.debug("Setting extended bolus: " + result);
|
||||||
|
updateView();
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -344,6 +357,7 @@ public class VirtualPumpFragment extends Fragment implements PluginBase, Pump {
|
||||||
tempBasal = null;
|
tempBasal = null;
|
||||||
if (Config.logPumpComm)
|
if (Config.logPumpComm)
|
||||||
log.debug("Canceling temp basal: " + result);
|
log.debug("Canceling temp basal: " + result);
|
||||||
|
updateView();
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -366,6 +380,7 @@ public class VirtualPumpFragment extends Fragment implements PluginBase, Pump {
|
||||||
extendedBolus = null;
|
extendedBolus = null;
|
||||||
if (Config.logPumpComm)
|
if (Config.logPumpComm)
|
||||||
log.debug("Canceling extended basal: " + result);
|
log.debug("Canceling extended basal: " + result);
|
||||||
|
updateView();
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -8,7 +8,7 @@ import android.support.v4.app.FragmentStatePagerAdapter;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
|
|
||||||
import info.nightscout.androidaps.plugins.PluginBase;
|
import info.nightscout.androidaps.interfaces.PluginBase;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by mike on 30.05.2016.
|
* Created by mike on 30.05.2016.
|
||||||
|
@ -50,20 +50,4 @@ public class TabPageAdapter extends FragmentStatePagerAdapter {
|
||||||
notifyDataSetChanged();
|
notifyDataSetChanged();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public ArrayList<PluginBase> getPluginsList() {
|
|
||||||
return fragmentList;
|
|
||||||
}
|
|
||||||
|
|
||||||
public ArrayList<PluginBase> getSpecificPluginsList(int type) {
|
|
||||||
ArrayList<PluginBase> newList = new ArrayList<PluginBase>();
|
|
||||||
|
|
||||||
Iterator<PluginBase> it = fragmentList.iterator();
|
|
||||||
while (it.hasNext()) {
|
|
||||||
PluginBase p = it.next();
|
|
||||||
if (p.getType() == type)
|
|
||||||
newList.add(p);
|
|
||||||
}
|
|
||||||
return newList;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -167,7 +167,7 @@ public class NSProfile {
|
||||||
JSONObject profile = getDefaultProfile();
|
JSONObject profile = getDefaultProfile();
|
||||||
if (profile != null) {
|
if (profile != null) {
|
||||||
try {
|
try {
|
||||||
return getValuesList(profile.getJSONArray("sens"), null, new DecimalFormat("0"), getUnits() + "/U");
|
return getValuesList(profile.getJSONArray("sens"), null, new DecimalFormat("0.0"), getUnits() + "/U");
|
||||||
} catch (JSONException e) {
|
} catch (JSONException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,8 +4,6 @@
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
tools:context="info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderFragment">
|
tools:context="info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderFragment">
|
||||||
|
|
||||||
<!-- TODO: Update blank fragment layout -->
|
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
|
@ -22,8 +20,8 @@
|
||||||
android:id="@+id/configbuilder_pumplistview"
|
android:id="@+id/configbuilder_pumplistview"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_marginRight="10dp"
|
|
||||||
android:layout_marginLeft="10dp"
|
android:layout_marginLeft="10dp"
|
||||||
|
android:layout_marginRight="10dp"
|
||||||
android:background="@color/cardColorBackground" />
|
android:background="@color/cardColorBackground" />
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
|
|
|
@ -4,6 +4,10 @@
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
tools:context="info.nightscout.androidaps.plugins.LowSuspend.LowSuspendFragment">
|
tools:context="info.nightscout.androidaps.plugins.LowSuspend.LowSuspendFragment">
|
||||||
|
|
||||||
|
<ScrollView
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent">
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
|
@ -123,5 +127,5 @@
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
</ScrollView>
|
||||||
</FrameLayout>
|
</FrameLayout>
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
xmlns:tools="http://schemas.android.com/tools"
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
tools:context=".plugins.ProfileViewer.ProfileViewerFragment">
|
tools:context=".plugins.NSProfileViewer.NSProfileViewerFragment">
|
||||||
|
|
||||||
<ScrollView
|
<ScrollView
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
|
@ -17,7 +17,7 @@
|
||||||
android:id="@+id/profileview_noprofile"
|
android:id="@+id/profileview_noprofile"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:text="@string/profileview_noprofile_text"
|
android:text="@string/nsprofileview_noprofile_text"
|
||||||
android:textAppearance="?android:attr/textAppearanceLarge"
|
android:textAppearance="?android:attr/textAppearanceLarge"
|
||||||
android:textColor="@android:color/holo_red_light"
|
android:textColor="@android:color/holo_red_light"
|
||||||
android:textStyle="bold"
|
android:textStyle="bold"
|
||||||
|
@ -26,7 +26,7 @@
|
||||||
<TextView
|
<TextView
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:text="@string/profileview_activeprofile_label"
|
android:text="@string/nsprofileview_activeprofile_label"
|
||||||
android:textAppearance="?android:attr/textAppearanceLarge"
|
android:textAppearance="?android:attr/textAppearanceLarge"
|
||||||
android:layout_marginLeft="10dp" />
|
android:layout_marginLeft="10dp" />
|
||||||
|
|
||||||
|
@ -39,7 +39,7 @@
|
||||||
<TextView
|
<TextView
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:text="@string/profileview_units_label"
|
android:text="@string/nsprofileview_units_label"
|
||||||
android:textAppearance="?android:attr/textAppearanceLarge"
|
android:textAppearance="?android:attr/textAppearanceLarge"
|
||||||
android:layout_marginLeft="10dp" />
|
android:layout_marginLeft="10dp" />
|
||||||
|
|
||||||
|
@ -52,7 +52,7 @@
|
||||||
<TextView
|
<TextView
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:text="@string/profileview_dia_label"
|
android:text="@string/nsprofileview_dia_label"
|
||||||
android:textAppearance="?android:attr/textAppearanceLarge"
|
android:textAppearance="?android:attr/textAppearanceLarge"
|
||||||
android:layout_marginLeft="10dp" />
|
android:layout_marginLeft="10dp" />
|
||||||
|
|
||||||
|
@ -65,7 +65,7 @@
|
||||||
<TextView
|
<TextView
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:text="@string/profileview_ic_label"
|
android:text="@string/nsprofileview_ic_label"
|
||||||
android:textAppearance="?android:attr/textAppearanceLarge"
|
android:textAppearance="?android:attr/textAppearanceLarge"
|
||||||
android:layout_marginLeft="10dp" />
|
android:layout_marginLeft="10dp" />
|
||||||
|
|
||||||
|
@ -78,7 +78,7 @@
|
||||||
<TextView
|
<TextView
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:text="@string/profileview_isf_label"
|
android:text="@string/nsprofileview_isf_label"
|
||||||
android:textAppearance="?android:attr/textAppearanceLarge"
|
android:textAppearance="?android:attr/textAppearanceLarge"
|
||||||
android:layout_marginLeft="10dp" />
|
android:layout_marginLeft="10dp" />
|
||||||
|
|
||||||
|
@ -91,7 +91,7 @@
|
||||||
<TextView
|
<TextView
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:text="@string/profileview_basal_label"
|
android:text="@string/nsprofileview_basal_label"
|
||||||
android:textAppearance="?android:attr/textAppearanceLarge"
|
android:textAppearance="?android:attr/textAppearanceLarge"
|
||||||
android:layout_marginLeft="10dp" />
|
android:layout_marginLeft="10dp" />
|
||||||
|
|
||||||
|
@ -104,7 +104,7 @@
|
||||||
<TextView
|
<TextView
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:text="@string/profileview_target_label"
|
android:text="@string/nsprofileview_target_label"
|
||||||
android:textAppearance="?android:attr/textAppearanceLarge"
|
android:textAppearance="?android:attr/textAppearanceLarge"
|
||||||
android:layout_marginLeft="10dp" />
|
android:layout_marginLeft="10dp" />
|
||||||
|
|
7
app/src/main/res/layout/simpleprofile_fragment.xml
Normal file
7
app/src/main/res/layout/simpleprofile_fragment.xml
Normal file
|
@ -0,0 +1,7 @@
|
||||||
|
<FrameLayout 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=".plugins.SimpleProfile.SimpleProfileFragment">
|
||||||
|
|
||||||
|
</FrameLayout>
|
|
@ -25,13 +25,14 @@
|
||||||
<string name="objectives_gate_label_string">Gate:</string>
|
<string name="objectives_gate_label_string">Gate:</string>
|
||||||
<string name="objectives_button_start">Start</string>
|
<string name="objectives_button_start">Start</string>
|
||||||
<string name="objectives_button_verify">Verify</string>
|
<string name="objectives_button_verify">Verify</string>
|
||||||
<string name="profileview_dia_label">DIA:</string>
|
<string name="nsprofileview_units_label">Units:</string>
|
||||||
<string name="profileview_activeprofile_label">Active profile:</string>
|
<string name="nsprofileview_dia_label">DIA:</string>
|
||||||
<string name="profileview_ic_label">IC:</string>
|
<string name="nsprofileview_activeprofile_label">Active profile:</string>
|
||||||
<string name="profileview_isf_label">ISF:</string>
|
<string name="nsprofileview_ic_label">IC:</string>
|
||||||
<string name="profileview_basal_label">Basal:</string>
|
<string name="nsprofileview_isf_label">ISF:</string>
|
||||||
<string name="profileview_target_label">Target:</string>
|
<string name="nsprofileview_basal_label">Basal:</string>
|
||||||
<string name="profileview_noprofile_text">NO PROFILE SET</string>
|
<string name="nsprofileview_target_label">Target:</string>
|
||||||
|
<string name="nsprofileview_noprofile_text">NO PROFILE SET</string>
|
||||||
<string name="treatments_insulin_label_string">Insulin:</string>
|
<string name="treatments_insulin_label_string">Insulin:</string>
|
||||||
<string name="treatments_carbs_label_string">Carbs:</string>
|
<string name="treatments_carbs_label_string">Carbs:</string>
|
||||||
<string name="treatments_iob_label_string">IOB:</string>
|
<string name="treatments_iob_label_string">IOB:</string>
|
||||||
|
@ -51,7 +52,6 @@
|
||||||
<string name="treatments_wizard_unit_label">U</string>
|
<string name="treatments_wizard_unit_label">U</string>
|
||||||
<string name="treatments_wizard_iob_label">IOB</string>
|
<string name="treatments_wizard_iob_label">IOB</string>
|
||||||
<string name="treatments_wizard_total_label">TOTAL</string>
|
<string name="treatments_wizard_total_label">TOTAL</string>
|
||||||
<string name="profileview_units_label">Units:</string>
|
|
||||||
<string name="openapsma_run">Run now</string>
|
<string name="openapsma_run">Run now</string>
|
||||||
<string name="vitualpump_label">VIRTUAL PUMP</string>
|
<string name="vitualpump_label">VIRTUAL PUMP</string>
|
||||||
<string name="virtualpump_basebasalrate_label">Base basal rate:</string>
|
<string name="virtualpump_basebasalrate_label">Base basal rate:</string>
|
||||||
|
@ -93,10 +93,12 @@
|
||||||
<string name="objectives">Objectives</string>
|
<string name="objectives">Objectives</string>
|
||||||
<string name="openapsma">OpenAPS MA</string>
|
<string name="openapsma">OpenAPS MA</string>
|
||||||
<string name="overview">Overview</string>
|
<string name="overview">Overview</string>
|
||||||
<string name="profileviewer">Profile Viewer</string>
|
<string name="profileviewer">NS Profile</string>
|
||||||
|
<string name="simpleprofile">Simple profile</string>
|
||||||
<string name="tempbasals">Temp Basals</string>
|
<string name="tempbasals">Temp Basals</string>
|
||||||
<string name="treatments">Treatments</string>
|
<string name="treatments">Treatments</string>
|
||||||
<string name="virtualpump">Virtual Pump</string>
|
<string name="virtualpump">Virtual Pump</string>
|
||||||
|
|
||||||
<string name="configbuilder_pump">Pump</string>
|
<string name="configbuilder_pump">Pump</string>
|
||||||
<string name="configbuilder_treatments">Treatments</string>
|
<string name="configbuilder_treatments">Treatments</string>
|
||||||
<string name="configbuilder_tempbasals">Temp Basals</string>
|
<string name="configbuilder_tempbasals">Temp Basals</string>
|
||||||
|
|
Loading…
Reference in a new issue