fix merge conflict
|
@ -44,7 +44,7 @@ android {
|
||||||
minSdkVersion 21
|
minSdkVersion 21
|
||||||
targetSdkVersion 23
|
targetSdkVersion 23
|
||||||
versionCode 1500
|
versionCode 1500
|
||||||
version "1.53"
|
version "1.54-dev"
|
||||||
buildConfigField "String", "VERSION", '"' + version + '"'
|
buildConfigField "String", "VERSION", '"' + version + '"'
|
||||||
buildConfigField "String", "BUILDVERSION", generateGitBuild()
|
buildConfigField "String", "BUILDVERSION", generateGitBuild()
|
||||||
}
|
}
|
||||||
|
|
|
@ -29,7 +29,7 @@ import info.nightscout.androidaps.plugins.Actions.ActionsFragment;
|
||||||
import info.nightscout.androidaps.plugins.Careportal.CareportalFragment;
|
import info.nightscout.androidaps.plugins.Careportal.CareportalFragment;
|
||||||
import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderFragment;
|
import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderFragment;
|
||||||
import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderPlugin;
|
import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderPlugin;
|
||||||
import info.nightscout.androidaps.plugins.ConstraintsObjectives.ObjectivesFragment;
|
import info.nightscout.androidaps.plugins.ConstraintsObjectives.ObjectivesPlugin;
|
||||||
import info.nightscout.androidaps.plugins.ConstraintsSafety.SafetyPlugin;
|
import info.nightscout.androidaps.plugins.ConstraintsSafety.SafetyPlugin;
|
||||||
import info.nightscout.androidaps.plugins.Insulin.InsulinFastactingPlugin;
|
import info.nightscout.androidaps.plugins.Insulin.InsulinFastactingPlugin;
|
||||||
import info.nightscout.androidaps.plugins.Insulin.InsulinFastactingProlongedPlugin;
|
import info.nightscout.androidaps.plugins.Insulin.InsulinFastactingProlongedPlugin;
|
||||||
|
@ -37,17 +37,17 @@ import info.nightscout.androidaps.plugins.Insulin.InsulinOrefFreePeakPlugin;
|
||||||
import info.nightscout.androidaps.plugins.Insulin.InsulinOrefRapidActingPlugin;
|
import info.nightscout.androidaps.plugins.Insulin.InsulinOrefRapidActingPlugin;
|
||||||
import info.nightscout.androidaps.plugins.Insulin.InsulinOrefUltraRapidActingPlugin;
|
import info.nightscout.androidaps.plugins.Insulin.InsulinOrefUltraRapidActingPlugin;
|
||||||
import info.nightscout.androidaps.plugins.IobCobCalculator.IobCobCalculatorPlugin;
|
import info.nightscout.androidaps.plugins.IobCobCalculator.IobCobCalculatorPlugin;
|
||||||
import info.nightscout.androidaps.plugins.Loop.LoopFragment;
|
import info.nightscout.androidaps.plugins.Loop.LoopPlugin;
|
||||||
import info.nightscout.androidaps.plugins.NSClientInternal.NSClientInternalFragment;
|
import info.nightscout.androidaps.plugins.NSClientInternal.NSClientInternalPlugin;
|
||||||
import info.nightscout.androidaps.plugins.NSClientInternal.receivers.AckAlarmReceiver;
|
import info.nightscout.androidaps.plugins.NSClientInternal.receivers.AckAlarmReceiver;
|
||||||
import info.nightscout.androidaps.plugins.OpenAPSAMA.OpenAPSAMAFragment;
|
import info.nightscout.androidaps.plugins.OpenAPSAMA.OpenAPSAMAPlugin;
|
||||||
import info.nightscout.androidaps.plugins.OpenAPSMA.OpenAPSMAFragment;
|
import info.nightscout.androidaps.plugins.OpenAPSMA.OpenAPSMAPlugin;
|
||||||
import info.nightscout.androidaps.plugins.Overview.OverviewFragment;
|
import info.nightscout.androidaps.plugins.Overview.OverviewPlugin;
|
||||||
import info.nightscout.androidaps.plugins.Persistentnotification.PersistentNotificationPlugin;
|
import info.nightscout.androidaps.plugins.Persistentnotification.PersistentNotificationPlugin;
|
||||||
import info.nightscout.androidaps.plugins.ProfileCircadianPercentage.CircadianPercentageProfileFragment;
|
import info.nightscout.androidaps.plugins.ProfileCircadianPercentage.CircadianPercentageProfileFragment;
|
||||||
import info.nightscout.androidaps.plugins.ProfileLocal.LocalProfileFragment;
|
import info.nightscout.androidaps.plugins.ProfileLocal.LocalProfileFragment;
|
||||||
import info.nightscout.androidaps.plugins.ProfileNS.NSProfileFragment;
|
import info.nightscout.androidaps.plugins.ProfileNS.NSProfilePlugin;
|
||||||
import info.nightscout.androidaps.plugins.ProfileSimple.SimpleProfileFragment;
|
import info.nightscout.androidaps.plugins.ProfileSimple.SimpleProfilePlugin;
|
||||||
import info.nightscout.androidaps.plugins.PumpDanaR.DanaRPlugin;
|
import info.nightscout.androidaps.plugins.PumpDanaR.DanaRPlugin;
|
||||||
import info.nightscout.androidaps.plugins.PumpDanaR.services.DanaRExecutionService;
|
import info.nightscout.androidaps.plugins.PumpDanaR.services.DanaRExecutionService;
|
||||||
import info.nightscout.androidaps.plugins.PumpDanaRKorean.DanaRKoreanPlugin;
|
import info.nightscout.androidaps.plugins.PumpDanaRKorean.DanaRKoreanPlugin;
|
||||||
|
@ -59,12 +59,12 @@ import info.nightscout.androidaps.plugins.PumpVirtual.VirtualPumpPlugin;
|
||||||
import info.nightscout.androidaps.plugins.SensitivityAAPS.SensitivityAAPSPlugin;
|
import info.nightscout.androidaps.plugins.SensitivityAAPS.SensitivityAAPSPlugin;
|
||||||
import info.nightscout.androidaps.plugins.SensitivityOref0.SensitivityOref0Plugin;
|
import info.nightscout.androidaps.plugins.SensitivityOref0.SensitivityOref0Plugin;
|
||||||
import info.nightscout.androidaps.plugins.SensitivityWeightedAverage.SensitivityWeightedAveragePlugin;
|
import info.nightscout.androidaps.plugins.SensitivityWeightedAverage.SensitivityWeightedAveragePlugin;
|
||||||
import info.nightscout.androidaps.plugins.SmsCommunicator.SmsCommunicatorFragment;
|
import info.nightscout.androidaps.plugins.SmsCommunicator.SmsCommunicatorPlugin;
|
||||||
import info.nightscout.androidaps.plugins.SourceGlimp.SourceGlimpPlugin;
|
import info.nightscout.androidaps.plugins.SourceGlimp.SourceGlimpPlugin;
|
||||||
import info.nightscout.androidaps.plugins.SourceMM640g.SourceMM640gPlugin;
|
import info.nightscout.androidaps.plugins.SourceMM640g.SourceMM640gPlugin;
|
||||||
import info.nightscout.androidaps.plugins.SourceNSClient.SourceNSClientPlugin;
|
import info.nightscout.androidaps.plugins.SourceNSClient.SourceNSClientPlugin;
|
||||||
import info.nightscout.androidaps.plugins.SourceXdrip.SourceXdripPlugin;
|
import info.nightscout.androidaps.plugins.SourceXdrip.SourceXdripPlugin;
|
||||||
import info.nightscout.androidaps.plugins.Treatments.TreatmentsFragment;
|
import info.nightscout.androidaps.plugins.Treatments.TreatmentsPlugin;
|
||||||
import info.nightscout.androidaps.plugins.Wear.WearFragment;
|
import info.nightscout.androidaps.plugins.Wear.WearFragment;
|
||||||
import info.nightscout.androidaps.plugins.XDripStatusline.StatuslinePlugin;
|
import info.nightscout.androidaps.plugins.XDripStatusline.StatuslinePlugin;
|
||||||
import info.nightscout.androidaps.receivers.DataReceiver;
|
import info.nightscout.androidaps.receivers.DataReceiver;
|
||||||
|
@ -110,7 +110,7 @@ public class MainApp extends Application {
|
||||||
if (pluginsList == null) {
|
if (pluginsList == null) {
|
||||||
pluginsList = new ArrayList<>();
|
pluginsList = new ArrayList<>();
|
||||||
// Register all tabs in app here
|
// Register all tabs in app here
|
||||||
pluginsList.add(OverviewFragment.getPlugin());
|
pluginsList.add(OverviewPlugin.getPlugin());
|
||||||
pluginsList.add(IobCobCalculatorPlugin.getPlugin());
|
pluginsList.add(IobCobCalculatorPlugin.getPlugin());
|
||||||
if (Config.ACTION) pluginsList.add(ActionsFragment.getPlugin());
|
if (Config.ACTION) pluginsList.add(ActionsFragment.getPlugin());
|
||||||
pluginsList.add(InsulinFastactingPlugin.getPlugin());
|
pluginsList.add(InsulinFastactingPlugin.getPlugin());
|
||||||
|
@ -127,17 +127,17 @@ public class MainApp extends Application {
|
||||||
pluginsList.add(CareportalFragment.getPlugin());
|
pluginsList.add(CareportalFragment.getPlugin());
|
||||||
if (Config.MDI) pluginsList.add(MDIPlugin.getPlugin());
|
if (Config.MDI) pluginsList.add(MDIPlugin.getPlugin());
|
||||||
if (Config.VIRTUALPUMP) pluginsList.add(VirtualPumpPlugin.getInstance());
|
if (Config.VIRTUALPUMP) pluginsList.add(VirtualPumpPlugin.getInstance());
|
||||||
if (Config.LOOPENABLED) pluginsList.add(LoopFragment.getPlugin());
|
if (Config.LOOPENABLED) pluginsList.add(LoopPlugin.getPlugin());
|
||||||
if (Config.OPENAPSENABLED) pluginsList.add(OpenAPSMAFragment.getPlugin());
|
if (Config.OPENAPSENABLED) pluginsList.add(OpenAPSMAPlugin.getPlugin());
|
||||||
if (Config.OPENAPSENABLED) pluginsList.add(OpenAPSAMAFragment.getPlugin());
|
if (Config.OPENAPSENABLED) pluginsList.add(OpenAPSAMAPlugin.getPlugin());
|
||||||
pluginsList.add(NSProfileFragment.getPlugin());
|
pluginsList.add(NSProfilePlugin.getPlugin());
|
||||||
if (Config.OTHERPROFILES) pluginsList.add(SimpleProfileFragment.getPlugin());
|
if (Config.OTHERPROFILES) pluginsList.add(SimpleProfilePlugin.getPlugin());
|
||||||
if (Config.OTHERPROFILES) pluginsList.add(LocalProfileFragment.getPlugin());
|
if (Config.OTHERPROFILES) pluginsList.add(LocalProfileFragment.getPlugin());
|
||||||
if (Config.OTHERPROFILES)
|
if (Config.OTHERPROFILES)
|
||||||
pluginsList.add(CircadianPercentageProfileFragment.getPlugin());
|
pluginsList.add(CircadianPercentageProfileFragment.getPlugin());
|
||||||
pluginsList.add(TreatmentsFragment.getPlugin());
|
pluginsList.add(TreatmentsPlugin.getPlugin());
|
||||||
if (Config.SAFETY) pluginsList.add(SafetyPlugin.getPlugin());
|
if (Config.SAFETY) pluginsList.add(SafetyPlugin.getPlugin());
|
||||||
if (Config.APS) pluginsList.add(ObjectivesFragment.getPlugin());
|
if (Config.APS) pluginsList.add(ObjectivesPlugin.getPlugin());
|
||||||
if (!Config.NSCLIENT)
|
if (!Config.NSCLIENT)
|
||||||
pluginsList.add(SourceXdripPlugin.getPlugin());
|
pluginsList.add(SourceXdripPlugin.getPlugin());
|
||||||
pluginsList.add(SourceNSClientPlugin.getPlugin());
|
pluginsList.add(SourceNSClientPlugin.getPlugin());
|
||||||
|
@ -145,12 +145,12 @@ public class MainApp extends Application {
|
||||||
pluginsList.add(SourceMM640gPlugin.getPlugin());
|
pluginsList.add(SourceMM640gPlugin.getPlugin());
|
||||||
if (!Config.NSCLIENT)
|
if (!Config.NSCLIENT)
|
||||||
pluginsList.add(SourceGlimpPlugin.getPlugin());
|
pluginsList.add(SourceGlimpPlugin.getPlugin());
|
||||||
if (Config.SMSCOMMUNICATORENABLED) pluginsList.add(SmsCommunicatorFragment.getPlugin());
|
if (Config.SMSCOMMUNICATORENABLED) pluginsList.add(SmsCommunicatorPlugin.getPlugin());
|
||||||
|
|
||||||
if (Config.WEAR) pluginsList.add(WearFragment.getPlugin(this));
|
if (Config.WEAR) pluginsList.add(WearFragment.getPlugin(this));
|
||||||
pluginsList.add(StatuslinePlugin.getPlugin(this));
|
pluginsList.add(StatuslinePlugin.getPlugin(this));
|
||||||
pluginsList.add(new PersistentNotificationPlugin(this));
|
pluginsList.add(new PersistentNotificationPlugin(this));
|
||||||
pluginsList.add(NSClientInternalFragment.getPlugin());
|
pluginsList.add(NSClientInternalPlugin.getPlugin());
|
||||||
|
|
||||||
pluginsList.add(sConfigBuilder = ConfigBuilderFragment.getPlugin());
|
pluginsList.add(sConfigBuilder = ConfigBuilderFragment.getPlugin());
|
||||||
|
|
||||||
|
|
|
@ -316,28 +316,8 @@ public class DataService extends IntentService {
|
||||||
log.error("Unhandled exception", e);
|
log.error("Unhandled exception", e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (intent.getAction().equals(Intents.ACTION_NEW_TREATMENT)) {
|
|
||||||
try {
|
|
||||||
if (bundles.containsKey("treatment")) {
|
|
||||||
String trstring = bundles.getString("treatment");
|
|
||||||
handleAddChangeDataFromNS(trstring);
|
|
||||||
}
|
|
||||||
if (bundles.containsKey("treatments")) {
|
|
||||||
String trstring = bundles.getString("treatments");
|
|
||||||
JSONArray jsonArray = new JSONArray(trstring);
|
|
||||||
for (int i = 0; i < jsonArray.length(); i++) {
|
|
||||||
JSONObject trJson = jsonArray.getJSONObject(i);
|
|
||||||
String trstr = trJson.toString();
|
|
||||||
handleAddChangeDataFromNS(trstr);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} catch (Exception e) {
|
|
||||||
log.error("Unhandled exception", e);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
if (intent.getAction().equals(Intents.ACTION_NEW_TREATMENT) || intent.getAction().equals(Intents.ACTION_CHANGED_TREATMENT)) {
|
||||||
|
|
||||||
if (intent.getAction().equals(Intents.ACTION_CHANGED_TREATMENT)) {
|
|
||||||
try {
|
try {
|
||||||
if (bundles.containsKey("treatment")) {
|
if (bundles.containsKey("treatment")) {
|
||||||
String trstring = bundles.getString("treatment");
|
String trstring = bundles.getString("treatment");
|
||||||
|
|
|
@ -8,6 +8,9 @@ public interface Intents {
|
||||||
String ACTION_NEW_PROFILE = "info.nightscout.client.NEW_PROFILE";
|
String ACTION_NEW_PROFILE = "info.nightscout.client.NEW_PROFILE";
|
||||||
String ACTION_NEW_SGV = "info.nightscout.client.NEW_SGV";
|
String ACTION_NEW_SGV = "info.nightscout.client.NEW_SGV";
|
||||||
String ACTION_NEW_DEVICESTATUS = "info.nightscout.client.NEW_DEVICESTATUS";
|
String ACTION_NEW_DEVICESTATUS = "info.nightscout.client.NEW_DEVICESTATUS";
|
||||||
|
String ACTION_NEW_FOOD = "info.nightscout.client.NEW_FOOD";
|
||||||
|
String ACTION_CHANGED_FOOD = "info.nightscout.client.CHANGED_FOOD";
|
||||||
|
String ACTION_REMOVED_FOOD = "info.nightscout.client.REMOVED_FOOD";
|
||||||
String ACTION_NEW_MBG = "info.nightscout.client.NEW_MBG";
|
String ACTION_NEW_MBG = "info.nightscout.client.NEW_MBG";
|
||||||
String ACTION_NEW_CAL = "info.nightscout.client.NEW_CAL";
|
String ACTION_NEW_CAL = "info.nightscout.client.NEW_CAL";
|
||||||
String ACTION_NEW_STATUS = "info.nightscout.client.NEW_STATUS";
|
String ACTION_NEW_STATUS = "info.nightscout.client.NEW_STATUS";
|
||||||
|
|
|
@ -33,6 +33,7 @@ import info.nightscout.androidaps.MainApp;
|
||||||
import info.nightscout.androidaps.data.Profile;
|
import info.nightscout.androidaps.data.Profile;
|
||||||
import info.nightscout.androidaps.events.EventCareportalEventChange;
|
import info.nightscout.androidaps.events.EventCareportalEventChange;
|
||||||
import info.nightscout.androidaps.events.EventExtendedBolusChange;
|
import info.nightscout.androidaps.events.EventExtendedBolusChange;
|
||||||
|
import info.nightscout.androidaps.events.EventFoodDatabaseChanged;
|
||||||
import info.nightscout.androidaps.events.EventNewBG;
|
import info.nightscout.androidaps.events.EventNewBG;
|
||||||
import info.nightscout.androidaps.events.EventProfileSwitchChange;
|
import info.nightscout.androidaps.events.EventProfileSwitchChange;
|
||||||
import info.nightscout.androidaps.events.EventRefreshOverview;
|
import info.nightscout.androidaps.events.EventRefreshOverview;
|
||||||
|
@ -59,6 +60,7 @@ public class DatabaseHelper extends OrmLiteSqliteOpenHelper {
|
||||||
public static final String DATABASE_DBREQUESTS = "DBRequests";
|
public static final String DATABASE_DBREQUESTS = "DBRequests";
|
||||||
public static final String DATABASE_CAREPORTALEVENTS = "CareportalEvents";
|
public static final String DATABASE_CAREPORTALEVENTS = "CareportalEvents";
|
||||||
public static final String DATABASE_PROFILESWITCHES = "ProfileSwitches";
|
public static final String DATABASE_PROFILESWITCHES = "ProfileSwitches";
|
||||||
|
public static final String DATABASE_FOODS = "Foods";
|
||||||
|
|
||||||
private static final int DATABASE_VERSION = 8;
|
private static final int DATABASE_VERSION = 8;
|
||||||
|
|
||||||
|
@ -85,6 +87,8 @@ public class DatabaseHelper extends OrmLiteSqliteOpenHelper {
|
||||||
private static final ScheduledExecutorService profileSwitchEventWorker = Executors.newSingleThreadScheduledExecutor();
|
private static final ScheduledExecutorService profileSwitchEventWorker = Executors.newSingleThreadScheduledExecutor();
|
||||||
private static ScheduledFuture<?> scheduledProfileSwitchEventPost = null;
|
private static ScheduledFuture<?> scheduledProfileSwitchEventPost = null;
|
||||||
|
|
||||||
|
public FoodHelper foodHelper = new FoodHelper(this);
|
||||||
|
|
||||||
public DatabaseHelper(Context context) {
|
public DatabaseHelper(Context context) {
|
||||||
super(context, DATABASE_NAME, null, DATABASE_VERSION);
|
super(context, DATABASE_NAME, null, DATABASE_VERSION);
|
||||||
onCreate(getWritableDatabase(), getConnectionSource());
|
onCreate(getWritableDatabase(), getConnectionSource());
|
||||||
|
@ -104,6 +108,7 @@ public class DatabaseHelper extends OrmLiteSqliteOpenHelper {
|
||||||
TableUtils.createTableIfNotExists(connectionSource, ExtendedBolus.class);
|
TableUtils.createTableIfNotExists(connectionSource, ExtendedBolus.class);
|
||||||
TableUtils.createTableIfNotExists(connectionSource, CareportalEvent.class);
|
TableUtils.createTableIfNotExists(connectionSource, CareportalEvent.class);
|
||||||
TableUtils.createTableIfNotExists(connectionSource, ProfileSwitch.class);
|
TableUtils.createTableIfNotExists(connectionSource, ProfileSwitch.class);
|
||||||
|
TableUtils.createTableIfNotExists(connectionSource, Food.class);
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
log.error("Can't create database", e);
|
log.error("Can't create database", e);
|
||||||
throw new RuntimeException(e);
|
throw new RuntimeException(e);
|
||||||
|
@ -128,6 +133,7 @@ public class DatabaseHelper extends OrmLiteSqliteOpenHelper {
|
||||||
TableUtils.dropTable(connectionSource, ExtendedBolus.class, true);
|
TableUtils.dropTable(connectionSource, ExtendedBolus.class, true);
|
||||||
TableUtils.dropTable(connectionSource, CareportalEvent.class, true);
|
TableUtils.dropTable(connectionSource, CareportalEvent.class, true);
|
||||||
TableUtils.dropTable(connectionSource, ProfileSwitch.class, true);
|
TableUtils.dropTable(connectionSource, ProfileSwitch.class, true);
|
||||||
|
TableUtils.dropTable(connectionSource, Food.class, true);
|
||||||
onCreate(database, connectionSource);
|
onCreate(database, connectionSource);
|
||||||
}
|
}
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
|
@ -205,6 +211,7 @@ public class DatabaseHelper extends OrmLiteSqliteOpenHelper {
|
||||||
TableUtils.createTableIfNotExists(connectionSource, ExtendedBolus.class);
|
TableUtils.createTableIfNotExists(connectionSource, ExtendedBolus.class);
|
||||||
TableUtils.createTableIfNotExists(connectionSource, CareportalEvent.class);
|
TableUtils.createTableIfNotExists(connectionSource, CareportalEvent.class);
|
||||||
TableUtils.createTableIfNotExists(connectionSource, ProfileSwitch.class);
|
TableUtils.createTableIfNotExists(connectionSource, ProfileSwitch.class);
|
||||||
|
foodHelper.resetFood();
|
||||||
updateEarliestDataChange(0);
|
updateEarliestDataChange(0);
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
log.error("Unhandled exception", e);
|
log.error("Unhandled exception", e);
|
||||||
|
@ -217,6 +224,7 @@ public class DatabaseHelper extends OrmLiteSqliteOpenHelper {
|
||||||
scheduleTemporaryTargetChange();
|
scheduleTemporaryTargetChange();
|
||||||
scheduleCareportalEventChange();
|
scheduleCareportalEventChange();
|
||||||
scheduleProfileSwitchChange();
|
scheduleProfileSwitchChange();
|
||||||
|
foodHelper.scheduleFoodChange();
|
||||||
new java.util.Timer().schedule(
|
new java.util.Timer().schedule(
|
||||||
new java.util.TimerTask() {
|
new java.util.TimerTask() {
|
||||||
@Override
|
@Override
|
||||||
|
@ -655,8 +663,7 @@ public class DatabaseHelper extends OrmLiteSqliteOpenHelper {
|
||||||
class PostRunnable implements Runnable {
|
class PostRunnable implements Runnable {
|
||||||
public void run() {
|
public void run() {
|
||||||
log.debug("Firing EventTreatmentChange");
|
log.debug("Firing EventTreatmentChange");
|
||||||
MainApp.bus().post(new EventReloadTreatmentData());
|
MainApp.bus().post(new EventReloadTreatmentData(new EventTreatmentChange()));
|
||||||
MainApp.bus().post(new EventTreatmentChange());
|
|
||||||
if (earliestDataChange != null)
|
if (earliestDataChange != null)
|
||||||
MainApp.bus().post(new EventNewHistoryData(earliestDataChange));
|
MainApp.bus().post(new EventNewHistoryData(earliestDataChange));
|
||||||
earliestDataChange = null;
|
earliestDataChange = null;
|
||||||
|
@ -1357,8 +1364,7 @@ public class DatabaseHelper extends OrmLiteSqliteOpenHelper {
|
||||||
class PostRunnable implements Runnable {
|
class PostRunnable implements Runnable {
|
||||||
public void run() {
|
public void run() {
|
||||||
log.debug("Firing EventExtendedBolusChange");
|
log.debug("Firing EventExtendedBolusChange");
|
||||||
MainApp.bus().post(new EventReloadTreatmentData());
|
MainApp.bus().post(new EventReloadTreatmentData(new EventExtendedBolusChange()));
|
||||||
MainApp.bus().post(new EventExtendedBolusChange());
|
|
||||||
if (earliestDataChange != null)
|
if (earliestDataChange != null)
|
||||||
MainApp.bus().post(new EventNewHistoryData(earliestDataChange));
|
MainApp.bus().post(new EventNewHistoryData(earliestDataChange));
|
||||||
earliestDataChange = null;
|
earliestDataChange = null;
|
||||||
|
@ -1672,4 +1678,5 @@ public class DatabaseHelper extends OrmLiteSqliteOpenHelper {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ---------------- Food handling ---------------
|
||||||
}
|
}
|
107
app/src/main/java/info/nightscout/androidaps/db/Food.java
Normal file
|
@ -0,0 +1,107 @@
|
||||||
|
package info.nightscout.androidaps.db;
|
||||||
|
|
||||||
|
import com.j256.ormlite.field.DatabaseField;
|
||||||
|
import com.j256.ormlite.table.DatabaseTable;
|
||||||
|
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
|
import java.util.Objects;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Created by mike on 20.09.2017.
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
@DatabaseTable(tableName = DatabaseHelper.DATABASE_FOODS)
|
||||||
|
public class Food {
|
||||||
|
private static Logger log = LoggerFactory.getLogger(Food.class);
|
||||||
|
|
||||||
|
@DatabaseField(id = true)
|
||||||
|
public long key;
|
||||||
|
|
||||||
|
@DatabaseField
|
||||||
|
public boolean isValid = true;
|
||||||
|
|
||||||
|
@DatabaseField
|
||||||
|
public String _id; // NS _id
|
||||||
|
|
||||||
|
@DatabaseField
|
||||||
|
public String name;
|
||||||
|
|
||||||
|
@DatabaseField
|
||||||
|
public String category;
|
||||||
|
|
||||||
|
@DatabaseField
|
||||||
|
public String subcategory;
|
||||||
|
|
||||||
|
// Example:
|
||||||
|
// name="juice" portion=250 units="ml" carbs=12
|
||||||
|
// means 250ml of juice has 12g of carbs
|
||||||
|
|
||||||
|
@DatabaseField
|
||||||
|
public double portion; // common portion in "units"
|
||||||
|
|
||||||
|
@DatabaseField
|
||||||
|
public int carbs; // in grams
|
||||||
|
|
||||||
|
@DatabaseField
|
||||||
|
public int fat = 0; // in grams
|
||||||
|
|
||||||
|
@DatabaseField
|
||||||
|
public int protein = 0; // in grams
|
||||||
|
|
||||||
|
@DatabaseField
|
||||||
|
public int energy = 0; // in kJ
|
||||||
|
|
||||||
|
@DatabaseField
|
||||||
|
public String units = "g";
|
||||||
|
|
||||||
|
@DatabaseField
|
||||||
|
public int gi; // not used yet
|
||||||
|
|
||||||
|
public Food() {
|
||||||
|
key = System.currentTimeMillis();
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isEqual(Food other) {
|
||||||
|
if (portion != other.portion)
|
||||||
|
return false;
|
||||||
|
if (carbs != other.carbs)
|
||||||
|
return false;
|
||||||
|
if (fat != other.fat)
|
||||||
|
return false;
|
||||||
|
if (protein != other.protein)
|
||||||
|
return false;
|
||||||
|
if (energy != other.energy)
|
||||||
|
return false;
|
||||||
|
if (gi != other.gi)
|
||||||
|
return false;
|
||||||
|
if (!Objects.equals(_id, other._id))
|
||||||
|
return false;
|
||||||
|
if (!Objects.equals(name, other.name))
|
||||||
|
return false;
|
||||||
|
if (!Objects.equals(category, other.category))
|
||||||
|
return false;
|
||||||
|
if (!Objects.equals(subcategory, other.subcategory))
|
||||||
|
return false;
|
||||||
|
if (!Objects.equals(units, other.units))
|
||||||
|
return false;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void copyFrom(Food other) {
|
||||||
|
isValid = other.isValid;
|
||||||
|
_id = other._id;
|
||||||
|
name = other.name;
|
||||||
|
category = other.category;
|
||||||
|
subcategory = other.subcategory;
|
||||||
|
portion = other.portion;
|
||||||
|
carbs = other.carbs;
|
||||||
|
fat = other.fat;
|
||||||
|
protein = other.protein;
|
||||||
|
energy = other.energy;
|
||||||
|
units = other.units;
|
||||||
|
gi = other.gi;
|
||||||
|
}
|
||||||
|
}
|
205
app/src/main/java/info/nightscout/androidaps/db/FoodHelper.java
Normal file
|
@ -0,0 +1,205 @@
|
||||||
|
package info.nightscout.androidaps.db;
|
||||||
|
|
||||||
|
import com.j256.ormlite.android.AndroidConnectionSource;
|
||||||
|
import com.j256.ormlite.dao.Dao;
|
||||||
|
import com.j256.ormlite.stmt.PreparedQuery;
|
||||||
|
import com.j256.ormlite.stmt.QueryBuilder;
|
||||||
|
import com.j256.ormlite.stmt.Where;
|
||||||
|
import com.j256.ormlite.table.TableUtils;
|
||||||
|
|
||||||
|
import org.json.JSONException;
|
||||||
|
import org.json.JSONObject;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
|
import java.sql.SQLException;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.concurrent.Executors;
|
||||||
|
import java.util.concurrent.ScheduledExecutorService;
|
||||||
|
import java.util.concurrent.ScheduledFuture;
|
||||||
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
|
import info.nightscout.androidaps.MainApp;
|
||||||
|
import info.nightscout.androidaps.events.EventFoodDatabaseChanged;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Created by mike on 24.09.2017.
|
||||||
|
*/
|
||||||
|
|
||||||
|
public class FoodHelper {
|
||||||
|
private static Logger log = LoggerFactory.getLogger(FoodHelper.class);
|
||||||
|
|
||||||
|
DatabaseHelper databaseHelper;
|
||||||
|
|
||||||
|
private static final ScheduledExecutorService foodEventWorker = Executors.newSingleThreadScheduledExecutor();
|
||||||
|
private static ScheduledFuture<?> scheduledFoodEventPost = null;
|
||||||
|
|
||||||
|
public FoodHelper(DatabaseHelper databaseHelper) {
|
||||||
|
this.databaseHelper = databaseHelper;
|
||||||
|
}
|
||||||
|
|
||||||
|
private Dao<Food, Long> getDaoFood() throws SQLException {
|
||||||
|
return databaseHelper.getDao(Food.class);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void resetFood() {
|
||||||
|
try {
|
||||||
|
TableUtils.dropTable(databaseHelper.getConnectionSource(), Food.class, true);
|
||||||
|
TableUtils.createTableIfNotExists(databaseHelper.getConnectionSource(), Food.class);
|
||||||
|
} catch (SQLException e) {
|
||||||
|
log.error("Unhandled exception", e);
|
||||||
|
}
|
||||||
|
scheduleFoodChange();
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<Food> getFoodData() {
|
||||||
|
try {
|
||||||
|
Dao<Food, Long> daoFood = getDaoFood();
|
||||||
|
List<Food> foods;
|
||||||
|
QueryBuilder<Food, Long> queryBuilder = daoFood.queryBuilder();
|
||||||
|
PreparedQuery<Food> preparedQuery = queryBuilder.prepare();
|
||||||
|
foods = daoFood.query(preparedQuery);
|
||||||
|
return foods;
|
||||||
|
} catch (SQLException e) {
|
||||||
|
log.error("Unhandled exception", e);
|
||||||
|
}
|
||||||
|
return new ArrayList<>();
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean createOrUpdate(Food food) {
|
||||||
|
try {
|
||||||
|
// find by NS _id
|
||||||
|
if (food._id != null) {
|
||||||
|
Food old;
|
||||||
|
|
||||||
|
QueryBuilder<Food, Long> queryBuilder = getDaoFood().queryBuilder();
|
||||||
|
Where where = queryBuilder.where();
|
||||||
|
where.eq("_id", food._id);
|
||||||
|
PreparedQuery<Food> preparedQuery = queryBuilder.prepare();
|
||||||
|
List<Food> found = getDaoFood().query(preparedQuery);
|
||||||
|
if (found.size() > 0) {
|
||||||
|
old = found.get(0);
|
||||||
|
if (!old.isEqual(food)) {
|
||||||
|
getDaoFood().delete(old); // need to delete/create because date may change too
|
||||||
|
old.copyFrom(food);
|
||||||
|
getDaoFood().create(old);
|
||||||
|
log.debug("FOOD: Updating record by _id: " + old.toString());
|
||||||
|
scheduleFoodChange();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
getDaoFood().createOrUpdate(food);
|
||||||
|
log.debug("FOOD: New record: " + food.toString());
|
||||||
|
scheduleFoodChange();
|
||||||
|
return true;
|
||||||
|
} catch (SQLException e) {
|
||||||
|
log.error("Unhandled exception", e);
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void delete(Food food) {
|
||||||
|
try {
|
||||||
|
getDaoFood().delete(food);
|
||||||
|
scheduleFoodChange();
|
||||||
|
} catch (SQLException e) {
|
||||||
|
log.error("Unhandled exception", e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void scheduleFoodChange() {
|
||||||
|
class PostRunnable implements Runnable {
|
||||||
|
public void run() {
|
||||||
|
log.debug("Firing EventFoodChange");
|
||||||
|
MainApp.bus().post(new EventFoodDatabaseChanged());
|
||||||
|
scheduledFoodEventPost = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// prepare task for execution in 1 sec
|
||||||
|
// cancel waiting task to prevent sending multiple posts
|
||||||
|
if (scheduledFoodEventPost != null)
|
||||||
|
scheduledFoodEventPost.cancel(false);
|
||||||
|
Runnable task = new PostRunnable();
|
||||||
|
final int sec = 1;
|
||||||
|
scheduledFoodEventPost = foodEventWorker.schedule(task, sec, TimeUnit.SECONDS);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
{
|
||||||
|
"_id": "551ee3ad368e06e80856e6a9",
|
||||||
|
"type": "food",
|
||||||
|
"category": "Zakladni",
|
||||||
|
"subcategory": "Napoje",
|
||||||
|
"name": "Mleko",
|
||||||
|
"portion": 250,
|
||||||
|
"carbs": 12,
|
||||||
|
"gi": 1,
|
||||||
|
"created_at": "2015-04-14T06:59:16.500Z",
|
||||||
|
"unit": "ml"
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
public void createFoodFromJsonIfNotExists(JSONObject trJson) {
|
||||||
|
try {
|
||||||
|
Food food = new Food();
|
||||||
|
if (trJson.has("type") && trJson.getString("type").equals("food")) {
|
||||||
|
if (trJson.has("_id"))
|
||||||
|
food._id = trJson.getString("_id");
|
||||||
|
if (trJson.has("category"))
|
||||||
|
food.category = trJson.getString("category");
|
||||||
|
if (trJson.has("subcategory"))
|
||||||
|
food.subcategory = trJson.getString("subcategory");
|
||||||
|
if (trJson.has("name"))
|
||||||
|
food.name = trJson.getString("name");
|
||||||
|
if (trJson.has("unit"))
|
||||||
|
food.units = trJson.getString("unit");
|
||||||
|
if (trJson.has("portion"))
|
||||||
|
food.portion = trJson.getDouble("portion");
|
||||||
|
if (trJson.has("carbs"))
|
||||||
|
food.carbs = trJson.getInt("carbs");
|
||||||
|
if (trJson.has("gi"))
|
||||||
|
food.gi = trJson.getInt("gi");
|
||||||
|
if (trJson.has("energy"))
|
||||||
|
food.energy = trJson.getInt("energy");
|
||||||
|
if (trJson.has("protein"))
|
||||||
|
food.protein = trJson.getInt("protein");
|
||||||
|
if (trJson.has("fat"))
|
||||||
|
food.fat = trJson.getInt("fat");
|
||||||
|
}
|
||||||
|
createOrUpdate(food);
|
||||||
|
} catch (JSONException e) {
|
||||||
|
log.error("Unhandled exception", e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void deleteFoodById(String _id) {
|
||||||
|
Food stored = findFoodById(_id);
|
||||||
|
if (stored != null) {
|
||||||
|
log.debug("FOOD: Removing Food record from database: " + stored.toString());
|
||||||
|
delete(stored);
|
||||||
|
scheduleFoodChange();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public Food findFoodById(String _id) {
|
||||||
|
try {
|
||||||
|
QueryBuilder<Food, Long> queryBuilder = getDaoFood().queryBuilder();
|
||||||
|
Where where = queryBuilder.where();
|
||||||
|
where.eq("_id", _id);
|
||||||
|
PreparedQuery<Food> preparedQuery = queryBuilder.prepare();
|
||||||
|
List<Food> list = getDaoFood().query(preparedQuery);
|
||||||
|
|
||||||
|
if (list.size() == 1) {
|
||||||
|
return list.get(0);
|
||||||
|
} else {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
} catch (SQLException e) {
|
||||||
|
log.error("Unhandled exception", e);
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,8 @@
|
||||||
|
package info.nightscout.androidaps.events;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Created by mike on 20.09.2017.
|
||||||
|
*/
|
||||||
|
|
||||||
|
public class EventFoodDatabaseChanged {
|
||||||
|
}
|
|
@ -5,4 +5,9 @@ package info.nightscout.androidaps.events;
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public class EventReloadTreatmentData {
|
public class EventReloadTreatmentData {
|
||||||
|
public Object next;
|
||||||
|
|
||||||
|
public EventReloadTreatmentData(Object next) {
|
||||||
|
this.next = next;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,6 +12,7 @@ import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
import android.widget.Button;
|
import android.widget.Button;
|
||||||
|
|
||||||
|
import com.crashlytics.android.Crashlytics;
|
||||||
import com.crashlytics.android.answers.Answers;
|
import com.crashlytics.android.answers.Answers;
|
||||||
import com.crashlytics.android.answers.CustomEvent;
|
import com.crashlytics.android.answers.CustomEvent;
|
||||||
import com.squareup.otto.Subscribe;
|
import com.squareup.otto.Subscribe;
|
||||||
|
@ -69,26 +70,32 @@ public class ActionsFragment extends SubscriberFragment implements View.OnClickL
|
||||||
@Override
|
@Override
|
||||||
public View onCreateView(LayoutInflater inflater, ViewGroup container,
|
public View onCreateView(LayoutInflater inflater, ViewGroup container,
|
||||||
Bundle savedInstanceState) {
|
Bundle savedInstanceState) {
|
||||||
View view = inflater.inflate(R.layout.actions_fragment, container, false);
|
try {
|
||||||
|
View view = inflater.inflate(R.layout.actions_fragment, container, false);
|
||||||
|
|
||||||
profileSwitch = (Button) view.findViewById(R.id.actions_profileswitch);
|
profileSwitch = (Button) view.findViewById(R.id.actions_profileswitch);
|
||||||
tempTarget = (Button) view.findViewById(R.id.actions_temptarget);
|
tempTarget = (Button) view.findViewById(R.id.actions_temptarget);
|
||||||
extendedBolus = (Button) view.findViewById(R.id.actions_extendedbolus);
|
extendedBolus = (Button) view.findViewById(R.id.actions_extendedbolus);
|
||||||
extendedBolusCancel = (Button) view.findViewById(R.id.actions_extendedbolus_cancel);
|
extendedBolusCancel = (Button) view.findViewById(R.id.actions_extendedbolus_cancel);
|
||||||
tempBasal = (Button) view.findViewById(R.id.actions_settempbasal);
|
tempBasal = (Button) view.findViewById(R.id.actions_settempbasal);
|
||||||
tempBasalCancel = (Button) view.findViewById(R.id.actions_canceltempbasal);
|
tempBasalCancel = (Button) view.findViewById(R.id.actions_canceltempbasal);
|
||||||
fill = (Button) view.findViewById(R.id.actions_fill);
|
fill = (Button) view.findViewById(R.id.actions_fill);
|
||||||
|
|
||||||
profileSwitch.setOnClickListener(this);
|
profileSwitch.setOnClickListener(this);
|
||||||
tempTarget.setOnClickListener(this);
|
tempTarget.setOnClickListener(this);
|
||||||
extendedBolus.setOnClickListener(this);
|
extendedBolus.setOnClickListener(this);
|
||||||
extendedBolusCancel.setOnClickListener(this);
|
extendedBolusCancel.setOnClickListener(this);
|
||||||
tempBasal.setOnClickListener(this);
|
tempBasal.setOnClickListener(this);
|
||||||
tempBasalCancel.setOnClickListener(this);
|
tempBasalCancel.setOnClickListener(this);
|
||||||
fill.setOnClickListener(this);
|
fill.setOnClickListener(this);
|
||||||
|
|
||||||
updateGUI();
|
updateGUI();
|
||||||
return view;
|
return view;
|
||||||
|
} catch (Exception e) {
|
||||||
|
Crashlytics.logException(e);
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Subscribe
|
@Subscribe
|
||||||
|
|
|
@ -10,8 +10,8 @@ import info.nightscout.androidaps.interfaces.PluginBase;
|
||||||
|
|
||||||
public class ActionsPlugin implements PluginBase {
|
public class ActionsPlugin implements PluginBase {
|
||||||
|
|
||||||
boolean fragmentEnabled = true;
|
private boolean fragmentEnabled = true;
|
||||||
boolean fragmentVisible = true;
|
private boolean fragmentVisible = true;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getType() {
|
public int getType() {
|
||||||
|
|
|
@ -10,6 +10,7 @@ import android.view.ViewGroup;
|
||||||
import android.widget.LinearLayout;
|
import android.widget.LinearLayout;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
|
||||||
|
import com.crashlytics.android.Crashlytics;
|
||||||
import com.squareup.otto.Subscribe;
|
import com.squareup.otto.Subscribe;
|
||||||
|
|
||||||
import info.nightscout.androidaps.BuildConfig;
|
import info.nightscout.androidaps.BuildConfig;
|
||||||
|
@ -69,53 +70,59 @@ public class CareportalFragment extends SubscriberFragment implements View.OnCli
|
||||||
@Override
|
@Override
|
||||||
public View onCreateView(LayoutInflater inflater, ViewGroup container,
|
public View onCreateView(LayoutInflater inflater, ViewGroup container,
|
||||||
Bundle savedInstanceState) {
|
Bundle savedInstanceState) {
|
||||||
View view = inflater.inflate(R.layout.careportal_fragment, container, false);
|
try {
|
||||||
|
View view = inflater.inflate(R.layout.careportal_fragment, container, false);
|
||||||
|
|
||||||
view.findViewById(R.id.careportal_bgcheck).setOnClickListener(this);
|
view.findViewById(R.id.careportal_bgcheck).setOnClickListener(this);
|
||||||
view.findViewById(R.id.careportal_announcement).setOnClickListener(this);
|
view.findViewById(R.id.careportal_announcement).setOnClickListener(this);
|
||||||
view.findViewById(R.id.careportal_cgmsensorinsert).setOnClickListener(this);
|
view.findViewById(R.id.careportal_cgmsensorinsert).setOnClickListener(this);
|
||||||
view.findViewById(R.id.careportal_cgmsensorstart).setOnClickListener(this);
|
view.findViewById(R.id.careportal_cgmsensorstart).setOnClickListener(this);
|
||||||
view.findViewById(R.id.careportal_combobolus).setOnClickListener(this);
|
view.findViewById(R.id.careportal_combobolus).setOnClickListener(this);
|
||||||
view.findViewById(R.id.careportal_correctionbolus).setOnClickListener(this);
|
view.findViewById(R.id.careportal_correctionbolus).setOnClickListener(this);
|
||||||
view.findViewById(R.id.careportal_carbscorrection).setOnClickListener(this);
|
view.findViewById(R.id.careportal_carbscorrection).setOnClickListener(this);
|
||||||
view.findViewById(R.id.careportal_exercise).setOnClickListener(this);
|
view.findViewById(R.id.careportal_exercise).setOnClickListener(this);
|
||||||
view.findViewById(R.id.careportal_insulincartridgechange).setOnClickListener(this);
|
view.findViewById(R.id.careportal_insulincartridgechange).setOnClickListener(this);
|
||||||
view.findViewById(R.id.careportal_pumpbatterychange).setOnClickListener(this);
|
view.findViewById(R.id.careportal_pumpbatterychange).setOnClickListener(this);
|
||||||
view.findViewById(R.id.careportal_mealbolus).setOnClickListener(this);
|
view.findViewById(R.id.careportal_mealbolus).setOnClickListener(this);
|
||||||
view.findViewById(R.id.careportal_note).setOnClickListener(this);
|
view.findViewById(R.id.careportal_note).setOnClickListener(this);
|
||||||
view.findViewById(R.id.careportal_profileswitch).setOnClickListener(this);
|
view.findViewById(R.id.careportal_profileswitch).setOnClickListener(this);
|
||||||
view.findViewById(R.id.careportal_pumpsitechange).setOnClickListener(this);
|
view.findViewById(R.id.careportal_pumpsitechange).setOnClickListener(this);
|
||||||
view.findViewById(R.id.careportal_question).setOnClickListener(this);
|
view.findViewById(R.id.careportal_question).setOnClickListener(this);
|
||||||
view.findViewById(R.id.careportal_snackbolus).setOnClickListener(this);
|
view.findViewById(R.id.careportal_snackbolus).setOnClickListener(this);
|
||||||
view.findViewById(R.id.careportal_tempbasalend).setOnClickListener(this);
|
view.findViewById(R.id.careportal_tempbasalend).setOnClickListener(this);
|
||||||
view.findViewById(R.id.careportal_tempbasalstart).setOnClickListener(this);
|
view.findViewById(R.id.careportal_tempbasalstart).setOnClickListener(this);
|
||||||
view.findViewById(R.id.careportal_openapsoffline).setOnClickListener(this);
|
view.findViewById(R.id.careportal_openapsoffline).setOnClickListener(this);
|
||||||
view.findViewById(R.id.careportal_temporarytarget).setOnClickListener(this);
|
view.findViewById(R.id.careportal_temporarytarget).setOnClickListener(this);
|
||||||
|
|
||||||
iage = (TextView) view.findViewById(R.id.careportal_insulinage);
|
iage = (TextView) view.findViewById(R.id.careportal_insulinage);
|
||||||
cage = (TextView) view.findViewById(R.id.careportal_canulaage);
|
cage = (TextView) view.findViewById(R.id.careportal_canulaage);
|
||||||
sage = (TextView) view.findViewById(R.id.careportal_sensorage);
|
sage = (TextView) view.findViewById(R.id.careportal_sensorage);
|
||||||
pbage = (TextView) view.findViewById(R.id.careportal_pbage);
|
pbage = (TextView) view.findViewById(R.id.careportal_pbage);
|
||||||
|
|
||||||
statsLayout = (View) view.findViewById(R.id.careportal_stats);
|
statsLayout = view.findViewById(R.id.careportal_stats);
|
||||||
|
|
||||||
noProfileView = (View) view.findViewById(R.id.profileview_noprofile);
|
noProfileView = view.findViewById(R.id.profileview_noprofile);
|
||||||
butonsLayout = (LinearLayout) view.findViewById(R.id.careportal_buttons);
|
butonsLayout = (LinearLayout) view.findViewById(R.id.careportal_buttons);
|
||||||
|
|
||||||
ProfileStore profileStore = ConfigBuilderPlugin.getActiveProfileInterface().getProfile();
|
ProfileStore profileStore = ConfigBuilderPlugin.getActiveProfileInterface().getProfile();
|
||||||
if (profileStore == null) {
|
if (profileStore == null) {
|
||||||
noProfileView.setVisibility(View.VISIBLE);
|
noProfileView.setVisibility(View.VISIBLE);
|
||||||
butonsLayout.setVisibility(View.GONE);
|
butonsLayout.setVisibility(View.GONE);
|
||||||
} else {
|
} else {
|
||||||
noProfileView.setVisibility(View.GONE);
|
noProfileView.setVisibility(View.GONE);
|
||||||
butonsLayout.setVisibility(View.VISIBLE);
|
butonsLayout.setVisibility(View.VISIBLE);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (BuildConfig.NSCLIENTOLNY)
|
||||||
|
statsLayout.setVisibility(View.GONE); // visible on overview
|
||||||
|
|
||||||
|
updateGUI();
|
||||||
|
return view;
|
||||||
|
} catch (Exception e) {
|
||||||
|
Crashlytics.logException(e);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (BuildConfig.NSCLIENTOLNY)
|
return null;
|
||||||
statsLayout.setVisibility(View.GONE); // visible on overview
|
|
||||||
|
|
||||||
updateGUI();
|
|
||||||
return view;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -7,8 +7,8 @@ import info.nightscout.androidaps.interfaces.PluginBase;
|
||||||
|
|
||||||
public class CareportalPlugin implements PluginBase {
|
public class CareportalPlugin implements PluginBase {
|
||||||
|
|
||||||
boolean fragmentEnabled = true;
|
private boolean fragmentEnabled = true;
|
||||||
boolean fragmentVisible = true;
|
private boolean fragmentVisible = true;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getType() {
|
public int getType() {
|
||||||
|
|
|
@ -14,6 +14,7 @@ import android.text.format.DateFormat;
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
|
import android.widget.AdapterView;
|
||||||
import android.widget.ArrayAdapter;
|
import android.widget.ArrayAdapter;
|
||||||
import android.widget.CompoundButton;
|
import android.widget.CompoundButton;
|
||||||
import android.widget.EditText;
|
import android.widget.EditText;
|
||||||
|
@ -178,19 +179,57 @@ public class NewNSTreatmentDialog extends DialogFragment implements View.OnClick
|
||||||
profileSpinner.setSelection(p);
|
profileSpinner.setSelection(p);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
final Double bg = Profile.fromMgdlToUnits(GlucoseStatus.getGlucoseStatusData() != null ? GlucoseStatus.getGlucoseStatusData().glucose : 0d, profile != null ? profile.getUnits() : Constants.MGDL);
|
||||||
|
|
||||||
// temp target
|
// temp target
|
||||||
ArrayList<CharSequence> reasonList = new ArrayList<CharSequence>();
|
final ArrayList<CharSequence> reasonList = new ArrayList<CharSequence>();
|
||||||
|
reasonList.add(MainApp.sResources.getString(R.string.manual));
|
||||||
reasonList.add(MainApp.sResources.getString(R.string.eatingsoon));
|
reasonList.add(MainApp.sResources.getString(R.string.eatingsoon));
|
||||||
reasonList.add(MainApp.sResources.getString(R.string.activity));
|
reasonList.add(MainApp.sResources.getString(R.string.activity));
|
||||||
reasonList.add(MainApp.sResources.getString(R.string.manual));
|
|
||||||
ArrayAdapter<CharSequence> adapterReason = new ArrayAdapter<CharSequence>(getContext(),
|
ArrayAdapter<CharSequence> adapterReason = new ArrayAdapter<CharSequence>(getContext(),
|
||||||
R.layout.spinner_centered, reasonList);
|
R.layout.spinner_centered, reasonList);
|
||||||
reasonSpinner.setAdapter(adapterReason);
|
reasonSpinner.setAdapter(adapterReason);
|
||||||
|
reasonSpinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
|
||||||
|
@Override
|
||||||
|
public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
|
||||||
|
double defaultDuration = 0;
|
||||||
|
double defaultTarget = 0;
|
||||||
|
if(profile!=null){
|
||||||
|
defaultTarget = bg.doubleValue();
|
||||||
|
}
|
||||||
|
boolean erase = false;
|
||||||
|
|
||||||
|
if(MainApp.sResources.getString(R.string.eatingsoon).equals(reasonList.get(position))){
|
||||||
|
defaultDuration = SP.getDouble(R.string.key_eatingsoon_duration, 0d);
|
||||||
|
defaultTarget = SP.getDouble(R.string.key_eatingsoon_target, 0d);;
|
||||||
|
} else if (MainApp.sResources.getString(R.string.activity).equals(reasonList.get(position))){
|
||||||
|
defaultDuration = SP.getDouble(R.string.key_activity_duration, 0d);;
|
||||||
|
defaultTarget = SP.getDouble(R.string.key_activity_target, 0d);;
|
||||||
|
} else {
|
||||||
|
defaultDuration = 0;
|
||||||
|
erase = true;
|
||||||
|
}
|
||||||
|
if(defaultTarget != 0 || erase){
|
||||||
|
editTemptarget.setValue(defaultTarget);
|
||||||
|
}
|
||||||
|
if(defaultDuration != 0){
|
||||||
|
editDuration.setValue(defaultDuration);
|
||||||
|
} else if (erase){
|
||||||
|
editDuration.setValue(0d);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onNothingSelected(AdapterView<?> parent) {
|
||||||
|
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
// bg
|
// bg
|
||||||
bgUnitsView.setText(units);
|
bgUnitsView.setText(units);
|
||||||
|
|
||||||
TextWatcher bgTextWatcher = new TextWatcher() {
|
TextWatcher bgTextWatcher = new TextWatcher() {
|
||||||
|
|
||||||
public void afterTextChanged(Editable s) {
|
public void afterTextChanged(Editable s) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -202,7 +241,6 @@ public class NewNSTreatmentDialog extends DialogFragment implements View.OnClick
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
Double bg = Profile.fromMgdlToUnits(GlucoseStatus.getGlucoseStatusData() != null ? GlucoseStatus.getGlucoseStatusData().glucose : 0d, profile != null ? profile.getUnits() : Constants.MGDL);
|
|
||||||
editBg = (NumberPicker) view.findViewById(R.id.careportal_newnstreatment_bginput);
|
editBg = (NumberPicker) view.findViewById(R.id.careportal_newnstreatment_bginput);
|
||||||
editTemptarget = (NumberPicker) view.findViewById(R.id.careportal_newnstreatment_temptarget);
|
editTemptarget = (NumberPicker) view.findViewById(R.id.careportal_newnstreatment_temptarget);
|
||||||
if (profile == null) {
|
if (profile == null) {
|
||||||
|
|
|
@ -15,6 +15,7 @@ import android.widget.ListAdapter;
|
||||||
import android.widget.ListView;
|
import android.widget.ListView;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
|
||||||
|
import com.crashlytics.android.Crashlytics;
|
||||||
import com.crashlytics.android.answers.Answers;
|
import com.crashlytics.android.answers.Answers;
|
||||||
import com.crashlytics.android.answers.CustomEvent;
|
import com.crashlytics.android.answers.CustomEvent;
|
||||||
|
|
||||||
|
@ -79,47 +80,53 @@ public class ConfigBuilderFragment extends Fragment {
|
||||||
@Override
|
@Override
|
||||||
public View onCreateView(LayoutInflater inflater, ViewGroup container,
|
public View onCreateView(LayoutInflater inflater, ViewGroup container,
|
||||||
Bundle savedInstanceState) {
|
Bundle savedInstanceState) {
|
||||||
View view = inflater.inflate(R.layout.configbuilder_fragment, container, false);
|
try {
|
||||||
|
View view = inflater.inflate(R.layout.configbuilder_fragment, container, false);
|
||||||
|
|
||||||
insulinListView = (ListView) view.findViewById(R.id.configbuilder_insulinlistview);
|
insulinListView = (ListView) view.findViewById(R.id.configbuilder_insulinlistview);
|
||||||
sensitivityListView = (ListView) view.findViewById(R.id.configbuilder_sensitivitylistview);
|
sensitivityListView = (ListView) view.findViewById(R.id.configbuilder_sensitivitylistview);
|
||||||
bgsourceListView = (ListView) view.findViewById(R.id.configbuilder_bgsourcelistview);
|
bgsourceListView = (ListView) view.findViewById(R.id.configbuilder_bgsourcelistview);
|
||||||
bgsourceLabel = (TextView) view.findViewById(R.id.configbuilder_bgsourcelabel);
|
bgsourceLabel = (TextView) view.findViewById(R.id.configbuilder_bgsourcelabel);
|
||||||
pumpListView = (ListView) view.findViewById(R.id.configbuilder_pumplistview);
|
pumpListView = (ListView) view.findViewById(R.id.configbuilder_pumplistview);
|
||||||
pumpLabel = (TextView) view.findViewById(R.id.configbuilder_pumplabel);
|
pumpLabel = (TextView) view.findViewById(R.id.configbuilder_pumplabel);
|
||||||
loopListView = (ListView) view.findViewById(R.id.configbuilder_looplistview);
|
loopListView = (ListView) view.findViewById(R.id.configbuilder_looplistview);
|
||||||
loopLabel = (TextView) view.findViewById(R.id.configbuilder_looplabel);
|
loopLabel = (TextView) view.findViewById(R.id.configbuilder_looplabel);
|
||||||
profileListView = (ListView) view.findViewById(R.id.configbuilder_profilelistview);
|
profileListView = (ListView) view.findViewById(R.id.configbuilder_profilelistview);
|
||||||
profileLabel = (TextView) view.findViewById(R.id.configbuilder_profilelabel);
|
profileLabel = (TextView) view.findViewById(R.id.configbuilder_profilelabel);
|
||||||
apsListView = (ListView) view.findViewById(R.id.configbuilder_apslistview);
|
apsListView = (ListView) view.findViewById(R.id.configbuilder_apslistview);
|
||||||
apsLabel = (TextView) view.findViewById(R.id.configbuilder_apslabel);
|
apsLabel = (TextView) view.findViewById(R.id.configbuilder_apslabel);
|
||||||
constraintsListView = (ListView) view.findViewById(R.id.configbuilder_constraintslistview);
|
constraintsListView = (ListView) view.findViewById(R.id.configbuilder_constraintslistview);
|
||||||
constraintsLabel = (TextView) view.findViewById(R.id.configbuilder_constraintslabel);
|
constraintsLabel = (TextView) view.findViewById(R.id.configbuilder_constraintslabel);
|
||||||
generalListView = (ListView) view.findViewById(R.id.configbuilder_generallistview);
|
generalListView = (ListView) view.findViewById(R.id.configbuilder_generallistview);
|
||||||
|
|
||||||
mainLayout = (LinearLayout) view.findViewById(R.id.configbuilder_mainlayout);
|
mainLayout = (LinearLayout) view.findViewById(R.id.configbuilder_mainlayout);
|
||||||
unlock = (Button) view.findViewById(R.id.configbuilder_unlock);
|
unlock = (Button) view.findViewById(R.id.configbuilder_unlock);
|
||||||
|
|
||||||
setViews();
|
setViews();
|
||||||
|
|
||||||
if (PasswordProtection.isLocked("settings_password")) {
|
if (PasswordProtection.isLocked("settings_password")) {
|
||||||
mainLayout.setVisibility(View.GONE);
|
mainLayout.setVisibility(View.GONE);
|
||||||
unlock.setOnClickListener(new View.OnClickListener() {
|
unlock.setOnClickListener(new View.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View v) {
|
public void onClick(View v) {
|
||||||
PasswordProtection.QueryPassword(getContext(), R.string.settings_password, "settings_password", new Runnable() {
|
PasswordProtection.QueryPassword(getContext(), R.string.settings_password, "settings_password", new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
mainLayout.setVisibility(View.VISIBLE);
|
mainLayout.setVisibility(View.VISIBLE);
|
||||||
unlock.setVisibility(View.GONE);
|
unlock.setVisibility(View.GONE);
|
||||||
}
|
}
|
||||||
}, null);
|
}, null);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
unlock.setVisibility(View.GONE);
|
unlock.setVisibility(View.GONE);
|
||||||
|
}
|
||||||
|
return view;
|
||||||
|
} catch (Exception e) {
|
||||||
|
Crashlytics.logException(e);
|
||||||
}
|
}
|
||||||
return view;
|
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
void setViews() {
|
void setViews() {
|
||||||
|
|
|
@ -15,6 +15,8 @@ import android.widget.CheckBox;
|
||||||
import android.widget.LinearLayout;
|
import android.widget.LinearLayout;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
|
||||||
|
import com.crashlytics.android.Crashlytics;
|
||||||
|
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
|
@ -27,15 +29,6 @@ import info.nightscout.androidaps.R;
|
||||||
public class ObjectivesFragment extends Fragment {
|
public class ObjectivesFragment extends Fragment {
|
||||||
private static Logger log = LoggerFactory.getLogger(ObjectivesFragment.class);
|
private static Logger log = LoggerFactory.getLogger(ObjectivesFragment.class);
|
||||||
|
|
||||||
private static ObjectivesPlugin objectivesPlugin;
|
|
||||||
|
|
||||||
public static ObjectivesPlugin getPlugin() {
|
|
||||||
if (objectivesPlugin == null) {
|
|
||||||
objectivesPlugin = new ObjectivesPlugin();
|
|
||||||
}
|
|
||||||
return objectivesPlugin;
|
|
||||||
}
|
|
||||||
|
|
||||||
RecyclerView recyclerView;
|
RecyclerView recyclerView;
|
||||||
LinearLayoutManager llm;
|
LinearLayoutManager llm;
|
||||||
CheckBox enableFake;
|
CheckBox enableFake;
|
||||||
|
@ -59,7 +52,7 @@ public class ObjectivesFragment extends Fragment {
|
||||||
@Override
|
@Override
|
||||||
public void onBindViewHolder(ObjectiveViewHolder holder, int position) {
|
public void onBindViewHolder(ObjectiveViewHolder holder, int position) {
|
||||||
ObjectivesPlugin.Objective o = objectives.get(position);
|
ObjectivesPlugin.Objective o = objectives.get(position);
|
||||||
ObjectivesPlugin.RequirementResult requirementsMet = getPlugin().requirementsMet(position);
|
ObjectivesPlugin.RequirementResult requirementsMet = ObjectivesPlugin.getPlugin().requirementsMet(position);
|
||||||
Context context = MainApp.instance().getApplicationContext();
|
Context context = MainApp.instance().getApplicationContext();
|
||||||
holder.position.setText(String.valueOf(position + 1));
|
holder.position.setText(String.valueOf(position + 1));
|
||||||
holder.objective.setText(o.objective);
|
holder.objective.setText(o.objective);
|
||||||
|
@ -83,7 +76,7 @@ public class ObjectivesFragment extends Fragment {
|
||||||
holder.verifyButton.setOnClickListener(new View.OnClickListener() {
|
holder.verifyButton.setOnClickListener(new View.OnClickListener() {
|
||||||
public void onClick(View v) {
|
public void onClick(View v) {
|
||||||
ObjectivesPlugin.Objective o = (ObjectivesPlugin.Objective) v.getTag();
|
ObjectivesPlugin.Objective o = (ObjectivesPlugin.Objective) v.getTag();
|
||||||
if (getPlugin().requirementsMet(o.num).done || enableFake.isChecked()) {
|
if (ObjectivesPlugin.getPlugin().requirementsMet(o.num).done || enableFake.isChecked()) {
|
||||||
o.accomplished = new Date();
|
o.accomplished = new Date();
|
||||||
updateGUI();
|
updateGUI();
|
||||||
ObjectivesPlugin.saveProgress();
|
ObjectivesPlugin.saveProgress();
|
||||||
|
@ -173,45 +166,51 @@ public class ObjectivesFragment extends Fragment {
|
||||||
@Override
|
@Override
|
||||||
public View onCreateView(LayoutInflater inflater, ViewGroup container,
|
public View onCreateView(LayoutInflater inflater, ViewGroup container,
|
||||||
Bundle savedInstanceState) {
|
Bundle savedInstanceState) {
|
||||||
View view = inflater.inflate(R.layout.objectives_fragment, container, false);
|
try {
|
||||||
|
View view = inflater.inflate(R.layout.objectives_fragment, container, false);
|
||||||
|
|
||||||
recyclerView = (RecyclerView) view.findViewById(R.id.objectives_recyclerview);
|
recyclerView = (RecyclerView) view.findViewById(R.id.objectives_recyclerview);
|
||||||
recyclerView.setHasFixedSize(true);
|
recyclerView.setHasFixedSize(true);
|
||||||
llm = new LinearLayoutManager(view.getContext());
|
llm = new LinearLayoutManager(view.getContext());
|
||||||
recyclerView.setLayoutManager(llm);
|
recyclerView.setLayoutManager(llm);
|
||||||
enableFake = (CheckBox) view.findViewById(R.id.objectives_fake);
|
enableFake = (CheckBox) view.findViewById(R.id.objectives_fake);
|
||||||
fake_layout = (LinearLayout) view.findViewById(R.id.objectives_fake_layout);
|
fake_layout = (LinearLayout) view.findViewById(R.id.objectives_fake_layout);
|
||||||
reset = (TextView) view.findViewById(R.id.objectives_reset);
|
reset = (TextView) view.findViewById(R.id.objectives_reset);
|
||||||
enableFake.setOnClickListener(new View.OnClickListener() {
|
enableFake.setOnClickListener(new View.OnClickListener() {
|
||||||
public void onClick(View v) {
|
public void onClick(View v) {
|
||||||
updateGUI();
|
updateGUI();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
reset.setOnClickListener(new View.OnClickListener() {
|
reset.setOnClickListener(new View.OnClickListener() {
|
||||||
public void onClick(View v) {
|
public void onClick(View v) {
|
||||||
getPlugin().initializeData();
|
ObjectivesPlugin.getPlugin().initializeData();
|
||||||
getPlugin().saveProgress();
|
ObjectivesPlugin.saveProgress();
|
||||||
updateGUI();
|
updateGUI();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
// Add correct translations to array after app is initialized
|
// Add correct translations to array after app is initialized
|
||||||
getPlugin().objectives.get(0).objective = MainApp.sResources.getString(R.string.objectives_0_objective);
|
ObjectivesPlugin.objectives.get(0).objective = MainApp.sResources.getString(R.string.objectives_0_objective);
|
||||||
getPlugin().objectives.get(1).objective = MainApp.sResources.getString(R.string.objectives_1_objective);
|
ObjectivesPlugin.objectives.get(1).objective = MainApp.sResources.getString(R.string.objectives_1_objective);
|
||||||
getPlugin().objectives.get(2).objective = MainApp.sResources.getString(R.string.objectives_2_objective);
|
ObjectivesPlugin.objectives.get(2).objective = MainApp.sResources.getString(R.string.objectives_2_objective);
|
||||||
getPlugin().objectives.get(3).objective = MainApp.sResources.getString(R.string.objectives_3_objective);
|
ObjectivesPlugin.objectives.get(3).objective = MainApp.sResources.getString(R.string.objectives_3_objective);
|
||||||
getPlugin().objectives.get(4).objective = MainApp.sResources.getString(R.string.objectives_4_objective);
|
ObjectivesPlugin.objectives.get(4).objective = MainApp.sResources.getString(R.string.objectives_4_objective);
|
||||||
getPlugin().objectives.get(5).objective = MainApp.sResources.getString(R.string.objectives_5_objective);
|
ObjectivesPlugin.objectives.get(5).objective = MainApp.sResources.getString(R.string.objectives_5_objective);
|
||||||
getPlugin().objectives.get(6).objective = MainApp.sResources.getString(R.string.objectives_6_objective);
|
ObjectivesPlugin.objectives.get(6).objective = MainApp.sResources.getString(R.string.objectives_6_objective);
|
||||||
getPlugin().objectives.get(0).gate = MainApp.sResources.getString(R.string.objectives_0_gate);
|
ObjectivesPlugin.objectives.get(0).gate = MainApp.sResources.getString(R.string.objectives_0_gate);
|
||||||
getPlugin().objectives.get(1).gate = MainApp.sResources.getString(R.string.objectives_1_gate);
|
ObjectivesPlugin.objectives.get(1).gate = MainApp.sResources.getString(R.string.objectives_1_gate);
|
||||||
getPlugin().objectives.get(2).gate = MainApp.sResources.getString(R.string.objectives_2_gate);
|
ObjectivesPlugin.objectives.get(2).gate = MainApp.sResources.getString(R.string.objectives_2_gate);
|
||||||
getPlugin().objectives.get(3).gate = MainApp.sResources.getString(R.string.objectives_3_gate);
|
ObjectivesPlugin.objectives.get(3).gate = MainApp.sResources.getString(R.string.objectives_3_gate);
|
||||||
getPlugin().objectives.get(4).gate = MainApp.sResources.getString(R.string.objectives_4_gate);
|
ObjectivesPlugin.objectives.get(4).gate = MainApp.sResources.getString(R.string.objectives_4_gate);
|
||||||
getPlugin().objectives.get(5).gate = MainApp.sResources.getString(R.string.objectives_5_gate);
|
ObjectivesPlugin.objectives.get(5).gate = MainApp.sResources.getString(R.string.objectives_5_gate);
|
||||||
updateGUI();
|
updateGUI();
|
||||||
|
|
||||||
return view;
|
return view;
|
||||||
|
} catch (Exception e) {
|
||||||
|
Crashlytics.logException(e);
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
void updateGUI() {
|
void updateGUI() {
|
||||||
|
|
|
@ -25,11 +25,20 @@ import info.nightscout.utils.SP;
|
||||||
public class ObjectivesPlugin implements PluginBase, ConstraintsInterface {
|
public class ObjectivesPlugin implements PluginBase, ConstraintsInterface {
|
||||||
private static Logger log = LoggerFactory.getLogger(ObjectivesPlugin.class);
|
private static Logger log = LoggerFactory.getLogger(ObjectivesPlugin.class);
|
||||||
|
|
||||||
|
private static ObjectivesPlugin objectivesPlugin;
|
||||||
|
|
||||||
|
public static ObjectivesPlugin getPlugin() {
|
||||||
|
if (objectivesPlugin == null) {
|
||||||
|
objectivesPlugin = new ObjectivesPlugin();
|
||||||
|
}
|
||||||
|
return objectivesPlugin;
|
||||||
|
}
|
||||||
|
|
||||||
public static List<Objective> objectives;
|
public static List<Objective> objectives;
|
||||||
|
|
||||||
boolean fragmentVisible = true;
|
private boolean fragmentVisible = true;
|
||||||
|
|
||||||
public ObjectivesPlugin() {
|
private ObjectivesPlugin() {
|
||||||
initializeData();
|
initializeData();
|
||||||
loadProgress();
|
loadProgress();
|
||||||
MainApp.bus().register(this);
|
MainApp.bus().register(this);
|
||||||
|
@ -95,7 +104,7 @@ public class ObjectivesPlugin implements PluginBase, ConstraintsInterface {
|
||||||
if (type == CONSTRAINTS) this.fragmentVisible = fragmentVisible;
|
if (type == CONSTRAINTS) this.fragmentVisible = fragmentVisible;
|
||||||
}
|
}
|
||||||
|
|
||||||
public class Objective {
|
class Objective {
|
||||||
Integer num;
|
Integer num;
|
||||||
String objective;
|
String objective;
|
||||||
String gate;
|
String gate;
|
||||||
|
@ -118,13 +127,13 @@ public class ObjectivesPlugin implements PluginBase, ConstraintsInterface {
|
||||||
public static boolean pumpStatusIsAvailableInNS = false;
|
public static boolean pumpStatusIsAvailableInNS = false;
|
||||||
// Objective 1
|
// Objective 1
|
||||||
public static Integer manualEnacts = 0;
|
public static Integer manualEnacts = 0;
|
||||||
public static final Integer manualEnactsNeeded = 20;
|
private static final Integer manualEnactsNeeded = 20;
|
||||||
|
|
||||||
public class RequirementResult {
|
class RequirementResult {
|
||||||
boolean done = false;
|
boolean done = false;
|
||||||
String comment = "";
|
String comment = "";
|
||||||
|
|
||||||
public RequirementResult(boolean done, String comment) {
|
RequirementResult(boolean done, String comment) {
|
||||||
this.done = done;
|
this.done = done;
|
||||||
this.comment = comment;
|
this.comment = comment;
|
||||||
}
|
}
|
||||||
|
@ -135,7 +144,7 @@ public class ObjectivesPlugin implements PluginBase, ConstraintsInterface {
|
||||||
else return "---";
|
else return "---";
|
||||||
}
|
}
|
||||||
|
|
||||||
public RequirementResult requirementsMet(Integer objNum) {
|
RequirementResult requirementsMet(Integer objNum) {
|
||||||
switch (objNum) {
|
switch (objNum) {
|
||||||
case 0:
|
case 0:
|
||||||
return new RequirementResult(bgIsAvailableInNS && pumpStatusIsAvailableInNS,
|
return new RequirementResult(bgIsAvailableInNS && pumpStatusIsAvailableInNS,
|
||||||
|
@ -152,7 +161,7 @@ public class ObjectivesPlugin implements PluginBase, ConstraintsInterface {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public void initializeData() {
|
void initializeData() {
|
||||||
bgIsAvailableInNS = false;
|
bgIsAvailableInNS = false;
|
||||||
pumpStatusIsAvailableInNS = false;
|
pumpStatusIsAvailableInNS = false;
|
||||||
manualEnacts = 0;
|
manualEnacts = 0;
|
||||||
|
@ -220,7 +229,7 @@ public class ObjectivesPlugin implements PluginBase, ConstraintsInterface {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void loadProgress() {
|
private void loadProgress() {
|
||||||
for (int num = 0; num < objectives.size(); num++) {
|
for (int num = 0; num < objectives.size(); num++) {
|
||||||
Objective o = objectives.get(num);
|
Objective o = objectives.get(num);
|
||||||
try {
|
try {
|
||||||
|
|
|
@ -14,8 +14,8 @@ import info.nightscout.androidaps.interfaces.PluginBase;
|
||||||
|
|
||||||
public class InsulinFastactingPlugin implements PluginBase, InsulinInterface {
|
public class InsulinFastactingPlugin implements PluginBase, InsulinInterface {
|
||||||
|
|
||||||
private static boolean fragmentEnabled = true;
|
private boolean fragmentEnabled = true;
|
||||||
private static boolean fragmentVisible = false;
|
private boolean fragmentVisible = false;
|
||||||
|
|
||||||
private static InsulinFastactingPlugin plugin = null;
|
private static InsulinFastactingPlugin plugin = null;
|
||||||
|
|
||||||
|
|
|
@ -14,8 +14,8 @@ import info.nightscout.androidaps.interfaces.PluginBase;
|
||||||
|
|
||||||
public class InsulinFastactingProlongedPlugin implements PluginBase, InsulinInterface {
|
public class InsulinFastactingProlongedPlugin implements PluginBase, InsulinInterface {
|
||||||
|
|
||||||
private static boolean fragmentEnabled = false;
|
private boolean fragmentEnabled = false;
|
||||||
private static boolean fragmentVisible = false;
|
private boolean fragmentVisible = false;
|
||||||
|
|
||||||
private static InsulinFastactingProlongedPlugin plugin = null;
|
private static InsulinFastactingProlongedPlugin plugin = null;
|
||||||
|
|
||||||
|
|
|
@ -7,8 +7,11 @@ import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
|
||||||
|
import com.crashlytics.android.Crashlytics;
|
||||||
|
|
||||||
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.ConfigBuilder.ConfigBuilderPlugin;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by mike on 17.04.2017.
|
* Created by mike on 17.04.2017.
|
||||||
|
@ -22,16 +25,22 @@ public class InsulinFragment extends Fragment {
|
||||||
|
|
||||||
public View onCreateView(LayoutInflater inflater, ViewGroup container,
|
public View onCreateView(LayoutInflater inflater, ViewGroup container,
|
||||||
Bundle savedInstanceState) {
|
Bundle savedInstanceState) {
|
||||||
View view = inflater.inflate(R.layout.insulin_fragment, container, false);
|
try {
|
||||||
|
View view = inflater.inflate(R.layout.insulin_fragment, container, false);
|
||||||
|
|
||||||
insulinName = (TextView) view.findViewById(R.id.insulin_name);
|
insulinName = (TextView) view.findViewById(R.id.insulin_name);
|
||||||
insulinComment = (TextView) view.findViewById(R.id.insulin_comment);
|
insulinComment = (TextView) view.findViewById(R.id.insulin_comment);
|
||||||
insulinDia = (TextView) view.findViewById(R.id.insulin_dia);
|
insulinDia = (TextView) view.findViewById(R.id.insulin_dia);
|
||||||
insulinGraph = (ActivityGraph) view.findViewById(R.id.insuling_graph);
|
insulinGraph = (ActivityGraph) view.findViewById(R.id.insuling_graph);
|
||||||
|
|
||||||
updateGUI();
|
updateGUI();
|
||||||
|
|
||||||
return view;
|
return view;
|
||||||
|
} catch (Exception e) {
|
||||||
|
Crashlytics.logException(e);
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -41,10 +50,10 @@ public class InsulinFragment extends Fragment {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void updateGUI() {
|
private void updateGUI() {
|
||||||
insulinName.setText(MainApp.getConfigBuilder().getActiveInsulin().getFriendlyName());
|
insulinName.setText(ConfigBuilderPlugin.getActiveInsulin().getFriendlyName());
|
||||||
insulinComment.setText(MainApp.getConfigBuilder().getActiveInsulin().getComment());
|
insulinComment.setText(ConfigBuilderPlugin.getActiveInsulin().getComment());
|
||||||
insulinDia.setText(MainApp.sResources.getText(R.string.dia) + " " + Double.toString(MainApp.getConfigBuilder().getActiveInsulin().getDia()) + "h");
|
insulinDia.setText(MainApp.sResources.getText(R.string.dia) + " " + Double.toString(ConfigBuilderPlugin.getActiveInsulin().getDia()) + "h");
|
||||||
insulinGraph.show(MainApp.getConfigBuilder().getActiveInsulin());
|
insulinGraph.show(ConfigBuilderPlugin.getActiveInsulin());
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,8 +10,8 @@ import info.nightscout.utils.SP;
|
||||||
|
|
||||||
public class InsulinOrefFreePeakPlugin extends InsulinOrefBasePlugin {
|
public class InsulinOrefFreePeakPlugin extends InsulinOrefBasePlugin {
|
||||||
|
|
||||||
private static boolean fragmentEnabled = false;
|
private boolean fragmentEnabled = false;
|
||||||
private static boolean fragmentVisible = false;
|
private boolean fragmentVisible = false;
|
||||||
|
|
||||||
private static InsulinOrefFreePeakPlugin plugin = null;
|
private static InsulinOrefFreePeakPlugin plugin = null;
|
||||||
|
|
||||||
|
|
|
@ -9,8 +9,8 @@ import info.nightscout.androidaps.R;
|
||||||
|
|
||||||
public class InsulinOrefRapidActingPlugin extends InsulinOrefBasePlugin {
|
public class InsulinOrefRapidActingPlugin extends InsulinOrefBasePlugin {
|
||||||
|
|
||||||
private static boolean fragmentEnabled = false;
|
private boolean fragmentEnabled = false;
|
||||||
private static boolean fragmentVisible = false;
|
private boolean fragmentVisible = false;
|
||||||
|
|
||||||
private static InsulinOrefRapidActingPlugin plugin = null;
|
private static InsulinOrefRapidActingPlugin plugin = null;
|
||||||
|
|
||||||
|
|
|
@ -9,8 +9,8 @@ import info.nightscout.androidaps.R;
|
||||||
|
|
||||||
public class InsulinOrefUltraRapidActingPlugin extends InsulinOrefBasePlugin {
|
public class InsulinOrefUltraRapidActingPlugin extends InsulinOrefBasePlugin {
|
||||||
|
|
||||||
private static boolean fragmentEnabled = false;
|
private boolean fragmentEnabled = false;
|
||||||
private static boolean fragmentVisible = false;
|
private boolean fragmentVisible = false;
|
||||||
|
|
||||||
private static InsulinOrefUltraRapidActingPlugin plugin = null;
|
private static InsulinOrefUltraRapidActingPlugin plugin = null;
|
||||||
|
|
||||||
|
|
|
@ -9,6 +9,7 @@ import android.view.ViewGroup;
|
||||||
import android.widget.Button;
|
import android.widget.Button;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
|
||||||
|
import com.crashlytics.android.Crashlytics;
|
||||||
import com.crashlytics.android.answers.Answers;
|
import com.crashlytics.android.answers.Answers;
|
||||||
import com.crashlytics.android.answers.CustomEvent;
|
import com.crashlytics.android.answers.CustomEvent;
|
||||||
import com.squareup.otto.Subscribe;
|
import com.squareup.otto.Subscribe;
|
||||||
|
@ -25,15 +26,6 @@ import info.nightscout.androidaps.plugins.Loop.events.EventLoopUpdateGui;
|
||||||
public class LoopFragment extends SubscriberFragment implements View.OnClickListener {
|
public class LoopFragment extends SubscriberFragment implements View.OnClickListener {
|
||||||
private static Logger log = LoggerFactory.getLogger(LoopFragment.class);
|
private static Logger log = LoggerFactory.getLogger(LoopFragment.class);
|
||||||
|
|
||||||
private static LoopPlugin loopPlugin;
|
|
||||||
|
|
||||||
public static LoopPlugin getPlugin() {
|
|
||||||
if (loopPlugin == null){
|
|
||||||
loopPlugin = new LoopPlugin();
|
|
||||||
}
|
|
||||||
return loopPlugin;
|
|
||||||
}
|
|
||||||
|
|
||||||
Button runNowButton;
|
Button runNowButton;
|
||||||
TextView lastRunView;
|
TextView lastRunView;
|
||||||
TextView lastEnactView;
|
TextView lastEnactView;
|
||||||
|
@ -46,19 +38,25 @@ public class LoopFragment extends SubscriberFragment implements View.OnClickList
|
||||||
@Override
|
@Override
|
||||||
public View onCreateView(LayoutInflater inflater, ViewGroup container,
|
public View onCreateView(LayoutInflater inflater, ViewGroup container,
|
||||||
Bundle savedInstanceState) {
|
Bundle savedInstanceState) {
|
||||||
View view = inflater.inflate(R.layout.loop_fragment, container, false);
|
try {
|
||||||
|
View view = inflater.inflate(R.layout.loop_fragment, container, false);
|
||||||
|
|
||||||
lastRunView = (TextView) view.findViewById(R.id.loop_lastrun);
|
lastRunView = (TextView) view.findViewById(R.id.loop_lastrun);
|
||||||
lastEnactView = (TextView) view.findViewById(R.id.loop_lastenact);
|
lastEnactView = (TextView) view.findViewById(R.id.loop_lastenact);
|
||||||
sourceView = (TextView) view.findViewById(R.id.loop_source);
|
sourceView = (TextView) view.findViewById(R.id.loop_source);
|
||||||
requestView = (TextView) view.findViewById(R.id.loop_request);
|
requestView = (TextView) view.findViewById(R.id.loop_request);
|
||||||
constraintsProcessedView = (TextView) view.findViewById(R.id.loop_constraintsprocessed);
|
constraintsProcessedView = (TextView) view.findViewById(R.id.loop_constraintsprocessed);
|
||||||
setByPumpView = (TextView) view.findViewById(R.id.loop_setbypump);
|
setByPumpView = (TextView) view.findViewById(R.id.loop_setbypump);
|
||||||
runNowButton = (Button) view.findViewById(R.id.loop_run);
|
runNowButton = (Button) view.findViewById(R.id.loop_run);
|
||||||
runNowButton.setOnClickListener(this);
|
runNowButton.setOnClickListener(this);
|
||||||
|
|
||||||
updateGUI();
|
updateGUI();
|
||||||
return view;
|
return view;
|
||||||
|
} catch (Exception e) {
|
||||||
|
Crashlytics.logException(e);
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -69,7 +67,7 @@ public class LoopFragment extends SubscriberFragment implements View.OnClickList
|
||||||
Thread thread = new Thread(new Runnable() {
|
Thread thread = new Thread(new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
getPlugin().invoke("Loop button", true);
|
LoopPlugin.getPlugin().invoke("Loop button", true);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
thread.start();
|
thread.start();
|
||||||
|
@ -105,13 +103,13 @@ public class LoopFragment extends SubscriberFragment implements View.OnClickList
|
||||||
activity.runOnUiThread(new Runnable() {
|
activity.runOnUiThread(new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
if (getPlugin().lastRun != null) {
|
if (LoopPlugin.lastRun != null) {
|
||||||
requestView.setText(getPlugin().lastRun.request != null ? getPlugin().lastRun.request.toSpanned() : "");
|
requestView.setText(LoopPlugin.lastRun.request != null ? LoopPlugin.lastRun.request.toSpanned() : "");
|
||||||
constraintsProcessedView.setText(getPlugin().lastRun.constraintsProcessed != null ? getPlugin().lastRun.constraintsProcessed.toSpanned() : "");
|
constraintsProcessedView.setText(LoopPlugin.lastRun.constraintsProcessed != null ? LoopPlugin.lastRun.constraintsProcessed.toSpanned() : "");
|
||||||
setByPumpView.setText(getPlugin().lastRun.setByPump != null ? getPlugin().lastRun.setByPump.toSpanned() : "");
|
setByPumpView.setText(LoopPlugin.lastRun.setByPump != null ? LoopPlugin.lastRun.setByPump.toSpanned() : "");
|
||||||
sourceView.setText(getPlugin().lastRun.source != null ? getPlugin().lastRun.source : "");
|
sourceView.setText(LoopPlugin.lastRun.source != null ? LoopPlugin.lastRun.source : "");
|
||||||
lastRunView.setText(getPlugin().lastRun.lastAPSRun != null && getPlugin().lastRun.lastAPSRun.getTime() != 0 ? getPlugin().lastRun.lastAPSRun.toLocaleString() : "");
|
lastRunView.setText(LoopPlugin.lastRun.lastAPSRun != null && LoopPlugin.lastRun.lastAPSRun.getTime() != 0 ? LoopPlugin.lastRun.lastAPSRun.toLocaleString() : "");
|
||||||
lastEnactView.setText(getPlugin().lastRun.lastEnact != null && getPlugin().lastRun.lastEnact.getTime() != 0 ? getPlugin().lastRun.lastEnact.toLocaleString() : "");
|
lastEnactView.setText(LoopPlugin.lastRun.lastEnact != null && LoopPlugin.lastRun.lastEnact.getTime() != 0 ? LoopPlugin.lastRun.lastEnact.toLocaleString() : "");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
|
@ -46,6 +46,15 @@ import info.nightscout.utils.SafeParse;
|
||||||
public class LoopPlugin implements PluginBase {
|
public class LoopPlugin implements PluginBase {
|
||||||
private static Logger log = LoggerFactory.getLogger(LoopPlugin.class);
|
private static Logger log = LoggerFactory.getLogger(LoopPlugin.class);
|
||||||
|
|
||||||
|
private static LoopPlugin loopPlugin;
|
||||||
|
|
||||||
|
public static LoopPlugin getPlugin() {
|
||||||
|
if (loopPlugin == null) {
|
||||||
|
loopPlugin = new LoopPlugin();
|
||||||
|
}
|
||||||
|
return loopPlugin;
|
||||||
|
}
|
||||||
|
|
||||||
private static Handler sHandler;
|
private static Handler sHandler;
|
||||||
private static HandlerThread sHandlerThread;
|
private static HandlerThread sHandlerThread;
|
||||||
|
|
||||||
|
|
|
@ -18,6 +18,7 @@ import android.widget.CompoundButton;
|
||||||
import android.widget.ScrollView;
|
import android.widget.ScrollView;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
|
||||||
|
import com.crashlytics.android.Crashlytics;
|
||||||
import com.crashlytics.android.answers.Answers;
|
import com.crashlytics.android.answers.Answers;
|
||||||
import com.crashlytics.android.answers.CustomEvent;
|
import com.crashlytics.android.answers.CustomEvent;
|
||||||
import com.squareup.otto.Subscribe;
|
import com.squareup.otto.Subscribe;
|
||||||
|
@ -37,15 +38,6 @@ import info.nightscout.utils.SP;
|
||||||
public class NSClientInternalFragment extends SubscriberFragment implements View.OnClickListener, CompoundButton.OnCheckedChangeListener {
|
public class NSClientInternalFragment extends SubscriberFragment implements View.OnClickListener, CompoundButton.OnCheckedChangeListener {
|
||||||
private static Logger log = LoggerFactory.getLogger(NSClientInternalFragment.class);
|
private static Logger log = LoggerFactory.getLogger(NSClientInternalFragment.class);
|
||||||
|
|
||||||
static NSClientInternalPlugin nsClientInternalPlugin;
|
|
||||||
|
|
||||||
static public NSClientInternalPlugin getPlugin() {
|
|
||||||
if (nsClientInternalPlugin == null) {
|
|
||||||
nsClientInternalPlugin = new NSClientInternalPlugin();
|
|
||||||
}
|
|
||||||
return nsClientInternalPlugin;
|
|
||||||
}
|
|
||||||
|
|
||||||
private TextView logTextView;
|
private TextView logTextView;
|
||||||
private TextView queueTextView;
|
private TextView queueTextView;
|
||||||
private TextView urlTextView;
|
private TextView urlTextView;
|
||||||
|
@ -62,38 +54,44 @@ public class NSClientInternalFragment extends SubscriberFragment implements View
|
||||||
@Override
|
@Override
|
||||||
public View onCreateView(LayoutInflater inflater, ViewGroup container,
|
public View onCreateView(LayoutInflater inflater, ViewGroup container,
|
||||||
Bundle savedInstanceState) {
|
Bundle savedInstanceState) {
|
||||||
View view = inflater.inflate(R.layout.nsclientinternal_fragment, container, false);
|
try {
|
||||||
|
View view = inflater.inflate(R.layout.nsclientinternal_fragment, container, false);
|
||||||
|
|
||||||
logScrollview = (ScrollView) view.findViewById(R.id.nsclientinternal_logscrollview);
|
logScrollview = (ScrollView) view.findViewById(R.id.nsclientinternal_logscrollview);
|
||||||
autoscrollCheckbox = (CheckBox) view.findViewById(R.id.nsclientinternal_autoscroll);
|
autoscrollCheckbox = (CheckBox) view.findViewById(R.id.nsclientinternal_autoscroll);
|
||||||
autoscrollCheckbox.setChecked(getPlugin().autoscroll);
|
autoscrollCheckbox.setChecked(NSClientInternalPlugin.getPlugin().autoscroll);
|
||||||
autoscrollCheckbox.setOnCheckedChangeListener(this);
|
autoscrollCheckbox.setOnCheckedChangeListener(this);
|
||||||
pausedCheckbox = (CheckBox) view.findViewById(R.id.nsclientinternal_paused);
|
pausedCheckbox = (CheckBox) view.findViewById(R.id.nsclientinternal_paused);
|
||||||
pausedCheckbox.setChecked(getPlugin().paused);
|
pausedCheckbox.setChecked(NSClientInternalPlugin.getPlugin().paused);
|
||||||
pausedCheckbox.setOnCheckedChangeListener(this);
|
pausedCheckbox.setOnCheckedChangeListener(this);
|
||||||
logTextView = (TextView) view.findViewById(R.id.nsclientinternal_log);
|
logTextView = (TextView) view.findViewById(R.id.nsclientinternal_log);
|
||||||
queueTextView = (TextView) view.findViewById(R.id.nsclientinternal_queue);
|
queueTextView = (TextView) view.findViewById(R.id.nsclientinternal_queue);
|
||||||
urlTextView = (TextView) view.findViewById(R.id.nsclientinternal_url);
|
urlTextView = (TextView) view.findViewById(R.id.nsclientinternal_url);
|
||||||
statusTextView = (TextView) view.findViewById(R.id.nsclientinternal_status);
|
statusTextView = (TextView) view.findViewById(R.id.nsclientinternal_status);
|
||||||
|
|
||||||
clearlog = (TextView) view.findViewById(R.id.nsclientinternal_clearlog);
|
clearlog = (TextView) view.findViewById(R.id.nsclientinternal_clearlog);
|
||||||
clearlog.setOnClickListener(this);
|
clearlog.setOnClickListener(this);
|
||||||
clearlog.setPaintFlags(clearlog.getPaintFlags() | Paint.UNDERLINE_TEXT_FLAG);
|
clearlog.setPaintFlags(clearlog.getPaintFlags() | Paint.UNDERLINE_TEXT_FLAG);
|
||||||
restart = (TextView) view.findViewById(R.id.nsclientinternal_restart);
|
restart = (TextView) view.findViewById(R.id.nsclientinternal_restart);
|
||||||
restart.setOnClickListener(this);
|
restart.setOnClickListener(this);
|
||||||
restart.setPaintFlags(restart.getPaintFlags() | Paint.UNDERLINE_TEXT_FLAG);
|
restart.setPaintFlags(restart.getPaintFlags() | Paint.UNDERLINE_TEXT_FLAG);
|
||||||
delivernow = (TextView) view.findViewById(R.id.nsclientinternal_delivernow);
|
delivernow = (TextView) view.findViewById(R.id.nsclientinternal_delivernow);
|
||||||
delivernow.setOnClickListener(this);
|
delivernow.setOnClickListener(this);
|
||||||
delivernow.setPaintFlags(delivernow.getPaintFlags() | Paint.UNDERLINE_TEXT_FLAG);
|
delivernow.setPaintFlags(delivernow.getPaintFlags() | Paint.UNDERLINE_TEXT_FLAG);
|
||||||
clearqueue = (TextView) view.findViewById(R.id.nsclientinternal_clearqueue);
|
clearqueue = (TextView) view.findViewById(R.id.nsclientinternal_clearqueue);
|
||||||
clearqueue.setOnClickListener(this);
|
clearqueue.setOnClickListener(this);
|
||||||
clearqueue.setPaintFlags(clearqueue.getPaintFlags() | Paint.UNDERLINE_TEXT_FLAG);
|
clearqueue.setPaintFlags(clearqueue.getPaintFlags() | Paint.UNDERLINE_TEXT_FLAG);
|
||||||
showqueue = (TextView) view.findViewById(R.id.nsclientinternal_showqueue);
|
showqueue = (TextView) view.findViewById(R.id.nsclientinternal_showqueue);
|
||||||
showqueue.setOnClickListener(this);
|
showqueue.setOnClickListener(this);
|
||||||
showqueue.setPaintFlags(showqueue.getPaintFlags() | Paint.UNDERLINE_TEXT_FLAG);
|
showqueue.setPaintFlags(showqueue.getPaintFlags() | Paint.UNDERLINE_TEXT_FLAG);
|
||||||
|
|
||||||
updateGUI();
|
updateGUI();
|
||||||
return view;
|
return view;
|
||||||
|
} catch (Exception e) {
|
||||||
|
Crashlytics.logException(e);
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -104,11 +102,11 @@ public class NSClientInternalFragment extends SubscriberFragment implements View
|
||||||
Answers.getInstance().logCustom(new CustomEvent("NSClientRestart"));
|
Answers.getInstance().logCustom(new CustomEvent("NSClientRestart"));
|
||||||
break;
|
break;
|
||||||
case R.id.nsclientinternal_delivernow:
|
case R.id.nsclientinternal_delivernow:
|
||||||
getPlugin().resend("GUI");
|
NSClientInternalPlugin.getPlugin().resend("GUI");
|
||||||
Answers.getInstance().logCustom(new CustomEvent("NSClientDeliverNow"));
|
Answers.getInstance().logCustom(new CustomEvent("NSClientDeliverNow"));
|
||||||
break;
|
break;
|
||||||
case R.id.nsclientinternal_clearlog:
|
case R.id.nsclientinternal_clearlog:
|
||||||
getPlugin().clearLog();
|
NSClientInternalPlugin.getPlugin().clearLog();
|
||||||
break;
|
break;
|
||||||
case R.id.nsclientinternal_clearqueue:
|
case R.id.nsclientinternal_clearqueue:
|
||||||
final Context context = getContext();
|
final Context context = getContext();
|
||||||
|
@ -127,7 +125,7 @@ public class NSClientInternalFragment extends SubscriberFragment implements View
|
||||||
builder.show();
|
builder.show();
|
||||||
break;
|
break;
|
||||||
case R.id.nsclientinternal_showqueue:
|
case R.id.nsclientinternal_showqueue:
|
||||||
MainApp.bus().post(new EventNSClientNewLog("QUEUE", getPlugin().queue().textList()));
|
MainApp.bus().post(new EventNSClientNewLog("QUEUE", NSClientInternalPlugin.getPlugin().queue().textList()));
|
||||||
Answers.getInstance().logCustom(new CustomEvent("NSClientShowQueue"));
|
Answers.getInstance().logCustom(new CustomEvent("NSClientShowQueue"));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -138,14 +136,14 @@ public class NSClientInternalFragment extends SubscriberFragment implements View
|
||||||
switch (buttonView.getId()) {
|
switch (buttonView.getId()) {
|
||||||
case R.id.nsclientinternal_paused:
|
case R.id.nsclientinternal_paused:
|
||||||
SP.putBoolean(R.string.key_nsclientinternal_paused, isChecked);
|
SP.putBoolean(R.string.key_nsclientinternal_paused, isChecked);
|
||||||
getPlugin().paused = isChecked;
|
NSClientInternalPlugin.getPlugin().paused = isChecked;
|
||||||
MainApp.bus().post(new EventPreferenceChange(R.string.key_nsclientinternal_paused));
|
MainApp.bus().post(new EventPreferenceChange(R.string.key_nsclientinternal_paused));
|
||||||
updateGUI();
|
updateGUI();
|
||||||
Answers.getInstance().logCustom(new CustomEvent("NSClientPause"));
|
Answers.getInstance().logCustom(new CustomEvent("NSClientPause"));
|
||||||
break;
|
break;
|
||||||
case R.id.nsclientinternal_autoscroll:
|
case R.id.nsclientinternal_autoscroll:
|
||||||
SP.putBoolean(R.string.key_nsclientinternal_autoscroll, isChecked);
|
SP.putBoolean(R.string.key_nsclientinternal_autoscroll, isChecked);
|
||||||
getPlugin().autoscroll = isChecked;
|
NSClientInternalPlugin.getPlugin().autoscroll = isChecked;
|
||||||
updateGUI();
|
updateGUI();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -165,13 +163,13 @@ public class NSClientInternalFragment extends SubscriberFragment implements View
|
||||||
public void run() {
|
public void run() {
|
||||||
NSClientInternalPlugin.updateLog();
|
NSClientInternalPlugin.updateLog();
|
||||||
logTextView.setText(NSClientInternalPlugin.textLog);
|
logTextView.setText(NSClientInternalPlugin.textLog);
|
||||||
if (getPlugin().autoscroll) {
|
if (NSClientInternalPlugin.getPlugin().autoscroll) {
|
||||||
logScrollview.fullScroll(ScrollView.FOCUS_DOWN);
|
logScrollview.fullScroll(ScrollView.FOCUS_DOWN);
|
||||||
}
|
}
|
||||||
urlTextView.setText(getPlugin().url());
|
urlTextView.setText(NSClientInternalPlugin.getPlugin().url());
|
||||||
Spanned queuetext = Html.fromHtml(MainApp.sResources.getString(R.string.queue) + " <b>" + UploadQueue.size() + "</b>");
|
Spanned queuetext = Html.fromHtml(MainApp.sResources.getString(R.string.queue) + " <b>" + UploadQueue.size() + "</b>");
|
||||||
queueTextView.setText(queuetext);
|
queueTextView.setText(queuetext);
|
||||||
statusTextView.setText(getPlugin().status);
|
statusTextView.setText(NSClientInternalPlugin.getPlugin().status);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -34,6 +34,15 @@ import info.nightscout.utils.ToastUtils;
|
||||||
public class NSClientInternalPlugin implements PluginBase {
|
public class NSClientInternalPlugin implements PluginBase {
|
||||||
private static Logger log = LoggerFactory.getLogger(NSClientInternalPlugin.class);
|
private static Logger log = LoggerFactory.getLogger(NSClientInternalPlugin.class);
|
||||||
|
|
||||||
|
static NSClientInternalPlugin nsClientInternalPlugin;
|
||||||
|
|
||||||
|
static public NSClientInternalPlugin getPlugin() {
|
||||||
|
if (nsClientInternalPlugin == null) {
|
||||||
|
nsClientInternalPlugin = new NSClientInternalPlugin();
|
||||||
|
}
|
||||||
|
return nsClientInternalPlugin;
|
||||||
|
}
|
||||||
|
|
||||||
private boolean fragmentEnabled = true;
|
private boolean fragmentEnabled = true;
|
||||||
private boolean fragmentVisible = true;
|
private boolean fragmentVisible = true;
|
||||||
|
|
||||||
|
|
|
@ -67,4 +67,31 @@ public class BroadcastDeviceStatus {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void handleNewFoods(JSONArray foods, Context context, boolean isDelta) {
|
||||||
|
|
||||||
|
List<JSONArray> splitted = BroadcastTreatment.splitArray(foods);
|
||||||
|
for (JSONArray part: splitted) {
|
||||||
|
Bundle bundle = new Bundle();
|
||||||
|
bundle.putString("foods", part.toString());
|
||||||
|
bundle.putBoolean("delta", isDelta);
|
||||||
|
Intent intent = new Intent(Intents.ACTION_NEW_FOOD);
|
||||||
|
intent.putExtras(bundle);
|
||||||
|
intent.addFlags(Intent.FLAG_INCLUDE_STOPPED_PACKAGES);
|
||||||
|
LocalBroadcastManager.getInstance(MainApp.instance()).sendBroadcast(intent);
|
||||||
|
}
|
||||||
|
|
||||||
|
if(SP.getBoolean(R.string.key_nsclient_localbroadcasts, true)) {
|
||||||
|
splitted = BroadcastTreatment.splitArray(foods);
|
||||||
|
for (JSONArray part : splitted) {
|
||||||
|
Bundle bundle = new Bundle();
|
||||||
|
bundle.putString("foods", part.toString());
|
||||||
|
bundle.putBoolean("delta", isDelta);
|
||||||
|
Intent intent = new Intent(Intents.ACTION_NEW_FOOD);
|
||||||
|
intent.putExtras(bundle);
|
||||||
|
intent.addFlags(Intent.FLAG_INCLUDE_STOPPED_PACKAGES);
|
||||||
|
context.sendBroadcast(intent);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,104 @@
|
||||||
|
package info.nightscout.androidaps.plugins.NSClientInternal.broadcasts;
|
||||||
|
|
||||||
|
import android.content.Context;
|
||||||
|
import android.content.Intent;
|
||||||
|
import android.os.Bundle;
|
||||||
|
import android.support.v4.content.LocalBroadcastManager;
|
||||||
|
|
||||||
|
import org.json.JSONArray;
|
||||||
|
import org.json.JSONException;
|
||||||
|
import org.json.JSONObject;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import info.nightscout.androidaps.MainApp;
|
||||||
|
import info.nightscout.androidaps.R;
|
||||||
|
import info.nightscout.androidaps.Services.Intents;
|
||||||
|
import info.nightscout.androidaps.plugins.NSClientInternal.data.NSTreatment;
|
||||||
|
import info.nightscout.utils.SP;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Created by mike on 20.02.2016.
|
||||||
|
*/
|
||||||
|
public class BroadcastFood {
|
||||||
|
private static Logger log = LoggerFactory.getLogger(BroadcastFood.class);
|
||||||
|
|
||||||
|
public static void handleNewFood(JSONArray foods, Context context, boolean isDelta) {
|
||||||
|
|
||||||
|
List<JSONArray> splitted = BroadcastTreatment.splitArray(foods);
|
||||||
|
for (JSONArray part : splitted) {
|
||||||
|
Bundle bundle = new Bundle();
|
||||||
|
bundle.putString("foods", part.toString());
|
||||||
|
bundle.putBoolean("delta", isDelta);
|
||||||
|
Intent intent = new Intent(Intents.ACTION_NEW_FOOD);
|
||||||
|
intent.putExtras(bundle);
|
||||||
|
intent.addFlags(Intent.FLAG_INCLUDE_STOPPED_PACKAGES);
|
||||||
|
LocalBroadcastManager.getInstance(MainApp.instance()).sendBroadcast(intent);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (SP.getBoolean(R.string.key_nsclient_localbroadcasts, true)) {
|
||||||
|
for (JSONArray part : splitted) {
|
||||||
|
Bundle bundle = new Bundle();
|
||||||
|
bundle.putString("foods", part.toString());
|
||||||
|
bundle.putBoolean("delta", isDelta);
|
||||||
|
Intent intent = new Intent(Intents.ACTION_NEW_FOOD);
|
||||||
|
intent.putExtras(bundle);
|
||||||
|
intent.addFlags(Intent.FLAG_INCLUDE_STOPPED_PACKAGES);
|
||||||
|
context.sendBroadcast(intent);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void handleChangedFood(JSONArray foods, Context context, boolean isDelta) {
|
||||||
|
|
||||||
|
List<JSONArray> splitted = BroadcastTreatment.splitArray(foods);
|
||||||
|
for (JSONArray part : splitted) {
|
||||||
|
Bundle bundle = new Bundle();
|
||||||
|
bundle.putString("foods", part.toString());
|
||||||
|
bundle.putBoolean("delta", isDelta);
|
||||||
|
Intent intent = new Intent(Intents.ACTION_CHANGED_FOOD);
|
||||||
|
intent.putExtras(bundle);
|
||||||
|
intent.addFlags(Intent.FLAG_INCLUDE_STOPPED_PACKAGES);
|
||||||
|
LocalBroadcastManager.getInstance(MainApp.instance()).sendBroadcast(intent);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (SP.getBoolean(R.string.key_nsclient_localbroadcasts, true)) {
|
||||||
|
for (JSONArray part : splitted) {
|
||||||
|
Bundle bundle = new Bundle();
|
||||||
|
bundle.putString("foods", part.toString());
|
||||||
|
bundle.putBoolean("delta", isDelta);
|
||||||
|
Intent intent = new Intent(Intents.ACTION_CHANGED_FOOD);
|
||||||
|
intent.putExtras(bundle);
|
||||||
|
intent.addFlags(Intent.FLAG_INCLUDE_STOPPED_PACKAGES);
|
||||||
|
context.sendBroadcast(intent);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void handleRemovedFood(JSONArray foods, Context context, boolean isDelta) {
|
||||||
|
|
||||||
|
Bundle bundle = new Bundle();
|
||||||
|
bundle.putString("foods", foods.toString());
|
||||||
|
bundle.putBoolean("delta", isDelta);
|
||||||
|
Intent intent = new Intent(Intents.ACTION_REMOVED_FOOD);
|
||||||
|
intent.putExtras(bundle);
|
||||||
|
intent.addFlags(Intent.FLAG_INCLUDE_STOPPED_PACKAGES);
|
||||||
|
LocalBroadcastManager.getInstance(MainApp.instance()).sendBroadcast(intent);
|
||||||
|
|
||||||
|
|
||||||
|
if (SP.getBoolean(R.string.key_nsclient_localbroadcasts, true)) {
|
||||||
|
bundle = new Bundle();
|
||||||
|
bundle.putString("foods", foods.toString());
|
||||||
|
bundle.putBoolean("delta", isDelta);
|
||||||
|
intent = new Intent(Intents.ACTION_REMOVED_FOOD);
|
||||||
|
intent.putExtras(bundle);
|
||||||
|
intent.addFlags(Intent.FLAG_INCLUDE_STOPPED_PACKAGES);
|
||||||
|
context.sendBroadcast(intent);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
|
@ -43,6 +43,7 @@ import info.nightscout.androidaps.plugins.NSClientInternal.broadcasts.BroadcastA
|
||||||
import info.nightscout.androidaps.plugins.NSClientInternal.broadcasts.BroadcastCals;
|
import info.nightscout.androidaps.plugins.NSClientInternal.broadcasts.BroadcastCals;
|
||||||
import info.nightscout.androidaps.plugins.NSClientInternal.broadcasts.BroadcastClearAlarm;
|
import info.nightscout.androidaps.plugins.NSClientInternal.broadcasts.BroadcastClearAlarm;
|
||||||
import info.nightscout.androidaps.plugins.NSClientInternal.broadcasts.BroadcastDeviceStatus;
|
import info.nightscout.androidaps.plugins.NSClientInternal.broadcasts.BroadcastDeviceStatus;
|
||||||
|
import info.nightscout.androidaps.plugins.NSClientInternal.broadcasts.BroadcastFood;
|
||||||
import info.nightscout.androidaps.plugins.NSClientInternal.broadcasts.BroadcastMbgs;
|
import info.nightscout.androidaps.plugins.NSClientInternal.broadcasts.BroadcastMbgs;
|
||||||
import info.nightscout.androidaps.plugins.NSClientInternal.broadcasts.BroadcastProfile;
|
import info.nightscout.androidaps.plugins.NSClientInternal.broadcasts.BroadcastProfile;
|
||||||
import info.nightscout.androidaps.plugins.NSClientInternal.broadcasts.BroadcastSgvs;
|
import info.nightscout.androidaps.plugins.NSClientInternal.broadcasts.BroadcastSgvs;
|
||||||
|
@ -519,6 +520,55 @@ public class NSClientService extends Service {
|
||||||
BroadcastDeviceStatus.handleNewDeviceStatus(devicestatuses, MainApp.instance().getApplicationContext(), isDelta);
|
BroadcastDeviceStatus.handleNewDeviceStatus(devicestatuses, MainApp.instance().getApplicationContext(), isDelta);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (data.has("food")) {
|
||||||
|
JSONArray foods = data.getJSONArray("food");
|
||||||
|
JSONArray removedFoods = new JSONArray();
|
||||||
|
JSONArray updatedFoods = new JSONArray();
|
||||||
|
JSONArray addedFoods = new JSONArray();
|
||||||
|
if (foods.length() > 0)
|
||||||
|
MainApp.bus().post(new EventNSClientNewLog("DATA", "received " + foods.length() + " foods"));
|
||||||
|
for (Integer index = 0; index < foods.length(); index++) {
|
||||||
|
JSONObject jsonFood = foods.getJSONObject(index);
|
||||||
|
NSTreatment treatment = new NSTreatment(jsonFood);
|
||||||
|
|
||||||
|
// remove from upload queue if Ack is failing
|
||||||
|
UploadQueue.removeID(jsonFood);
|
||||||
|
//Find latest date in treatment
|
||||||
|
if (treatment.getMills() != null && treatment.getMills() < System.currentTimeMillis())
|
||||||
|
if (treatment.getMills() > latestDateInReceivedData)
|
||||||
|
latestDateInReceivedData = treatment.getMills();
|
||||||
|
|
||||||
|
if (treatment.getAction() == null) {
|
||||||
|
addedFoods.put(jsonFood);
|
||||||
|
} else if (treatment.getAction().equals("update")) {
|
||||||
|
updatedFoods.put(jsonFood);
|
||||||
|
} else if (treatment.getAction().equals("remove")) {
|
||||||
|
if (treatment.getMills() != null && treatment.getMills() > System.currentTimeMillis() - 24 * 60 * 60 * 1000L) // handle 1 day old deletions only
|
||||||
|
removedFoods.put(jsonFood);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (removedFoods.length() > 0) {
|
||||||
|
BroadcastFood.handleRemovedFood(removedFoods, MainApp.instance().getApplicationContext(), isDelta);
|
||||||
|
}
|
||||||
|
if (updatedFoods.length() > 0) {
|
||||||
|
BroadcastFood.handleChangedFood(updatedFoods, MainApp.instance().getApplicationContext(), isDelta);
|
||||||
|
}
|
||||||
|
if (addedFoods.length() > 0) {
|
||||||
|
BroadcastFood.handleNewFood(addedFoods, MainApp.instance().getApplicationContext(), isDelta);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (data.has("")) {
|
||||||
|
JSONArray foods = data.getJSONArray("food");
|
||||||
|
if (foods.length() > 0) {
|
||||||
|
MainApp.bus().post(new EventNSClientNewLog("DATA", "received " + foods.length() + " foods"));
|
||||||
|
for (Integer index = 0; index < foods.length(); index++) {
|
||||||
|
JSONObject jsonFood = foods.getJSONObject(index);
|
||||||
|
// remove from upload queue if Ack is failing
|
||||||
|
UploadQueue.removeID(jsonFood);
|
||||||
|
}
|
||||||
|
BroadcastDeviceStatus.handleNewFoods(foods, MainApp.instance().getApplicationContext(), isDelta);
|
||||||
|
}
|
||||||
|
}
|
||||||
if (data.has("mbgs")) {
|
if (data.has("mbgs")) {
|
||||||
JSONArray mbgs = data.getJSONArray("mbgs");
|
JSONArray mbgs = data.getJSONArray("mbgs");
|
||||||
if (mbgs.length() > 0)
|
if (mbgs.length() > 0)
|
||||||
|
|
|
@ -9,6 +9,7 @@ import android.view.ViewGroup;
|
||||||
import android.widget.Button;
|
import android.widget.Button;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
|
||||||
|
import com.crashlytics.android.Crashlytics;
|
||||||
import com.crashlytics.android.answers.Answers;
|
import com.crashlytics.android.answers.Answers;
|
||||||
import com.crashlytics.android.answers.CustomEvent;
|
import com.crashlytics.android.answers.CustomEvent;
|
||||||
import com.squareup.otto.Subscribe;
|
import com.squareup.otto.Subscribe;
|
||||||
|
@ -28,15 +29,6 @@ import info.nightscout.utils.JSONFormatter;
|
||||||
public class OpenAPSAMAFragment extends SubscriberFragment implements View.OnClickListener {
|
public class OpenAPSAMAFragment extends SubscriberFragment implements View.OnClickListener {
|
||||||
private static Logger log = LoggerFactory.getLogger(OpenAPSAMAFragment.class);
|
private static Logger log = LoggerFactory.getLogger(OpenAPSAMAFragment.class);
|
||||||
|
|
||||||
private static OpenAPSAMAPlugin openAPSAMAPlugin;
|
|
||||||
|
|
||||||
public static OpenAPSAMAPlugin getPlugin() {
|
|
||||||
if(openAPSAMAPlugin ==null){
|
|
||||||
openAPSAMAPlugin = new OpenAPSAMAPlugin();
|
|
||||||
}
|
|
||||||
return openAPSAMAPlugin;
|
|
||||||
}
|
|
||||||
|
|
||||||
Button run;
|
Button run;
|
||||||
TextView lastRunView;
|
TextView lastRunView;
|
||||||
TextView glucoseStatusView;
|
TextView glucoseStatusView;
|
||||||
|
@ -52,30 +44,36 @@ public class OpenAPSAMAFragment extends SubscriberFragment implements View.OnCli
|
||||||
@Override
|
@Override
|
||||||
public View onCreateView(LayoutInflater inflater, ViewGroup container,
|
public View onCreateView(LayoutInflater inflater, ViewGroup container,
|
||||||
Bundle savedInstanceState) {
|
Bundle savedInstanceState) {
|
||||||
View view = inflater.inflate(R.layout.openapsama_fragment, container, false);
|
try {
|
||||||
|
View view = inflater.inflate(R.layout.openapsama_fragment, container, false);
|
||||||
|
|
||||||
run = (Button) view.findViewById(R.id.openapsma_run);
|
run = (Button) view.findViewById(R.id.openapsma_run);
|
||||||
run.setOnClickListener(this);
|
run.setOnClickListener(this);
|
||||||
lastRunView = (TextView) view.findViewById(R.id.openapsma_lastrun);
|
lastRunView = (TextView) view.findViewById(R.id.openapsma_lastrun);
|
||||||
glucoseStatusView = (TextView) view.findViewById(R.id.openapsma_glucosestatus);
|
glucoseStatusView = (TextView) view.findViewById(R.id.openapsma_glucosestatus);
|
||||||
currentTempView = (TextView) view.findViewById(R.id.openapsma_currenttemp);
|
currentTempView = (TextView) view.findViewById(R.id.openapsma_currenttemp);
|
||||||
iobDataView = (TextView) view.findViewById(R.id.openapsma_iobdata);
|
iobDataView = (TextView) view.findViewById(R.id.openapsma_iobdata);
|
||||||
profileView = (TextView) view.findViewById(R.id.openapsma_profile);
|
profileView = (TextView) view.findViewById(R.id.openapsma_profile);
|
||||||
mealDataView = (TextView) view.findViewById(R.id.openapsma_mealdata);
|
mealDataView = (TextView) view.findViewById(R.id.openapsma_mealdata);
|
||||||
autosensDataView = (TextView) view.findViewById(R.id.openapsma_autosensdata);
|
autosensDataView = (TextView) view.findViewById(R.id.openapsma_autosensdata);
|
||||||
scriptdebugView = (TextView) view.findViewById(R.id.openapsma_scriptdebugdata);
|
scriptdebugView = (TextView) view.findViewById(R.id.openapsma_scriptdebugdata);
|
||||||
resultView = (TextView) view.findViewById(R.id.openapsma_result);
|
resultView = (TextView) view.findViewById(R.id.openapsma_result);
|
||||||
requestView = (TextView) view.findViewById(R.id.openapsma_request);
|
requestView = (TextView) view.findViewById(R.id.openapsma_request);
|
||||||
|
|
||||||
updateGUI();
|
updateGUI();
|
||||||
return view;
|
return view;
|
||||||
|
} catch (Exception e) {
|
||||||
|
Crashlytics.logException(e);
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View view) {
|
public void onClick(View view) {
|
||||||
switch (view.getId()) {
|
switch (view.getId()) {
|
||||||
case R.id.openapsma_run:
|
case R.id.openapsma_run:
|
||||||
getPlugin().invoke("OpenAPSAMA button");
|
OpenAPSAMAPlugin.getPlugin().invoke("OpenAPSAMA button");
|
||||||
Answers.getInstance().logCustom(new CustomEvent("OpenAPS_AMA_Run"));
|
Answers.getInstance().logCustom(new CustomEvent("OpenAPS_AMA_Run"));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -99,12 +97,12 @@ public class OpenAPSAMAFragment extends SubscriberFragment implements View.OnCli
|
||||||
activity.runOnUiThread(new Runnable() {
|
activity.runOnUiThread(new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
DetermineBasalResultAMA lastAPSResult = getPlugin().lastAPSResult;
|
DetermineBasalResultAMA lastAPSResult = OpenAPSAMAPlugin.getPlugin().lastAPSResult;
|
||||||
if (lastAPSResult != null) {
|
if (lastAPSResult != null) {
|
||||||
resultView.setText(JSONFormatter.format(lastAPSResult.json));
|
resultView.setText(JSONFormatter.format(lastAPSResult.json));
|
||||||
requestView.setText(lastAPSResult.toSpanned());
|
requestView.setText(lastAPSResult.toSpanned());
|
||||||
}
|
}
|
||||||
DetermineBasalAdapterAMAJS determineBasalAdapterAMAJS = getPlugin().lastDetermineBasalAdapterAMAJS;
|
DetermineBasalAdapterAMAJS determineBasalAdapterAMAJS = OpenAPSAMAPlugin.getPlugin().lastDetermineBasalAdapterAMAJS;
|
||||||
if (determineBasalAdapterAMAJS != null) {
|
if (determineBasalAdapterAMAJS != null) {
|
||||||
glucoseStatusView.setText(JSONFormatter.format(determineBasalAdapterAMAJS.getGlucoseStatusParam()));
|
glucoseStatusView.setText(JSONFormatter.format(determineBasalAdapterAMAJS.getGlucoseStatusParam()));
|
||||||
currentTempView.setText(JSONFormatter.format(determineBasalAdapterAMAJS.getCurrentTempParam()));
|
currentTempView.setText(JSONFormatter.format(determineBasalAdapterAMAJS.getCurrentTempParam()));
|
||||||
|
@ -119,11 +117,11 @@ public class OpenAPSAMAFragment extends SubscriberFragment implements View.OnCli
|
||||||
mealDataView.setText(JSONFormatter.format(determineBasalAdapterAMAJS.getMealDataParam()));
|
mealDataView.setText(JSONFormatter.format(determineBasalAdapterAMAJS.getMealDataParam()));
|
||||||
scriptdebugView.setText(determineBasalAdapterAMAJS.getScriptDebug());
|
scriptdebugView.setText(determineBasalAdapterAMAJS.getScriptDebug());
|
||||||
}
|
}
|
||||||
if (getPlugin().lastAPSRun != null) {
|
if (OpenAPSAMAPlugin.getPlugin().lastAPSRun != null) {
|
||||||
lastRunView.setText(getPlugin().lastAPSRun.toLocaleString());
|
lastRunView.setText(OpenAPSAMAPlugin.getPlugin().lastAPSRun.toLocaleString());
|
||||||
}
|
}
|
||||||
if (getPlugin().lastAutosensResult != null) {
|
if (OpenAPSAMAPlugin.getPlugin().lastAutosensResult != null) {
|
||||||
autosensDataView.setText(JSONFormatter.format(getPlugin().lastAutosensResult.json()));
|
autosensDataView.setText(JSONFormatter.format(OpenAPSAMAPlugin.getPlugin().lastAutosensResult.json()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
|
@ -39,14 +39,23 @@ import info.nightscout.utils.ToastUtils;
|
||||||
public class OpenAPSAMAPlugin implements PluginBase, APSInterface {
|
public class OpenAPSAMAPlugin implements PluginBase, APSInterface {
|
||||||
private static Logger log = LoggerFactory.getLogger(OpenAPSAMAPlugin.class);
|
private static Logger log = LoggerFactory.getLogger(OpenAPSAMAPlugin.class);
|
||||||
|
|
||||||
|
private static OpenAPSAMAPlugin openAPSAMAPlugin;
|
||||||
|
|
||||||
|
public static OpenAPSAMAPlugin getPlugin() {
|
||||||
|
if (openAPSAMAPlugin == null) {
|
||||||
|
openAPSAMAPlugin = new OpenAPSAMAPlugin();
|
||||||
|
}
|
||||||
|
return openAPSAMAPlugin;
|
||||||
|
}
|
||||||
|
|
||||||
// last values
|
// last values
|
||||||
DetermineBasalAdapterAMAJS lastDetermineBasalAdapterAMAJS = null;
|
DetermineBasalAdapterAMAJS lastDetermineBasalAdapterAMAJS = null;
|
||||||
Date lastAPSRun = null;
|
Date lastAPSRun = null;
|
||||||
DetermineBasalResultAMA lastAPSResult = null;
|
DetermineBasalResultAMA lastAPSResult = null;
|
||||||
AutosensResult lastAutosensResult = null;
|
AutosensResult lastAutosensResult = null;
|
||||||
|
|
||||||
boolean fragmentEnabled = false;
|
private boolean fragmentEnabled = false;
|
||||||
boolean fragmentVisible = true;
|
private boolean fragmentVisible = true;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getName() {
|
public String getName() {
|
||||||
|
@ -196,9 +205,9 @@ public class OpenAPSAMAPlugin implements PluginBase, APSInterface {
|
||||||
maxBasal = verifyHardLimits(maxBasal, "max_basal", 0.1, 10);
|
maxBasal = verifyHardLimits(maxBasal, "max_basal", 0.1, 10);
|
||||||
|
|
||||||
if (!checkOnlyHardLimits(profile.getDia(), "dia", 2, 7)) return;
|
if (!checkOnlyHardLimits(profile.getDia(), "dia", 2, 7)) return;
|
||||||
if (!checkOnlyHardLimits(profile.getIc(profile.secondsFromMidnight()), "carbratio", 2, 100))
|
if (!checkOnlyHardLimits(profile.getIc(Profile.secondsFromMidnight()), "carbratio", 2, 100))
|
||||||
return;
|
return;
|
||||||
if (!checkOnlyHardLimits(Profile.toMgdl(profile.getIsf().doubleValue(), units), "sens", 2, 900))
|
if (!checkOnlyHardLimits(Profile.toMgdl(profile.getIsf(), units), "sens", 2, 900))
|
||||||
return;
|
return;
|
||||||
if (!checkOnlyHardLimits(profile.getMaxDailyBasal(), "max_daily_basal", 0.1, 10)) return;
|
if (!checkOnlyHardLimits(profile.getMaxDailyBasal(), "max_daily_basal", 0.1, 10)) return;
|
||||||
if (!checkOnlyHardLimits(pump.getBaseBasalRate(), "current_basal", 0.01, 5)) return;
|
if (!checkOnlyHardLimits(pump.getBaseBasalRate(), "current_basal", 0.01, 5)) return;
|
||||||
|
|
|
@ -9,6 +9,7 @@ import android.view.ViewGroup;
|
||||||
import android.widget.Button;
|
import android.widget.Button;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
|
||||||
|
import com.crashlytics.android.Crashlytics;
|
||||||
import com.crashlytics.android.answers.Answers;
|
import com.crashlytics.android.answers.Answers;
|
||||||
import com.crashlytics.android.answers.CustomEvent;
|
import com.crashlytics.android.answers.CustomEvent;
|
||||||
import com.squareup.otto.Subscribe;
|
import com.squareup.otto.Subscribe;
|
||||||
|
@ -26,15 +27,6 @@ import info.nightscout.utils.JSONFormatter;
|
||||||
public class OpenAPSMAFragment extends SubscriberFragment implements View.OnClickListener {
|
public class OpenAPSMAFragment extends SubscriberFragment implements View.OnClickListener {
|
||||||
private static Logger log = LoggerFactory.getLogger(OpenAPSMAFragment.class);
|
private static Logger log = LoggerFactory.getLogger(OpenAPSMAFragment.class);
|
||||||
|
|
||||||
private static OpenAPSMAPlugin openAPSMAPlugin;
|
|
||||||
|
|
||||||
public static OpenAPSMAPlugin getPlugin() {
|
|
||||||
if (openAPSMAPlugin == null) {
|
|
||||||
openAPSMAPlugin = new OpenAPSMAPlugin();
|
|
||||||
}
|
|
||||||
return openAPSMAPlugin;
|
|
||||||
}
|
|
||||||
|
|
||||||
Button run;
|
Button run;
|
||||||
TextView lastRunView;
|
TextView lastRunView;
|
||||||
TextView glucoseStatusView;
|
TextView glucoseStatusView;
|
||||||
|
@ -48,28 +40,34 @@ public class OpenAPSMAFragment extends SubscriberFragment implements View.OnClic
|
||||||
@Override
|
@Override
|
||||||
public View onCreateView(LayoutInflater inflater, ViewGroup container,
|
public View onCreateView(LayoutInflater inflater, ViewGroup container,
|
||||||
Bundle savedInstanceState) {
|
Bundle savedInstanceState) {
|
||||||
View view = inflater.inflate(R.layout.openapsma_fragment, container, false);
|
try {
|
||||||
|
View view = inflater.inflate(R.layout.openapsma_fragment, container, false);
|
||||||
|
|
||||||
run = (Button) view.findViewById(R.id.openapsma_run);
|
run = (Button) view.findViewById(R.id.openapsma_run);
|
||||||
run.setOnClickListener(this);
|
run.setOnClickListener(this);
|
||||||
lastRunView = (TextView) view.findViewById(R.id.openapsma_lastrun);
|
lastRunView = (TextView) view.findViewById(R.id.openapsma_lastrun);
|
||||||
glucoseStatusView = (TextView) view.findViewById(R.id.openapsma_glucosestatus);
|
glucoseStatusView = (TextView) view.findViewById(R.id.openapsma_glucosestatus);
|
||||||
currentTempView = (TextView) view.findViewById(R.id.openapsma_currenttemp);
|
currentTempView = (TextView) view.findViewById(R.id.openapsma_currenttemp);
|
||||||
iobDataView = (TextView) view.findViewById(R.id.openapsma_iobdata);
|
iobDataView = (TextView) view.findViewById(R.id.openapsma_iobdata);
|
||||||
profileView = (TextView) view.findViewById(R.id.openapsma_profile);
|
profileView = (TextView) view.findViewById(R.id.openapsma_profile);
|
||||||
mealDataView = (TextView) view.findViewById(R.id.openapsma_mealdata);
|
mealDataView = (TextView) view.findViewById(R.id.openapsma_mealdata);
|
||||||
resultView = (TextView) view.findViewById(R.id.openapsma_result);
|
resultView = (TextView) view.findViewById(R.id.openapsma_result);
|
||||||
requestView = (TextView) view.findViewById(R.id.openapsma_request);
|
requestView = (TextView) view.findViewById(R.id.openapsma_request);
|
||||||
|
|
||||||
updateGUI();
|
updateGUI();
|
||||||
return view;
|
return view;
|
||||||
|
} catch (Exception e) {
|
||||||
|
Crashlytics.logException(e);
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View view) {
|
public void onClick(View view) {
|
||||||
switch (view.getId()) {
|
switch (view.getId()) {
|
||||||
case R.id.openapsma_run:
|
case R.id.openapsma_run:
|
||||||
getPlugin().invoke("OpenAPSMA button");
|
OpenAPSMAPlugin.getPlugin().invoke("OpenAPSMA button");
|
||||||
Answers.getInstance().logCustom(new CustomEvent("OpenAPS_MA_Run"));
|
Answers.getInstance().logCustom(new CustomEvent("OpenAPS_MA_Run"));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -93,12 +91,12 @@ public class OpenAPSMAFragment extends SubscriberFragment implements View.OnClic
|
||||||
activity.runOnUiThread(new Runnable() {
|
activity.runOnUiThread(new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
DetermineBasalResultMA lastAPSResult = getPlugin().lastAPSResult;
|
DetermineBasalResultMA lastAPSResult = OpenAPSMAPlugin.getPlugin().lastAPSResult;
|
||||||
if (lastAPSResult != null) {
|
if (lastAPSResult != null) {
|
||||||
resultView.setText(JSONFormatter.format(lastAPSResult.json));
|
resultView.setText(JSONFormatter.format(lastAPSResult.json));
|
||||||
requestView.setText(lastAPSResult.toSpanned());
|
requestView.setText(lastAPSResult.toSpanned());
|
||||||
}
|
}
|
||||||
DetermineBasalAdapterMAJS determineBasalAdapterMAJS = getPlugin().lastDetermineBasalAdapterMAJS;
|
DetermineBasalAdapterMAJS determineBasalAdapterMAJS = OpenAPSMAPlugin.getPlugin().lastDetermineBasalAdapterMAJS;
|
||||||
if (determineBasalAdapterMAJS != null) {
|
if (determineBasalAdapterMAJS != null) {
|
||||||
glucoseStatusView.setText(JSONFormatter.format(determineBasalAdapterMAJS.getGlucoseStatusParam()));
|
glucoseStatusView.setText(JSONFormatter.format(determineBasalAdapterMAJS.getGlucoseStatusParam()));
|
||||||
currentTempView.setText(JSONFormatter.format(determineBasalAdapterMAJS.getCurrentTempParam()));
|
currentTempView.setText(JSONFormatter.format(determineBasalAdapterMAJS.getCurrentTempParam()));
|
||||||
|
@ -106,8 +104,8 @@ public class OpenAPSMAFragment extends SubscriberFragment implements View.OnClic
|
||||||
profileView.setText(JSONFormatter.format(determineBasalAdapterMAJS.getProfileParam()));
|
profileView.setText(JSONFormatter.format(determineBasalAdapterMAJS.getProfileParam()));
|
||||||
mealDataView.setText(JSONFormatter.format(determineBasalAdapterMAJS.getMealDataParam()));
|
mealDataView.setText(JSONFormatter.format(determineBasalAdapterMAJS.getMealDataParam()));
|
||||||
}
|
}
|
||||||
if (getPlugin().lastAPSRun != null) {
|
if (OpenAPSMAPlugin.getPlugin().lastAPSRun != null) {
|
||||||
lastRunView.setText(getPlugin().lastAPSRun.toLocaleString());
|
lastRunView.setText(OpenAPSMAPlugin.getPlugin().lastAPSRun.toLocaleString());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
|
@ -38,13 +38,22 @@ import static info.nightscout.androidaps.plugins.OpenAPSAMA.OpenAPSAMAPlugin.ver
|
||||||
public class OpenAPSMAPlugin implements PluginBase, APSInterface {
|
public class OpenAPSMAPlugin implements PluginBase, APSInterface {
|
||||||
private static Logger log = LoggerFactory.getLogger(OpenAPSMAPlugin.class);
|
private static Logger log = LoggerFactory.getLogger(OpenAPSMAPlugin.class);
|
||||||
|
|
||||||
|
private static OpenAPSMAPlugin openAPSMAPlugin;
|
||||||
|
|
||||||
|
public static OpenAPSMAPlugin getPlugin() {
|
||||||
|
if (openAPSMAPlugin == null) {
|
||||||
|
openAPSMAPlugin = new OpenAPSMAPlugin();
|
||||||
|
}
|
||||||
|
return openAPSMAPlugin;
|
||||||
|
}
|
||||||
|
|
||||||
// last values
|
// last values
|
||||||
DetermineBasalAdapterMAJS lastDetermineBasalAdapterMAJS = null;
|
DetermineBasalAdapterMAJS lastDetermineBasalAdapterMAJS = null;
|
||||||
Date lastAPSRun = null;
|
Date lastAPSRun = null;
|
||||||
DetermineBasalResultMA lastAPSResult = null;
|
DetermineBasalResultMA lastAPSResult = null;
|
||||||
|
|
||||||
boolean fragmentEnabled = false;
|
private boolean fragmentEnabled = false;
|
||||||
boolean fragmentVisible = true;
|
private boolean fragmentVisible = true;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getName() {
|
public String getName() {
|
||||||
|
@ -196,7 +205,7 @@ public class OpenAPSMAPlugin implements PluginBase, APSInterface {
|
||||||
|
|
||||||
if (!checkOnlyHardLimits(profile.getDia(), "dia", 2, 7)) return;
|
if (!checkOnlyHardLimits(profile.getDia(), "dia", 2, 7)) return;
|
||||||
if (!checkOnlyHardLimits(profile.getIc(), "carbratio", 2, 100)) return;
|
if (!checkOnlyHardLimits(profile.getIc(), "carbratio", 2, 100)) return;
|
||||||
if (!checkOnlyHardLimits(Profile.toMgdl(profile.getIsf().doubleValue(), units), "sens", 2, 900))
|
if (!checkOnlyHardLimits(Profile.toMgdl(profile.getIsf(), units), "sens", 2, 900))
|
||||||
return;
|
return;
|
||||||
if (!checkOnlyHardLimits(profile.getMaxDailyBasal(), "max_daily_basal", 0.1, 10)) return;
|
if (!checkOnlyHardLimits(profile.getMaxDailyBasal(), "max_daily_basal", 0.1, 10)) return;
|
||||||
if (!checkOnlyHardLimits(pump.getBaseBasalRate(), "current_basal", 0.01, 5)) return;
|
if (!checkOnlyHardLimits(pump.getBaseBasalRate(), "current_basal", 0.01, 5)) return;
|
||||||
|
|
|
@ -33,6 +33,7 @@ import android.widget.CompoundButton;
|
||||||
import android.widget.LinearLayout;
|
import android.widget.LinearLayout;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
|
||||||
|
import com.crashlytics.android.Crashlytics;
|
||||||
import com.crashlytics.android.answers.Answers;
|
import com.crashlytics.android.answers.Answers;
|
||||||
import com.crashlytics.android.answers.CustomEvent;
|
import com.crashlytics.android.answers.CustomEvent;
|
||||||
import com.jjoe64.graphview.GraphView;
|
import com.jjoe64.graphview.GraphView;
|
||||||
|
@ -134,12 +135,6 @@ import info.nightscout.utils.ToastUtils;
|
||||||
public class OverviewFragment extends Fragment implements View.OnClickListener, CompoundButton.OnCheckedChangeListener {
|
public class OverviewFragment extends Fragment implements View.OnClickListener, CompoundButton.OnCheckedChangeListener {
|
||||||
private static Logger log = LoggerFactory.getLogger(OverviewFragment.class);
|
private static Logger log = LoggerFactory.getLogger(OverviewFragment.class);
|
||||||
|
|
||||||
private static OverviewPlugin overviewPlugin = new OverviewPlugin();
|
|
||||||
|
|
||||||
public static OverviewPlugin getPlugin() {
|
|
||||||
return overviewPlugin;
|
|
||||||
}
|
|
||||||
|
|
||||||
TextView timeView;
|
TextView timeView;
|
||||||
TextView bgView;
|
TextView bgView;
|
||||||
TextView arrowView;
|
TextView arrowView;
|
||||||
|
@ -215,136 +210,142 @@ public class OverviewFragment extends Fragment implements View.OnClickListener,
|
||||||
public View onCreateView(LayoutInflater inflater, ViewGroup container,
|
public View onCreateView(LayoutInflater inflater, ViewGroup container,
|
||||||
Bundle savedInstanceState) {
|
Bundle savedInstanceState) {
|
||||||
|
|
||||||
//check screen width
|
try {
|
||||||
final DisplayMetrics dm = new DisplayMetrics();
|
//check screen width
|
||||||
getActivity().getWindowManager().getDefaultDisplay().getMetrics(dm);
|
final DisplayMetrics dm = new DisplayMetrics();
|
||||||
int screen_width = dm.widthPixels;
|
getActivity().getWindowManager().getDefaultDisplay().getMetrics(dm);
|
||||||
int screen_height = dm.heightPixels;
|
int screen_width = dm.widthPixels;
|
||||||
smallWidth = screen_width < Constants.SMALL_WIDTH;
|
int screen_height = dm.heightPixels;
|
||||||
smallHeight = screen_height < Constants.SMALL_HEIGHT;
|
smallWidth = screen_width < Constants.SMALL_WIDTH;
|
||||||
boolean landscape = screen_height < screen_width;
|
smallHeight = screen_height < Constants.SMALL_HEIGHT;
|
||||||
|
boolean landscape = screen_height < screen_width;
|
||||||
|
|
||||||
View view;
|
View view;
|
||||||
|
|
||||||
if (MainApp.sResources.getBoolean(R.bool.isTablet) && BuildConfig.NSCLIENTOLNY) {
|
if (MainApp.sResources.getBoolean(R.bool.isTablet) && BuildConfig.NSCLIENTOLNY) {
|
||||||
view = inflater.inflate(R.layout.overview_fragment_nsclient_tablet, container, false);
|
view = inflater.inflate(R.layout.overview_fragment_nsclient_tablet, container, false);
|
||||||
} else if (BuildConfig.NSCLIENTOLNY) {
|
} else if (BuildConfig.NSCLIENTOLNY) {
|
||||||
view = inflater.inflate(R.layout.overview_fragment_nsclient, container, false);
|
view = inflater.inflate(R.layout.overview_fragment_nsclient, container, false);
|
||||||
shorttextmode = true;
|
shorttextmode = true;
|
||||||
} else if (smallHeight || landscape) {
|
} else if (smallHeight || landscape) {
|
||||||
view = inflater.inflate(R.layout.overview_fragment_smallheight, container, false);
|
view = inflater.inflate(R.layout.overview_fragment_smallheight, container, false);
|
||||||
} else {
|
} else {
|
||||||
view = inflater.inflate(R.layout.overview_fragment, container, false);
|
view = inflater.inflate(R.layout.overview_fragment, container, false);
|
||||||
}
|
|
||||||
|
|
||||||
timeView = (TextView) view.findViewById(R.id.overview_time);
|
|
||||||
bgView = (TextView) view.findViewById(R.id.overview_bg);
|
|
||||||
arrowView = (TextView) view.findViewById(R.id.overview_arrow);
|
|
||||||
if (smallWidth) {
|
|
||||||
arrowView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 35);
|
|
||||||
}
|
|
||||||
timeAgoView = (TextView) view.findViewById(R.id.overview_timeago);
|
|
||||||
deltaView = (TextView) view.findViewById(R.id.overview_delta);
|
|
||||||
avgdeltaView = (TextView) view.findViewById(R.id.overview_avgdelta);
|
|
||||||
baseBasalView = (TextView) view.findViewById(R.id.overview_basebasal);
|
|
||||||
extendedBolusView = (TextView) view.findViewById(R.id.overview_extendedbolus);
|
|
||||||
activeProfileView = (TextView) view.findViewById(R.id.overview_activeprofile);
|
|
||||||
pumpStatusView = (TextView) view.findViewById(R.id.overview_pumpstatus);
|
|
||||||
pumpDeviceStatusView = (TextView) view.findViewById(R.id.overview_pump);
|
|
||||||
openapsDeviceStatusView = (TextView) view.findViewById(R.id.overview_openaps);
|
|
||||||
uploaderDeviceStatusView = (TextView) view.findViewById(R.id.overview_uploader);
|
|
||||||
loopStatusLayout = (LinearLayout) view.findViewById(R.id.overview_looplayout);
|
|
||||||
pumpStatusLayout = (LinearLayout) view.findViewById(R.id.overview_pumpstatuslayout);
|
|
||||||
|
|
||||||
pumpStatusView.setBackgroundColor(MainApp.sResources.getColor(R.color.colorInitializingBorder));
|
|
||||||
|
|
||||||
iobView = (TextView) view.findViewById(R.id.overview_iob);
|
|
||||||
cobView = (TextView) view.findViewById(R.id.overview_cob);
|
|
||||||
apsModeView = (TextView) view.findViewById(R.id.overview_apsmode);
|
|
||||||
tempTargetView = (TextView) view.findViewById(R.id.overview_temptarget);
|
|
||||||
|
|
||||||
iage = (TextView) view.findViewById(R.id.careportal_insulinage);
|
|
||||||
cage = (TextView) view.findViewById(R.id.careportal_canulaage);
|
|
||||||
sage = (TextView) view.findViewById(R.id.careportal_sensorage);
|
|
||||||
pbage = (TextView) view.findViewById(R.id.careportal_pbage);
|
|
||||||
|
|
||||||
bgGraph = (GraphView) view.findViewById(R.id.overview_bggraph);
|
|
||||||
iobGraph = (GraphView) view.findViewById(R.id.overview_iobgraph);
|
|
||||||
|
|
||||||
treatmentButton = (Button) view.findViewById(R.id.overview_treatmentbutton);
|
|
||||||
treatmentButton.setOnClickListener(this);
|
|
||||||
wizardButton = (Button) view.findViewById(R.id.overview_wizardbutton);
|
|
||||||
wizardButton.setOnClickListener(this);
|
|
||||||
acceptTempButton = (Button) view.findViewById(R.id.overview_accepttempbutton);
|
|
||||||
if (acceptTempButton != null)
|
|
||||||
acceptTempButton.setOnClickListener(this);
|
|
||||||
quickWizardButton = (Button) view.findViewById(R.id.overview_quickwizardbutton);
|
|
||||||
quickWizardButton.setOnClickListener(this);
|
|
||||||
calibrationButton = (Button) view.findViewById(R.id.overview_calibrationbutton);
|
|
||||||
if (calibrationButton != null)
|
|
||||||
calibrationButton.setOnClickListener(this);
|
|
||||||
|
|
||||||
acceptTempLayout = (LinearLayout) view.findViewById(R.id.overview_accepttemplayout);
|
|
||||||
|
|
||||||
showPredictionView = (CheckBox) view.findViewById(R.id.overview_showprediction);
|
|
||||||
showBasalsView = (CheckBox) view.findViewById(R.id.overview_showbasals);
|
|
||||||
showIobView = (CheckBox) view.findViewById(R.id.overview_showiob);
|
|
||||||
showCobView = (CheckBox) view.findViewById(R.id.overview_showcob);
|
|
||||||
showDeviationsView = (CheckBox) view.findViewById(R.id.overview_showdeviations);
|
|
||||||
showRatiosView = (CheckBox) view.findViewById(R.id.overview_showratios);
|
|
||||||
showPredictionView.setChecked(SP.getBoolean("showprediction", false));
|
|
||||||
showBasalsView.setChecked(SP.getBoolean("showbasals", true));
|
|
||||||
showIobView.setChecked(SP.getBoolean("showiob", false));
|
|
||||||
showCobView.setChecked(SP.getBoolean("showcob", false));
|
|
||||||
showDeviationsView.setChecked(SP.getBoolean("showdeviations", false));
|
|
||||||
showRatiosView.setChecked(SP.getBoolean("showratios", false));
|
|
||||||
showPredictionView.setOnCheckedChangeListener(this);
|
|
||||||
showBasalsView.setOnCheckedChangeListener(this);
|
|
||||||
showIobView.setOnCheckedChangeListener(this);
|
|
||||||
showCobView.setOnCheckedChangeListener(this);
|
|
||||||
showDeviationsView.setOnCheckedChangeListener(this);
|
|
||||||
showRatiosView.setOnCheckedChangeListener(this);
|
|
||||||
|
|
||||||
notificationsView = (RecyclerView) view.findViewById(R.id.overview_notifications);
|
|
||||||
notificationsView.setHasFixedSize(true);
|
|
||||||
llm = new LinearLayoutManager(view.getContext());
|
|
||||||
notificationsView.setLayoutManager(llm);
|
|
||||||
|
|
||||||
bgGraph.getGridLabelRenderer().setGridColor(MainApp.sResources.getColor(R.color.graphgrid));
|
|
||||||
bgGraph.getGridLabelRenderer().reloadStyles();
|
|
||||||
iobGraph.getGridLabelRenderer().setGridColor(MainApp.sResources.getColor(R.color.graphgrid));
|
|
||||||
iobGraph.getGridLabelRenderer().reloadStyles();
|
|
||||||
iobGraph.getGridLabelRenderer().setHorizontalLabelsVisible(false);
|
|
||||||
bgGraph.getGridLabelRenderer().setLabelVerticalWidth(50);
|
|
||||||
iobGraph.getGridLabelRenderer().setLabelVerticalWidth(50);
|
|
||||||
iobGraph.getGridLabelRenderer().setNumVerticalLabels(5);
|
|
||||||
|
|
||||||
rangeToDisplay = SP.getInt(R.string.key_rangetodisplay, 6);
|
|
||||||
|
|
||||||
bgGraph.setOnLongClickListener(new View.OnLongClickListener() {
|
|
||||||
@Override
|
|
||||||
public boolean onLongClick(View v) {
|
|
||||||
rangeToDisplay += 6;
|
|
||||||
rangeToDisplay = rangeToDisplay > 24 ? 6 : rangeToDisplay;
|
|
||||||
SP.putInt(R.string.key_rangetodisplay, rangeToDisplay);
|
|
||||||
updateGUI("rangeChange");
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
});
|
|
||||||
|
|
||||||
lockScreen = (CheckBox) view.findViewById(R.id.overview_lockscreen);
|
timeView = (TextView) view.findViewById(R.id.overview_time);
|
||||||
if (lockScreen != null) {
|
bgView = (TextView) view.findViewById(R.id.overview_bg);
|
||||||
lockScreen.setChecked(SP.getBoolean("lockscreen", false));
|
arrowView = (TextView) view.findViewById(R.id.overview_arrow);
|
||||||
lockScreen.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
|
if (smallWidth) {
|
||||||
|
arrowView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 35);
|
||||||
|
}
|
||||||
|
timeAgoView = (TextView) view.findViewById(R.id.overview_timeago);
|
||||||
|
deltaView = (TextView) view.findViewById(R.id.overview_delta);
|
||||||
|
avgdeltaView = (TextView) view.findViewById(R.id.overview_avgdelta);
|
||||||
|
baseBasalView = (TextView) view.findViewById(R.id.overview_basebasal);
|
||||||
|
extendedBolusView = (TextView) view.findViewById(R.id.overview_extendedbolus);
|
||||||
|
activeProfileView = (TextView) view.findViewById(R.id.overview_activeprofile);
|
||||||
|
pumpStatusView = (TextView) view.findViewById(R.id.overview_pumpstatus);
|
||||||
|
pumpDeviceStatusView = (TextView) view.findViewById(R.id.overview_pump);
|
||||||
|
openapsDeviceStatusView = (TextView) view.findViewById(R.id.overview_openaps);
|
||||||
|
uploaderDeviceStatusView = (TextView) view.findViewById(R.id.overview_uploader);
|
||||||
|
loopStatusLayout = (LinearLayout) view.findViewById(R.id.overview_looplayout);
|
||||||
|
pumpStatusLayout = (LinearLayout) view.findViewById(R.id.overview_pumpstatuslayout);
|
||||||
|
|
||||||
|
pumpStatusView.setBackgroundColor(MainApp.sResources.getColor(R.color.colorInitializingBorder));
|
||||||
|
|
||||||
|
iobView = (TextView) view.findViewById(R.id.overview_iob);
|
||||||
|
cobView = (TextView) view.findViewById(R.id.overview_cob);
|
||||||
|
apsModeView = (TextView) view.findViewById(R.id.overview_apsmode);
|
||||||
|
tempTargetView = (TextView) view.findViewById(R.id.overview_temptarget);
|
||||||
|
|
||||||
|
iage = (TextView) view.findViewById(R.id.careportal_insulinage);
|
||||||
|
cage = (TextView) view.findViewById(R.id.careportal_canulaage);
|
||||||
|
sage = (TextView) view.findViewById(R.id.careportal_sensorage);
|
||||||
|
pbage = (TextView) view.findViewById(R.id.careportal_pbage);
|
||||||
|
|
||||||
|
bgGraph = (GraphView) view.findViewById(R.id.overview_bggraph);
|
||||||
|
iobGraph = (GraphView) view.findViewById(R.id.overview_iobgraph);
|
||||||
|
|
||||||
|
treatmentButton = (Button) view.findViewById(R.id.overview_treatmentbutton);
|
||||||
|
treatmentButton.setOnClickListener(this);
|
||||||
|
wizardButton = (Button) view.findViewById(R.id.overview_wizardbutton);
|
||||||
|
wizardButton.setOnClickListener(this);
|
||||||
|
acceptTempButton = (Button) view.findViewById(R.id.overview_accepttempbutton);
|
||||||
|
if (acceptTempButton != null)
|
||||||
|
acceptTempButton.setOnClickListener(this);
|
||||||
|
quickWizardButton = (Button) view.findViewById(R.id.overview_quickwizardbutton);
|
||||||
|
quickWizardButton.setOnClickListener(this);
|
||||||
|
calibrationButton = (Button) view.findViewById(R.id.overview_calibrationbutton);
|
||||||
|
if (calibrationButton != null)
|
||||||
|
calibrationButton.setOnClickListener(this);
|
||||||
|
|
||||||
|
acceptTempLayout = (LinearLayout) view.findViewById(R.id.overview_accepttemplayout);
|
||||||
|
|
||||||
|
showPredictionView = (CheckBox) view.findViewById(R.id.overview_showprediction);
|
||||||
|
showBasalsView = (CheckBox) view.findViewById(R.id.overview_showbasals);
|
||||||
|
showIobView = (CheckBox) view.findViewById(R.id.overview_showiob);
|
||||||
|
showCobView = (CheckBox) view.findViewById(R.id.overview_showcob);
|
||||||
|
showDeviationsView = (CheckBox) view.findViewById(R.id.overview_showdeviations);
|
||||||
|
showRatiosView = (CheckBox) view.findViewById(R.id.overview_showratios);
|
||||||
|
showPredictionView.setChecked(SP.getBoolean("showprediction", false));
|
||||||
|
showBasalsView.setChecked(SP.getBoolean("showbasals", true));
|
||||||
|
showIobView.setChecked(SP.getBoolean("showiob", false));
|
||||||
|
showCobView.setChecked(SP.getBoolean("showcob", false));
|
||||||
|
showDeviationsView.setChecked(SP.getBoolean("showdeviations", false));
|
||||||
|
showRatiosView.setChecked(SP.getBoolean("showratios", false));
|
||||||
|
showPredictionView.setOnCheckedChangeListener(this);
|
||||||
|
showBasalsView.setOnCheckedChangeListener(this);
|
||||||
|
showIobView.setOnCheckedChangeListener(this);
|
||||||
|
showCobView.setOnCheckedChangeListener(this);
|
||||||
|
showDeviationsView.setOnCheckedChangeListener(this);
|
||||||
|
showRatiosView.setOnCheckedChangeListener(this);
|
||||||
|
|
||||||
|
notificationsView = (RecyclerView) view.findViewById(R.id.overview_notifications);
|
||||||
|
notificationsView.setHasFixedSize(true);
|
||||||
|
llm = new LinearLayoutManager(view.getContext());
|
||||||
|
notificationsView.setLayoutManager(llm);
|
||||||
|
|
||||||
|
bgGraph.getGridLabelRenderer().setGridColor(MainApp.sResources.getColor(R.color.graphgrid));
|
||||||
|
bgGraph.getGridLabelRenderer().reloadStyles();
|
||||||
|
iobGraph.getGridLabelRenderer().setGridColor(MainApp.sResources.getColor(R.color.graphgrid));
|
||||||
|
iobGraph.getGridLabelRenderer().reloadStyles();
|
||||||
|
iobGraph.getGridLabelRenderer().setHorizontalLabelsVisible(false);
|
||||||
|
bgGraph.getGridLabelRenderer().setLabelVerticalWidth(50);
|
||||||
|
iobGraph.getGridLabelRenderer().setLabelVerticalWidth(50);
|
||||||
|
iobGraph.getGridLabelRenderer().setNumVerticalLabels(5);
|
||||||
|
|
||||||
|
rangeToDisplay = SP.getInt(R.string.key_rangetodisplay, 6);
|
||||||
|
|
||||||
|
bgGraph.setOnLongClickListener(new View.OnLongClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
|
public boolean onLongClick(View v) {
|
||||||
SP.putBoolean("lockscreen", isChecked);
|
rangeToDisplay += 6;
|
||||||
MainApp.bus().post(new EventSetWakeLock(isChecked));
|
rangeToDisplay = rangeToDisplay > 24 ? 6 : rangeToDisplay;
|
||||||
|
SP.putInt(R.string.key_rangetodisplay, rangeToDisplay);
|
||||||
|
updateGUI("rangeChange");
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
lockScreen = (CheckBox) view.findViewById(R.id.overview_lockscreen);
|
||||||
|
if (lockScreen != null) {
|
||||||
|
lockScreen.setChecked(SP.getBoolean("lockscreen", false));
|
||||||
|
lockScreen.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
|
||||||
|
@Override
|
||||||
|
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
|
||||||
|
SP.putBoolean("lockscreen", isChecked);
|
||||||
|
MainApp.bus().post(new EventSetWakeLock(isChecked));
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
return view;
|
||||||
|
} catch (Exception e) {
|
||||||
|
Crashlytics.logException(e);
|
||||||
}
|
}
|
||||||
|
|
||||||
return view;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -655,7 +656,7 @@ public class OverviewFragment extends Fragment implements View.OnClickListener,
|
||||||
final Profile profile = MainApp.getConfigBuilder().getProfile();
|
final Profile profile = MainApp.getConfigBuilder().getProfile();
|
||||||
final TempTarget tempTarget = MainApp.getConfigBuilder().getTempTargetFromHistory();
|
final TempTarget tempTarget = MainApp.getConfigBuilder().getTempTargetFromHistory();
|
||||||
|
|
||||||
QuickWizard.QuickWizardEntry quickWizardEntry = getPlugin().quickWizard.getActive();
|
QuickWizard.QuickWizardEntry quickWizardEntry = OverviewPlugin.getPlugin().quickWizard.getActive();
|
||||||
if (quickWizardEntry != null && actualBg != null) {
|
if (quickWizardEntry != null && actualBg != null) {
|
||||||
quickWizardButton.setVisibility(View.VISIBLE);
|
quickWizardButton.setVisibility(View.VISIBLE);
|
||||||
BolusWizard wizard = new BolusWizard();
|
BolusWizard wizard = new BolusWizard();
|
||||||
|
@ -1122,7 +1123,7 @@ public class OverviewFragment extends Fragment implements View.OnClickListener,
|
||||||
tempTargetView.setLongClickable(true);
|
tempTargetView.setLongClickable(true);
|
||||||
|
|
||||||
// QuickWizard button
|
// QuickWizard button
|
||||||
QuickWizard.QuickWizardEntry quickWizardEntry = getPlugin().quickWizard.getActive();
|
QuickWizard.QuickWizardEntry quickWizardEntry = OverviewPlugin.getPlugin().quickWizard.getActive();
|
||||||
if (quickWizardEntry != null && lastBG != null && pump.isInitialized() && !pump.isSuspended()) {
|
if (quickWizardEntry != null && lastBG != null && pump.isInitialized() && !pump.isSuspended()) {
|
||||||
quickWizardButton.setVisibility(View.VISIBLE);
|
quickWizardButton.setVisibility(View.VISIBLE);
|
||||||
String text = quickWizardEntry.buttonText() + "\n" + DecimalFormatter.to0Decimal(quickWizardEntry.carbs()) + "g";
|
String text = quickWizardEntry.buttonText() + "\n" + DecimalFormatter.to0Decimal(quickWizardEntry.carbs()) + "g";
|
||||||
|
@ -1809,7 +1810,7 @@ public class OverviewFragment extends Fragment implements View.OnClickListener,
|
||||||
// Adding current time to snooze if we got staleData
|
// Adding current time to snooze if we got staleData
|
||||||
log.debug("Notification text is: " + notification.text);
|
log.debug("Notification text is: " + notification.text);
|
||||||
if (notification.text.equals(MainApp.sResources.getString(R.string.nsalarm_staledata))) {
|
if (notification.text.equals(MainApp.sResources.getString(R.string.nsalarm_staledata))) {
|
||||||
NotificationStore nstore = getPlugin().notificationStore;
|
NotificationStore nstore = OverviewPlugin.getPlugin().notificationStore;
|
||||||
long msToSnooze = SP.getInt("nsalarm_staledatavalue", 15) * 60 * 1000L;
|
long msToSnooze = SP.getInt("nsalarm_staledatavalue", 15) * 60 * 1000L;
|
||||||
log.debug("snooze nsalarm_staledatavalue in minutes is " + SP.getInt("nsalarm_staledatavalue", 15) + "\n in ms is: " + msToSnooze + " currentTimeMillis is: " + System.currentTimeMillis());
|
log.debug("snooze nsalarm_staledatavalue in minutes is " + SP.getInt("nsalarm_staledatavalue", 15) + "\n in ms is: " + msToSnooze + " currentTimeMillis is: " + System.currentTimeMillis());
|
||||||
nstore.snoozeTo(System.currentTimeMillis() + (SP.getInt("nsalarm_staledatavalue", 15) * 60 * 1000L));
|
nstore.snoozeTo(System.currentTimeMillis() + (SP.getInt("nsalarm_staledatavalue", 15) * 60 * 1000L));
|
||||||
|
@ -1826,7 +1827,7 @@ public class OverviewFragment extends Fragment implements View.OnClickListener,
|
||||||
activity.runOnUiThread(new Runnable() {
|
activity.runOnUiThread(new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
NotificationStore nstore = getPlugin().notificationStore;
|
NotificationStore nstore = OverviewPlugin.getPlugin().notificationStore;
|
||||||
nstore.removeExpired();
|
nstore.removeExpired();
|
||||||
nstore.unSnooze();
|
nstore.unSnooze();
|
||||||
if (nstore.store.size() > 0) {
|
if (nstore.store.size() > 0) {
|
||||||
|
|
|
@ -21,6 +21,15 @@ import info.nightscout.utils.SP;
|
||||||
public class OverviewPlugin implements PluginBase {
|
public class OverviewPlugin implements PluginBase {
|
||||||
private static Logger log = LoggerFactory.getLogger(OverviewPlugin.class);
|
private static Logger log = LoggerFactory.getLogger(OverviewPlugin.class);
|
||||||
|
|
||||||
|
private static OverviewPlugin overviewPlugin = new OverviewPlugin();
|
||||||
|
|
||||||
|
public static OverviewPlugin getPlugin() {
|
||||||
|
|
||||||
|
if (overviewPlugin == null)
|
||||||
|
overviewPlugin = new OverviewPlugin();
|
||||||
|
return overviewPlugin;
|
||||||
|
}
|
||||||
|
|
||||||
public static double bgTargetLow = 80d;
|
public static double bgTargetLow = 80d;
|
||||||
public static double bgTargetHigh = 180d;
|
public static double bgTargetHigh = 180d;
|
||||||
|
|
||||||
|
@ -51,7 +60,7 @@ public class OverviewPlugin implements PluginBase {
|
||||||
@Override
|
@Override
|
||||||
public String getNameShort() {
|
public String getNameShort() {
|
||||||
String name = MainApp.sResources.getString(R.string.overview_shortname);
|
String name = MainApp.sResources.getString(R.string.overview_shortname);
|
||||||
if (!name.trim().isEmpty()){
|
if (!name.trim().isEmpty()) {
|
||||||
//only if translation exists
|
//only if translation exists
|
||||||
return name;
|
return name;
|
||||||
}
|
}
|
||||||
|
|
|
@ -39,7 +39,7 @@ import info.nightscout.utils.DecimalFormatter;
|
||||||
public class PersistentNotificationPlugin implements PluginBase {
|
public class PersistentNotificationPlugin implements PluginBase {
|
||||||
|
|
||||||
private static final int ONGOING_NOTIFICATION_ID = 4711;
|
private static final int ONGOING_NOTIFICATION_ID = 4711;
|
||||||
static boolean fragmentEnabled = true;
|
private boolean fragmentEnabled = true;
|
||||||
private final Context ctx;
|
private final Context ctx;
|
||||||
|
|
||||||
public PersistentNotificationPlugin(Context ctx) {
|
public PersistentNotificationPlugin(Context ctx) {
|
||||||
|
|
|
@ -35,8 +35,8 @@ public class CircadianPercentageProfilePlugin implements PluginBase, ProfileInte
|
||||||
public static final String SETTINGS_PREFIX = "CircadianPercentageProfile";
|
public static final String SETTINGS_PREFIX = "CircadianPercentageProfile";
|
||||||
private static Logger log = LoggerFactory.getLogger(CircadianPercentageProfilePlugin.class);
|
private static Logger log = LoggerFactory.getLogger(CircadianPercentageProfilePlugin.class);
|
||||||
|
|
||||||
private static boolean fragmentEnabled = false;
|
private boolean fragmentEnabled = false;
|
||||||
private static boolean fragmentVisible = true;
|
private boolean fragmentVisible = true;
|
||||||
|
|
||||||
private static ProfileStore convertedProfile = null;
|
private static ProfileStore convertedProfile = null;
|
||||||
private static String convertedProfileName = null;
|
private static String convertedProfileName = null;
|
||||||
|
|
|
@ -10,27 +10,21 @@ import android.widget.ArrayAdapter;
|
||||||
import android.widget.Spinner;
|
import android.widget.Spinner;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
|
||||||
|
import com.crashlytics.android.Crashlytics;
|
||||||
import com.squareup.otto.Subscribe;
|
import com.squareup.otto.Subscribe;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
|
||||||
import info.nightscout.androidaps.Constants;
|
|
||||||
import info.nightscout.androidaps.MainApp;
|
import info.nightscout.androidaps.MainApp;
|
||||||
import info.nightscout.androidaps.R;
|
import info.nightscout.androidaps.R;
|
||||||
import info.nightscout.androidaps.data.Profile;
|
import info.nightscout.androidaps.data.Profile;
|
||||||
import info.nightscout.androidaps.data.ProfileStore;
|
import info.nightscout.androidaps.data.ProfileStore;
|
||||||
import info.nightscout.androidaps.plugins.Common.SubscriberFragment;
|
import info.nightscout.androidaps.plugins.Common.SubscriberFragment;
|
||||||
import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderPlugin;
|
|
||||||
import info.nightscout.androidaps.plugins.ProfileNS.events.EventNSProfileUpdateGUI;
|
import info.nightscout.androidaps.plugins.ProfileNS.events.EventNSProfileUpdateGUI;
|
||||||
import info.nightscout.utils.DecimalFormatter;
|
import info.nightscout.utils.DecimalFormatter;
|
||||||
|
|
||||||
|
|
||||||
public class NSProfileFragment extends SubscriberFragment implements AdapterView.OnItemSelectedListener {
|
public class NSProfileFragment extends SubscriberFragment implements AdapterView.OnItemSelectedListener {
|
||||||
private static NSProfilePlugin nsProfilePlugin = new NSProfilePlugin();
|
|
||||||
|
|
||||||
public static NSProfilePlugin getPlugin() {
|
|
||||||
return nsProfilePlugin;
|
|
||||||
}
|
|
||||||
|
|
||||||
private Spinner profileSpinner;
|
private Spinner profileSpinner;
|
||||||
private TextView noProfile;
|
private TextView noProfile;
|
||||||
private TextView units;
|
private TextView units;
|
||||||
|
@ -44,22 +38,28 @@ public class NSProfileFragment extends SubscriberFragment implements AdapterView
|
||||||
@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.nsprofile_fragment, container, false);
|
try {
|
||||||
|
View layout = inflater.inflate(R.layout.nsprofile_fragment, container, false);
|
||||||
|
|
||||||
profileSpinner = (Spinner) layout.findViewById(R.id.nsprofile_spinner);
|
profileSpinner = (Spinner) layout.findViewById(R.id.nsprofile_spinner);
|
||||||
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);
|
||||||
dia = (TextView) layout.findViewById(R.id.profileview_dia);
|
dia = (TextView) layout.findViewById(R.id.profileview_dia);
|
||||||
activeProfile = (TextView) layout.findViewById(R.id.profileview_activeprofile);
|
activeProfile = (TextView) layout.findViewById(R.id.profileview_activeprofile);
|
||||||
ic = (TextView) layout.findViewById(R.id.profileview_ic);
|
ic = (TextView) layout.findViewById(R.id.profileview_ic);
|
||||||
isf = (TextView) layout.findViewById(R.id.profileview_isf);
|
isf = (TextView) layout.findViewById(R.id.profileview_isf);
|
||||||
basal = (TextView) layout.findViewById(R.id.profileview_basal);
|
basal = (TextView) layout.findViewById(R.id.profileview_basal);
|
||||||
target = (TextView) layout.findViewById(R.id.profileview_target);
|
target = (TextView) layout.findViewById(R.id.profileview_target);
|
||||||
|
|
||||||
profileSpinner.setOnItemSelectedListener(this);
|
profileSpinner.setOnItemSelectedListener(this);
|
||||||
|
|
||||||
updateGUI();
|
updateGUI();
|
||||||
return layout;
|
return layout;
|
||||||
|
} catch (Exception e) {
|
||||||
|
Crashlytics.logException(e);
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Subscribe
|
@Subscribe
|
||||||
|
@ -83,7 +83,7 @@ public class NSProfileFragment extends SubscriberFragment implements AdapterView
|
||||||
noProfile.setVisibility(View.GONE);
|
noProfile.setVisibility(View.GONE);
|
||||||
}
|
}
|
||||||
|
|
||||||
ProfileStore profileStore = getPlugin().getProfile();
|
ProfileStore profileStore = NSProfilePlugin.getPlugin().getProfile();
|
||||||
ArrayList<CharSequence> profileList = profileStore.getProfileList();
|
ArrayList<CharSequence> profileList = profileStore.getProfileList();
|
||||||
ArrayAdapter<CharSequence> adapter = new ArrayAdapter<>(getContext(),
|
ArrayAdapter<CharSequence> adapter = new ArrayAdapter<>(getContext(),
|
||||||
R.layout.spinner_centered, profileList);
|
R.layout.spinner_centered, profileList);
|
||||||
|
@ -100,7 +100,7 @@ public class NSProfileFragment extends SubscriberFragment implements AdapterView
|
||||||
public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
|
public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
|
||||||
String name = parent.getItemAtPosition(position).toString();
|
String name = parent.getItemAtPosition(position).toString();
|
||||||
|
|
||||||
Profile profile = getPlugin().getProfile().getSpecificProfile(name);
|
Profile profile = NSProfilePlugin.getPlugin().getProfile().getSpecificProfile(name);
|
||||||
units.setText(profile.getUnits());
|
units.setText(profile.getUnits());
|
||||||
dia.setText(DecimalFormatter.to2Decimal(profile.getDia()) + " h");
|
dia.setText(DecimalFormatter.to2Decimal(profile.getDia()) + " h");
|
||||||
activeProfile.setText(name);
|
activeProfile.setText(name);
|
||||||
|
|
|
@ -29,17 +29,25 @@ import info.nightscout.utils.SP;
|
||||||
public class NSProfilePlugin implements PluginBase, ProfileInterface {
|
public class NSProfilePlugin implements PluginBase, ProfileInterface {
|
||||||
private static Logger log = LoggerFactory.getLogger(NSProfilePlugin.class);
|
private static Logger log = LoggerFactory.getLogger(NSProfilePlugin.class);
|
||||||
|
|
||||||
|
private static NSProfilePlugin nsProfilePlugin;
|
||||||
|
|
||||||
|
public static NSProfilePlugin getPlugin() {
|
||||||
|
if (nsProfilePlugin == null)
|
||||||
|
nsProfilePlugin = new NSProfilePlugin();
|
||||||
|
return nsProfilePlugin;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getFragmentClass() {
|
public String getFragmentClass() {
|
||||||
return NSProfileFragment.class.getName();
|
return NSProfileFragment.class.getName();
|
||||||
}
|
}
|
||||||
|
|
||||||
static boolean fragmentEnabled = true;
|
private boolean fragmentEnabled = true;
|
||||||
static boolean fragmentVisible = true;
|
private boolean fragmentVisible = true;
|
||||||
|
|
||||||
static ProfileStore profile = null;
|
private static ProfileStore profile = null;
|
||||||
|
|
||||||
public NSProfilePlugin() {
|
private NSProfilePlugin() {
|
||||||
MainApp.bus().register(this);
|
MainApp.bus().register(this);
|
||||||
loadNSProfile();
|
loadNSProfile();
|
||||||
|
|
||||||
|
|
|
@ -12,6 +12,7 @@ import android.widget.Button;
|
||||||
import android.widget.EditText;
|
import android.widget.EditText;
|
||||||
import android.widget.RadioButton;
|
import android.widget.RadioButton;
|
||||||
|
|
||||||
|
import com.crashlytics.android.Crashlytics;
|
||||||
import com.squareup.otto.Subscribe;
|
import com.squareup.otto.Subscribe;
|
||||||
|
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
|
@ -30,12 +31,6 @@ import info.nightscout.utils.SafeParse;
|
||||||
public class SimpleProfileFragment extends SubscriberFragment {
|
public class SimpleProfileFragment extends SubscriberFragment {
|
||||||
private static Logger log = LoggerFactory.getLogger(SimpleProfileFragment.class);
|
private static Logger log = LoggerFactory.getLogger(SimpleProfileFragment.class);
|
||||||
|
|
||||||
private static SimpleProfilePlugin simpleProfilePlugin = new SimpleProfilePlugin();
|
|
||||||
|
|
||||||
public static SimpleProfilePlugin getPlugin() {
|
|
||||||
return simpleProfilePlugin;
|
|
||||||
}
|
|
||||||
|
|
||||||
EditText diaView;
|
EditText diaView;
|
||||||
RadioButton mgdlView;
|
RadioButton mgdlView;
|
||||||
RadioButton mmolView;
|
RadioButton mmolView;
|
||||||
|
@ -49,98 +44,104 @@ public class SimpleProfileFragment extends SubscriberFragment {
|
||||||
@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.simpleprofile_fragment, container, false);
|
try {
|
||||||
diaView = (EditText) layout.findViewById(R.id.simpleprofile_dia);
|
View layout = inflater.inflate(R.layout.simpleprofile_fragment, container, false);
|
||||||
mgdlView = (RadioButton) layout.findViewById(R.id.simpleprofile_mgdl);
|
diaView = (EditText) layout.findViewById(R.id.simpleprofile_dia);
|
||||||
mmolView = (RadioButton) layout.findViewById(R.id.simpleprofile_mmol);
|
mgdlView = (RadioButton) layout.findViewById(R.id.simpleprofile_mgdl);
|
||||||
icView = (EditText) layout.findViewById(R.id.simpleprofile_ic);
|
mmolView = (RadioButton) layout.findViewById(R.id.simpleprofile_mmol);
|
||||||
isfView = (EditText) layout.findViewById(R.id.simpleprofile_isf);
|
icView = (EditText) layout.findViewById(R.id.simpleprofile_ic);
|
||||||
basalView = (EditText) layout.findViewById(R.id.simpleprofile_basalrate);
|
isfView = (EditText) layout.findViewById(R.id.simpleprofile_isf);
|
||||||
targetlowView = (EditText) layout.findViewById(R.id.simpleprofile_targetlow);
|
basalView = (EditText) layout.findViewById(R.id.simpleprofile_basalrate);
|
||||||
targethighView = (EditText) layout.findViewById(R.id.simpleprofile_targethigh);
|
targetlowView = (EditText) layout.findViewById(R.id.simpleprofile_targetlow);
|
||||||
profileswitchButton = (Button) layout.findViewById(R.id.simpleprofile_profileswitch);
|
targethighView = (EditText) layout.findViewById(R.id.simpleprofile_targethigh);
|
||||||
|
profileswitchButton = (Button) layout.findViewById(R.id.simpleprofile_profileswitch);
|
||||||
|
|
||||||
PumpInterface pump = MainApp.getConfigBuilder();
|
PumpInterface pump = MainApp.getConfigBuilder();
|
||||||
if (!pump.getPumpDescription().isTempBasalCapable) {
|
if (!pump.getPumpDescription().isTempBasalCapable) {
|
||||||
layout.findViewById(R.id.simpleprofile_basalrate).setVisibility(View.GONE);
|
layout.findViewById(R.id.simpleprofile_basalrate).setVisibility(View.GONE);
|
||||||
layout.findViewById(R.id.simpleprofile_basalrate_label).setVisibility(View.GONE);
|
layout.findViewById(R.id.simpleprofile_basalrate_label).setVisibility(View.GONE);
|
||||||
|
}
|
||||||
|
|
||||||
|
updateGUI();
|
||||||
|
|
||||||
|
mgdlView.setChecked(SimpleProfilePlugin.getPlugin().mgdl);
|
||||||
|
mmolView.setChecked(SimpleProfilePlugin.getPlugin().mmol);
|
||||||
|
diaView.setText(SimpleProfilePlugin.getPlugin().dia.toString());
|
||||||
|
icView.setText(SimpleProfilePlugin.getPlugin().ic.toString());
|
||||||
|
isfView.setText(SimpleProfilePlugin.getPlugin().isf.toString());
|
||||||
|
basalView.setText(SimpleProfilePlugin.getPlugin().basal.toString());
|
||||||
|
targetlowView.setText(SimpleProfilePlugin.getPlugin().targetLow.toString());
|
||||||
|
targethighView.setText(SimpleProfilePlugin.getPlugin().targetHigh.toString());
|
||||||
|
|
||||||
|
mgdlView.setOnClickListener(new View.OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(View v) {
|
||||||
|
SimpleProfilePlugin.getPlugin().mgdl = mgdlView.isChecked();
|
||||||
|
SimpleProfilePlugin.getPlugin().mmol = !SimpleProfilePlugin.getPlugin().mgdl;
|
||||||
|
mmolView.setChecked(SimpleProfilePlugin.getPlugin().mmol);
|
||||||
|
SimpleProfilePlugin.getPlugin().storeSettings();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
mmolView.setOnClickListener(new View.OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(View v) {
|
||||||
|
SimpleProfilePlugin.getPlugin().mmol = mmolView.isChecked();
|
||||||
|
SimpleProfilePlugin.getPlugin().mgdl = !SimpleProfilePlugin.getPlugin().mmol;
|
||||||
|
mgdlView.setChecked(SimpleProfilePlugin.getPlugin().mgdl);
|
||||||
|
SimpleProfilePlugin.getPlugin().storeSettings();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
profileswitchButton.setOnClickListener(new View.OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(View view) {
|
||||||
|
NewNSTreatmentDialog newDialog = new NewNSTreatmentDialog();
|
||||||
|
final OptionsToShow profileswitch = CareportalFragment.PROFILESWITCH;
|
||||||
|
profileswitch.executeProfileSwitch = true;
|
||||||
|
newDialog.setOptions(profileswitch, R.string.careportal_profileswitch);
|
||||||
|
newDialog.show(getFragmentManager(), "NewNSTreatmentDialog");
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
TextWatcher textWatch = new TextWatcher() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void afterTextChanged(Editable s) {
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void beforeTextChanged(CharSequence s, int start,
|
||||||
|
int count, int after) {
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onTextChanged(CharSequence s, int start,
|
||||||
|
int before, int count) {
|
||||||
|
SimpleProfilePlugin.getPlugin().dia = SafeParse.stringToDouble(diaView.getText().toString());
|
||||||
|
SimpleProfilePlugin.getPlugin().ic = SafeParse.stringToDouble(icView.getText().toString());
|
||||||
|
SimpleProfilePlugin.getPlugin().isf = SafeParse.stringToDouble(isfView.getText().toString());
|
||||||
|
SimpleProfilePlugin.getPlugin().basal = SafeParse.stringToDouble(basalView.getText().toString());
|
||||||
|
SimpleProfilePlugin.getPlugin().targetLow = SafeParse.stringToDouble(targetlowView.getText().toString());
|
||||||
|
SimpleProfilePlugin.getPlugin().targetHigh = SafeParse.stringToDouble(targethighView.getText().toString());
|
||||||
|
SimpleProfilePlugin.getPlugin().storeSettings();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
diaView.addTextChangedListener(textWatch);
|
||||||
|
icView.addTextChangedListener(textWatch);
|
||||||
|
isfView.addTextChangedListener(textWatch);
|
||||||
|
basalView.addTextChangedListener(textWatch);
|
||||||
|
targetlowView.addTextChangedListener(textWatch);
|
||||||
|
targethighView.addTextChangedListener(textWatch);
|
||||||
|
|
||||||
|
updateGUI();
|
||||||
|
|
||||||
|
return layout;
|
||||||
|
} catch (Exception e) {
|
||||||
|
Crashlytics.logException(e);
|
||||||
}
|
}
|
||||||
|
|
||||||
updateGUI();
|
return null;
|
||||||
|
|
||||||
mgdlView.setChecked(simpleProfilePlugin.mgdl);
|
|
||||||
mmolView.setChecked(simpleProfilePlugin.mmol);
|
|
||||||
diaView.setText(simpleProfilePlugin.dia.toString());
|
|
||||||
icView.setText(simpleProfilePlugin.ic.toString());
|
|
||||||
isfView.setText(simpleProfilePlugin.isf.toString());
|
|
||||||
basalView.setText(simpleProfilePlugin.basal.toString());
|
|
||||||
targetlowView.setText(simpleProfilePlugin.targetLow.toString());
|
|
||||||
targethighView.setText(simpleProfilePlugin.targetHigh.toString());
|
|
||||||
|
|
||||||
mgdlView.setOnClickListener(new View.OnClickListener() {
|
|
||||||
@Override
|
|
||||||
public void onClick(View v) {
|
|
||||||
simpleProfilePlugin.mgdl = mgdlView.isChecked();
|
|
||||||
simpleProfilePlugin.mmol = !simpleProfilePlugin.mgdl;
|
|
||||||
mmolView.setChecked(simpleProfilePlugin.mmol);
|
|
||||||
simpleProfilePlugin.storeSettings();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
mmolView.setOnClickListener(new View.OnClickListener() {
|
|
||||||
@Override
|
|
||||||
public void onClick(View v) {
|
|
||||||
simpleProfilePlugin.mmol = mmolView.isChecked();
|
|
||||||
simpleProfilePlugin.mgdl = !simpleProfilePlugin.mmol;
|
|
||||||
mgdlView.setChecked(simpleProfilePlugin.mgdl);
|
|
||||||
simpleProfilePlugin.storeSettings();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
profileswitchButton.setOnClickListener(new View.OnClickListener() {
|
|
||||||
@Override
|
|
||||||
public void onClick(View view) {
|
|
||||||
NewNSTreatmentDialog newDialog = new NewNSTreatmentDialog();
|
|
||||||
final OptionsToShow profileswitch = CareportalFragment.PROFILESWITCHDIRECT;
|
|
||||||
profileswitch.executeProfileSwitch = true;
|
|
||||||
newDialog.setOptions(profileswitch, R.string.careportal_profileswitch);
|
|
||||||
newDialog.show(getFragmentManager(), "NewNSTreatmentDialog");
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
TextWatcher textWatch = new TextWatcher() {
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void afterTextChanged(Editable s) {
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void beforeTextChanged(CharSequence s, int start,
|
|
||||||
int count, int after) {
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onTextChanged(CharSequence s, int start,
|
|
||||||
int before, int count) {
|
|
||||||
simpleProfilePlugin.dia = SafeParse.stringToDouble(diaView.getText().toString());
|
|
||||||
simpleProfilePlugin.ic = SafeParse.stringToDouble(icView.getText().toString());
|
|
||||||
simpleProfilePlugin.isf = SafeParse.stringToDouble(isfView.getText().toString());
|
|
||||||
simpleProfilePlugin.basal = SafeParse.stringToDouble(basalView.getText().toString());
|
|
||||||
simpleProfilePlugin.targetLow = SafeParse.stringToDouble(targetlowView.getText().toString());
|
|
||||||
simpleProfilePlugin.targetHigh = SafeParse.stringToDouble(targethighView.getText().toString());
|
|
||||||
simpleProfilePlugin.storeSettings();
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
diaView.addTextChangedListener(textWatch);
|
|
||||||
icView.addTextChangedListener(textWatch);
|
|
||||||
isfView.addTextChangedListener(textWatch);
|
|
||||||
basalView.addTextChangedListener(textWatch);
|
|
||||||
targetlowView.addTextChangedListener(textWatch);
|
|
||||||
targethighView.addTextChangedListener(textWatch);
|
|
||||||
|
|
||||||
updateGUI();
|
|
||||||
|
|
||||||
return layout;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Subscribe
|
@Subscribe
|
||||||
|
|
|
@ -24,8 +24,16 @@ import info.nightscout.utils.SP;
|
||||||
public class SimpleProfilePlugin implements PluginBase, ProfileInterface {
|
public class SimpleProfilePlugin implements PluginBase, ProfileInterface {
|
||||||
private static Logger log = LoggerFactory.getLogger(SimpleProfilePlugin.class);
|
private static Logger log = LoggerFactory.getLogger(SimpleProfilePlugin.class);
|
||||||
|
|
||||||
private static boolean fragmentEnabled = false;
|
private static SimpleProfilePlugin simpleProfilePlugin;
|
||||||
private static boolean fragmentVisible = true;
|
|
||||||
|
public static SimpleProfilePlugin getPlugin() {
|
||||||
|
if (simpleProfilePlugin == null)
|
||||||
|
simpleProfilePlugin = new SimpleProfilePlugin();
|
||||||
|
return simpleProfilePlugin;
|
||||||
|
}
|
||||||
|
|
||||||
|
private boolean fragmentEnabled = false;
|
||||||
|
private boolean fragmentVisible = true;
|
||||||
|
|
||||||
private static ProfileStore convertedProfile = null;
|
private static ProfileStore convertedProfile = null;
|
||||||
|
|
||||||
|
@ -38,7 +46,7 @@ public class SimpleProfilePlugin implements PluginBase, ProfileInterface {
|
||||||
Double targetLow;
|
Double targetLow;
|
||||||
Double targetHigh;
|
Double targetHigh;
|
||||||
|
|
||||||
public SimpleProfilePlugin() {
|
private SimpleProfilePlugin() {
|
||||||
loadSettings();
|
loadSettings();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -117,7 +125,7 @@ public class SimpleProfilePlugin implements PluginBase, ProfileInterface {
|
||||||
editor.putString("SimpleProfile" + "targetlow", targetLow.toString());
|
editor.putString("SimpleProfile" + "targetlow", targetLow.toString());
|
||||||
editor.putString("SimpleProfile" + "targethigh", targetHigh.toString());
|
editor.putString("SimpleProfile" + "targethigh", targetHigh.toString());
|
||||||
|
|
||||||
editor.commit();
|
editor.apply();
|
||||||
createConvertedProfile();
|
createConvertedProfile();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -174,7 +182,7 @@ public class SimpleProfilePlugin implements PluginBase, ProfileInterface {
|
||||||
"created_at": "2016-06-16T08:34:41.256Z"
|
"created_at": "2016-06-16T08:34:41.256Z"
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
void createConvertedProfile() {
|
private void createConvertedProfile() {
|
||||||
JSONObject json = new JSONObject();
|
JSONObject json = new JSONObject();
|
||||||
JSONObject store = new JSONObject();
|
JSONObject store = new JSONObject();
|
||||||
JSONObject profile = new JSONObject();
|
JSONObject profile = new JSONObject();
|
||||||
|
|
|
@ -7,7 +7,6 @@ import android.content.Intent;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.os.Handler;
|
import android.os.Handler;
|
||||||
import android.os.HandlerThread;
|
import android.os.HandlerThread;
|
||||||
import android.support.v4.app.Fragment;
|
|
||||||
import android.support.v4.app.FragmentManager;
|
import android.support.v4.app.FragmentManager;
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
|
@ -15,13 +14,12 @@ import android.view.ViewGroup;
|
||||||
import android.widget.Button;
|
import android.widget.Button;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
|
||||||
|
import com.crashlytics.android.Crashlytics;
|
||||||
import com.squareup.otto.Subscribe;
|
import com.squareup.otto.Subscribe;
|
||||||
|
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
import java.util.Date;
|
|
||||||
|
|
||||||
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.EventExtendedBolusChange;
|
import info.nightscout.androidaps.events.EventExtendedBolusChange;
|
||||||
|
@ -89,63 +87,69 @@ public class DanaRFragment extends SubscriberFragment {
|
||||||
@Override
|
@Override
|
||||||
public View onCreateView(LayoutInflater inflater, ViewGroup container,
|
public View onCreateView(LayoutInflater inflater, ViewGroup container,
|
||||||
Bundle savedInstanceState) {
|
Bundle savedInstanceState) {
|
||||||
View view = inflater.inflate(R.layout.danar_fragment, container, false);
|
try {
|
||||||
btConnectionView = (TextView) view.findViewById(R.id.danar_btconnection);
|
View view = inflater.inflate(R.layout.danar_fragment, container, false);
|
||||||
lastConnectionView = (TextView) view.findViewById(R.id.danar_lastconnection);
|
btConnectionView = (TextView) view.findViewById(R.id.danar_btconnection);
|
||||||
lastBolusView = (TextView) view.findViewById(R.id.danar_lastbolus);
|
lastConnectionView = (TextView) view.findViewById(R.id.danar_lastconnection);
|
||||||
dailyUnitsView = (TextView) view.findViewById(R.id.danar_dailyunits);
|
lastBolusView = (TextView) view.findViewById(R.id.danar_lastbolus);
|
||||||
basaBasalRateView = (TextView) view.findViewById(R.id.danar_basabasalrate);
|
dailyUnitsView = (TextView) view.findViewById(R.id.danar_dailyunits);
|
||||||
tempBasalView = (TextView) view.findViewById(R.id.danar_tempbasal);
|
basaBasalRateView = (TextView) view.findViewById(R.id.danar_basabasalrate);
|
||||||
extendedBolusView = (TextView) view.findViewById(R.id.danar_extendedbolus);
|
tempBasalView = (TextView) view.findViewById(R.id.danar_tempbasal);
|
||||||
batteryView = (TextView) view.findViewById(R.id.danar_battery);
|
extendedBolusView = (TextView) view.findViewById(R.id.danar_extendedbolus);
|
||||||
reservoirView = (TextView) view.findViewById(R.id.danar_reservoir);
|
batteryView = (TextView) view.findViewById(R.id.danar_battery);
|
||||||
iobView = (TextView) view.findViewById(R.id.danar_iob);
|
reservoirView = (TextView) view.findViewById(R.id.danar_reservoir);
|
||||||
firmwareView = (TextView) view.findViewById(R.id.danar_firmware);
|
iobView = (TextView) view.findViewById(R.id.danar_iob);
|
||||||
viewProfileButton = (Button) view.findViewById(R.id.danar_viewprofile);
|
firmwareView = (TextView) view.findViewById(R.id.danar_firmware);
|
||||||
historyButton = (Button) view.findViewById(R.id.danar_history);
|
viewProfileButton = (Button) view.findViewById(R.id.danar_viewprofile);
|
||||||
statsButton = (Button) view.findViewById(R.id.danar_stats);
|
historyButton = (Button) view.findViewById(R.id.danar_history);
|
||||||
basalStepView = (TextView) view.findViewById(R.id.danar_basalstep);
|
statsButton = (Button) view.findViewById(R.id.danar_stats);
|
||||||
bolusStepView = (TextView) view.findViewById(R.id.danar_bolusstep);
|
basalStepView = (TextView) view.findViewById(R.id.danar_basalstep);
|
||||||
|
bolusStepView = (TextView) view.findViewById(R.id.danar_bolusstep);
|
||||||
|
|
||||||
|
|
||||||
viewProfileButton.setOnClickListener(new View.OnClickListener() {
|
viewProfileButton.setOnClickListener(new View.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View v) {
|
public void onClick(View v) {
|
||||||
FragmentManager manager = getFragmentManager();
|
FragmentManager manager = getFragmentManager();
|
||||||
ProfileViewDialog profileViewDialog = new ProfileViewDialog();
|
ProfileViewDialog profileViewDialog = new ProfileViewDialog();
|
||||||
profileViewDialog.show(manager, "ProfileViewDialog");
|
profileViewDialog.show(manager, "ProfileViewDialog");
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
historyButton.setOnClickListener(new View.OnClickListener() {
|
historyButton.setOnClickListener(new View.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View v) {
|
public void onClick(View v) {
|
||||||
startActivity(new Intent(getContext(), DanaRHistoryActivity.class));
|
startActivity(new Intent(getContext(), DanaRHistoryActivity.class));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
statsButton.setOnClickListener(new View.OnClickListener() {
|
statsButton.setOnClickListener(new View.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View v) {
|
public void onClick(View v) {
|
||||||
startActivity(new Intent(getContext(), DanaRStatsActivity.class));
|
startActivity(new Intent(getContext(), DanaRStatsActivity.class));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
btConnectionView.setOnClickListener(new View.OnClickListener() {
|
btConnectionView.setOnClickListener(new View.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View v) {
|
public void onClick(View v) {
|
||||||
sHandler.post(new Runnable() {
|
sHandler.post(new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
MainApp.getConfigBuilder().refreshDataFromPump("Connect request from GUI");
|
MainApp.getConfigBuilder().refreshDataFromPump("Connect request from GUI");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
);
|
||||||
);
|
}
|
||||||
}
|
});
|
||||||
});
|
|
||||||
|
|
||||||
updateGUI();
|
updateGUI();
|
||||||
return view;
|
return view;
|
||||||
|
} catch (Exception e) {
|
||||||
|
Crashlytics.logException(e);
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Subscribe
|
@Subscribe
|
||||||
|
|
|
@ -59,11 +59,11 @@ public class DanaRPlugin implements PluginBase, PumpInterface, DanaRInterface, C
|
||||||
return DanaRFragment.class.getName();
|
return DanaRFragment.class.getName();
|
||||||
}
|
}
|
||||||
|
|
||||||
static boolean fragmentPumpEnabled = false;
|
private static boolean fragmentPumpEnabled = false;
|
||||||
static boolean fragmentProfileEnabled = false;
|
private static boolean fragmentProfileEnabled = false;
|
||||||
static boolean fragmentPumpVisible = true;
|
private static boolean fragmentPumpVisible = true;
|
||||||
|
|
||||||
public static DanaRExecutionService sExecutionService;
|
private static DanaRExecutionService sExecutionService;
|
||||||
|
|
||||||
|
|
||||||
private static DanaRPump pump = DanaRPump.getInstance();
|
private static DanaRPump pump = DanaRPump.getInstance();
|
||||||
|
@ -199,22 +199,22 @@ public class DanaRPlugin implements PluginBase, PumpInterface, DanaRInterface, C
|
||||||
@Override
|
@Override
|
||||||
public void setFragmentEnabled(int type, boolean fragmentEnabled) {
|
public void setFragmentEnabled(int type, boolean fragmentEnabled) {
|
||||||
if (type == PluginBase.PROFILE)
|
if (type == PluginBase.PROFILE)
|
||||||
this.fragmentProfileEnabled = fragmentEnabled;
|
fragmentProfileEnabled = fragmentEnabled;
|
||||||
else if (type == PluginBase.PUMP)
|
else if (type == PluginBase.PUMP)
|
||||||
this.fragmentPumpEnabled = fragmentEnabled;
|
fragmentPumpEnabled = fragmentEnabled;
|
||||||
// if pump profile was enabled need to switch to another too
|
// if pump profile was enabled need to switch to another too
|
||||||
if (type == PluginBase.PUMP && !fragmentEnabled && this.fragmentProfileEnabled) {
|
if (type == PluginBase.PUMP && !fragmentEnabled && fragmentProfileEnabled) {
|
||||||
setFragmentEnabled(PluginBase.PROFILE, false);
|
setFragmentEnabled(PluginBase.PROFILE, false);
|
||||||
setFragmentVisible(PluginBase.PROFILE, false);
|
setFragmentVisible(PluginBase.PROFILE, false);
|
||||||
MainApp.getSpecificPlugin(NSProfilePlugin.class).setFragmentEnabled(PluginBase.PROFILE, true);
|
NSProfilePlugin.getPlugin().setFragmentEnabled(PluginBase.PROFILE, true);
|
||||||
MainApp.getSpecificPlugin(NSProfilePlugin.class).setFragmentVisible(PluginBase.PROFILE, true);
|
NSProfilePlugin.getPlugin().setFragmentVisible(PluginBase.PROFILE, true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setFragmentVisible(int type, boolean fragmentVisible) {
|
public void setFragmentVisible(int type, boolean fragmentVisible) {
|
||||||
if (type == PluginBase.PUMP)
|
if (type == PluginBase.PUMP)
|
||||||
this.fragmentPumpVisible = fragmentVisible;
|
fragmentPumpVisible = fragmentVisible;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -506,7 +506,8 @@ public class DanaRPlugin implements PluginBase, PumpInterface, DanaRInterface, C
|
||||||
}
|
}
|
||||||
if (percent > getPumpDescription().maxTempPercent)
|
if (percent > getPumpDescription().maxTempPercent)
|
||||||
percent = getPumpDescription().maxTempPercent;
|
percent = getPumpDescription().maxTempPercent;
|
||||||
if (pump.isTempBasalInProgress && pump.tempBasalPercent == percent) {
|
TemporaryBasal runningTB = MainApp.getConfigBuilder().getRealTempBasalFromHistory(System.currentTimeMillis());
|
||||||
|
if (runningTB != null && runningTB.percentRate == percent) {
|
||||||
result.enacted = false;
|
result.enacted = false;
|
||||||
result.success = true;
|
result.success = true;
|
||||||
result.isTempCancel = false;
|
result.isTempCancel = false;
|
||||||
|
@ -550,7 +551,8 @@ public class DanaRPlugin implements PluginBase, PumpInterface, DanaRInterface, C
|
||||||
insulin = Round.roundTo(insulin, getPumpDescription().extendedBolusStep * (1 + durationInHalfHours % 1));
|
insulin = Round.roundTo(insulin, getPumpDescription().extendedBolusStep * (1 + durationInHalfHours % 1));
|
||||||
|
|
||||||
PumpEnactResult result = new PumpEnactResult();
|
PumpEnactResult result = new PumpEnactResult();
|
||||||
if (pump.isExtendedInProgress && Math.abs(pump.extendedBolusAmount - insulin) < getPumpDescription().extendedBolusStep) {
|
ExtendedBolus runningEB = MainApp.getConfigBuilder().getExtendedBolusFromHistory(System.currentTimeMillis());
|
||||||
|
if (runningEB != null && Math.abs(runningEB.insulin - insulin) < getPumpDescription().extendedBolusStep) {
|
||||||
result.enacted = false;
|
result.enacted = false;
|
||||||
result.success = true;
|
result.success = true;
|
||||||
result.comment = MainApp.instance().getString(R.string.virtualpump_resultok);
|
result.comment = MainApp.instance().getString(R.string.virtualpump_resultok);
|
||||||
|
@ -601,7 +603,8 @@ public class DanaRPlugin implements PluginBase, PumpInterface, DanaRInterface, C
|
||||||
|
|
||||||
public PumpEnactResult cancelRealTempBasal() {
|
public PumpEnactResult cancelRealTempBasal() {
|
||||||
PumpEnactResult result = new PumpEnactResult();
|
PumpEnactResult result = new PumpEnactResult();
|
||||||
if (pump.isTempBasalInProgress) {
|
TemporaryBasal runningTB = MainApp.getConfigBuilder().getTempBasalFromHistory(System.currentTimeMillis());
|
||||||
|
if (runningTB != null) {
|
||||||
sExecutionService.tempBasalStop();
|
sExecutionService.tempBasalStop();
|
||||||
result.enacted = true;
|
result.enacted = true;
|
||||||
result.isTempCancel = true;
|
result.isTempCancel = true;
|
||||||
|
@ -625,7 +628,8 @@ public class DanaRPlugin implements PluginBase, PumpInterface, DanaRInterface, C
|
||||||
@Override
|
@Override
|
||||||
public PumpEnactResult cancelExtendedBolus() {
|
public PumpEnactResult cancelExtendedBolus() {
|
||||||
PumpEnactResult result = new PumpEnactResult();
|
PumpEnactResult result = new PumpEnactResult();
|
||||||
if (pump.isExtendedInProgress) {
|
ExtendedBolus runningEB = MainApp.getConfigBuilder().getExtendedBolusFromHistory(System.currentTimeMillis());
|
||||||
|
if (runningEB != null) {
|
||||||
sExecutionService.extendedBolusStop();
|
sExecutionService.extendedBolusStop();
|
||||||
result.enacted = true;
|
result.enacted = true;
|
||||||
result.isTempCancel = true;
|
result.isTempCancel = true;
|
||||||
|
|
|
@ -61,15 +61,15 @@ public class DanaRKoreanPlugin implements PluginBase, PumpInterface, DanaRInterf
|
||||||
return DanaRFragment.class.getName();
|
return DanaRFragment.class.getName();
|
||||||
}
|
}
|
||||||
|
|
||||||
static boolean fragmentPumpEnabled = false;
|
private boolean fragmentPumpEnabled = false;
|
||||||
static boolean fragmentProfileEnabled = false;
|
private boolean fragmentProfileEnabled = false;
|
||||||
static boolean fragmentPumpVisible = true;
|
private boolean fragmentPumpVisible = true;
|
||||||
|
|
||||||
public static DanaRKoreanExecutionService sExecutionService;
|
private static DanaRKoreanExecutionService sExecutionService;
|
||||||
|
|
||||||
|
|
||||||
private static DanaRPump pump = DanaRPump.getInstance();
|
private DanaRPump pump = DanaRPump.getInstance();
|
||||||
private static boolean useExtendedBoluses = false;
|
private boolean useExtendedBoluses = false;
|
||||||
|
|
||||||
private static DanaRKoreanPlugin plugin = null;
|
private static DanaRKoreanPlugin plugin = null;
|
||||||
|
|
||||||
|
@ -208,8 +208,8 @@ public class DanaRKoreanPlugin implements PluginBase, PumpInterface, DanaRInterf
|
||||||
if (type == PluginBase.PUMP && !fragmentEnabled && this.fragmentProfileEnabled) {
|
if (type == PluginBase.PUMP && !fragmentEnabled && this.fragmentProfileEnabled) {
|
||||||
setFragmentEnabled(PluginBase.PROFILE, false);
|
setFragmentEnabled(PluginBase.PROFILE, false);
|
||||||
setFragmentVisible(PluginBase.PROFILE, false);
|
setFragmentVisible(PluginBase.PROFILE, false);
|
||||||
MainApp.getSpecificPlugin(NSProfilePlugin.class).setFragmentEnabled(PluginBase.PROFILE, true);
|
NSProfilePlugin.getPlugin().setFragmentEnabled(PluginBase.PROFILE, true);
|
||||||
MainApp.getSpecificPlugin(NSProfilePlugin.class).setFragmentVisible(PluginBase.PROFILE, true);
|
NSProfilePlugin.getPlugin().setFragmentVisible(PluginBase.PROFILE, true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -503,7 +503,8 @@ public class DanaRKoreanPlugin implements PluginBase, PumpInterface, DanaRInterf
|
||||||
}
|
}
|
||||||
if (percent > getPumpDescription().maxTempPercent)
|
if (percent > getPumpDescription().maxTempPercent)
|
||||||
percent = getPumpDescription().maxTempPercent;
|
percent = getPumpDescription().maxTempPercent;
|
||||||
if (pump.isTempBasalInProgress && pump.tempBasalPercent == percent) {
|
TemporaryBasal runningTB = MainApp.getConfigBuilder().getRealTempBasalFromHistory(System.currentTimeMillis());
|
||||||
|
if (runningTB != null && runningTB.percentRate == percent) {
|
||||||
result.enacted = false;
|
result.enacted = false;
|
||||||
result.success = true;
|
result.success = true;
|
||||||
result.isTempCancel = false;
|
result.isTempCancel = false;
|
||||||
|
@ -547,7 +548,8 @@ public class DanaRKoreanPlugin implements PluginBase, PumpInterface, DanaRInterf
|
||||||
insulin = Round.roundTo(insulin, getPumpDescription().extendedBolusStep * (1 + durationInHalfHours % 1));
|
insulin = Round.roundTo(insulin, getPumpDescription().extendedBolusStep * (1 + durationInHalfHours % 1));
|
||||||
|
|
||||||
PumpEnactResult result = new PumpEnactResult();
|
PumpEnactResult result = new PumpEnactResult();
|
||||||
if (pump.isExtendedInProgress && Math.abs(pump.extendedBolusAmount - insulin) < getPumpDescription().extendedBolusStep) {
|
ExtendedBolus runningEB = MainApp.getConfigBuilder().getExtendedBolusFromHistory(System.currentTimeMillis());
|
||||||
|
if (runningEB != null && Math.abs(runningEB.insulin - insulin) < getPumpDescription().extendedBolusStep) {
|
||||||
result.enacted = false;
|
result.enacted = false;
|
||||||
result.success = true;
|
result.success = true;
|
||||||
result.comment = MainApp.instance().getString(R.string.virtualpump_resultok);
|
result.comment = MainApp.instance().getString(R.string.virtualpump_resultok);
|
||||||
|
@ -598,7 +600,8 @@ public class DanaRKoreanPlugin implements PluginBase, PumpInterface, DanaRInterf
|
||||||
|
|
||||||
public PumpEnactResult cancelRealTempBasal() {
|
public PumpEnactResult cancelRealTempBasal() {
|
||||||
PumpEnactResult result = new PumpEnactResult();
|
PumpEnactResult result = new PumpEnactResult();
|
||||||
if (pump.isTempBasalInProgress) {
|
TemporaryBasal runningTB = MainApp.getConfigBuilder().getTempBasalFromHistory(System.currentTimeMillis());
|
||||||
|
if (runningTB != null) {
|
||||||
sExecutionService.tempBasalStop();
|
sExecutionService.tempBasalStop();
|
||||||
result.enacted = true;
|
result.enacted = true;
|
||||||
result.isTempCancel = true;
|
result.isTempCancel = true;
|
||||||
|
@ -622,7 +625,8 @@ public class DanaRKoreanPlugin implements PluginBase, PumpInterface, DanaRInterf
|
||||||
@Override
|
@Override
|
||||||
public PumpEnactResult cancelExtendedBolus() {
|
public PumpEnactResult cancelExtendedBolus() {
|
||||||
PumpEnactResult result = new PumpEnactResult();
|
PumpEnactResult result = new PumpEnactResult();
|
||||||
if (pump.isExtendedInProgress) {
|
ExtendedBolus runningEB = MainApp.getConfigBuilder().getExtendedBolusFromHistory(System.currentTimeMillis());
|
||||||
|
if (runningEB != null) {
|
||||||
sExecutionService.extendedBolusStop();
|
sExecutionService.extendedBolusStop();
|
||||||
result.enacted = true;
|
result.enacted = true;
|
||||||
result.isTempCancel = true;
|
result.isTempCancel = true;
|
||||||
|
|
|
@ -60,11 +60,11 @@ public class DanaRv2Plugin implements PluginBase, PumpInterface, DanaRInterface,
|
||||||
return DanaRFragment.class.getName();
|
return DanaRFragment.class.getName();
|
||||||
}
|
}
|
||||||
|
|
||||||
static boolean fragmentPumpEnabled = false;
|
private boolean fragmentPumpEnabled = false;
|
||||||
static boolean fragmentProfileEnabled = false;
|
private boolean fragmentProfileEnabled = false;
|
||||||
static boolean fragmentPumpVisible = false;
|
private boolean fragmentPumpVisible = false;
|
||||||
|
|
||||||
public static DanaRv2ExecutionService sExecutionService;
|
private static DanaRv2ExecutionService sExecutionService;
|
||||||
|
|
||||||
|
|
||||||
private static DanaRv2Plugin plugin = null;
|
private static DanaRv2Plugin plugin = null;
|
||||||
|
@ -77,9 +77,9 @@ public class DanaRv2Plugin implements PluginBase, PumpInterface, DanaRInterface,
|
||||||
|
|
||||||
private static DanaRPump pump = DanaRPump.getInstance();
|
private static DanaRPump pump = DanaRPump.getInstance();
|
||||||
|
|
||||||
public static PumpDescription pumpDescription = new PumpDescription();
|
private static PumpDescription pumpDescription = new PumpDescription();
|
||||||
|
|
||||||
public DanaRv2Plugin() {
|
private DanaRv2Plugin() {
|
||||||
Context context = MainApp.instance().getApplicationContext();
|
Context context = MainApp.instance().getApplicationContext();
|
||||||
Intent intent = new Intent(context, DanaRv2ExecutionService.class);
|
Intent intent = new Intent(context, DanaRv2ExecutionService.class);
|
||||||
context.bindService(intent, mConnection, Context.BIND_AUTO_CREATE);
|
context.bindService(intent, mConnection, Context.BIND_AUTO_CREATE);
|
||||||
|
@ -192,8 +192,8 @@ public class DanaRv2Plugin implements PluginBase, PumpInterface, DanaRInterface,
|
||||||
if (type == PluginBase.PUMP && !fragmentEnabled && this.fragmentProfileEnabled) {
|
if (type == PluginBase.PUMP && !fragmentEnabled && this.fragmentProfileEnabled) {
|
||||||
setFragmentEnabled(PluginBase.PROFILE, false);
|
setFragmentEnabled(PluginBase.PROFILE, false);
|
||||||
setFragmentVisible(PluginBase.PROFILE, false);
|
setFragmentVisible(PluginBase.PROFILE, false);
|
||||||
MainApp.getSpecificPlugin(NSProfilePlugin.class).setFragmentEnabled(PluginBase.PROFILE, true);
|
NSProfilePlugin.getPlugin().setFragmentEnabled(PluginBase.PROFILE, true);
|
||||||
MainApp.getSpecificPlugin(NSProfilePlugin.class).setFragmentVisible(PluginBase.PROFILE, true);
|
NSProfilePlugin.getPlugin().setFragmentVisible(PluginBase.PROFILE, true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -429,7 +429,8 @@ public class DanaRv2Plugin implements PluginBase, PumpInterface, DanaRInterface,
|
||||||
}
|
}
|
||||||
if (percent > getPumpDescription().maxTempPercent)
|
if (percent > getPumpDescription().maxTempPercent)
|
||||||
percent = getPumpDescription().maxTempPercent;
|
percent = getPumpDescription().maxTempPercent;
|
||||||
if (pump.isTempBasalInProgress && pump.tempBasalPercent == percent) {
|
TemporaryBasal runningTB = MainApp.getConfigBuilder().getRealTempBasalFromHistory(System.currentTimeMillis());
|
||||||
|
if (runningTB != null && runningTB.percentRate == percent) {
|
||||||
result.enacted = false;
|
result.enacted = false;
|
||||||
result.success = true;
|
result.success = true;
|
||||||
result.isTempCancel = false;
|
result.isTempCancel = false;
|
||||||
|
@ -494,7 +495,8 @@ public class DanaRv2Plugin implements PluginBase, PumpInterface, DanaRInterface,
|
||||||
int durationInHalfHours = Math.max(durationInMinutes / 30, 1);
|
int durationInHalfHours = Math.max(durationInMinutes / 30, 1);
|
||||||
insulin = Round.roundTo(insulin, getPumpDescription().extendedBolusStep * (1 + durationInHalfHours % 1));
|
insulin = Round.roundTo(insulin, getPumpDescription().extendedBolusStep * (1 + durationInHalfHours % 1));
|
||||||
PumpEnactResult result = new PumpEnactResult();
|
PumpEnactResult result = new PumpEnactResult();
|
||||||
if (pump.isExtendedInProgress && Math.abs(pump.extendedBolusAmount - insulin) < getPumpDescription().extendedBolusStep) {
|
ExtendedBolus runningEB = MainApp.getConfigBuilder().getExtendedBolusFromHistory(System.currentTimeMillis());
|
||||||
|
if (runningEB != null && Math.abs(runningEB.insulin - insulin) < getPumpDescription().extendedBolusStep) {
|
||||||
result.enacted = false;
|
result.enacted = false;
|
||||||
result.success = true;
|
result.success = true;
|
||||||
result.comment = MainApp.instance().getString(R.string.virtualpump_resultok);
|
result.comment = MainApp.instance().getString(R.string.virtualpump_resultok);
|
||||||
|
@ -530,7 +532,8 @@ public class DanaRv2Plugin implements PluginBase, PumpInterface, DanaRInterface,
|
||||||
@Override
|
@Override
|
||||||
public PumpEnactResult cancelTempBasal(boolean force) {
|
public PumpEnactResult cancelTempBasal(boolean force) {
|
||||||
PumpEnactResult result = new PumpEnactResult();
|
PumpEnactResult result = new PumpEnactResult();
|
||||||
if (pump.isTempBasalInProgress) {
|
TemporaryBasal runningTB = MainApp.getConfigBuilder().getTempBasalFromHistory(System.currentTimeMillis());
|
||||||
|
if (runningTB != null) {
|
||||||
sExecutionService.tempBasalStop();
|
sExecutionService.tempBasalStop();
|
||||||
result.enacted = true;
|
result.enacted = true;
|
||||||
result.isTempCancel = true;
|
result.isTempCancel = true;
|
||||||
|
@ -554,7 +557,8 @@ public class DanaRv2Plugin implements PluginBase, PumpInterface, DanaRInterface,
|
||||||
@Override
|
@Override
|
||||||
public PumpEnactResult cancelExtendedBolus() {
|
public PumpEnactResult cancelExtendedBolus() {
|
||||||
PumpEnactResult result = new PumpEnactResult();
|
PumpEnactResult result = new PumpEnactResult();
|
||||||
if (pump.isExtendedInProgress) {
|
ExtendedBolus runningEB = MainApp.getConfigBuilder().getExtendedBolusFromHistory(System.currentTimeMillis());
|
||||||
|
if (runningEB != null) {
|
||||||
sExecutionService.extendedBolusStop();
|
sExecutionService.extendedBolusStop();
|
||||||
result.enacted = true;
|
result.enacted = true;
|
||||||
result.isTempCancel = true;
|
result.isTempCancel = true;
|
||||||
|
|
|
@ -25,12 +25,12 @@ import info.nightscout.utils.DateUtil;
|
||||||
public class MDIPlugin implements PluginBase, PumpInterface {
|
public class MDIPlugin implements PluginBase, PumpInterface {
|
||||||
private static Logger log = LoggerFactory.getLogger(MDIPlugin.class);
|
private static Logger log = LoggerFactory.getLogger(MDIPlugin.class);
|
||||||
|
|
||||||
boolean fragmentEnabled = false;
|
private boolean fragmentEnabled = false;
|
||||||
boolean fragmentVisible = false;
|
private boolean fragmentVisible = false;
|
||||||
|
|
||||||
PumpDescription pumpDescription = new PumpDescription();
|
private PumpDescription pumpDescription = new PumpDescription();
|
||||||
|
|
||||||
static MDIPlugin plugin = null;
|
private static MDIPlugin plugin = null;
|
||||||
|
|
||||||
public static MDIPlugin getPlugin() {
|
public static MDIPlugin getPlugin() {
|
||||||
if (plugin == null)
|
if (plugin == null)
|
||||||
|
@ -38,7 +38,7 @@ public class MDIPlugin implements PluginBase, PumpInterface {
|
||||||
return plugin;
|
return plugin;
|
||||||
}
|
}
|
||||||
|
|
||||||
public MDIPlugin() {
|
private MDIPlugin() {
|
||||||
pumpDescription.isBolusCapable = true;
|
pumpDescription.isBolusCapable = true;
|
||||||
pumpDescription.bolusStep = 0.5d;
|
pumpDescription.bolusStep = 0.5d;
|
||||||
|
|
||||||
|
|
|
@ -10,6 +10,7 @@ import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
|
||||||
|
import com.crashlytics.android.Crashlytics;
|
||||||
import com.squareup.otto.Subscribe;
|
import com.squareup.otto.Subscribe;
|
||||||
|
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
|
@ -50,14 +51,20 @@ public class VirtualPumpFragment extends SubscriberFragment {
|
||||||
@Override
|
@Override
|
||||||
public View onCreateView(LayoutInflater inflater, ViewGroup container,
|
public View onCreateView(LayoutInflater inflater, ViewGroup container,
|
||||||
Bundle savedInstanceState) {
|
Bundle savedInstanceState) {
|
||||||
View view = inflater.inflate(R.layout.vitualpump_fragment, container, false);
|
try {
|
||||||
basaBasalRateView = (TextView) view.findViewById(R.id.virtualpump_basabasalrate);
|
View view = inflater.inflate(R.layout.vitualpump_fragment, container, false);
|
||||||
tempBasalView = (TextView) view.findViewById(R.id.virtualpump_tempbasal);
|
basaBasalRateView = (TextView) view.findViewById(R.id.virtualpump_basabasalrate);
|
||||||
extendedBolusView = (TextView) view.findViewById(R.id.virtualpump_extendedbolus);
|
tempBasalView = (TextView) view.findViewById(R.id.virtualpump_tempbasal);
|
||||||
batteryView = (TextView) view.findViewById(R.id.virtualpump_battery);
|
extendedBolusView = (TextView) view.findViewById(R.id.virtualpump_extendedbolus);
|
||||||
reservoirView = (TextView) view.findViewById(R.id.virtualpump_reservoir);
|
batteryView = (TextView) view.findViewById(R.id.virtualpump_battery);
|
||||||
|
reservoirView = (TextView) view.findViewById(R.id.virtualpump_reservoir);
|
||||||
|
|
||||||
return view;
|
return view;
|
||||||
|
} catch (Exception e) {
|
||||||
|
Crashlytics.logException(e);
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Subscribe
|
@Subscribe
|
||||||
|
|
|
@ -39,19 +39,19 @@ public class VirtualPumpPlugin implements PluginBase, PumpInterface {
|
||||||
|
|
||||||
public static Double defaultBasalValue = 0.2d;
|
public static Double defaultBasalValue = 0.2d;
|
||||||
|
|
||||||
public static Integer batteryPercent = 50;
|
static Integer batteryPercent = 50;
|
||||||
public static Integer reservoirInUnits = 50;
|
static Integer reservoirInUnits = 50;
|
||||||
|
|
||||||
Date lastDataTime = new Date(0);
|
private Date lastDataTime = new Date(0);
|
||||||
|
|
||||||
boolean fragmentEnabled = true;
|
private boolean fragmentEnabled = true;
|
||||||
boolean fragmentVisible = true;
|
private boolean fragmentVisible = true;
|
||||||
|
|
||||||
private static boolean fromNSAreCommingFakedExtendedBoluses = false;
|
private static boolean fromNSAreCommingFakedExtendedBoluses = false;
|
||||||
|
|
||||||
PumpDescription pumpDescription = new PumpDescription();
|
private PumpDescription pumpDescription = new PumpDescription();
|
||||||
|
|
||||||
static void loadFakingStatus() {
|
private static void loadFakingStatus() {
|
||||||
fromNSAreCommingFakedExtendedBoluses = SP.getBoolean("fromNSAreCommingFakedExtendedBoluses", false);
|
fromNSAreCommingFakedExtendedBoluses = SP.getBoolean("fromNSAreCommingFakedExtendedBoluses", false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -64,7 +64,7 @@ public class VirtualPumpPlugin implements PluginBase, PumpInterface {
|
||||||
return fromNSAreCommingFakedExtendedBoluses;
|
return fromNSAreCommingFakedExtendedBoluses;
|
||||||
}
|
}
|
||||||
|
|
||||||
static VirtualPumpPlugin instance = null;
|
private static VirtualPumpPlugin instance = null;
|
||||||
public static VirtualPumpPlugin getInstance() {
|
public static VirtualPumpPlugin getInstance() {
|
||||||
loadFakingStatus();
|
loadFakingStatus();
|
||||||
if (instance == null)
|
if (instance == null)
|
||||||
|
@ -72,7 +72,7 @@ public class VirtualPumpPlugin implements PluginBase, PumpInterface {
|
||||||
return instance;
|
return instance;
|
||||||
}
|
}
|
||||||
|
|
||||||
public VirtualPumpPlugin() {
|
private VirtualPumpPlugin() {
|
||||||
pumpDescription.isBolusCapable = true;
|
pumpDescription.isBolusCapable = true;
|
||||||
pumpDescription.bolusStep = 0.1d;
|
pumpDescription.bolusStep = 0.1d;
|
||||||
|
|
||||||
|
|
|
@ -30,8 +30,8 @@ import info.nightscout.utils.SafeParse;
|
||||||
public class SensitivityAAPSPlugin implements PluginBase, SensitivityInterface{
|
public class SensitivityAAPSPlugin implements PluginBase, SensitivityInterface{
|
||||||
private static Logger log = LoggerFactory.getLogger(SensitivityAAPSPlugin.class);
|
private static Logger log = LoggerFactory.getLogger(SensitivityAAPSPlugin.class);
|
||||||
|
|
||||||
private static boolean fragmentEnabled = true;
|
private boolean fragmentEnabled = true;
|
||||||
private static boolean fragmentVisible = false;
|
private boolean fragmentVisible = false;
|
||||||
|
|
||||||
static SensitivityAAPSPlugin plugin = null;
|
static SensitivityAAPSPlugin plugin = null;
|
||||||
|
|
||||||
|
|
|
@ -28,8 +28,8 @@ import info.nightscout.utils.SafeParse;
|
||||||
public class SensitivityOref0Plugin implements PluginBase, SensitivityInterface {
|
public class SensitivityOref0Plugin implements PluginBase, SensitivityInterface {
|
||||||
private static Logger log = LoggerFactory.getLogger(IobCobCalculatorPlugin.class);
|
private static Logger log = LoggerFactory.getLogger(IobCobCalculatorPlugin.class);
|
||||||
|
|
||||||
private static boolean fragmentEnabled = true;
|
private boolean fragmentEnabled = true;
|
||||||
private static boolean fragmentVisible = false;
|
private boolean fragmentVisible = false;
|
||||||
|
|
||||||
static SensitivityOref0Plugin plugin = null;
|
static SensitivityOref0Plugin plugin = null;
|
||||||
|
|
||||||
|
|
|
@ -29,8 +29,8 @@ import info.nightscout.utils.SafeParse;
|
||||||
public class SensitivityWeightedAveragePlugin implements PluginBase, SensitivityInterface {
|
public class SensitivityWeightedAveragePlugin implements PluginBase, SensitivityInterface {
|
||||||
private static Logger log = LoggerFactory.getLogger(SensitivityWeightedAveragePlugin.class);
|
private static Logger log = LoggerFactory.getLogger(SensitivityWeightedAveragePlugin.class);
|
||||||
|
|
||||||
private static boolean fragmentEnabled = true;
|
private boolean fragmentEnabled = true;
|
||||||
private static boolean fragmentVisible = false;
|
private boolean fragmentVisible = false;
|
||||||
|
|
||||||
static SensitivityWeightedAveragePlugin plugin = null;
|
static SensitivityWeightedAveragePlugin plugin = null;
|
||||||
|
|
||||||
|
|
|
@ -10,6 +10,7 @@ import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
|
||||||
|
import com.crashlytics.android.Crashlytics;
|
||||||
import com.squareup.otto.Subscribe;
|
import com.squareup.otto.Subscribe;
|
||||||
|
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
|
@ -18,7 +19,6 @@ import org.slf4j.LoggerFactory;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.Comparator;
|
import java.util.Comparator;
|
||||||
|
|
||||||
import info.nightscout.androidaps.MainApp;
|
|
||||||
import info.nightscout.androidaps.R;
|
import info.nightscout.androidaps.R;
|
||||||
import info.nightscout.androidaps.plugins.Common.SubscriberFragment;
|
import info.nightscout.androidaps.plugins.Common.SubscriberFragment;
|
||||||
import info.nightscout.androidaps.plugins.SmsCommunicator.events.EventSmsCommunicatorUpdateGui;
|
import info.nightscout.androidaps.plugins.SmsCommunicator.events.EventSmsCommunicatorUpdateGui;
|
||||||
|
@ -30,16 +30,6 @@ import info.nightscout.utils.DateUtil;
|
||||||
public class SmsCommunicatorFragment extends SubscriberFragment {
|
public class SmsCommunicatorFragment extends SubscriberFragment {
|
||||||
private static Logger log = LoggerFactory.getLogger(SmsCommunicatorFragment.class);
|
private static Logger log = LoggerFactory.getLogger(SmsCommunicatorFragment.class);
|
||||||
|
|
||||||
private static SmsCommunicatorPlugin smsCommunicatorPlugin;
|
|
||||||
|
|
||||||
public static SmsCommunicatorPlugin getPlugin() {
|
|
||||||
|
|
||||||
if(smsCommunicatorPlugin==null){
|
|
||||||
smsCommunicatorPlugin = new SmsCommunicatorPlugin();
|
|
||||||
}
|
|
||||||
return smsCommunicatorPlugin;
|
|
||||||
}
|
|
||||||
|
|
||||||
TextView logView;
|
TextView logView;
|
||||||
|
|
||||||
public SmsCommunicatorFragment() {
|
public SmsCommunicatorFragment() {
|
||||||
|
@ -49,12 +39,18 @@ public class SmsCommunicatorFragment extends SubscriberFragment {
|
||||||
@Override
|
@Override
|
||||||
public View onCreateView(LayoutInflater inflater, ViewGroup container,
|
public View onCreateView(LayoutInflater inflater, ViewGroup container,
|
||||||
Bundle savedInstanceState) {
|
Bundle savedInstanceState) {
|
||||||
View view = inflater.inflate(R.layout.smscommunicator_fragment, container, false);
|
try {
|
||||||
|
View view = inflater.inflate(R.layout.smscommunicator_fragment, container, false);
|
||||||
|
|
||||||
logView = (TextView) view.findViewById(R.id.smscommunicator_log);
|
logView = (TextView) view.findViewById(R.id.smscommunicator_log);
|
||||||
|
|
||||||
updateGUI();
|
updateGUI();
|
||||||
return view;
|
return view;
|
||||||
|
} catch (Exception e) {
|
||||||
|
Crashlytics.logException(e);
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Subscribe
|
@Subscribe
|
||||||
|
@ -75,14 +71,14 @@ public class SmsCommunicatorFragment extends SubscriberFragment {
|
||||||
return (int) (object1.date.getTime() - object2.date.getTime());
|
return (int) (object1.date.getTime() - object2.date.getTime());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Collections.sort(getPlugin().messages, new CustomComparator());
|
Collections.sort(SmsCommunicatorPlugin.getPlugin().messages, new CustomComparator());
|
||||||
int messagesToShow = 40;
|
int messagesToShow = 40;
|
||||||
|
|
||||||
int start = Math.max(0, getPlugin().messages.size() - messagesToShow);
|
int start = Math.max(0, SmsCommunicatorPlugin.getPlugin().messages.size() - messagesToShow);
|
||||||
|
|
||||||
String logText = "";
|
String logText = "";
|
||||||
for (int x = start; x < getPlugin().messages.size(); x++) {
|
for (int x = start; x < SmsCommunicatorPlugin.getPlugin().messages.size(); x++) {
|
||||||
SmsCommunicatorPlugin.Sms sms = getPlugin().messages.get(x);
|
SmsCommunicatorPlugin.Sms sms = SmsCommunicatorPlugin.getPlugin().messages.get(x);
|
||||||
if (sms.received) {
|
if (sms.received) {
|
||||||
logText += DateUtil.timeString(sms.date) + " <<< " + (sms.processed ? "● " : "○ ") + sms.phoneNumber + " <b>" + sms.text + "</b><br>";
|
logText += DateUtil.timeString(sms.date) + " <<< " + (sms.processed ? "● " : "○ ") + sms.phoneNumber + " <b>" + sms.text + "</b><br>";
|
||||||
} else if (sms.sent) {
|
} else if (sms.sent) {
|
||||||
|
|
|
@ -53,12 +53,22 @@ import info.nightscout.utils.XdripCalibrations;
|
||||||
public class SmsCommunicatorPlugin implements PluginBase {
|
public class SmsCommunicatorPlugin implements PluginBase {
|
||||||
private static Logger log = LoggerFactory.getLogger(SmsCommunicatorPlugin.class);
|
private static Logger log = LoggerFactory.getLogger(SmsCommunicatorPlugin.class);
|
||||||
|
|
||||||
private static boolean fragmentEnabled = false;
|
private static SmsCommunicatorPlugin smsCommunicatorPlugin;
|
||||||
private static boolean fragmentVisible = true;
|
|
||||||
|
public static SmsCommunicatorPlugin getPlugin() {
|
||||||
|
|
||||||
|
if (smsCommunicatorPlugin == null) {
|
||||||
|
smsCommunicatorPlugin = new SmsCommunicatorPlugin();
|
||||||
|
}
|
||||||
|
return smsCommunicatorPlugin;
|
||||||
|
}
|
||||||
|
|
||||||
|
private boolean fragmentEnabled = false;
|
||||||
|
private boolean fragmentVisible = true;
|
||||||
|
|
||||||
private final long CONFIRM_TIMEOUT = 5 * 60 * 1000L;
|
private final long CONFIRM_TIMEOUT = 5 * 60 * 1000L;
|
||||||
|
|
||||||
private List<String> allowedNumbers = new ArrayList<String>();
|
private List<String> allowedNumbers = new ArrayList<>();
|
||||||
|
|
||||||
class Sms {
|
class Sms {
|
||||||
String phoneNumber;
|
String phoneNumber;
|
||||||
|
@ -110,7 +120,7 @@ public class SmsCommunicatorPlugin implements PluginBase {
|
||||||
|
|
||||||
ArrayList<Sms> messages = new ArrayList<>();
|
ArrayList<Sms> messages = new ArrayList<>();
|
||||||
|
|
||||||
public SmsCommunicatorPlugin() {
|
private SmsCommunicatorPlugin() {
|
||||||
MainApp.bus().register(this);
|
MainApp.bus().register(this);
|
||||||
processSettings(null);
|
processSettings(null);
|
||||||
}
|
}
|
||||||
|
@ -274,8 +284,8 @@ public class SmsCommunicatorPlugin implements PluginBase {
|
||||||
loopPlugin.setFragmentEnabled(PluginBase.LOOP, false);
|
loopPlugin.setFragmentEnabled(PluginBase.LOOP, false);
|
||||||
PumpEnactResult result = MainApp.getConfigBuilder().cancelTempBasal(true);
|
PumpEnactResult result = MainApp.getConfigBuilder().cancelTempBasal(true);
|
||||||
MainApp.bus().post(new EventRefreshOverview("SMS_LOOP_STOP"));
|
MainApp.bus().post(new EventRefreshOverview("SMS_LOOP_STOP"));
|
||||||
reply = MainApp.sResources.getString(R.string.smscommunicator_loophasbeendisabled)+ " " +
|
reply = MainApp.sResources.getString(R.string.smscommunicator_loophasbeendisabled) + " " +
|
||||||
MainApp.sResources.getString(result.success?R.string.smscommunicator_tempbasalcanceled:R.string.smscommunicator_tempbasalcancelfailed);
|
MainApp.sResources.getString(result.success ? R.string.smscommunicator_tempbasalcanceled : R.string.smscommunicator_tempbasalcancelfailed);
|
||||||
sendSMS(new Sms(receivedSms.phoneNumber, reply, new Date()));
|
sendSMS(new Sms(receivedSms.phoneNumber, reply, new Date()));
|
||||||
}
|
}
|
||||||
receivedSms.processed = true;
|
receivedSms.processed = true;
|
||||||
|
@ -539,7 +549,7 @@ public class SmsCommunicatorPlugin implements PluginBase {
|
||||||
NSUpload.uploadOpenAPSOffline(suspendWaitingForConfirmation.duration * 60);
|
NSUpload.uploadOpenAPSOffline(suspendWaitingForConfirmation.duration * 60);
|
||||||
MainApp.bus().post(new EventRefreshOverview("SMS_LOOP_SUSPENDED"));
|
MainApp.bus().post(new EventRefreshOverview("SMS_LOOP_SUSPENDED"));
|
||||||
reply = MainApp.sResources.getString(R.string.smscommunicator_loopsuspended) + " " +
|
reply = MainApp.sResources.getString(R.string.smscommunicator_loopsuspended) + " " +
|
||||||
MainApp.sResources.getString(result.success?R.string.smscommunicator_tempbasalcanceled:R.string.smscommunicator_tempbasalcancelfailed);
|
MainApp.sResources.getString(result.success ? R.string.smscommunicator_tempbasalcanceled : R.string.smscommunicator_tempbasalcancelfailed);
|
||||||
sendSMSToAllNumbers(new Sms(receivedSms.phoneNumber, reply, new Date()));
|
sendSMSToAllNumbers(new Sms(receivedSms.phoneNumber, reply, new Date()));
|
||||||
} else {
|
} else {
|
||||||
sendSMS(new Sms(receivedSms.phoneNumber, MainApp.sResources.getString(R.string.smscommunicator_unknowncommand), new Date()));
|
sendSMS(new Sms(receivedSms.phoneNumber, MainApp.sResources.getString(R.string.smscommunicator_unknowncommand), new Date()));
|
||||||
|
|
|
@ -9,9 +9,9 @@ import info.nightscout.androidaps.interfaces.PluginBase;
|
||||||
* Created by mike on 05.08.2016.
|
* Created by mike on 05.08.2016.
|
||||||
*/
|
*/
|
||||||
public class SourceGlimpPlugin implements PluginBase, BgSourceInterface {
|
public class SourceGlimpPlugin implements PluginBase, BgSourceInterface {
|
||||||
boolean fragmentEnabled = false;
|
private boolean fragmentEnabled = false;
|
||||||
|
|
||||||
static SourceGlimpPlugin plugin = null;
|
private static SourceGlimpPlugin plugin = null;
|
||||||
|
|
||||||
public static SourceGlimpPlugin getPlugin() {
|
public static SourceGlimpPlugin getPlugin() {
|
||||||
if (plugin == null)
|
if (plugin == null)
|
||||||
|
|
|
@ -9,9 +9,9 @@ import info.nightscout.androidaps.interfaces.PluginBase;
|
||||||
* Created by mike on 05.08.2016.
|
* Created by mike on 05.08.2016.
|
||||||
*/
|
*/
|
||||||
public class SourceMM640gPlugin implements PluginBase, BgSourceInterface {
|
public class SourceMM640gPlugin implements PluginBase, BgSourceInterface {
|
||||||
boolean fragmentEnabled = false;
|
private boolean fragmentEnabled = false;
|
||||||
|
|
||||||
static SourceMM640gPlugin plugin = null;
|
private static SourceMM640gPlugin plugin = null;
|
||||||
|
|
||||||
public static SourceMM640gPlugin getPlugin() {
|
public static SourceMM640gPlugin getPlugin() {
|
||||||
if (plugin == null)
|
if (plugin == null)
|
||||||
|
|
|
@ -10,9 +10,9 @@ import info.nightscout.androidaps.interfaces.PluginBase;
|
||||||
* Created by mike on 05.08.2016.
|
* Created by mike on 05.08.2016.
|
||||||
*/
|
*/
|
||||||
public class SourceNSClientPlugin implements PluginBase, BgSourceInterface {
|
public class SourceNSClientPlugin implements PluginBase, BgSourceInterface {
|
||||||
boolean fragmentEnabled = true;
|
private boolean fragmentEnabled = true;
|
||||||
|
|
||||||
static SourceNSClientPlugin plugin = null;
|
private static SourceNSClientPlugin plugin = null;
|
||||||
|
|
||||||
public static SourceNSClientPlugin getPlugin() {
|
public static SourceNSClientPlugin getPlugin() {
|
||||||
if (plugin == null)
|
if (plugin == null)
|
||||||
|
|
|
@ -10,7 +10,7 @@ import info.nightscout.androidaps.interfaces.PluginBase;
|
||||||
*/
|
*/
|
||||||
public class SourceXdripPlugin implements PluginBase, BgSourceInterface {
|
public class SourceXdripPlugin implements PluginBase, BgSourceInterface {
|
||||||
|
|
||||||
static SourceXdripPlugin plugin = null;
|
private static SourceXdripPlugin plugin = null;
|
||||||
|
|
||||||
public static SourceXdripPlugin getPlugin() {
|
public static SourceXdripPlugin getPlugin() {
|
||||||
if (plugin == null)
|
if (plugin == null)
|
||||||
|
@ -23,7 +23,7 @@ public class SourceXdripPlugin implements PluginBase, BgSourceInterface {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static boolean fragmentEnabled = false;
|
private boolean fragmentEnabled = false;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getType() {
|
public int getType() {
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
package info.nightscout.androidaps.plugins.Treatments;
|
package info.nightscout.androidaps.plugins.Treatments;
|
||||||
|
|
||||||
import android.content.Context;
|
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.support.v4.app.Fragment;
|
import android.support.v4.app.Fragment;
|
||||||
import android.support.v4.app.FragmentTransaction;
|
import android.support.v4.app.FragmentTransaction;
|
||||||
|
@ -9,6 +8,8 @@ import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
|
||||||
|
import com.crashlytics.android.Crashlytics;
|
||||||
|
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
|
@ -23,12 +24,6 @@ import info.nightscout.androidaps.plugins.Treatments.fragments.TreatmentsTempora
|
||||||
public class TreatmentsFragment extends Fragment implements View.OnClickListener {
|
public class TreatmentsFragment extends Fragment implements View.OnClickListener {
|
||||||
private static Logger log = LoggerFactory.getLogger(TreatmentsFragment.class);
|
private static Logger log = LoggerFactory.getLogger(TreatmentsFragment.class);
|
||||||
|
|
||||||
private static TreatmentsPlugin treatmentsPlugin = new TreatmentsPlugin();
|
|
||||||
|
|
||||||
public static TreatmentsPlugin getPlugin() {
|
|
||||||
return treatmentsPlugin;
|
|
||||||
}
|
|
||||||
|
|
||||||
TextView treatmentsTab;
|
TextView treatmentsTab;
|
||||||
TextView extendedBolusesTab;
|
TextView extendedBolusesTab;
|
||||||
TextView tempBasalsTab;
|
TextView tempBasalsTab;
|
||||||
|
@ -38,23 +33,30 @@ public class TreatmentsFragment extends Fragment implements View.OnClickListener
|
||||||
@Override
|
@Override
|
||||||
public View onCreateView(LayoutInflater inflater, ViewGroup container,
|
public View onCreateView(LayoutInflater inflater, ViewGroup container,
|
||||||
Bundle savedInstanceState) {
|
Bundle savedInstanceState) {
|
||||||
View view = inflater.inflate(R.layout.treatments_fragment, container, false);
|
try {
|
||||||
|
View view = inflater.inflate(R.layout.treatments_fragment, container, false);
|
||||||
|
|
||||||
treatmentsTab = (TextView) view.findViewById(R.id.treatments_treatments);
|
treatmentsTab = (TextView) view.findViewById(R.id.treatments_treatments);
|
||||||
extendedBolusesTab = (TextView) view.findViewById(R.id.treatments_extendedboluses);
|
extendedBolusesTab = (TextView) view.findViewById(R.id.treatments_extendedboluses);
|
||||||
tempBasalsTab = (TextView) view.findViewById(R.id.treatments_tempbasals);
|
tempBasalsTab = (TextView) view.findViewById(R.id.treatments_tempbasals);
|
||||||
tempTargetTab = (TextView) view.findViewById(R.id.treatments_temptargets);
|
tempTargetTab = (TextView) view.findViewById(R.id.treatments_temptargets);
|
||||||
profileSwitchTab = (TextView) view.findViewById(R.id.treatments_profileswitches);
|
profileSwitchTab = (TextView) view.findViewById(R.id.treatments_profileswitches);
|
||||||
treatmentsTab.setOnClickListener(this);
|
treatmentsTab.setOnClickListener(this);
|
||||||
extendedBolusesTab.setOnClickListener(this);
|
extendedBolusesTab.setOnClickListener(this);
|
||||||
tempBasalsTab.setOnClickListener(this);
|
tempBasalsTab.setOnClickListener(this);
|
||||||
tempTargetTab.setOnClickListener(this);
|
tempTargetTab.setOnClickListener(this);
|
||||||
profileSwitchTab.setOnClickListener(this);
|
profileSwitchTab.setOnClickListener(this);
|
||||||
|
|
||||||
setFragment(new TreatmentsBolusFragment());
|
setFragment(new TreatmentsBolusFragment());
|
||||||
setBackgroundColorOnSelected(treatmentsTab);
|
setBackgroundColorOnSelected(treatmentsTab);
|
||||||
|
|
||||||
|
return view;
|
||||||
|
} catch (Exception e) {
|
||||||
|
Crashlytics.logException(e);
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
|
||||||
return view;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -45,17 +45,25 @@ import info.nightscout.utils.SP;
|
||||||
public class TreatmentsPlugin implements PluginBase, TreatmentsInterface {
|
public class TreatmentsPlugin implements PluginBase, TreatmentsInterface {
|
||||||
private static Logger log = LoggerFactory.getLogger(TreatmentsPlugin.class);
|
private static Logger log = LoggerFactory.getLogger(TreatmentsPlugin.class);
|
||||||
|
|
||||||
public static IobTotal lastTreatmentCalculation;
|
private static TreatmentsPlugin treatmentsPlugin;
|
||||||
public static IobTotal lastTempBasalsCalculation;
|
|
||||||
|
public static TreatmentsPlugin getPlugin() {
|
||||||
|
if (treatmentsPlugin == null)
|
||||||
|
treatmentsPlugin = new TreatmentsPlugin();
|
||||||
|
return treatmentsPlugin;
|
||||||
|
}
|
||||||
|
|
||||||
|
private IobTotal lastTreatmentCalculation;
|
||||||
|
private IobTotal lastTempBasalsCalculation;
|
||||||
|
|
||||||
public static List<Treatment> treatments;
|
public static List<Treatment> treatments;
|
||||||
private static Intervals<TemporaryBasal> tempBasals = new NonOverlappingIntervals<TemporaryBasal>();
|
private static Intervals<TemporaryBasal> tempBasals = new NonOverlappingIntervals<>();
|
||||||
private static Intervals<ExtendedBolus> extendedBoluses = new NonOverlappingIntervals<ExtendedBolus>();
|
private static Intervals<ExtendedBolus> extendedBoluses = new NonOverlappingIntervals<>();
|
||||||
private static Intervals<TempTarget> tempTargets = new OverlappingIntervals<TempTarget>();
|
private static Intervals<TempTarget> tempTargets = new OverlappingIntervals<>();
|
||||||
private static ProfileIntervals<ProfileSwitch> profiles = new ProfileIntervals<>();
|
private static ProfileIntervals<ProfileSwitch> profiles = new ProfileIntervals<>();
|
||||||
|
|
||||||
private static boolean fragmentEnabled = true;
|
private boolean fragmentEnabled = true;
|
||||||
private static boolean fragmentVisible = true;
|
private boolean fragmentVisible = true;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getFragmentClass() {
|
public String getFragmentClass() {
|
||||||
|
@ -118,7 +126,7 @@ public class TreatmentsPlugin implements PluginBase, TreatmentsInterface {
|
||||||
return PluginBase.TREATMENT;
|
return PluginBase.TREATMENT;
|
||||||
}
|
}
|
||||||
|
|
||||||
public TreatmentsPlugin() {
|
private TreatmentsPlugin() {
|
||||||
MainApp.bus().register(this);
|
MainApp.bus().register(this);
|
||||||
initializeTempBasalData();
|
initializeTempBasalData();
|
||||||
initializeTreatmentData();
|
initializeTreatmentData();
|
||||||
|
@ -127,7 +135,7 @@ public class TreatmentsPlugin implements PluginBase, TreatmentsInterface {
|
||||||
initializeProfileSwitchData();
|
initializeProfileSwitchData();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void initializeTreatmentData() {
|
private static void initializeTreatmentData() {
|
||||||
// Treatments
|
// Treatments
|
||||||
double dia = MainApp.getConfigBuilder() == null ? Constants.defaultDIA : MainApp.getConfigBuilder().getProfile().getDia();
|
double dia = MainApp.getConfigBuilder() == null ? Constants.defaultDIA : MainApp.getConfigBuilder().getProfile().getDia();
|
||||||
long fromMills = (long) (System.currentTimeMillis() - 60 * 60 * 1000L * (24 + dia));
|
long fromMills = (long) (System.currentTimeMillis() - 60 * 60 * 1000L * (24 + dia));
|
||||||
|
@ -135,7 +143,7 @@ public class TreatmentsPlugin implements PluginBase, TreatmentsInterface {
|
||||||
treatments = MainApp.getDbHelper().getTreatmentDataFromTime(fromMills, false);
|
treatments = MainApp.getDbHelper().getTreatmentDataFromTime(fromMills, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void initializeTempBasalData() {
|
private static void initializeTempBasalData() {
|
||||||
// Treatments
|
// Treatments
|
||||||
double dia = MainApp.getConfigBuilder() == null ? Constants.defaultDIA : MainApp.getConfigBuilder().getProfile().getDia();
|
double dia = MainApp.getConfigBuilder() == null ? Constants.defaultDIA : MainApp.getConfigBuilder().getProfile().getDia();
|
||||||
long fromMills = (long) (System.currentTimeMillis() - 60 * 60 * 1000L * (24 + dia));
|
long fromMills = (long) (System.currentTimeMillis() - 60 * 60 * 1000L * (24 + dia));
|
||||||
|
@ -144,7 +152,7 @@ public class TreatmentsPlugin implements PluginBase, TreatmentsInterface {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void initializeExtendedBolusData() {
|
private static void initializeExtendedBolusData() {
|
||||||
// Treatments
|
// Treatments
|
||||||
double dia = MainApp.getConfigBuilder() == null ? Constants.defaultDIA : MainApp.getConfigBuilder().getProfile().getDia();
|
double dia = MainApp.getConfigBuilder() == null ? Constants.defaultDIA : MainApp.getConfigBuilder().getProfile().getDia();
|
||||||
long fromMills = (long) (System.currentTimeMillis() - 60 * 60 * 1000L * (24 + dia));
|
long fromMills = (long) (System.currentTimeMillis() - 60 * 60 * 1000L * (24 + dia));
|
||||||
|
@ -153,12 +161,12 @@ public class TreatmentsPlugin implements PluginBase, TreatmentsInterface {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void initializeTempTargetData() {
|
private void initializeTempTargetData() {
|
||||||
long fromMills = System.currentTimeMillis() - 60 * 60 * 1000L * 24;
|
long fromMills = System.currentTimeMillis() - 60 * 60 * 1000L * 24;
|
||||||
tempTargets.reset().add(MainApp.getDbHelper().getTemptargetsDataFromTime(fromMills, false));
|
tempTargets.reset().add(MainApp.getDbHelper().getTemptargetsDataFromTime(fromMills, false));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void initializeProfileSwitchData() {
|
private void initializeProfileSwitchData() {
|
||||||
profiles.reset().add(MainApp.getDbHelper().getProfileSwitchData(false));
|
profiles.reset().add(MainApp.getDbHelper().getProfileSwitchData(false));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -211,9 +219,7 @@ public class TreatmentsPlugin implements PluginBase, TreatmentsInterface {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void updateTotalIOBTreatments() {
|
public void updateTotalIOBTreatments() {
|
||||||
IobTotal total = getCalculationToTimeTreatments(System.currentTimeMillis());
|
lastTreatmentCalculation = getCalculationToTimeTreatments(System.currentTimeMillis());
|
||||||
|
|
||||||
lastTreatmentCalculation = total;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -224,7 +230,7 @@ public class TreatmentsPlugin implements PluginBase, TreatmentsInterface {
|
||||||
if (profile == null) return result;
|
if (profile == null) return result;
|
||||||
|
|
||||||
long now = System.currentTimeMillis();
|
long now = System.currentTimeMillis();
|
||||||
long dia_ago = now - (new Double(1.5d * profile.getDia() * 60 * 60 * 1000l)).longValue();
|
long dia_ago = now - (Double.valueOf(1.5d * profile.getDia() * 60 * 60 * 1000l)).longValue();
|
||||||
|
|
||||||
for (Treatment treatment : treatments) {
|
for (Treatment treatment : treatments) {
|
||||||
if (!treatment.isValid)
|
if (!treatment.isValid)
|
||||||
|
@ -291,6 +297,7 @@ public class TreatmentsPlugin implements PluginBase, TreatmentsInterface {
|
||||||
initializeTreatmentData();
|
initializeTreatmentData();
|
||||||
initializeExtendedBolusData();
|
initializeExtendedBolusData();
|
||||||
updateTotalIOBTreatments();
|
updateTotalIOBTreatments();
|
||||||
|
MainApp.bus().post(ev.next);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Subscribe
|
@Subscribe
|
||||||
|
@ -339,9 +346,7 @@ public class TreatmentsPlugin implements PluginBase, TreatmentsInterface {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void updateTotalIOBTempBasals() {
|
public void updateTotalIOBTempBasals() {
|
||||||
IobTotal total = getCalculationToTimeTempBasals(System.currentTimeMillis());
|
lastTempBasalsCalculation = getCalculationToTimeTempBasals(System.currentTimeMillis());
|
||||||
|
|
||||||
lastTempBasalsCalculation = total;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
|
|
|
@ -6,7 +6,6 @@ import android.content.DialogInterface;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.graphics.Paint;
|
import android.graphics.Paint;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.support.v4.app.Fragment;
|
|
||||||
import android.support.v4.content.ContextCompat;
|
import android.support.v4.content.ContextCompat;
|
||||||
import android.support.v7.app.AlertDialog;
|
import android.support.v7.app.AlertDialog;
|
||||||
import android.support.v7.widget.CardView;
|
import android.support.v7.widget.CardView;
|
||||||
|
@ -25,18 +24,17 @@ import com.squareup.otto.Subscribe;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
import java.util.Date;
|
|
||||||
import java.util.List;
|
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.Services.Intents;
|
import info.nightscout.androidaps.Services.Intents;
|
||||||
import info.nightscout.androidaps.data.Iob;
|
import info.nightscout.androidaps.data.Iob;
|
||||||
|
import info.nightscout.androidaps.data.Profile;
|
||||||
import info.nightscout.androidaps.db.Source;
|
import info.nightscout.androidaps.db.Source;
|
||||||
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.data.Profile;
|
|
||||||
import info.nightscout.androidaps.plugins.Common.SubscriberFragment;
|
import info.nightscout.androidaps.plugins.Common.SubscriberFragment;
|
||||||
import info.nightscout.androidaps.plugins.Treatments.TreatmentsPlugin;
|
import info.nightscout.androidaps.plugins.Treatments.TreatmentsPlugin;
|
||||||
import info.nightscout.utils.DateUtil;
|
import info.nightscout.utils.DateUtil;
|
||||||
|
@ -232,10 +230,10 @@ public class TreatmentsBolusFragment extends SubscriberFragment implements View.
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
recyclerView.swapAdapter(new RecyclerViewAdapter(TreatmentsPlugin.treatments), false);
|
recyclerView.swapAdapter(new RecyclerViewAdapter(TreatmentsPlugin.treatments), false);
|
||||||
if (TreatmentsPlugin.lastTreatmentCalculation != null)
|
if (TreatmentsPlugin.getPlugin().getLastCalculationTreatments() != null) {
|
||||||
iobTotal.setText(DecimalFormatter.to2Decimal(TreatmentsPlugin.lastTreatmentCalculation.iob) + " U");
|
iobTotal.setText(DecimalFormatter.to2Decimal(TreatmentsPlugin.getPlugin().getLastCalculationTreatments().iob) + " U");
|
||||||
if (TreatmentsPlugin.lastTreatmentCalculation != null)
|
activityTotal.setText(DecimalFormatter.to3Decimal(TreatmentsPlugin.getPlugin().getLastCalculationTreatments().activity) + " U");
|
||||||
activityTotal.setText(DecimalFormatter.to3Decimal(TreatmentsPlugin.lastTreatmentCalculation.activity) + " U");
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -29,8 +29,8 @@ import info.nightscout.utils.SP;
|
||||||
|
|
||||||
public class WearPlugin implements PluginBase {
|
public class WearPlugin implements PluginBase {
|
||||||
|
|
||||||
static boolean fragmentEnabled = Config.WEAR;
|
private static boolean fragmentEnabled = Config.WEAR;
|
||||||
static boolean fragmentVisible = true;
|
private boolean fragmentVisible = true;
|
||||||
private static WatchUpdaterService watchUS;
|
private static WatchUpdaterService watchUS;
|
||||||
private final Context ctx;
|
private final Context ctx;
|
||||||
|
|
||||||
|
|
|
@ -23,6 +23,7 @@ import info.nightscout.androidaps.events.EventTempBasalChange;
|
||||||
import info.nightscout.androidaps.events.EventTreatmentChange;
|
import info.nightscout.androidaps.events.EventTreatmentChange;
|
||||||
import info.nightscout.androidaps.interfaces.PluginBase;
|
import info.nightscout.androidaps.interfaces.PluginBase;
|
||||||
import info.nightscout.androidaps.interfaces.TreatmentsInterface;
|
import info.nightscout.androidaps.interfaces.TreatmentsInterface;
|
||||||
|
import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderPlugin;
|
||||||
import info.nightscout.androidaps.plugins.Loop.LoopPlugin;
|
import info.nightscout.androidaps.plugins.Loop.LoopPlugin;
|
||||||
import info.nightscout.utils.DecimalFormatter;
|
import info.nightscout.utils.DecimalFormatter;
|
||||||
|
|
||||||
|
@ -33,16 +34,16 @@ import info.nightscout.utils.DecimalFormatter;
|
||||||
public class StatuslinePlugin implements PluginBase {
|
public class StatuslinePlugin implements PluginBase {
|
||||||
|
|
||||||
//broadcast related constants
|
//broadcast related constants
|
||||||
public static final String EXTRA_STATUSLINE = "com.eveningoutpost.dexdrip.Extras.Statusline";
|
private static final String EXTRA_STATUSLINE = "com.eveningoutpost.dexdrip.Extras.Statusline";
|
||||||
public static final String ACTION_NEW_EXTERNAL_STATUSLINE = "com.eveningoutpost.dexdrip.ExternalStatusline";
|
private static final String ACTION_NEW_EXTERNAL_STATUSLINE = "com.eveningoutpost.dexdrip.ExternalStatusline";
|
||||||
public static final String RECEIVER_PERMISSION = "com.eveningoutpost.dexdrip.permissions.RECEIVE_EXTERNAL_STATUSLINE";
|
private static final String RECEIVER_PERMISSION = "com.eveningoutpost.dexdrip.permissions.RECEIVE_EXTERNAL_STATUSLINE";
|
||||||
|
|
||||||
|
|
||||||
static boolean fragmentEnabled = false;
|
private boolean fragmentEnabled = false;
|
||||||
private static boolean lastLoopStatus;
|
private boolean lastLoopStatus;
|
||||||
|
|
||||||
private final Context ctx;
|
private final Context ctx;
|
||||||
SharedPreferences mPrefs;
|
private SharedPreferences mPrefs;
|
||||||
|
|
||||||
private static StatuslinePlugin statuslinePlugin;
|
private static StatuslinePlugin statuslinePlugin;
|
||||||
|
|
||||||
|
@ -55,7 +56,7 @@ public class StatuslinePlugin implements PluginBase {
|
||||||
return statuslinePlugin;
|
return statuslinePlugin;
|
||||||
}
|
}
|
||||||
|
|
||||||
StatuslinePlugin(Context ctx) {
|
private StatuslinePlugin(Context ctx) {
|
||||||
this.ctx = ctx;
|
this.ctx = ctx;
|
||||||
this.mPrefs = PreferenceManager.getDefaultSharedPreferences(ctx);
|
this.mPrefs = PreferenceManager.getDefaultSharedPreferences(ctx);
|
||||||
}
|
}
|
||||||
|
@ -160,7 +161,7 @@ public class StatuslinePlugin implements PluginBase {
|
||||||
@NonNull
|
@NonNull
|
||||||
private String buildStatusString() {
|
private String buildStatusString() {
|
||||||
String status = "";
|
String status = "";
|
||||||
LoopPlugin activeloop = MainApp.getConfigBuilder().getActiveLoop();
|
LoopPlugin activeloop = ConfigBuilderPlugin.getActiveLoop();
|
||||||
|
|
||||||
if (activeloop != null && !activeloop.isEnabled(PluginBase.LOOP)) {
|
if (activeloop != null && !activeloop.isEnabled(PluginBase.LOOP)) {
|
||||||
status += ctx.getString(R.string.disabledloop) + "\n";
|
status += ctx.getString(R.string.disabledloop) + "\n";
|
||||||
|
@ -239,7 +240,7 @@ public class StatuslinePlugin implements PluginBase {
|
||||||
|
|
||||||
//Filter events where loop is (de)activated
|
//Filter events where loop is (de)activated
|
||||||
|
|
||||||
LoopPlugin activeloop = MainApp.getConfigBuilder().getActiveLoop();
|
LoopPlugin activeloop = ConfigBuilderPlugin.getActiveLoop();
|
||||||
if (activeloop == null) return;
|
if (activeloop == null) return;
|
||||||
|
|
||||||
if ((lastLoopStatus != activeloop.isEnabled(PluginBase.LOOP))) {
|
if ((lastLoopStatus != activeloop.isEnabled(PluginBase.LOOP))) {
|
||||||
|
@ -248,7 +249,7 @@ public class StatuslinePlugin implements PluginBase {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public static boolean isEnabled() {
|
public boolean isEnabled() {
|
||||||
return fragmentEnabled;
|
return fragmentEnabled;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -3,6 +3,7 @@ package info.nightscout.utils;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.os.Handler;
|
import android.os.Handler;
|
||||||
import android.os.Message;
|
import android.os.Message;
|
||||||
|
import android.text.Editable;
|
||||||
import android.text.TextWatcher;
|
import android.text.TextWatcher;
|
||||||
import android.util.AttributeSet;
|
import android.util.AttributeSet;
|
||||||
import android.view.KeyEvent;
|
import android.view.KeyEvent;
|
||||||
|
@ -123,6 +124,22 @@ public class NumberPicker extends LinearLayout implements View.OnKeyListener,
|
||||||
plusButton.setOnTouchListener(this);
|
plusButton.setOnTouchListener(this);
|
||||||
plusButton.setOnKeyListener(this);
|
plusButton.setOnKeyListener(this);
|
||||||
plusButton.setOnClickListener(this);
|
plusButton.setOnClickListener(this);
|
||||||
|
setTextWatcher(new TextWatcher() {
|
||||||
|
@Override
|
||||||
|
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onTextChanged(CharSequence s, int start, int before, int count) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void afterTextChanged(Editable s) {
|
||||||
|
value = SafeParse.stringToDouble(editText.getText().toString());
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setTextWatcher(TextWatcher textWatcher) {
|
public void setTextWatcher(TextWatcher textWatcher) {
|
||||||
|
|
BIN
app/src/main/res/drawable-hdpi/icon_danarhistory.png
Normal file
After Width: | Height: | Size: 2 KiB |
BIN
app/src/main/res/drawable-hdpi/icon_danarprofile.png
Normal file
After Width: | Height: | Size: 1.9 KiB |
BIN
app/src/main/res/drawable-hdpi/icon_danarstats.png
Normal file
After Width: | Height: | Size: 1 KiB |
BIN
app/src/main/res/drawable-mdpi/icon_danarhistory.png
Normal file
After Width: | Height: | Size: 1.3 KiB |
BIN
app/src/main/res/drawable-mdpi/icon_danarprofile.png
Normal file
After Width: | Height: | Size: 1.2 KiB |
BIN
app/src/main/res/drawable-mdpi/icon_danarstats.png
Normal file
After Width: | Height: | Size: 754 B |
BIN
app/src/main/res/drawable-xhdpi/icon_danarhistory.png
Normal file
After Width: | Height: | Size: 2.8 KiB |
BIN
app/src/main/res/drawable-xhdpi/icon_danarprofile.png
Normal file
After Width: | Height: | Size: 2.4 KiB |
BIN
app/src/main/res/drawable-xhdpi/icon_danarstats.png
Normal file
After Width: | Height: | Size: 1.2 KiB |
BIN
app/src/main/res/drawable-xxhdpi/icon_danarhistory.png
Normal file
After Width: | Height: | Size: 4 KiB |
BIN
app/src/main/res/drawable-xxhdpi/icon_danarprofile.png
Normal file
After Width: | Height: | Size: 3.7 KiB |
BIN
app/src/main/res/drawable-xxhdpi/icon_danarstats.png
Normal file
After Width: | Height: | Size: 1.7 KiB |
BIN
app/src/main/res/drawable-xxxhdpi/icon_danarhistory.png
Normal file
After Width: | Height: | Size: 5 KiB |
BIN
app/src/main/res/drawable-xxxhdpi/icon_danarprofile.png
Normal file
After Width: | Height: | Size: 4.8 KiB |
BIN
app/src/main/res/drawable-xxxhdpi/icon_danarstats.png
Normal file
After Width: | Height: | Size: 2.1 KiB |
|
@ -608,28 +608,39 @@
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:orientation="horizontal">
|
android:orientation="horizontal">
|
||||||
|
|
||||||
<Button
|
<Button
|
||||||
android:id="@+id/danar_viewprofile"
|
android:id="@+id/danar_viewprofile"
|
||||||
|
style="@style/ButtonSmallFontStyle"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_weight="1"
|
android:layout_weight="1"
|
||||||
android:text="@string/danar_viewprofile" />
|
android:drawableTop="@drawable/icon_danarprofile"
|
||||||
|
android:paddingLeft="0dp"
|
||||||
|
android:paddingRight="0dp"
|
||||||
|
android:text="@string/danar_viewprofile"/>
|
||||||
|
|
||||||
|
|
||||||
<Button
|
<Button
|
||||||
android:id="@+id/danar_history"
|
android:id="@+id/danar_history"
|
||||||
|
style="@style/ButtonSmallFontStyle"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_weight="1"
|
android:layout_weight="1"
|
||||||
|
android:drawableTop="@drawable/icon_danarhistory"
|
||||||
|
android:paddingLeft="0dp"
|
||||||
|
android:paddingRight="0dp"
|
||||||
android:text="@string/danar_history" />
|
android:text="@string/danar_history" />
|
||||||
|
<Button
|
||||||
|
android:id="@+id/danar_stats"
|
||||||
|
style="@style/ButtonSmallFontStyle"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_weight="1"
|
||||||
|
android:drawableTop="@drawable/icon_danarstats"
|
||||||
|
android:paddingLeft="0dp"
|
||||||
|
android:paddingRight="0dp"
|
||||||
|
android:text="@string/danar_stats" />
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
<Button
|
|
||||||
android:id="@+id/danar_stats"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_weight="1"
|
|
||||||
android:text="@string/danar_stats" />
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
</ScrollView>
|
</ScrollView>
|
||||||
|
|
||||||
|
|
|
@ -708,5 +708,14 @@
|
||||||
<string name="key_wizard_include_basal_iob">wizard_include_basal_iob</string>
|
<string name="key_wizard_include_basal_iob">wizard_include_basal_iob</string>
|
||||||
<string name="careportal_newnstreatment_percentage_label">Percentage</string>
|
<string name="careportal_newnstreatment_percentage_label">Percentage</string>
|
||||||
<string name="careportal_newnstreatment_timeshift_label">Time shift</string>
|
<string name="careportal_newnstreatment_timeshift_label">Time shift</string>
|
||||||
|
<string name="default_temptargets">Default Temp-Targets</string>
|
||||||
|
<string name="eatingsoon_duration">eatingsoon duration</string>
|
||||||
|
<string name="eatingsoon_target">eatingsoon target</string>
|
||||||
|
<string name="activity_duration">activity duration</string>
|
||||||
|
<string name="activity_target">activity target</string>
|
||||||
|
<string name="key_eatingsoon_duration">eatingsoon_duration</string>
|
||||||
|
<string name="key_eatingsoon_target">eatingsoon_target</string>
|
||||||
|
<string name="key_activity_duration">activity_duration</string>
|
||||||
|
<string name="key_activity_target">activity_target</string>
|
||||||
</resources>
|
</resources>
|
||||||
|
|
||||||
|
|
|
@ -3,6 +3,33 @@
|
||||||
<PreferenceCategory
|
<PreferenceCategory
|
||||||
android:key="others"
|
android:key="others"
|
||||||
android:title="@string/othersettings_title">
|
android:title="@string/othersettings_title">
|
||||||
|
<PreferenceScreen
|
||||||
|
android:title="@string/default_temptargets">
|
||||||
|
<EditTextPreference
|
||||||
|
android:title="@string/eatingsoon_duration"
|
||||||
|
android:key="@string/key_eatingsoon_duration"
|
||||||
|
android:defaultValue="0"
|
||||||
|
android:inputType="number">
|
||||||
|
</EditTextPreference>
|
||||||
|
<EditTextPreference
|
||||||
|
android:title="@string/eatingsoon_target"
|
||||||
|
android:key="@string/key_eatingsoon_target"
|
||||||
|
android:defaultValue="0"
|
||||||
|
android:inputType="numberDecimal">
|
||||||
|
</EditTextPreference>
|
||||||
|
<EditTextPreference
|
||||||
|
android:title="@string/activity_duration"
|
||||||
|
android:key="@string/key_activity_duration"
|
||||||
|
android:defaultValue="0"
|
||||||
|
android:inputType="number">
|
||||||
|
</EditTextPreference>
|
||||||
|
<EditTextPreference
|
||||||
|
android:title="@string/activity_target"
|
||||||
|
android:key="@string/key_activity_target"
|
||||||
|
android:defaultValue="0"
|
||||||
|
android:inputType="numberDecimal">
|
||||||
|
</EditTextPreference>
|
||||||
|
</PreferenceScreen>
|
||||||
<PreferenceScreen
|
<PreferenceScreen
|
||||||
android:title="@string/fillbolus_title">
|
android:title="@string/fillbolus_title">
|
||||||
<EditTextPreference
|
<EditTextPreference
|
||||||
|
|