more of dagger
This commit is contained in:
parent
d82141e6d6
commit
ac5ea83d38
213 changed files with 3829 additions and 3798 deletions
|
@ -7,7 +7,6 @@ import android.content.Context;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.content.IntentFilter;
|
import android.content.IntentFilter;
|
||||||
import android.content.res.Resources;
|
import android.content.res.Resources;
|
||||||
import android.os.SystemClock;
|
|
||||||
|
|
||||||
import androidx.annotation.ColorRes;
|
import androidx.annotation.ColorRes;
|
||||||
import androidx.annotation.PluralsRes;
|
import androidx.annotation.PluralsRes;
|
||||||
|
@ -39,7 +38,6 @@ import info.nightscout.androidaps.db.DatabaseHelper;
|
||||||
import info.nightscout.androidaps.dependencyInjection.DaggerAppComponent;
|
import info.nightscout.androidaps.dependencyInjection.DaggerAppComponent;
|
||||||
import info.nightscout.androidaps.interfaces.PluginBase;
|
import info.nightscout.androidaps.interfaces.PluginBase;
|
||||||
import info.nightscout.androidaps.interfaces.PluginType;
|
import info.nightscout.androidaps.interfaces.PluginType;
|
||||||
import info.nightscout.androidaps.interfaces.PumpInterface;
|
|
||||||
import info.nightscout.androidaps.logging.AAPSLogger;
|
import info.nightscout.androidaps.logging.AAPSLogger;
|
||||||
import info.nightscout.androidaps.logging.L;
|
import info.nightscout.androidaps.logging.L;
|
||||||
import info.nightscout.androidaps.logging.LTag;
|
import info.nightscout.androidaps.logging.LTag;
|
||||||
|
@ -89,13 +87,13 @@ import info.nightscout.androidaps.plugins.sensitivity.SensitivityAAPSPlugin;
|
||||||
import info.nightscout.androidaps.plugins.sensitivity.SensitivityOref0Plugin;
|
import info.nightscout.androidaps.plugins.sensitivity.SensitivityOref0Plugin;
|
||||||
import info.nightscout.androidaps.plugins.sensitivity.SensitivityOref1Plugin;
|
import info.nightscout.androidaps.plugins.sensitivity.SensitivityOref1Plugin;
|
||||||
import info.nightscout.androidaps.plugins.sensitivity.SensitivityWeightedAveragePlugin;
|
import info.nightscout.androidaps.plugins.sensitivity.SensitivityWeightedAveragePlugin;
|
||||||
import info.nightscout.androidaps.plugins.source.NSClientSourcePlugin;
|
|
||||||
import info.nightscout.androidaps.plugins.source.RandomBgPlugin;
|
|
||||||
import info.nightscout.androidaps.plugins.source.DexcomPlugin;
|
import info.nightscout.androidaps.plugins.source.DexcomPlugin;
|
||||||
import info.nightscout.androidaps.plugins.source.EversensePlugin;
|
import info.nightscout.androidaps.plugins.source.EversensePlugin;
|
||||||
import info.nightscout.androidaps.plugins.source.GlimpPlugin;
|
import info.nightscout.androidaps.plugins.source.GlimpPlugin;
|
||||||
import info.nightscout.androidaps.plugins.source.MM640gPlugin;
|
import info.nightscout.androidaps.plugins.source.MM640gPlugin;
|
||||||
|
import info.nightscout.androidaps.plugins.source.NSClientSourcePlugin;
|
||||||
import info.nightscout.androidaps.plugins.source.PoctechPlugin;
|
import info.nightscout.androidaps.plugins.source.PoctechPlugin;
|
||||||
|
import info.nightscout.androidaps.plugins.source.RandomBgPlugin;
|
||||||
import info.nightscout.androidaps.plugins.source.TomatoPlugin;
|
import info.nightscout.androidaps.plugins.source.TomatoPlugin;
|
||||||
import info.nightscout.androidaps.plugins.source.XdripPlugin;
|
import info.nightscout.androidaps.plugins.source.XdripPlugin;
|
||||||
import info.nightscout.androidaps.plugins.treatments.TreatmentsPlugin;
|
import info.nightscout.androidaps.plugins.treatments.TreatmentsPlugin;
|
||||||
|
@ -120,7 +118,7 @@ public class MainApp extends DaggerApplication {
|
||||||
|
|
||||||
static DatabaseHelper sDatabaseHelper = null;
|
static DatabaseHelper sDatabaseHelper = null;
|
||||||
|
|
||||||
static ArrayList<PluginBase> pluginsList = null;
|
static ArrayList<PluginBase> pluginsList = new ArrayList<>();
|
||||||
|
|
||||||
static DataReceiver dataReceiver = new DataReceiver();
|
static DataReceiver dataReceiver = new DataReceiver();
|
||||||
TimeDateOrTZChangeReceiver timeDateOrTZChangeReceiver;
|
TimeDateOrTZChangeReceiver timeDateOrTZChangeReceiver;
|
||||||
|
@ -140,6 +138,7 @@ public class MainApp extends DaggerApplication {
|
||||||
|
|
||||||
@Inject ActionsPlugin actionsPlugin;
|
@Inject ActionsPlugin actionsPlugin;
|
||||||
@Inject AutomationPlugin automationPlugin;
|
@Inject AutomationPlugin automationPlugin;
|
||||||
|
@Inject ComboPlugin comboPlugin;
|
||||||
@Inject CareportalPlugin careportalPlugin;
|
@Inject CareportalPlugin careportalPlugin;
|
||||||
@Inject ConfigBuilderPlugin configBuilderPlugin;
|
@Inject ConfigBuilderPlugin configBuilderPlugin;
|
||||||
@Inject DanaRPlugin danaRPlugin;
|
@Inject DanaRPlugin danaRPlugin;
|
||||||
|
@ -152,8 +151,12 @@ public class MainApp extends DaggerApplication {
|
||||||
@Inject InsulinOrefRapidActingPlugin insulinOrefRapidActingPlugin;
|
@Inject InsulinOrefRapidActingPlugin insulinOrefRapidActingPlugin;
|
||||||
@Inject InsulinOrefUltraRapidActingPlugin insulinOrefUltraRapidActingPlugin;
|
@Inject InsulinOrefUltraRapidActingPlugin insulinOrefUltraRapidActingPlugin;
|
||||||
@Inject IobCobCalculatorPlugin iobCobCalculatorPlugin;
|
@Inject IobCobCalculatorPlugin iobCobCalculatorPlugin;
|
||||||
|
@Inject LocalInsightPlugin localInsightPlugin;
|
||||||
@Inject LocalProfilePlugin localProfilePlugin;
|
@Inject LocalProfilePlugin localProfilePlugin;
|
||||||
@Inject LoopPlugin loopPlugin;
|
@Inject LoopPlugin loopPlugin;
|
||||||
|
@Inject MedtronicPumpPlugin medtronicPumpPlugin;
|
||||||
|
@Inject MDIPlugin mdiPlugin;
|
||||||
|
@Inject NSProfilePlugin nsProfilePlugin;
|
||||||
@Inject ObjectivesPlugin objectivesPlugin;
|
@Inject ObjectivesPlugin objectivesPlugin;
|
||||||
@Inject SafetyPlugin safetyPlugin;
|
@Inject SafetyPlugin safetyPlugin;
|
||||||
@Inject SmsCommunicatorPlugin smsCommunicatorPlugin;
|
@Inject SmsCommunicatorPlugin smsCommunicatorPlugin;
|
||||||
|
@ -163,12 +166,18 @@ public class MainApp extends DaggerApplication {
|
||||||
@Inject OverviewPlugin overviewPlugin;
|
@Inject OverviewPlugin overviewPlugin;
|
||||||
@Inject PersistentNotificationPlugin persistentNotificationPlugin;
|
@Inject PersistentNotificationPlugin persistentNotificationPlugin;
|
||||||
@Inject RandomBgPlugin randomBgPlugin;
|
@Inject RandomBgPlugin randomBgPlugin;
|
||||||
|
@Inject SensitivityOref1Plugin sensitivityOref1Plugin;
|
||||||
|
@Inject SensitivityAAPSPlugin sensitivityAAPSPlugin;
|
||||||
|
@Inject SensitivityOref0Plugin sensitivityOref0Plugin;
|
||||||
|
@Inject SensitivityWeightedAveragePlugin sensitivityWeightedAveragePlugin;
|
||||||
@Inject SignatureVerifierPlugin signatureVerifierPlugin;
|
@Inject SignatureVerifierPlugin signatureVerifierPlugin;
|
||||||
|
@Inject StorageConstraintPlugin storageConstraintPlugin;
|
||||||
@Inject DexcomPlugin dexcomPlugin;
|
@Inject DexcomPlugin dexcomPlugin;
|
||||||
@Inject EversensePlugin eversensePlugin;
|
@Inject EversensePlugin eversensePlugin;
|
||||||
@Inject GlimpPlugin glimpPlugin;
|
@Inject GlimpPlugin glimpPlugin;
|
||||||
@Inject MaintenancePlugin maintenancePlugin;
|
@Inject MaintenancePlugin maintenancePlugin;
|
||||||
@Inject MM640gPlugin mM640GPlugin;
|
@Inject MM640gPlugin mM640GPlugin;
|
||||||
|
@Inject NSClientPlugin nsClientPlugin;
|
||||||
@Inject NSClientSourcePlugin nSClientSourcePlugin;
|
@Inject NSClientSourcePlugin nSClientSourcePlugin;
|
||||||
@Inject PoctechPlugin poctechPlugin;
|
@Inject PoctechPlugin poctechPlugin;
|
||||||
@Inject TomatoPlugin tomatoPlugin;
|
@Inject TomatoPlugin tomatoPlugin;
|
||||||
|
@ -232,8 +241,6 @@ public class MainApp extends DaggerApplication {
|
||||||
//trigger here to see the new version on app start after an update
|
//trigger here to see the new version on app start after an update
|
||||||
versionCheckersUtils.triggerCheckVersion();
|
versionCheckersUtils.triggerCheckVersion();
|
||||||
|
|
||||||
if (pluginsList == null) {
|
|
||||||
pluginsList = new ArrayList<>();
|
|
||||||
// Register all tabs in app here
|
// Register all tabs in app here
|
||||||
pluginsList.add(overviewPlugin);
|
pluginsList.add(overviewPlugin);
|
||||||
pluginsList.add(iobCobCalculatorPlugin);
|
pluginsList.add(iobCobCalculatorPlugin);
|
||||||
|
@ -241,30 +248,30 @@ public class MainApp extends DaggerApplication {
|
||||||
pluginsList.add(insulinOrefRapidActingPlugin);
|
pluginsList.add(insulinOrefRapidActingPlugin);
|
||||||
pluginsList.add(insulinOrefUltraRapidActingPlugin);
|
pluginsList.add(insulinOrefUltraRapidActingPlugin);
|
||||||
pluginsList.add(insulinOrefFreePeakPlugin);
|
pluginsList.add(insulinOrefFreePeakPlugin);
|
||||||
pluginsList.add(SensitivityOref0Plugin.getPlugin());
|
pluginsList.add(sensitivityOref0Plugin);
|
||||||
pluginsList.add(SensitivityAAPSPlugin.getPlugin());
|
pluginsList.add(sensitivityAAPSPlugin);
|
||||||
pluginsList.add(SensitivityWeightedAveragePlugin.getPlugin());
|
pluginsList.add(sensitivityWeightedAveragePlugin);
|
||||||
pluginsList.add(SensitivityOref1Plugin.getPlugin());
|
pluginsList.add(sensitivityOref1Plugin);
|
||||||
if (Config.PUMPDRIVERS) pluginsList.add(danaRPlugin);
|
if (Config.PUMPDRIVERS) pluginsList.add(danaRPlugin);
|
||||||
if (Config.PUMPDRIVERS) pluginsList.add(danaRKoreanPlugin);
|
if (Config.PUMPDRIVERS) pluginsList.add(danaRKoreanPlugin);
|
||||||
if (Config.PUMPDRIVERS) pluginsList.add(danaRv2Plugin);
|
if (Config.PUMPDRIVERS) pluginsList.add(danaRv2Plugin);
|
||||||
if (Config.PUMPDRIVERS) pluginsList.add(danaRSPlugin);
|
if (Config.PUMPDRIVERS) pluginsList.add(danaRSPlugin);
|
||||||
if (Config.PUMPDRIVERS) pluginsList.add(LocalInsightPlugin.getPlugin());
|
if (Config.PUMPDRIVERS) pluginsList.add(localInsightPlugin);
|
||||||
if (Config.PUMPDRIVERS) pluginsList.add(ComboPlugin.getPlugin());
|
if (Config.PUMPDRIVERS) pluginsList.add(comboPlugin);
|
||||||
if (Config.PUMPDRIVERS) pluginsList.add(MedtronicPumpPlugin.getPlugin());
|
if (Config.PUMPDRIVERS) pluginsList.add(medtronicPumpPlugin);
|
||||||
if (!Config.NSCLIENT) pluginsList.add(MDIPlugin.getPlugin());
|
if (!Config.NSCLIENT) pluginsList.add(mdiPlugin);
|
||||||
pluginsList.add(virtualPumpPlugin);
|
if (!Config.NSCLIENT) pluginsList.add(virtualPumpPlugin);
|
||||||
pluginsList.add(careportalPlugin);
|
pluginsList.add(careportalPlugin);
|
||||||
if (Config.APS) pluginsList.add(loopPlugin);
|
if (Config.APS) pluginsList.add(loopPlugin);
|
||||||
if (Config.APS) pluginsList.add(openAPSMAPlugin);
|
if (Config.APS) pluginsList.add(openAPSMAPlugin);
|
||||||
if (Config.APS) pluginsList.add(openAPSAMAPlugin);
|
if (Config.APS) pluginsList.add(openAPSAMAPlugin);
|
||||||
if (Config.APS) pluginsList.add(openAPSSMBPlugin);
|
if (Config.APS) pluginsList.add(openAPSSMBPlugin);
|
||||||
pluginsList.add(NSProfilePlugin.getPlugin());
|
pluginsList.add(nsProfilePlugin);
|
||||||
if (!Config.NSCLIENT) pluginsList.add(localProfilePlugin);
|
if (!Config.NSCLIENT) pluginsList.add(localProfilePlugin);
|
||||||
pluginsList.add(treatmentsPlugin);
|
pluginsList.add(treatmentsPlugin);
|
||||||
if (!Config.NSCLIENT) pluginsList.add(safetyPlugin);
|
if (!Config.NSCLIENT) pluginsList.add(safetyPlugin);
|
||||||
if (!Config.NSCLIENT) pluginsList.add(versionCheckerPlugin);
|
if (!Config.NSCLIENT) pluginsList.add(versionCheckerPlugin);
|
||||||
if (Config.APS) pluginsList.add(StorageConstraintPlugin.getPlugin());
|
if (Config.APS) pluginsList.add(storageConstraintPlugin);
|
||||||
if (Config.APS) pluginsList.add(signatureVerifierPlugin);
|
if (Config.APS) pluginsList.add(signatureVerifierPlugin);
|
||||||
if (Config.APS) pluginsList.add(objectivesPlugin);
|
if (Config.APS) pluginsList.add(objectivesPlugin);
|
||||||
pluginsList.add(xdripPlugin);
|
pluginsList.add(xdripPlugin);
|
||||||
|
@ -282,7 +289,7 @@ public class MainApp extends DaggerApplication {
|
||||||
pluginsList.add(wearPlugin);
|
pluginsList.add(wearPlugin);
|
||||||
pluginsList.add(statusLinePlugin);
|
pluginsList.add(statusLinePlugin);
|
||||||
pluginsList.add(persistentNotificationPlugin);
|
pluginsList.add(persistentNotificationPlugin);
|
||||||
pluginsList.add(NSClientPlugin.getPlugin());
|
pluginsList.add(nsClientPlugin);
|
||||||
// if (engineeringMode) pluginsList.add(tidepoolPlugin);
|
// if (engineeringMode) pluginsList.add(tidepoolPlugin);
|
||||||
pluginsList.add(maintenancePlugin);
|
pluginsList.add(maintenancePlugin);
|
||||||
pluginsList.add(automationPlugin);
|
pluginsList.add(automationPlugin);
|
||||||
|
@ -291,18 +298,9 @@ public class MainApp extends DaggerApplication {
|
||||||
pluginsList.add(configBuilderPlugin);
|
pluginsList.add(configBuilderPlugin);
|
||||||
|
|
||||||
configBuilderPlugin.initialize();
|
configBuilderPlugin.initialize();
|
||||||
}
|
|
||||||
|
|
||||||
NSUpload.uploadAppStart();
|
NSUpload.uploadAppStart();
|
||||||
|
|
||||||
final PumpInterface pump = configBuilderPlugin.getActivePump();
|
|
||||||
if (pump != null) {
|
|
||||||
new Thread(() -> {
|
|
||||||
SystemClock.sleep(5000);
|
|
||||||
configBuilderPlugin.getCommandQueue().readStatus("Initialization", null);
|
|
||||||
}).start();
|
|
||||||
}
|
|
||||||
|
|
||||||
new Thread(() -> keepAliveManager.setAlarm(this)).start();
|
new Thread(() -> keepAliveManager.setAlarm(this)).start();
|
||||||
doMigrations();
|
doMigrations();
|
||||||
}
|
}
|
||||||
|
|
|
@ -41,7 +41,6 @@ import info.nightscout.androidaps.plugins.pump.insight.LocalInsightPlugin
|
||||||
import info.nightscout.androidaps.plugins.pump.medtronic.MedtronicPumpPlugin
|
import info.nightscout.androidaps.plugins.pump.medtronic.MedtronicPumpPlugin
|
||||||
import info.nightscout.androidaps.plugins.pump.virtual.VirtualPumpPlugin
|
import info.nightscout.androidaps.plugins.pump.virtual.VirtualPumpPlugin
|
||||||
import info.nightscout.androidaps.plugins.sensitivity.SensitivityAAPSPlugin
|
import info.nightscout.androidaps.plugins.sensitivity.SensitivityAAPSPlugin
|
||||||
import info.nightscout.androidaps.plugins.sensitivity.SensitivityOref0Plugin
|
|
||||||
import info.nightscout.androidaps.plugins.sensitivity.SensitivityOref1Plugin
|
import info.nightscout.androidaps.plugins.sensitivity.SensitivityOref1Plugin
|
||||||
import info.nightscout.androidaps.plugins.sensitivity.SensitivityWeightedAveragePlugin
|
import info.nightscout.androidaps.plugins.sensitivity.SensitivityWeightedAveragePlugin
|
||||||
import info.nightscout.androidaps.plugins.source.DexcomPlugin
|
import info.nightscout.androidaps.plugins.source.DexcomPlugin
|
||||||
|
@ -53,7 +52,6 @@ import info.nightscout.androidaps.utils.OKDialog.show
|
||||||
import info.nightscout.androidaps.utils.SafeParse
|
import info.nightscout.androidaps.utils.SafeParse
|
||||||
import info.nightscout.androidaps.utils.resources.ResourceHelper
|
import info.nightscout.androidaps.utils.resources.ResourceHelper
|
||||||
import info.nightscout.androidaps.utils.sharedPreferences.SP
|
import info.nightscout.androidaps.utils.sharedPreferences.SP
|
||||||
import java.util.*
|
|
||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
|
|
||||||
class MyPreferenceFragment : PreferenceFragmentCompat(), OnSharedPreferenceChangeListener, HasAndroidInjector {
|
class MyPreferenceFragment : PreferenceFragmentCompat(), OnSharedPreferenceChangeListener, HasAndroidInjector {
|
||||||
|
@ -69,12 +67,20 @@ class MyPreferenceFragment : PreferenceFragmentCompat(), OnSharedPreferenceChang
|
||||||
@Inject lateinit var danaRv2Plugin: DanaRv2Plugin
|
@Inject lateinit var danaRv2Plugin: DanaRv2Plugin
|
||||||
@Inject lateinit var danaRSPlugin: DanaRSPlugin
|
@Inject lateinit var danaRSPlugin: DanaRSPlugin
|
||||||
@Inject lateinit var careportalPlugin: CareportalPlugin
|
@Inject lateinit var careportalPlugin: CareportalPlugin
|
||||||
|
@Inject lateinit var comboPlugin: ComboPlugin
|
||||||
@Inject lateinit var insulinOrefFreePeakPlugin: InsulinOrefFreePeakPlugin
|
@Inject lateinit var insulinOrefFreePeakPlugin: InsulinOrefFreePeakPlugin
|
||||||
@Inject lateinit var loopPlugin: LoopPlugin
|
@Inject lateinit var loopPlugin: LoopPlugin
|
||||||
|
@Inject lateinit var localInsightPlugin: LocalInsightPlugin
|
||||||
|
@Inject lateinit var medtronicPumpPlugin: MedtronicPumpPlugin
|
||||||
|
@Inject lateinit var nsClientPlugin: NSClientPlugin
|
||||||
@Inject lateinit var openAPSAMAPlugin: OpenAPSAMAPlugin
|
@Inject lateinit var openAPSAMAPlugin: OpenAPSAMAPlugin
|
||||||
@Inject lateinit var openAPSMAPlugin: OpenAPSMAPlugin
|
@Inject lateinit var openAPSMAPlugin: OpenAPSMAPlugin
|
||||||
@Inject lateinit var openAPSSMBPlugin: OpenAPSSMBPlugin
|
@Inject lateinit var openAPSSMBPlugin: OpenAPSSMBPlugin
|
||||||
@Inject lateinit var safetyPlugin: SafetyPlugin
|
@Inject lateinit var safetyPlugin: SafetyPlugin
|
||||||
|
@Inject lateinit var sensitivityAAPSPlugin: SensitivityAAPSPlugin
|
||||||
|
@Inject lateinit var sensitivityOref0Plugin: SensitivityOref1Plugin
|
||||||
|
@Inject lateinit var sensitivityOref1Plugin: SensitivityOref1Plugin
|
||||||
|
@Inject lateinit var sensitivityWeightedAveragePlugin: SensitivityWeightedAveragePlugin
|
||||||
@Inject lateinit var dexcomPlugin: DexcomPlugin
|
@Inject lateinit var dexcomPlugin: DexcomPlugin
|
||||||
@Inject lateinit var eversensePlugin: EversensePlugin
|
@Inject lateinit var eversensePlugin: EversensePlugin
|
||||||
@Inject lateinit var glimpPlugin: GlimpPlugin
|
@Inject lateinit var glimpPlugin: GlimpPlugin
|
||||||
|
@ -144,20 +150,20 @@ class MyPreferenceFragment : PreferenceFragmentCompat(), OnSharedPreferenceChang
|
||||||
addPreferencesFromResourceIfEnabled(openAPSMAPlugin, rootKey, Config.APS)
|
addPreferencesFromResourceIfEnabled(openAPSMAPlugin, rootKey, Config.APS)
|
||||||
addPreferencesFromResourceIfEnabled(openAPSAMAPlugin, rootKey, Config.APS)
|
addPreferencesFromResourceIfEnabled(openAPSAMAPlugin, rootKey, Config.APS)
|
||||||
addPreferencesFromResourceIfEnabled(openAPSSMBPlugin, rootKey, Config.APS)
|
addPreferencesFromResourceIfEnabled(openAPSSMBPlugin, rootKey, Config.APS)
|
||||||
addPreferencesFromResourceIfEnabled(SensitivityAAPSPlugin.getPlugin(), rootKey)
|
addPreferencesFromResourceIfEnabled(sensitivityAAPSPlugin, rootKey)
|
||||||
addPreferencesFromResourceIfEnabled(SensitivityWeightedAveragePlugin.getPlugin(), rootKey)
|
addPreferencesFromResourceIfEnabled(sensitivityWeightedAveragePlugin, rootKey)
|
||||||
addPreferencesFromResourceIfEnabled(SensitivityOref0Plugin.getPlugin(), rootKey)
|
addPreferencesFromResourceIfEnabled(sensitivityOref0Plugin, rootKey)
|
||||||
addPreferencesFromResourceIfEnabled(SensitivityOref1Plugin.getPlugin(), rootKey)
|
addPreferencesFromResourceIfEnabled(sensitivityOref1Plugin, rootKey)
|
||||||
addPreferencesFromResourceIfEnabled(danaRPlugin, rootKey, Config.PUMPDRIVERS)
|
addPreferencesFromResourceIfEnabled(danaRPlugin, rootKey, Config.PUMPDRIVERS)
|
||||||
addPreferencesFromResourceIfEnabled(danaRKoreanPlugin, rootKey, Config.PUMPDRIVERS)
|
addPreferencesFromResourceIfEnabled(danaRKoreanPlugin, rootKey, Config.PUMPDRIVERS)
|
||||||
addPreferencesFromResourceIfEnabled(danaRv2Plugin, rootKey, Config.PUMPDRIVERS)
|
addPreferencesFromResourceIfEnabled(danaRv2Plugin, rootKey, Config.PUMPDRIVERS)
|
||||||
addPreferencesFromResourceIfEnabled(danaRSPlugin, rootKey, Config.PUMPDRIVERS)
|
addPreferencesFromResourceIfEnabled(danaRSPlugin, rootKey, Config.PUMPDRIVERS)
|
||||||
addPreferencesFromResourceIfEnabled(LocalInsightPlugin.getPlugin(), rootKey, Config.PUMPDRIVERS)
|
addPreferencesFromResourceIfEnabled(localInsightPlugin, rootKey, Config.PUMPDRIVERS)
|
||||||
addPreferencesFromResourceIfEnabled(ComboPlugin.getPlugin(), rootKey, Config.PUMPDRIVERS)
|
addPreferencesFromResourceIfEnabled(comboPlugin, rootKey, Config.PUMPDRIVERS)
|
||||||
addPreferencesFromResourceIfEnabled(MedtronicPumpPlugin.getPlugin(), rootKey, Config.PUMPDRIVERS)
|
addPreferencesFromResourceIfEnabled(medtronicPumpPlugin, rootKey, Config.PUMPDRIVERS)
|
||||||
addPreferencesFromResourceIfEnabled(virtualPumpPlugin, rootKey, !Config.NSCLIENT)
|
addPreferencesFromResourceIfEnabled(virtualPumpPlugin, rootKey, !Config.NSCLIENT)
|
||||||
addPreferencesFromResourceIfEnabled(insulinOrefFreePeakPlugin, rootKey)
|
addPreferencesFromResourceIfEnabled(insulinOrefFreePeakPlugin, rootKey)
|
||||||
addPreferencesFromResourceIfEnabled(NSClientPlugin.getPlugin(), rootKey)
|
addPreferencesFromResourceIfEnabled(nsClientPlugin, rootKey)
|
||||||
addPreferencesFromResourceIfEnabled(tidepoolPlugin, rootKey)
|
addPreferencesFromResourceIfEnabled(tidepoolPlugin, rootKey)
|
||||||
addPreferencesFromResourceIfEnabled(smsCommunicatorPlugin, rootKey)
|
addPreferencesFromResourceIfEnabled(smsCommunicatorPlugin, rootKey)
|
||||||
addPreferencesFromResourceIfEnabled(automationPlugin, rootKey)
|
addPreferencesFromResourceIfEnabled(automationPlugin, rootKey)
|
||||||
|
@ -195,7 +201,7 @@ class MyPreferenceFragment : PreferenceFragmentCompat(), OnSharedPreferenceChang
|
||||||
updatePrefSummary(findPreference(key))
|
updatePrefSummary(findPreference(key))
|
||||||
}
|
}
|
||||||
|
|
||||||
fun addPreferencesFromResource(@XmlRes preferencesResId: Int, key: String?) {
|
private fun addPreferencesFromResource(@XmlRes preferencesResId: Int, key: String?) {
|
||||||
val xmlRoot = preferenceManager.inflateFromResource(context,
|
val xmlRoot = preferenceManager.inflateFromResource(context,
|
||||||
preferencesResId, null)
|
preferencesResId, null)
|
||||||
val root: Preference?
|
val root: Preference?
|
||||||
|
@ -220,7 +226,7 @@ class MyPreferenceFragment : PreferenceFragmentCompat(), OnSharedPreferenceChang
|
||||||
resourceHelper.gs(R.string.key_high_mark),
|
resourceHelper.gs(R.string.key_high_mark),
|
||||||
resourceHelper.gs(R.string.key_low_mark)
|
resourceHelper.gs(R.string.key_low_mark)
|
||||||
)
|
)
|
||||||
if (Arrays.asList(*unitDependent).contains(pref.key)) {
|
if (listOf(*unitDependent).contains(pref.key)) {
|
||||||
val editTextPref = pref as EditTextPreference
|
val editTextPref = pref as EditTextPreference
|
||||||
val converted = Profile.toCurrentUnitsString(SafeParse.stringToDouble(editTextPref.text))
|
val converted = Profile.toCurrentUnitsString(SafeParse.stringToDouble(editTextPref.text))
|
||||||
editTextPref.summary = converted
|
editTextPref.summary = converted
|
||||||
|
@ -233,12 +239,11 @@ class MyPreferenceFragment : PreferenceFragmentCompat(), OnSharedPreferenceChang
|
||||||
pref.setSummary(pref.entry)
|
pref.setSummary(pref.entry)
|
||||||
}
|
}
|
||||||
if (pref is EditTextPreference) {
|
if (pref is EditTextPreference) {
|
||||||
val editTextPref = pref
|
|
||||||
if (pref.getKey().contains("password") || pref.getKey().contains("secret")) {
|
if (pref.getKey().contains("password") || pref.getKey().contains("secret")) {
|
||||||
pref.setSummary("******")
|
pref.setSummary("******")
|
||||||
} else if (editTextPref.text != null) {
|
} else if (pref.text != null) {
|
||||||
pref.dialogMessage = editTextPref.dialogMessage
|
pref.dialogMessage = pref.dialogMessage
|
||||||
pref.setSummary(editTextPref.text)
|
pref.setSummary(pref.text)
|
||||||
} else {
|
} else {
|
||||||
for (plugin in MainApp.getPluginsList()) {
|
for (plugin in MainApp.getPluginsList()) {
|
||||||
plugin.updatePreferenceSummary(pref)
|
plugin.updatePreferenceSummary(pref)
|
||||||
|
@ -251,9 +256,8 @@ class MyPreferenceFragment : PreferenceFragmentCompat(), OnSharedPreferenceChang
|
||||||
private fun initSummary(p: Preference) {
|
private fun initSummary(p: Preference) {
|
||||||
p.isIconSpaceReserved = false // remove extra spacing on left after migration to androidx
|
p.isIconSpaceReserved = false // remove extra spacing on left after migration to androidx
|
||||||
if (p is PreferenceGroup) {
|
if (p is PreferenceGroup) {
|
||||||
val pGrp = p
|
for (i in 0 until p.preferenceCount) {
|
||||||
for (i in 0 until pGrp.preferenceCount) {
|
initSummary(p.getPreference(i))
|
||||||
initSummary(pGrp.getPreference(i))
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
updatePrefSummary(p)
|
updatePrefSummary(p)
|
||||||
|
|
|
@ -11,7 +11,7 @@ class RequestDexcomPermissionActivity : NoSplashAppCompatActivity() {
|
||||||
|
|
||||||
override fun onCreate(savedInstanceState: Bundle?) {
|
override fun onCreate(savedInstanceState: Bundle?) {
|
||||||
super.onCreate(savedInstanceState)
|
super.onCreate(savedInstanceState)
|
||||||
requestPermissions(arrayOf(dexcomPlugin.PERMISSION), requestCode)
|
requestPermissions(arrayOf(DexcomPlugin.PERMISSION), requestCode)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onRequestPermissionsResult(requestCode: Int, permissions: Array<out String>, grantResults: IntArray) {
|
override fun onRequestPermissionsResult(requestCode: Int, permissions: Array<out String>, grantResults: IntArray) {
|
||||||
|
|
|
@ -11,7 +11,11 @@ import info.nightscout.androidaps.interfaces.ActivePluginProvider
|
||||||
import info.nightscout.androidaps.logging.AAPSLogger
|
import info.nightscout.androidaps.logging.AAPSLogger
|
||||||
import info.nightscout.androidaps.logging.LTag
|
import info.nightscout.androidaps.logging.LTag
|
||||||
import info.nightscout.androidaps.plugins.configBuilder.ProfileFunction
|
import info.nightscout.androidaps.plugins.configBuilder.ProfileFunction
|
||||||
import info.nightscout.androidaps.utils.*
|
import info.nightscout.androidaps.utils.ActivityMonitor
|
||||||
|
import info.nightscout.androidaps.utils.DateUtil
|
||||||
|
import info.nightscout.androidaps.utils.InstanceId
|
||||||
|
import info.nightscout.androidaps.utils.SafeParse
|
||||||
|
import info.nightscout.androidaps.utils.ToastUtils
|
||||||
import info.nightscout.androidaps.utils.resources.ResourceHelper
|
import info.nightscout.androidaps.utils.resources.ResourceHelper
|
||||||
import info.nightscout.androidaps.utils.stats.TddCalculator
|
import info.nightscout.androidaps.utils.stats.TddCalculator
|
||||||
import info.nightscout.androidaps.utils.stats.TirCalculator
|
import info.nightscout.androidaps.utils.stats.TirCalculator
|
||||||
|
@ -21,7 +25,7 @@ import javax.inject.Inject
|
||||||
class SurveyActivity : NoSplashAppCompatActivity() {
|
class SurveyActivity : NoSplashAppCompatActivity() {
|
||||||
@Inject lateinit var aapsLogger: AAPSLogger
|
@Inject lateinit var aapsLogger: AAPSLogger
|
||||||
@Inject lateinit var resourceHelper: ResourceHelper
|
@Inject lateinit var resourceHelper: ResourceHelper
|
||||||
@Inject lateinit var activePluginProvider: ActivePluginProvider
|
@Inject lateinit var activePlugin: ActivePluginProvider
|
||||||
@Inject lateinit var tddCalculator: TddCalculator
|
@Inject lateinit var tddCalculator: TddCalculator
|
||||||
@Inject lateinit var tirCalculator: TirCalculator
|
@Inject lateinit var tirCalculator: TirCalculator
|
||||||
@Inject lateinit var profileFunction: ProfileFunction
|
@Inject lateinit var profileFunction: ProfileFunction
|
||||||
|
@ -33,7 +37,7 @@ class SurveyActivity : NoSplashAppCompatActivity() {
|
||||||
|
|
||||||
survey_id.text = InstanceId.instanceId()
|
survey_id.text = InstanceId.instanceId()
|
||||||
|
|
||||||
val profileStore = activePluginProvider.activeProfileInterface.profile
|
val profileStore = activePlugin.activeProfileInterface.profile
|
||||||
val profileList = profileStore?.getProfileList() ?: return
|
val profileList = profileStore?.getProfileList() ?: return
|
||||||
survey_spinner.adapter = ArrayAdapter(this, R.layout.spinner_centered, profileList)
|
survey_spinner.adapter = ArrayAdapter(this, R.layout.spinner_centered, profileList)
|
||||||
|
|
||||||
|
|
|
@ -38,6 +38,7 @@ import info.nightscout.androidaps.data.Profile;
|
||||||
import info.nightscout.androidaps.db.TDD;
|
import info.nightscout.androidaps.db.TDD;
|
||||||
import info.nightscout.androidaps.events.EventPumpStatusChanged;
|
import info.nightscout.androidaps.events.EventPumpStatusChanged;
|
||||||
import info.nightscout.androidaps.interfaces.ActivePluginProvider;
|
import info.nightscout.androidaps.interfaces.ActivePluginProvider;
|
||||||
|
import info.nightscout.androidaps.interfaces.CommandQueueProvider;
|
||||||
import info.nightscout.androidaps.plugins.bus.RxBusWrapper;
|
import info.nightscout.androidaps.plugins.bus.RxBusWrapper;
|
||||||
import info.nightscout.androidaps.plugins.configBuilder.ConfigBuilderPlugin;
|
import info.nightscout.androidaps.plugins.configBuilder.ConfigBuilderPlugin;
|
||||||
import info.nightscout.androidaps.plugins.configBuilder.ProfileFunction;
|
import info.nightscout.androidaps.plugins.configBuilder.ProfileFunction;
|
||||||
|
@ -60,12 +61,14 @@ public class TDDStatsActivity extends NoSplashAppCompatActivity {
|
||||||
@Inject RxBusWrapper rxBus;
|
@Inject RxBusWrapper rxBus;
|
||||||
@Inject SP sp;
|
@Inject SP sp;
|
||||||
@Inject ProfileFunction profileFunction;
|
@Inject ProfileFunction profileFunction;
|
||||||
@Inject ActivePluginProvider activePluginProvider;
|
@Inject ActivePluginProvider activePlugin;
|
||||||
@Inject DanaRSPlugin danaRSPlugin;
|
@Inject DanaRSPlugin danaRSPlugin;
|
||||||
@Inject DanaRPlugin danaRPlugin;
|
@Inject DanaRPlugin danaRPlugin;
|
||||||
@Inject DanaRv2Plugin danaRv2Plugin;
|
@Inject DanaRv2Plugin danaRv2Plugin;
|
||||||
@Inject DanaRKoreanPlugin danaRKoreanPlugin;
|
@Inject DanaRKoreanPlugin danaRKoreanPlugin;
|
||||||
|
@Inject LocalInsightPlugin localInsightPlugin;
|
||||||
@Inject ConfigBuilderPlugin configBuilderPlugin;
|
@Inject ConfigBuilderPlugin configBuilderPlugin;
|
||||||
|
@Inject CommandQueueProvider commandQueue;
|
||||||
|
|
||||||
private static Logger log = LoggerFactory.getLogger(TDDStatsActivity.class);
|
private static Logger log = LoggerFactory.getLogger(TDDStatsActivity.class);
|
||||||
private CompositeDisposable disposable = new CompositeDisposable();
|
private CompositeDisposable disposable = new CompositeDisposable();
|
||||||
|
@ -157,7 +160,7 @@ public class TDDStatsActivity extends NoSplashAppCompatActivity {
|
||||||
}
|
}
|
||||||
totalBaseBasal.setText(TBB);
|
totalBaseBasal.setText(TBB);
|
||||||
|
|
||||||
if (!activePluginProvider.getActivePump().getPumpDescription().needsManualTDDLoad)
|
if (!activePlugin.getActivePump().getPumpDescription().needsManualTDDLoad)
|
||||||
reloadButton.setVisibility(View.GONE);
|
reloadButton.setVisibility(View.GONE);
|
||||||
|
|
||||||
// stats table
|
// stats table
|
||||||
|
@ -261,7 +264,7 @@ public class TDDStatsActivity extends NoSplashAppCompatActivity {
|
||||||
statsMessage.setVisibility(View.VISIBLE);
|
statsMessage.setVisibility(View.VISIBLE);
|
||||||
statsMessage.setText(resourceHelper.gs(R.string.danar_stats_warning_Message));
|
statsMessage.setText(resourceHelper.gs(R.string.danar_stats_warning_Message));
|
||||||
});
|
});
|
||||||
configBuilderPlugin.getCommandQueue().loadTDDs(new Callback() {
|
commandQueue.loadTDDs(new Callback() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
loadDataFromDB();
|
loadDataFromDB();
|
||||||
|
@ -445,7 +448,7 @@ public class TDDStatsActivity extends NoSplashAppCompatActivity {
|
||||||
TableLayout.LayoutParams.WRAP_CONTENT));
|
TableLayout.LayoutParams.WRAP_CONTENT));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isOldData(historyList) && activePluginProvider.getActivePump().getPumpDescription().needsManualTDDLoad) {
|
if (isOldData(historyList) && activePlugin.getActivePump().getPumpDescription().needsManualTDDLoad) {
|
||||||
statsMessage.setVisibility(View.VISIBLE);
|
statsMessage.setVisibility(View.VISIBLE);
|
||||||
statsMessage.setText(resourceHelper.gs(R.string.danar_stats_olddata_Message));
|
statsMessage.setText(resourceHelper.gs(R.string.danar_stats_olddata_Message));
|
||||||
|
|
||||||
|
@ -525,7 +528,7 @@ public class TDDStatsActivity extends NoSplashAppCompatActivity {
|
||||||
|
|
||||||
public boolean isOldData(List<TDD> historyList) {
|
public boolean isOldData(List<TDD> historyList) {
|
||||||
|
|
||||||
boolean startsYesterday = danaRPlugin.isEnabled() || danaRSPlugin.isEnabled() || danaRv2Plugin.isEnabled() || danaRKoreanPlugin.isEnabled() || LocalInsightPlugin.getPlugin().isEnabled();
|
boolean startsYesterday = danaRPlugin.isEnabled() || danaRSPlugin.isEnabled() || danaRv2Plugin.isEnabled() || danaRKoreanPlugin.isEnabled() || localInsightPlugin.isEnabled();
|
||||||
|
|
||||||
DateFormat df = new SimpleDateFormat("dd.MM.", Locale.getDefault());
|
DateFormat df = new SimpleDateFormat("dd.MM.", Locale.getDefault());
|
||||||
return (historyList.size() < 3 || !(df.format(new Date(historyList.get(0).date)).equals(df.format(new Date(System.currentTimeMillis() - (startsYesterday ? 1000 * 60 * 60 * 24 : 0))))));
|
return (historyList.size() < 3 || !(df.format(new Date(historyList.get(0).date)).equals(df.format(new Date(System.currentTimeMillis() - (startsYesterday ? 1000 * 60 * 60 * 24 : 0))))));
|
||||||
|
|
|
@ -228,7 +228,7 @@ public class Profile {
|
||||||
|
|
||||||
if (isValid) {
|
if (isValid) {
|
||||||
// Check for hours alignment
|
// Check for hours alignment
|
||||||
PumpInterface pump = ConfigBuilderPlugin.getPlugin().getActivePump();
|
PumpInterface pump = ConfigBuilderPlugin.getPlugin().getActivePumpPlugin();
|
||||||
if (pump != null && !pump.getPumpDescription().is30minBasalRatesCapable) {
|
if (pump != null && !pump.getPumpDescription().is30minBasalRatesCapable) {
|
||||||
for (int index = 0; index < basal_v.size(); index++) {
|
for (int index = 0; index < basal_v.size(); index++) {
|
||||||
long secondsFromMidnight = basal_v.keyAt(index);
|
long secondsFromMidnight = basal_v.keyAt(index);
|
||||||
|
|
|
@ -191,4 +191,8 @@ public class PumpEnactResult {
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static PumpEnactResult error(String message) {
|
||||||
|
return new PumpEnactResult().enacted(false).success(false).comment(message);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -32,7 +32,6 @@ import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
import info.nightscout.androidaps.Constants;
|
import info.nightscout.androidaps.Constants;
|
||||||
import info.nightscout.androidaps.MainApp;
|
import info.nightscout.androidaps.MainApp;
|
||||||
import info.nightscout.androidaps.plugins.bus.RxBus;
|
|
||||||
import info.nightscout.androidaps.data.OverlappingIntervals;
|
import info.nightscout.androidaps.data.OverlappingIntervals;
|
||||||
import info.nightscout.androidaps.data.Profile;
|
import info.nightscout.androidaps.data.Profile;
|
||||||
import info.nightscout.androidaps.data.ProfileStore;
|
import info.nightscout.androidaps.data.ProfileStore;
|
||||||
|
@ -48,9 +47,9 @@ import info.nightscout.androidaps.events.EventTempBasalChange;
|
||||||
import info.nightscout.androidaps.events.EventTempTargetChange;
|
import info.nightscout.androidaps.events.EventTempTargetChange;
|
||||||
import info.nightscout.androidaps.interfaces.ProfileInterface;
|
import info.nightscout.androidaps.interfaces.ProfileInterface;
|
||||||
import info.nightscout.androidaps.logging.L;
|
import info.nightscout.androidaps.logging.L;
|
||||||
|
import info.nightscout.androidaps.plugins.bus.RxBus;
|
||||||
import info.nightscout.androidaps.plugins.configBuilder.ConfigBuilderPlugin;
|
import info.nightscout.androidaps.plugins.configBuilder.ConfigBuilderPlugin;
|
||||||
import info.nightscout.androidaps.plugins.general.nsclient.NSUpload;
|
import info.nightscout.androidaps.plugins.general.nsclient.NSUpload;
|
||||||
import info.nightscout.androidaps.plugins.iob.iobCobCalculator.IobCobCalculatorPlugin;
|
|
||||||
import info.nightscout.androidaps.plugins.iob.iobCobCalculator.events.EventNewHistoryData;
|
import info.nightscout.androidaps.plugins.iob.iobCobCalculator.events.EventNewHistoryData;
|
||||||
import info.nightscout.androidaps.plugins.pump.danaR.activities.DanaRNSHistorySync;
|
import info.nightscout.androidaps.plugins.pump.danaR.activities.DanaRNSHistorySync;
|
||||||
import info.nightscout.androidaps.plugins.pump.danaR.comm.RecordTypes;
|
import info.nightscout.androidaps.plugins.pump.danaR.comm.RecordTypes;
|
||||||
|
@ -418,40 +417,6 @@ public class DatabaseHelper extends OrmLiteSqliteOpenHelper {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
* Return last BgReading from database or null if db is empty
|
|
||||||
*/
|
|
||||||
@Nullable
|
|
||||||
public static BgReading lastBg() {
|
|
||||||
List<BgReading> bgList = IobCobCalculatorPlugin.getPlugin().getBgReadings();
|
|
||||||
|
|
||||||
if (bgList == null)
|
|
||||||
return null;
|
|
||||||
|
|
||||||
for (int i = 0; i < bgList.size(); i++)
|
|
||||||
if (bgList.get(i).value >= 39)
|
|
||||||
return bgList.get(i);
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Return bg reading if not old ( <9 min )
|
|
||||||
* or null if older
|
|
||||||
*/
|
|
||||||
@Nullable
|
|
||||||
public static BgReading actualBg() {
|
|
||||||
BgReading lastBg = lastBg();
|
|
||||||
|
|
||||||
if (lastBg == null)
|
|
||||||
return null;
|
|
||||||
|
|
||||||
if (lastBg.date > System.currentTimeMillis() - 9 * 60 * 1000)
|
|
||||||
return lastBg;
|
|
||||||
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public List<BgReading> getBgreadingsDataFromTime(long mills, boolean ascending) {
|
public List<BgReading> getBgreadingsDataFromTime(long mills, boolean ascending) {
|
||||||
try {
|
try {
|
||||||
Dao<BgReading, Long> daoBgreadings = getDaoBgReadings();
|
Dao<BgReading, Long> daoBgreadings = getDaoBgReadings();
|
||||||
|
|
|
@ -13,8 +13,12 @@ import info.nightscout.androidaps.plugins.general.automation.actions.*
|
||||||
import info.nightscout.androidaps.plugins.general.automation.elements.*
|
import info.nightscout.androidaps.plugins.general.automation.elements.*
|
||||||
import info.nightscout.androidaps.plugins.general.automation.triggers.*
|
import info.nightscout.androidaps.plugins.general.automation.triggers.*
|
||||||
import info.nightscout.androidaps.plugins.general.overview.notifications.NotificationWithAction
|
import info.nightscout.androidaps.plugins.general.overview.notifications.NotificationWithAction
|
||||||
|
import info.nightscout.androidaps.plugins.iob.iobCobCalculator.AutosensData
|
||||||
|
import info.nightscout.androidaps.plugins.iob.iobCobCalculator.IobCobOref1Thread
|
||||||
|
import info.nightscout.androidaps.plugins.iob.iobCobCalculator.IobCobThread
|
||||||
import info.nightscout.androidaps.plugins.treatments.Treatment
|
import info.nightscout.androidaps.plugins.treatments.Treatment
|
||||||
import info.nightscout.androidaps.queue.commands.CommandSetProfile
|
import info.nightscout.androidaps.queue.CommandQueue
|
||||||
|
import info.nightscout.androidaps.queue.commands.*
|
||||||
import info.nightscout.androidaps.utils.wizard.BolusWizard
|
import info.nightscout.androidaps.utils.wizard.BolusWizard
|
||||||
import info.nightscout.androidaps.utils.wizard.QuickWizardEntry
|
import info.nightscout.androidaps.utils.wizard.QuickWizardEntry
|
||||||
import javax.inject.Singleton
|
import javax.inject.Singleton
|
||||||
|
@ -32,7 +36,21 @@ import javax.inject.Singleton
|
||||||
)
|
)
|
||||||
interface AppComponent : AndroidInjector<MainApp> {
|
interface AppComponent : AndroidInjector<MainApp> {
|
||||||
|
|
||||||
|
fun injectCommandQueue(commandQueue: CommandQueue)
|
||||||
|
fun injectCommandBolus(commandBolus: CommandBolus)
|
||||||
|
fun injectCommandCancelExtendedBolus(commandCancelExtendedBolus: CommandCancelExtendedBolus)
|
||||||
|
fun injectCommandCancelTempBasal(commandCancelTempBasal: CommandCancelTempBasal)
|
||||||
|
fun injectCommandExtendedBolus(commandExtendedBolus: CommandExtendedBolus)
|
||||||
|
fun injectCommandInsightSetTBROverNotification(commandInsightSetTBROverNotification: CommandInsightSetTBROverNotification)
|
||||||
|
fun injectCommandLoadEvents(commandLoadEvents: CommandLoadEvents)
|
||||||
|
fun injectCommandLoadHistory(commandLoadHistory: CommandLoadHistory)
|
||||||
|
fun injectCommandReadStatus(commandReadStatus: CommandReadStatus)
|
||||||
fun injectCommandSetProfile(commandSetProfile: CommandSetProfile)
|
fun injectCommandSetProfile(commandSetProfile: CommandSetProfile)
|
||||||
|
fun injectCommandCommandSMBBolus(commandSMBBolus: CommandSMBBolus)
|
||||||
|
fun injectCommandStartPump(commandStartPump: CommandStartPump)
|
||||||
|
fun injectCommandStopPump(commandStopPump: CommandStopPump)
|
||||||
|
fun injectCommandTempBasalAbsolute(commandTempBasalAbsolute: CommandTempBasalAbsolute)
|
||||||
|
fun injectCommandTempBasalPercent(commandTempBasalPercent: CommandTempBasalPercent)
|
||||||
|
|
||||||
fun injectObjective0(objective0: Objective0)
|
fun injectObjective0(objective0: Objective0)
|
||||||
fun injectObjective1(objective1: Objective1)
|
fun injectObjective1(objective1: Objective1)
|
||||||
|
@ -95,6 +113,10 @@ interface AppComponent : AndroidInjector<MainApp> {
|
||||||
fun injectElement(labelWithElement: LabelWithElement)
|
fun injectElement(labelWithElement: LabelWithElement)
|
||||||
fun injectElement(staticLabel: StaticLabel)
|
fun injectElement(staticLabel: StaticLabel)
|
||||||
|
|
||||||
|
fun injectAutosensDate(autosensData: AutosensData)
|
||||||
|
fun injectIobCobThread(iobCobThread: IobCobThread)
|
||||||
|
fun injectIobCobOref1Thread(iobCobOref1Thread: IobCobOref1Thread)
|
||||||
|
|
||||||
fun injectTreatment(treatment: Treatment)
|
fun injectTreatment(treatment: Treatment)
|
||||||
fun injectBgReading(bgReading: BgReading)
|
fun injectBgReading(bgReading: BgReading)
|
||||||
|
|
||||||
|
|
|
@ -25,8 +25,12 @@ import info.nightscout.androidaps.plugins.general.automation.actions.*
|
||||||
import info.nightscout.androidaps.plugins.general.automation.elements.*
|
import info.nightscout.androidaps.plugins.general.automation.elements.*
|
||||||
import info.nightscout.androidaps.plugins.general.automation.triggers.*
|
import info.nightscout.androidaps.plugins.general.automation.triggers.*
|
||||||
import info.nightscout.androidaps.plugins.general.overview.notifications.NotificationWithAction
|
import info.nightscout.androidaps.plugins.general.overview.notifications.NotificationWithAction
|
||||||
|
import info.nightscout.androidaps.plugins.iob.iobCobCalculator.AutosensData
|
||||||
|
import info.nightscout.androidaps.plugins.iob.iobCobCalculator.IobCobOref1Thread
|
||||||
|
import info.nightscout.androidaps.plugins.iob.iobCobCalculator.IobCobThread
|
||||||
import info.nightscout.androidaps.plugins.treatments.Treatment
|
import info.nightscout.androidaps.plugins.treatments.Treatment
|
||||||
import info.nightscout.androidaps.queue.commands.CommandSetProfile
|
import info.nightscout.androidaps.queue.CommandQueue
|
||||||
|
import info.nightscout.androidaps.queue.commands.*
|
||||||
import info.nightscout.androidaps.utils.resources.ResourceHelper
|
import info.nightscout.androidaps.utils.resources.ResourceHelper
|
||||||
import info.nightscout.androidaps.utils.resources.ResourceHelperImplementation
|
import info.nightscout.androidaps.utils.resources.ResourceHelperImplementation
|
||||||
import info.nightscout.androidaps.utils.sharedPreferences.SP
|
import info.nightscout.androidaps.utils.sharedPreferences.SP
|
||||||
|
@ -46,8 +50,8 @@ open class AppModule {
|
||||||
|
|
||||||
@Provides
|
@Provides
|
||||||
@Singleton
|
@Singleton
|
||||||
fun provideProfileFunction(sp: SP, configBuilderPlugin: ConfigBuilderPlugin): ProfileFunction {
|
fun provideProfileFunction(sp: SP): ProfileFunction {
|
||||||
return ProfileFunctionImplementation(sp, configBuilderPlugin)
|
return ProfileFunctionImplementation(sp)
|
||||||
}
|
}
|
||||||
|
|
||||||
@Provides
|
@Provides
|
||||||
|
@ -69,7 +73,25 @@ open class AppModule {
|
||||||
@Module
|
@Module
|
||||||
interface AppBindings {
|
interface AppBindings {
|
||||||
|
|
||||||
|
@ContributesAndroidInjector fun commandQueueInjector(): CommandQueue
|
||||||
|
@ContributesAndroidInjector fun commandBolusInjector(): CommandBolus
|
||||||
|
@ContributesAndroidInjector
|
||||||
|
fun commandCancelExtendedBolusInjector(): CommandCancelExtendedBolus
|
||||||
|
|
||||||
|
@ContributesAndroidInjector fun commandCancelTempBasalInjector(): CommandCancelTempBasal
|
||||||
|
@ContributesAndroidInjector fun commandExtendedBolusInjector(): CommandExtendedBolus
|
||||||
|
@ContributesAndroidInjector
|
||||||
|
fun commandInsightSetTBROverNotificationInjector(): CommandInsightSetTBROverNotification
|
||||||
|
|
||||||
|
@ContributesAndroidInjector fun commandLoadEventsInjector(): CommandLoadEvents
|
||||||
|
@ContributesAndroidInjector fun commandLoadHistoryInjector(): CommandLoadHistory
|
||||||
|
@ContributesAndroidInjector fun commandReadStatusInjector(): CommandReadStatus
|
||||||
@ContributesAndroidInjector fun commandSetProfileInjector(): CommandSetProfile
|
@ContributesAndroidInjector fun commandSetProfileInjector(): CommandSetProfile
|
||||||
|
@ContributesAndroidInjector fun commandCommandSMBBolusInjector(): CommandSMBBolus
|
||||||
|
@ContributesAndroidInjector fun commandStartPumpInjector(): CommandStartPump
|
||||||
|
@ContributesAndroidInjector fun commandStopPumpInjector(): CommandStopPump
|
||||||
|
@ContributesAndroidInjector fun commandTempBasalAbsoluteInjector(): CommandTempBasalAbsolute
|
||||||
|
@ContributesAndroidInjector fun commandTempBasalPercentInjector(): CommandTempBasalPercent
|
||||||
|
|
||||||
@ContributesAndroidInjector fun objective0Injector(): Objective0
|
@ContributesAndroidInjector fun objective0Injector(): Objective0
|
||||||
@ContributesAndroidInjector fun objective1Injector(): Objective1
|
@ContributesAndroidInjector fun objective1Injector(): Objective1
|
||||||
|
@ -107,7 +129,9 @@ open class AppModule {
|
||||||
@ContributesAndroidInjector fun actionLoopSuspendInjector(): ActionLoopSuspend
|
@ContributesAndroidInjector fun actionLoopSuspendInjector(): ActionLoopSuspend
|
||||||
@ContributesAndroidInjector fun actionNotificationInjector(): ActionNotification
|
@ContributesAndroidInjector fun actionNotificationInjector(): ActionNotification
|
||||||
@ContributesAndroidInjector fun actionProfileSwitchInjector(): ActionProfileSwitch
|
@ContributesAndroidInjector fun actionProfileSwitchInjector(): ActionProfileSwitch
|
||||||
@ContributesAndroidInjector fun actionProfileSwitchPercentInjector(): ActionProfileSwitchPercent
|
@ContributesAndroidInjector
|
||||||
|
fun actionProfileSwitchPercentInjector(): ActionProfileSwitchPercent
|
||||||
|
|
||||||
@ContributesAndroidInjector fun actionSendSMSInjector(): ActionSendSMS
|
@ContributesAndroidInjector fun actionSendSMSInjector(): ActionSendSMS
|
||||||
@ContributesAndroidInjector fun actionStartTempTargetInjector(): ActionStartTempTarget
|
@ContributesAndroidInjector fun actionStartTempTargetInjector(): ActionStartTempTarget
|
||||||
@ContributesAndroidInjector fun actionStopTempTargetInjector(): ActionStopTempTarget
|
@ContributesAndroidInjector fun actionStopTempTargetInjector(): ActionStopTempTarget
|
||||||
|
@ -134,6 +158,10 @@ open class AppModule {
|
||||||
@ContributesAndroidInjector fun labelWithElementInjector(): LabelWithElement
|
@ContributesAndroidInjector fun labelWithElementInjector(): LabelWithElement
|
||||||
@ContributesAndroidInjector fun staticLabelInjector(): StaticLabel
|
@ContributesAndroidInjector fun staticLabelInjector(): StaticLabel
|
||||||
|
|
||||||
|
@ContributesAndroidInjector fun autosensDataInjector(): AutosensData
|
||||||
|
@ContributesAndroidInjector fun iobCobThreadInjector(): IobCobThread
|
||||||
|
@ContributesAndroidInjector fun iobCobOref1ThreadInjector(): IobCobOref1Thread
|
||||||
|
|
||||||
@ContributesAndroidInjector fun bgReadingInjector(): BgReading
|
@ContributesAndroidInjector fun bgReadingInjector(): BgReading
|
||||||
@ContributesAndroidInjector fun treatmentInjector(): Treatment
|
@ContributesAndroidInjector fun treatmentInjector(): Treatment
|
||||||
|
|
||||||
|
@ -146,9 +174,10 @@ open class AppModule {
|
||||||
@Binds fun bindContext(mainApp: MainApp): Context
|
@Binds fun bindContext(mainApp: MainApp): Context
|
||||||
@Binds fun bindInjector(mainApp: MainApp): HasAndroidInjector
|
@Binds fun bindInjector(mainApp: MainApp): HasAndroidInjector
|
||||||
|
|
||||||
@Binds fun bindActivePluginProvider(configBuilderPlugin: ConfigBuilderPlugin): ActivePluginProvider
|
@Binds
|
||||||
|
fun bindActivePluginProvider(configBuilderPlugin: ConfigBuilderPlugin): ActivePluginProvider
|
||||||
|
|
||||||
@Binds fun bindCommandQueueProvider(configBuilderPlugin: ConfigBuilderPlugin): CommandQueueProvider
|
@Binds fun commandQueueProvider(commandQueue: CommandQueue): CommandQueueProvider
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,22 +19,24 @@ import info.nightscout.androidaps.plugins.general.automation.dialogs.ChooseTrigg
|
||||||
import info.nightscout.androidaps.plugins.general.automation.dialogs.EditActionDialog
|
import info.nightscout.androidaps.plugins.general.automation.dialogs.EditActionDialog
|
||||||
import info.nightscout.androidaps.plugins.general.automation.dialogs.EditEventDialog
|
import info.nightscout.androidaps.plugins.general.automation.dialogs.EditEventDialog
|
||||||
import info.nightscout.androidaps.plugins.general.automation.dialogs.EditTriggerDialog
|
import info.nightscout.androidaps.plugins.general.automation.dialogs.EditTriggerDialog
|
||||||
|
import info.nightscout.androidaps.plugins.general.careportal.CareportalFragment
|
||||||
|
import info.nightscout.androidaps.plugins.general.careportal.Dialogs.NewNSTreatmentDialog
|
||||||
|
import info.nightscout.androidaps.plugins.general.food.FoodFragment
|
||||||
|
import info.nightscout.androidaps.plugins.general.maintenance.MaintenanceFragment
|
||||||
|
import info.nightscout.androidaps.plugins.general.nsclient.NSClientFragment
|
||||||
import info.nightscout.androidaps.plugins.general.overview.OverviewFragment
|
import info.nightscout.androidaps.plugins.general.overview.OverviewFragment
|
||||||
import info.nightscout.androidaps.plugins.general.overview.dialogs.EditQuickWizardDialog
|
import info.nightscout.androidaps.plugins.general.overview.dialogs.EditQuickWizardDialog
|
||||||
import info.nightscout.androidaps.plugins.general.smsCommunicator.SmsCommunicatorFragment
|
import info.nightscout.androidaps.plugins.general.smsCommunicator.SmsCommunicatorFragment
|
||||||
import info.nightscout.androidaps.plugins.general.tidepool.TidepoolFragment
|
import info.nightscout.androidaps.plugins.general.tidepool.TidepoolFragment
|
||||||
import info.nightscout.androidaps.plugins.profile.local.LocalProfileFragment
|
import info.nightscout.androidaps.plugins.profile.local.LocalProfileFragment
|
||||||
import info.nightscout.androidaps.plugins.profile.ns.NSProfileFragment
|
import info.nightscout.androidaps.plugins.profile.ns.NSProfileFragment
|
||||||
|
import info.nightscout.androidaps.plugins.pump.combo.ComboFragment
|
||||||
import info.nightscout.androidaps.plugins.pump.danaR.DanaRFragment
|
import info.nightscout.androidaps.plugins.pump.danaR.DanaRFragment
|
||||||
|
import info.nightscout.androidaps.plugins.pump.insight.LocalInsightFragment
|
||||||
import info.nightscout.androidaps.plugins.pump.medtronic.MedtronicFragment
|
import info.nightscout.androidaps.plugins.pump.medtronic.MedtronicFragment
|
||||||
import info.nightscout.androidaps.plugins.pump.virtual.VirtualPumpFragment
|
import info.nightscout.androidaps.plugins.pump.virtual.VirtualPumpFragment
|
||||||
import info.nightscout.androidaps.plugins.source.BGSourceFragment
|
import info.nightscout.androidaps.plugins.source.BGSourceFragment
|
||||||
import info.nightscout.androidaps.plugins.treatments.TreatmentsFragment
|
import info.nightscout.androidaps.plugins.treatments.TreatmentsFragment
|
||||||
import info.nightscout.androidaps.dialogs.WizardInfoDialog
|
|
||||||
import info.nightscout.androidaps.plugins.general.careportal.CareportalFragment
|
|
||||||
import info.nightscout.androidaps.plugins.general.careportal.Dialogs.NewNSTreatmentDialog
|
|
||||||
import info.nightscout.androidaps.plugins.general.food.FoodFragment
|
|
||||||
import info.nightscout.androidaps.plugins.general.maintenance.MaintenanceFragment
|
|
||||||
import info.nightscout.androidaps.plugins.treatments.fragments.TreatmentsBolusFragment
|
import info.nightscout.androidaps.plugins.treatments.fragments.TreatmentsBolusFragment
|
||||||
import info.nightscout.androidaps.plugins.treatments.fragments.TreatmentsCareportalFragment
|
import info.nightscout.androidaps.plugins.treatments.fragments.TreatmentsCareportalFragment
|
||||||
import info.nightscout.androidaps.plugins.treatments.fragments.TreatmentsProfileSwitchFragment
|
import info.nightscout.androidaps.plugins.treatments.fragments.TreatmentsProfileSwitchFragment
|
||||||
|
@ -49,7 +51,10 @@ abstract class FragmentsModule {
|
||||||
@ContributesAndroidInjector abstract fun contributesAutomationFragment(): AutomationFragment
|
@ContributesAndroidInjector abstract fun contributesAutomationFragment(): AutomationFragment
|
||||||
@ContributesAndroidInjector abstract fun contributesBGSourceFragment(): BGSourceFragment
|
@ContributesAndroidInjector abstract fun contributesBGSourceFragment(): BGSourceFragment
|
||||||
@ContributesAndroidInjector abstract fun contributesCareportalFragment(): CareportalFragment
|
@ContributesAndroidInjector abstract fun contributesCareportalFragment(): CareportalFragment
|
||||||
@ContributesAndroidInjector abstract fun contributesConfigBuilderFragment(): ConfigBuilderFragment
|
@ContributesAndroidInjector abstract fun contributesComboFragment(): ComboFragment
|
||||||
|
@ContributesAndroidInjector
|
||||||
|
abstract fun contributesConfigBuilderFragment(): ConfigBuilderFragment
|
||||||
|
|
||||||
@ContributesAndroidInjector abstract fun contributesDanaRFragment(): DanaRFragment
|
@ContributesAndroidInjector abstract fun contributesDanaRFragment(): DanaRFragment
|
||||||
@ContributesAndroidInjector abstract fun contributesFoodFragment(): FoodFragment
|
@ContributesAndroidInjector abstract fun contributesFoodFragment(): FoodFragment
|
||||||
@ContributesAndroidInjector abstract fun contributesLocalProfileFragment(): LocalProfileFragment
|
@ContributesAndroidInjector abstract fun contributesLocalProfileFragment(): LocalProfileFragment
|
||||||
|
@ -58,16 +63,26 @@ abstract class FragmentsModule {
|
||||||
@ContributesAndroidInjector abstract fun contributesOpenAPSMAFragment(): OpenAPSMAFragment
|
@ContributesAndroidInjector abstract fun contributesOpenAPSMAFragment(): OpenAPSMAFragment
|
||||||
@ContributesAndroidInjector abstract fun contributesOpenAPSSMBFragment(): OpenAPSSMBFragment
|
@ContributesAndroidInjector abstract fun contributesOpenAPSSMBFragment(): OpenAPSSMBFragment
|
||||||
@ContributesAndroidInjector abstract fun contributesOverviewFragment(): OverviewFragment
|
@ContributesAndroidInjector abstract fun contributesOverviewFragment(): OverviewFragment
|
||||||
|
@ContributesAndroidInjector abstract fun contributesLocalInsightFragment(): LocalInsightFragment
|
||||||
@ContributesAndroidInjector abstract fun contributesLoopFragment(): LoopFragment
|
@ContributesAndroidInjector abstract fun contributesLoopFragment(): LoopFragment
|
||||||
@ContributesAndroidInjector abstract fun contributesMaintenanceFragment(): MaintenanceFragment
|
@ContributesAndroidInjector abstract fun contributesMaintenanceFragment(): MaintenanceFragment
|
||||||
@ContributesAndroidInjector abstract fun contributesMedtronicFragment(): MedtronicFragment
|
@ContributesAndroidInjector abstract fun contributesMedtronicFragment(): MedtronicFragment
|
||||||
@ContributesAndroidInjector abstract fun contributesNSProfileFragment(): NSProfileFragment
|
@ContributesAndroidInjector abstract fun contributesNSProfileFragment(): NSProfileFragment
|
||||||
@ContributesAndroidInjector abstract fun contributesSmsCommunicatorFragment(): SmsCommunicatorFragment
|
@ContributesAndroidInjector abstract fun contributesNSClientFragment(): NSClientFragment
|
||||||
|
@ContributesAndroidInjector
|
||||||
|
abstract fun contributesSmsCommunicatorFragment(): SmsCommunicatorFragment
|
||||||
|
|
||||||
@ContributesAndroidInjector abstract fun contributesTidepoolFragment(): TidepoolFragment
|
@ContributesAndroidInjector abstract fun contributesTidepoolFragment(): TidepoolFragment
|
||||||
@ContributesAndroidInjector abstract fun contributesTreatmentsFragment(): TreatmentsFragment
|
@ContributesAndroidInjector abstract fun contributesTreatmentsFragment(): TreatmentsFragment
|
||||||
@ContributesAndroidInjector abstract fun contributesTreatmentsBolusFragment(): TreatmentsBolusFragment
|
@ContributesAndroidInjector
|
||||||
@ContributesAndroidInjector abstract fun contributesTreatmentsCareportalFragment(): TreatmentsCareportalFragment
|
abstract fun contributesTreatmentsBolusFragment(): TreatmentsBolusFragment
|
||||||
@ContributesAndroidInjector abstract fun contributesTreatmentsProfileSwitchFragment(): TreatmentsProfileSwitchFragment
|
|
||||||
|
@ContributesAndroidInjector
|
||||||
|
abstract fun contributesTreatmentsCareportalFragment(): TreatmentsCareportalFragment
|
||||||
|
|
||||||
|
@ContributesAndroidInjector
|
||||||
|
abstract fun contributesTreatmentsProfileSwitchFragment(): TreatmentsProfileSwitchFragment
|
||||||
|
|
||||||
@ContributesAndroidInjector abstract fun contributesVirtualPumpFragment(): VirtualPumpFragment
|
@ContributesAndroidInjector abstract fun contributesVirtualPumpFragment(): VirtualPumpFragment
|
||||||
|
|
||||||
@ContributesAndroidInjector abstract fun contributesBolusProgressDialog(): BolusProgressDialog
|
@ContributesAndroidInjector abstract fun contributesBolusProgressDialog(): BolusProgressDialog
|
||||||
|
@ -77,7 +92,9 @@ abstract class FragmentsModule {
|
||||||
@ContributesAndroidInjector abstract fun contributesEditActionDialog(): EditActionDialog
|
@ContributesAndroidInjector abstract fun contributesEditActionDialog(): EditActionDialog
|
||||||
@ContributesAndroidInjector abstract fun contributesEditEventDialog(): EditEventDialog
|
@ContributesAndroidInjector abstract fun contributesEditEventDialog(): EditEventDialog
|
||||||
@ContributesAndroidInjector abstract fun contributesEditTriggerDialog(): EditTriggerDialog
|
@ContributesAndroidInjector abstract fun contributesEditTriggerDialog(): EditTriggerDialog
|
||||||
@ContributesAndroidInjector abstract fun contributesEditQuickWizardDialog(): EditQuickWizardDialog
|
@ContributesAndroidInjector
|
||||||
|
abstract fun contributesEditQuickWizardDialog(): EditQuickWizardDialog
|
||||||
|
|
||||||
@ContributesAndroidInjector abstract fun contributesErrorDialog(): ErrorDialog
|
@ContributesAndroidInjector abstract fun contributesErrorDialog(): ErrorDialog
|
||||||
@ContributesAndroidInjector abstract fun contributesExtendedBolusDialog(): ExtendedBolusDialog
|
@ContributesAndroidInjector abstract fun contributesExtendedBolusDialog(): ExtendedBolusDialog
|
||||||
@ContributesAndroidInjector abstract fun contributesFillDialog(): FillDialog
|
@ContributesAndroidInjector abstract fun contributesFillDialog(): FillDialog
|
||||||
|
|
|
@ -12,10 +12,10 @@ import dagger.android.support.DaggerDialogFragment
|
||||||
import info.nightscout.androidaps.R
|
import info.nightscout.androidaps.R
|
||||||
import info.nightscout.androidaps.activities.BolusProgressHelperActivity
|
import info.nightscout.androidaps.activities.BolusProgressHelperActivity
|
||||||
import info.nightscout.androidaps.events.EventPumpStatusChanged
|
import info.nightscout.androidaps.events.EventPumpStatusChanged
|
||||||
|
import info.nightscout.androidaps.interfaces.CommandQueueProvider
|
||||||
import info.nightscout.androidaps.logging.AAPSLogger
|
import info.nightscout.androidaps.logging.AAPSLogger
|
||||||
import info.nightscout.androidaps.logging.LTag
|
import info.nightscout.androidaps.logging.LTag
|
||||||
import info.nightscout.androidaps.plugins.bus.RxBusWrapper
|
import info.nightscout.androidaps.plugins.bus.RxBusWrapper
|
||||||
import info.nightscout.androidaps.plugins.configBuilder.ConfigBuilderPlugin
|
|
||||||
import info.nightscout.androidaps.plugins.general.overview.events.EventDismissBolusProgressIfRunning
|
import info.nightscout.androidaps.plugins.general.overview.events.EventDismissBolusProgressIfRunning
|
||||||
import info.nightscout.androidaps.plugins.general.overview.events.EventOverviewBolusProgress
|
import info.nightscout.androidaps.plugins.general.overview.events.EventOverviewBolusProgress
|
||||||
import info.nightscout.androidaps.utils.FabricPrivacy
|
import info.nightscout.androidaps.utils.FabricPrivacy
|
||||||
|
@ -29,7 +29,7 @@ class BolusProgressDialog : DaggerDialogFragment() {
|
||||||
@Inject lateinit var aapsLogger: AAPSLogger
|
@Inject lateinit var aapsLogger: AAPSLogger
|
||||||
@Inject lateinit var rxBus: RxBusWrapper
|
@Inject lateinit var rxBus: RxBusWrapper
|
||||||
@Inject lateinit var resourceHelper: ResourceHelper
|
@Inject lateinit var resourceHelper: ResourceHelper
|
||||||
@Inject lateinit var configBuilderPlugin: ConfigBuilderPlugin
|
@Inject lateinit var commandQueue: CommandQueueProvider
|
||||||
@Inject lateinit var fabricPrivacy: FabricPrivacy
|
@Inject lateinit var fabricPrivacy: FabricPrivacy
|
||||||
|
|
||||||
private val disposable = CompositeDisposable()
|
private val disposable = CompositeDisposable()
|
||||||
|
@ -73,7 +73,7 @@ class BolusProgressDialog : DaggerDialogFragment() {
|
||||||
stopPressed = true
|
stopPressed = true
|
||||||
overview_bolusprogress_stoppressed.visibility = View.VISIBLE
|
overview_bolusprogress_stoppressed.visibility = View.VISIBLE
|
||||||
overview_bolusprogress_stop.visibility = View.INVISIBLE
|
overview_bolusprogress_stop.visibility = View.INVISIBLE
|
||||||
configBuilderPlugin.commandQueue.cancelAllBoluses()
|
commandQueue.cancelAllBoluses()
|
||||||
}
|
}
|
||||||
val defaultState = resourceHelper.gs(R.string.waitingforpump)
|
val defaultState = resourceHelper.gs(R.string.waitingforpump)
|
||||||
overview_bolusprogress_progressbar.max = 100
|
overview_bolusprogress_progressbar.max = 100
|
||||||
|
@ -90,7 +90,7 @@ class BolusProgressDialog : DaggerDialogFragment() {
|
||||||
override fun onResume() {
|
override fun onResume() {
|
||||||
super.onResume()
|
super.onResume()
|
||||||
aapsLogger.debug(LTag.UI, "onResume")
|
aapsLogger.debug(LTag.UI, "onResume")
|
||||||
if (!configBuilderPlugin.commandQueue.bolusInQueue())
|
if (!commandQueue.bolusInQueue())
|
||||||
bolusEnded = true
|
bolusEnded = true
|
||||||
|
|
||||||
if (bolusEnded) dismiss()
|
if (bolusEnded) dismiss()
|
||||||
|
|
|
@ -12,13 +12,13 @@ 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.db.CareportalEvent
|
import info.nightscout.androidaps.db.CareportalEvent
|
||||||
import info.nightscout.androidaps.db.DatabaseHelper
|
|
||||||
import info.nightscout.androidaps.db.Source
|
import info.nightscout.androidaps.db.Source
|
||||||
import info.nightscout.androidaps.db.TempTarget
|
import info.nightscout.androidaps.db.TempTarget
|
||||||
import info.nightscout.androidaps.interfaces.Constraint
|
import info.nightscout.androidaps.interfaces.Constraint
|
||||||
import info.nightscout.androidaps.plugins.configBuilder.ConstraintChecker
|
import info.nightscout.androidaps.plugins.configBuilder.ConstraintChecker
|
||||||
import info.nightscout.androidaps.plugins.configBuilder.ProfileFunction
|
import info.nightscout.androidaps.plugins.configBuilder.ProfileFunction
|
||||||
import info.nightscout.androidaps.plugins.general.nsclient.NSUpload
|
import info.nightscout.androidaps.plugins.general.nsclient.NSUpload
|
||||||
|
import info.nightscout.androidaps.plugins.iob.iobCobCalculator.IobCobCalculatorPlugin
|
||||||
import info.nightscout.androidaps.plugins.treatments.CarbsGenerator
|
import info.nightscout.androidaps.plugins.treatments.CarbsGenerator
|
||||||
import info.nightscout.androidaps.plugins.treatments.TreatmentsPlugin
|
import info.nightscout.androidaps.plugins.treatments.TreatmentsPlugin
|
||||||
import info.nightscout.androidaps.utils.*
|
import info.nightscout.androidaps.utils.*
|
||||||
|
@ -38,6 +38,7 @@ class CarbsDialog : DialogFragmentWithDate() {
|
||||||
@Inject lateinit var defaultValueHelper: DefaultValueHelper
|
@Inject lateinit var defaultValueHelper: DefaultValueHelper
|
||||||
@Inject lateinit var treatmentsPlugin: TreatmentsPlugin
|
@Inject lateinit var treatmentsPlugin: TreatmentsPlugin
|
||||||
@Inject lateinit var profileFunction: ProfileFunction
|
@Inject lateinit var profileFunction: ProfileFunction
|
||||||
|
@Inject lateinit var iobCobCalculatorPlugin: IobCobCalculatorPlugin;
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
private const val FAV1_DEFAULT = 5
|
private const val FAV1_DEFAULT = 5
|
||||||
|
@ -118,7 +119,7 @@ class CarbsDialog : DialogFragmentWithDate() {
|
||||||
validateInputs()
|
validateInputs()
|
||||||
}
|
}
|
||||||
|
|
||||||
DatabaseHelper.actualBg()?.let { bgReading ->
|
iobCobCalculatorPlugin.actualBg()?.let { bgReading ->
|
||||||
if (bgReading.value < 72)
|
if (bgReading.value < 72)
|
||||||
overview_carbs_hypo_tt.isChecked = true
|
overview_carbs_hypo_tt.isChecked = true
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,8 +9,9 @@ import com.google.common.base.Joiner
|
||||||
import info.nightscout.androidaps.MainApp
|
import info.nightscout.androidaps.MainApp
|
||||||
import info.nightscout.androidaps.R
|
import info.nightscout.androidaps.R
|
||||||
import info.nightscout.androidaps.activities.ErrorHelperActivity
|
import info.nightscout.androidaps.activities.ErrorHelperActivity
|
||||||
|
import info.nightscout.androidaps.interfaces.ActivePluginProvider
|
||||||
|
import info.nightscout.androidaps.interfaces.CommandQueueProvider
|
||||||
import info.nightscout.androidaps.interfaces.Constraint
|
import info.nightscout.androidaps.interfaces.Constraint
|
||||||
import info.nightscout.androidaps.plugins.configBuilder.ConfigBuilderPlugin
|
|
||||||
import info.nightscout.androidaps.plugins.configBuilder.ConstraintChecker
|
import info.nightscout.androidaps.plugins.configBuilder.ConstraintChecker
|
||||||
import info.nightscout.androidaps.queue.Callback
|
import info.nightscout.androidaps.queue.Callback
|
||||||
import info.nightscout.androidaps.utils.HtmlHelper
|
import info.nightscout.androidaps.utils.HtmlHelper
|
||||||
|
@ -28,7 +29,8 @@ class ExtendedBolusDialog : DialogFragmentWithDate() {
|
||||||
@Inject lateinit var mainApp: MainApp
|
@Inject lateinit var mainApp: MainApp
|
||||||
@Inject lateinit var resourceHelper: ResourceHelper
|
@Inject lateinit var resourceHelper: ResourceHelper
|
||||||
@Inject lateinit var constraintChecker: ConstraintChecker
|
@Inject lateinit var constraintChecker: ConstraintChecker
|
||||||
@Inject lateinit var configBuilderPlugin: ConfigBuilderPlugin
|
@Inject lateinit var commandQueue: CommandQueueProvider
|
||||||
|
@Inject lateinit var activePlugin: ActivePluginProvider
|
||||||
|
|
||||||
override fun onSaveInstanceState(savedInstanceState: Bundle) {
|
override fun onSaveInstanceState(savedInstanceState: Bundle) {
|
||||||
super.onSaveInstanceState(savedInstanceState)
|
super.onSaveInstanceState(savedInstanceState)
|
||||||
|
@ -45,7 +47,7 @@ class ExtendedBolusDialog : DialogFragmentWithDate() {
|
||||||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||||
super.onViewCreated(view, savedInstanceState)
|
super.onViewCreated(view, savedInstanceState)
|
||||||
|
|
||||||
val pumpDescription = configBuilderPlugin.activePump?.pumpDescription ?: return
|
val pumpDescription = activePlugin.activePump.pumpDescription
|
||||||
|
|
||||||
val maxInsulin = constraintChecker.getMaxExtendedBolusAllowed().value()
|
val maxInsulin = constraintChecker.getMaxExtendedBolusAllowed().value()
|
||||||
val extendedStep = pumpDescription.extendedBolusStep
|
val extendedStep = pumpDescription.extendedBolusStep
|
||||||
|
@ -70,7 +72,7 @@ class ExtendedBolusDialog : DialogFragmentWithDate() {
|
||||||
|
|
||||||
activity?.let { activity ->
|
activity?.let { activity ->
|
||||||
OKDialog.showConfirmation(activity, resourceHelper.gs(R.string.extended_bolus), HtmlHelper.fromHtml(Joiner.on("<br/>").join(actions)), Runnable {
|
OKDialog.showConfirmation(activity, resourceHelper.gs(R.string.extended_bolus), HtmlHelper.fromHtml(Joiner.on("<br/>").join(actions)), Runnable {
|
||||||
configBuilderPlugin.commandQueue.extendedBolus(insulinAfterConstraint, durationInMinutes, object : Callback() {
|
commandQueue.extendedBolus(insulinAfterConstraint, durationInMinutes, object : Callback() {
|
||||||
override fun run() {
|
override fun run() {
|
||||||
if (!result.success) {
|
if (!result.success) {
|
||||||
val i = Intent(mainApp, ErrorHelperActivity::class.java)
|
val i = Intent(mainApp, ErrorHelperActivity::class.java)
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
package info.nightscout.androidaps.dialogs
|
package info.nightscout.androidaps.dialogs
|
||||||
|
|
||||||
|
import android.content.Context
|
||||||
import android.content.Intent
|
import android.content.Intent
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
import android.view.LayoutInflater
|
import android.view.LayoutInflater
|
||||||
|
@ -12,8 +13,9 @@ import info.nightscout.androidaps.activities.ErrorHelperActivity
|
||||||
import info.nightscout.androidaps.data.DetailedBolusInfo
|
import info.nightscout.androidaps.data.DetailedBolusInfo
|
||||||
import info.nightscout.androidaps.db.CareportalEvent
|
import info.nightscout.androidaps.db.CareportalEvent
|
||||||
import info.nightscout.androidaps.db.Source
|
import info.nightscout.androidaps.db.Source
|
||||||
|
import info.nightscout.androidaps.interfaces.ActivePluginProvider
|
||||||
|
import info.nightscout.androidaps.interfaces.CommandQueueProvider
|
||||||
import info.nightscout.androidaps.interfaces.Constraint
|
import info.nightscout.androidaps.interfaces.Constraint
|
||||||
import info.nightscout.androidaps.plugins.configBuilder.ConfigBuilderPlugin
|
|
||||||
import info.nightscout.androidaps.plugins.configBuilder.ConstraintChecker
|
import info.nightscout.androidaps.plugins.configBuilder.ConstraintChecker
|
||||||
import info.nightscout.androidaps.plugins.general.nsclient.NSUpload
|
import info.nightscout.androidaps.plugins.general.nsclient.NSUpload
|
||||||
import info.nightscout.androidaps.queue.Callback
|
import info.nightscout.androidaps.queue.Callback
|
||||||
|
@ -35,8 +37,9 @@ import kotlin.math.abs
|
||||||
class FillDialog : DialogFragmentWithDate() {
|
class FillDialog : DialogFragmentWithDate() {
|
||||||
@Inject lateinit var constraintChecker: ConstraintChecker
|
@Inject lateinit var constraintChecker: ConstraintChecker
|
||||||
@Inject lateinit var resourceHelper: ResourceHelper
|
@Inject lateinit var resourceHelper: ResourceHelper
|
||||||
@Inject lateinit var mainApp: MainApp
|
@Inject lateinit var ctx: Context
|
||||||
@Inject lateinit var configBuilderPlugin: ConfigBuilderPlugin
|
@Inject lateinit var commandQueue: CommandQueueProvider
|
||||||
|
@Inject lateinit var activePlugin: ActivePluginProvider
|
||||||
|
|
||||||
override fun onSaveInstanceState(savedInstanceState: Bundle) {
|
override fun onSaveInstanceState(savedInstanceState: Bundle) {
|
||||||
super.onSaveInstanceState(savedInstanceState)
|
super.onSaveInstanceState(savedInstanceState)
|
||||||
|
@ -53,7 +56,7 @@ class FillDialog : DialogFragmentWithDate() {
|
||||||
super.onViewCreated(view, savedInstanceState)
|
super.onViewCreated(view, savedInstanceState)
|
||||||
|
|
||||||
val maxInsulin = constraintChecker.getMaxBolusAllowed().value()
|
val maxInsulin = constraintChecker.getMaxBolusAllowed().value()
|
||||||
val bolusStep = configBuilderPlugin.activePump!!.pumpDescription.bolusStep
|
val bolusStep = activePlugin.activePump.pumpDescription.bolusStep
|
||||||
fill_insulinamount.setParams(savedInstanceState?.getDouble("fill_insulin_amount")
|
fill_insulinamount.setParams(savedInstanceState?.getDouble("fill_insulin_amount")
|
||||||
?: 0.0, 0.0, maxInsulin, bolusStep, DecimalFormatter.pumpSupportedBolusFormat(), true, ok)
|
?: 0.0, 0.0, maxInsulin, bolusStep, DecimalFormatter.pumpSupportedBolusFormat(), true, ok)
|
||||||
val amount1 = sp.getDouble("fill_button1", 0.3)
|
val amount1 = sp.getDouble("fill_button1", 0.3)
|
||||||
|
@ -119,15 +122,15 @@ class FillDialog : DialogFragmentWithDate() {
|
||||||
detailedBolusInfo.source = Source.USER
|
detailedBolusInfo.source = Source.USER
|
||||||
detailedBolusInfo.isValid = false // do not count it in IOB (for pump history)
|
detailedBolusInfo.isValid = false // do not count it in IOB (for pump history)
|
||||||
detailedBolusInfo.notes = notes
|
detailedBolusInfo.notes = notes
|
||||||
configBuilderPlugin.commandQueue.bolus(detailedBolusInfo, object : Callback() {
|
commandQueue.bolus(detailedBolusInfo, object : Callback() {
|
||||||
override fun run() {
|
override fun run() {
|
||||||
if (!result.success) {
|
if (!result.success) {
|
||||||
val i = Intent(mainApp, ErrorHelperActivity::class.java)
|
val i = Intent(ctx, ErrorHelperActivity::class.java)
|
||||||
i.putExtra("soundid", R.raw.boluserror)
|
i.putExtra("soundid", R.raw.boluserror)
|
||||||
i.putExtra("status", result.comment)
|
i.putExtra("status", result.comment)
|
||||||
i.putExtra("title", resourceHelper.gs(R.string.treatmentdeliveryerror))
|
i.putExtra("title", resourceHelper.gs(R.string.treatmentdeliveryerror))
|
||||||
i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
|
i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
|
||||||
mainApp.startActivity(i)
|
ctx.startActivity(i)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
@ -158,7 +161,7 @@ class FillDialog : DialogFragmentWithDate() {
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
fun generateJson(careportalEvent: String, time: Long, notes: String): JSONObject {
|
private fun generateJson(careportalEvent: String, time: Long, notes: String): JSONObject {
|
||||||
val data = JSONObject()
|
val data = JSONObject()
|
||||||
try {
|
try {
|
||||||
data.put("eventType", careportalEvent)
|
data.put("eventType", careportalEvent)
|
||||||
|
|
|
@ -9,7 +9,6 @@ import android.view.View
|
||||||
import android.view.ViewGroup
|
import android.view.ViewGroup
|
||||||
import com.google.common.base.Joiner
|
import com.google.common.base.Joiner
|
||||||
import info.nightscout.androidaps.Constants
|
import info.nightscout.androidaps.Constants
|
||||||
import info.nightscout.androidaps.MainApp
|
|
||||||
import info.nightscout.androidaps.R
|
import info.nightscout.androidaps.R
|
||||||
import info.nightscout.androidaps.activities.ErrorHelperActivity
|
import info.nightscout.androidaps.activities.ErrorHelperActivity
|
||||||
import info.nightscout.androidaps.data.DetailedBolusInfo
|
import info.nightscout.androidaps.data.DetailedBolusInfo
|
||||||
|
@ -17,11 +16,11 @@ import info.nightscout.androidaps.data.Profile
|
||||||
import info.nightscout.androidaps.db.CareportalEvent
|
import info.nightscout.androidaps.db.CareportalEvent
|
||||||
import info.nightscout.androidaps.db.Source
|
import info.nightscout.androidaps.db.Source
|
||||||
import info.nightscout.androidaps.db.TempTarget
|
import info.nightscout.androidaps.db.TempTarget
|
||||||
|
import info.nightscout.androidaps.interfaces.ActivePluginProvider
|
||||||
|
import info.nightscout.androidaps.interfaces.CommandQueueProvider
|
||||||
import info.nightscout.androidaps.interfaces.Constraint
|
import info.nightscout.androidaps.interfaces.Constraint
|
||||||
import info.nightscout.androidaps.plugins.configBuilder.ConfigBuilderPlugin
|
|
||||||
import info.nightscout.androidaps.plugins.configBuilder.ConstraintChecker
|
import info.nightscout.androidaps.plugins.configBuilder.ConstraintChecker
|
||||||
import info.nightscout.androidaps.plugins.configBuilder.ProfileFunction
|
import info.nightscout.androidaps.plugins.configBuilder.ProfileFunction
|
||||||
import info.nightscout.androidaps.plugins.treatments.TreatmentsPlugin
|
|
||||||
import info.nightscout.androidaps.queue.Callback
|
import info.nightscout.androidaps.queue.Callback
|
||||||
import info.nightscout.androidaps.utils.*
|
import info.nightscout.androidaps.utils.*
|
||||||
import info.nightscout.androidaps.utils.extensions.toSignedString
|
import info.nightscout.androidaps.utils.extensions.toSignedString
|
||||||
|
@ -37,12 +36,11 @@ import kotlin.math.max
|
||||||
|
|
||||||
class InsulinDialog : DialogFragmentWithDate() {
|
class InsulinDialog : DialogFragmentWithDate() {
|
||||||
@Inject lateinit var constraintChecker: ConstraintChecker
|
@Inject lateinit var constraintChecker: ConstraintChecker
|
||||||
@Inject lateinit var mainApp: MainApp
|
|
||||||
@Inject lateinit var resourceHelper: ResourceHelper
|
@Inject lateinit var resourceHelper: ResourceHelper
|
||||||
@Inject lateinit var defaultValueHelper: DefaultValueHelper
|
@Inject lateinit var defaultValueHelper: DefaultValueHelper
|
||||||
@Inject lateinit var profileFunction: ProfileFunction
|
@Inject lateinit var profileFunction: ProfileFunction
|
||||||
@Inject lateinit var configBuilderPlugin: ConfigBuilderPlugin
|
@Inject lateinit var commandQueue: CommandQueueProvider
|
||||||
@Inject lateinit var treatmentsPlugin: TreatmentsPlugin
|
@Inject lateinit var activePlugin: ActivePluginProvider
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
private const val PLUS1_DEFAULT = 0.5
|
private const val PLUS1_DEFAULT = 0.5
|
||||||
|
@ -63,11 +61,11 @@ class InsulinDialog : DialogFragmentWithDate() {
|
||||||
val maxInsulin = constraintChecker.getMaxBolusAllowed().value()
|
val maxInsulin = constraintChecker.getMaxBolusAllowed().value()
|
||||||
if (abs(overview_insulin_time.value.toInt()) > 12 * 60) {
|
if (abs(overview_insulin_time.value.toInt()) > 12 * 60) {
|
||||||
overview_insulin_time.value = 0.0
|
overview_insulin_time.value = 0.0
|
||||||
ToastUtils.showToastInUiThread(mainApp, resourceHelper.gs(R.string.constraintapllied))
|
ToastUtils.showToastInUiThread(context, resourceHelper.gs(R.string.constraintapllied))
|
||||||
}
|
}
|
||||||
if (overview_insulin_amount.value > maxInsulin) {
|
if (overview_insulin_amount.value > maxInsulin) {
|
||||||
overview_insulin_amount.value = 0.0
|
overview_insulin_amount.value = 0.0
|
||||||
ToastUtils.showToastInUiThread(mainApp, resourceHelper.gs(R.string.bolusconstraintapplied))
|
ToastUtils.showToastInUiThread(context, resourceHelper.gs(R.string.bolusconstraintapplied))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -91,7 +89,7 @@ class InsulinDialog : DialogFragmentWithDate() {
|
||||||
overview_insulin_time.setParams(savedInstanceState?.getDouble("overview_insulin_time")
|
overview_insulin_time.setParams(savedInstanceState?.getDouble("overview_insulin_time")
|
||||||
?: 0.0, -12 * 60.0, 12 * 60.0, 5.0, DecimalFormat("0"), false, ok, textWatcher)
|
?: 0.0, -12 * 60.0, 12 * 60.0, 5.0, DecimalFormat("0"), false, ok, textWatcher)
|
||||||
overview_insulin_amount.setParams(savedInstanceState?.getDouble("overview_insulin_amount")
|
overview_insulin_amount.setParams(savedInstanceState?.getDouble("overview_insulin_amount")
|
||||||
?: 0.0, 0.0, maxInsulin, configBuilderPlugin.activePump!!.pumpDescription.bolusStep, DecimalFormatter.pumpSupportedBolusFormat(), false, ok, textWatcher)
|
?: 0.0, 0.0, maxInsulin, activePlugin.activePump.pumpDescription.bolusStep, DecimalFormatter.pumpSupportedBolusFormat(), false, ok, textWatcher)
|
||||||
|
|
||||||
overview_insulin_plus05.text = sp.getDouble(resourceHelper.gs(R.string.key_insulin_button_increment_1), PLUS1_DEFAULT).toSignedString()
|
overview_insulin_plus05.text = sp.getDouble(resourceHelper.gs(R.string.key_insulin_button_increment_1), PLUS1_DEFAULT).toSignedString()
|
||||||
overview_insulin_plus05.setOnClickListener {
|
overview_insulin_plus05.setOnClickListener {
|
||||||
|
@ -107,7 +105,7 @@ class InsulinDialog : DialogFragmentWithDate() {
|
||||||
}
|
}
|
||||||
overview_insulin_plus20.text = sp.getDouble(resourceHelper.gs(R.string.key_insulin_button_increment_3), PLUS3_DEFAULT).toSignedString()
|
overview_insulin_plus20.text = sp.getDouble(resourceHelper.gs(R.string.key_insulin_button_increment_3), PLUS3_DEFAULT).toSignedString()
|
||||||
overview_insulin_plus20.setOnClickListener {
|
overview_insulin_plus20.setOnClickListener {
|
||||||
overview_insulin_amount.value = Math.max(0.0, overview_insulin_amount.value
|
overview_insulin_amount.value = max(0.0, overview_insulin_amount.value
|
||||||
+ sp.getDouble(resourceHelper.gs(R.string.key_insulin_button_increment_3), PLUS3_DEFAULT))
|
+ sp.getDouble(resourceHelper.gs(R.string.key_insulin_button_increment_3), PLUS3_DEFAULT))
|
||||||
validateInputs()
|
validateInputs()
|
||||||
}
|
}
|
||||||
|
@ -119,7 +117,7 @@ class InsulinDialog : DialogFragmentWithDate() {
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun submit(): Boolean {
|
override fun submit(): Boolean {
|
||||||
val pumpDescription = configBuilderPlugin.activePump?.pumpDescription
|
val pumpDescription = activePlugin.activePumpPlugin?.pumpDescription
|
||||||
?: return false
|
?: return false
|
||||||
val insulin = SafeParse.stringToDouble(overview_insulin_amount.text)
|
val insulin = SafeParse.stringToDouble(overview_insulin_amount.text)
|
||||||
val insulinAfterConstraints = constraintChecker.applyBolusConstraints(Constraint(insulin)).value()
|
val insulinAfterConstraints = constraintChecker.applyBolusConstraints(Constraint(insulin)).value()
|
||||||
|
@ -161,7 +159,7 @@ class InsulinDialog : DialogFragmentWithDate() {
|
||||||
.source(Source.USER)
|
.source(Source.USER)
|
||||||
.low(Profile.toMgdl(eatingSoonTT, profileFunction.getUnits()))
|
.low(Profile.toMgdl(eatingSoonTT, profileFunction.getUnits()))
|
||||||
.high(Profile.toMgdl(eatingSoonTT, profileFunction.getUnits()))
|
.high(Profile.toMgdl(eatingSoonTT, profileFunction.getUnits()))
|
||||||
treatmentsPlugin.addToHistoryTempTarget(tempTarget)
|
activePlugin.activeTreatments.addToHistoryTempTarget(tempTarget)
|
||||||
}
|
}
|
||||||
if (insulinAfterConstraints > 0) {
|
if (insulinAfterConstraints > 0) {
|
||||||
val detailedBolusInfo = DetailedBolusInfo()
|
val detailedBolusInfo = DetailedBolusInfo()
|
||||||
|
@ -172,18 +170,18 @@ class InsulinDialog : DialogFragmentWithDate() {
|
||||||
detailedBolusInfo.notes = notes
|
detailedBolusInfo.notes = notes
|
||||||
if (recordOnlyChecked) {
|
if (recordOnlyChecked) {
|
||||||
detailedBolusInfo.date = time
|
detailedBolusInfo.date = time
|
||||||
treatmentsPlugin.addToHistoryTreatment(detailedBolusInfo, false)
|
activePlugin.activeTreatments.addToHistoryTreatment(detailedBolusInfo, false)
|
||||||
} else {
|
} else {
|
||||||
detailedBolusInfo.date = DateUtil.now()
|
detailedBolusInfo.date = DateUtil.now()
|
||||||
configBuilderPlugin.commandQueue.bolus(detailedBolusInfo, object : Callback() {
|
commandQueue.bolus(detailedBolusInfo, object : Callback() {
|
||||||
override fun run() {
|
override fun run() {
|
||||||
if (!result.success) {
|
if (!result.success) {
|
||||||
val i = Intent(mainApp, ErrorHelperActivity::class.java)
|
val i = Intent(context, ErrorHelperActivity::class.java)
|
||||||
i.putExtra("soundid", R.raw.boluserror)
|
i.putExtra("soundid", R.raw.boluserror)
|
||||||
i.putExtra("status", result.comment)
|
i.putExtra("status", result.comment)
|
||||||
i.putExtra("title", resourceHelper.gs(R.string.treatmentdeliveryerror))
|
i.putExtra("title", resourceHelper.gs(R.string.treatmentdeliveryerror))
|
||||||
i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
|
i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
|
||||||
mainApp.startActivity(i)
|
context?.startActivity(i)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
|
@ -6,15 +6,14 @@ import android.view.LayoutInflater
|
||||||
import android.view.View
|
import android.view.View
|
||||||
import android.view.ViewGroup
|
import android.view.ViewGroup
|
||||||
import com.google.common.base.Joiner
|
import com.google.common.base.Joiner
|
||||||
import info.nightscout.androidaps.MainApp
|
|
||||||
import info.nightscout.androidaps.R
|
import info.nightscout.androidaps.R
|
||||||
import info.nightscout.androidaps.activities.ErrorHelperActivity
|
import info.nightscout.androidaps.activities.ErrorHelperActivity
|
||||||
|
import info.nightscout.androidaps.interfaces.ActivePluginProvider
|
||||||
|
import info.nightscout.androidaps.interfaces.CommandQueueProvider
|
||||||
import info.nightscout.androidaps.interfaces.Constraint
|
import info.nightscout.androidaps.interfaces.Constraint
|
||||||
import info.nightscout.androidaps.interfaces.PumpDescription
|
import info.nightscout.androidaps.interfaces.PumpDescription
|
||||||
import info.nightscout.androidaps.plugins.configBuilder.ConfigBuilderPlugin
|
|
||||||
import info.nightscout.androidaps.plugins.configBuilder.ConstraintChecker
|
import info.nightscout.androidaps.plugins.configBuilder.ConstraintChecker
|
||||||
import info.nightscout.androidaps.plugins.configBuilder.ProfileFunction
|
import info.nightscout.androidaps.plugins.configBuilder.ProfileFunction
|
||||||
import info.nightscout.androidaps.plugins.treatments.TreatmentsPlugin
|
|
||||||
import info.nightscout.androidaps.queue.Callback
|
import info.nightscout.androidaps.queue.Callback
|
||||||
import info.nightscout.androidaps.utils.HtmlHelper
|
import info.nightscout.androidaps.utils.HtmlHelper
|
||||||
import info.nightscout.androidaps.utils.OKDialog
|
import info.nightscout.androidaps.utils.OKDialog
|
||||||
|
@ -29,10 +28,10 @@ import kotlin.math.abs
|
||||||
|
|
||||||
class TempBasalDialog : DialogFragmentWithDate() {
|
class TempBasalDialog : DialogFragmentWithDate() {
|
||||||
@Inject lateinit var constraintChecker: ConstraintChecker
|
@Inject lateinit var constraintChecker: ConstraintChecker
|
||||||
@Inject lateinit var mainApp: MainApp
|
|
||||||
@Inject lateinit var resourceHelper: ResourceHelper
|
@Inject lateinit var resourceHelper: ResourceHelper
|
||||||
@Inject lateinit var profileFunction: ProfileFunction
|
@Inject lateinit var profileFunction: ProfileFunction
|
||||||
@Inject lateinit var configBuilderPlugin: ConfigBuilderPlugin
|
@Inject lateinit var activePlugin: ActivePluginProvider
|
||||||
|
@Inject lateinit var commandQueue: CommandQueueProvider
|
||||||
|
|
||||||
private var isPercentPump = true
|
private var isPercentPump = true
|
||||||
|
|
||||||
|
@ -52,7 +51,7 @@ class TempBasalDialog : DialogFragmentWithDate() {
|
||||||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||||
super.onViewCreated(view, savedInstanceState)
|
super.onViewCreated(view, savedInstanceState)
|
||||||
|
|
||||||
val pumpDescription = configBuilderPlugin.activePump?.pumpDescription ?: return
|
val pumpDescription = activePlugin.activePumpPlugin?.pumpDescription ?: return
|
||||||
val profile = profileFunction.getProfile() ?: return
|
val profile = profileFunction.getProfile() ?: return
|
||||||
|
|
||||||
val maxTempPercent = pumpDescription.maxTempPercent.toDouble()
|
val maxTempPercent = pumpDescription.maxTempPercent.toDouble()
|
||||||
|
@ -104,20 +103,19 @@ class TempBasalDialog : DialogFragmentWithDate() {
|
||||||
val callback: Callback = object : Callback() {
|
val callback: Callback = object : Callback() {
|
||||||
override fun run() {
|
override fun run() {
|
||||||
if (!result.success) {
|
if (!result.success) {
|
||||||
val i = Intent(mainApp, ErrorHelperActivity::class.java)
|
val i = Intent(context, ErrorHelperActivity::class.java)
|
||||||
i.putExtra("soundid", R.raw.boluserror)
|
i.putExtra("soundid", R.raw.boluserror)
|
||||||
i.putExtra("status", result.comment)
|
i.putExtra("status", result.comment)
|
||||||
i.putExtra("title", resourceHelper.gs(R.string.tempbasaldeliveryerror))
|
i.putExtra("title", resourceHelper.gs(R.string.tempbasaldeliveryerror))
|
||||||
i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
|
i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
|
||||||
mainApp.startActivity(i)
|
context?.startActivity(i)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (isPercentPump) {
|
if (isPercentPump)
|
||||||
configBuilderPlugin.commandQueue.tempBasalPercent(percent, durationInMinutes, true, profile, callback)
|
commandQueue.tempBasalPercent(percent, durationInMinutes, true, profile, callback)
|
||||||
} else {
|
else
|
||||||
configBuilderPlugin.commandQueue.tempBasalAbsolute(absolute, durationInMinutes, true, profile, callback)
|
commandQueue.tempBasalAbsolute(absolute, durationInMinutes, true, profile, callback)
|
||||||
}
|
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
return true
|
return true
|
||||||
|
|
|
@ -8,16 +8,15 @@ import android.view.LayoutInflater
|
||||||
import android.view.View
|
import android.view.View
|
||||||
import android.view.ViewGroup
|
import android.view.ViewGroup
|
||||||
import com.google.common.base.Joiner
|
import com.google.common.base.Joiner
|
||||||
import info.nightscout.androidaps.MainApp
|
|
||||||
import info.nightscout.androidaps.R
|
import info.nightscout.androidaps.R
|
||||||
import info.nightscout.androidaps.activities.ErrorHelperActivity
|
import info.nightscout.androidaps.activities.ErrorHelperActivity
|
||||||
import info.nightscout.androidaps.data.DetailedBolusInfo
|
import info.nightscout.androidaps.data.DetailedBolusInfo
|
||||||
import info.nightscout.androidaps.db.CareportalEvent
|
import info.nightscout.androidaps.db.CareportalEvent
|
||||||
import info.nightscout.androidaps.db.Source
|
import info.nightscout.androidaps.db.Source
|
||||||
|
import info.nightscout.androidaps.interfaces.ActivePluginProvider
|
||||||
|
import info.nightscout.androidaps.interfaces.CommandQueueProvider
|
||||||
import info.nightscout.androidaps.interfaces.Constraint
|
import info.nightscout.androidaps.interfaces.Constraint
|
||||||
import info.nightscout.androidaps.plugins.configBuilder.ConfigBuilderPlugin
|
|
||||||
import info.nightscout.androidaps.plugins.configBuilder.ConstraintChecker
|
import info.nightscout.androidaps.plugins.configBuilder.ConstraintChecker
|
||||||
import info.nightscout.androidaps.plugins.treatments.TreatmentsPlugin
|
|
||||||
import info.nightscout.androidaps.queue.Callback
|
import info.nightscout.androidaps.queue.Callback
|
||||||
import info.nightscout.androidaps.utils.DecimalFormatter
|
import info.nightscout.androidaps.utils.DecimalFormatter
|
||||||
import info.nightscout.androidaps.utils.HtmlHelper
|
import info.nightscout.androidaps.utils.HtmlHelper
|
||||||
|
@ -34,10 +33,9 @@ import kotlin.math.abs
|
||||||
|
|
||||||
class TreatmentDialog : DialogFragmentWithDate() {
|
class TreatmentDialog : DialogFragmentWithDate() {
|
||||||
@Inject lateinit var constraintChecker: ConstraintChecker
|
@Inject lateinit var constraintChecker: ConstraintChecker
|
||||||
@Inject lateinit var mainApp: MainApp
|
|
||||||
@Inject lateinit var resourceHelper: ResourceHelper
|
@Inject lateinit var resourceHelper: ResourceHelper
|
||||||
@Inject lateinit var configBuilderPlugin: ConfigBuilderPlugin
|
@Inject lateinit var activePlugin: ActivePluginProvider
|
||||||
@Inject lateinit var treatmentsPlugin: TreatmentsPlugin
|
@Inject lateinit var commandQueue: CommandQueueProvider
|
||||||
|
|
||||||
private val textWatcher: TextWatcher = object : TextWatcher {
|
private val textWatcher: TextWatcher = object : TextWatcher {
|
||||||
override fun afterTextChanged(s: Editable) {}
|
override fun afterTextChanged(s: Editable) {}
|
||||||
|
@ -52,11 +50,11 @@ class TreatmentDialog : DialogFragmentWithDate() {
|
||||||
val maxInsulin = constraintChecker.getMaxBolusAllowed().value()
|
val maxInsulin = constraintChecker.getMaxBolusAllowed().value()
|
||||||
if (SafeParse.stringToInt(overview_treatment_carbs.text) > maxCarbs) {
|
if (SafeParse.stringToInt(overview_treatment_carbs.text) > maxCarbs) {
|
||||||
overview_treatment_carbs.value = 0.0
|
overview_treatment_carbs.value = 0.0
|
||||||
ToastUtils.showToastInUiThread(mainApp, resourceHelper.gs(R.string.carbsconstraintapplied))
|
ToastUtils.showToastInUiThread(context, resourceHelper.gs(R.string.carbsconstraintapplied))
|
||||||
}
|
}
|
||||||
if (SafeParse.stringToDouble(overview_treatment_insulin.text) > maxInsulin) {
|
if (SafeParse.stringToDouble(overview_treatment_insulin.text) > maxInsulin) {
|
||||||
overview_treatment_insulin.value = 0.0
|
overview_treatment_insulin.value = 0.0
|
||||||
ToastUtils.showToastInUiThread(mainApp, resourceHelper.gs(R.string.bolusconstraintapplied))
|
ToastUtils.showToastInUiThread(context, resourceHelper.gs(R.string.bolusconstraintapplied))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -77,7 +75,7 @@ class TreatmentDialog : DialogFragmentWithDate() {
|
||||||
|
|
||||||
val maxCarbs = constraintChecker.getMaxCarbsAllowed().value().toDouble()
|
val maxCarbs = constraintChecker.getMaxCarbsAllowed().value().toDouble()
|
||||||
val maxInsulin = constraintChecker.getMaxBolusAllowed().value()
|
val maxInsulin = constraintChecker.getMaxBolusAllowed().value()
|
||||||
val pumpDescription = configBuilderPlugin.activePump?.pumpDescription ?: return
|
val pumpDescription = activePlugin.activePumpPlugin?.pumpDescription ?: return
|
||||||
overview_treatment_carbs.setParams(savedInstanceState?.getDouble("overview_treatment_carbs")
|
overview_treatment_carbs.setParams(savedInstanceState?.getDouble("overview_treatment_carbs")
|
||||||
?: 0.0, 0.0, maxCarbs, 1.0, DecimalFormat("0"), false, ok, textWatcher)
|
?: 0.0, 0.0, maxCarbs, 1.0, DecimalFormat("0"), false, ok, textWatcher)
|
||||||
overview_treatment_insulin.setParams(savedInstanceState?.getDouble("overview_treatment_insulin")
|
overview_treatment_insulin.setParams(savedInstanceState?.getDouble("overview_treatment_insulin")
|
||||||
|
@ -85,7 +83,7 @@ class TreatmentDialog : DialogFragmentWithDate() {
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun submit(): Boolean {
|
override fun submit(): Boolean {
|
||||||
val pumpDescription = configBuilderPlugin.activePump?.pumpDescription
|
val pumpDescription = activePlugin.activePumpPlugin?.pumpDescription
|
||||||
?: return false
|
?: return false
|
||||||
val insulin = SafeParse.stringToDouble(overview_treatment_insulin.text)
|
val insulin = SafeParse.stringToDouble(overview_treatment_insulin.text)
|
||||||
val carbs = SafeParse.stringToInt(overview_treatment_carbs.text)
|
val carbs = SafeParse.stringToInt(overview_treatment_carbs.text)
|
||||||
|
@ -117,20 +115,20 @@ class TreatmentDialog : DialogFragmentWithDate() {
|
||||||
detailedBolusInfo.context = context
|
detailedBolusInfo.context = context
|
||||||
detailedBolusInfo.source = Source.USER
|
detailedBolusInfo.source = Source.USER
|
||||||
if (!(recordOnlyChecked && (detailedBolusInfo.insulin > 0 || pumpDescription.storesCarbInfo))) {
|
if (!(recordOnlyChecked && (detailedBolusInfo.insulin > 0 || pumpDescription.storesCarbInfo))) {
|
||||||
configBuilderPlugin.commandQueue.bolus(detailedBolusInfo, object : Callback() {
|
commandQueue.bolus(detailedBolusInfo, object : Callback() {
|
||||||
override fun run() {
|
override fun run() {
|
||||||
if (!result.success) {
|
if (!result.success) {
|
||||||
val i = Intent(mainApp, ErrorHelperActivity::class.java)
|
val i = Intent(context, ErrorHelperActivity::class.java)
|
||||||
i.putExtra("soundid", R.raw.boluserror)
|
i.putExtra("soundid", R.raw.boluserror)
|
||||||
i.putExtra("status", result.comment)
|
i.putExtra("status", result.comment)
|
||||||
i.putExtra("title", resourceHelper.gs(R.string.treatmentdeliveryerror))
|
i.putExtra("title", resourceHelper.gs(R.string.treatmentdeliveryerror))
|
||||||
i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
|
i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
|
||||||
mainApp.startActivity(i)
|
context?.startActivity(i)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
} else
|
} else
|
||||||
treatmentsPlugin.addToHistoryTreatment(detailedBolusInfo, false)
|
activePlugin.activeTreatments.addToHistoryTreatment(detailedBolusInfo, false)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
} else
|
} else
|
||||||
|
|
|
@ -18,7 +18,6 @@ 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.db.BgReading
|
import info.nightscout.androidaps.db.BgReading
|
||||||
import info.nightscout.androidaps.db.DatabaseHelper
|
|
||||||
import info.nightscout.androidaps.interfaces.Constraint
|
import info.nightscout.androidaps.interfaces.Constraint
|
||||||
import info.nightscout.androidaps.logging.AAPSLogger
|
import info.nightscout.androidaps.logging.AAPSLogger
|
||||||
import info.nightscout.androidaps.logging.LTag
|
import info.nightscout.androidaps.logging.LTag
|
||||||
|
@ -110,8 +109,7 @@ class WizardDialog : DaggerDialogFragment() {
|
||||||
?: 0.0, 0.0, 500.0, 0.1, DecimalFormat("0.0"), false, ok, textWatcher)
|
?: 0.0, 0.0, 500.0, 0.1, DecimalFormat("0.0"), false, ok, textWatcher)
|
||||||
treatments_wizard_carbs_input.setParams(savedInstanceState?.getDouble("treatments_wizard_carbs_input")
|
treatments_wizard_carbs_input.setParams(savedInstanceState?.getDouble("treatments_wizard_carbs_input")
|
||||||
?: 0.0, 0.0, maxCarbs.toDouble(), 1.0, DecimalFormat("0"), false, ok, textWatcher)
|
?: 0.0, 0.0, maxCarbs.toDouble(), 1.0, DecimalFormat("0"), false, ok, textWatcher)
|
||||||
val bolusStep = configBuilderPlugin.activePump?.pumpDescription?.bolusStep
|
val bolusStep = configBuilderPlugin.activePump.pumpDescription.bolusStep
|
||||||
?: 0.1
|
|
||||||
treatments_wizard_correction_input.setParams(savedInstanceState?.getDouble("treatments_wizard_correction_input")
|
treatments_wizard_correction_input.setParams(savedInstanceState?.getDouble("treatments_wizard_correction_input")
|
||||||
?: 0.0, -maxCorrection, maxCorrection, bolusStep, DecimalFormatter.pumpSupportedBolusFormat(), false, ok, textWatcher)
|
?: 0.0, -maxCorrection, maxCorrection, bolusStep, DecimalFormatter.pumpSupportedBolusFormat(), false, ok, textWatcher)
|
||||||
treatments_wizard_carb_time_input.setParams(savedInstanceState?.getDouble("treatments_wizard_carb_time_input")
|
treatments_wizard_carb_time_input.setParams(savedInstanceState?.getDouble("treatments_wizard_carb_time_input")
|
||||||
|
@ -238,7 +236,7 @@ class WizardDialog : DaggerDialogFragment() {
|
||||||
treatments_wizard_bg_input.setStep(0.1)
|
treatments_wizard_bg_input.setStep(0.1)
|
||||||
|
|
||||||
// Set BG if not old
|
// Set BG if not old
|
||||||
val lastBg = DatabaseHelper.actualBg()
|
val lastBg = iobCobCalculatorPlugin.actualBg()
|
||||||
|
|
||||||
if (lastBg != null) {
|
if (lastBg != null) {
|
||||||
treatments_wizard_bg_input.value = lastBg.valueToUnits(units)
|
treatments_wizard_bg_input.value = lastBg.valueToUnits(units)
|
||||||
|
|
|
@ -1,24 +1,34 @@
|
||||||
package info.nightscout.androidaps.historyBrowser
|
package info.nightscout.androidaps.historyBrowser
|
||||||
|
|
||||||
|
import dagger.android.HasAndroidInjector
|
||||||
import info.nightscout.androidaps.logging.AAPSLogger
|
import info.nightscout.androidaps.logging.AAPSLogger
|
||||||
import info.nightscout.androidaps.plugins.bus.RxBusWrapper
|
import info.nightscout.androidaps.plugins.bus.RxBusWrapper
|
||||||
import info.nightscout.androidaps.plugins.configBuilder.ConfigBuilderPlugin
|
import info.nightscout.androidaps.plugins.configBuilder.ConfigBuilderPlugin
|
||||||
import info.nightscout.androidaps.plugins.configBuilder.ProfileFunction
|
import info.nightscout.androidaps.plugins.configBuilder.ProfileFunction
|
||||||
import info.nightscout.androidaps.plugins.iob.iobCobCalculator.IobCobCalculatorPlugin
|
import info.nightscout.androidaps.plugins.iob.iobCobCalculator.IobCobCalculatorPlugin
|
||||||
|
import info.nightscout.androidaps.plugins.sensitivity.SensitivityAAPSPlugin
|
||||||
|
import info.nightscout.androidaps.plugins.sensitivity.SensitivityOref1Plugin
|
||||||
|
import info.nightscout.androidaps.plugins.sensitivity.SensitivityWeightedAveragePlugin
|
||||||
import info.nightscout.androidaps.plugins.treatments.TreatmentsPlugin
|
import info.nightscout.androidaps.plugins.treatments.TreatmentsPlugin
|
||||||
import info.nightscout.androidaps.utils.resources.ResourceHelper
|
import info.nightscout.androidaps.utils.resources.ResourceHelper
|
||||||
import info.nightscout.androidaps.utils.sharedPreferences.SP
|
import info.nightscout.androidaps.utils.sharedPreferences.SP
|
||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
|
|
||||||
class IobCobStaticCalculatorPlugin @Inject constructor(
|
class IobCobStaticCalculatorPlugin @Inject constructor(
|
||||||
|
injector: HasAndroidInjector,
|
||||||
aapsLogger: AAPSLogger,
|
aapsLogger: AAPSLogger,
|
||||||
rxBus: RxBusWrapper,
|
rxBus: RxBusWrapper,
|
||||||
sp: SP,
|
sp: SP,
|
||||||
resourceHelper: ResourceHelper,
|
resourceHelper: ResourceHelper,
|
||||||
profileFunction: ProfileFunction,
|
profileFunction: ProfileFunction,
|
||||||
configBuilderPlugin: ConfigBuilderPlugin,
|
configBuilderPlugin: ConfigBuilderPlugin,
|
||||||
treatmentsPlugin: TreatmentsPlugin
|
treatmentsPlugin: TreatmentsPlugin,
|
||||||
) : IobCobCalculatorPlugin(aapsLogger, rxBus, sp, resourceHelper, profileFunction, configBuilderPlugin, treatmentsPlugin) {
|
sensitivityOref1Plugin: SensitivityOref1Plugin,
|
||||||
|
sensitivityAAPSPlugin: SensitivityAAPSPlugin,
|
||||||
|
sensitivityWeightedAveragePlugin: SensitivityWeightedAveragePlugin
|
||||||
|
) : IobCobCalculatorPlugin(injector, aapsLogger, rxBus, sp, resourceHelper, profileFunction,
|
||||||
|
configBuilderPlugin, treatmentsPlugin, sensitivityOref1Plugin, sensitivityAAPSPlugin, sensitivityWeightedAveragePlugin) {
|
||||||
|
|
||||||
override fun onStart() { // do not attach to rxbus
|
override fun onStart() { // do not attach to rxbus
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -1,23 +1,25 @@
|
||||||
package info.nightscout.androidaps.interfaces;
|
package info.nightscout.androidaps.interfaces;
|
||||||
|
|
||||||
|
import androidx.annotation.NonNull;
|
||||||
import androidx.annotation.Nullable;
|
import androidx.annotation.Nullable;
|
||||||
|
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
/**
|
|
||||||
* Created by adrian on 2020-01-07.
|
|
||||||
*/
|
|
||||||
|
|
||||||
public interface ActivePluginProvider {
|
public interface ActivePluginProvider {
|
||||||
|
|
||||||
@Nullable BgSourceInterface getActiveBgSource();
|
@Nullable BgSourceInterface getActiveBgSource();
|
||||||
|
|
||||||
@NotNull ProfileInterface getActiveProfileInterface();
|
@NotNull ProfileInterface getActiveProfileInterface(); // Forced to LocalProfile if not changed
|
||||||
|
|
||||||
@Nullable InsulinInterface getActiveInsulin();
|
@NonNull InsulinInterface getActiveInsulin(); // Forced to RapidActing if not changed
|
||||||
|
|
||||||
@Nullable APSInterface getActiveAPS();
|
@Nullable APSInterface getActiveAPS();
|
||||||
|
|
||||||
@Nullable PumpInterface getActivePump();
|
@Nullable PumpInterface getActivePumpPlugin(); // Use in UI to disable buttons or check if pump is selected
|
||||||
|
|
||||||
@Nullable SensitivityInterface getActiveSensitivity();
|
@NotNull PumpInterface getActivePump(); // Use in places not reachable without active pump. Otherwise IllegalStateException is thrown
|
||||||
|
|
||||||
|
@NotNull SensitivityInterface getActiveSensitivity(); // Forced to oref1 if not changed
|
||||||
|
|
||||||
|
@NotNull TreatmentsInterface getActiveTreatments();
|
||||||
}
|
}
|
|
@ -1,11 +0,0 @@
|
||||||
package info.nightscout.androidaps.interfaces;
|
|
||||||
|
|
||||||
import info.nightscout.androidaps.queue.CommandQueue;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Created by adrian on 2020-01-07.
|
|
||||||
*/
|
|
||||||
|
|
||||||
public interface CommandQueueProvider {
|
|
||||||
CommandQueue getCommandQueue();
|
|
||||||
}
|
|
|
@ -0,0 +1,38 @@
|
||||||
|
package info.nightscout.androidaps.interfaces
|
||||||
|
|
||||||
|
import android.text.Spanned
|
||||||
|
import info.nightscout.androidaps.data.DetailedBolusInfo
|
||||||
|
import info.nightscout.androidaps.data.Profile
|
||||||
|
import info.nightscout.androidaps.queue.Callback
|
||||||
|
import info.nightscout.androidaps.queue.commands.Command
|
||||||
|
|
||||||
|
interface CommandQueueProvider {
|
||||||
|
|
||||||
|
fun isRunning(type: Command.CommandType): Boolean
|
||||||
|
fun pickup()
|
||||||
|
fun clear()
|
||||||
|
fun size(): Int
|
||||||
|
fun performing(): Command?
|
||||||
|
fun resetPerforming()
|
||||||
|
fun independentConnect(reason: String, callback: Callback?)
|
||||||
|
fun bolusInQueue(): Boolean
|
||||||
|
fun bolus(detailedBolusInfo: DetailedBolusInfo, callback: Callback?): Boolean
|
||||||
|
fun cancelAllBoluses()
|
||||||
|
fun stopPump(callback: Callback?)
|
||||||
|
fun startPump(callback: Callback?)
|
||||||
|
fun setTBROverNotification(callback: Callback?, enable: Boolean)
|
||||||
|
fun tempBasalAbsolute(absoluteRate: Double, durationInMinutes: Int, enforceNew: Boolean, profile: Profile, callback: Callback?): Boolean
|
||||||
|
fun tempBasalPercent(percent: Int, durationInMinutes: Int, enforceNew: Boolean, profile: Profile, callback: Callback?): Boolean
|
||||||
|
fun extendedBolus(insulin: Double, durationInMinutes: Int, callback: Callback?): Boolean
|
||||||
|
fun cancelTempBasal(enforceNew: Boolean, callback: Callback?): Boolean
|
||||||
|
fun cancelExtended(callback: Callback?): Boolean
|
||||||
|
fun setProfile(profile: Profile, callback: Callback?): Boolean
|
||||||
|
fun readStatus(reason: String, callback: Callback?): Boolean
|
||||||
|
fun statusInQueue(): Boolean
|
||||||
|
fun loadHistory(type: Byte, callback: Callback?): Boolean
|
||||||
|
fun setUserOptions(callback: Callback?): Boolean
|
||||||
|
fun loadTDDs(callback: Callback?): Boolean
|
||||||
|
fun loadEvents(callback: Callback?): Boolean
|
||||||
|
fun spannedStatus(): Spanned
|
||||||
|
fun isThisProfileSet(profile: Profile): Boolean
|
||||||
|
}
|
|
@ -1,32 +1,19 @@
|
||||||
package info.nightscout.androidaps.interfaces
|
package info.nightscout.androidaps.interfaces
|
||||||
|
|
||||||
import android.os.SystemClock
|
|
||||||
import androidx.fragment.app.FragmentActivity
|
|
||||||
import androidx.preference.Preference
|
import androidx.preference.Preference
|
||||||
import androidx.preference.PreferenceFragmentCompat
|
import androidx.preference.PreferenceFragmentCompat
|
||||||
import info.nightscout.androidaps.MainApp
|
|
||||||
import info.nightscout.androidaps.R
|
|
||||||
import info.nightscout.androidaps.events.EventConfigBuilderChange
|
|
||||||
import info.nightscout.androidaps.events.EventRebuildTabs
|
|
||||||
import info.nightscout.androidaps.logging.AAPSLogger
|
import info.nightscout.androidaps.logging.AAPSLogger
|
||||||
import info.nightscout.androidaps.logging.L
|
import info.nightscout.androidaps.logging.LTag
|
||||||
import info.nightscout.androidaps.logging.L.isEnabled
|
import info.nightscout.androidaps.utils.resources.ResourceHelper
|
||||||
import info.nightscout.androidaps.plugins.bus.RxBus
|
|
||||||
import info.nightscout.androidaps.plugins.bus.RxBusWrapper
|
|
||||||
import info.nightscout.androidaps.plugins.configBuilder.ConfigBuilderPlugin
|
|
||||||
import info.nightscout.androidaps.plugins.configBuilder.EventConfigBuilderUpdateGui
|
|
||||||
import info.nightscout.androidaps.utils.OKDialog.showConfirmation
|
|
||||||
import info.nightscout.androidaps.utils.SP
|
|
||||||
import org.slf4j.LoggerFactory
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by mike on 09.06.2016.
|
* Created by mike on 09.06.2016.
|
||||||
*/
|
*/
|
||||||
abstract class PluginBase(val pluginDescription: PluginDescription, val rxBus: RxBusWrapper, val aapsLogger: AAPSLogger) {
|
abstract class PluginBase(
|
||||||
|
val pluginDescription: PluginDescription,
|
||||||
companion object {
|
val aapsLogger: AAPSLogger,
|
||||||
private val log = LoggerFactory.getLogger(L.CORE)
|
val resourceHelper: ResourceHelper
|
||||||
}
|
) {
|
||||||
|
|
||||||
enum class State {
|
enum class State {
|
||||||
NOT_INITIALIZED, ENABLED, DISABLED
|
NOT_INITIALIZED, ENABLED, DISABLED
|
||||||
|
@ -34,61 +21,22 @@ abstract class PluginBase(val pluginDescription: PluginDescription, val rxBus: R
|
||||||
|
|
||||||
private var state = State.NOT_INITIALIZED
|
private var state = State.NOT_INITIALIZED
|
||||||
private var fragmentVisible = false
|
private var fragmentVisible = false
|
||||||
// Specific plugin with more Interfaces
|
|
||||||
protected var isProfileInterfaceEnabled = false
|
|
||||||
|
|
||||||
// Default always calls invoke
|
|
||||||
// Plugins that have special constraints if they get switched to may override this method
|
|
||||||
open fun switchAllowed(newState: Boolean, activity: FragmentActivity?, type: PluginType) {
|
|
||||||
performPluginSwitch(newState, type)
|
|
||||||
}
|
|
||||||
|
|
||||||
protected fun confirmPumpPluginActivation(newState: Boolean, activity: FragmentActivity?, type: PluginType) {
|
|
||||||
if (type == PluginType.PUMP) {
|
|
||||||
val allowHardwarePump = SP.getBoolean("allow_hardware_pump", false)
|
|
||||||
if (allowHardwarePump || activity == null) {
|
|
||||||
performPluginSwitch(newState, type)
|
|
||||||
} else {
|
|
||||||
showConfirmation(activity, MainApp.gs(R.string.allow_hardware_pump_text), Runnable {
|
|
||||||
performPluginSwitch(newState, type)
|
|
||||||
SP.putBoolean("allow_hardware_pump", true)
|
|
||||||
if (isEnabled(L.PUMP)) log.debug("First time HW pump allowed!")
|
|
||||||
}, Runnable {
|
|
||||||
RxBus.INSTANCE.send(EventConfigBuilderUpdateGui())
|
|
||||||
if (isEnabled(L.PUMP)) log.debug("User does not allow switching to HW pump!")
|
|
||||||
})
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
performPluginSwitch(newState, type)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun performPluginSwitch(enabled: Boolean, type: PluginType) {
|
|
||||||
setPluginEnabled(type, enabled)
|
|
||||||
setFragmentVisible(type, enabled)
|
|
||||||
ConfigBuilderPlugin.getPlugin().processOnEnabledCategoryChanged(this, type)
|
|
||||||
ConfigBuilderPlugin.getPlugin().storeSettings("CheckedCheckboxEnabled")
|
|
||||||
RxBus.INSTANCE.send(EventRebuildTabs())
|
|
||||||
RxBus.INSTANCE.send(EventConfigBuilderChange())
|
|
||||||
RxBus.INSTANCE.send(EventConfigBuilderUpdateGui())
|
|
||||||
ConfigBuilderPlugin.getPlugin().logPluginStatus()
|
|
||||||
}
|
|
||||||
|
|
||||||
open val name: String
|
open val name: String
|
||||||
get() = if (pluginDescription.pluginName == -1) "UNKNOWN" else MainApp.gs(pluginDescription.pluginName)
|
get() = if (pluginDescription.pluginName == -1) "UNKNOWN" else resourceHelper.gs(pluginDescription.pluginName)
|
||||||
|
|
||||||
//only if translation exists
|
//only if translation exists
|
||||||
// use long name as fallback
|
// use long name as fallback
|
||||||
val nameShort: String
|
val nameShort: String
|
||||||
get() {
|
get() {
|
||||||
if (pluginDescription.shortName == -1) return name
|
if (pluginDescription.shortName == -1) return name
|
||||||
val translatedName = MainApp.gs(pluginDescription.shortName)
|
val translatedName = resourceHelper.gs(pluginDescription.shortName)
|
||||||
return if (!translatedName.trim { it <= ' ' }.isEmpty()) translatedName else name
|
return if (!translatedName.trim { it <= ' ' }.isEmpty()) translatedName else name
|
||||||
// use long name as fallback
|
// use long name as fallback
|
||||||
}
|
}
|
||||||
|
|
||||||
val description: String?
|
val description: String?
|
||||||
get() = if (pluginDescription.description == -1) null else MainApp.gs(pluginDescription.description)
|
get() = if (pluginDescription.description == -1) null else resourceHelper.gs(pluginDescription.description)
|
||||||
|
|
||||||
fun getType(): PluginType = pluginDescription.mainType
|
fun getType(): PluginType = pluginDescription.mainType
|
||||||
|
|
||||||
|
@ -103,7 +51,7 @@ abstract class PluginBase(val pluginDescription: PluginDescription, val rxBus: R
|
||||||
if (type == pluginDescription.mainType) return state == State.ENABLED && specialEnableCondition()
|
if (type == pluginDescription.mainType) return state == State.ENABLED && specialEnableCondition()
|
||||||
if (type == PluginType.CONSTRAINTS && pluginDescription.mainType == PluginType.PUMP && isEnabled(PluginType.PUMP)) return true
|
if (type == PluginType.CONSTRAINTS && pluginDescription.mainType == PluginType.PUMP && isEnabled(PluginType.PUMP)) return true
|
||||||
if (type == PluginType.CONSTRAINTS && pluginDescription.mainType == PluginType.APS && isEnabled(PluginType.APS)) return true
|
if (type == PluginType.CONSTRAINTS && pluginDescription.mainType == PluginType.APS && isEnabled(PluginType.APS)) return true
|
||||||
return if (type == PluginType.PROFILE && pluginDescription.mainType == PluginType.PUMP) isProfileInterfaceEnabled else false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
fun hasFragment(): Boolean {
|
fun hasFragment(): Boolean {
|
||||||
|
@ -121,7 +69,7 @@ abstract class PluginBase(val pluginDescription: PluginDescription, val rxBus: R
|
||||||
if (state != State.ENABLED) {
|
if (state != State.ENABLED) {
|
||||||
onStateChange(type, state, State.ENABLED)
|
onStateChange(type, state, State.ENABLED)
|
||||||
state = State.ENABLED
|
state = State.ENABLED
|
||||||
if (isEnabled(L.CORE)) log.debug("Starting: $name")
|
aapsLogger.debug(LTag.CORE, "Starting: $name")
|
||||||
onStart()
|
onStart()
|
||||||
}
|
}
|
||||||
} else { // disabling plugin
|
} else { // disabling plugin
|
||||||
|
@ -129,11 +77,9 @@ abstract class PluginBase(val pluginDescription: PluginDescription, val rxBus: R
|
||||||
onStateChange(type, state, State.DISABLED)
|
onStateChange(type, state, State.DISABLED)
|
||||||
state = State.DISABLED
|
state = State.DISABLED
|
||||||
onStop()
|
onStop()
|
||||||
if (isEnabled(L.CORE)) log.debug("Stopping: $name")
|
aapsLogger.debug(LTag.CORE, "Stopping: $name")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if (type == PluginType.PROFILE) {
|
|
||||||
isProfileInterfaceEnabled = newState
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -161,16 +107,7 @@ abstract class PluginBase(val pluginDescription: PluginDescription, val rxBus: R
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
protected open fun onStart() {
|
protected open fun onStart() {}
|
||||||
if (getType() == PluginType.PUMP) {
|
|
||||||
Thread(Runnable {
|
|
||||||
SystemClock.sleep(3000)
|
|
||||||
val commandQueue = ConfigBuilderPlugin.getPlugin().commandQueue
|
|
||||||
commandQueue?.readStatus("Pump driver changed.", null)
|
|
||||||
}).start()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
protected open fun onStop() {}
|
protected open fun onStop() {}
|
||||||
protected open fun onStateChange(type: PluginType?, oldState: State?, newState: State?) {}
|
protected open fun onStateChange(type: PluginType?, oldState: State?, newState: State?) {}
|
||||||
open fun preprocessPreferences(preferenceFragment: PreferenceFragmentCompat) {}
|
open fun preprocessPreferences(preferenceFragment: PreferenceFragmentCompat) {}
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
package info.nightscout.androidaps.interfaces;
|
package info.nightscout.androidaps.interfaces;
|
||||||
|
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.json.JSONObject;
|
import org.json.JSONObject;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
@ -42,6 +43,7 @@ public interface PumpInterface {
|
||||||
void getPumpStatus();
|
void getPumpStatus();
|
||||||
|
|
||||||
// Upload to pump new basal profile
|
// Upload to pump new basal profile
|
||||||
|
@NotNull
|
||||||
PumpEnactResult setNewBasalProfile(Profile profile);
|
PumpEnactResult setNewBasalProfile(Profile profile);
|
||||||
|
|
||||||
boolean isThisProfileSet(Profile profile);
|
boolean isThisProfileSet(Profile profile);
|
||||||
|
@ -54,39 +56,52 @@ public interface PumpInterface {
|
||||||
|
|
||||||
int getBatteryLevel(); // in percent as integer
|
int getBatteryLevel(); // in percent as integer
|
||||||
|
|
||||||
|
@NotNull
|
||||||
PumpEnactResult deliverTreatment(DetailedBolusInfo detailedBolusInfo);
|
PumpEnactResult deliverTreatment(DetailedBolusInfo detailedBolusInfo);
|
||||||
|
|
||||||
void stopBolusDelivering();
|
void stopBolusDelivering();
|
||||||
|
|
||||||
|
@NotNull
|
||||||
PumpEnactResult setTempBasalAbsolute(Double absoluteRate, Integer durationInMinutes, Profile profile, boolean enforceNew);
|
PumpEnactResult setTempBasalAbsolute(Double absoluteRate, Integer durationInMinutes, Profile profile, boolean enforceNew);
|
||||||
|
|
||||||
|
@NotNull
|
||||||
PumpEnactResult setTempBasalPercent(Integer percent, Integer durationInMinutes, Profile profile, boolean enforceNew);
|
PumpEnactResult setTempBasalPercent(Integer percent, Integer durationInMinutes, Profile profile, boolean enforceNew);
|
||||||
|
|
||||||
|
@NotNull
|
||||||
PumpEnactResult setExtendedBolus(Double insulin, Integer durationInMinutes);
|
PumpEnactResult setExtendedBolus(Double insulin, Integer durationInMinutes);
|
||||||
|
|
||||||
//some pumps might set a very short temp close to 100% as cancelling a temp can be noisy
|
//some pumps might set a very short temp close to 100% as cancelling a temp can be noisy
|
||||||
//when the cancel request is requested by the user (forced), the pump should always do a real cancel
|
//when the cancel request is requested by the user (forced), the pump should always do a real cancel
|
||||||
|
@NotNull
|
||||||
PumpEnactResult cancelTempBasal(boolean enforceNew);
|
PumpEnactResult cancelTempBasal(boolean enforceNew);
|
||||||
|
|
||||||
|
@NotNull
|
||||||
PumpEnactResult cancelExtendedBolus();
|
PumpEnactResult cancelExtendedBolus();
|
||||||
|
|
||||||
// Status to be passed to NS
|
// Status to be passed to NS
|
||||||
|
@NotNull
|
||||||
JSONObject getJSONStatus(Profile profile, String profileName);
|
JSONObject getJSONStatus(Profile profile, String profileName);
|
||||||
|
|
||||||
|
@NotNull
|
||||||
ManufacturerType manufacturer();
|
ManufacturerType manufacturer();
|
||||||
|
|
||||||
|
@NotNull
|
||||||
PumpType model();
|
PumpType model();
|
||||||
|
|
||||||
|
@NotNull
|
||||||
String serialNumber();
|
String serialNumber();
|
||||||
|
|
||||||
// Pump capabilities
|
// Pump capabilities
|
||||||
|
@NotNull
|
||||||
PumpDescription getPumpDescription();
|
PumpDescription getPumpDescription();
|
||||||
|
|
||||||
// Short info for SMS, Wear etc
|
// Short info for SMS, Wear etc
|
||||||
|
@NotNull
|
||||||
String shortStatus(boolean veryShort);
|
String shortStatus(boolean veryShort);
|
||||||
|
|
||||||
boolean isFakingTempsByExtendedBoluses();
|
boolean isFakingTempsByExtendedBoluses();
|
||||||
|
|
||||||
|
@NotNull
|
||||||
PumpEnactResult loadTDDs();
|
PumpEnactResult loadTDDs();
|
||||||
|
|
||||||
boolean canHandleDST();
|
boolean canHandleDST();
|
||||||
|
@ -101,5 +116,4 @@ public interface PumpInterface {
|
||||||
* example update clock on pump).
|
* example update clock on pump).
|
||||||
*/
|
*/
|
||||||
void timeDateOrTimeZoneChanged();
|
void timeDateOrTimeZoneChanged();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,23 @@
|
||||||
|
package info.nightscout.androidaps.interfaces
|
||||||
|
|
||||||
|
import android.os.SystemClock
|
||||||
|
import info.nightscout.androidaps.logging.AAPSLogger
|
||||||
|
import info.nightscout.androidaps.utils.resources.ResourceHelper
|
||||||
|
|
||||||
|
abstract class PumpPluginBase(
|
||||||
|
pluginDescription: PluginDescription,
|
||||||
|
aapsLogger: AAPSLogger,
|
||||||
|
resourceHelper: ResourceHelper,
|
||||||
|
val commandQueue: CommandQueueProvider
|
||||||
|
) : PluginBase(pluginDescription, aapsLogger, resourceHelper) {
|
||||||
|
|
||||||
|
override fun onStart() {
|
||||||
|
super.onStart()
|
||||||
|
if (getType() == PluginType.PUMP) {
|
||||||
|
Thread(Runnable {
|
||||||
|
SystemClock.sleep(3000)
|
||||||
|
commandQueue.readStatus("Pump driver changed.", null)
|
||||||
|
}).start()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -29,13 +29,13 @@ import info.nightscout.androidaps.data.Profile;
|
||||||
import info.nightscout.androidaps.data.PumpEnactResult;
|
import info.nightscout.androidaps.data.PumpEnactResult;
|
||||||
import info.nightscout.androidaps.db.BgReading;
|
import info.nightscout.androidaps.db.BgReading;
|
||||||
import info.nightscout.androidaps.db.CareportalEvent;
|
import info.nightscout.androidaps.db.CareportalEvent;
|
||||||
import info.nightscout.androidaps.db.DatabaseHelper;
|
|
||||||
import info.nightscout.androidaps.db.Source;
|
import info.nightscout.androidaps.db.Source;
|
||||||
import info.nightscout.androidaps.db.TemporaryBasal;
|
import info.nightscout.androidaps.db.TemporaryBasal;
|
||||||
import info.nightscout.androidaps.events.EventAcceptOpenLoopChange;
|
import info.nightscout.androidaps.events.EventAcceptOpenLoopChange;
|
||||||
import info.nightscout.androidaps.events.EventNewBG;
|
import info.nightscout.androidaps.events.EventNewBG;
|
||||||
import info.nightscout.androidaps.events.EventTempTargetChange;
|
import info.nightscout.androidaps.events.EventTempTargetChange;
|
||||||
import info.nightscout.androidaps.interfaces.APSInterface;
|
import info.nightscout.androidaps.interfaces.APSInterface;
|
||||||
|
import info.nightscout.androidaps.interfaces.CommandQueueProvider;
|
||||||
import info.nightscout.androidaps.interfaces.Constraint;
|
import info.nightscout.androidaps.interfaces.Constraint;
|
||||||
import info.nightscout.androidaps.interfaces.PluginBase;
|
import info.nightscout.androidaps.interfaces.PluginBase;
|
||||||
import info.nightscout.androidaps.interfaces.PluginDescription;
|
import info.nightscout.androidaps.interfaces.PluginDescription;
|
||||||
|
@ -54,6 +54,7 @@ import info.nightscout.androidaps.plugins.configBuilder.ConstraintChecker;
|
||||||
import info.nightscout.androidaps.plugins.configBuilder.ProfileFunction;
|
import info.nightscout.androidaps.plugins.configBuilder.ProfileFunction;
|
||||||
import info.nightscout.androidaps.plugins.general.nsclient.NSUpload;
|
import info.nightscout.androidaps.plugins.general.nsclient.NSUpload;
|
||||||
import info.nightscout.androidaps.plugins.general.wear.ActionStringHandler;
|
import info.nightscout.androidaps.plugins.general.wear.ActionStringHandler;
|
||||||
|
import info.nightscout.androidaps.plugins.iob.iobCobCalculator.IobCobCalculatorPlugin;
|
||||||
import info.nightscout.androidaps.plugins.iob.iobCobCalculator.events.EventAutosensCalculationFinished;
|
import info.nightscout.androidaps.plugins.iob.iobCobCalculator.events.EventAutosensCalculationFinished;
|
||||||
import info.nightscout.androidaps.plugins.pump.virtual.VirtualPumpPlugin;
|
import info.nightscout.androidaps.plugins.pump.virtual.VirtualPumpPlugin;
|
||||||
import info.nightscout.androidaps.plugins.treatments.TreatmentsPlugin;
|
import info.nightscout.androidaps.plugins.treatments.TreatmentsPlugin;
|
||||||
|
@ -69,14 +70,17 @@ import io.reactivex.schedulers.Schedulers;
|
||||||
@Singleton
|
@Singleton
|
||||||
public class LoopPlugin extends PluginBase {
|
public class LoopPlugin extends PluginBase {
|
||||||
private final SP sp;
|
private final SP sp;
|
||||||
|
private final RxBusWrapper rxBus;
|
||||||
private final ConstraintChecker constraintChecker;
|
private final ConstraintChecker constraintChecker;
|
||||||
private final ResourceHelper resourceHelper;
|
private final ResourceHelper resourceHelper;
|
||||||
private final ProfileFunction profileFunction;
|
private final ProfileFunction profileFunction;
|
||||||
private final MainApp mainApp;
|
private final MainApp mainApp;
|
||||||
|
private final CommandQueueProvider commandQueue;
|
||||||
private final ConfigBuilderPlugin configBuilderPlugin;
|
private final ConfigBuilderPlugin configBuilderPlugin;
|
||||||
private final TreatmentsPlugin treatmentsPlugin;
|
private final TreatmentsPlugin treatmentsPlugin;
|
||||||
private final VirtualPumpPlugin virtualPumpPlugin;
|
private final VirtualPumpPlugin virtualPumpPlugin;
|
||||||
private final Lazy<ActionStringHandler> actionStringHandler;
|
private final Lazy<ActionStringHandler> actionStringHandler;
|
||||||
|
private final IobCobCalculatorPlugin iobCobCalculatorPlugin;
|
||||||
|
|
||||||
private CompositeDisposable disposable = new CompositeDisposable();
|
private CompositeDisposable disposable = new CompositeDisposable();
|
||||||
|
|
||||||
|
@ -104,16 +108,18 @@ public class LoopPlugin extends PluginBase {
|
||||||
@Inject
|
@Inject
|
||||||
public LoopPlugin(
|
public LoopPlugin(
|
||||||
AAPSLogger aapsLogger,
|
AAPSLogger aapsLogger,
|
||||||
RxBusWrapper rxBusWrapper,
|
RxBusWrapper rxBus,
|
||||||
SP sp,
|
SP sp,
|
||||||
ConstraintChecker constraintChecker,
|
ConstraintChecker constraintChecker,
|
||||||
ResourceHelper resourceHelper,
|
ResourceHelper resourceHelper,
|
||||||
ProfileFunction profileFunction,
|
ProfileFunction profileFunction,
|
||||||
MainApp mainApp,
|
MainApp mainApp,
|
||||||
|
CommandQueueProvider commandQueue,
|
||||||
ConfigBuilderPlugin configBuilderPlugin,
|
ConfigBuilderPlugin configBuilderPlugin,
|
||||||
TreatmentsPlugin treatmentsPlugin,
|
TreatmentsPlugin treatmentsPlugin,
|
||||||
VirtualPumpPlugin virtualPumpPlugin,
|
VirtualPumpPlugin virtualPumpPlugin,
|
||||||
Lazy<ActionStringHandler> actionStringHandler // TODO Adrian use RxBus instead of Lazy
|
Lazy<ActionStringHandler> actionStringHandler, // TODO Adrian use RxBus instead of Lazy
|
||||||
|
IobCobCalculatorPlugin iobCobCalculatorPlugin
|
||||||
) {
|
) {
|
||||||
super(new PluginDescription()
|
super(new PluginDescription()
|
||||||
.mainType(PluginType.LOOP)
|
.mainType(PluginType.LOOP)
|
||||||
|
@ -122,17 +128,20 @@ public class LoopPlugin extends PluginBase {
|
||||||
.shortName(R.string.loop_shortname)
|
.shortName(R.string.loop_shortname)
|
||||||
.preferencesId(R.xml.pref_loop)
|
.preferencesId(R.xml.pref_loop)
|
||||||
.description(R.string.description_loop),
|
.description(R.string.description_loop),
|
||||||
rxBusWrapper, aapsLogger
|
aapsLogger, resourceHelper
|
||||||
);
|
);
|
||||||
this.sp = sp;
|
this.sp = sp;
|
||||||
|
this.rxBus = rxBus;
|
||||||
this.constraintChecker = constraintChecker;
|
this.constraintChecker = constraintChecker;
|
||||||
this.resourceHelper = resourceHelper;
|
this.resourceHelper = resourceHelper;
|
||||||
this.profileFunction = profileFunction;
|
this.profileFunction = profileFunction;
|
||||||
this.mainApp = mainApp;
|
this.mainApp = mainApp;
|
||||||
this.configBuilderPlugin = configBuilderPlugin;
|
this.configBuilderPlugin = configBuilderPlugin;
|
||||||
|
this.commandQueue = commandQueue;
|
||||||
this.treatmentsPlugin = treatmentsPlugin;
|
this.treatmentsPlugin = treatmentsPlugin;
|
||||||
this.virtualPumpPlugin = virtualPumpPlugin;
|
this.virtualPumpPlugin = virtualPumpPlugin;
|
||||||
this.actionStringHandler = actionStringHandler;
|
this.actionStringHandler = actionStringHandler;
|
||||||
|
this.iobCobCalculatorPlugin = iobCobCalculatorPlugin;
|
||||||
|
|
||||||
loopSuspendedTill = sp.getLong("loopSuspendedTill", 0L);
|
loopSuspendedTill = sp.getLong("loopSuspendedTill", 0L);
|
||||||
isSuperBolus = sp.getBoolean("isSuperBolus", false);
|
isSuperBolus = sp.getBoolean("isSuperBolus", false);
|
||||||
|
@ -143,7 +152,7 @@ public class LoopPlugin extends PluginBase {
|
||||||
protected void onStart() {
|
protected void onStart() {
|
||||||
createNotificationChannel();
|
createNotificationChannel();
|
||||||
super.onStart();
|
super.onStart();
|
||||||
disposable.add(getRxBus()
|
disposable.add(rxBus
|
||||||
.toObservable(EventTempTargetChange.class)
|
.toObservable(EventTempTargetChange.class)
|
||||||
.observeOn(Schedulers.io())
|
.observeOn(Schedulers.io())
|
||||||
.subscribe(event -> invoke("EventTempTargetChange", true), exception -> FabricPrivacy.getInstance().logException(exception))
|
.subscribe(event -> invoke("EventTempTargetChange", true), exception -> FabricPrivacy.getInstance().logException(exception))
|
||||||
|
@ -155,14 +164,14 @@ public class LoopPlugin extends PluginBase {
|
||||||
* the event causing the calculation is not EventNewBg.
|
* the event causing the calculation is not EventNewBg.
|
||||||
* <p>
|
* <p>
|
||||||
*/
|
*/
|
||||||
disposable.add(getRxBus()
|
disposable.add(rxBus
|
||||||
.toObservable(EventAutosensCalculationFinished.class)
|
.toObservable(EventAutosensCalculationFinished.class)
|
||||||
.observeOn(Schedulers.io())
|
.observeOn(Schedulers.io())
|
||||||
.subscribe(event -> {
|
.subscribe(event -> {
|
||||||
// Autosens calculation not triggered by a new BG
|
// Autosens calculation not triggered by a new BG
|
||||||
if (!(event.getCause() instanceof EventNewBG)) return;
|
if (!(event.getCause() instanceof EventNewBG)) return;
|
||||||
|
|
||||||
BgReading bgReading = DatabaseHelper.actualBg();
|
BgReading bgReading = iobCobCalculatorPlugin.actualBg();
|
||||||
// BG outdated
|
// BG outdated
|
||||||
if (bgReading == null) return;
|
if (bgReading == null) return;
|
||||||
// already looped with that value
|
// already looped with that value
|
||||||
|
@ -194,7 +203,7 @@ public class LoopPlugin extends PluginBase {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean specialEnableCondition() {
|
public boolean specialEnableCondition() {
|
||||||
PumpInterface pump = configBuilderPlugin.getActivePump();
|
PumpInterface pump = configBuilderPlugin.getActivePumpPlugin();
|
||||||
return pump == null || pump.getPumpDescription().isTempBasalCapable;
|
return pump == null || pump.getPumpDescription().isTempBasalCapable;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -297,10 +306,10 @@ public class LoopPlugin extends PluginBase {
|
||||||
if (!loopEnabled.value()) {
|
if (!loopEnabled.value()) {
|
||||||
String message = resourceHelper.gs(R.string.loopdisabled) + "\n" + loopEnabled.getReasons();
|
String message = resourceHelper.gs(R.string.loopdisabled) + "\n" + loopEnabled.getReasons();
|
||||||
getAapsLogger().debug(LTag.APS, message);
|
getAapsLogger().debug(LTag.APS, message);
|
||||||
getRxBus().send(new EventLoopSetLastRunGui(message));
|
rxBus.send(new EventLoopSetLastRunGui(message));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
final PumpInterface pump = configBuilderPlugin.getActivePump();
|
final PumpInterface pump = configBuilderPlugin.getActivePumpPlugin();
|
||||||
if (pump == null)
|
if (pump == null)
|
||||||
return;
|
return;
|
||||||
APSResult result = null;
|
APSResult result = null;
|
||||||
|
@ -313,7 +322,7 @@ public class LoopPlugin extends PluginBase {
|
||||||
if (profile == null || !profileFunction.isProfileValid("Loop")) {
|
if (profile == null || !profileFunction.isProfileValid("Loop")) {
|
||||||
if (L.isEnabled(L.APS))
|
if (L.isEnabled(L.APS))
|
||||||
getAapsLogger().debug(LTag.APS, resourceHelper.gs(R.string.noprofileselected));
|
getAapsLogger().debug(LTag.APS, resourceHelper.gs(R.string.noprofileselected));
|
||||||
getRxBus().send(new EventLoopSetLastRunGui(resourceHelper.gs(R.string.noprofileselected)));
|
rxBus.send(new EventLoopSetLastRunGui(resourceHelper.gs(R.string.noprofileselected)));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -328,7 +337,7 @@ public class LoopPlugin extends PluginBase {
|
||||||
|
|
||||||
// Check if we have any result
|
// Check if we have any result
|
||||||
if (result == null) {
|
if (result == null) {
|
||||||
getRxBus().send(new EventLoopSetLastRunGui(resourceHelper.gs(R.string.noapsselected)));
|
rxBus.send(new EventLoopSetLastRunGui(resourceHelper.gs(R.string.noapsselected)));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -368,13 +377,13 @@ public class LoopPlugin extends PluginBase {
|
||||||
|
|
||||||
if (isSuspended()) {
|
if (isSuspended()) {
|
||||||
getAapsLogger().debug(LTag.APS, resourceHelper.gs(R.string.loopsuspended));
|
getAapsLogger().debug(LTag.APS, resourceHelper.gs(R.string.loopsuspended));
|
||||||
getRxBus().send(new EventLoopSetLastRunGui(resourceHelper.gs(R.string.loopsuspended)));
|
rxBus.send(new EventLoopSetLastRunGui(resourceHelper.gs(R.string.loopsuspended)));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pump.isSuspended()) {
|
if (pump.isSuspended()) {
|
||||||
getAapsLogger().debug(LTag.APS, resourceHelper.gs(R.string.pumpsuspended));
|
getAapsLogger().debug(LTag.APS, resourceHelper.gs(R.string.pumpsuspended));
|
||||||
getRxBus().send(new EventLoopSetLastRunGui(resourceHelper.gs(R.string.pumpsuspended)));
|
rxBus.send(new EventLoopSetLastRunGui(resourceHelper.gs(R.string.pumpsuspended)));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -382,15 +391,15 @@ public class LoopPlugin extends PluginBase {
|
||||||
|
|
||||||
if (closedLoopEnabled.value()) {
|
if (closedLoopEnabled.value()) {
|
||||||
if (resultAfterConstraints.isChangeRequested()
|
if (resultAfterConstraints.isChangeRequested()
|
||||||
&& !configBuilderPlugin.getCommandQueue().bolusInQueue()
|
&& !commandQueue.bolusInQueue()
|
||||||
&& !configBuilderPlugin.getCommandQueue().isRunning(Command.CommandType.BOLUS)) {
|
&& !commandQueue.isRunning(Command.CommandType.BOLUS)) {
|
||||||
final PumpEnactResult waiting = new PumpEnactResult();
|
final PumpEnactResult waiting = new PumpEnactResult();
|
||||||
waiting.queued = true;
|
waiting.queued = true;
|
||||||
if (resultAfterConstraints.tempBasalRequested)
|
if (resultAfterConstraints.tempBasalRequested)
|
||||||
lastRun.tbrSetByPump = waiting;
|
lastRun.tbrSetByPump = waiting;
|
||||||
if (resultAfterConstraints.bolusRequested)
|
if (resultAfterConstraints.bolusRequested)
|
||||||
lastRun.smbSetByPump = waiting;
|
lastRun.smbSetByPump = waiting;
|
||||||
getRxBus().send(new EventLoopUpdateGui());
|
rxBus.send(new EventLoopUpdateGui());
|
||||||
FabricPrivacy.getInstance().logCustom("APSRequest");
|
FabricPrivacy.getInstance().logCustom("APSRequest");
|
||||||
applyTBRRequest(resultAfterConstraints, profile, new Callback() {
|
applyTBRRequest(resultAfterConstraints, profile, new Callback() {
|
||||||
@Override
|
@Override
|
||||||
|
@ -411,11 +420,11 @@ public class LoopPlugin extends PluginBase {
|
||||||
invoke("tempBasalFallback", allowNotification, true);
|
invoke("tempBasalFallback", allowNotification, true);
|
||||||
}).start();
|
}).start();
|
||||||
}
|
}
|
||||||
getRxBus().send(new EventLoopUpdateGui());
|
rxBus.send(new EventLoopUpdateGui());
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
getRxBus().send(new EventLoopUpdateGui());
|
rxBus.send(new EventLoopUpdateGui());
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
|
@ -456,7 +465,7 @@ public class LoopPlugin extends PluginBase {
|
||||||
(NotificationManager) mainApp.getSystemService(Context.NOTIFICATION_SERVICE);
|
(NotificationManager) mainApp.getSystemService(Context.NOTIFICATION_SERVICE);
|
||||||
// mId allows you to update the notification later on.
|
// mId allows you to update the notification later on.
|
||||||
mNotificationManager.notify(Constants.notificationID, builder.build());
|
mNotificationManager.notify(Constants.notificationID, builder.build());
|
||||||
getRxBus().send(new EventNewOpenLoopNotification());
|
rxBus.send(new EventNewOpenLoopNotification());
|
||||||
|
|
||||||
// Send to Wear
|
// Send to Wear
|
||||||
actionStringHandler.get().handleInitiate("changeRequest");
|
actionStringHandler.get().handleInitiate("changeRequest");
|
||||||
|
@ -469,7 +478,7 @@ public class LoopPlugin extends PluginBase {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
getRxBus().send(new EventLoopUpdateGui());
|
rxBus.send(new EventLoopUpdateGui());
|
||||||
} finally {
|
} finally {
|
||||||
getAapsLogger().debug(LTag.APS, "invoke end");
|
getAapsLogger().debug(LTag.APS, "invoke end");
|
||||||
}
|
}
|
||||||
|
@ -488,7 +497,7 @@ public class LoopPlugin extends PluginBase {
|
||||||
NSUpload.uploadDeviceStatus(lp);
|
NSUpload.uploadDeviceStatus(lp);
|
||||||
sp.incInt(R.string.key_ObjectivesmanualEnacts);
|
sp.incInt(R.string.key_ObjectivesmanualEnacts);
|
||||||
}
|
}
|
||||||
getRxBus().send(new EventAcceptOpenLoopChange());
|
rxBus.send(new EventAcceptOpenLoopChange());
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
FabricPrivacy.getInstance().logCustom("AcceptTemp");
|
FabricPrivacy.getInstance().logCustom("AcceptTemp");
|
||||||
|
@ -509,7 +518,7 @@ public class LoopPlugin extends PluginBase {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
PumpInterface pump = configBuilderPlugin.getActivePump();
|
PumpInterface pump = configBuilderPlugin.getActivePumpPlugin();
|
||||||
if (pump == null) {
|
if (pump == null) {
|
||||||
if (callback != null)
|
if (callback != null)
|
||||||
callback.result(new PumpEnactResult().enacted(false).success(false).comment(resourceHelper.gs(R.string.nopumpselected))).run();
|
callback.result(new PumpEnactResult().enacted(false).success(false).comment(resourceHelper.gs(R.string.nopumpselected))).run();
|
||||||
|
@ -540,7 +549,7 @@ public class LoopPlugin extends PluginBase {
|
||||||
if (request.percent == 100 && request.duration == 0) {
|
if (request.percent == 100 && request.duration == 0) {
|
||||||
if (activeTemp != null) {
|
if (activeTemp != null) {
|
||||||
getAapsLogger().debug(LTag.APS, "applyAPSRequest: cancelTempBasal()");
|
getAapsLogger().debug(LTag.APS, "applyAPSRequest: cancelTempBasal()");
|
||||||
configBuilderPlugin.getCommandQueue().cancelTempBasal(false, callback);
|
commandQueue.cancelTempBasal(false, callback);
|
||||||
} else {
|
} else {
|
||||||
getAapsLogger().debug(LTag.APS, "applyAPSRequest: Basal set correctly");
|
getAapsLogger().debug(LTag.APS, "applyAPSRequest: Basal set correctly");
|
||||||
if (callback != null) {
|
if (callback != null) {
|
||||||
|
@ -560,13 +569,13 @@ public class LoopPlugin extends PluginBase {
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
getAapsLogger().debug(LTag.APS, "applyAPSRequest: tempBasalPercent()");
|
getAapsLogger().debug(LTag.APS, "applyAPSRequest: tempBasalPercent()");
|
||||||
configBuilderPlugin.getCommandQueue().tempBasalPercent(request.percent, request.duration, false, profile, callback);
|
commandQueue.tempBasalPercent(request.percent, request.duration, false, profile, callback);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if ((request.rate == 0 && request.duration == 0) || Math.abs(request.rate - pump.getBaseBasalRate()) < pump.getPumpDescription().basalStep) {
|
if ((request.rate == 0 && request.duration == 0) || Math.abs(request.rate - pump.getBaseBasalRate()) < pump.getPumpDescription().basalStep) {
|
||||||
if (activeTemp != null) {
|
if (activeTemp != null) {
|
||||||
getAapsLogger().debug(LTag.APS, "applyAPSRequest: cancelTempBasal()");
|
getAapsLogger().debug(LTag.APS, "applyAPSRequest: cancelTempBasal()");
|
||||||
configBuilderPlugin.getCommandQueue().cancelTempBasal(false, callback);
|
commandQueue.cancelTempBasal(false, callback);
|
||||||
} else {
|
} else {
|
||||||
getAapsLogger().debug(LTag.APS, "applyAPSRequest: Basal set correctly");
|
getAapsLogger().debug(LTag.APS, "applyAPSRequest: Basal set correctly");
|
||||||
if (callback != null) {
|
if (callback != null) {
|
||||||
|
@ -586,7 +595,7 @@ public class LoopPlugin extends PluginBase {
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
getAapsLogger().debug(LTag.APS, "applyAPSRequest: setTempBasalAbsolute()");
|
getAapsLogger().debug(LTag.APS, "applyAPSRequest: setTempBasalAbsolute()");
|
||||||
configBuilderPlugin.getCommandQueue().tempBasalAbsolute(request.rate, request.duration, false, profile, callback);
|
commandQueue.tempBasalAbsolute(request.rate, request.duration, false, profile, callback);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -596,7 +605,7 @@ public class LoopPlugin extends PluginBase {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
PumpInterface pump = configBuilderPlugin.getActivePump();
|
PumpInterface pump = configBuilderPlugin.getActivePumpPlugin();
|
||||||
if (pump == null) {
|
if (pump == null) {
|
||||||
if (callback != null)
|
if (callback != null)
|
||||||
callback.result(new PumpEnactResult().enacted(false).success(false).comment(resourceHelper.gs(R.string.nopumpselected))).run();
|
callback.result(new PumpEnactResult().enacted(false).success(false).comment(resourceHelper.gs(R.string.nopumpselected))).run();
|
||||||
|
@ -641,18 +650,18 @@ public class LoopPlugin extends PluginBase {
|
||||||
detailedBolusInfo.source = Source.USER;
|
detailedBolusInfo.source = Source.USER;
|
||||||
detailedBolusInfo.deliverAt = request.deliverAt;
|
detailedBolusInfo.deliverAt = request.deliverAt;
|
||||||
getAapsLogger().debug(LTag.APS, "applyAPSRequest: bolus()");
|
getAapsLogger().debug(LTag.APS, "applyAPSRequest: bolus()");
|
||||||
configBuilderPlugin.getCommandQueue().bolus(detailedBolusInfo, callback);
|
commandQueue.bolus(detailedBolusInfo, callback);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void disconnectPump(int durationInMinutes, Profile profile) {
|
public void disconnectPump(int durationInMinutes, Profile profile) {
|
||||||
PumpInterface pump = configBuilderPlugin.getActivePump();
|
PumpInterface pump = configBuilderPlugin.getActivePumpPlugin();
|
||||||
if (pump == null)
|
if (pump == null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
disconnectTo(System.currentTimeMillis() + durationInMinutes * 60 * 1000L);
|
disconnectTo(System.currentTimeMillis() + durationInMinutes * 60 * 1000L);
|
||||||
|
|
||||||
if (pump.getPumpDescription().tempBasalStyle == PumpDescription.ABSOLUTE) {
|
if (pump.getPumpDescription().tempBasalStyle == PumpDescription.ABSOLUTE) {
|
||||||
configBuilderPlugin.getCommandQueue().tempBasalAbsolute(0, durationInMinutes, true, profile, new Callback() {
|
commandQueue.tempBasalAbsolute(0, durationInMinutes, true, profile, new Callback() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
if (!result.success) {
|
if (!result.success) {
|
||||||
|
@ -666,7 +675,7 @@ public class LoopPlugin extends PluginBase {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
configBuilderPlugin.getCommandQueue().tempBasalPercent(0, durationInMinutes, true, profile, new Callback() {
|
commandQueue.tempBasalPercent(0, durationInMinutes, true, profile, new Callback() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
if (!result.success) {
|
if (!result.success) {
|
||||||
|
@ -682,7 +691,7 @@ public class LoopPlugin extends PluginBase {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pump.getPumpDescription().isExtendedBolusCapable && treatmentsPlugin.isInHistoryExtendedBoluslInProgress()) {
|
if (pump.getPumpDescription().isExtendedBolusCapable && treatmentsPlugin.isInHistoryExtendedBoluslInProgress()) {
|
||||||
configBuilderPlugin.getCommandQueue().cancelExtended(new Callback() {
|
commandQueue.cancelExtended(new Callback() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
if (!result.success) {
|
if (!result.success) {
|
||||||
|
@ -701,7 +710,7 @@ public class LoopPlugin extends PluginBase {
|
||||||
|
|
||||||
public void suspendLoop(int durationInMinutes) {
|
public void suspendLoop(int durationInMinutes) {
|
||||||
suspendTo(System.currentTimeMillis() + durationInMinutes * 60 * 1000);
|
suspendTo(System.currentTimeMillis() + durationInMinutes * 60 * 1000);
|
||||||
configBuilderPlugin.getCommandQueue().cancelTempBasal(true, new Callback() {
|
commandQueue.cancelTempBasal(true, new Callback() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
if (!result.success) {
|
if (!result.success) {
|
||||||
|
|
|
@ -12,6 +12,7 @@ import info.nightscout.androidaps.data.MealData;
|
||||||
import info.nightscout.androidaps.data.Profile;
|
import info.nightscout.androidaps.data.Profile;
|
||||||
import info.nightscout.androidaps.db.TempTarget;
|
import info.nightscout.androidaps.db.TempTarget;
|
||||||
import info.nightscout.androidaps.interfaces.APSInterface;
|
import info.nightscout.androidaps.interfaces.APSInterface;
|
||||||
|
import info.nightscout.androidaps.interfaces.ActivePluginProvider;
|
||||||
import info.nightscout.androidaps.interfaces.PluginBase;
|
import info.nightscout.androidaps.interfaces.PluginBase;
|
||||||
import info.nightscout.androidaps.interfaces.PluginDescription;
|
import info.nightscout.androidaps.interfaces.PluginDescription;
|
||||||
import info.nightscout.androidaps.interfaces.PluginType;
|
import info.nightscout.androidaps.interfaces.PluginType;
|
||||||
|
@ -23,7 +24,6 @@ import info.nightscout.androidaps.plugins.aps.loop.ScriptReader;
|
||||||
import info.nightscout.androidaps.plugins.aps.openAPSMA.events.EventOpenAPSUpdateGui;
|
import info.nightscout.androidaps.plugins.aps.openAPSMA.events.EventOpenAPSUpdateGui;
|
||||||
import info.nightscout.androidaps.plugins.aps.openAPSMA.events.EventOpenAPSUpdateResultGui;
|
import info.nightscout.androidaps.plugins.aps.openAPSMA.events.EventOpenAPSUpdateResultGui;
|
||||||
import info.nightscout.androidaps.plugins.bus.RxBusWrapper;
|
import info.nightscout.androidaps.plugins.bus.RxBusWrapper;
|
||||||
import info.nightscout.androidaps.plugins.configBuilder.ConfigBuilderPlugin;
|
|
||||||
import info.nightscout.androidaps.plugins.configBuilder.ConstraintChecker;
|
import info.nightscout.androidaps.plugins.configBuilder.ConstraintChecker;
|
||||||
import info.nightscout.androidaps.plugins.configBuilder.ProfileFunction;
|
import info.nightscout.androidaps.plugins.configBuilder.ProfileFunction;
|
||||||
import info.nightscout.androidaps.plugins.iob.iobCobCalculator.AutosensData;
|
import info.nightscout.androidaps.plugins.iob.iobCobCalculator.AutosensData;
|
||||||
|
@ -46,7 +46,7 @@ public class OpenAPSAMAPlugin extends PluginBase implements APSInterface {
|
||||||
private final ResourceHelper resourceHelper;
|
private final ResourceHelper resourceHelper;
|
||||||
private final ProfileFunction profileFunction;
|
private final ProfileFunction profileFunction;
|
||||||
private final MainApp mainApp;
|
private final MainApp mainApp;
|
||||||
private final ConfigBuilderPlugin configBuilderPlugin;
|
private final ActivePluginProvider activePlugin;
|
||||||
private final TreatmentsPlugin treatmentsPlugin;
|
private final TreatmentsPlugin treatmentsPlugin;
|
||||||
private final IobCobCalculatorPlugin iobCobCalculatorPlugin;
|
private final IobCobCalculatorPlugin iobCobCalculatorPlugin;
|
||||||
|
|
||||||
|
@ -64,7 +64,7 @@ public class OpenAPSAMAPlugin extends PluginBase implements APSInterface {
|
||||||
ResourceHelper resourceHelper,
|
ResourceHelper resourceHelper,
|
||||||
ProfileFunction profileFunction,
|
ProfileFunction profileFunction,
|
||||||
MainApp mainApp,
|
MainApp mainApp,
|
||||||
ConfigBuilderPlugin configBuilderPlugin,
|
ActivePluginProvider activePlugin,
|
||||||
TreatmentsPlugin treatmentsPlugin,
|
TreatmentsPlugin treatmentsPlugin,
|
||||||
IobCobCalculatorPlugin iobCobCalculatorPlugin
|
IobCobCalculatorPlugin iobCobCalculatorPlugin
|
||||||
) {
|
) {
|
||||||
|
@ -75,7 +75,7 @@ public class OpenAPSAMAPlugin extends PluginBase implements APSInterface {
|
||||||
.shortName(R.string.oaps_shortname)
|
.shortName(R.string.oaps_shortname)
|
||||||
.preferencesId(R.xml.pref_openapsama)
|
.preferencesId(R.xml.pref_openapsama)
|
||||||
.description(R.string.description_ama),
|
.description(R.string.description_ama),
|
||||||
rxBus, aapsLogger
|
aapsLogger, resourceHelper
|
||||||
);
|
);
|
||||||
this.aapsLogger = aapsLogger;
|
this.aapsLogger = aapsLogger;
|
||||||
this.rxBus = rxBus;
|
this.rxBus = rxBus;
|
||||||
|
@ -83,20 +83,24 @@ public class OpenAPSAMAPlugin extends PluginBase implements APSInterface {
|
||||||
this.resourceHelper = resourceHelper;
|
this.resourceHelper = resourceHelper;
|
||||||
this.profileFunction = profileFunction;
|
this.profileFunction = profileFunction;
|
||||||
this.mainApp = mainApp;
|
this.mainApp = mainApp;
|
||||||
this.configBuilderPlugin = configBuilderPlugin;
|
this.activePlugin = activePlugin;
|
||||||
this.treatmentsPlugin = treatmentsPlugin;
|
this.treatmentsPlugin = treatmentsPlugin;
|
||||||
this.iobCobCalculatorPlugin = iobCobCalculatorPlugin;
|
this.iobCobCalculatorPlugin = iobCobCalculatorPlugin;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean specialEnableCondition() {
|
public boolean specialEnableCondition() {
|
||||||
PumpInterface pump = configBuilderPlugin.getActivePump();
|
// main fail during init
|
||||||
|
if (activePlugin != null) {
|
||||||
|
PumpInterface pump = activePlugin.getActivePumpPlugin();
|
||||||
return pump == null || pump.getPumpDescription().isTempBasalCapable;
|
return pump == null || pump.getPumpDescription().isTempBasalCapable;
|
||||||
}
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean specialShowInListCondition() {
|
public boolean specialShowInListCondition() {
|
||||||
PumpInterface pump = configBuilderPlugin.getActivePump();
|
PumpInterface pump = activePlugin.getActivePumpPlugin();
|
||||||
return pump == null || pump.getPumpDescription().isTempBasalCapable;
|
return pump == null || pump.getPumpDescription().isTempBasalCapable;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -119,7 +123,7 @@ public class OpenAPSAMAPlugin extends PluginBase implements APSInterface {
|
||||||
|
|
||||||
GlucoseStatus glucoseStatus = GlucoseStatus.getGlucoseStatusData();
|
GlucoseStatus glucoseStatus = GlucoseStatus.getGlucoseStatusData();
|
||||||
Profile profile = profileFunction.getProfile();
|
Profile profile = profileFunction.getProfile();
|
||||||
PumpInterface pump = configBuilderPlugin.getActivePump();
|
PumpInterface pump = activePlugin.getActivePump();
|
||||||
|
|
||||||
if (profile == null) {
|
if (profile == null) {
|
||||||
rxBus.send(new EventOpenAPSUpdateResultGui(resourceHelper.gs(R.string.noprofileselected)));
|
rxBus.send(new EventOpenAPSUpdateResultGui(resourceHelper.gs(R.string.noprofileselected)));
|
||||||
|
@ -207,7 +211,7 @@ public class OpenAPSAMAPlugin extends PluginBase implements APSInterface {
|
||||||
start = System.currentTimeMillis();
|
start = System.currentTimeMillis();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
determineBasalAdapterAMAJS.setData(profile, maxIob, maxBasal, minBg, maxBg, targetBg, configBuilderPlugin.getActivePump().getBaseBasalRate(), iobArray, glucoseStatus, mealData,
|
determineBasalAdapterAMAJS.setData(profile, maxIob, maxBasal, minBg, maxBg, targetBg, activePlugin.getActivePump().getBaseBasalRate(), iobArray, glucoseStatus, mealData,
|
||||||
lastAutosensResult.ratio, //autosensDataRatio
|
lastAutosensResult.ratio, //autosensDataRatio
|
||||||
isTempTarget
|
isTempTarget
|
||||||
);
|
);
|
||||||
|
|
|
@ -12,6 +12,7 @@ import info.nightscout.androidaps.data.MealData;
|
||||||
import info.nightscout.androidaps.data.Profile;
|
import info.nightscout.androidaps.data.Profile;
|
||||||
import info.nightscout.androidaps.db.TempTarget;
|
import info.nightscout.androidaps.db.TempTarget;
|
||||||
import info.nightscout.androidaps.interfaces.APSInterface;
|
import info.nightscout.androidaps.interfaces.APSInterface;
|
||||||
|
import info.nightscout.androidaps.interfaces.ActivePluginProvider;
|
||||||
import info.nightscout.androidaps.interfaces.PluginBase;
|
import info.nightscout.androidaps.interfaces.PluginBase;
|
||||||
import info.nightscout.androidaps.interfaces.PluginDescription;
|
import info.nightscout.androidaps.interfaces.PluginDescription;
|
||||||
import info.nightscout.androidaps.interfaces.PluginType;
|
import info.nightscout.androidaps.interfaces.PluginType;
|
||||||
|
@ -23,7 +24,6 @@ import info.nightscout.androidaps.plugins.aps.loop.ScriptReader;
|
||||||
import info.nightscout.androidaps.plugins.aps.openAPSMA.events.EventOpenAPSUpdateGui;
|
import info.nightscout.androidaps.plugins.aps.openAPSMA.events.EventOpenAPSUpdateGui;
|
||||||
import info.nightscout.androidaps.plugins.aps.openAPSMA.events.EventOpenAPSUpdateResultGui;
|
import info.nightscout.androidaps.plugins.aps.openAPSMA.events.EventOpenAPSUpdateResultGui;
|
||||||
import info.nightscout.androidaps.plugins.bus.RxBusWrapper;
|
import info.nightscout.androidaps.plugins.bus.RxBusWrapper;
|
||||||
import info.nightscout.androidaps.plugins.configBuilder.ConfigBuilderPlugin;
|
|
||||||
import info.nightscout.androidaps.plugins.configBuilder.ConstraintChecker;
|
import info.nightscout.androidaps.plugins.configBuilder.ConstraintChecker;
|
||||||
import info.nightscout.androidaps.plugins.configBuilder.ProfileFunction;
|
import info.nightscout.androidaps.plugins.configBuilder.ProfileFunction;
|
||||||
import info.nightscout.androidaps.plugins.iob.iobCobCalculator.GlucoseStatus;
|
import info.nightscout.androidaps.plugins.iob.iobCobCalculator.GlucoseStatus;
|
||||||
|
@ -41,11 +41,12 @@ import static info.nightscout.androidaps.utils.HardLimits.verifyHardLimits;
|
||||||
|
|
||||||
@Singleton
|
@Singleton
|
||||||
public class OpenAPSMAPlugin extends PluginBase implements APSInterface {
|
public class OpenAPSMAPlugin extends PluginBase implements APSInterface {
|
||||||
|
private final RxBusWrapper rxBus;
|
||||||
private final ConstraintChecker constraintChecker;
|
private final ConstraintChecker constraintChecker;
|
||||||
private final ResourceHelper resourceHelper;
|
private final ResourceHelper resourceHelper;
|
||||||
private final ProfileFunction profileFunction;
|
private final ProfileFunction profileFunction;
|
||||||
private final MainApp mainApp;
|
private final MainApp mainApp;
|
||||||
private final ConfigBuilderPlugin configBuilderPlugin;
|
private final ActivePluginProvider activePlugin;
|
||||||
private final TreatmentsPlugin treatmentsPlugin;
|
private final TreatmentsPlugin treatmentsPlugin;
|
||||||
private final IobCobCalculatorPlugin iobCobCalculatorPlugin;
|
private final IobCobCalculatorPlugin iobCobCalculatorPlugin;
|
||||||
|
|
||||||
|
@ -57,12 +58,12 @@ public class OpenAPSMAPlugin extends PluginBase implements APSInterface {
|
||||||
@Inject
|
@Inject
|
||||||
public OpenAPSMAPlugin(
|
public OpenAPSMAPlugin(
|
||||||
AAPSLogger aapsLogger,
|
AAPSLogger aapsLogger,
|
||||||
RxBusWrapper rxBusWrapper,
|
RxBusWrapper rxBus,
|
||||||
ConstraintChecker constraintChecker,
|
ConstraintChecker constraintChecker,
|
||||||
ResourceHelper resourceHelper,
|
ResourceHelper resourceHelper,
|
||||||
ProfileFunction profileFunction,
|
ProfileFunction profileFunction,
|
||||||
MainApp mainApp,
|
MainApp mainApp,
|
||||||
ConfigBuilderPlugin configBuilderPlugin,
|
ActivePluginProvider activePlugin,
|
||||||
TreatmentsPlugin treatmentsPlugin,
|
TreatmentsPlugin treatmentsPlugin,
|
||||||
IobCobCalculatorPlugin iobCobCalculatorPlugin
|
IobCobCalculatorPlugin iobCobCalculatorPlugin
|
||||||
) {
|
) {
|
||||||
|
@ -73,27 +74,32 @@ public class OpenAPSMAPlugin extends PluginBase implements APSInterface {
|
||||||
.shortName(R.string.oaps_shortname)
|
.shortName(R.string.oaps_shortname)
|
||||||
.preferencesId(R.xml.pref_openapsma)
|
.preferencesId(R.xml.pref_openapsma)
|
||||||
.description(R.string.description_ma),
|
.description(R.string.description_ma),
|
||||||
rxBusWrapper, aapsLogger
|
aapsLogger, resourceHelper
|
||||||
);
|
);
|
||||||
|
|
||||||
this.constraintChecker = constraintChecker;
|
this.constraintChecker = constraintChecker;
|
||||||
this.resourceHelper = resourceHelper;
|
this.resourceHelper = resourceHelper;
|
||||||
this.profileFunction = profileFunction;
|
this.profileFunction = profileFunction;
|
||||||
this.mainApp = mainApp;
|
this.mainApp = mainApp;
|
||||||
this.configBuilderPlugin = configBuilderPlugin;
|
this.rxBus = rxBus;
|
||||||
|
this.activePlugin = activePlugin;
|
||||||
this.treatmentsPlugin = treatmentsPlugin;
|
this.treatmentsPlugin = treatmentsPlugin;
|
||||||
this.iobCobCalculatorPlugin = iobCobCalculatorPlugin;
|
this.iobCobCalculatorPlugin = iobCobCalculatorPlugin;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean specialEnableCondition() {
|
public boolean specialEnableCondition() {
|
||||||
PumpInterface pump = configBuilderPlugin.getActivePump();
|
// main fail during init
|
||||||
|
if (activePlugin != null) {
|
||||||
|
PumpInterface pump = activePlugin.getActivePumpPlugin();
|
||||||
return pump == null || pump.getPumpDescription().isTempBasalCapable;
|
return pump == null || pump.getPumpDescription().isTempBasalCapable;
|
||||||
}
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean specialShowInListCondition() {
|
public boolean specialShowInListCondition() {
|
||||||
PumpInterface pump = configBuilderPlugin.getActivePump();
|
PumpInterface pump = activePlugin.getActivePumpPlugin();
|
||||||
return pump == null || pump.getPumpDescription().isTempBasalCapable;
|
return pump == null || pump.getPumpDescription().isTempBasalCapable;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -116,28 +122,28 @@ public class OpenAPSMAPlugin extends PluginBase implements APSInterface {
|
||||||
|
|
||||||
GlucoseStatus glucoseStatus = GlucoseStatus.getGlucoseStatusData();
|
GlucoseStatus glucoseStatus = GlucoseStatus.getGlucoseStatusData();
|
||||||
Profile profile = profileFunction.getProfile();
|
Profile profile = profileFunction.getProfile();
|
||||||
PumpInterface pump = configBuilderPlugin.getActivePump();
|
PumpInterface pump = activePlugin.getActivePumpPlugin();
|
||||||
|
|
||||||
if (profile == null) {
|
if (profile == null) {
|
||||||
getRxBus().send(new EventOpenAPSUpdateResultGui(resourceHelper.gs(R.string.noprofileselected)));
|
rxBus.send(new EventOpenAPSUpdateResultGui(resourceHelper.gs(R.string.noprofileselected)));
|
||||||
getAapsLogger().debug(LTag.APS, resourceHelper.gs(R.string.noprofileselected));
|
getAapsLogger().debug(LTag.APS, resourceHelper.gs(R.string.noprofileselected));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pump == null) {
|
if (pump == null) {
|
||||||
getRxBus().send(new EventOpenAPSUpdateResultGui(resourceHelper.gs(R.string.nopumpselected)));
|
rxBus.send(new EventOpenAPSUpdateResultGui(resourceHelper.gs(R.string.nopumpselected)));
|
||||||
getAapsLogger().debug(LTag.APS, resourceHelper.gs(R.string.nopumpselected));
|
getAapsLogger().debug(LTag.APS, resourceHelper.gs(R.string.nopumpselected));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!isEnabled(PluginType.APS)) {
|
if (!isEnabled(PluginType.APS)) {
|
||||||
getRxBus().send(new EventOpenAPSUpdateResultGui(resourceHelper.gs(R.string.openapsma_disabled)));
|
rxBus.send(new EventOpenAPSUpdateResultGui(resourceHelper.gs(R.string.openapsma_disabled)));
|
||||||
getAapsLogger().debug(LTag.APS, resourceHelper.gs(R.string.openapsma_disabled));
|
getAapsLogger().debug(LTag.APS, resourceHelper.gs(R.string.openapsma_disabled));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (glucoseStatus == null) {
|
if (glucoseStatus == null) {
|
||||||
getRxBus().send(new EventOpenAPSUpdateResultGui(resourceHelper.gs(R.string.openapsma_noglucosedata)));
|
rxBus.send(new EventOpenAPSUpdateResultGui(resourceHelper.gs(R.string.openapsma_noglucosedata)));
|
||||||
getAapsLogger().debug(LTag.APS, resourceHelper.gs(R.string.openapsma_noglucosedata));
|
getAapsLogger().debug(LTag.APS, resourceHelper.gs(R.string.openapsma_noglucosedata));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -188,7 +194,7 @@ public class OpenAPSMAPlugin extends PluginBase implements APSInterface {
|
||||||
|
|
||||||
start = System.currentTimeMillis();
|
start = System.currentTimeMillis();
|
||||||
try {
|
try {
|
||||||
determineBasalAdapterMAJS.setData(profile, maxIob, maxBasal, minBg, maxBg, targetBg, configBuilderPlugin.getActivePump().getBaseBasalRate(), iobTotal, glucoseStatus, mealData);
|
determineBasalAdapterMAJS.setData(profile, maxIob, maxBasal, minBg, maxBg, targetBg, activePlugin.getActivePump().getBaseBasalRate(), iobTotal, glucoseStatus, mealData);
|
||||||
} catch (JSONException e) {
|
} catch (JSONException e) {
|
||||||
FabricPrivacy.getInstance().logException(e);
|
FabricPrivacy.getInstance().logException(e);
|
||||||
return;
|
return;
|
||||||
|
@ -221,7 +227,7 @@ public class OpenAPSMAPlugin extends PluginBase implements APSInterface {
|
||||||
lastAPSResult = determineBasalResultMA;
|
lastAPSResult = determineBasalResultMA;
|
||||||
lastAPSRun = now;
|
lastAPSRun = now;
|
||||||
}
|
}
|
||||||
getRxBus().send(new EventOpenAPSUpdateGui());
|
rxBus.send(new EventOpenAPSUpdateGui());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -13,6 +13,7 @@ import info.nightscout.androidaps.data.MealData;
|
||||||
import info.nightscout.androidaps.data.Profile;
|
import info.nightscout.androidaps.data.Profile;
|
||||||
import info.nightscout.androidaps.db.TempTarget;
|
import info.nightscout.androidaps.db.TempTarget;
|
||||||
import info.nightscout.androidaps.interfaces.APSInterface;
|
import info.nightscout.androidaps.interfaces.APSInterface;
|
||||||
|
import info.nightscout.androidaps.interfaces.ActivePluginProvider;
|
||||||
import info.nightscout.androidaps.interfaces.Constraint;
|
import info.nightscout.androidaps.interfaces.Constraint;
|
||||||
import info.nightscout.androidaps.interfaces.ConstraintsInterface;
|
import info.nightscout.androidaps.interfaces.ConstraintsInterface;
|
||||||
import info.nightscout.androidaps.interfaces.PluginBase;
|
import info.nightscout.androidaps.interfaces.PluginBase;
|
||||||
|
@ -26,7 +27,6 @@ import info.nightscout.androidaps.plugins.aps.loop.ScriptReader;
|
||||||
import info.nightscout.androidaps.plugins.aps.openAPSMA.events.EventOpenAPSUpdateGui;
|
import info.nightscout.androidaps.plugins.aps.openAPSMA.events.EventOpenAPSUpdateGui;
|
||||||
import info.nightscout.androidaps.plugins.aps.openAPSMA.events.EventOpenAPSUpdateResultGui;
|
import info.nightscout.androidaps.plugins.aps.openAPSMA.events.EventOpenAPSUpdateResultGui;
|
||||||
import info.nightscout.androidaps.plugins.bus.RxBusWrapper;
|
import info.nightscout.androidaps.plugins.bus.RxBusWrapper;
|
||||||
import info.nightscout.androidaps.plugins.configBuilder.ConfigBuilderPlugin;
|
|
||||||
import info.nightscout.androidaps.plugins.configBuilder.ConstraintChecker;
|
import info.nightscout.androidaps.plugins.configBuilder.ConstraintChecker;
|
||||||
import info.nightscout.androidaps.plugins.configBuilder.ProfileFunction;
|
import info.nightscout.androidaps.plugins.configBuilder.ProfileFunction;
|
||||||
import info.nightscout.androidaps.plugins.general.nsclient.NSUpload;
|
import info.nightscout.androidaps.plugins.general.nsclient.NSUpload;
|
||||||
|
@ -49,7 +49,8 @@ public class OpenAPSSMBPlugin extends PluginBase implements APSInterface, Constr
|
||||||
private final ResourceHelper resourceHelper;
|
private final ResourceHelper resourceHelper;
|
||||||
private final ProfileFunction profileFunction;
|
private final ProfileFunction profileFunction;
|
||||||
private final MainApp mainApp;
|
private final MainApp mainApp;
|
||||||
private final ConfigBuilderPlugin configBuilderPlugin;
|
private final RxBusWrapper rxBus;
|
||||||
|
private final ActivePluginProvider activePlugin;
|
||||||
private final TreatmentsPlugin treatmentsPlugin;
|
private final TreatmentsPlugin treatmentsPlugin;
|
||||||
private final IobCobCalculatorPlugin iobCobCalculatorPlugin;
|
private final IobCobCalculatorPlugin iobCobCalculatorPlugin;
|
||||||
|
|
||||||
|
@ -62,12 +63,12 @@ public class OpenAPSSMBPlugin extends PluginBase implements APSInterface, Constr
|
||||||
@Inject
|
@Inject
|
||||||
public OpenAPSSMBPlugin(
|
public OpenAPSSMBPlugin(
|
||||||
AAPSLogger aapsLogger,
|
AAPSLogger aapsLogger,
|
||||||
RxBusWrapper rxBusWrapper,
|
RxBusWrapper rxBus,
|
||||||
ConstraintChecker constraintChecker,
|
ConstraintChecker constraintChecker,
|
||||||
ResourceHelper resourceHelper,
|
ResourceHelper resourceHelper,
|
||||||
ProfileFunction profileFunction,
|
ProfileFunction profileFunction,
|
||||||
MainApp mainApp,
|
MainApp mainApp,
|
||||||
ConfigBuilderPlugin configBuilderPlugin,
|
ActivePluginProvider activePlugin,
|
||||||
TreatmentsPlugin treatmentsPlugin,
|
TreatmentsPlugin treatmentsPlugin,
|
||||||
IobCobCalculatorPlugin iobCobCalculatorPlugin
|
IobCobCalculatorPlugin iobCobCalculatorPlugin
|
||||||
) {
|
) {
|
||||||
|
@ -78,27 +79,32 @@ public class OpenAPSSMBPlugin extends PluginBase implements APSInterface, Constr
|
||||||
.shortName(R.string.smb_shortname)
|
.shortName(R.string.smb_shortname)
|
||||||
.preferencesId(R.xml.pref_openapssmb)
|
.preferencesId(R.xml.pref_openapssmb)
|
||||||
.description(R.string.description_smb),
|
.description(R.string.description_smb),
|
||||||
rxBusWrapper, aapsLogger
|
aapsLogger, resourceHelper
|
||||||
);
|
);
|
||||||
|
|
||||||
this.constraintChecker = constraintChecker;
|
this.constraintChecker = constraintChecker;
|
||||||
this.resourceHelper = resourceHelper;
|
this.resourceHelper = resourceHelper;
|
||||||
this.profileFunction = profileFunction;
|
this.profileFunction = profileFunction;
|
||||||
|
this.rxBus = rxBus;
|
||||||
this.mainApp = mainApp;
|
this.mainApp = mainApp;
|
||||||
this.configBuilderPlugin = configBuilderPlugin;
|
this.activePlugin = activePlugin;
|
||||||
this.treatmentsPlugin = treatmentsPlugin;
|
this.treatmentsPlugin = treatmentsPlugin;
|
||||||
this.iobCobCalculatorPlugin = iobCobCalculatorPlugin;
|
this.iobCobCalculatorPlugin = iobCobCalculatorPlugin;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean specialEnableCondition() {
|
public boolean specialEnableCondition() {
|
||||||
PumpInterface pump = configBuilderPlugin.getActivePump();
|
// main fail during init
|
||||||
|
if (activePlugin != null) {
|
||||||
|
PumpInterface pump = activePlugin.getActivePumpPlugin();
|
||||||
return pump == null || pump.getPumpDescription().isTempBasalCapable;
|
return pump == null || pump.getPumpDescription().isTempBasalCapable;
|
||||||
}
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean specialShowInListCondition() {
|
public boolean specialShowInListCondition() {
|
||||||
PumpInterface pump = configBuilderPlugin.getActivePump();
|
PumpInterface pump = activePlugin.getActivePumpPlugin();
|
||||||
return pump == null || pump.getPumpDescription().isTempBasalCapable;
|
return pump == null || pump.getPumpDescription().isTempBasalCapable;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -121,28 +127,28 @@ public class OpenAPSSMBPlugin extends PluginBase implements APSInterface, Constr
|
||||||
|
|
||||||
GlucoseStatus glucoseStatus = GlucoseStatus.getGlucoseStatusData();
|
GlucoseStatus glucoseStatus = GlucoseStatus.getGlucoseStatusData();
|
||||||
Profile profile = profileFunction.getProfile();
|
Profile profile = profileFunction.getProfile();
|
||||||
PumpInterface pump = configBuilderPlugin.getActivePump();
|
PumpInterface pump = activePlugin.getActivePump();
|
||||||
|
|
||||||
if (profile == null) {
|
if (profile == null) {
|
||||||
getRxBus().send(new EventOpenAPSUpdateResultGui(resourceHelper.gs(R.string.noprofileselected)));
|
rxBus.send(new EventOpenAPSUpdateResultGui(resourceHelper.gs(R.string.noprofileselected)));
|
||||||
getAapsLogger().debug(LTag.APS, resourceHelper.gs(R.string.noprofileselected));
|
getAapsLogger().debug(LTag.APS, resourceHelper.gs(R.string.noprofileselected));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pump == null) {
|
if (pump == null) {
|
||||||
getRxBus().send(new EventOpenAPSUpdateResultGui(resourceHelper.gs(R.string.nopumpselected)));
|
rxBus.send(new EventOpenAPSUpdateResultGui(resourceHelper.gs(R.string.nopumpselected)));
|
||||||
getAapsLogger().debug(LTag.APS, resourceHelper.gs(R.string.nopumpselected));
|
getAapsLogger().debug(LTag.APS, resourceHelper.gs(R.string.nopumpselected));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!isEnabled(PluginType.APS)) {
|
if (!isEnabled(PluginType.APS)) {
|
||||||
getRxBus().send(new EventOpenAPSUpdateResultGui(resourceHelper.gs(R.string.openapsma_disabled)));
|
rxBus.send(new EventOpenAPSUpdateResultGui(resourceHelper.gs(R.string.openapsma_disabled)));
|
||||||
getAapsLogger().debug(LTag.APS, resourceHelper.gs(R.string.openapsma_disabled));
|
getAapsLogger().debug(LTag.APS, resourceHelper.gs(R.string.openapsma_disabled));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (glucoseStatus == null) {
|
if (glucoseStatus == null) {
|
||||||
getRxBus().send(new EventOpenAPSUpdateResultGui(resourceHelper.gs(R.string.openapsma_noglucosedata)));
|
rxBus.send(new EventOpenAPSUpdateResultGui(resourceHelper.gs(R.string.openapsma_noglucosedata)));
|
||||||
getAapsLogger().debug(LTag.APS, resourceHelper.gs(R.string.openapsma_noglucosedata));
|
getAapsLogger().debug(LTag.APS, resourceHelper.gs(R.string.openapsma_noglucosedata));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -198,7 +204,7 @@ public class OpenAPSSMBPlugin extends PluginBase implements APSInterface, Constr
|
||||||
if (constraintChecker.isAutosensModeEnabled().value()) {
|
if (constraintChecker.isAutosensModeEnabled().value()) {
|
||||||
AutosensData autosensData = iobCobCalculatorPlugin.getLastAutosensDataSynchronized("OpenAPSPlugin");
|
AutosensData autosensData = iobCobCalculatorPlugin.getLastAutosensDataSynchronized("OpenAPSPlugin");
|
||||||
if (autosensData == null) {
|
if (autosensData == null) {
|
||||||
getRxBus().send(new EventOpenAPSUpdateResultGui(resourceHelper.gs(R.string.openaps_noasdata)));
|
rxBus.send(new EventOpenAPSUpdateResultGui(resourceHelper.gs(R.string.openaps_noasdata)));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
lastAutosensResult = autosensData.autosensResult;
|
lastAutosensResult = autosensData.autosensResult;
|
||||||
|
@ -228,7 +234,7 @@ public class OpenAPSSMBPlugin extends PluginBase implements APSInterface, Constr
|
||||||
|
|
||||||
start = System.currentTimeMillis();
|
start = System.currentTimeMillis();
|
||||||
try {
|
try {
|
||||||
determineBasalAdapterSMBJS.setData(profile, maxIob, maxBasal, minBg, maxBg, targetBg, configBuilderPlugin.getActivePump().getBaseBasalRate(), iobArray, glucoseStatus, mealData,
|
determineBasalAdapterSMBJS.setData(profile, maxIob, maxBasal, minBg, maxBg, targetBg, activePlugin.getActivePump().getBaseBasalRate(), iobArray, glucoseStatus, mealData,
|
||||||
lastAutosensResult.ratio, //autosensDataRatio
|
lastAutosensResult.ratio, //autosensDataRatio
|
||||||
isTempTarget,
|
isTempTarget,
|
||||||
smbAllowed.value(),
|
smbAllowed.value(),
|
||||||
|
@ -269,7 +275,7 @@ public class OpenAPSSMBPlugin extends PluginBase implements APSInterface, Constr
|
||||||
lastAPSResult = determineBasalResultSMB;
|
lastAPSResult = determineBasalResultSMB;
|
||||||
lastAPSRun = now;
|
lastAPSRun = now;
|
||||||
}
|
}
|
||||||
getRxBus().send(new EventOpenAPSUpdateGui());
|
rxBus.send(new EventOpenAPSUpdateGui());
|
||||||
|
|
||||||
//deviceStatus.suggested = determineBasalResultAMA.json;
|
//deviceStatus.suggested = determineBasalResultAMA.json;
|
||||||
}
|
}
|
||||||
|
|
|
@ -136,10 +136,10 @@ class ConfigBuilderFragment : DaggerFragment() {
|
||||||
}
|
}
|
||||||
|
|
||||||
enabledExclusive.setOnClickListener {
|
enabledExclusive.setOnClickListener {
|
||||||
plugin.switchAllowed(if (enabledExclusive.visibility == View.VISIBLE) enabledExclusive.isChecked else enabledInclusive.isChecked, fragment.activity, pluginType)
|
configBuilderPlugin.switchAllowed(plugin, if (enabledExclusive.visibility == View.VISIBLE) enabledExclusive.isChecked else enabledInclusive.isChecked, fragment.activity, pluginType)
|
||||||
}
|
}
|
||||||
enabledInclusive.setOnClickListener {
|
enabledInclusive.setOnClickListener {
|
||||||
plugin.switchAllowed(if (enabledExclusive.visibility == View.VISIBLE) enabledExclusive.isChecked else enabledInclusive.isChecked, fragment.activity, pluginType)
|
configBuilderPlugin.switchAllowed(plugin, if (enabledExclusive.visibility == View.VISIBLE) enabledExclusive.isChecked else enabledInclusive.isChecked, fragment.activity, pluginType)
|
||||||
}
|
}
|
||||||
|
|
||||||
pluginPreferences.setOnClickListener {
|
pluginPreferences.setOnClickListener {
|
||||||
|
|
|
@ -1,6 +1,8 @@
|
||||||
package info.nightscout.androidaps.plugins.configBuilder;
|
package info.nightscout.androidaps.plugins.configBuilder;
|
||||||
|
|
||||||
|
import androidx.annotation.NonNull;
|
||||||
import androidx.annotation.Nullable;
|
import androidx.annotation.Nullable;
|
||||||
|
import androidx.fragment.app.FragmentActivity;
|
||||||
|
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
|
@ -13,6 +15,8 @@ import dagger.Lazy;
|
||||||
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.EventAppInitialized;
|
import info.nightscout.androidaps.events.EventAppInitialized;
|
||||||
|
import info.nightscout.androidaps.events.EventConfigBuilderChange;
|
||||||
|
import info.nightscout.androidaps.events.EventRebuildTabs;
|
||||||
import info.nightscout.androidaps.interfaces.APSInterface;
|
import info.nightscout.androidaps.interfaces.APSInterface;
|
||||||
import info.nightscout.androidaps.interfaces.ActivePluginProvider;
|
import info.nightscout.androidaps.interfaces.ActivePluginProvider;
|
||||||
import info.nightscout.androidaps.interfaces.BgSourceInterface;
|
import info.nightscout.androidaps.interfaces.BgSourceInterface;
|
||||||
|
@ -24,30 +28,45 @@ import info.nightscout.androidaps.interfaces.PluginType;
|
||||||
import info.nightscout.androidaps.interfaces.ProfileInterface;
|
import info.nightscout.androidaps.interfaces.ProfileInterface;
|
||||||
import info.nightscout.androidaps.interfaces.PumpInterface;
|
import info.nightscout.androidaps.interfaces.PumpInterface;
|
||||||
import info.nightscout.androidaps.interfaces.SensitivityInterface;
|
import info.nightscout.androidaps.interfaces.SensitivityInterface;
|
||||||
|
import info.nightscout.androidaps.interfaces.TreatmentsInterface;
|
||||||
import info.nightscout.androidaps.logging.AAPSLogger;
|
import info.nightscout.androidaps.logging.AAPSLogger;
|
||||||
import info.nightscout.androidaps.logging.LTag;
|
import info.nightscout.androidaps.logging.LTag;
|
||||||
import info.nightscout.androidaps.plugins.bus.RxBus;
|
|
||||||
import info.nightscout.androidaps.plugins.bus.RxBusWrapper;
|
import info.nightscout.androidaps.plugins.bus.RxBusWrapper;
|
||||||
import info.nightscout.androidaps.plugins.insulin.InsulinOrefRapidActingPlugin;
|
import info.nightscout.androidaps.plugins.insulin.InsulinOrefRapidActingPlugin;
|
||||||
import info.nightscout.androidaps.plugins.profile.local.LocalProfilePlugin;
|
import info.nightscout.androidaps.plugins.profile.local.LocalProfilePlugin;
|
||||||
import info.nightscout.androidaps.plugins.profile.ns.NSProfilePlugin;
|
import info.nightscout.androidaps.plugins.profile.ns.NSProfilePlugin;
|
||||||
import info.nightscout.androidaps.plugins.pump.virtual.VirtualPumpPlugin;
|
import info.nightscout.androidaps.plugins.pump.virtual.VirtualPumpPlugin;
|
||||||
import info.nightscout.androidaps.plugins.sensitivity.SensitivityOref0Plugin;
|
import info.nightscout.androidaps.plugins.sensitivity.SensitivityOref0Plugin;
|
||||||
import info.nightscout.androidaps.queue.CommandQueue;
|
import info.nightscout.androidaps.plugins.sensitivity.SensitivityOref1Plugin;
|
||||||
|
import info.nightscout.androidaps.plugins.treatments.TreatmentsPlugin;
|
||||||
|
import info.nightscout.androidaps.utils.OKDialog;
|
||||||
|
import info.nightscout.androidaps.utils.resources.ResourceHelper;
|
||||||
import info.nightscout.androidaps.utils.sharedPreferences.SP;
|
import info.nightscout.androidaps.utils.sharedPreferences.SP;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by mike on 05.08.2016.
|
* Created by mike on 05.08.2016.
|
||||||
*/
|
*/
|
||||||
@Singleton
|
@Singleton
|
||||||
public class ConfigBuilderPlugin extends PluginBase implements ActivePluginProvider, CommandQueueProvider {
|
public class ConfigBuilderPlugin extends PluginBase implements ActivePluginProvider {
|
||||||
private static ConfigBuilderPlugin configBuilderPlugin;
|
private static ConfigBuilderPlugin configBuilderPlugin;
|
||||||
private final SP sp;
|
private final SP sp;
|
||||||
|
private final AAPSLogger aapsLogger;
|
||||||
|
private final RxBusWrapper rxBus;
|
||||||
|
private final ResourceHelper resourceHelper;
|
||||||
|
private final CommandQueueProvider commandQueue;
|
||||||
|
private final NSProfilePlugin nsProfilePlugin;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @deprecated Use dagger to get an instance
|
* @deprecated Use dagger to get an instance
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
@Deprecated
|
||||||
|
public CommandQueueProvider getCommandQueue() {
|
||||||
|
if (commandQueue == null)
|
||||||
|
throw new IllegalStateException("Accessing commandQueue before first instantiation");
|
||||||
|
return commandQueue;
|
||||||
|
}
|
||||||
|
|
||||||
@Deprecated
|
@Deprecated
|
||||||
static public ConfigBuilderPlugin getPlugin() {
|
static public ConfigBuilderPlugin getPlugin() {
|
||||||
if (configBuilderPlugin == null)
|
if (configBuilderPlugin == null)
|
||||||
|
@ -61,11 +80,12 @@ public class ConfigBuilderPlugin extends PluginBase implements ActivePluginProvi
|
||||||
private APSInterface activeAPS;
|
private APSInterface activeAPS;
|
||||||
private InsulinInterface activeInsulin;
|
private InsulinInterface activeInsulin;
|
||||||
private SensitivityInterface activeSensitivity;
|
private SensitivityInterface activeSensitivity;
|
||||||
|
private Lazy<TreatmentsPlugin> treatmentsPlugin;
|
||||||
|
private Lazy<SensitivityOref0Plugin> sensitivityOref0Plugin;
|
||||||
|
private Lazy<SensitivityOref1Plugin> sensitivityOref1Plugin;
|
||||||
|
|
||||||
private ArrayList<PluginBase> pluginList;
|
private ArrayList<PluginBase> pluginList;
|
||||||
|
|
||||||
private CommandQueue commandQueue = new CommandQueue();
|
|
||||||
|
|
||||||
private final Lazy<InsulinOrefRapidActingPlugin> insulinOrefRapidActingPlugin;
|
private final Lazy<InsulinOrefRapidActingPlugin> insulinOrefRapidActingPlugin;
|
||||||
private final Lazy<LocalProfilePlugin> localProfilePlugin;
|
private final Lazy<LocalProfilePlugin> localProfilePlugin;
|
||||||
private final Lazy<VirtualPumpPlugin> virtualPumpPlugin;
|
private final Lazy<VirtualPumpPlugin> virtualPumpPlugin;
|
||||||
|
@ -82,9 +102,16 @@ public class ConfigBuilderPlugin extends PluginBase implements ActivePluginProvi
|
||||||
Lazy<InsulinOrefRapidActingPlugin> insulinOrefRapidActingPlugin,
|
Lazy<InsulinOrefRapidActingPlugin> insulinOrefRapidActingPlugin,
|
||||||
Lazy<LocalProfilePlugin> localProfilePlugin,
|
Lazy<LocalProfilePlugin> localProfilePlugin,
|
||||||
Lazy<VirtualPumpPlugin> virtualPumpPlugin,
|
Lazy<VirtualPumpPlugin> virtualPumpPlugin,
|
||||||
|
Lazy<TreatmentsPlugin> treatmentsPlugin,
|
||||||
|
Lazy<SensitivityOref0Plugin> sensitivityOref0Plugin,
|
||||||
|
Lazy<SensitivityOref1Plugin> sensitivityOref1Plugin,
|
||||||
SP sp,
|
SP sp,
|
||||||
RxBusWrapper rxBus,
|
RxBusWrapper rxBus,
|
||||||
AAPSLogger aapsLogger) {
|
AAPSLogger aapsLogger,
|
||||||
|
ResourceHelper resourceHelper,
|
||||||
|
CommandQueueProvider commandQueue,
|
||||||
|
NSProfilePlugin nsProfilePlugin
|
||||||
|
) {
|
||||||
super(new PluginDescription()
|
super(new PluginDescription()
|
||||||
.mainType(PluginType.GENERAL)
|
.mainType(PluginType.GENERAL)
|
||||||
.fragmentClass(ConfigBuilderFragment.class.getName())
|
.fragmentClass(ConfigBuilderFragment.class.getName())
|
||||||
|
@ -94,12 +121,20 @@ public class ConfigBuilderPlugin extends PluginBase implements ActivePluginProvi
|
||||||
.pluginName(R.string.configbuilder)
|
.pluginName(R.string.configbuilder)
|
||||||
.shortName(R.string.configbuilder_shortname)
|
.shortName(R.string.configbuilder_shortname)
|
||||||
.description(R.string.description_config_builder),
|
.description(R.string.description_config_builder),
|
||||||
rxBus, aapsLogger
|
aapsLogger, resourceHelper
|
||||||
);
|
);
|
||||||
this.insulinOrefRapidActingPlugin = insulinOrefRapidActingPlugin;
|
this.insulinOrefRapidActingPlugin = insulinOrefRapidActingPlugin;
|
||||||
this.localProfilePlugin = localProfilePlugin;
|
this.localProfilePlugin = localProfilePlugin;
|
||||||
this.virtualPumpPlugin = virtualPumpPlugin;
|
this.virtualPumpPlugin = virtualPumpPlugin;
|
||||||
|
this.treatmentsPlugin = treatmentsPlugin;
|
||||||
|
this.sensitivityOref0Plugin = sensitivityOref0Plugin;
|
||||||
|
this.sensitivityOref1Plugin = sensitivityOref1Plugin;
|
||||||
this.sp = sp;
|
this.sp = sp;
|
||||||
|
this.rxBus = rxBus;
|
||||||
|
this.aapsLogger = aapsLogger;
|
||||||
|
this.resourceHelper = resourceHelper;
|
||||||
|
this.commandQueue = commandQueue;
|
||||||
|
this.nsProfilePlugin = nsProfilePlugin;
|
||||||
configBuilderPlugin = this; // TODO: only while transitioning to Dagger
|
configBuilderPlugin = this; // TODO: only while transitioning to Dagger
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -108,7 +143,7 @@ public class ConfigBuilderPlugin extends PluginBase implements ActivePluginProvi
|
||||||
upgradeSettings();
|
upgradeSettings();
|
||||||
loadSettings();
|
loadSettings();
|
||||||
setAlwaysEnabledPluginsEnabled();
|
setAlwaysEnabledPluginsEnabled();
|
||||||
RxBus.Companion.getINSTANCE().send(new EventAppInitialized());
|
rxBus.send(new EventAppInitialized());
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setAlwaysEnabledPluginsEnabled() {
|
private void setAlwaysEnabledPluginsEnabled() {
|
||||||
|
@ -246,41 +281,60 @@ public class ConfigBuilderPlugin extends PluginBase implements ActivePluginProvi
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override public CommandQueue getCommandQueue() {
|
@Override
|
||||||
return commandQueue;
|
@Nullable
|
||||||
}
|
|
||||||
|
|
||||||
@Override @Nullable
|
|
||||||
public BgSourceInterface getActiveBgSource() {
|
public BgSourceInterface getActiveBgSource() {
|
||||||
return activeBgSource;
|
return activeBgSource;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override @NotNull
|
@Override
|
||||||
|
@NotNull
|
||||||
public ProfileInterface getActiveProfileInterface() {
|
public ProfileInterface getActiveProfileInterface() {
|
||||||
if (activeProfile != null) return activeProfile;
|
if (activeProfile != null) return activeProfile;
|
||||||
else return localProfilePlugin.get();
|
else return localProfilePlugin.get();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override @Nullable
|
@Override
|
||||||
|
@NotNull
|
||||||
public InsulinInterface getActiveInsulin() {
|
public InsulinInterface getActiveInsulin() {
|
||||||
|
if (activeInsulin == null)
|
||||||
|
return insulinOrefRapidActingPlugin.get();
|
||||||
return activeInsulin;
|
return activeInsulin;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override @Nullable
|
@Override
|
||||||
|
@Nullable
|
||||||
public APSInterface getActiveAPS() {
|
public APSInterface getActiveAPS() {
|
||||||
return activeAPS;
|
return activeAPS;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override @Nullable
|
@Override
|
||||||
|
@NotNull
|
||||||
public PumpInterface getActivePump() {
|
public PumpInterface getActivePump() {
|
||||||
|
if (activePump == null)
|
||||||
|
throw new IllegalStateException("No pump selected");
|
||||||
return activePump;
|
return activePump;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override @Nullable
|
@Override
|
||||||
|
@Nullable
|
||||||
|
public PumpInterface getActivePumpPlugin() {
|
||||||
|
return activePump;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@NotNull
|
||||||
public SensitivityInterface getActiveSensitivity() {
|
public SensitivityInterface getActiveSensitivity() {
|
||||||
|
if (activeSensitivity == null)
|
||||||
|
return sensitivityOref1Plugin.get();
|
||||||
|
else
|
||||||
return activeSensitivity;
|
return activeSensitivity;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@NonNull @Override public TreatmentsInterface getActiveTreatments() {
|
||||||
|
return treatmentsPlugin.get();
|
||||||
|
}
|
||||||
|
|
||||||
public void logPluginStatus() {
|
public void logPluginStatus() {
|
||||||
for (PluginBase p : pluginList) {
|
for (PluginBase p : pluginList) {
|
||||||
getAapsLogger().debug(LTag.CONFIGBUILDER, p.getName() + ":" +
|
getAapsLogger().debug(LTag.CONFIGBUILDER, p.getName() + ":" +
|
||||||
|
@ -318,8 +372,8 @@ public class ConfigBuilderPlugin extends PluginBase implements ActivePluginProvi
|
||||||
pluginsInCategory = MainApp.getSpecificPluginsList(PluginType.SENSITIVITY);
|
pluginsInCategory = MainApp.getSpecificPluginsList(PluginType.SENSITIVITY);
|
||||||
activeSensitivity = (SensitivityInterface) getTheOneEnabledInArray(pluginsInCategory, PluginType.SENSITIVITY);
|
activeSensitivity = (SensitivityInterface) getTheOneEnabledInArray(pluginsInCategory, PluginType.SENSITIVITY);
|
||||||
if (activeSensitivity == null) {
|
if (activeSensitivity == null) {
|
||||||
activeSensitivity = SensitivityOref0Plugin.getPlugin();
|
activeSensitivity = sensitivityOref0Plugin.get();
|
||||||
SensitivityOref0Plugin.getPlugin().setPluginEnabled(PluginType.SENSITIVITY, true);
|
sensitivityOref0Plugin.get().setPluginEnabled(PluginType.SENSITIVITY, true);
|
||||||
getAapsLogger().debug(LTag.CONFIGBUILDER, "Defaulting SensitivityOref0Plugin");
|
getAapsLogger().debug(LTag.CONFIGBUILDER, "Defaulting SensitivityOref0Plugin");
|
||||||
}
|
}
|
||||||
this.setFragmentVisiblities(((PluginBase) activeSensitivity).getName(), pluginsInCategory, PluginType.SENSITIVITY);
|
this.setFragmentVisiblities(((PluginBase) activeSensitivity).getName(), pluginsInCategory, PluginType.SENSITIVITY);
|
||||||
|
@ -359,13 +413,6 @@ public class ConfigBuilderPlugin extends PluginBase implements ActivePluginProvi
|
||||||
return this.determineActivePlugin(pluginsInCategory, pluginType);
|
return this.determineActivePlugin(pluginsInCategory, pluginType);
|
||||||
}
|
}
|
||||||
|
|
||||||
private <T> T determineActivePlugin(PluginType pluginType) {
|
|
||||||
ArrayList<PluginBase> pluginsInCategory;
|
|
||||||
pluginsInCategory = MainApp.getSpecificPluginsList(pluginType);
|
|
||||||
|
|
||||||
return this.determineActivePlugin(pluginsInCategory, pluginType);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* disables the visibility for all fragments of Plugins in the given pluginsInCategory
|
* disables the visibility for all fragments of Plugins in the given pluginsInCategory
|
||||||
* with the given PluginType which are not equally named to the Plugin implementing the
|
* with the given PluginType which are not equally named to the Plugin implementing the
|
||||||
|
@ -419,6 +466,45 @@ public class ConfigBuilderPlugin extends PluginBase implements ActivePluginProvi
|
||||||
return found;
|
return found;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Ask when switching to physical pump plugin
|
||||||
|
public void switchAllowed(@NonNull PluginBase changedPlugin, boolean newState, @Nullable FragmentActivity activity, @NonNull PluginType type) {
|
||||||
|
if (changedPlugin.getType() == PluginType.PUMP && !changedPlugin.getName().equals(resourceHelper.gs(R.string.virtualpump)))
|
||||||
|
confirmPumpPluginActivation(changedPlugin, newState, activity, type);
|
||||||
|
else
|
||||||
|
performPluginSwitch(changedPlugin, newState, type);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void confirmPumpPluginActivation(@NonNull PluginBase changedPlugin, boolean newState, @Nullable FragmentActivity activity, @NonNull PluginType type) {
|
||||||
|
if (type == PluginType.PUMP) {
|
||||||
|
boolean allowHardwarePump = sp.getBoolean("allow_hardware_pump", false);
|
||||||
|
if (allowHardwarePump || activity == null) {
|
||||||
|
performPluginSwitch(changedPlugin, newState, type);
|
||||||
|
} else {
|
||||||
|
OKDialog.showConfirmation(activity, resourceHelper.gs(R.string.allow_hardware_pump_text), () -> {
|
||||||
|
performPluginSwitch(changedPlugin, newState, type);
|
||||||
|
sp.putBoolean("allow_hardware_pump", true);
|
||||||
|
aapsLogger.debug(LTag.PUMP, "First time HW pump allowed!");
|
||||||
|
}, () -> {
|
||||||
|
rxBus.send(new EventConfigBuilderUpdateGui());
|
||||||
|
aapsLogger.debug(LTag.PUMP, "User does not allow switching to HW pump!");
|
||||||
|
});
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
performPluginSwitch(changedPlugin, newState, type);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void performPluginSwitch(PluginBase changedPlugin, boolean enabled, @NonNull PluginType type) {
|
||||||
|
setPluginEnabled(type, enabled);
|
||||||
|
setFragmentVisible(type, enabled);
|
||||||
|
processOnEnabledCategoryChanged(changedPlugin, type);
|
||||||
|
storeSettings("CheckedCheckboxEnabled");
|
||||||
|
rxBus.send(new EventRebuildTabs());
|
||||||
|
rxBus.send(new EventConfigBuilderChange());
|
||||||
|
rxBus.send(new EventConfigBuilderUpdateGui());
|
||||||
|
logPluginStatus();
|
||||||
|
}
|
||||||
|
|
||||||
public void processOnEnabledCategoryChanged(PluginBase changedPlugin, PluginType type) {
|
public void processOnEnabledCategoryChanged(PluginBase changedPlugin, PluginType type) {
|
||||||
ArrayList<PluginBase> pluginsInCategory = null;
|
ArrayList<PluginBase> pluginsInCategory = null;
|
||||||
switch (type) {
|
switch (type) {
|
||||||
|
@ -461,13 +547,13 @@ public class ConfigBuilderPlugin extends PluginBase implements ActivePluginProvi
|
||||||
}
|
}
|
||||||
} else { // enable first plugin in list
|
} else { // enable first plugin in list
|
||||||
if (type == PluginType.PUMP)
|
if (type == PluginType.PUMP)
|
||||||
VirtualPumpPlugin.Companion.getPlugin().setPluginEnabled(type, true);
|
virtualPumpPlugin.get().setPluginEnabled(type, true);
|
||||||
else if (type == PluginType.INSULIN)
|
else if (type == PluginType.INSULIN)
|
||||||
insulinOrefRapidActingPlugin.get().setPluginEnabled(type, true);
|
insulinOrefRapidActingPlugin.get().setPluginEnabled(type, true);
|
||||||
else if (type == PluginType.SENSITIVITY)
|
else if (type == PluginType.SENSITIVITY)
|
||||||
SensitivityOref0Plugin.getPlugin().setPluginEnabled(type, true);
|
sensitivityOref0Plugin.get().setPluginEnabled(type, true);
|
||||||
else if (type == PluginType.PROFILE)
|
else if (type == PluginType.PROFILE)
|
||||||
NSProfilePlugin.getPlugin().setPluginEnabled(type, true);
|
nsProfilePlugin.setPluginEnabled(type, true);
|
||||||
else
|
else
|
||||||
pluginsInCategory.get(0).setPluginEnabled(type, true);
|
pluginsInCategory.get(0).setPluginEnabled(type, true);
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,8 +13,7 @@ import javax.inject.Singleton
|
||||||
|
|
||||||
@Singleton
|
@Singleton
|
||||||
class ProfileFunctionImplementation @Inject constructor(
|
class ProfileFunctionImplementation @Inject constructor(
|
||||||
private val sp: SP,
|
private val sp: SP
|
||||||
private val configBuilderPlugin: ConfigBuilderPlugin
|
|
||||||
) : ProfileFunction {
|
) : ProfileFunction {
|
||||||
|
|
||||||
override fun getProfileName(): String =
|
override fun getProfileName(): String =
|
||||||
|
@ -50,7 +49,6 @@ class ProfileFunctionImplementation @Inject constructor(
|
||||||
profileSwitch.source = Source.USER
|
profileSwitch.source = Source.USER
|
||||||
profileSwitch.profileName = profileName
|
profileSwitch.profileName = profileName
|
||||||
profileSwitch.profileJson = profile.data.toString()
|
profileSwitch.profileJson = profile.data.toString()
|
||||||
profileSwitch.profilePlugin = configBuilderPlugin.activeProfileInterface::class.java.name
|
|
||||||
profileSwitch.durationInMinutes = duration
|
profileSwitch.durationInMinutes = duration
|
||||||
profileSwitch.isCPP = percentage != 100 || timeShift != 0
|
profileSwitch.isCPP = percentage != 100 || timeShift != 0
|
||||||
profileSwitch.timeshift = timeShift
|
profileSwitch.timeshift = timeShift
|
||||||
|
|
|
@ -1,17 +1,12 @@
|
||||||
package info.nightscout.androidaps.plugins.constraints.dstHelper
|
package info.nightscout.androidaps.plugins.constraints.dstHelper
|
||||||
|
|
||||||
import info.nightscout.androidaps.MainApp
|
import dagger.android.HasAndroidInjector
|
||||||
import info.nightscout.androidaps.R
|
import info.nightscout.androidaps.R
|
||||||
import info.nightscout.androidaps.interfaces.Constraint
|
import info.nightscout.androidaps.interfaces.*
|
||||||
import info.nightscout.androidaps.interfaces.ConstraintsInterface
|
|
||||||
import info.nightscout.androidaps.interfaces.PluginBase
|
|
||||||
import info.nightscout.androidaps.interfaces.PluginDescription
|
|
||||||
import info.nightscout.androidaps.interfaces.PluginType
|
|
||||||
import info.nightscout.androidaps.logging.AAPSLogger
|
import info.nightscout.androidaps.logging.AAPSLogger
|
||||||
import info.nightscout.androidaps.logging.LTag
|
import info.nightscout.androidaps.logging.LTag
|
||||||
import info.nightscout.androidaps.plugins.aps.loop.LoopPlugin
|
import info.nightscout.androidaps.plugins.aps.loop.LoopPlugin
|
||||||
import info.nightscout.androidaps.plugins.bus.RxBusWrapper
|
import info.nightscout.androidaps.plugins.bus.RxBusWrapper
|
||||||
import info.nightscout.androidaps.plugins.configBuilder.ConfigBuilderPlugin
|
|
||||||
import info.nightscout.androidaps.plugins.general.overview.events.EventNewNotification
|
import info.nightscout.androidaps.plugins.general.overview.events.EventNewNotification
|
||||||
import info.nightscout.androidaps.plugins.general.overview.notifications.Notification
|
import info.nightscout.androidaps.plugins.general.overview.notifications.Notification
|
||||||
import info.nightscout.androidaps.plugins.general.overview.notifications.NotificationWithAction
|
import info.nightscout.androidaps.plugins.general.overview.notifications.NotificationWithAction
|
||||||
|
@ -24,29 +19,31 @@ import javax.inject.Singleton
|
||||||
|
|
||||||
@Singleton
|
@Singleton
|
||||||
class DstHelperPlugin @Inject constructor(
|
class DstHelperPlugin @Inject constructor(
|
||||||
|
private var injector: HasAndroidInjector,
|
||||||
aapsLogger: AAPSLogger,
|
aapsLogger: AAPSLogger,
|
||||||
rxBus: RxBusWrapper,
|
private var rxBus: RxBusWrapper,
|
||||||
var resourceHelper: ResourceHelper,
|
resourceHelper: ResourceHelper,
|
||||||
var mainApp: MainApp,
|
private var sp: SP,
|
||||||
var sp: SP,
|
private var activePlugin: ActivePluginProvider,
|
||||||
var configBuilderPlugin: ConfigBuilderPlugin,
|
private var loopPlugin: LoopPlugin
|
||||||
var loopPlugin: LoopPlugin
|
|
||||||
) : PluginBase(PluginDescription()
|
) : PluginBase(PluginDescription()
|
||||||
.mainType(PluginType.CONSTRAINTS)
|
.mainType(PluginType.CONSTRAINTS)
|
||||||
.neverVisible(true)
|
.neverVisible(true)
|
||||||
.alwaysEnabled(true)
|
.alwaysEnabled(true)
|
||||||
.showInList(false)
|
.showInList(false)
|
||||||
.pluginName(R.string.dst_plugin_name),
|
.pluginName(R.string.dst_plugin_name),
|
||||||
rxBus, aapsLogger
|
aapsLogger, resourceHelper
|
||||||
), ConstraintsInterface {
|
), ConstraintsInterface {
|
||||||
|
|
||||||
private val DISABLE_TIMEFRAME_HOURS = -3
|
companion object {
|
||||||
private val WARN_PRIOR_TIMEFRAME_HOURS = 12
|
private const val DISABLE_TIME_FRAME_HOURS = -3
|
||||||
|
private const val WARN_PRIOR_TIME_FRAME_HOURS = 12
|
||||||
|
}
|
||||||
|
|
||||||
//Return false if time to DST change happened in the last 3 hours.
|
//Return false if time to DST change happened in the last 3 hours.
|
||||||
override fun isLoopInvocationAllowed(value: Constraint<Boolean>): Constraint<Boolean> {
|
override fun isLoopInvocationAllowed(value: Constraint<Boolean>): Constraint<Boolean> {
|
||||||
val pump = configBuilderPlugin.activePump
|
val pump = activePlugin.activePumpPlugin ?: return value
|
||||||
if (pump == null || pump.canHandleDST()) {
|
if (pump.canHandleDST()) {
|
||||||
aapsLogger.debug(LTag.CONSTRAINTS, "Pump can handle DST")
|
aapsLogger.debug(LTag.CONSTRAINTS, "Pump can handle DST")
|
||||||
return value
|
return value
|
||||||
}
|
}
|
||||||
|
@ -54,7 +51,7 @@ class DstHelperPlugin @Inject constructor(
|
||||||
if (willBeDST(cal)) {
|
if (willBeDST(cal)) {
|
||||||
val snoozedTo: Long = sp.getLong(R.string.key_snooze_dst_in24h, 0L)
|
val snoozedTo: Long = sp.getLong(R.string.key_snooze_dst_in24h, 0L)
|
||||||
if (snoozedTo == 0L || System.currentTimeMillis() > snoozedTo) {
|
if (snoozedTo == 0L || System.currentTimeMillis() > snoozedTo) {
|
||||||
val notification = NotificationWithAction(mainApp, Notification.DST_IN_24H, resourceHelper.gs(R.string.dst_in_24h_warning), Notification.LOW)
|
val notification = NotificationWithAction(injector, Notification.DST_IN_24H, resourceHelper.gs(R.string.dst_in_24h_warning), Notification.LOW)
|
||||||
notification.action(R.string.snooze, Runnable {
|
notification.action(R.string.snooze, Runnable {
|
||||||
sp.putLong(R.string.key_snooze_dst_in24h, System.currentTimeMillis() + T.hours(24).msecs())
|
sp.putLong(R.string.key_snooze_dst_in24h, System.currentTimeMillis() + T.hours(24).msecs())
|
||||||
})
|
})
|
||||||
|
@ -69,7 +66,7 @@ class DstHelperPlugin @Inject constructor(
|
||||||
if (!loopPlugin.isSuspended) {
|
if (!loopPlugin.isSuspended) {
|
||||||
val snoozedTo: Long = sp.getLong(R.string.key_snooze_loopdisabled, 0L)
|
val snoozedTo: Long = sp.getLong(R.string.key_snooze_loopdisabled, 0L)
|
||||||
if (snoozedTo == 0L || System.currentTimeMillis() > snoozedTo) {
|
if (snoozedTo == 0L || System.currentTimeMillis() > snoozedTo) {
|
||||||
val notification = NotificationWithAction(mainApp, Notification.DST_LOOP_DISABLED, resourceHelper.gs(R.string.dst_loop_disabled_warning), Notification.LOW)
|
val notification = NotificationWithAction(injector, Notification.DST_LOOP_DISABLED, resourceHelper.gs(R.string.dst_loop_disabled_warning), Notification.LOW)
|
||||||
notification.action(R.string.snooze, Runnable {
|
notification.action(R.string.snooze, Runnable {
|
||||||
sp.putLong(R.string.key_snooze_loopdisabled, System.currentTimeMillis() + T.hours(24).msecs())
|
sp.putLong(R.string.key_snooze_loopdisabled, System.currentTimeMillis() + T.hours(24).msecs())
|
||||||
})
|
})
|
||||||
|
@ -85,13 +82,13 @@ class DstHelperPlugin @Inject constructor(
|
||||||
|
|
||||||
fun wasDST(now: Calendar): Boolean {
|
fun wasDST(now: Calendar): Boolean {
|
||||||
val ago = now.clone() as Calendar
|
val ago = now.clone() as Calendar
|
||||||
ago.add(Calendar.HOUR, DISABLE_TIMEFRAME_HOURS)
|
ago.add(Calendar.HOUR, DISABLE_TIME_FRAME_HOURS)
|
||||||
return now[Calendar.DST_OFFSET] != ago[Calendar.DST_OFFSET]
|
return now[Calendar.DST_OFFSET] != ago[Calendar.DST_OFFSET]
|
||||||
}
|
}
|
||||||
|
|
||||||
fun willBeDST(now: Calendar): Boolean {
|
fun willBeDST(now: Calendar): Boolean {
|
||||||
val ago = now.clone() as Calendar
|
val ago = now.clone() as Calendar
|
||||||
ago.add(Calendar.HOUR, WARN_PRIOR_TIMEFRAME_HOURS)
|
ago.add(Calendar.HOUR, WARN_PRIOR_TIME_FRAME_HOURS)
|
||||||
return now[Calendar.DST_OFFSET] != ago[Calendar.DST_OFFSET]
|
return now[Calendar.DST_OFFSET] != ago[Calendar.DST_OFFSET]
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -3,6 +3,7 @@ package info.nightscout.androidaps.plugins.constraints.objectives
|
||||||
import android.app.Activity
|
import android.app.Activity
|
||||||
import com.google.common.base.Charsets
|
import com.google.common.base.Charsets
|
||||||
import com.google.common.hash.Hashing
|
import com.google.common.hash.Hashing
|
||||||
|
import dagger.android.HasAndroidInjector
|
||||||
import info.nightscout.androidaps.BuildConfig
|
import info.nightscout.androidaps.BuildConfig
|
||||||
import info.nightscout.androidaps.Config
|
import info.nightscout.androidaps.Config
|
||||||
import info.nightscout.androidaps.R
|
import info.nightscout.androidaps.R
|
||||||
|
@ -12,7 +13,6 @@ import info.nightscout.androidaps.interfaces.PluginBase
|
||||||
import info.nightscout.androidaps.interfaces.PluginDescription
|
import info.nightscout.androidaps.interfaces.PluginDescription
|
||||||
import info.nightscout.androidaps.interfaces.PluginType
|
import info.nightscout.androidaps.interfaces.PluginType
|
||||||
import info.nightscout.androidaps.logging.AAPSLogger
|
import info.nightscout.androidaps.logging.AAPSLogger
|
||||||
import info.nightscout.androidaps.plugins.bus.RxBusWrapper
|
|
||||||
import info.nightscout.androidaps.plugins.configBuilder.ConfigBuilderPlugin
|
import info.nightscout.androidaps.plugins.configBuilder.ConfigBuilderPlugin
|
||||||
import info.nightscout.androidaps.plugins.constraints.objectives.objectives.*
|
import info.nightscout.androidaps.plugins.constraints.objectives.objectives.*
|
||||||
import info.nightscout.androidaps.utils.DateUtil
|
import info.nightscout.androidaps.utils.DateUtil
|
||||||
|
@ -25,10 +25,11 @@ import javax.inject.Singleton
|
||||||
|
|
||||||
@Singleton
|
@Singleton
|
||||||
class ObjectivesPlugin @Inject constructor(
|
class ObjectivesPlugin @Inject constructor(
|
||||||
private val sp: SP,
|
private val injector: HasAndroidInjector,
|
||||||
private val resourceHelper: ResourceHelper,
|
aapsLogger: AAPSLogger,
|
||||||
|
resourceHelper: ResourceHelper,
|
||||||
private val configBuilderPlugin: ConfigBuilderPlugin,
|
private val configBuilderPlugin: ConfigBuilderPlugin,
|
||||||
rxBus: RxBusWrapper, aapsLogger: AAPSLogger
|
private val sp: SP
|
||||||
|
|
||||||
) : PluginBase(PluginDescription()
|
) : PluginBase(PluginDescription()
|
||||||
.mainType(PluginType.CONSTRAINTS)
|
.mainType(PluginType.CONSTRAINTS)
|
||||||
|
@ -38,21 +39,23 @@ class ObjectivesPlugin @Inject constructor(
|
||||||
.pluginName(R.string.objectives)
|
.pluginName(R.string.objectives)
|
||||||
.shortName(R.string.objectives_shortname)
|
.shortName(R.string.objectives_shortname)
|
||||||
.description(R.string.description_objectives),
|
.description(R.string.description_objectives),
|
||||||
rxBus, aapsLogger
|
aapsLogger, resourceHelper
|
||||||
), ConstraintsInterface {
|
), ConstraintsInterface {
|
||||||
|
|
||||||
var objectives: MutableList<Objective> = ArrayList()
|
var objectives: MutableList<Objective> = ArrayList()
|
||||||
|
|
||||||
val FIRST_OBJECTIVE = 0
|
companion object {
|
||||||
val USAGE_OBJECTIVE = 1
|
const val FIRST_OBJECTIVE = 0
|
||||||
val EXAM_OBJECTIVE = 2
|
@Suppress("unused") const val USAGE_OBJECTIVE = 1
|
||||||
val OPENLOOP_OBJECTIVE = 3
|
@Suppress("unused") const val EXAM_OBJECTIVE = 2
|
||||||
val MAXBASAL_OBJECTIVE = 4
|
@Suppress("unused") const val OPENLOOP_OBJECTIVE = 3
|
||||||
val MAXIOB_ZERO_CL_OBJECTIVE = 5
|
@Suppress("unused") const val MAXBASAL_OBJECTIVE = 4
|
||||||
val MAXIOB_OBJECTIVE = 6
|
const val MAXIOB_ZERO_CL_OBJECTIVE = 5
|
||||||
val AUTOSENS_OBJECTIVE = 7
|
@Suppress("unused") const val MAXIOB_OBJECTIVE = 6
|
||||||
val AMA_OBJECTIVE = 8
|
const val AUTOSENS_OBJECTIVE = 7
|
||||||
val SMB_OBJECTIVE = 9
|
const val AMA_OBJECTIVE = 8
|
||||||
|
const val SMB_OBJECTIVE = 9
|
||||||
|
}
|
||||||
|
|
||||||
override fun onStart() {
|
override fun onStart() {
|
||||||
super.onStart()
|
super.onStart()
|
||||||
|
@ -61,7 +64,7 @@ class ObjectivesPlugin @Inject constructor(
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun specialEnableCondition(): Boolean {
|
override fun specialEnableCondition(): Boolean {
|
||||||
val pump = configBuilderPlugin.activePump
|
val pump = configBuilderPlugin.activePumpPlugin
|
||||||
return pump == null || pump.pumpDescription.isTempBasalCapable
|
return pump == null || pump.pumpDescription.isTempBasalCapable
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -92,7 +95,7 @@ class ObjectivesPlugin @Inject constructor(
|
||||||
objectives.add(Objective2())
|
objectives.add(Objective2())
|
||||||
objectives.add(Objective3())
|
objectives.add(Objective3())
|
||||||
objectives.add(Objective4())
|
objectives.add(Objective4())
|
||||||
objectives.add(Objective5())
|
objectives.add(Objective5(injector))
|
||||||
objectives.add(Objective6())
|
objectives.add(Objective6())
|
||||||
objectives.add(Objective7())
|
objectives.add(Objective7())
|
||||||
objectives.add(Objective8())
|
objectives.add(Objective8())
|
||||||
|
@ -118,7 +121,7 @@ class ObjectivesPlugin @Inject constructor(
|
||||||
|
|
||||||
fun completeObjectives(activity: Activity, request: String) {
|
fun completeObjectives(activity: Activity, request: String) {
|
||||||
val requestCode = sp.getString(R.string.key_objectives_request_code, "")
|
val requestCode = sp.getString(R.string.key_objectives_request_code, "")
|
||||||
var url = sp.getString(R.string.key_nsclientinternal_url, "").toLowerCase()
|
var url = sp.getString(R.string.key_nsclientinternal_url, "").toLowerCase(Locale.getDefault())
|
||||||
if (!url.endsWith("/")) url = "$url/"
|
if (!url.endsWith("/")) url = "$url/"
|
||||||
@Suppress("DEPRECATION") val hashNS = Hashing.sha1().hashString(url + BuildConfig.APPLICATION_ID + "/" + requestCode, Charsets.UTF_8).toString()
|
@Suppress("DEPRECATION") val hashNS = Hashing.sha1().hashString(url + BuildConfig.APPLICATION_ID + "/" + requestCode, Charsets.UTF_8).toString()
|
||||||
if (request.equals(hashNS.substring(0, 10), ignoreCase = true)) {
|
if (request.equals(hashNS.substring(0, 10), ignoreCase = true)) {
|
||||||
|
@ -181,5 +184,4 @@ class ObjectivesPlugin @Inject constructor(
|
||||||
maxIob.set(0.0, resourceHelper.gs(R.string.objectivenotfinished, MAXIOB_ZERO_CL_OBJECTIVE + 1), this)
|
maxIob.set(0.0, resourceHelper.gs(R.string.objectivenotfinished, MAXIOB_ZERO_CL_OBJECTIVE + 1), this)
|
||||||
return maxIob
|
return maxIob
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,13 +6,13 @@ import javax.inject.Inject;
|
||||||
|
|
||||||
import info.nightscout.androidaps.MainApp;
|
import info.nightscout.androidaps.MainApp;
|
||||||
import info.nightscout.androidaps.R;
|
import info.nightscout.androidaps.R;
|
||||||
import info.nightscout.androidaps.db.DatabaseHelper;
|
|
||||||
import info.nightscout.androidaps.interfaces.APSInterface;
|
import info.nightscout.androidaps.interfaces.APSInterface;
|
||||||
import info.nightscout.androidaps.interfaces.PluginBase;
|
import info.nightscout.androidaps.interfaces.PluginBase;
|
||||||
import info.nightscout.androidaps.interfaces.PluginType;
|
import info.nightscout.androidaps.interfaces.PluginType;
|
||||||
import info.nightscout.androidaps.plugins.aps.loop.LoopPlugin;
|
import info.nightscout.androidaps.plugins.aps.loop.LoopPlugin;
|
||||||
import info.nightscout.androidaps.plugins.configBuilder.ConfigBuilderPlugin;
|
import info.nightscout.androidaps.plugins.configBuilder.ConfigBuilderPlugin;
|
||||||
import info.nightscout.androidaps.plugins.general.nsclient.NSClientPlugin;
|
import info.nightscout.androidaps.plugins.general.nsclient.NSClientPlugin;
|
||||||
|
import info.nightscout.androidaps.plugins.iob.iobCobCalculator.IobCobCalculatorPlugin;
|
||||||
import info.nightscout.androidaps.plugins.pump.virtual.VirtualPumpPlugin;
|
import info.nightscout.androidaps.plugins.pump.virtual.VirtualPumpPlugin;
|
||||||
import info.nightscout.androidaps.plugins.treatments.TreatmentsPlugin;
|
import info.nightscout.androidaps.plugins.treatments.TreatmentsPlugin;
|
||||||
import info.nightscout.androidaps.utils.DateUtil;
|
import info.nightscout.androidaps.utils.DateUtil;
|
||||||
|
@ -24,6 +24,8 @@ public class Objective0 extends Objective {
|
||||||
@Inject VirtualPumpPlugin virtualPumpPlugin;
|
@Inject VirtualPumpPlugin virtualPumpPlugin;
|
||||||
@Inject TreatmentsPlugin treatmentsPlugin;
|
@Inject TreatmentsPlugin treatmentsPlugin;
|
||||||
@Inject LoopPlugin loopPlugin;
|
@Inject LoopPlugin loopPlugin;
|
||||||
|
@Inject NSClientPlugin nsClientPlugin;
|
||||||
|
@Inject IobCobCalculatorPlugin iobCobCalculatorPlugin;
|
||||||
|
|
||||||
public Objective0() {
|
public Objective0() {
|
||||||
super("config", R.string.objectives_0_objective, R.string.objectives_0_gate);
|
super("config", R.string.objectives_0_objective, R.string.objectives_0_gate);
|
||||||
|
@ -41,7 +43,7 @@ public class Objective0 extends Objective {
|
||||||
tasks.add(new Task(R.string.nsclienthaswritepermission) {
|
tasks.add(new Task(R.string.nsclienthaswritepermission) {
|
||||||
@Override
|
@Override
|
||||||
public boolean isCompleted() {
|
public boolean isCompleted() {
|
||||||
return NSClientPlugin.getPlugin().hasWritePermission();
|
return nsClientPlugin.hasWritePermission();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
tasks.add(new Task(R.string.virtualpump_uploadstatus_title) {
|
tasks.add(new Task(R.string.virtualpump_uploadstatus_title) {
|
||||||
|
@ -64,7 +66,7 @@ public class Objective0 extends Objective {
|
||||||
tasks.add(new Task(R.string.hasbgdata) {
|
tasks.add(new Task(R.string.hasbgdata) {
|
||||||
@Override
|
@Override
|
||||||
public boolean isCompleted() {
|
public boolean isCompleted() {
|
||||||
return DatabaseHelper.lastBg() != null;
|
return iobCobCalculatorPlugin.lastBg() != null;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
tasks.add(new Task(R.string.loopenabled) {
|
tasks.add(new Task(R.string.loopenabled) {
|
||||||
|
|
|
@ -18,6 +18,7 @@ public class Objective3 extends Objective {
|
||||||
@Inject SP sp;
|
@Inject SP sp;
|
||||||
@Inject ObjectivesPlugin objectivesPlugin;
|
@Inject ObjectivesPlugin objectivesPlugin;
|
||||||
@Inject ResourceHelper resourceHelper;
|
@Inject ResourceHelper resourceHelper;
|
||||||
|
@Inject NSClientPlugin nsClientPlugin;
|
||||||
|
|
||||||
private final int MANUAL_ENACTS_NEEDED = 20;
|
private final int MANUAL_ENACTS_NEEDED = 20;
|
||||||
|
|
||||||
|
@ -49,7 +50,7 @@ public class Objective3 extends Objective {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean specialActionEnabled() {
|
public boolean specialActionEnabled() {
|
||||||
return NSClientPlugin.getPlugin().nsClientService.isConnected && NSClientPlugin.getPlugin().nsClientService.hasWriteAuth;
|
return nsClientPlugin.nsClientService.isConnected && nsClientPlugin.nsClientService.hasWriteAuth;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -4,7 +4,7 @@ import java.util.List;
|
||||||
|
|
||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
|
|
||||||
import info.nightscout.androidaps.MainApp;
|
import dagger.android.HasAndroidInjector;
|
||||||
import info.nightscout.androidaps.R;
|
import info.nightscout.androidaps.R;
|
||||||
import info.nightscout.androidaps.interfaces.Constraint;
|
import info.nightscout.androidaps.interfaces.Constraint;
|
||||||
import info.nightscout.androidaps.plugins.constraints.safety.SafetyPlugin;
|
import info.nightscout.androidaps.plugins.constraints.safety.SafetyPlugin;
|
||||||
|
@ -13,9 +13,9 @@ import info.nightscout.androidaps.utils.T;
|
||||||
public class Objective5 extends Objective {
|
public class Objective5 extends Objective {
|
||||||
@Inject SafetyPlugin safetyPlugin;
|
@Inject SafetyPlugin safetyPlugin;
|
||||||
|
|
||||||
public Objective5() {
|
public Objective5(HasAndroidInjector injector) {
|
||||||
super("maxiobzero", R.string.objectives_maxiobzero_objective, R.string.objectives_maxiobzero_gate);
|
super("maxiobzero", R.string.objectives_maxiobzero_objective, R.string.objectives_maxiobzero_gate);
|
||||||
MainApp.instance().androidInjector().inject(this); // TODO inject or pass itno constructor once AutomationPlugin is prepared for Dagger
|
injector.androidInjector().inject(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
package info.nightscout.androidaps.plugins.constraints.safety;
|
package info.nightscout.androidaps.plugins.constraints.safety;
|
||||||
|
|
||||||
|
import androidx.annotation.NonNull;
|
||||||
|
|
||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
import javax.inject.Singleton;
|
import javax.inject.Singleton;
|
||||||
|
|
||||||
|
@ -7,6 +9,7 @@ import info.nightscout.androidaps.Config;
|
||||||
import info.nightscout.androidaps.MainApp;
|
import info.nightscout.androidaps.MainApp;
|
||||||
import info.nightscout.androidaps.R;
|
import info.nightscout.androidaps.R;
|
||||||
import info.nightscout.androidaps.data.Profile;
|
import info.nightscout.androidaps.data.Profile;
|
||||||
|
import info.nightscout.androidaps.interfaces.ActivePluginProvider;
|
||||||
import info.nightscout.androidaps.interfaces.BgSourceInterface;
|
import info.nightscout.androidaps.interfaces.BgSourceInterface;
|
||||||
import info.nightscout.androidaps.interfaces.Constraint;
|
import info.nightscout.androidaps.interfaces.Constraint;
|
||||||
import info.nightscout.androidaps.interfaces.ConstraintsInterface;
|
import info.nightscout.androidaps.interfaces.ConstraintsInterface;
|
||||||
|
@ -19,9 +22,7 @@ import info.nightscout.androidaps.logging.AAPSLogger;
|
||||||
import info.nightscout.androidaps.plugins.aps.openAPSAMA.OpenAPSAMAPlugin;
|
import info.nightscout.androidaps.plugins.aps.openAPSAMA.OpenAPSAMAPlugin;
|
||||||
import info.nightscout.androidaps.plugins.aps.openAPSMA.OpenAPSMAPlugin;
|
import info.nightscout.androidaps.plugins.aps.openAPSMA.OpenAPSMAPlugin;
|
||||||
import info.nightscout.androidaps.plugins.aps.openAPSSMB.OpenAPSSMBPlugin;
|
import info.nightscout.androidaps.plugins.aps.openAPSSMB.OpenAPSSMBPlugin;
|
||||||
import info.nightscout.androidaps.plugins.bus.RxBus;
|
|
||||||
import info.nightscout.androidaps.plugins.bus.RxBusWrapper;
|
import info.nightscout.androidaps.plugins.bus.RxBusWrapper;
|
||||||
import info.nightscout.androidaps.plugins.configBuilder.ConfigBuilderPlugin;
|
|
||||||
import info.nightscout.androidaps.plugins.configBuilder.ConstraintChecker;
|
import info.nightscout.androidaps.plugins.configBuilder.ConstraintChecker;
|
||||||
import info.nightscout.androidaps.plugins.general.overview.events.EventNewNotification;
|
import info.nightscout.androidaps.plugins.general.overview.events.EventNewNotification;
|
||||||
import info.nightscout.androidaps.plugins.general.overview.notifications.Notification;
|
import info.nightscout.androidaps.plugins.general.overview.notifications.Notification;
|
||||||
|
@ -29,132 +30,133 @@ import info.nightscout.androidaps.plugins.sensitivity.SensitivityOref1Plugin;
|
||||||
import info.nightscout.androidaps.utils.DecimalFormatter;
|
import info.nightscout.androidaps.utils.DecimalFormatter;
|
||||||
import info.nightscout.androidaps.utils.HardLimits;
|
import info.nightscout.androidaps.utils.HardLimits;
|
||||||
import info.nightscout.androidaps.utils.Round;
|
import info.nightscout.androidaps.utils.Round;
|
||||||
import info.nightscout.androidaps.utils.SP;
|
import info.nightscout.androidaps.utils.resources.ResourceHelper;
|
||||||
|
import info.nightscout.androidaps.utils.sharedPreferences.SP;
|
||||||
|
|
||||||
@Singleton
|
@Singleton
|
||||||
public class SafetyPlugin extends PluginBase implements ConstraintsInterface {
|
public class SafetyPlugin extends PluginBase implements ConstraintsInterface {
|
||||||
|
|
||||||
// TODO: dagger
|
// TODO: dagger
|
||||||
|
@Inject SP sp;
|
||||||
|
@Inject RxBusWrapper rxBus;
|
||||||
|
@Inject ResourceHelper resourceHelper;
|
||||||
|
@Inject ConstraintChecker constraintChecker;
|
||||||
|
@Inject OpenAPSAMAPlugin openAPSAMAPlugin;
|
||||||
|
@Inject OpenAPSMAPlugin openAPSMAPlugin;
|
||||||
|
@Inject OpenAPSSMBPlugin openAPSSMBPlugin;
|
||||||
|
@Inject SensitivityOref1Plugin sensitivityOref1Plugin;
|
||||||
|
@Inject ActivePluginProvider activePlugin;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
OpenAPSAMAPlugin openAPSAMAPlugin;
|
public SafetyPlugin(AAPSLogger aapsLogger, ResourceHelper resourceHelper) {
|
||||||
|
|
||||||
@Inject
|
|
||||||
OpenAPSMAPlugin openAPSMAPlugin;
|
|
||||||
|
|
||||||
@Inject
|
|
||||||
OpenAPSSMBPlugin openAPSSMBPlugin;
|
|
||||||
|
|
||||||
@Inject
|
|
||||||
public SafetyPlugin(RxBusWrapper rxBusWrapper, AAPSLogger aapsLogger) {
|
|
||||||
super(new PluginDescription()
|
super(new PluginDescription()
|
||||||
.mainType(PluginType.CONSTRAINTS)
|
.mainType(PluginType.CONSTRAINTS)
|
||||||
.neverVisible(true)
|
.neverVisible(true)
|
||||||
.alwaysEnabled(true)
|
.alwaysEnabled(true)
|
||||||
.showInList(false)
|
.showInList(false)
|
||||||
.pluginName(R.string.safety)
|
.pluginName(R.string.safety)
|
||||||
.preferencesId(R.xml.pref_safety), rxBusWrapper, aapsLogger
|
.preferencesId(R.xml.pref_safety), aapsLogger, resourceHelper
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constraints interface
|
* Constraints interface
|
||||||
**/
|
**/
|
||||||
@Override
|
@NonNull @Override
|
||||||
public Constraint<Boolean> isLoopInvocationAllowed(Constraint<Boolean> value) {
|
public Constraint<Boolean> isLoopInvocationAllowed(@NonNull Constraint<Boolean> value) {
|
||||||
if (!ConfigBuilderPlugin.getPlugin().getActivePump().getPumpDescription().isTempBasalCapable)
|
if (!activePlugin.getActivePumpPlugin().getPumpDescription().isTempBasalCapable)
|
||||||
value.set(false, MainApp.gs(R.string.pumpisnottempbasalcapable), this);
|
value.set(false, resourceHelper.gs(R.string.pumpisnottempbasalcapable), this);
|
||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@NonNull @Override
|
||||||
public Constraint<Boolean> isClosedLoopAllowed(Constraint<Boolean> value) {
|
public Constraint<Boolean> isClosedLoopAllowed(@NonNull Constraint<Boolean> value) {
|
||||||
String mode = SP.getString(R.string.key_aps_mode, "open");
|
String mode = sp.getString(R.string.key_aps_mode, "open");
|
||||||
if (!mode.equals("closed"))
|
if (!mode.equals("closed"))
|
||||||
value.set(false, MainApp.gs(R.string.closedmodedisabledinpreferences), this);
|
value.set(false, resourceHelper.gs(R.string.closedmodedisabledinpreferences), this);
|
||||||
|
|
||||||
if (!MainApp.isEngineeringModeOrRelease()) {
|
if (!MainApp.isEngineeringModeOrRelease()) {
|
||||||
if (value.value()) {
|
if (value.value()) {
|
||||||
Notification n = new Notification(Notification.TOAST_ALARM, MainApp.gs(R.string.closed_loop_disabled_on_dev_branch), Notification.NORMAL);
|
Notification n = new Notification(Notification.TOAST_ALARM, resourceHelper.gs(R.string.closed_loop_disabled_on_dev_branch), Notification.NORMAL);
|
||||||
RxBus.Companion.getINSTANCE().send(new EventNewNotification(n));
|
rxBus.send(new EventNewNotification(n));
|
||||||
}
|
}
|
||||||
value.set(false, MainApp.gs(R.string.closed_loop_disabled_on_dev_branch), this);
|
value.set(false, resourceHelper.gs(R.string.closed_loop_disabled_on_dev_branch), this);
|
||||||
}
|
}
|
||||||
|
|
||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@NonNull @Override
|
||||||
public Constraint<Boolean> isAutosensModeEnabled(Constraint<Boolean> value) {
|
public Constraint<Boolean> isAutosensModeEnabled(@NonNull Constraint<Boolean> value) {
|
||||||
boolean enabled = SP.getBoolean(R.string.key_openapsama_useautosens, false);
|
boolean enabled = sp.getBoolean(R.string.key_openapsama_useautosens, false);
|
||||||
if (!enabled)
|
if (!enabled)
|
||||||
value.set(false, MainApp.gs(R.string.autosensdisabledinpreferences), this);
|
value.set(false, resourceHelper.gs(R.string.autosensdisabledinpreferences), this);
|
||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@NonNull @Override
|
||||||
public Constraint<Boolean> isSMBModeEnabled(Constraint<Boolean> value) {
|
public Constraint<Boolean> isSMBModeEnabled(@NonNull Constraint<Boolean> value) {
|
||||||
boolean enabled = SP.getBoolean(R.string.key_use_smb, false);
|
boolean enabled = sp.getBoolean(R.string.key_use_smb, false);
|
||||||
if (!enabled)
|
if (!enabled)
|
||||||
value.set(false, MainApp.gs(R.string.smbdisabledinpreferences), this);
|
value.set(false, resourceHelper.gs(R.string.smbdisabledinpreferences), this);
|
||||||
Constraint<Boolean> closedLoop = ConstraintChecker.getInstance().isClosedLoopAllowed();
|
Constraint<Boolean> closedLoop = constraintChecker.isClosedLoopAllowed();
|
||||||
if (!closedLoop.value())
|
if (!closedLoop.value())
|
||||||
value.set(false, MainApp.gs(R.string.smbnotallowedinopenloopmode), this);
|
value.set(false, resourceHelper.gs(R.string.smbnotallowedinopenloopmode), this);
|
||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@NonNull @Override
|
||||||
public Constraint<Boolean> isUAMEnabled(Constraint<Boolean> value) {
|
public Constraint<Boolean> isUAMEnabled(@NonNull Constraint<Boolean> value) {
|
||||||
boolean enabled = SP.getBoolean(R.string.key_use_uam, false);
|
boolean enabled = sp.getBoolean(R.string.key_use_uam, false);
|
||||||
if (!enabled)
|
if (!enabled)
|
||||||
value.set(false, MainApp.gs(R.string.uamdisabledinpreferences), this);
|
value.set(false, resourceHelper.gs(R.string.uamdisabledinpreferences), this);
|
||||||
boolean oref1Enabled = SensitivityOref1Plugin.getPlugin().isEnabled(PluginType.SENSITIVITY);
|
boolean oref1Enabled = sensitivityOref1Plugin.isEnabled(PluginType.SENSITIVITY);
|
||||||
if (!oref1Enabled)
|
if (!oref1Enabled)
|
||||||
value.set(false, MainApp.gs(R.string.uamdisabledoref1notselected), this);
|
value.set(false, resourceHelper.gs(R.string.uamdisabledoref1notselected), this);
|
||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@NonNull @Override
|
||||||
public Constraint<Boolean> isAdvancedFilteringEnabled(Constraint<Boolean> value) {
|
public Constraint<Boolean> isAdvancedFilteringEnabled(@NonNull Constraint<Boolean> value) {
|
||||||
BgSourceInterface bgSource = ConfigBuilderPlugin.getPlugin().getActiveBgSource();
|
BgSourceInterface bgSource = activePlugin.getActiveBgSource();
|
||||||
|
|
||||||
if (bgSource != null) {
|
if (bgSource != null) {
|
||||||
if (!bgSource.advancedFilteringSupported())
|
if (!bgSource.advancedFilteringSupported())
|
||||||
value.set(false, MainApp.gs(R.string.smbalwaysdisabled), this);
|
value.set(false, resourceHelper.gs(R.string.smbalwaysdisabled), this);
|
||||||
}
|
}
|
||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@NonNull @Override
|
||||||
public Constraint<Double> applyBasalConstraints(Constraint<Double> absoluteRate, Profile profile) {
|
public Constraint<Double> applyBasalConstraints(Constraint<Double> absoluteRate, @NonNull Profile profile) {
|
||||||
|
|
||||||
absoluteRate.setIfGreater(0d, String.format(MainApp.gs(R.string.limitingbasalratio), 0d, MainApp.gs(R.string.itmustbepositivevalue)), this);
|
absoluteRate.setIfGreater(0d, String.format(resourceHelper.gs(R.string.limitingbasalratio), 0d, resourceHelper.gs(R.string.itmustbepositivevalue)), this);
|
||||||
|
|
||||||
if (Config.APS) {
|
if (Config.APS) {
|
||||||
double maxBasal = SP.getDouble(R.string.key_openapsma_max_basal, 1d);
|
double maxBasal = sp.getDouble(R.string.key_openapsma_max_basal, 1d);
|
||||||
if (maxBasal < profile.getMaxDailyBasal()) {
|
if (maxBasal < profile.getMaxDailyBasal()) {
|
||||||
maxBasal = profile.getMaxDailyBasal();
|
maxBasal = profile.getMaxDailyBasal();
|
||||||
absoluteRate.addReason(MainApp.gs(R.string.increasingmaxbasal), this);
|
absoluteRate.addReason(resourceHelper.gs(R.string.increasingmaxbasal), this);
|
||||||
}
|
}
|
||||||
absoluteRate.setIfSmaller(maxBasal, String.format(MainApp.gs(R.string.limitingbasalratio), maxBasal, MainApp.gs(R.string.maxvalueinpreferences)), this);
|
absoluteRate.setIfSmaller(maxBasal, String.format(resourceHelper.gs(R.string.limitingbasalratio), maxBasal, resourceHelper.gs(R.string.maxvalueinpreferences)), this);
|
||||||
|
|
||||||
// Check percentRate but absolute rate too, because we know real current basal in pump
|
// Check percentRate but absolute rate too, because we know real current basal in pump
|
||||||
Double maxBasalMult = SP.getDouble(R.string.key_openapsama_current_basal_safety_multiplier, 4d);
|
Double maxBasalMult = sp.getDouble(R.string.key_openapsama_current_basal_safety_multiplier, 4d);
|
||||||
double maxFromBasalMult = Math.floor(maxBasalMult * profile.getBasal() * 100) / 100;
|
double maxFromBasalMult = Math.floor(maxBasalMult * profile.getBasal() * 100) / 100;
|
||||||
absoluteRate.setIfSmaller(maxFromBasalMult, String.format(MainApp.gs(R.string.limitingbasalratio), maxFromBasalMult, MainApp.gs(R.string.maxbasalmultiplier)), this);
|
absoluteRate.setIfSmaller(maxFromBasalMult, String.format(resourceHelper.gs(R.string.limitingbasalratio), maxFromBasalMult, resourceHelper.gs(R.string.maxbasalmultiplier)), this);
|
||||||
|
|
||||||
Double maxBasalFromDaily = SP.getDouble(R.string.key_openapsama_max_daily_safety_multiplier, 3d);
|
Double maxBasalFromDaily = sp.getDouble(R.string.key_openapsama_max_daily_safety_multiplier, 3d);
|
||||||
double maxFromDaily = Math.floor(profile.getMaxDailyBasal() * maxBasalFromDaily * 100) / 100;
|
double maxFromDaily = Math.floor(profile.getMaxDailyBasal() * maxBasalFromDaily * 100) / 100;
|
||||||
absoluteRate.setIfSmaller(maxFromDaily, String.format(MainApp.gs(R.string.limitingbasalratio), maxFromDaily, MainApp.gs(R.string.maxdailybasalmultiplier)), this);
|
absoluteRate.setIfSmaller(maxFromDaily, String.format(resourceHelper.gs(R.string.limitingbasalratio), maxFromDaily, resourceHelper.gs(R.string.maxdailybasalmultiplier)), this);
|
||||||
}
|
}
|
||||||
|
|
||||||
absoluteRate.setIfSmaller(HardLimits.maxBasal(), String.format(MainApp.gs(R.string.limitingbasalratio), HardLimits.maxBasal(), MainApp.gs(R.string.hardlimit)), this);
|
absoluteRate.setIfSmaller(HardLimits.maxBasal(), String.format(resourceHelper.gs(R.string.limitingbasalratio), HardLimits.maxBasal(), resourceHelper.gs(R.string.hardlimit)), this);
|
||||||
|
|
||||||
PumpInterface pump = ConfigBuilderPlugin.getPlugin().getActivePump();
|
PumpInterface pump = activePlugin.getActivePumpPlugin();
|
||||||
// check for pump max
|
// check for pump max
|
||||||
if (pump != null && pump.getPumpDescription().tempBasalStyle == PumpDescription.ABSOLUTE) {
|
if (pump != null && pump.getPumpDescription().tempBasalStyle == PumpDescription.ABSOLUTE) {
|
||||||
double pumpLimit = pump.getPumpDescription().pumpType.getTbrSettings().getMaxDose();
|
double pumpLimit = pump.getPumpDescription().pumpType.getTbrSettings().getMaxDose();
|
||||||
absoluteRate.setIfSmaller(pumpLimit, String.format(MainApp.gs(R.string.limitingbasalratio), pumpLimit, MainApp.gs(R.string.pumplimit)), this);
|
absoluteRate.setIfSmaller(pumpLimit, String.format(resourceHelper.gs(R.string.limitingbasalratio), pumpLimit, resourceHelper.gs(R.string.pumplimit)), this);
|
||||||
}
|
}
|
||||||
|
|
||||||
// do rounding
|
// do rounding
|
||||||
|
@ -164,7 +166,7 @@ public class SafetyPlugin extends PluginBase implements ConstraintsInterface {
|
||||||
return absoluteRate;
|
return absoluteRate;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@NonNull @Override
|
||||||
public Constraint<Integer> applyBasalPercentConstraints(Constraint<Integer> percentRate, Profile profile) {
|
public Constraint<Integer> applyBasalPercentConstraints(Constraint<Integer> percentRate, Profile profile) {
|
||||||
|
|
||||||
Double currentBasal = profile.getBasal();
|
Double currentBasal = profile.getBasal();
|
||||||
|
@ -176,7 +178,7 @@ public class SafetyPlugin extends PluginBase implements ConstraintsInterface {
|
||||||
applyBasalConstraints(absoluteConstraint, profile);
|
applyBasalConstraints(absoluteConstraint, profile);
|
||||||
percentRate.copyReasons(absoluteConstraint);
|
percentRate.copyReasons(absoluteConstraint);
|
||||||
|
|
||||||
PumpInterface pump = ConfigBuilderPlugin.getPlugin().getActivePump();
|
PumpInterface pump = activePlugin.getActivePumpPlugin();
|
||||||
|
|
||||||
Integer percentRateAfterConst = Double.valueOf(absoluteConstraint.value() / currentBasal * 100).intValue();
|
Integer percentRateAfterConst = Double.valueOf(absoluteConstraint.value() / currentBasal * 100).intValue();
|
||||||
if (pump != null) {
|
if (pump != null) {
|
||||||
|
@ -186,75 +188,75 @@ public class SafetyPlugin extends PluginBase implements ConstraintsInterface {
|
||||||
percentRateAfterConst = Round.floorTo((double) percentRateAfterConst, (double) pump.getPumpDescription().tempPercentStep).intValue();
|
percentRateAfterConst = Round.floorTo((double) percentRateAfterConst, (double) pump.getPumpDescription().tempPercentStep).intValue();
|
||||||
}
|
}
|
||||||
|
|
||||||
percentRate.set(percentRateAfterConst, String.format(MainApp.gs(R.string.limitingpercentrate), percentRateAfterConst, MainApp.gs(R.string.pumplimit)), this);
|
percentRate.set(percentRateAfterConst, String.format(resourceHelper.gs(R.string.limitingpercentrate), percentRateAfterConst, resourceHelper.gs(R.string.pumplimit)), this);
|
||||||
|
|
||||||
if (pump != null && pump.getPumpDescription().tempBasalStyle == PumpDescription.PERCENT) {
|
if (pump != null && pump.getPumpDescription().tempBasalStyle == PumpDescription.PERCENT) {
|
||||||
double pumpLimit = pump.getPumpDescription().pumpType.getTbrSettings().getMaxDose();
|
double pumpLimit = pump.getPumpDescription().pumpType.getTbrSettings().getMaxDose();
|
||||||
percentRate.setIfSmaller((int) pumpLimit, String.format(MainApp.gs(R.string.limitingbasalratio), pumpLimit, MainApp.gs(R.string.pumplimit)), this);
|
percentRate.setIfSmaller((int) pumpLimit, String.format(resourceHelper.gs(R.string.limitingbasalratio), pumpLimit, resourceHelper.gs(R.string.pumplimit)), this);
|
||||||
}
|
}
|
||||||
|
|
||||||
return percentRate;
|
return percentRate;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@NonNull @Override
|
||||||
public Constraint<Double> applyBolusConstraints(Constraint<Double> insulin) {
|
public Constraint<Double> applyBolusConstraints(Constraint<Double> insulin) {
|
||||||
insulin.setIfGreater(0d, String.format(MainApp.gs(R.string.limitingbolus), 0d, MainApp.gs(R.string.itmustbepositivevalue)), this);
|
insulin.setIfGreater(0d, String.format(resourceHelper.gs(R.string.limitingbolus), 0d, resourceHelper.gs(R.string.itmustbepositivevalue)), this);
|
||||||
|
|
||||||
Double maxBolus = SP.getDouble(R.string.key_treatmentssafety_maxbolus, 3d);
|
Double maxBolus = sp.getDouble(R.string.key_treatmentssafety_maxbolus, 3d);
|
||||||
insulin.setIfSmaller(maxBolus, String.format(MainApp.gs(R.string.limitingbolus), maxBolus, MainApp.gs(R.string.maxvalueinpreferences)), this);
|
insulin.setIfSmaller(maxBolus, String.format(resourceHelper.gs(R.string.limitingbolus), maxBolus, resourceHelper.gs(R.string.maxvalueinpreferences)), this);
|
||||||
|
|
||||||
insulin.setIfSmaller(HardLimits.maxBolus(), String.format(MainApp.gs(R.string.limitingbolus), HardLimits.maxBolus(), MainApp.gs(R.string.hardlimit)), this);
|
insulin.setIfSmaller(HardLimits.maxBolus(), String.format(resourceHelper.gs(R.string.limitingbolus), HardLimits.maxBolus(), resourceHelper.gs(R.string.hardlimit)), this);
|
||||||
|
|
||||||
PumpInterface pump = ConfigBuilderPlugin.getPlugin().getActivePump();
|
PumpInterface pump = activePlugin.getActivePumpPlugin();
|
||||||
if (pump != null) {
|
if (pump != null) {
|
||||||
double rounded = pump.getPumpDescription().pumpType.determineCorrectBolusSize(insulin.value());
|
double rounded = pump.getPumpDescription().pumpType.determineCorrectBolusSize(insulin.value());
|
||||||
insulin.setIfDifferent(rounded, MainApp.gs(R.string.pumplimit), this);
|
insulin.setIfDifferent(rounded, resourceHelper.gs(R.string.pumplimit), this);
|
||||||
}
|
}
|
||||||
return insulin;
|
return insulin;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@NonNull @Override
|
||||||
public Constraint<Double> applyExtendedBolusConstraints(Constraint<Double> insulin) {
|
public Constraint<Double> applyExtendedBolusConstraints(Constraint<Double> insulin) {
|
||||||
insulin.setIfGreater(0d, String.format(MainApp.gs(R.string.limitingextendedbolus), 0d, MainApp.gs(R.string.itmustbepositivevalue)), this);
|
insulin.setIfGreater(0d, String.format(resourceHelper.gs(R.string.limitingextendedbolus), 0d, resourceHelper.gs(R.string.itmustbepositivevalue)), this);
|
||||||
|
|
||||||
Double maxBolus = SP.getDouble(R.string.key_treatmentssafety_maxbolus, 3d);
|
Double maxBolus = sp.getDouble(R.string.key_treatmentssafety_maxbolus, 3d);
|
||||||
insulin.setIfSmaller(maxBolus, String.format(MainApp.gs(R.string.limitingextendedbolus), maxBolus, MainApp.gs(R.string.maxvalueinpreferences)), this);
|
insulin.setIfSmaller(maxBolus, String.format(resourceHelper.gs(R.string.limitingextendedbolus), maxBolus, resourceHelper.gs(R.string.maxvalueinpreferences)), this);
|
||||||
|
|
||||||
insulin.setIfSmaller(HardLimits.maxBolus(), String.format(MainApp.gs(R.string.limitingextendedbolus), HardLimits.maxBolus(), MainApp.gs(R.string.hardlimit)), this);
|
insulin.setIfSmaller(HardLimits.maxBolus(), String.format(resourceHelper.gs(R.string.limitingextendedbolus), HardLimits.maxBolus(), resourceHelper.gs(R.string.hardlimit)), this);
|
||||||
|
|
||||||
PumpInterface pump = ConfigBuilderPlugin.getPlugin().getActivePump();
|
PumpInterface pump = activePlugin.getActivePumpPlugin();
|
||||||
if (pump != null) {
|
if (pump != null) {
|
||||||
double rounded = pump.getPumpDescription().pumpType.determineCorrectExtendedBolusSize(insulin.value());
|
double rounded = pump.getPumpDescription().pumpType.determineCorrectExtendedBolusSize(insulin.value());
|
||||||
insulin.setIfDifferent(rounded, MainApp.gs(R.string.pumplimit), this);
|
insulin.setIfDifferent(rounded, resourceHelper.gs(R.string.pumplimit), this);
|
||||||
}
|
}
|
||||||
return insulin;
|
return insulin;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@NonNull @Override
|
||||||
public Constraint<Integer> applyCarbsConstraints(Constraint<Integer> carbs) {
|
public Constraint<Integer> applyCarbsConstraints(Constraint<Integer> carbs) {
|
||||||
carbs.setIfGreater(0, String.format(MainApp.gs(R.string.limitingcarbs), 0, MainApp.gs(R.string.itmustbepositivevalue)), this);
|
carbs.setIfGreater(0, String.format(resourceHelper.gs(R.string.limitingcarbs), 0, resourceHelper.gs(R.string.itmustbepositivevalue)), this);
|
||||||
|
|
||||||
Integer maxCarbs = SP.getInt(R.string.key_treatmentssafety_maxcarbs, 48);
|
Integer maxCarbs = sp.getInt(R.string.key_treatmentssafety_maxcarbs, 48);
|
||||||
carbs.setIfSmaller(maxCarbs, String.format(MainApp.gs(R.string.limitingcarbs), maxCarbs, MainApp.gs(R.string.maxvalueinpreferences)), this);
|
carbs.setIfSmaller(maxCarbs, String.format(resourceHelper.gs(R.string.limitingcarbs), maxCarbs, resourceHelper.gs(R.string.maxvalueinpreferences)), this);
|
||||||
|
|
||||||
return carbs;
|
return carbs;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@NonNull @Override
|
||||||
public Constraint<Double> applyMaxIOBConstraints(Constraint<Double> maxIob) {
|
public Constraint<Double> applyMaxIOBConstraints(@NonNull Constraint<Double> maxIob) {
|
||||||
double maxIobPref;
|
double maxIobPref;
|
||||||
if (openAPSSMBPlugin.isEnabled(PluginType.APS))
|
if (openAPSSMBPlugin.isEnabled(PluginType.APS))
|
||||||
maxIobPref = SP.getDouble(R.string.key_openapssmb_max_iob, 3d);
|
maxIobPref = sp.getDouble(R.string.key_openapssmb_max_iob, 3d);
|
||||||
else
|
else
|
||||||
maxIobPref = SP.getDouble(R.string.key_openapsma_max_iob, 1.5d);
|
maxIobPref = sp.getDouble(R.string.key_openapsma_max_iob, 1.5d);
|
||||||
maxIob.setIfSmaller(maxIobPref, String.format(MainApp.gs(R.string.limitingiob), maxIobPref, MainApp.gs(R.string.maxvalueinpreferences)), this);
|
maxIob.setIfSmaller(maxIobPref, String.format(resourceHelper.gs(R.string.limitingiob), maxIobPref, resourceHelper.gs(R.string.maxvalueinpreferences)), this);
|
||||||
|
|
||||||
if (openAPSMAPlugin.isEnabled(PluginType.APS))
|
if (openAPSMAPlugin.isEnabled(PluginType.APS))
|
||||||
maxIob.setIfSmaller(HardLimits.maxIobAMA(), String.format(MainApp.gs(R.string.limitingiob), HardLimits.maxIobAMA(), MainApp.gs(R.string.hardlimit)), this);
|
maxIob.setIfSmaller(HardLimits.maxIobAMA(), String.format(resourceHelper.gs(R.string.limitingiob), HardLimits.maxIobAMA(), resourceHelper.gs(R.string.hardlimit)), this);
|
||||||
if (openAPSAMAPlugin.isEnabled(PluginType.APS))
|
if (openAPSAMAPlugin.isEnabled(PluginType.APS))
|
||||||
maxIob.setIfSmaller(HardLimits.maxIobAMA(), String.format(MainApp.gs(R.string.limitingiob), HardLimits.maxIobAMA(), MainApp.gs(R.string.hardlimit)), this);
|
maxIob.setIfSmaller(HardLimits.maxIobAMA(), String.format(resourceHelper.gs(R.string.limitingiob), HardLimits.maxIobAMA(), resourceHelper.gs(R.string.hardlimit)), this);
|
||||||
if (openAPSSMBPlugin.isEnabled(PluginType.APS))
|
if (openAPSSMBPlugin.isEnabled(PluginType.APS))
|
||||||
maxIob.setIfSmaller(HardLimits.maxIobSMB(), String.format(MainApp.gs(R.string.limitingiob), HardLimits.maxIobSMB(), MainApp.gs(R.string.hardlimit)), this);
|
maxIob.setIfSmaller(HardLimits.maxIobSMB(), String.format(resourceHelper.gs(R.string.limitingiob), HardLimits.maxIobSMB(), resourceHelper.gs(R.string.hardlimit)), this);
|
||||||
return maxIob;
|
return maxIob;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
package info.nightscout.androidaps.plugins.constraints.signatureVerifier
|
package info.nightscout.androidaps.plugins.constraints.signatureVerifier
|
||||||
|
|
||||||
|
import android.content.Context
|
||||||
import android.content.pm.PackageManager
|
import android.content.pm.PackageManager
|
||||||
import info.nightscout.androidaps.MainApp
|
|
||||||
import info.nightscout.androidaps.R
|
import info.nightscout.androidaps.R
|
||||||
import info.nightscout.androidaps.interfaces.Constraint
|
import info.nightscout.androidaps.interfaces.Constraint
|
||||||
import info.nightscout.androidaps.interfaces.ConstraintsInterface
|
import info.nightscout.androidaps.interfaces.ConstraintsInterface
|
||||||
|
@ -34,17 +34,18 @@ import javax.inject.Singleton
|
||||||
*/
|
*/
|
||||||
@Singleton
|
@Singleton
|
||||||
class SignatureVerifierPlugin @Inject constructor(
|
class SignatureVerifierPlugin @Inject constructor(
|
||||||
|
aapsLogger: AAPSLogger,
|
||||||
|
resourceHelper: ResourceHelper,
|
||||||
private val sp: SP,
|
private val sp: SP,
|
||||||
private val resourceHelper: ResourceHelper,
|
private val rxBus: RxBusWrapper,
|
||||||
private val mainApp: MainApp,
|
private val context: Context
|
||||||
rxBus: RxBusWrapper, aapsLogger: AAPSLogger
|
|
||||||
) : PluginBase(PluginDescription()
|
) : PluginBase(PluginDescription()
|
||||||
.mainType(PluginType.CONSTRAINTS)
|
.mainType(PluginType.CONSTRAINTS)
|
||||||
.neverVisible(true)
|
.neverVisible(true)
|
||||||
.alwaysEnabled(true)
|
.alwaysEnabled(true)
|
||||||
.showInList(false)
|
.showInList(false)
|
||||||
.pluginName(R.string.signature_verifier),
|
.pluginName(R.string.signature_verifier),
|
||||||
rxBus, aapsLogger
|
aapsLogger, resourceHelper
|
||||||
), ConstraintsInterface {
|
), ConstraintsInterface {
|
||||||
|
|
||||||
private val REVOKED_CERTS_URL = "https://raw.githubusercontent.com/MilosKozak/AndroidAPS/master/app/src/main/assets/revoked_certs.txt"
|
private val REVOKED_CERTS_URL = "https://raw.githubusercontent.com/MilosKozak/AndroidAPS/master/app/src/main/assets/revoked_certs.txt"
|
||||||
|
@ -56,7 +57,7 @@ class SignatureVerifierPlugin @Inject constructor(
|
||||||
private var revokedCerts: List<ByteArray>? = null
|
private var revokedCerts: List<ByteArray>? = null
|
||||||
override fun onStart() {
|
override fun onStart() {
|
||||||
super.onStart()
|
super.onStart()
|
||||||
revokedCertsFile = File(mainApp.filesDir, "revoked_certs.txt")
|
revokedCertsFile = File(context.filesDir, "revoked_certs.txt")
|
||||||
Thread(Runnable {
|
Thread(Runnable {
|
||||||
loadLocalRevokedCerts()
|
loadLocalRevokedCerts()
|
||||||
if (shouldDownloadCerts()) {
|
if (shouldDownloadCerts()) {
|
||||||
|
@ -98,7 +99,7 @@ class SignatureVerifierPlugin @Inject constructor(
|
||||||
if (revokedCerts == null) return false
|
if (revokedCerts == null) return false
|
||||||
// TODO Change after raising min API to 28
|
// TODO Change after raising min API to 28
|
||||||
@Suppress("DEPRECATION", "PackageManagerGetSignatures")
|
@Suppress("DEPRECATION", "PackageManagerGetSignatures")
|
||||||
val signatures = mainApp.packageManager.getPackageInfo(mainApp.packageName, PackageManager.GET_SIGNATURES).signatures
|
val signatures = context.packageManager.getPackageInfo(context.packageName, PackageManager.GET_SIGNATURES).signatures
|
||||||
if (signatures != null) {
|
if (signatures != null) {
|
||||||
for (signature in signatures) {
|
for (signature in signatures) {
|
||||||
val digest = MessageDigest.getInstance("SHA256")
|
val digest = MessageDigest.getInstance("SHA256")
|
||||||
|
@ -124,7 +125,7 @@ class SignatureVerifierPlugin @Inject constructor(
|
||||||
try {
|
try {
|
||||||
// TODO Change after raising min API to 28
|
// TODO Change after raising min API to 28
|
||||||
@Suppress("DEPRECATION", "PackageManagerGetSignatures")
|
@Suppress("DEPRECATION", "PackageManagerGetSignatures")
|
||||||
val signatures = mainApp.packageManager.getPackageInfo(mainApp.packageName, PackageManager.GET_SIGNATURES).signatures
|
val signatures = context.packageManager.getPackageInfo(context.packageName, PackageManager.GET_SIGNATURES).signatures
|
||||||
if (signatures != null) {
|
if (signatures != null) {
|
||||||
for (signature in signatures) {
|
for (signature in signatures) {
|
||||||
val digest = MessageDigest.getInstance("SHA256")
|
val digest = MessageDigest.getInstance("SHA256")
|
||||||
|
@ -212,7 +213,7 @@ class SignatureVerifierPlugin @Inject constructor(
|
||||||
}
|
}
|
||||||
|
|
||||||
@Throws(IOException::class) private fun readRevokedCertsInAssets(): String {
|
@Throws(IOException::class) private fun readRevokedCertsInAssets(): String {
|
||||||
val inputStream = mainApp.assets.open("revoked_certs.txt")
|
val inputStream = context.assets.open("revoked_certs.txt")
|
||||||
return readInputStream(inputStream)
|
return readInputStream(inputStream)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,83 +0,0 @@
|
||||||
package info.nightscout.androidaps.plugins.constraints.storage;
|
|
||||||
|
|
||||||
import android.os.Environment;
|
|
||||||
import android.os.StatFs;
|
|
||||||
|
|
||||||
import org.slf4j.Logger;
|
|
||||||
import org.slf4j.LoggerFactory;
|
|
||||||
|
|
||||||
import java.io.File;
|
|
||||||
|
|
||||||
import info.nightscout.androidaps.Constants;
|
|
||||||
import info.nightscout.androidaps.MainApp;
|
|
||||||
import info.nightscout.androidaps.R;
|
|
||||||
import info.nightscout.androidaps.interfaces.Constraint;
|
|
||||||
import info.nightscout.androidaps.interfaces.ConstraintsInterface;
|
|
||||||
import info.nightscout.androidaps.interfaces.PluginBase;
|
|
||||||
import info.nightscout.androidaps.interfaces.PluginDescription;
|
|
||||||
import info.nightscout.androidaps.interfaces.PluginType;
|
|
||||||
import info.nightscout.androidaps.logging.AAPSLoggerProduction;
|
|
||||||
import info.nightscout.androidaps.logging.L;
|
|
||||||
import info.nightscout.androidaps.plugins.bus.RxBus;
|
|
||||||
import info.nightscout.androidaps.plugins.bus.RxBusWrapper;
|
|
||||||
import info.nightscout.androidaps.plugins.general.overview.events.EventDismissNotification;
|
|
||||||
import info.nightscout.androidaps.plugins.general.overview.events.EventNewNotification;
|
|
||||||
import info.nightscout.androidaps.plugins.general.overview.notifications.Notification;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Created by Rumen on 06.03.2019.
|
|
||||||
*/
|
|
||||||
public class StorageConstraintPlugin extends PluginBase implements ConstraintsInterface {
|
|
||||||
private static Logger log = LoggerFactory.getLogger(L.CONSTRAINTS);
|
|
||||||
static StorageConstraintPlugin plugin = null;
|
|
||||||
|
|
||||||
@Deprecated
|
|
||||||
public static StorageConstraintPlugin getPlugin() {
|
|
||||||
if (plugin == null)
|
|
||||||
plugin = new StorageConstraintPlugin();
|
|
||||||
return plugin;
|
|
||||||
}
|
|
||||||
|
|
||||||
// TODO: dagger
|
|
||||||
|
|
||||||
public StorageConstraintPlugin() {
|
|
||||||
super(new PluginDescription()
|
|
||||||
.mainType(PluginType.CONSTRAINTS)
|
|
||||||
.neverVisible(true)
|
|
||||||
.alwaysEnabled(true)
|
|
||||||
.showInList(false)
|
|
||||||
.pluginName(R.string.storage),
|
|
||||||
new RxBusWrapper(), new AAPSLoggerProduction() // TODO: dagger
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Constraints interface
|
|
||||||
**/
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Constraint<Boolean> isClosedLoopAllowed(Constraint<Boolean> value) {
|
|
||||||
long diskfree = getAvailableInternalMemorySize();
|
|
||||||
if (L.isEnabled(L.CONSTRAINTS))
|
|
||||||
log.debug("Internal storage free (Mb):" + diskfree);
|
|
||||||
if (diskfree < Constants.MINIMUM_FREE_SPACE) {
|
|
||||||
value.set(false, MainApp.gs(R.string.diskfull, Constants.MINIMUM_FREE_SPACE), this);
|
|
||||||
Notification notification = new Notification(Notification.DISKFULL, MainApp.gs(R.string.diskfull, Constants.MINIMUM_FREE_SPACE), Notification.NORMAL);
|
|
||||||
RxBus.Companion.getINSTANCE().send(new EventNewNotification(notification));
|
|
||||||
} else {
|
|
||||||
RxBus.Companion.getINSTANCE().send(new EventDismissNotification(Notification.DISKFULL));
|
|
||||||
}
|
|
||||||
|
|
||||||
return value;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static long getAvailableInternalMemorySize() {
|
|
||||||
File path = Environment.getDataDirectory();
|
|
||||||
StatFs stat = new StatFs(path.getPath());
|
|
||||||
long blockSize = stat.getBlockSizeLong();
|
|
||||||
long blocksAvailable = stat.getAvailableBlocksLong();
|
|
||||||
int size = 1048576; // blocksize of 1 Mb
|
|
||||||
return ((blocksAvailable * blockSize) / size);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -0,0 +1,58 @@
|
||||||
|
package info.nightscout.androidaps.plugins.constraints.storage
|
||||||
|
|
||||||
|
import android.os.Environment
|
||||||
|
import android.os.StatFs
|
||||||
|
import info.nightscout.androidaps.Constants
|
||||||
|
import info.nightscout.androidaps.R
|
||||||
|
import info.nightscout.androidaps.interfaces.Constraint
|
||||||
|
import info.nightscout.androidaps.interfaces.ConstraintsInterface
|
||||||
|
import info.nightscout.androidaps.interfaces.PluginBase
|
||||||
|
import info.nightscout.androidaps.interfaces.PluginDescription
|
||||||
|
import info.nightscout.androidaps.interfaces.PluginType
|
||||||
|
import info.nightscout.androidaps.logging.AAPSLogger
|
||||||
|
import info.nightscout.androidaps.logging.LTag
|
||||||
|
import info.nightscout.androidaps.plugins.bus.RxBusWrapper
|
||||||
|
import info.nightscout.androidaps.plugins.general.overview.events.EventDismissNotification
|
||||||
|
import info.nightscout.androidaps.plugins.general.overview.events.EventNewNotification
|
||||||
|
import info.nightscout.androidaps.plugins.general.overview.notifications.Notification
|
||||||
|
import info.nightscout.androidaps.utils.resources.ResourceHelper
|
||||||
|
import javax.inject.Inject
|
||||||
|
import javax.inject.Singleton
|
||||||
|
|
||||||
|
@Singleton
|
||||||
|
open class StorageConstraintPlugin @Inject constructor(
|
||||||
|
aapsLogger: AAPSLogger,
|
||||||
|
resourceHelper: ResourceHelper,
|
||||||
|
private val rxBus: RxBusWrapper
|
||||||
|
) : PluginBase(PluginDescription()
|
||||||
|
.mainType(PluginType.CONSTRAINTS)
|
||||||
|
.neverVisible(true)
|
||||||
|
.alwaysEnabled(true)
|
||||||
|
.showInList(false)
|
||||||
|
.pluginName(R.string.storage),
|
||||||
|
aapsLogger, resourceHelper
|
||||||
|
), ConstraintsInterface {
|
||||||
|
|
||||||
|
override fun isClosedLoopAllowed(value: Constraint<Boolean>): Constraint<Boolean> {
|
||||||
|
val diskFree = availableInternalMemorySize
|
||||||
|
aapsLogger.debug(LTag.CONSTRAINTS, "Internal storage free (Mb):$diskFree")
|
||||||
|
if (diskFree < Constants.MINIMUM_FREE_SPACE) {
|
||||||
|
value[false, resourceHelper.gs(R.string.diskfull, Constants.MINIMUM_FREE_SPACE)] = this
|
||||||
|
val notification = Notification(Notification.DISKFULL, resourceHelper.gs(R.string.diskfull, Constants.MINIMUM_FREE_SPACE), Notification.NORMAL)
|
||||||
|
rxBus.send(EventNewNotification(notification))
|
||||||
|
} else {
|
||||||
|
rxBus.send(EventDismissNotification(Notification.DISKFULL))
|
||||||
|
}
|
||||||
|
return value
|
||||||
|
}
|
||||||
|
|
||||||
|
val availableInternalMemorySize: Long
|
||||||
|
get() {
|
||||||
|
val path = Environment.getDataDirectory()
|
||||||
|
val stat = StatFs(path.path)
|
||||||
|
val blockSize = stat.blockSizeLong
|
||||||
|
val blocksAvailable = stat.availableBlocksLong
|
||||||
|
val size = 1048576 // block size of 1 Mb
|
||||||
|
return blocksAvailable * blockSize / size
|
||||||
|
}
|
||||||
|
}
|
|
@ -22,16 +22,17 @@ import kotlin.math.roundToInt
|
||||||
@Singleton
|
@Singleton
|
||||||
class VersionCheckerPlugin @Inject constructor(
|
class VersionCheckerPlugin @Inject constructor(
|
||||||
private val sp: SP,
|
private val sp: SP,
|
||||||
private val resourceHelper: ResourceHelper,
|
resourceHelper: ResourceHelper,
|
||||||
private val versionCheckerUtils: VersionCheckerUtils,
|
private val versionCheckerUtils: VersionCheckerUtils,
|
||||||
rxBus: RxBusWrapper, aapsLogger: AAPSLogger
|
val rxBus: RxBusWrapper,
|
||||||
|
aapsLogger: AAPSLogger
|
||||||
) : PluginBase(PluginDescription()
|
) : PluginBase(PluginDescription()
|
||||||
.mainType(PluginType.CONSTRAINTS)
|
.mainType(PluginType.CONSTRAINTS)
|
||||||
.neverVisible(true)
|
.neverVisible(true)
|
||||||
.alwaysEnabled(true)
|
.alwaysEnabled(true)
|
||||||
.showInList(false)
|
.showInList(false)
|
||||||
.pluginName(R.string.versionChecker),
|
.pluginName(R.string.versionChecker),
|
||||||
rxBus, aapsLogger
|
aapsLogger, resourceHelper
|
||||||
), ConstraintsInterface {
|
), ConstraintsInterface {
|
||||||
|
|
||||||
enum class GracePeriod(val warning: Long, val old: Long, val veryOld: Long) {
|
enum class GracePeriod(val warning: Long, val old: Long, val veryOld: Long) {
|
||||||
|
|
|
@ -16,12 +16,12 @@ import info.nightscout.androidaps.activities.TDDStatsActivity
|
||||||
import info.nightscout.androidaps.dialogs.*
|
import info.nightscout.androidaps.dialogs.*
|
||||||
import info.nightscout.androidaps.events.*
|
import info.nightscout.androidaps.events.*
|
||||||
import info.nightscout.androidaps.historyBrowser.HistoryBrowseActivity
|
import info.nightscout.androidaps.historyBrowser.HistoryBrowseActivity
|
||||||
|
import info.nightscout.androidaps.interfaces.ActivePluginProvider
|
||||||
|
import info.nightscout.androidaps.interfaces.CommandQueueProvider
|
||||||
import info.nightscout.androidaps.plugins.bus.RxBusWrapper
|
import info.nightscout.androidaps.plugins.bus.RxBusWrapper
|
||||||
import info.nightscout.androidaps.plugins.configBuilder.ConfigBuilderPlugin
|
|
||||||
import info.nightscout.androidaps.plugins.configBuilder.ProfileFunction
|
import info.nightscout.androidaps.plugins.configBuilder.ProfileFunction
|
||||||
import info.nightscout.androidaps.plugins.general.actions.defs.CustomAction
|
import info.nightscout.androidaps.plugins.general.actions.defs.CustomAction
|
||||||
import info.nightscout.androidaps.plugins.general.overview.StatusLightHandler
|
import info.nightscout.androidaps.plugins.general.overview.StatusLightHandler
|
||||||
import info.nightscout.androidaps.plugins.treatments.TreatmentsPlugin
|
|
||||||
import info.nightscout.androidaps.queue.Callback
|
import info.nightscout.androidaps.queue.Callback
|
||||||
import info.nightscout.androidaps.utils.FabricPrivacy
|
import info.nightscout.androidaps.utils.FabricPrivacy
|
||||||
import info.nightscout.androidaps.utils.SingleClickButton
|
import info.nightscout.androidaps.utils.SingleClickButton
|
||||||
|
@ -44,8 +44,8 @@ class ActionsFragment : DaggerFragment() {
|
||||||
@Inject lateinit var resourceHelper: ResourceHelper
|
@Inject lateinit var resourceHelper: ResourceHelper
|
||||||
@Inject lateinit var statusLightHandler: StatusLightHandler
|
@Inject lateinit var statusLightHandler: StatusLightHandler
|
||||||
@Inject lateinit var fabricPrivacy: FabricPrivacy
|
@Inject lateinit var fabricPrivacy: FabricPrivacy
|
||||||
@Inject lateinit var configBuilderPlugin: ConfigBuilderPlugin
|
@Inject lateinit var activePlugin: ActivePluginProvider
|
||||||
@Inject lateinit var treatmentsPlugin: TreatmentsPlugin
|
@Inject lateinit var commandQueue: CommandQueueProvider
|
||||||
|
|
||||||
private var disposable: CompositeDisposable = CompositeDisposable()
|
private var disposable: CompositeDisposable = CompositeDisposable()
|
||||||
|
|
||||||
|
@ -70,8 +70,8 @@ class ActionsFragment : DaggerFragment() {
|
||||||
fragmentManager?.let { ExtendedBolusDialog().show(it, "Actions") }
|
fragmentManager?.let { ExtendedBolusDialog().show(it, "Actions") }
|
||||||
}
|
}
|
||||||
actions_extendedbolus_cancel.setOnClickListener {
|
actions_extendedbolus_cancel.setOnClickListener {
|
||||||
if (treatmentsPlugin.isInHistoryExtendedBoluslInProgress) {
|
if (activePlugin.activeTreatments.isInHistoryExtendedBoluslInProgress) {
|
||||||
configBuilderPlugin.commandQueue.cancelExtended(object : Callback() {
|
commandQueue.cancelExtended(object : Callback() {
|
||||||
override fun run() {
|
override fun run() {
|
||||||
if (!result.success) {
|
if (!result.success) {
|
||||||
val i = Intent(mainApp, ErrorHelperActivity::class.java)
|
val i = Intent(mainApp, ErrorHelperActivity::class.java)
|
||||||
|
@ -89,8 +89,8 @@ class ActionsFragment : DaggerFragment() {
|
||||||
fragmentManager?.let { TempBasalDialog().show(it, "Actions") }
|
fragmentManager?.let { TempBasalDialog().show(it, "Actions") }
|
||||||
}
|
}
|
||||||
actions_canceltempbasal.setOnClickListener {
|
actions_canceltempbasal.setOnClickListener {
|
||||||
if (treatmentsPlugin.isTempBasalInProgress) {
|
if (activePlugin.activeTreatments.isTempBasalInProgress) {
|
||||||
configBuilderPlugin.commandQueue.cancelTempBasal(true, object : Callback() {
|
commandQueue.cancelTempBasal(true, object : Callback() {
|
||||||
override fun run() {
|
override fun run() {
|
||||||
if (!result.success) {
|
if (!result.success) {
|
||||||
val i = Intent(mainApp, ErrorHelperActivity::class.java)
|
val i = Intent(mainApp, ErrorHelperActivity::class.java)
|
||||||
|
@ -159,20 +159,22 @@ class ActionsFragment : DaggerFragment() {
|
||||||
@Synchronized
|
@Synchronized
|
||||||
fun updateGui() {
|
fun updateGui() {
|
||||||
actions_profileswitch?.visibility =
|
actions_profileswitch?.visibility =
|
||||||
if (configBuilderPlugin.activeProfileInterface.profile != null) View.VISIBLE
|
if (activePlugin.activeProfileInterface.profile != null) View.VISIBLE
|
||||||
else View.GONE
|
else View.GONE
|
||||||
|
|
||||||
if (profileFunction.getProfile() == null) {
|
val profile = profileFunction.getProfile()
|
||||||
actions_temptarget?.visibility = View.GONE
|
val pump = activePlugin.activePumpPlugin
|
||||||
actions_extendedbolus?.visibility = View.GONE
|
|
||||||
actions_extendedbolus_cancel?.visibility = View.GONE
|
actions_temptarget?.visibility = (profile != null).toVisibility()
|
||||||
actions_settempbasal?.visibility = View.GONE
|
actions_canceltempbasal.visibility = (pump != null || profile == null).toVisibility()
|
||||||
actions_canceltempbasal?.visibility = View.GONE
|
actions_settempbasal.visibility = (pump != null || profile == null).toVisibility()
|
||||||
actions_fill?.visibility = View.GONE
|
actions_fill.visibility = (pump != null || profile == null).toVisibility()
|
||||||
return
|
actions_extendedbolus.visibility = (pump != null || profile == null).toVisibility()
|
||||||
}
|
actions_extendedbolus_cancel.visibility = (pump != null || profile == null).toVisibility()
|
||||||
|
actions_historybrowser.visibility = (pump != null || profile == null).toVisibility()
|
||||||
|
actions_tddstats.visibility = (pump != null || profile == null).toVisibility()
|
||||||
|
if (pump == null) return
|
||||||
|
|
||||||
val pump = configBuilderPlugin.activePump ?: return
|
|
||||||
val basalProfileEnabled = MainApp.isEngineeringModeOrRelease() && pump.pumpDescription.isSetBasalProfileCapable
|
val basalProfileEnabled = MainApp.isEngineeringModeOrRelease() && pump.pumpDescription.isSetBasalProfileCapable
|
||||||
|
|
||||||
actions_profileswitch?.visibility = if (!basalProfileEnabled || !pump.isInitialized || pump.isSuspended) View.GONE else View.VISIBLE
|
actions_profileswitch?.visibility = if (!basalProfileEnabled || !pump.isInitialized || pump.isSuspended) View.GONE else View.VISIBLE
|
||||||
|
@ -181,7 +183,7 @@ class ActionsFragment : DaggerFragment() {
|
||||||
actions_extendedbolus?.visibility = View.GONE
|
actions_extendedbolus?.visibility = View.GONE
|
||||||
actions_extendedbolus_cancel?.visibility = View.GONE
|
actions_extendedbolus_cancel?.visibility = View.GONE
|
||||||
} else {
|
} else {
|
||||||
val activeExtendedBolus = treatmentsPlugin.getExtendedBolusFromHistory(System.currentTimeMillis())
|
val activeExtendedBolus = activePlugin.activeTreatments.getExtendedBolusFromHistory(System.currentTimeMillis())
|
||||||
if (activeExtendedBolus != null) {
|
if (activeExtendedBolus != null) {
|
||||||
actions_extendedbolus?.visibility = View.GONE
|
actions_extendedbolus?.visibility = View.GONE
|
||||||
actions_extendedbolus_cancel?.visibility = View.VISIBLE
|
actions_extendedbolus_cancel?.visibility = View.VISIBLE
|
||||||
|
@ -197,7 +199,7 @@ class ActionsFragment : DaggerFragment() {
|
||||||
actions_settempbasal?.visibility = View.GONE
|
actions_settempbasal?.visibility = View.GONE
|
||||||
actions_canceltempbasal?.visibility = View.GONE
|
actions_canceltempbasal?.visibility = View.GONE
|
||||||
} else {
|
} else {
|
||||||
val activeTemp = treatmentsPlugin.getTempBasalFromHistory(System.currentTimeMillis())
|
val activeTemp = activePlugin.activeTreatments.getTempBasalFromHistory(System.currentTimeMillis())
|
||||||
if (activeTemp != null) {
|
if (activeTemp != null) {
|
||||||
actions_settempbasal?.visibility = View.GONE
|
actions_settempbasal?.visibility = View.GONE
|
||||||
actions_canceltempbasal?.visibility = View.VISIBLE
|
actions_canceltempbasal?.visibility = View.VISIBLE
|
||||||
|
@ -220,7 +222,7 @@ class ActionsFragment : DaggerFragment() {
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun checkPumpCustomActions() {
|
private fun checkPumpCustomActions() {
|
||||||
val activePump = configBuilderPlugin.activePump ?: return
|
val activePump = activePlugin.activePumpPlugin ?: return
|
||||||
val customActions = activePump.customActions ?: return
|
val customActions = activePump.customActions ?: return
|
||||||
removePumpCustomActions()
|
removePumpCustomActions()
|
||||||
|
|
||||||
|
@ -237,8 +239,9 @@ class ActionsFragment : DaggerFragment() {
|
||||||
btn.layoutParams = layoutParams
|
btn.layoutParams = layoutParams
|
||||||
btn.setOnClickListener { v ->
|
btn.setOnClickListener { v ->
|
||||||
val b = v as SingleClickButton
|
val b = v as SingleClickButton
|
||||||
val action = this.pumpCustomActions[b.text.toString()]
|
this.pumpCustomActions[b.text.toString()]?.let {
|
||||||
configBuilderPlugin.activePump!!.executeCustomAction(action!!.customActionType)
|
activePlugin.activePump.executeCustomAction(it.customActionType)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
val top = activity?.let { ContextCompat.getDrawable(it, customAction.iconResourceId) }
|
val top = activity?.let { ContextCompat.getDrawable(it, customAction.iconResourceId) }
|
||||||
btn.setCompoundDrawablesWithIntrinsicBounds(null, top, null, null)
|
btn.setCompoundDrawablesWithIntrinsicBounds(null, top, null, null)
|
||||||
|
|
|
@ -6,12 +6,12 @@ import info.nightscout.androidaps.interfaces.PluginBase
|
||||||
import info.nightscout.androidaps.interfaces.PluginDescription
|
import info.nightscout.androidaps.interfaces.PluginDescription
|
||||||
import info.nightscout.androidaps.interfaces.PluginType
|
import info.nightscout.androidaps.interfaces.PluginType
|
||||||
import info.nightscout.androidaps.logging.AAPSLogger
|
import info.nightscout.androidaps.logging.AAPSLogger
|
||||||
import info.nightscout.androidaps.plugins.bus.RxBusWrapper
|
import info.nightscout.androidaps.utils.resources.ResourceHelper
|
||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
import javax.inject.Singleton
|
import javax.inject.Singleton
|
||||||
|
|
||||||
@Singleton
|
@Singleton
|
||||||
class ActionsPlugin @Inject constructor(rxBus: RxBusWrapper, aapsLogger: AAPSLogger
|
class ActionsPlugin @Inject constructor(aapsLogger: AAPSLogger, resourceHelper: ResourceHelper
|
||||||
) : PluginBase(PluginDescription()
|
) : PluginBase(PluginDescription()
|
||||||
.mainType(PluginType.GENERAL)
|
.mainType(PluginType.GENERAL)
|
||||||
.fragmentClass(ActionsFragment::class.qualifiedName)
|
.fragmentClass(ActionsFragment::class.qualifiedName)
|
||||||
|
@ -20,5 +20,5 @@ class ActionsPlugin @Inject constructor(rxBus: RxBusWrapper, aapsLogger: AAPSLog
|
||||||
.pluginName(R.string.actions)
|
.pluginName(R.string.actions)
|
||||||
.shortName(R.string.actions_shortname)
|
.shortName(R.string.actions_shortname)
|
||||||
.description(R.string.description_actions),
|
.description(R.string.description_actions),
|
||||||
rxBus, aapsLogger
|
aapsLogger, resourceHelper
|
||||||
)
|
)
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
package info.nightscout.androidaps.plugins.general.automation
|
package info.nightscout.androidaps.plugins.general.automation
|
||||||
|
|
||||||
import info.nightscout.androidaps.MainApp
|
import dagger.android.HasAndroidInjector
|
||||||
import info.nightscout.androidaps.logging.AAPSLogger
|
import info.nightscout.androidaps.logging.AAPSLogger
|
||||||
import info.nightscout.androidaps.plugins.general.automation.actions.Action
|
import info.nightscout.androidaps.plugins.general.automation.actions.Action
|
||||||
import info.nightscout.androidaps.plugins.general.automation.actions.ActionDummy
|
import info.nightscout.androidaps.plugins.general.automation.actions.ActionDummy
|
||||||
|
@ -14,21 +14,21 @@ import org.json.JSONObject
|
||||||
import java.util.*
|
import java.util.*
|
||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
|
|
||||||
class AutomationEvent(private val mainApp: MainApp) {
|
class AutomationEvent(private val injector: HasAndroidInjector) {
|
||||||
@Inject lateinit var aapsLogger: AAPSLogger
|
@Inject lateinit var aapsLogger: AAPSLogger
|
||||||
|
|
||||||
var trigger: Trigger = TriggerConnector(mainApp)
|
var trigger: Trigger = TriggerConnector(injector)
|
||||||
val actions: MutableList<Action> = ArrayList()
|
val actions: MutableList<Action> = ArrayList()
|
||||||
var title: String? = null
|
var title: String? = null
|
||||||
var isEnabled = true
|
var isEnabled = true
|
||||||
var lastRun: Long = 0
|
var lastRun: Long = 0
|
||||||
|
|
||||||
init {
|
init {
|
||||||
mainApp.androidInjector().inject(this)
|
injector.androidInjector().inject(this)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun getPreconditions(): TriggerConnector {
|
fun getPreconditions(): TriggerConnector {
|
||||||
val trigger = TriggerConnector(mainApp, TriggerConnector.Type.AND)
|
val trigger = TriggerConnector(injector, TriggerConnector.Type.AND)
|
||||||
for (action in actions) {
|
for (action in actions) {
|
||||||
action.precondition?.let { trigger.list.add(it) }
|
action.precondition?.let { trigger.list.add(it) }
|
||||||
}
|
}
|
||||||
|
@ -52,12 +52,12 @@ class AutomationEvent(private val mainApp: MainApp) {
|
||||||
val d = JSONObject(data)
|
val d = JSONObject(data)
|
||||||
title = d.optString("title", "")
|
title = d.optString("title", "")
|
||||||
isEnabled = d.optBoolean("enabled", true)
|
isEnabled = d.optBoolean("enabled", true)
|
||||||
trigger = TriggerDummy(mainApp).instantiate(JSONObject(d.getString("trigger")))
|
trigger = TriggerDummy(injector).instantiate(JSONObject(d.getString("trigger")))
|
||||||
?: TriggerConnector(mainApp)
|
?: TriggerConnector(injector)
|
||||||
val array = d.getJSONArray("actions")
|
val array = d.getJSONArray("actions")
|
||||||
actions.clear()
|
actions.clear()
|
||||||
for (i in 0 until array.length()) {
|
for (i in 0 until array.length()) {
|
||||||
ActionDummy(mainApp).instantiate(JSONObject(array.getString(i)))?.let {
|
ActionDummy(injector).instantiate(JSONObject(array.getString(i)))?.let {
|
||||||
actions.add(it)
|
actions.add(it)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,9 +1,10 @@
|
||||||
package info.nightscout.androidaps.plugins.general.automation
|
package info.nightscout.androidaps.plugins.general.automation
|
||||||
|
|
||||||
|
import android.content.Context
|
||||||
import android.content.Intent
|
import android.content.Intent
|
||||||
import android.os.Build
|
import android.os.Build
|
||||||
import android.os.Handler
|
import android.os.Handler
|
||||||
import info.nightscout.androidaps.MainApp
|
import dagger.android.HasAndroidInjector
|
||||||
import info.nightscout.androidaps.R
|
import info.nightscout.androidaps.R
|
||||||
import info.nightscout.androidaps.events.EventChargingState
|
import info.nightscout.androidaps.events.EventChargingState
|
||||||
import info.nightscout.androidaps.events.EventLocationChange
|
import info.nightscout.androidaps.events.EventLocationChange
|
||||||
|
@ -40,19 +41,21 @@ import javax.inject.Singleton
|
||||||
|
|
||||||
@Singleton
|
@Singleton
|
||||||
class AutomationPlugin @Inject constructor(
|
class AutomationPlugin @Inject constructor(
|
||||||
private val resourceHelper: ResourceHelper,
|
private val injector: HasAndroidInjector,
|
||||||
private val mainApp: MainApp,
|
resourceHelper: ResourceHelper,
|
||||||
|
private val context: Context,
|
||||||
private val sp: SP,
|
private val sp: SP,
|
||||||
private val fabricPrivacy: FabricPrivacy,
|
private val fabricPrivacy: FabricPrivacy,
|
||||||
private val loopPlugin: LoopPlugin,
|
private val loopPlugin: LoopPlugin,
|
||||||
rxBus: RxBusWrapper, aapsLogger: AAPSLogger
|
private val rxBus: RxBusWrapper,
|
||||||
|
aapsLogger: AAPSLogger
|
||||||
) : PluginBase(PluginDescription()
|
) : PluginBase(PluginDescription()
|
||||||
.mainType(PluginType.GENERAL)
|
.mainType(PluginType.GENERAL)
|
||||||
.fragmentClass(AutomationFragment::class.qualifiedName)
|
.fragmentClass(AutomationFragment::class.qualifiedName)
|
||||||
.pluginName(R.string.automation)
|
.pluginName(R.string.automation)
|
||||||
.shortName(R.string.automation_short)
|
.shortName(R.string.automation_short)
|
||||||
.preferencesId(R.xml.pref_automation)
|
.preferencesId(R.xml.pref_automation)
|
||||||
.description(R.string.automation_description), rxBus, aapsLogger
|
.description(R.string.automation_description), aapsLogger, resourceHelper
|
||||||
) {
|
) {
|
||||||
|
|
||||||
private var disposable: CompositeDisposable = CompositeDisposable()
|
private var disposable: CompositeDisposable = CompositeDisposable()
|
||||||
|
@ -74,9 +77,9 @@ class AutomationPlugin @Inject constructor(
|
||||||
|
|
||||||
override fun onStart() {
|
override fun onStart() {
|
||||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O)
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O)
|
||||||
mainApp.startForegroundService(Intent(mainApp, LocationService::class.java))
|
context.startForegroundService(Intent(context, LocationService::class.java))
|
||||||
else
|
else
|
||||||
mainApp.startService(Intent(mainApp, LocationService::class.java))
|
context.startService(Intent(context, LocationService::class.java))
|
||||||
|
|
||||||
super.onStart()
|
super.onStart()
|
||||||
loadFromSP()
|
loadFromSP()
|
||||||
|
@ -87,11 +90,11 @@ class AutomationPlugin @Inject constructor(
|
||||||
.observeOn(Schedulers.io())
|
.observeOn(Schedulers.io())
|
||||||
.subscribe({ e ->
|
.subscribe({ e ->
|
||||||
if (e.isChanged(resourceHelper, R.string.key_location)) {
|
if (e.isChanged(resourceHelper, R.string.key_location)) {
|
||||||
mainApp.stopService(Intent(mainApp, LocationService::class.java))
|
context.stopService(Intent(context, LocationService::class.java))
|
||||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O)
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O)
|
||||||
mainApp.startForegroundService(Intent(mainApp, LocationService::class.java))
|
context.startForegroundService(Intent(context, LocationService::class.java))
|
||||||
else
|
else
|
||||||
mainApp.startService(Intent(mainApp, LocationService::class.java))
|
context.startService(Intent(context, LocationService::class.java))
|
||||||
}
|
}
|
||||||
}, { fabricPrivacy.logException(it) })
|
}, { fabricPrivacy.logException(it) })
|
||||||
disposable += rxBus
|
disposable += rxBus
|
||||||
|
@ -124,7 +127,7 @@ class AutomationPlugin @Inject constructor(
|
||||||
override fun onStop() {
|
override fun onStop() {
|
||||||
disposable.clear()
|
disposable.clear()
|
||||||
loopHandler.removeCallbacks(refreshLoop)
|
loopHandler.removeCallbacks(refreshLoop)
|
||||||
mainApp.stopService(Intent(mainApp, LocationService::class.java))
|
context.stopService(Intent(context, LocationService::class.java))
|
||||||
super.onStop()
|
super.onStop()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -149,7 +152,7 @@ class AutomationPlugin @Inject constructor(
|
||||||
val array = JSONArray(data)
|
val array = JSONArray(data)
|
||||||
for (i in 0 until array.length()) {
|
for (i in 0 until array.length()) {
|
||||||
val o = array.getJSONObject(i)
|
val o = array.getJSONObject(i)
|
||||||
val event = AutomationEvent(mainApp).fromJSON(o.toString())
|
val event = AutomationEvent(injector).fromJSON(o.toString())
|
||||||
automationEvents.add(event)
|
automationEvents.add(event)
|
||||||
}
|
}
|
||||||
} catch (e: JSONException) {
|
} catch (e: JSONException) {
|
||||||
|
@ -198,36 +201,36 @@ class AutomationPlugin @Inject constructor(
|
||||||
|
|
||||||
fun getActionDummyObjects(): List<Action> {
|
fun getActionDummyObjects(): List<Action> {
|
||||||
return listOf(
|
return listOf(
|
||||||
//ActionLoopDisable(mainApp),
|
//ActionLoopDisable(injector),
|
||||||
//ActionLoopEnable(mainApp),
|
//ActionLoopEnable(injector),
|
||||||
//ActionLoopResume(mainApp),
|
//ActionLoopResume(injector),
|
||||||
//ActionLoopSuspend(mainApp),
|
//ActionLoopSuspend(injector),
|
||||||
ActionStartTempTarget(mainApp),
|
ActionStartTempTarget(injector),
|
||||||
ActionStopTempTarget(mainApp),
|
ActionStopTempTarget(injector),
|
||||||
ActionNotification(mainApp),
|
ActionNotification(injector),
|
||||||
ActionProfileSwitchPercent(mainApp),
|
ActionProfileSwitchPercent(injector),
|
||||||
ActionProfileSwitch(mainApp),
|
ActionProfileSwitch(injector),
|
||||||
ActionSendSMS(mainApp)
|
ActionSendSMS(injector)
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun getTriggerDummyObjects(): List<Trigger> {
|
fun getTriggerDummyObjects(): List<Trigger> {
|
||||||
return listOf(
|
return listOf(
|
||||||
TriggerConnector(mainApp),
|
TriggerConnector(injector),
|
||||||
TriggerTime(mainApp),
|
TriggerTime(injector),
|
||||||
TriggerRecurringTime(mainApp),
|
TriggerRecurringTime(injector),
|
||||||
TriggerTimeRange(mainApp),
|
TriggerTimeRange(injector),
|
||||||
TriggerBg(mainApp),
|
TriggerBg(injector),
|
||||||
TriggerDelta(mainApp),
|
TriggerDelta(injector),
|
||||||
TriggerIob(mainApp),
|
TriggerIob(injector),
|
||||||
TriggerCOB(mainApp),
|
TriggerCOB(injector),
|
||||||
TriggerProfilePercent(mainApp),
|
TriggerProfilePercent(injector),
|
||||||
TriggerTempTarget(mainApp),
|
TriggerTempTarget(injector),
|
||||||
TriggerWifiSsid(mainApp),
|
TriggerWifiSsid(injector),
|
||||||
TriggerLocation(mainApp),
|
TriggerLocation(injector),
|
||||||
TriggerAutosensValue(mainApp),
|
TriggerAutosensValue(injector),
|
||||||
TriggerBolusAgo(mainApp),
|
TriggerBolusAgo(injector),
|
||||||
TriggerPumpLastConnection(mainApp)
|
TriggerPumpLastConnection(injector)
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -2,33 +2,17 @@ package info.nightscout.androidaps.plugins.general.automation.actions
|
||||||
|
|
||||||
import android.widget.LinearLayout
|
import android.widget.LinearLayout
|
||||||
import androidx.annotation.DrawableRes
|
import androidx.annotation.DrawableRes
|
||||||
import info.nightscout.androidaps.MainApp
|
import dagger.android.HasAndroidInjector
|
||||||
import info.nightscout.androidaps.logging.AAPSLogger
|
import info.nightscout.androidaps.logging.AAPSLogger
|
||||||
import info.nightscout.androidaps.plugins.aps.loop.LoopPlugin
|
|
||||||
import info.nightscout.androidaps.plugins.bus.RxBusWrapper
|
|
||||||
import info.nightscout.androidaps.plugins.configBuilder.ConfigBuilderPlugin
|
|
||||||
import info.nightscout.androidaps.plugins.configBuilder.ProfileFunction
|
|
||||||
import info.nightscout.androidaps.plugins.general.automation.triggers.Trigger
|
import info.nightscout.androidaps.plugins.general.automation.triggers.Trigger
|
||||||
import info.nightscout.androidaps.plugins.general.smsCommunicator.SmsCommunicatorPlugin
|
|
||||||
import info.nightscout.androidaps.plugins.treatments.TreatmentsPlugin
|
|
||||||
import info.nightscout.androidaps.queue.Callback
|
import info.nightscout.androidaps.queue.Callback
|
||||||
import info.nightscout.androidaps.utils.resources.ResourceHelper
|
|
||||||
import info.nightscout.androidaps.utils.sharedPreferences.SP
|
|
||||||
import org.json.JSONException
|
import org.json.JSONException
|
||||||
import org.json.JSONObject
|
import org.json.JSONObject
|
||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
import kotlin.reflect.full.primaryConstructor
|
import kotlin.reflect.full.primaryConstructor
|
||||||
|
|
||||||
abstract class Action(val mainApp: MainApp) {
|
abstract class Action(val injector: HasAndroidInjector) {
|
||||||
@Inject lateinit var aapsLogger: AAPSLogger
|
@Inject lateinit var aapsLogger: AAPSLogger
|
||||||
@Inject lateinit var sp: SP
|
|
||||||
@Inject lateinit var rxBus: RxBusWrapper
|
|
||||||
@Inject lateinit var profileFunction: ProfileFunction
|
|
||||||
@Inject lateinit var resourceHelper: ResourceHelper
|
|
||||||
@Inject lateinit var configBuilderPlugin: ConfigBuilderPlugin
|
|
||||||
@Inject lateinit var loopPlugin: LoopPlugin
|
|
||||||
@Inject lateinit var treatmentsPlugin: TreatmentsPlugin
|
|
||||||
@Inject lateinit var smsCommunicatorPlugin: SmsCommunicatorPlugin
|
|
||||||
|
|
||||||
var precondition: Trigger? = null
|
var precondition: Trigger? = null
|
||||||
|
|
||||||
|
@ -38,7 +22,7 @@ abstract class Action(val mainApp: MainApp) {
|
||||||
@DrawableRes abstract fun icon(): Int
|
@DrawableRes abstract fun icon(): Int
|
||||||
|
|
||||||
init {
|
init {
|
||||||
mainApp.androidInjector().inject(this)
|
injector.androidInjector().inject(this)
|
||||||
}
|
}
|
||||||
|
|
||||||
open fun generateDialog(root: LinearLayout) {}
|
open fun generateDialog(root: LinearLayout) {}
|
||||||
|
@ -62,7 +46,7 @@ abstract class Action(val mainApp: MainApp) {
|
||||||
val type = obj.getString("type")
|
val type = obj.getString("type")
|
||||||
val data = obj.optJSONObject("data")
|
val data = obj.optJSONObject("data")
|
||||||
val clazz = Class.forName(type).kotlin
|
val clazz = Class.forName(type).kotlin
|
||||||
return (clazz.primaryConstructor?.call(mainApp) as Action).fromJSON(data?.toString()
|
return (clazz.primaryConstructor?.call(injector) as Action).fromJSON(data?.toString()
|
||||||
?: "")
|
?: "")
|
||||||
//return (clazz.newInstance() as Action).fromJSON(data?.toString() ?: "")
|
//return (clazz.newInstance() as Action).fromJSON(data?.toString() ?: "")
|
||||||
} catch (e: ClassNotFoundException) {
|
} catch (e: ClassNotFoundException) {
|
||||||
|
|
|
@ -1,10 +1,10 @@
|
||||||
package info.nightscout.androidaps.plugins.general.automation.actions
|
package info.nightscout.androidaps.plugins.general.automation.actions
|
||||||
|
|
||||||
import info.nightscout.androidaps.MainApp
|
import dagger.android.HasAndroidInjector
|
||||||
import info.nightscout.androidaps.queue.Callback
|
import info.nightscout.androidaps.queue.Callback
|
||||||
|
|
||||||
// Used for instantiation of other actions only
|
// Used for instantiation of other actions only
|
||||||
class ActionDummy(mainApp: MainApp) : Action(mainApp) {
|
class ActionDummy(injector: HasAndroidInjector) : Action(injector) {
|
||||||
|
|
||||||
override fun friendlyName(): Int {
|
override fun friendlyName(): Int {
|
||||||
throw NotImplementedError("An operation is not implemented")
|
throw NotImplementedError("An operation is not implemented")
|
||||||
|
|
|
@ -1,14 +1,25 @@
|
||||||
package info.nightscout.androidaps.plugins.general.automation.actions
|
package info.nightscout.androidaps.plugins.general.automation.actions
|
||||||
|
|
||||||
import androidx.annotation.DrawableRes
|
import androidx.annotation.DrawableRes
|
||||||
import info.nightscout.androidaps.MainApp
|
import dagger.android.HasAndroidInjector
|
||||||
import info.nightscout.androidaps.R
|
import info.nightscout.androidaps.R
|
||||||
import info.nightscout.androidaps.data.PumpEnactResult
|
import info.nightscout.androidaps.data.PumpEnactResult
|
||||||
import info.nightscout.androidaps.events.EventRefreshOverview
|
import info.nightscout.androidaps.events.EventRefreshOverview
|
||||||
|
import info.nightscout.androidaps.interfaces.CommandQueueProvider
|
||||||
import info.nightscout.androidaps.interfaces.PluginType
|
import info.nightscout.androidaps.interfaces.PluginType
|
||||||
|
import info.nightscout.androidaps.plugins.aps.loop.LoopPlugin
|
||||||
|
import info.nightscout.androidaps.plugins.bus.RxBusWrapper
|
||||||
|
import info.nightscout.androidaps.plugins.configBuilder.ConfigBuilderPlugin
|
||||||
import info.nightscout.androidaps.queue.Callback
|
import info.nightscout.androidaps.queue.Callback
|
||||||
|
import info.nightscout.androidaps.utils.resources.ResourceHelper
|
||||||
|
import javax.inject.Inject
|
||||||
|
|
||||||
class ActionLoopDisable(mainApp: MainApp) : Action(mainApp) {
|
class ActionLoopDisable(injector: HasAndroidInjector) : Action(injector) {
|
||||||
|
@Inject lateinit var loopPlugin: LoopPlugin
|
||||||
|
@Inject lateinit var resourceHelper: ResourceHelper
|
||||||
|
@Inject lateinit var configBuilderPlugin: ConfigBuilderPlugin
|
||||||
|
@Inject lateinit var commandQueue: CommandQueueProvider
|
||||||
|
@Inject lateinit var rxBus: RxBusWrapper
|
||||||
|
|
||||||
override fun friendlyName(): Int = R.string.disableloop
|
override fun friendlyName(): Int = R.string.disableloop
|
||||||
override fun shortDescription(): String = resourceHelper.gs(R.string.disableloop)
|
override fun shortDescription(): String = resourceHelper.gs(R.string.disableloop)
|
||||||
|
@ -18,7 +29,7 @@ class ActionLoopDisable(mainApp: MainApp) : Action(mainApp) {
|
||||||
if (loopPlugin.isEnabled(PluginType.LOOP)) {
|
if (loopPlugin.isEnabled(PluginType.LOOP)) {
|
||||||
loopPlugin.setPluginEnabled(PluginType.LOOP, false)
|
loopPlugin.setPluginEnabled(PluginType.LOOP, false)
|
||||||
configBuilderPlugin.storeSettings("ActionLoopDisable")
|
configBuilderPlugin.storeSettings("ActionLoopDisable")
|
||||||
configBuilderPlugin.commandQueue.cancelTempBasal(true, object : Callback() {
|
commandQueue.cancelTempBasal(true, object : Callback() {
|
||||||
override fun run() {
|
override fun run() {
|
||||||
rxBus.send(EventRefreshOverview("ActionLoopDisable"))
|
rxBus.send(EventRefreshOverview("ActionLoopDisable"))
|
||||||
callback.result(result).run()
|
callback.result(result).run()
|
||||||
|
|
|
@ -1,14 +1,23 @@
|
||||||
package info.nightscout.androidaps.plugins.general.automation.actions
|
package info.nightscout.androidaps.plugins.general.automation.actions
|
||||||
|
|
||||||
import androidx.annotation.DrawableRes
|
import androidx.annotation.DrawableRes
|
||||||
import info.nightscout.androidaps.MainApp
|
import dagger.android.HasAndroidInjector
|
||||||
import info.nightscout.androidaps.R
|
import info.nightscout.androidaps.R
|
||||||
import info.nightscout.androidaps.data.PumpEnactResult
|
import info.nightscout.androidaps.data.PumpEnactResult
|
||||||
import info.nightscout.androidaps.events.EventRefreshOverview
|
import info.nightscout.androidaps.events.EventRefreshOverview
|
||||||
import info.nightscout.androidaps.interfaces.PluginType
|
import info.nightscout.androidaps.interfaces.PluginType
|
||||||
|
import info.nightscout.androidaps.plugins.aps.loop.LoopPlugin
|
||||||
|
import info.nightscout.androidaps.plugins.bus.RxBusWrapper
|
||||||
|
import info.nightscout.androidaps.plugins.configBuilder.ConfigBuilderPlugin
|
||||||
import info.nightscout.androidaps.queue.Callback
|
import info.nightscout.androidaps.queue.Callback
|
||||||
|
import info.nightscout.androidaps.utils.resources.ResourceHelper
|
||||||
|
import javax.inject.Inject
|
||||||
|
|
||||||
class ActionLoopEnable(mainApp: MainApp) : Action(mainApp) {
|
class ActionLoopEnable(injector: HasAndroidInjector) : Action(injector) {
|
||||||
|
@Inject lateinit var resourceHelper: ResourceHelper
|
||||||
|
@Inject lateinit var loopPlugin: LoopPlugin
|
||||||
|
@Inject lateinit var configBuilderPlugin: ConfigBuilderPlugin
|
||||||
|
@Inject lateinit var rxBus: RxBusWrapper
|
||||||
|
|
||||||
override fun friendlyName(): Int = R.string.enableloop
|
override fun friendlyName(): Int = R.string.enableloop
|
||||||
override fun shortDescription(): String = resourceHelper.gs(R.string.enableloop)
|
override fun shortDescription(): String = resourceHelper.gs(R.string.enableloop)
|
||||||
|
|
|
@ -1,14 +1,23 @@
|
||||||
package info.nightscout.androidaps.plugins.general.automation.actions
|
package info.nightscout.androidaps.plugins.general.automation.actions
|
||||||
|
|
||||||
import androidx.annotation.DrawableRes
|
import androidx.annotation.DrawableRes
|
||||||
import info.nightscout.androidaps.MainApp
|
import dagger.android.HasAndroidInjector
|
||||||
import info.nightscout.androidaps.R
|
import info.nightscout.androidaps.R
|
||||||
import info.nightscout.androidaps.data.PumpEnactResult
|
import info.nightscout.androidaps.data.PumpEnactResult
|
||||||
import info.nightscout.androidaps.events.EventRefreshOverview
|
import info.nightscout.androidaps.events.EventRefreshOverview
|
||||||
|
import info.nightscout.androidaps.plugins.aps.loop.LoopPlugin
|
||||||
|
import info.nightscout.androidaps.plugins.bus.RxBusWrapper
|
||||||
|
import info.nightscout.androidaps.plugins.configBuilder.ConfigBuilderPlugin
|
||||||
import info.nightscout.androidaps.plugins.general.nsclient.NSUpload
|
import info.nightscout.androidaps.plugins.general.nsclient.NSUpload
|
||||||
import info.nightscout.androidaps.queue.Callback
|
import info.nightscout.androidaps.queue.Callback
|
||||||
|
import info.nightscout.androidaps.utils.resources.ResourceHelper
|
||||||
|
import javax.inject.Inject
|
||||||
|
|
||||||
class ActionLoopResume(mainApp: MainApp) : Action(mainApp) {
|
class ActionLoopResume(injector: HasAndroidInjector) : Action(injector) {
|
||||||
|
@Inject lateinit var resourceHelper: ResourceHelper
|
||||||
|
@Inject lateinit var loopPlugin: LoopPlugin
|
||||||
|
@Inject lateinit var configBuilderPlugin: ConfigBuilderPlugin
|
||||||
|
@Inject lateinit var rxBus: RxBusWrapper
|
||||||
|
|
||||||
override fun friendlyName(): Int = R.string.resumeloop
|
override fun friendlyName(): Int = R.string.resumeloop
|
||||||
override fun shortDescription(): String = resourceHelper.gs(R.string.resumeloop)
|
override fun shortDescription(): String = resourceHelper.gs(R.string.resumeloop)
|
||||||
|
|
|
@ -2,19 +2,27 @@ package info.nightscout.androidaps.plugins.general.automation.actions
|
||||||
|
|
||||||
import android.widget.LinearLayout
|
import android.widget.LinearLayout
|
||||||
import androidx.annotation.DrawableRes
|
import androidx.annotation.DrawableRes
|
||||||
import info.nightscout.androidaps.MainApp
|
import dagger.android.HasAndroidInjector
|
||||||
import info.nightscout.androidaps.R
|
import info.nightscout.androidaps.R
|
||||||
import info.nightscout.androidaps.data.PumpEnactResult
|
import info.nightscout.androidaps.data.PumpEnactResult
|
||||||
import info.nightscout.androidaps.events.EventRefreshOverview
|
import info.nightscout.androidaps.events.EventRefreshOverview
|
||||||
|
import info.nightscout.androidaps.plugins.aps.loop.LoopPlugin
|
||||||
|
import info.nightscout.androidaps.plugins.bus.RxBusWrapper
|
||||||
import info.nightscout.androidaps.plugins.general.automation.elements.InputDuration
|
import info.nightscout.androidaps.plugins.general.automation.elements.InputDuration
|
||||||
import info.nightscout.androidaps.plugins.general.automation.elements.LabelWithElement
|
import info.nightscout.androidaps.plugins.general.automation.elements.LabelWithElement
|
||||||
import info.nightscout.androidaps.plugins.general.automation.elements.LayoutBuilder
|
import info.nightscout.androidaps.plugins.general.automation.elements.LayoutBuilder
|
||||||
import info.nightscout.androidaps.queue.Callback
|
import info.nightscout.androidaps.queue.Callback
|
||||||
import info.nightscout.androidaps.utils.JsonHelper
|
import info.nightscout.androidaps.utils.JsonHelper
|
||||||
|
import info.nightscout.androidaps.utils.resources.ResourceHelper
|
||||||
import org.json.JSONObject
|
import org.json.JSONObject
|
||||||
|
import javax.inject.Inject
|
||||||
|
|
||||||
class ActionLoopSuspend(mainApp: MainApp) : Action(mainApp) {
|
class ActionLoopSuspend(injector: HasAndroidInjector) : Action(injector) {
|
||||||
var minutes = InputDuration(mainApp, 0, InputDuration.TimeUnit.MINUTES)
|
@Inject lateinit var resourceHelper: ResourceHelper
|
||||||
|
@Inject lateinit var loopPlugin: LoopPlugin
|
||||||
|
@Inject lateinit var rxBus: RxBusWrapper
|
||||||
|
|
||||||
|
var minutes = InputDuration(injector, 0, InputDuration.TimeUnit.MINUTES)
|
||||||
|
|
||||||
override fun friendlyName(): Int = R.string.suspendloop
|
override fun friendlyName(): Int = R.string.suspendloop
|
||||||
override fun shortDescription(): String = resourceHelper.gs(R.string.suspendloopforXmin, minutes.getMinutes())
|
override fun shortDescription(): String = resourceHelper.gs(R.string.suspendloopforXmin, minutes.getMinutes())
|
||||||
|
@ -48,7 +56,7 @@ class ActionLoopSuspend(mainApp: MainApp) : Action(mainApp) {
|
||||||
|
|
||||||
override fun generateDialog(root: LinearLayout) {
|
override fun generateDialog(root: LinearLayout) {
|
||||||
LayoutBuilder()
|
LayoutBuilder()
|
||||||
.add(LabelWithElement(mainApp, resourceHelper.gs(R.string.careportal_newnstreatment_duration_min_label), "", minutes))
|
.add(LabelWithElement(injector, resourceHelper.gs(R.string.careportal_newnstreatment_duration_min_label), "", minutes))
|
||||||
.build(root)
|
.build(root)
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -2,10 +2,11 @@ package info.nightscout.androidaps.plugins.general.automation.actions
|
||||||
|
|
||||||
import android.widget.LinearLayout
|
import android.widget.LinearLayout
|
||||||
import androidx.annotation.DrawableRes
|
import androidx.annotation.DrawableRes
|
||||||
import info.nightscout.androidaps.MainApp
|
import dagger.android.HasAndroidInjector
|
||||||
import info.nightscout.androidaps.R
|
import info.nightscout.androidaps.R
|
||||||
import info.nightscout.androidaps.data.PumpEnactResult
|
import info.nightscout.androidaps.data.PumpEnactResult
|
||||||
import info.nightscout.androidaps.events.EventRefreshOverview
|
import info.nightscout.androidaps.events.EventRefreshOverview
|
||||||
|
import info.nightscout.androidaps.plugins.bus.RxBusWrapper
|
||||||
import info.nightscout.androidaps.plugins.general.automation.elements.InputString
|
import info.nightscout.androidaps.plugins.general.automation.elements.InputString
|
||||||
import info.nightscout.androidaps.plugins.general.automation.elements.LabelWithElement
|
import info.nightscout.androidaps.plugins.general.automation.elements.LabelWithElement
|
||||||
import info.nightscout.androidaps.plugins.general.automation.elements.LayoutBuilder
|
import info.nightscout.androidaps.plugins.general.automation.elements.LayoutBuilder
|
||||||
|
@ -14,10 +15,15 @@ import info.nightscout.androidaps.plugins.general.overview.events.EventNewNotifi
|
||||||
import info.nightscout.androidaps.plugins.general.overview.notifications.Notification
|
import info.nightscout.androidaps.plugins.general.overview.notifications.Notification
|
||||||
import info.nightscout.androidaps.queue.Callback
|
import info.nightscout.androidaps.queue.Callback
|
||||||
import info.nightscout.androidaps.utils.JsonHelper
|
import info.nightscout.androidaps.utils.JsonHelper
|
||||||
|
import info.nightscout.androidaps.utils.resources.ResourceHelper
|
||||||
import org.json.JSONObject
|
import org.json.JSONObject
|
||||||
|
import javax.inject.Inject
|
||||||
|
|
||||||
class ActionNotification(mainApp: MainApp) : Action(mainApp) {
|
class ActionNotification(injector: HasAndroidInjector) : Action(injector) {
|
||||||
var text = InputString(mainApp)
|
@Inject lateinit var resourceHelper: ResourceHelper
|
||||||
|
@Inject lateinit var rxBus: RxBusWrapper
|
||||||
|
|
||||||
|
var text = InputString(injector)
|
||||||
|
|
||||||
override fun friendlyName(): Int = R.string.notification
|
override fun friendlyName(): Int = R.string.notification
|
||||||
override fun shortDescription(): String = resourceHelper.gs(R.string.notification_message, text.value)
|
override fun shortDescription(): String = resourceHelper.gs(R.string.notification_message, text.value)
|
||||||
|
@ -49,7 +55,7 @@ class ActionNotification(mainApp: MainApp) : Action(mainApp) {
|
||||||
|
|
||||||
override fun generateDialog(root: LinearLayout) {
|
override fun generateDialog(root: LinearLayout) {
|
||||||
LayoutBuilder()
|
LayoutBuilder()
|
||||||
.add(LabelWithElement(mainApp,resourceHelper.gs(R.string.message_short), "", text))
|
.add(LabelWithElement(injector, resourceHelper.gs(R.string.message_short), "", text))
|
||||||
.build(root)
|
.build(root)
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -2,20 +2,28 @@ package info.nightscout.androidaps.plugins.general.automation.actions
|
||||||
|
|
||||||
import android.widget.LinearLayout
|
import android.widget.LinearLayout
|
||||||
import androidx.annotation.DrawableRes
|
import androidx.annotation.DrawableRes
|
||||||
import info.nightscout.androidaps.MainApp
|
import dagger.android.HasAndroidInjector
|
||||||
import info.nightscout.androidaps.R
|
import info.nightscout.androidaps.R
|
||||||
import info.nightscout.androidaps.data.PumpEnactResult
|
import info.nightscout.androidaps.data.PumpEnactResult
|
||||||
|
import info.nightscout.androidaps.interfaces.ActivePluginProvider
|
||||||
import info.nightscout.androidaps.logging.LTag
|
import info.nightscout.androidaps.logging.LTag
|
||||||
|
import info.nightscout.androidaps.plugins.configBuilder.ProfileFunction
|
||||||
import info.nightscout.androidaps.plugins.general.automation.elements.InputProfileName
|
import info.nightscout.androidaps.plugins.general.automation.elements.InputProfileName
|
||||||
import info.nightscout.androidaps.plugins.general.automation.elements.LabelWithElement
|
import info.nightscout.androidaps.plugins.general.automation.elements.LabelWithElement
|
||||||
import info.nightscout.androidaps.plugins.general.automation.elements.LayoutBuilder
|
import info.nightscout.androidaps.plugins.general.automation.elements.LayoutBuilder
|
||||||
import info.nightscout.androidaps.queue.Callback
|
import info.nightscout.androidaps.queue.Callback
|
||||||
import info.nightscout.androidaps.utils.DateUtil
|
import info.nightscout.androidaps.utils.DateUtil
|
||||||
import info.nightscout.androidaps.utils.JsonHelper
|
import info.nightscout.androidaps.utils.JsonHelper
|
||||||
|
import info.nightscout.androidaps.utils.resources.ResourceHelper
|
||||||
import org.json.JSONObject
|
import org.json.JSONObject
|
||||||
|
import javax.inject.Inject
|
||||||
|
|
||||||
class ActionProfileSwitch(mainApp: MainApp) : Action(mainApp) {
|
class ActionProfileSwitch(injector: HasAndroidInjector) : Action(injector) {
|
||||||
var inputProfileName: InputProfileName = InputProfileName(mainApp, "")
|
@Inject lateinit var resourceHelper: ResourceHelper
|
||||||
|
@Inject lateinit var activePlugin: ActivePluginProvider
|
||||||
|
@Inject lateinit var profileFunction: ProfileFunction
|
||||||
|
|
||||||
|
var inputProfileName: InputProfileName = InputProfileName(injector, "")
|
||||||
|
|
||||||
override fun friendlyName(): Int = R.string.profilename
|
override fun friendlyName(): Int = R.string.profilename
|
||||||
override fun shortDescription(): String = resourceHelper.gs(R.string.changengetoprofilename, inputProfileName.value)
|
override fun shortDescription(): String = resourceHelper.gs(R.string.changengetoprofilename, inputProfileName.value)
|
||||||
|
@ -39,19 +47,19 @@ class ActionProfileSwitch(mainApp: MainApp) : Action(mainApp) {
|
||||||
callback.result(PumpEnactResult().success(true).comment(R.string.alreadyset))?.run()
|
callback.result(PumpEnactResult().success(true).comment(R.string.alreadyset))?.run()
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
val profileStore = configBuilderPlugin.activeProfileInterface.profile ?: return
|
val profileStore = activePlugin.activeProfileInterface.profile ?: return
|
||||||
if (profileStore.getSpecificProfile(inputProfileName.value) == null) {
|
if (profileStore.getSpecificProfile(inputProfileName.value) == null) {
|
||||||
aapsLogger.error(LTag.AUTOMATION, "Selected profile does not exist! - ${inputProfileName.value}")
|
aapsLogger.error(LTag.AUTOMATION, "Selected profile does not exist! - ${inputProfileName.value}")
|
||||||
callback.result(PumpEnactResult().success(false).comment(R.string.notexists))?.run()
|
callback.result(PumpEnactResult().success(false).comment(R.string.notexists))?.run()
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
treatmentsPlugin.doProfileSwitch(profileStore, inputProfileName.value, 0, 100, 0, DateUtil.now())
|
activePlugin.activeTreatments.doProfileSwitch(profileStore, inputProfileName.value, 0, 100, 0, DateUtil.now())
|
||||||
callback.result(PumpEnactResult().success(true).comment(R.string.ok))?.run()
|
callback.result(PumpEnactResult().success(true).comment(R.string.ok))?.run()
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun generateDialog(root: LinearLayout) {
|
override fun generateDialog(root: LinearLayout) {
|
||||||
LayoutBuilder()
|
LayoutBuilder()
|
||||||
.add(LabelWithElement(mainApp, resourceHelper.gs(R.string.profilename), "", inputProfileName))
|
.add(LabelWithElement(injector, resourceHelper.gs(R.string.profilename), "", inputProfileName))
|
||||||
.build(root)
|
.build(root)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -2,9 +2,10 @@ package info.nightscout.androidaps.plugins.general.automation.actions
|
||||||
|
|
||||||
import android.widget.LinearLayout
|
import android.widget.LinearLayout
|
||||||
import androidx.annotation.DrawableRes
|
import androidx.annotation.DrawableRes
|
||||||
import info.nightscout.androidaps.MainApp
|
import dagger.android.HasAndroidInjector
|
||||||
import info.nightscout.androidaps.R
|
import info.nightscout.androidaps.R
|
||||||
import info.nightscout.androidaps.data.PumpEnactResult
|
import info.nightscout.androidaps.data.PumpEnactResult
|
||||||
|
import info.nightscout.androidaps.interfaces.ActivePluginProvider
|
||||||
import info.nightscout.androidaps.plugins.general.automation.elements.Comparator
|
import info.nightscout.androidaps.plugins.general.automation.elements.Comparator
|
||||||
import info.nightscout.androidaps.plugins.general.automation.elements.InputDuration
|
import info.nightscout.androidaps.plugins.general.automation.elements.InputDuration
|
||||||
import info.nightscout.androidaps.plugins.general.automation.elements.InputPercent
|
import info.nightscout.androidaps.plugins.general.automation.elements.InputPercent
|
||||||
|
@ -13,11 +14,16 @@ import info.nightscout.androidaps.plugins.general.automation.elements.LayoutBuil
|
||||||
import info.nightscout.androidaps.plugins.general.automation.triggers.TriggerProfilePercent
|
import info.nightscout.androidaps.plugins.general.automation.triggers.TriggerProfilePercent
|
||||||
import info.nightscout.androidaps.queue.Callback
|
import info.nightscout.androidaps.queue.Callback
|
||||||
import info.nightscout.androidaps.utils.JsonHelper
|
import info.nightscout.androidaps.utils.JsonHelper
|
||||||
|
import info.nightscout.androidaps.utils.resources.ResourceHelper
|
||||||
import org.json.JSONObject
|
import org.json.JSONObject
|
||||||
|
import javax.inject.Inject
|
||||||
|
|
||||||
class ActionProfileSwitchPercent(mainApp: MainApp) : Action(mainApp) {
|
class ActionProfileSwitchPercent(injector: HasAndroidInjector) : Action(injector) {
|
||||||
var pct = InputPercent(mainApp)
|
@Inject lateinit var resourceHelper: ResourceHelper
|
||||||
var duration = InputDuration(mainApp, 0, InputDuration.TimeUnit.MINUTES)
|
@Inject lateinit var activePlugin: ActivePluginProvider
|
||||||
|
|
||||||
|
var pct = InputPercent(injector)
|
||||||
|
var duration = InputDuration(injector, 0, InputDuration.TimeUnit.MINUTES)
|
||||||
|
|
||||||
override fun friendlyName(): Int = R.string.profilepercentage
|
override fun friendlyName(): Int = R.string.profilepercentage
|
||||||
override fun shortDescription(): String =
|
override fun shortDescription(): String =
|
||||||
|
@ -27,18 +33,18 @@ class ActionProfileSwitchPercent(mainApp: MainApp) : Action(mainApp) {
|
||||||
@DrawableRes override fun icon(): Int = R.drawable.icon_actions_profileswitch
|
@DrawableRes override fun icon(): Int = R.drawable.icon_actions_profileswitch
|
||||||
|
|
||||||
init {
|
init {
|
||||||
precondition = TriggerProfilePercent(mainApp, 100.0, Comparator.Compare.IS_EQUAL)
|
precondition = TriggerProfilePercent(injector, 100.0, Comparator.Compare.IS_EQUAL)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun doAction(callback: Callback) {
|
override fun doAction(callback: Callback) {
|
||||||
treatmentsPlugin.doProfileSwitch(duration.value, pct.value.toInt(), 0)
|
activePlugin.activeTreatments.doProfileSwitch(duration.value, pct.value.toInt(), 0)
|
||||||
callback.result(PumpEnactResult().success(true).comment(R.string.ok))?.run()
|
callback.result(PumpEnactResult().success(true).comment(R.string.ok))?.run()
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun generateDialog(root: LinearLayout) {
|
override fun generateDialog(root: LinearLayout) {
|
||||||
LayoutBuilder()
|
LayoutBuilder()
|
||||||
.add(LabelWithElement(mainApp, resourceHelper.gs(R.string.percent_u), "", pct))
|
.add(LabelWithElement(injector, resourceHelper.gs(R.string.percent_u), "", pct))
|
||||||
.add(LabelWithElement(mainApp, resourceHelper.gs(R.string.careportal_newnstreatment_duration_min_label), "", duration))
|
.add(LabelWithElement(injector, resourceHelper.gs(R.string.careportal_newnstreatment_duration_min_label), "", duration))
|
||||||
.build(root)
|
.build(root)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,18 +1,24 @@
|
||||||
package info.nightscout.androidaps.plugins.general.automation.actions
|
package info.nightscout.androidaps.plugins.general.automation.actions
|
||||||
|
|
||||||
import android.widget.LinearLayout
|
import android.widget.LinearLayout
|
||||||
import info.nightscout.androidaps.MainApp
|
import dagger.android.HasAndroidInjector
|
||||||
import info.nightscout.androidaps.R
|
import info.nightscout.androidaps.R
|
||||||
import info.nightscout.androidaps.data.PumpEnactResult
|
import info.nightscout.androidaps.data.PumpEnactResult
|
||||||
import info.nightscout.androidaps.plugins.general.automation.elements.InputString
|
import info.nightscout.androidaps.plugins.general.automation.elements.InputString
|
||||||
import info.nightscout.androidaps.plugins.general.automation.elements.LabelWithElement
|
import info.nightscout.androidaps.plugins.general.automation.elements.LabelWithElement
|
||||||
import info.nightscout.androidaps.plugins.general.automation.elements.LayoutBuilder
|
import info.nightscout.androidaps.plugins.general.automation.elements.LayoutBuilder
|
||||||
|
import info.nightscout.androidaps.plugins.general.smsCommunicator.SmsCommunicatorPlugin
|
||||||
import info.nightscout.androidaps.queue.Callback
|
import info.nightscout.androidaps.queue.Callback
|
||||||
import info.nightscout.androidaps.utils.JsonHelper
|
import info.nightscout.androidaps.utils.JsonHelper
|
||||||
|
import info.nightscout.androidaps.utils.resources.ResourceHelper
|
||||||
import org.json.JSONObject
|
import org.json.JSONObject
|
||||||
|
import javax.inject.Inject
|
||||||
|
|
||||||
class ActionSendSMS(mainApp: MainApp) : Action(mainApp) {
|
class ActionSendSMS(injector: HasAndroidInjector) : Action(injector) {
|
||||||
var text = InputString(mainApp)
|
@Inject lateinit var resourceHelper: ResourceHelper
|
||||||
|
@Inject lateinit var smsCommunicatorPlugin: SmsCommunicatorPlugin
|
||||||
|
|
||||||
|
var text = InputString(injector)
|
||||||
|
|
||||||
override fun friendlyName(): Int = R.string.sendsmsactiondescription
|
override fun friendlyName(): Int = R.string.sendsmsactiondescription
|
||||||
override fun shortDescription(): String = resourceHelper.gs(R.string.sendsmsactionlabel, text.value)
|
override fun shortDescription(): String = resourceHelper.gs(R.string.sendsmsactionlabel, text.value)
|
||||||
|
@ -41,7 +47,7 @@ class ActionSendSMS(mainApp: MainApp) : Action(mainApp) {
|
||||||
|
|
||||||
override fun generateDialog(root: LinearLayout) {
|
override fun generateDialog(root: LinearLayout) {
|
||||||
LayoutBuilder()
|
LayoutBuilder()
|
||||||
.add(LabelWithElement(mainApp, resourceHelper.gs(R.string.sendsmsactiontext), "", text))
|
.add(LabelWithElement(injector, resourceHelper.gs(R.string.sendsmsactiontext), "", text))
|
||||||
.build(root)
|
.build(root)
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -2,13 +2,14 @@ package info.nightscout.androidaps.plugins.general.automation.actions
|
||||||
|
|
||||||
import android.widget.LinearLayout
|
import android.widget.LinearLayout
|
||||||
import androidx.annotation.DrawableRes
|
import androidx.annotation.DrawableRes
|
||||||
|
import dagger.android.HasAndroidInjector
|
||||||
import info.nightscout.androidaps.Constants
|
import info.nightscout.androidaps.Constants
|
||||||
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.PumpEnactResult
|
import info.nightscout.androidaps.data.PumpEnactResult
|
||||||
import info.nightscout.androidaps.db.Source
|
import info.nightscout.androidaps.db.Source
|
||||||
import info.nightscout.androidaps.db.TempTarget
|
import info.nightscout.androidaps.db.TempTarget
|
||||||
|
import info.nightscout.androidaps.interfaces.ActivePluginProvider
|
||||||
import info.nightscout.androidaps.plugins.general.automation.elements.ComparatorExists
|
import info.nightscout.androidaps.plugins.general.automation.elements.ComparatorExists
|
||||||
import info.nightscout.androidaps.plugins.general.automation.elements.InputDuration
|
import info.nightscout.androidaps.plugins.general.automation.elements.InputDuration
|
||||||
import info.nightscout.androidaps.plugins.general.automation.elements.InputTempTarget
|
import info.nightscout.androidaps.plugins.general.automation.elements.InputTempTarget
|
||||||
|
@ -19,14 +20,19 @@ import info.nightscout.androidaps.queue.Callback
|
||||||
import info.nightscout.androidaps.utils.DateUtil
|
import info.nightscout.androidaps.utils.DateUtil
|
||||||
import info.nightscout.androidaps.utils.JsonHelper
|
import info.nightscout.androidaps.utils.JsonHelper
|
||||||
import info.nightscout.androidaps.utils.JsonHelper.safeGetDouble
|
import info.nightscout.androidaps.utils.JsonHelper.safeGetDouble
|
||||||
|
import info.nightscout.androidaps.utils.resources.ResourceHelper
|
||||||
import org.json.JSONObject
|
import org.json.JSONObject
|
||||||
|
import javax.inject.Inject
|
||||||
|
|
||||||
class ActionStartTempTarget(mainApp: MainApp) : Action(mainApp) {
|
class ActionStartTempTarget(injector: HasAndroidInjector) : Action(injector) {
|
||||||
var value = InputTempTarget(mainApp)
|
@Inject lateinit var resourceHelper: ResourceHelper
|
||||||
var duration = InputDuration(mainApp, 0, InputDuration.TimeUnit.MINUTES)
|
@Inject lateinit var activePlugin: ActivePluginProvider
|
||||||
|
|
||||||
|
var value = InputTempTarget(injector)
|
||||||
|
var duration = InputDuration(injector, 0, InputDuration.TimeUnit.MINUTES)
|
||||||
|
|
||||||
init {
|
init {
|
||||||
precondition = TriggerTempTarget(mainApp, ComparatorExists.Compare.NOT_EXISTS)
|
precondition = TriggerTempTarget(injector, ComparatorExists.Compare.NOT_EXISTS)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun friendlyName(): Int = R.string.starttemptarget
|
override fun friendlyName(): Int = R.string.starttemptarget
|
||||||
|
@ -34,15 +40,15 @@ class ActionStartTempTarget(mainApp: MainApp) : Action(mainApp) {
|
||||||
@DrawableRes override fun icon(): Int = R.drawable.icon_cp_cgm_target
|
@DrawableRes override fun icon(): Int = R.drawable.icon_cp_cgm_target
|
||||||
|
|
||||||
override fun doAction(callback: Callback) {
|
override fun doAction(callback: Callback) {
|
||||||
treatmentsPlugin.addToHistoryTempTarget(tt())
|
activePlugin.activeTreatments.addToHistoryTempTarget(tt())
|
||||||
callback.result(PumpEnactResult().success(true).comment(R.string.ok))?.run()
|
callback.result(PumpEnactResult().success(true).comment(R.string.ok))?.run()
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun generateDialog(root: LinearLayout) {
|
override fun generateDialog(root: LinearLayout) {
|
||||||
val unitResId = if (value.units == Constants.MGDL) R.string.mgdl else R.string.mmol
|
val unitResId = if (value.units == Constants.MGDL) R.string.mgdl else R.string.mmol
|
||||||
LayoutBuilder()
|
LayoutBuilder()
|
||||||
.add(LabelWithElement(mainApp, resourceHelper.gs(R.string.careportal_temporarytarget) + "\n[" + resourceHelper.gs(unitResId) + "]", "", value))
|
.add(LabelWithElement(injector, resourceHelper.gs(R.string.careportal_temporarytarget) + "\n[" + resourceHelper.gs(unitResId) + "]", "", value))
|
||||||
.add(LabelWithElement(mainApp, resourceHelper.gs(R.string.careportal_newnstreatment_duration_min_label), "", duration))
|
.add(LabelWithElement(injector, resourceHelper.gs(R.string.careportal_newnstreatment_duration_min_label), "", duration))
|
||||||
.build(root)
|
.build(root)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,14 +1,19 @@
|
||||||
package info.nightscout.androidaps.plugins.general.automation.actions
|
package info.nightscout.androidaps.plugins.general.automation.actions
|
||||||
|
|
||||||
import info.nightscout.androidaps.MainApp
|
import dagger.android.HasAndroidInjector
|
||||||
import info.nightscout.androidaps.R
|
import info.nightscout.androidaps.R
|
||||||
import info.nightscout.androidaps.data.PumpEnactResult
|
import info.nightscout.androidaps.data.PumpEnactResult
|
||||||
import info.nightscout.androidaps.db.Source
|
import info.nightscout.androidaps.db.Source
|
||||||
import info.nightscout.androidaps.db.TempTarget
|
import info.nightscout.androidaps.db.TempTarget
|
||||||
|
import info.nightscout.androidaps.interfaces.ActivePluginProvider
|
||||||
import info.nightscout.androidaps.queue.Callback
|
import info.nightscout.androidaps.queue.Callback
|
||||||
import info.nightscout.androidaps.utils.DateUtil
|
import info.nightscout.androidaps.utils.DateUtil
|
||||||
|
import info.nightscout.androidaps.utils.resources.ResourceHelper
|
||||||
|
import javax.inject.Inject
|
||||||
|
|
||||||
class ActionStopTempTarget(mainApp: MainApp) : Action(mainApp) {
|
class ActionStopTempTarget(injector: HasAndroidInjector) : Action(injector) {
|
||||||
|
@Inject lateinit var resourceHelper: ResourceHelper
|
||||||
|
@Inject lateinit var activePlugin: ActivePluginProvider
|
||||||
|
|
||||||
override fun friendlyName(): Int = R.string.stoptemptarget
|
override fun friendlyName(): Int = R.string.stoptemptarget
|
||||||
override fun shortDescription(): String = resourceHelper.gs(R.string.stoptemptarget)
|
override fun shortDescription(): String = resourceHelper.gs(R.string.stoptemptarget)
|
||||||
|
@ -21,7 +26,7 @@ class ActionStopTempTarget(mainApp: MainApp) : Action(mainApp) {
|
||||||
.reason("Automation")
|
.reason("Automation")
|
||||||
.source(Source.USER)
|
.source(Source.USER)
|
||||||
.low(0.0).high(0.0)
|
.low(0.0).high(0.0)
|
||||||
treatmentsPlugin.addToHistoryTempTarget(tempTarget)
|
activePlugin.activeTreatments.addToHistoryTempTarget(tempTarget)
|
||||||
callback.result(PumpEnactResult().success(true).comment(R.string.ok))?.run()
|
callback.result(PumpEnactResult().success(true).comment(R.string.ok))?.run()
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -6,12 +6,15 @@ import android.widget.ArrayAdapter
|
||||||
import android.widget.LinearLayout
|
import android.widget.LinearLayout
|
||||||
import android.widget.Spinner
|
import android.widget.Spinner
|
||||||
import androidx.annotation.StringRes
|
import androidx.annotation.StringRes
|
||||||
import info.nightscout.androidaps.MainApp
|
import dagger.android.HasAndroidInjector
|
||||||
import info.nightscout.androidaps.R
|
import info.nightscout.androidaps.R
|
||||||
import info.nightscout.androidaps.utils.resources.ResourceHelper
|
import info.nightscout.androidaps.utils.resources.ResourceHelper
|
||||||
import java.util.*
|
import java.util.*
|
||||||
|
import javax.inject.Inject
|
||||||
|
|
||||||
|
class Comparator(injector: HasAndroidInjector) : Element(injector) {
|
||||||
|
@Inject lateinit var resourceHelper: ResourceHelper
|
||||||
|
|
||||||
class Comparator(mainApp: MainApp) : Element(mainApp) {
|
|
||||||
enum class Compare {
|
enum class Compare {
|
||||||
IS_LESSER,
|
IS_LESSER,
|
||||||
IS_EQUAL_OR_LESSER,
|
IS_EQUAL_OR_LESSER,
|
||||||
|
@ -53,7 +56,7 @@ class Comparator(mainApp: MainApp) : Element(mainApp) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
constructor(mainApp: MainApp, value : Compare) : this(mainApp) {
|
constructor(injector: HasAndroidInjector, value: Compare) : this(injector) {
|
||||||
this.value = value
|
this.value = value
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -6,12 +6,15 @@ import android.widget.ArrayAdapter
|
||||||
import android.widget.LinearLayout
|
import android.widget.LinearLayout
|
||||||
import android.widget.Spinner
|
import android.widget.Spinner
|
||||||
import androidx.annotation.StringRes
|
import androidx.annotation.StringRes
|
||||||
import info.nightscout.androidaps.MainApp
|
import dagger.android.HasAndroidInjector
|
||||||
import info.nightscout.androidaps.R
|
import info.nightscout.androidaps.R
|
||||||
import info.nightscout.androidaps.utils.resources.ResourceHelper
|
import info.nightscout.androidaps.utils.resources.ResourceHelper
|
||||||
import java.util.*
|
import java.util.*
|
||||||
|
import javax.inject.Inject
|
||||||
|
|
||||||
|
class ComparatorExists(injector: HasAndroidInjector) : Element(injector) {
|
||||||
|
@Inject lateinit var resourceHelper: ResourceHelper
|
||||||
|
|
||||||
class ComparatorExists(mainApp: MainApp) : Element(mainApp) {
|
|
||||||
enum class Compare {
|
enum class Compare {
|
||||||
EXISTS, NOT_EXISTS;
|
EXISTS, NOT_EXISTS;
|
||||||
|
|
||||||
|
@ -30,7 +33,7 @@ class ComparatorExists(mainApp: MainApp) : Element(mainApp) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
constructor(mainApp: MainApp, value: Compare) : this(mainApp) {
|
constructor(injector: HasAndroidInjector, value: Compare) : this(injector) {
|
||||||
this.value = value
|
this.value = value
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,20 +1,13 @@
|
||||||
package info.nightscout.androidaps.plugins.general.automation.elements
|
package info.nightscout.androidaps.plugins.general.automation.elements
|
||||||
|
|
||||||
import android.widget.LinearLayout
|
import android.widget.LinearLayout
|
||||||
import info.nightscout.androidaps.MainApp
|
import dagger.android.HasAndroidInjector
|
||||||
import info.nightscout.androidaps.plugins.configBuilder.ConfigBuilderPlugin
|
|
||||||
import info.nightscout.androidaps.plugins.configBuilder.ProfileFunction
|
|
||||||
import info.nightscout.androidaps.utils.resources.ResourceHelper
|
|
||||||
import javax.inject.Inject
|
|
||||||
|
|
||||||
abstract class Element(val mainApp: MainApp) {
|
abstract class Element(val injector: HasAndroidInjector) {
|
||||||
@Inject lateinit var resourceHelper: ResourceHelper
|
|
||||||
@Inject lateinit var profileFunction: ProfileFunction
|
|
||||||
@Inject lateinit var configBuilderPlugin: ConfigBuilderPlugin
|
|
||||||
|
|
||||||
abstract fun addToLayout(root: LinearLayout)
|
abstract fun addToLayout(root: LinearLayout)
|
||||||
|
|
||||||
init {
|
init {
|
||||||
mainApp.androidInjector().inject(this)
|
injector.androidInjector().inject(this)
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -1,13 +1,17 @@
|
||||||
package info.nightscout.androidaps.plugins.general.automation.elements
|
package info.nightscout.androidaps.plugins.general.automation.elements
|
||||||
|
|
||||||
import android.widget.LinearLayout
|
import android.widget.LinearLayout
|
||||||
|
import dagger.android.HasAndroidInjector
|
||||||
import info.nightscout.androidaps.Constants
|
import info.nightscout.androidaps.Constants
|
||||||
import info.nightscout.androidaps.MainApp
|
|
||||||
import info.nightscout.androidaps.R
|
import info.nightscout.androidaps.R
|
||||||
|
import info.nightscout.androidaps.plugins.configBuilder.ProfileFunction
|
||||||
import info.nightscout.androidaps.utils.NumberPicker
|
import info.nightscout.androidaps.utils.NumberPicker
|
||||||
import java.text.DecimalFormat
|
import java.text.DecimalFormat
|
||||||
|
import javax.inject.Inject
|
||||||
|
|
||||||
|
class InputBg(injector: HasAndroidInjector) : Element(injector) {
|
||||||
|
@Inject lateinit var profileFunction: ProfileFunction
|
||||||
|
|
||||||
class InputBg(mainApp: MainApp) : Element(mainApp) {
|
|
||||||
var units = Constants.MGDL
|
var units = Constants.MGDL
|
||||||
var value = 0.0
|
var value = 0.0
|
||||||
private var minValue = 0.0
|
private var minValue = 0.0
|
||||||
|
@ -15,9 +19,7 @@ class InputBg(mainApp: MainApp) : Element(mainApp) {
|
||||||
private var step = 0.0
|
private var step = 0.0
|
||||||
private var decimalFormat: DecimalFormat? = null
|
private var decimalFormat: DecimalFormat? = null
|
||||||
|
|
||||||
|
constructor(injector: HasAndroidInjector, value: Double, units: String) : this(injector) {
|
||||||
|
|
||||||
constructor(mainApp: MainApp, value : Double, units: String) : this(mainApp) {
|
|
||||||
setUnits(units)
|
setUnits(units)
|
||||||
this.value = value
|
this.value = value
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,13 +2,13 @@ package info.nightscout.androidaps.plugins.general.automation.elements
|
||||||
|
|
||||||
import android.widget.Button
|
import android.widget.Button
|
||||||
import android.widget.LinearLayout
|
import android.widget.LinearLayout
|
||||||
import info.nightscout.androidaps.MainApp
|
import dagger.android.HasAndroidInjector
|
||||||
|
|
||||||
class InputButton(mainApp: MainApp) : Element(mainApp) {
|
class InputButton(injector: HasAndroidInjector) : Element(injector) {
|
||||||
var text: String? = null
|
var text: String? = null
|
||||||
var runnable: Runnable? = null
|
var runnable: Runnable? = null
|
||||||
|
|
||||||
constructor(mainApp: MainApp, text: String, runnable: Runnable) : this(mainApp) {
|
constructor(injector: HasAndroidInjector, text: String, runnable: Runnable) : this(injector) {
|
||||||
this.text = text
|
this.text = text
|
||||||
this.runnable = runnable
|
this.runnable = runnable
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,22 +2,29 @@ package info.nightscout.androidaps.plugins.general.automation.elements
|
||||||
|
|
||||||
import android.app.DatePickerDialog
|
import android.app.DatePickerDialog
|
||||||
import android.app.TimePickerDialog
|
import android.app.TimePickerDialog
|
||||||
|
import android.content.Context
|
||||||
import android.graphics.Typeface
|
import android.graphics.Typeface
|
||||||
import android.text.format.DateFormat
|
import android.text.format.DateFormat
|
||||||
import android.view.ViewGroup
|
import android.view.ViewGroup
|
||||||
import android.widget.LinearLayout
|
import android.widget.LinearLayout
|
||||||
import android.widget.TextView
|
import android.widget.TextView
|
||||||
import info.nightscout.androidaps.MainApp
|
import dagger.android.HasAndroidInjector
|
||||||
import info.nightscout.androidaps.R
|
import info.nightscout.androidaps.R
|
||||||
import info.nightscout.androidaps.utils.DateUtil
|
import info.nightscout.androidaps.utils.DateUtil
|
||||||
|
import info.nightscout.androidaps.utils.resources.ResourceHelper
|
||||||
import java.util.*
|
import java.util.*
|
||||||
|
import javax.inject.Inject
|
||||||
|
|
||||||
|
class InputDateTime(injector: HasAndroidInjector) : Element(injector) {
|
||||||
|
@Inject lateinit var resourceHelper: ResourceHelper
|
||||||
|
@Inject lateinit var context: Context
|
||||||
|
|
||||||
class InputDateTime(mainApp: MainApp) : Element(mainApp) {
|
|
||||||
var value: Long = DateUtil.now()
|
var value: Long = DateUtil.now()
|
||||||
|
|
||||||
constructor(mainApp: MainApp, value : Long) : this(mainApp) {
|
constructor(injector: HasAndroidInjector, value: Long) : this(injector) {
|
||||||
this.value = value
|
this.value = value
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun addToLayout(root: LinearLayout) {
|
override fun addToLayout(root: LinearLayout) {
|
||||||
val label = TextView(root.context)
|
val label = TextView(root.context)
|
||||||
val dateButton = TextView(root.context)
|
val dateButton = TextView(root.context)
|
||||||
|
@ -66,7 +73,7 @@ class InputDateTime(mainApp: MainApp) : Element(mainApp) {
|
||||||
TimePickerDialog(it, timeSetListener,
|
TimePickerDialog(it, timeSetListener,
|
||||||
cal.get(Calendar.HOUR_OF_DAY),
|
cal.get(Calendar.HOUR_OF_DAY),
|
||||||
cal.get(Calendar.MINUTE),
|
cal.get(Calendar.MINUTE),
|
||||||
DateFormat.is24HourFormat(mainApp)
|
DateFormat.is24HourFormat(context)
|
||||||
).show()
|
).show()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,14 +7,17 @@ import android.widget.ArrayAdapter
|
||||||
import android.widget.LinearLayout
|
import android.widget.LinearLayout
|
||||||
import android.widget.Spinner
|
import android.widget.Spinner
|
||||||
import androidx.annotation.StringRes
|
import androidx.annotation.StringRes
|
||||||
import info.nightscout.androidaps.MainApp
|
import dagger.android.HasAndroidInjector
|
||||||
import info.nightscout.androidaps.R
|
import info.nightscout.androidaps.R
|
||||||
import info.nightscout.androidaps.utils.NumberPicker
|
import info.nightscout.androidaps.utils.NumberPicker
|
||||||
import info.nightscout.androidaps.utils.resources.ResourceHelper
|
import info.nightscout.androidaps.utils.resources.ResourceHelper
|
||||||
import java.text.DecimalFormat
|
import java.text.DecimalFormat
|
||||||
import java.util.*
|
import java.util.*
|
||||||
|
import javax.inject.Inject
|
||||||
|
|
||||||
|
class InputDelta(injector: HasAndroidInjector) : Element(injector) {
|
||||||
|
@Inject lateinit var resourceHelper: ResourceHelper
|
||||||
|
|
||||||
class InputDelta(mainApp: MainApp) : Element(mainApp) {
|
|
||||||
enum class DeltaType {
|
enum class DeltaType {
|
||||||
DELTA, SHORT_AVERAGE, LONG_AVERAGE;
|
DELTA, SHORT_AVERAGE, LONG_AVERAGE;
|
||||||
|
|
||||||
|
@ -43,7 +46,7 @@ class InputDelta(mainApp: MainApp) : Element(mainApp) {
|
||||||
private var decimalFormat: DecimalFormat? = null
|
private var decimalFormat: DecimalFormat? = null
|
||||||
var deltaType: DeltaType = DeltaType.DELTA
|
var deltaType: DeltaType = DeltaType.DELTA
|
||||||
|
|
||||||
constructor(mainApp: MainApp, value: Double, minValue: Double, maxValue: Double, step: Double, decimalFormat: DecimalFormat, deltaType: DeltaType) : this(mainApp) {
|
constructor(injector: HasAndroidInjector, value: Double, minValue: Double, maxValue: Double, step: Double, decimalFormat: DecimalFormat, deltaType: DeltaType) : this(injector) {
|
||||||
this.value = value
|
this.value = value
|
||||||
this.minValue = minValue
|
this.minValue = minValue
|
||||||
this.maxValue = maxValue
|
this.maxValue = maxValue
|
||||||
|
@ -52,7 +55,7 @@ class InputDelta(mainApp: MainApp) : Element(mainApp) {
|
||||||
this.deltaType = deltaType
|
this.deltaType = deltaType
|
||||||
}
|
}
|
||||||
|
|
||||||
constructor(mainApp: MainApp, inputDelta: InputDelta) : this(mainApp) {
|
constructor(injector: HasAndroidInjector, inputDelta: InputDelta) : this(injector) {
|
||||||
value = inputDelta.value
|
value = inputDelta.value
|
||||||
minValue = inputDelta.minValue
|
minValue = inputDelta.minValue
|
||||||
maxValue = inputDelta.maxValue
|
maxValue = inputDelta.maxValue
|
||||||
|
|
|
@ -1,12 +1,12 @@
|
||||||
package info.nightscout.androidaps.plugins.general.automation.elements
|
package info.nightscout.androidaps.plugins.general.automation.elements
|
||||||
|
|
||||||
import android.widget.LinearLayout
|
import android.widget.LinearLayout
|
||||||
import info.nightscout.androidaps.MainApp
|
import dagger.android.HasAndroidInjector
|
||||||
import info.nightscout.androidaps.R
|
import info.nightscout.androidaps.R
|
||||||
import info.nightscout.androidaps.utils.NumberPicker
|
import info.nightscout.androidaps.utils.NumberPicker
|
||||||
import java.text.DecimalFormat
|
import java.text.DecimalFormat
|
||||||
|
|
||||||
class InputDouble(mainApp: MainApp) : Element(mainApp) {
|
class InputDouble(injector: HasAndroidInjector) : Element(injector) {
|
||||||
var value = 0.0
|
var value = 0.0
|
||||||
private var minValue = 0.0
|
private var minValue = 0.0
|
||||||
private var maxValue = 0.0
|
private var maxValue = 0.0
|
||||||
|
@ -14,7 +14,7 @@ class InputDouble(mainApp: MainApp) : Element(mainApp) {
|
||||||
private var decimalFormat: DecimalFormat? = null
|
private var decimalFormat: DecimalFormat? = null
|
||||||
private var numberPicker: NumberPicker? = null
|
private var numberPicker: NumberPicker? = null
|
||||||
|
|
||||||
constructor(mainApp: MainApp, value: Double, minValue: Double, maxValue: Double, step: Double, decimalFormat: DecimalFormat) : this(mainApp) {
|
constructor(injector: HasAndroidInjector, value: Double, minValue: Double, maxValue: Double, step: Double, decimalFormat: DecimalFormat) : this(injector) {
|
||||||
this.value = value
|
this.value = value
|
||||||
this.minValue = minValue
|
this.minValue = minValue
|
||||||
this.maxValue = maxValue
|
this.maxValue = maxValue
|
||||||
|
@ -22,7 +22,7 @@ class InputDouble(mainApp: MainApp) : Element(mainApp) {
|
||||||
this.decimalFormat = decimalFormat
|
this.decimalFormat = decimalFormat
|
||||||
}
|
}
|
||||||
|
|
||||||
constructor(mainApp: MainApp, inputDouble: InputDouble) : this(mainApp) {
|
constructor(injector: HasAndroidInjector, inputDouble: InputDouble) : this(injector) {
|
||||||
this.value = inputDouble.value
|
this.value = inputDouble.value
|
||||||
this.minValue = inputDouble.minValue
|
this.minValue = inputDouble.minValue
|
||||||
this.maxValue = inputDouble.maxValue
|
this.maxValue = inputDouble.maxValue
|
||||||
|
|
|
@ -1,17 +1,17 @@
|
||||||
package info.nightscout.androidaps.plugins.general.automation.elements
|
package info.nightscout.androidaps.plugins.general.automation.elements
|
||||||
|
|
||||||
import android.widget.LinearLayout
|
import android.widget.LinearLayout
|
||||||
import info.nightscout.androidaps.MainApp
|
import dagger.android.HasAndroidInjector
|
||||||
import info.nightscout.androidaps.R
|
import info.nightscout.androidaps.R
|
||||||
import info.nightscout.androidaps.utils.NumberPicker
|
import info.nightscout.androidaps.utils.NumberPicker
|
||||||
import java.text.DecimalFormat
|
import java.text.DecimalFormat
|
||||||
|
|
||||||
class InputDuration(mainApp: MainApp) : Element(mainApp) {
|
class InputDuration(injector: HasAndroidInjector) : Element(injector) {
|
||||||
enum class TimeUnit {
|
enum class TimeUnit {
|
||||||
MINUTES, HOURS
|
MINUTES, HOURS
|
||||||
}
|
}
|
||||||
|
|
||||||
constructor(mainApp: MainApp, value: Int, unit: TimeUnit) : this(mainApp) {
|
constructor(injector: HasAndroidInjector, value: Int, unit: TimeUnit) : this(injector) {
|
||||||
this.unit = unit
|
this.unit = unit
|
||||||
this.value = value
|
this.value = value
|
||||||
}
|
}
|
||||||
|
@ -31,7 +31,7 @@ class InputDuration(mainApp: MainApp) : Element(mainApp) {
|
||||||
}
|
}
|
||||||
|
|
||||||
fun duplicate(): InputDuration {
|
fun duplicate(): InputDuration {
|
||||||
val i = InputDuration(mainApp)
|
val i = InputDuration(injector)
|
||||||
i.unit = unit
|
i.unit = unit
|
||||||
i.value = value
|
i.value = value
|
||||||
return i
|
return i
|
||||||
|
|
|
@ -1,15 +1,15 @@
|
||||||
package info.nightscout.androidaps.plugins.general.automation.elements
|
package info.nightscout.androidaps.plugins.general.automation.elements
|
||||||
|
|
||||||
import android.widget.LinearLayout
|
import android.widget.LinearLayout
|
||||||
import info.nightscout.androidaps.MainApp
|
import dagger.android.HasAndroidInjector
|
||||||
import info.nightscout.androidaps.R
|
import info.nightscout.androidaps.R
|
||||||
import info.nightscout.androidaps.utils.NumberPicker
|
import info.nightscout.androidaps.utils.NumberPicker
|
||||||
import java.text.DecimalFormat
|
import java.text.DecimalFormat
|
||||||
|
|
||||||
class InputInsulin(mainApp: MainApp) : Element(mainApp) {
|
class InputInsulin(injector: HasAndroidInjector) : Element(injector) {
|
||||||
var value = 0.0
|
var value = 0.0
|
||||||
|
|
||||||
constructor(mainApp: MainApp, another: InputInsulin) : this(mainApp) {
|
constructor(injector: HasAndroidInjector, another: InputInsulin) : this(injector) {
|
||||||
value = another.value
|
value = another.value
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -6,12 +6,15 @@ import android.widget.ArrayAdapter
|
||||||
import android.widget.LinearLayout
|
import android.widget.LinearLayout
|
||||||
import android.widget.Spinner
|
import android.widget.Spinner
|
||||||
import androidx.annotation.StringRes
|
import androidx.annotation.StringRes
|
||||||
import info.nightscout.androidaps.MainApp
|
import dagger.android.HasAndroidInjector
|
||||||
import info.nightscout.androidaps.R
|
import info.nightscout.androidaps.R
|
||||||
import info.nightscout.androidaps.utils.resources.ResourceHelper
|
import info.nightscout.androidaps.utils.resources.ResourceHelper
|
||||||
import java.util.*
|
import java.util.*
|
||||||
|
import javax.inject.Inject
|
||||||
|
|
||||||
|
class InputLocationMode(injector: HasAndroidInjector) : Element(injector) {
|
||||||
|
@Inject lateinit var resourceHelper: ResourceHelper
|
||||||
|
|
||||||
class InputLocationMode(mainApp: MainApp) : Element(mainApp) {
|
|
||||||
enum class Mode {
|
enum class Mode {
|
||||||
INSIDE, OUTSIDE, GOING_IN, GOING_OUT;
|
INSIDE, OUTSIDE, GOING_IN, GOING_OUT;
|
||||||
|
|
||||||
|
@ -43,7 +46,7 @@ class InputLocationMode(mainApp: MainApp) : Element(mainApp) {
|
||||||
|
|
||||||
var value: Mode = Mode.INSIDE
|
var value: Mode = Mode.INSIDE
|
||||||
|
|
||||||
constructor(mainApp: MainApp, value: InputLocationMode.Mode) : this(mainApp) {
|
constructor(injector: HasAndroidInjector, value: InputLocationMode.Mode) : this(injector) {
|
||||||
this.value = value
|
this.value = value
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,15 +1,15 @@
|
||||||
package info.nightscout.androidaps.plugins.general.automation.elements
|
package info.nightscout.androidaps.plugins.general.automation.elements
|
||||||
|
|
||||||
import android.widget.LinearLayout
|
import android.widget.LinearLayout
|
||||||
import info.nightscout.androidaps.MainApp
|
import dagger.android.HasAndroidInjector
|
||||||
import info.nightscout.androidaps.R
|
import info.nightscout.androidaps.R
|
||||||
import info.nightscout.androidaps.utils.NumberPicker
|
import info.nightscout.androidaps.utils.NumberPicker
|
||||||
import java.text.DecimalFormat
|
import java.text.DecimalFormat
|
||||||
|
|
||||||
class InputPercent(mainApp: MainApp) : Element(mainApp) {
|
class InputPercent(injector: HasAndroidInjector) : Element(injector) {
|
||||||
var value: Double = 100.0
|
var value: Double = 100.0
|
||||||
|
|
||||||
constructor(mainApp: MainApp, value: Double) : this(mainApp) {
|
constructor(injector: HasAndroidInjector, value: Double) : this(injector) {
|
||||||
this.value = value
|
this.value = value
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -6,19 +6,24 @@ import android.widget.AdapterView
|
||||||
import android.widget.ArrayAdapter
|
import android.widget.ArrayAdapter
|
||||||
import android.widget.LinearLayout
|
import android.widget.LinearLayout
|
||||||
import android.widget.Spinner
|
import android.widget.Spinner
|
||||||
import info.nightscout.androidaps.MainApp
|
import dagger.android.HasAndroidInjector
|
||||||
import info.nightscout.androidaps.R
|
import info.nightscout.androidaps.R
|
||||||
import info.nightscout.androidaps.plugins.configBuilder.ConfigBuilderPlugin
|
import info.nightscout.androidaps.interfaces.ActivePluginProvider
|
||||||
|
import info.nightscout.androidaps.utils.resources.ResourceHelper
|
||||||
|
import javax.inject.Inject
|
||||||
|
|
||||||
|
class InputProfileName(injector: HasAndroidInjector) : Element(injector) {
|
||||||
|
@Inject lateinit var resourceHelper: ResourceHelper
|
||||||
|
@Inject lateinit var activePlugin: ActivePluginProvider
|
||||||
|
|
||||||
class InputProfileName(mainApp: MainApp) : Element(mainApp) {
|
|
||||||
var value: String = ""
|
var value: String = ""
|
||||||
|
|
||||||
constructor(mainApp: MainApp, name: String) : this(mainApp) {
|
constructor(injector: HasAndroidInjector, name: String) : this(injector) {
|
||||||
value = name
|
value = name
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun addToLayout(root: LinearLayout) {
|
override fun addToLayout(root: LinearLayout) {
|
||||||
val profileStore = configBuilderPlugin.activeProfileInterface.profile ?: return
|
val profileStore = activePlugin.activeProfileInterface.profile ?: return
|
||||||
val profileList = profileStore.getProfileList()
|
val profileList = profileStore.getProfileList()
|
||||||
val adapter = ArrayAdapter(root.context, R.layout.spinner_centered, profileList)
|
val adapter = ArrayAdapter(root.context, R.layout.spinner_centered, profileList)
|
||||||
adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item)
|
adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item)
|
||||||
|
|
|
@ -5,9 +5,9 @@ import android.text.TextWatcher
|
||||||
import android.view.ViewGroup
|
import android.view.ViewGroup
|
||||||
import android.widget.EditText
|
import android.widget.EditText
|
||||||
import android.widget.LinearLayout
|
import android.widget.LinearLayout
|
||||||
import info.nightscout.androidaps.MainApp
|
import dagger.android.HasAndroidInjector
|
||||||
|
|
||||||
class InputString(mainApp: MainApp) : Element(mainApp) {
|
class InputString(injector: HasAndroidInjector) : Element(injector) {
|
||||||
var textWatcher: TextWatcher = object : TextWatcher {
|
var textWatcher: TextWatcher = object : TextWatcher {
|
||||||
override fun beforeTextChanged(s: CharSequence, start: Int, count: Int, after: Int) {}
|
override fun beforeTextChanged(s: CharSequence, start: Int, count: Int, after: Int) {}
|
||||||
override fun onTextChanged(s: CharSequence, start: Int, before: Int, count: Int) {}
|
override fun onTextChanged(s: CharSequence, start: Int, before: Int, count: Int) {}
|
||||||
|
@ -17,7 +17,7 @@ class InputString(mainApp: MainApp) : Element(mainApp) {
|
||||||
}
|
}
|
||||||
var value = ""
|
var value = ""
|
||||||
|
|
||||||
constructor(mainApp: MainApp, value: String) : this(mainApp) {
|
constructor(injector: HasAndroidInjector, value: String) : this(injector) {
|
||||||
this.value = value
|
this.value = value
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,13 +1,13 @@
|
||||||
package info.nightscout.androidaps.plugins.general.automation.elements
|
package info.nightscout.androidaps.plugins.general.automation.elements
|
||||||
|
|
||||||
import android.widget.LinearLayout
|
import android.widget.LinearLayout
|
||||||
|
import dagger.android.HasAndroidInjector
|
||||||
import info.nightscout.androidaps.Constants
|
import info.nightscout.androidaps.Constants
|
||||||
import info.nightscout.androidaps.MainApp
|
|
||||||
import info.nightscout.androidaps.R
|
import info.nightscout.androidaps.R
|
||||||
import info.nightscout.androidaps.utils.NumberPicker
|
import info.nightscout.androidaps.utils.NumberPicker
|
||||||
import java.text.DecimalFormat
|
import java.text.DecimalFormat
|
||||||
|
|
||||||
class InputTempTarget(mainApp: MainApp) : Element(mainApp) {
|
class InputTempTarget(injector: HasAndroidInjector) : Element(injector) {
|
||||||
var units = Constants.MGDL
|
var units = Constants.MGDL
|
||||||
var value = 0.0
|
var value = 0.0
|
||||||
|
|
||||||
|
@ -15,7 +15,7 @@ class InputTempTarget(mainApp: MainApp) : Element(mainApp) {
|
||||||
value = if (units == Constants.MMOL) 6.0 else 110.0
|
value = if (units == Constants.MMOL) 6.0 else 110.0
|
||||||
}
|
}
|
||||||
|
|
||||||
constructor(mainApp: MainApp, inputTempTarget: InputTempTarget) : this(mainApp) {
|
constructor(injector: HasAndroidInjector, inputTempTarget: InputTempTarget) : this(injector) {
|
||||||
value = inputTempTarget.value
|
value = inputTempTarget.value
|
||||||
units = inputTempTarget.units
|
units = inputTempTarget.units
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,20 +1,26 @@
|
||||||
package info.nightscout.androidaps.plugins.general.automation.elements
|
package info.nightscout.androidaps.plugins.general.automation.elements
|
||||||
|
|
||||||
import android.app.TimePickerDialog
|
import android.app.TimePickerDialog
|
||||||
|
import android.content.Context
|
||||||
import android.graphics.Typeface
|
import android.graphics.Typeface
|
||||||
import android.text.format.DateFormat
|
import android.text.format.DateFormat
|
||||||
import android.view.ViewGroup
|
import android.view.ViewGroup
|
||||||
import android.widget.LinearLayout
|
import android.widget.LinearLayout
|
||||||
import android.widget.TextView
|
import android.widget.TextView
|
||||||
import info.nightscout.androidaps.MainApp
|
import dagger.android.HasAndroidInjector
|
||||||
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.utils.DateUtil
|
import info.nightscout.androidaps.utils.DateUtil
|
||||||
import info.nightscout.androidaps.utils.MidnightTime
|
import info.nightscout.androidaps.utils.MidnightTime
|
||||||
import info.nightscout.androidaps.utils.T
|
import info.nightscout.androidaps.utils.T
|
||||||
|
import info.nightscout.androidaps.utils.resources.ResourceHelper
|
||||||
import java.util.*
|
import java.util.*
|
||||||
|
import javax.inject.Inject
|
||||||
|
|
||||||
|
class InputTime(injector: HasAndroidInjector) : Element(injector) {
|
||||||
|
@Inject lateinit var resourceHelper: ResourceHelper
|
||||||
|
@Inject lateinit var context: Context
|
||||||
|
|
||||||
class InputTime(mainApp: MainApp) : Element(mainApp) {
|
|
||||||
var value: Int = getMinSinceMidnight(DateUtil.now())
|
var value: Int = getMinSinceMidnight(DateUtil.now())
|
||||||
|
|
||||||
override fun addToLayout(root: LinearLayout) {
|
override fun addToLayout(root: LinearLayout) {
|
||||||
|
@ -34,7 +40,7 @@ class InputTime(mainApp: MainApp) : Element(mainApp) {
|
||||||
TimePickerDialog(it, startTimeSetListener,
|
TimePickerDialog(it, startTimeSetListener,
|
||||||
cal.get(Calendar.HOUR_OF_DAY),
|
cal.get(Calendar.HOUR_OF_DAY),
|
||||||
cal.get(Calendar.MINUTE),
|
cal.get(Calendar.MINUTE),
|
||||||
DateFormat.is24HourFormat(mainApp)
|
DateFormat.is24HourFormat(context)
|
||||||
).show()
|
).show()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,20 +1,26 @@
|
||||||
package info.nightscout.androidaps.plugins.general.automation.elements
|
package info.nightscout.androidaps.plugins.general.automation.elements
|
||||||
|
|
||||||
import android.app.TimePickerDialog
|
import android.app.TimePickerDialog
|
||||||
|
import android.content.Context
|
||||||
import android.graphics.Typeface
|
import android.graphics.Typeface
|
||||||
import android.text.format.DateFormat
|
import android.text.format.DateFormat
|
||||||
import android.view.ViewGroup
|
import android.view.ViewGroup
|
||||||
import android.widget.LinearLayout
|
import android.widget.LinearLayout
|
||||||
import android.widget.TextView
|
import android.widget.TextView
|
||||||
import info.nightscout.androidaps.MainApp
|
import dagger.android.HasAndroidInjector
|
||||||
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.utils.DateUtil
|
import info.nightscout.androidaps.utils.DateUtil
|
||||||
import info.nightscout.androidaps.utils.MidnightTime
|
import info.nightscout.androidaps.utils.MidnightTime
|
||||||
import info.nightscout.androidaps.utils.T
|
import info.nightscout.androidaps.utils.T
|
||||||
|
import info.nightscout.androidaps.utils.resources.ResourceHelper
|
||||||
import java.util.*
|
import java.util.*
|
||||||
|
import javax.inject.Inject
|
||||||
|
|
||||||
|
class InputTimeRange(injector: HasAndroidInjector) : Element(injector) {
|
||||||
|
@Inject lateinit var resourceHelper: ResourceHelper
|
||||||
|
@Inject lateinit var context: Context
|
||||||
|
|
||||||
class InputTimeRange(mainApp: MainApp) : Element(mainApp) {
|
|
||||||
var start: Int = getMinSinceMidnight(DateUtil.now())
|
var start: Int = getMinSinceMidnight(DateUtil.now())
|
||||||
var end: Int = getMinSinceMidnight(DateUtil.now())
|
var end: Int = getMinSinceMidnight(DateUtil.now())
|
||||||
|
|
||||||
|
@ -38,7 +44,7 @@ class InputTimeRange(mainApp: MainApp) : Element(mainApp) {
|
||||||
TimePickerDialog(it, startTimeSetListener,
|
TimePickerDialog(it, startTimeSetListener,
|
||||||
cal.get(Calendar.HOUR_OF_DAY),
|
cal.get(Calendar.HOUR_OF_DAY),
|
||||||
cal.get(Calendar.MINUTE),
|
cal.get(Calendar.MINUTE),
|
||||||
DateFormat.is24HourFormat(mainApp)
|
DateFormat.is24HourFormat(context)
|
||||||
).show()
|
).show()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -55,7 +61,7 @@ class InputTimeRange(mainApp: MainApp) : Element(mainApp) {
|
||||||
TimePickerDialog(it, endTimeSetListener,
|
TimePickerDialog(it, endTimeSetListener,
|
||||||
cal.get(Calendar.HOUR_OF_DAY),
|
cal.get(Calendar.HOUR_OF_DAY),
|
||||||
cal.get(Calendar.MINUTE),
|
cal.get(Calendar.MINUTE),
|
||||||
DateFormat.is24HourFormat(mainApp)
|
DateFormat.is24HourFormat(context)
|
||||||
).show()
|
).show()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,11 +5,11 @@ import android.view.ViewGroup
|
||||||
import android.widget.LinearLayout
|
import android.widget.LinearLayout
|
||||||
import androidx.annotation.StringRes
|
import androidx.annotation.StringRes
|
||||||
import com.dpro.widgets.WeekdaysPicker
|
import com.dpro.widgets.WeekdaysPicker
|
||||||
import info.nightscout.androidaps.MainApp
|
import dagger.android.HasAndroidInjector
|
||||||
import info.nightscout.androidaps.R
|
import info.nightscout.androidaps.R
|
||||||
import java.util.*
|
import java.util.*
|
||||||
|
|
||||||
class InputWeekDay(mainApp: MainApp) : Element(mainApp) {
|
class InputWeekDay(injector: HasAndroidInjector) : Element(injector) {
|
||||||
|
|
||||||
enum class DayOfWeek {
|
enum class DayOfWeek {
|
||||||
MONDAY, TUESDAY, WEDNESDAY, THURSDAY, FRIDAY, SATURDAY, SUNDAY;
|
MONDAY, TUESDAY, WEDNESDAY, THURSDAY, FRIDAY, SATURDAY, SUNDAY;
|
||||||
|
|
|
@ -5,14 +5,18 @@ import android.view.ViewGroup
|
||||||
import android.widget.LinearLayout
|
import android.widget.LinearLayout
|
||||||
import android.widget.TableLayout
|
import android.widget.TableLayout
|
||||||
import android.widget.TextView
|
import android.widget.TextView
|
||||||
import info.nightscout.androidaps.MainApp
|
import dagger.android.HasAndroidInjector
|
||||||
|
import info.nightscout.androidaps.utils.resources.ResourceHelper
|
||||||
|
import javax.inject.Inject
|
||||||
|
|
||||||
|
class LabelWithElement(injector: HasAndroidInjector) : Element(injector) {
|
||||||
|
@Inject lateinit var resourceHelper: ResourceHelper
|
||||||
|
|
||||||
class LabelWithElement(mainApp: MainApp) : Element(mainApp) {
|
|
||||||
var element: Element? = null
|
var element: Element? = null
|
||||||
var textPre: String = ""
|
var textPre: String = ""
|
||||||
var textPost: String = ""
|
var textPost: String = ""
|
||||||
|
|
||||||
constructor(mainApp: MainApp, textPre: String, textPost: String, element: Element) : this(mainApp) {
|
constructor(injector: HasAndroidInjector, textPre: String, textPost: String, element: Element) : this(injector) {
|
||||||
this.textPre = textPre
|
this.textPre = textPre
|
||||||
this.textPost = textPost
|
this.textPost = textPost
|
||||||
this.element = element
|
this.element = element
|
||||||
|
|
|
@ -4,19 +4,23 @@ import android.graphics.Typeface
|
||||||
import android.view.ViewGroup
|
import android.view.ViewGroup
|
||||||
import android.widget.LinearLayout
|
import android.widget.LinearLayout
|
||||||
import android.widget.TextView
|
import android.widget.TextView
|
||||||
import info.nightscout.androidaps.MainApp
|
import dagger.android.HasAndroidInjector
|
||||||
import info.nightscout.androidaps.plugins.general.automation.triggers.Trigger
|
import info.nightscout.androidaps.plugins.general.automation.triggers.Trigger
|
||||||
|
import info.nightscout.androidaps.utils.resources.ResourceHelper
|
||||||
|
import javax.inject.Inject
|
||||||
|
|
||||||
|
class StaticLabel(injector: HasAndroidInjector) : Element(injector) {
|
||||||
|
@Inject lateinit var resourceHelper: ResourceHelper
|
||||||
|
|
||||||
class StaticLabel(mainApp: MainApp) : Element(mainApp) {
|
|
||||||
var label = ""
|
var label = ""
|
||||||
var trigger: Trigger? = null
|
var trigger: Trigger? = null
|
||||||
|
|
||||||
constructor(mainApp: MainApp, label: String, trigger: Trigger) : this(mainApp) {
|
constructor(injector: HasAndroidInjector, label: String, trigger: Trigger) : this(injector) {
|
||||||
this.label = label
|
this.label = label
|
||||||
this.trigger = trigger
|
this.trigger = trigger
|
||||||
}
|
}
|
||||||
|
|
||||||
constructor(mainApp: MainApp, resourceId: Int, trigger: Trigger) : this(mainApp) {
|
constructor(injector: HasAndroidInjector, resourceId: Int, trigger: Trigger) : this(injector) {
|
||||||
label = resourceHelper.gs(resourceId)
|
label = resourceHelper.gs(resourceId)
|
||||||
this.trigger = trigger
|
this.trigger = trigger
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,12 +8,11 @@ import android.widget.LinearLayout
|
||||||
import android.widget.TextView
|
import android.widget.TextView
|
||||||
import androidx.appcompat.app.AppCompatActivity
|
import androidx.appcompat.app.AppCompatActivity
|
||||||
import com.google.common.base.Optional
|
import com.google.common.base.Optional
|
||||||
import info.nightscout.androidaps.MainApp
|
import dagger.android.HasAndroidInjector
|
||||||
import info.nightscout.androidaps.R
|
import info.nightscout.androidaps.R
|
||||||
import info.nightscout.androidaps.interfaces.ActivePluginProvider
|
import info.nightscout.androidaps.interfaces.ActivePluginProvider
|
||||||
import info.nightscout.androidaps.logging.AAPSLogger
|
import info.nightscout.androidaps.logging.AAPSLogger
|
||||||
import info.nightscout.androidaps.plugins.bus.RxBusWrapper
|
import info.nightscout.androidaps.plugins.bus.RxBusWrapper
|
||||||
import info.nightscout.androidaps.plugins.configBuilder.ConfigBuilderPlugin
|
|
||||||
import info.nightscout.androidaps.plugins.configBuilder.ProfileFunction
|
import info.nightscout.androidaps.plugins.configBuilder.ProfileFunction
|
||||||
import info.nightscout.androidaps.plugins.general.automation.dialogs.ChooseTriggerDialog
|
import info.nightscout.androidaps.plugins.general.automation.dialogs.ChooseTriggerDialog
|
||||||
import info.nightscout.androidaps.plugins.general.automation.events.EventTriggerChanged
|
import info.nightscout.androidaps.plugins.general.automation.events.EventTriggerChanged
|
||||||
|
@ -22,7 +21,6 @@ import info.nightscout.androidaps.plugins.general.automation.events.EventTrigger
|
||||||
import info.nightscout.androidaps.plugins.iob.iobCobCalculator.IobCobCalculatorPlugin
|
import info.nightscout.androidaps.plugins.iob.iobCobCalculator.IobCobCalculatorPlugin
|
||||||
import info.nightscout.androidaps.plugins.treatments.TreatmentsPlugin
|
import info.nightscout.androidaps.plugins.treatments.TreatmentsPlugin
|
||||||
import info.nightscout.androidaps.services.LastLocationDataContainer
|
import info.nightscout.androidaps.services.LastLocationDataContainer
|
||||||
import info.nightscout.androidaps.services.LocationService
|
|
||||||
import info.nightscout.androidaps.utils.resources.ResourceHelper
|
import info.nightscout.androidaps.utils.resources.ResourceHelper
|
||||||
import info.nightscout.androidaps.utils.sharedPreferences.SP
|
import info.nightscout.androidaps.utils.sharedPreferences.SP
|
||||||
import org.json.JSONException
|
import org.json.JSONException
|
||||||
|
@ -30,7 +28,7 @@ import org.json.JSONObject
|
||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
import kotlin.reflect.full.primaryConstructor
|
import kotlin.reflect.full.primaryConstructor
|
||||||
|
|
||||||
abstract class Trigger(val mainApp: MainApp) {
|
abstract class Trigger(val injector: HasAndroidInjector) {
|
||||||
@Inject lateinit var aapsLogger: AAPSLogger
|
@Inject lateinit var aapsLogger: AAPSLogger
|
||||||
@Inject lateinit var rxBus: RxBusWrapper
|
@Inject lateinit var rxBus: RxBusWrapper
|
||||||
@Inject lateinit var resourceHelper: ResourceHelper
|
@Inject lateinit var resourceHelper: ResourceHelper
|
||||||
|
@ -38,11 +36,11 @@ abstract class Trigger(val mainApp: MainApp) {
|
||||||
@Inject lateinit var sp: SP
|
@Inject lateinit var sp: SP
|
||||||
@Inject lateinit var locationDataContainer: LastLocationDataContainer
|
@Inject lateinit var locationDataContainer: LastLocationDataContainer
|
||||||
@Inject lateinit var treatmentsPlugin: TreatmentsPlugin
|
@Inject lateinit var treatmentsPlugin: TreatmentsPlugin
|
||||||
@Inject lateinit var activePluginProvider: ActivePluginProvider
|
@Inject lateinit var activePlugin: ActivePluginProvider
|
||||||
@Inject lateinit var iobCobCalculatorPlugin: IobCobCalculatorPlugin
|
@Inject lateinit var iobCobCalculatorPlugin: IobCobCalculatorPlugin
|
||||||
|
|
||||||
init {
|
init {
|
||||||
mainApp.androidInjector().inject(this)
|
injector.androidInjector().inject(this)
|
||||||
}
|
}
|
||||||
|
|
||||||
abstract fun shouldRun(): Boolean
|
abstract fun shouldRun(): Boolean
|
||||||
|
@ -77,7 +75,7 @@ abstract class Trigger(val mainApp: MainApp) {
|
||||||
val type = obj.getString("type")
|
val type = obj.getString("type")
|
||||||
val data = obj.getJSONObject("data")
|
val data = obj.getJSONObject("data")
|
||||||
val clazz = Class.forName(type).kotlin
|
val clazz = Class.forName(type).kotlin
|
||||||
return (clazz.primaryConstructor?.call(mainApp) as Trigger).fromJSON(data?.toString()
|
return (clazz.primaryConstructor?.call(injector) as Trigger).fromJSON(data?.toString()
|
||||||
?: "")
|
?: "")
|
||||||
} catch (e: ClassNotFoundException) {
|
} catch (e: ClassNotFoundException) {
|
||||||
aapsLogger.error("Unhandled exception", e)
|
aapsLogger.error("Unhandled exception", e)
|
||||||
|
|
|
@ -2,7 +2,7 @@ package info.nightscout.androidaps.plugins.general.automation.triggers
|
||||||
|
|
||||||
import android.widget.LinearLayout
|
import android.widget.LinearLayout
|
||||||
import com.google.common.base.Optional
|
import com.google.common.base.Optional
|
||||||
import info.nightscout.androidaps.MainApp
|
import dagger.android.HasAndroidInjector
|
||||||
import info.nightscout.androidaps.R
|
import info.nightscout.androidaps.R
|
||||||
import info.nightscout.androidaps.logging.LTag
|
import info.nightscout.androidaps.logging.LTag
|
||||||
import info.nightscout.androidaps.plugins.general.automation.elements.Comparator
|
import info.nightscout.androidaps.plugins.general.automation.elements.Comparator
|
||||||
|
@ -15,18 +15,18 @@ import info.nightscout.androidaps.utils.JsonHelper.safeGetString
|
||||||
import org.json.JSONObject
|
import org.json.JSONObject
|
||||||
import java.text.DecimalFormat
|
import java.text.DecimalFormat
|
||||||
|
|
||||||
class TriggerAutosensValue(mainApp: MainApp) : Trigger(mainApp) {
|
class TriggerAutosensValue(injector: HasAndroidInjector) : Trigger(injector) {
|
||||||
private val minValue = (sp.getDouble(R.string.key_openapsama_autosens_min, 0.7) * 100).toInt()
|
private val minValue = (sp.getDouble(R.string.key_openapsama_autosens_min, 0.7) * 100).toInt()
|
||||||
private val maxValue = (sp.getDouble(R.string.key_openapsama_autosens_max, 1.2) * 100).toInt()
|
private val maxValue = (sp.getDouble(R.string.key_openapsama_autosens_max, 1.2) * 100).toInt()
|
||||||
private val step = 1.0
|
private val step = 1.0
|
||||||
private val decimalFormat = DecimalFormat("1")
|
private val decimalFormat = DecimalFormat("1")
|
||||||
private var autosens: InputDouble = InputDouble(mainApp, 100.0, minValue.toDouble(), maxValue.toDouble(), step, decimalFormat)
|
private var autosens: InputDouble = InputDouble(injector, 100.0, minValue.toDouble(), maxValue.toDouble(), step, decimalFormat)
|
||||||
|
|
||||||
var comparator: Comparator = Comparator(mainApp)
|
var comparator: Comparator = Comparator(injector)
|
||||||
|
|
||||||
private constructor(mainApp: MainApp, triggerAutosensValue: TriggerAutosensValue) : this(mainApp) {
|
private constructor(injector: HasAndroidInjector, triggerAutosensValue: TriggerAutosensValue) : this(injector) {
|
||||||
autosens = InputDouble(mainApp, triggerAutosensValue.autosens)
|
autosens = InputDouble(injector, triggerAutosensValue.autosens)
|
||||||
comparator = Comparator(mainApp, triggerAutosensValue.comparator.value)
|
comparator = Comparator(injector, triggerAutosensValue.comparator.value)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun shouldRun(): Boolean {
|
override fun shouldRun(): Boolean {
|
||||||
|
@ -70,13 +70,13 @@ class TriggerAutosensValue(mainApp: MainApp) : Trigger(mainApp) {
|
||||||
|
|
||||||
override fun icon(): Optional<Int?> = Optional.of(R.drawable.`as`)
|
override fun icon(): Optional<Int?> = Optional.of(R.drawable.`as`)
|
||||||
|
|
||||||
override fun duplicate(): Trigger = TriggerAutosensValue(mainApp, this)
|
override fun duplicate(): Trigger = TriggerAutosensValue(injector, this)
|
||||||
|
|
||||||
override fun generateDialog(root: LinearLayout) {
|
override fun generateDialog(root: LinearLayout) {
|
||||||
LayoutBuilder()
|
LayoutBuilder()
|
||||||
.add(StaticLabel(mainApp, R.string.autosenslabel, this))
|
.add(StaticLabel(injector, R.string.autosenslabel, this))
|
||||||
.add(comparator)
|
.add(comparator)
|
||||||
.add(LabelWithElement(mainApp, resourceHelper.gs(R.string.autosenslabel) + ": ", "", autosens))
|
.add(LabelWithElement(injector, resourceHelper.gs(R.string.autosenslabel) + ": ", "", autosens))
|
||||||
.build(root)
|
.build(root)
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -2,8 +2,8 @@ package info.nightscout.androidaps.plugins.general.automation.triggers
|
||||||
|
|
||||||
import android.widget.LinearLayout
|
import android.widget.LinearLayout
|
||||||
import com.google.common.base.Optional
|
import com.google.common.base.Optional
|
||||||
|
import dagger.android.HasAndroidInjector
|
||||||
import info.nightscout.androidaps.Constants
|
import info.nightscout.androidaps.Constants
|
||||||
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.logging.LTag
|
import info.nightscout.androidaps.logging.LTag
|
||||||
|
@ -16,18 +16,18 @@ import info.nightscout.androidaps.plugins.iob.iobCobCalculator.GlucoseStatus
|
||||||
import info.nightscout.androidaps.utils.JsonHelper
|
import info.nightscout.androidaps.utils.JsonHelper
|
||||||
import org.json.JSONObject
|
import org.json.JSONObject
|
||||||
|
|
||||||
class TriggerBg(mainApp: MainApp) : Trigger(mainApp) {
|
class TriggerBg(injector: HasAndroidInjector) : Trigger(injector) {
|
||||||
private var bg = InputBg(mainApp)
|
private var bg = InputBg(injector)
|
||||||
var comparator = Comparator(mainApp)
|
var comparator = Comparator(injector)
|
||||||
|
|
||||||
constructor(mainApp: MainApp, value: Double, units: String, compare: Comparator.Compare) : this(mainApp) {
|
constructor(injector: HasAndroidInjector, value: Double, units: String, compare: Comparator.Compare) : this(injector) {
|
||||||
bg = InputBg(mainApp, value, units)
|
bg = InputBg(injector, value, units)
|
||||||
comparator = Comparator(mainApp, compare)
|
comparator = Comparator(injector, compare)
|
||||||
}
|
}
|
||||||
|
|
||||||
constructor(mainApp: MainApp, triggerBg: TriggerBg) : this(mainApp) {
|
constructor(injector: HasAndroidInjector, triggerBg: TriggerBg) : this(injector) {
|
||||||
bg = InputBg(mainApp, triggerBg.bg.value, triggerBg.bg.units)
|
bg = InputBg(injector, triggerBg.bg.value, triggerBg.bg.units)
|
||||||
comparator = Comparator(mainApp, triggerBg.comparator.value)
|
comparator = Comparator(injector, triggerBg.comparator.value)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun shouldRun(): Boolean {
|
override fun shouldRun(): Boolean {
|
||||||
|
@ -78,13 +78,13 @@ class TriggerBg(mainApp: MainApp) : Trigger(mainApp) {
|
||||||
|
|
||||||
override fun icon(): Optional<Int?> = Optional.of(R.drawable.icon_cp_bgcheck)
|
override fun icon(): Optional<Int?> = Optional.of(R.drawable.icon_cp_bgcheck)
|
||||||
|
|
||||||
override fun duplicate(): Trigger = TriggerBg(mainApp, this)
|
override fun duplicate(): Trigger = TriggerBg(injector, this)
|
||||||
|
|
||||||
override fun generateDialog(root: LinearLayout) {
|
override fun generateDialog(root: LinearLayout) {
|
||||||
LayoutBuilder()
|
LayoutBuilder()
|
||||||
.add(StaticLabel(mainApp, R.string.glucose, this))
|
.add(StaticLabel(injector, R.string.glucose, this))
|
||||||
.add(comparator)
|
.add(comparator)
|
||||||
.add(LabelWithElement(mainApp, resourceHelper.gs(R.string.glucose_u, bg.units), "", bg))
|
.add(LabelWithElement(injector, resourceHelper.gs(R.string.glucose_u, bg.units), "", bg))
|
||||||
.build(root)
|
.build(root)
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -2,7 +2,7 @@ package info.nightscout.androidaps.plugins.general.automation.triggers
|
||||||
|
|
||||||
import android.widget.LinearLayout
|
import android.widget.LinearLayout
|
||||||
import com.google.common.base.Optional
|
import com.google.common.base.Optional
|
||||||
import info.nightscout.androidaps.MainApp
|
import dagger.android.HasAndroidInjector
|
||||||
import info.nightscout.androidaps.R
|
import info.nightscout.androidaps.R
|
||||||
import info.nightscout.androidaps.logging.LTag
|
import info.nightscout.androidaps.logging.LTag
|
||||||
import info.nightscout.androidaps.plugins.general.automation.elements.Comparator
|
import info.nightscout.androidaps.plugins.general.automation.elements.Comparator
|
||||||
|
@ -15,13 +15,13 @@ import info.nightscout.androidaps.utils.JsonHelper
|
||||||
import info.nightscout.androidaps.utils.JsonHelper.safeGetString
|
import info.nightscout.androidaps.utils.JsonHelper.safeGetString
|
||||||
import org.json.JSONObject
|
import org.json.JSONObject
|
||||||
|
|
||||||
class TriggerBolusAgo(mainApp: MainApp) : Trigger(mainApp) {
|
class TriggerBolusAgo(injector: HasAndroidInjector) : Trigger(injector) {
|
||||||
private var minutesAgo: InputDuration = InputDuration(mainApp, 0, InputDuration.TimeUnit.MINUTES)
|
private var minutesAgo: InputDuration = InputDuration(injector, 0, InputDuration.TimeUnit.MINUTES)
|
||||||
var comparator: Comparator = Comparator(mainApp)
|
var comparator: Comparator = Comparator(injector)
|
||||||
|
|
||||||
private constructor(mainApp: MainApp, triggerBolusAgo: TriggerBolusAgo) : this(mainApp) {
|
private constructor(injector: HasAndroidInjector, triggerBolusAgo: TriggerBolusAgo) : this(injector) {
|
||||||
minutesAgo = InputDuration(mainApp, triggerBolusAgo.minutesAgo.value, InputDuration.TimeUnit.MINUTES)
|
minutesAgo = InputDuration(injector, triggerBolusAgo.minutesAgo.value, InputDuration.TimeUnit.MINUTES)
|
||||||
comparator = Comparator(mainApp, triggerBolusAgo.comparator.value)
|
comparator = Comparator(injector, triggerBolusAgo.comparator.value)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun shouldRun(): Boolean {
|
override fun shouldRun(): Boolean {
|
||||||
|
@ -69,13 +69,13 @@ class TriggerBolusAgo(mainApp: MainApp) : Trigger(mainApp) {
|
||||||
|
|
||||||
override fun icon(): Optional<Int?> = Optional.of(R.drawable.icon_bolus)
|
override fun icon(): Optional<Int?> = Optional.of(R.drawable.icon_bolus)
|
||||||
|
|
||||||
override fun duplicate(): Trigger = TriggerBolusAgo(mainApp, this)
|
override fun duplicate(): Trigger = TriggerBolusAgo(injector, this)
|
||||||
|
|
||||||
override fun generateDialog(root: LinearLayout) {
|
override fun generateDialog(root: LinearLayout) {
|
||||||
LayoutBuilder()
|
LayoutBuilder()
|
||||||
.add(StaticLabel(mainApp, R.string.lastboluslabel, this))
|
.add(StaticLabel(injector, R.string.lastboluslabel, this))
|
||||||
.add(comparator)
|
.add(comparator)
|
||||||
.add(LabelWithElement(mainApp, resourceHelper.gs(R.string.lastboluslabel) + ": ", "", minutesAgo))
|
.add(LabelWithElement(injector, resourceHelper.gs(R.string.lastboluslabel) + ": ", "", minutesAgo))
|
||||||
.build(root)
|
.build(root)
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -2,7 +2,7 @@ package info.nightscout.androidaps.plugins.general.automation.triggers
|
||||||
|
|
||||||
import android.widget.LinearLayout
|
import android.widget.LinearLayout
|
||||||
import com.google.common.base.Optional
|
import com.google.common.base.Optional
|
||||||
import info.nightscout.androidaps.MainApp
|
import dagger.android.HasAndroidInjector
|
||||||
import info.nightscout.androidaps.R
|
import info.nightscout.androidaps.R
|
||||||
import info.nightscout.androidaps.logging.LTag
|
import info.nightscout.androidaps.logging.LTag
|
||||||
import info.nightscout.androidaps.plugins.general.automation.elements.Comparator
|
import info.nightscout.androidaps.plugins.general.automation.elements.Comparator
|
||||||
|
@ -15,15 +15,15 @@ import info.nightscout.androidaps.utils.JsonHelper.safeGetDouble
|
||||||
import org.json.JSONObject
|
import org.json.JSONObject
|
||||||
import java.text.DecimalFormat
|
import java.text.DecimalFormat
|
||||||
|
|
||||||
class TriggerCOB(mainApp: MainApp) : Trigger(mainApp) {
|
class TriggerCOB(injector: HasAndroidInjector) : Trigger(injector) {
|
||||||
private val minValue = 0
|
private val minValue = 0
|
||||||
private val maxValue = sp.getInt(R.string.key_treatmentssafety_maxcarbs, 48)
|
private val maxValue = sp.getInt(R.string.key_treatmentssafety_maxcarbs, 48)
|
||||||
private var cob: InputDouble = InputDouble(mainApp, 0.0, minValue.toDouble(), maxValue.toDouble(), 1.0, DecimalFormat("1"))
|
private var cob: InputDouble = InputDouble(injector, 0.0, minValue.toDouble(), maxValue.toDouble(), 1.0, DecimalFormat("1"))
|
||||||
var comparator: Comparator = Comparator(mainApp)
|
var comparator: Comparator = Comparator(injector)
|
||||||
|
|
||||||
private constructor(mainApp: MainApp, triggerCOB: TriggerCOB) : this(mainApp) {
|
private constructor(injector: HasAndroidInjector, triggerCOB: TriggerCOB) : this(injector) {
|
||||||
cob = InputDouble(mainApp, triggerCOB.cob)
|
cob = InputDouble(injector, triggerCOB.cob)
|
||||||
comparator = Comparator(mainApp, triggerCOB.comparator.value)
|
comparator = Comparator(injector, triggerCOB.comparator.value)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun shouldRun(): Boolean {
|
override fun shouldRun(): Boolean {
|
||||||
|
@ -69,13 +69,13 @@ class TriggerCOB(mainApp: MainApp) : Trigger(mainApp) {
|
||||||
|
|
||||||
override fun icon(): Optional<Int?> = Optional.of(R.drawable.icon_cp_bolus_carbs)
|
override fun icon(): Optional<Int?> = Optional.of(R.drawable.icon_cp_bolus_carbs)
|
||||||
|
|
||||||
override fun duplicate(): Trigger = TriggerCOB(mainApp, this)
|
override fun duplicate(): Trigger = TriggerCOB(injector, this)
|
||||||
|
|
||||||
override fun generateDialog(root: LinearLayout) {
|
override fun generateDialog(root: LinearLayout) {
|
||||||
LayoutBuilder()
|
LayoutBuilder()
|
||||||
.add(StaticLabel(mainApp, R.string.triggercoblabel, this))
|
.add(StaticLabel(injector, R.string.triggercoblabel, this))
|
||||||
.add(comparator)
|
.add(comparator)
|
||||||
.add(LabelWithElement(mainApp, resourceHelper.gs(R.string.triggercoblabel) + ": ", "", cob))
|
.add(LabelWithElement(injector, resourceHelper.gs(R.string.triggercoblabel) + ": ", "", cob))
|
||||||
.build(root)
|
.build(root)
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -9,7 +9,7 @@ import android.widget.LinearLayout
|
||||||
import android.widget.Spinner
|
import android.widget.Spinner
|
||||||
import androidx.annotation.StringRes
|
import androidx.annotation.StringRes
|
||||||
import com.google.common.base.Optional
|
import com.google.common.base.Optional
|
||||||
import info.nightscout.androidaps.MainApp
|
import dagger.android.HasAndroidInjector
|
||||||
import info.nightscout.androidaps.R
|
import info.nightscout.androidaps.R
|
||||||
import info.nightscout.androidaps.logging.LTag
|
import info.nightscout.androidaps.logging.LTag
|
||||||
import info.nightscout.androidaps.utils.JsonHelper.safeGetString
|
import info.nightscout.androidaps.utils.JsonHelper.safeGetString
|
||||||
|
@ -18,11 +18,11 @@ import org.json.JSONArray
|
||||||
import org.json.JSONObject
|
import org.json.JSONObject
|
||||||
import java.util.*
|
import java.util.*
|
||||||
|
|
||||||
class TriggerConnector(mainApp: MainApp) : Trigger(mainApp) {
|
class TriggerConnector(injector: HasAndroidInjector) : Trigger(injector) {
|
||||||
var list: MutableList<Trigger> = ArrayList()
|
var list: MutableList<Trigger> = ArrayList()
|
||||||
private var connectorType: Type = Type.AND
|
private var connectorType: Type = Type.AND
|
||||||
// TODO move to TriggerConnector
|
// TODO move to TriggerConnector
|
||||||
//var connector: TriggerConnector = TriggerConnector(mainApp, TriggerConnector.Type.AND)
|
//var connector: TriggerConnector = TriggerConnector(injector, TriggerConnector.Type.AND)
|
||||||
|
|
||||||
enum class Type {
|
enum class Type {
|
||||||
AND, OR, XOR;
|
AND, OR, XOR;
|
||||||
|
@ -52,7 +52,7 @@ class TriggerConnector(mainApp: MainApp) : Trigger(mainApp) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
constructor(mainApp: MainApp, connectorType: Type) : this(mainApp) {
|
constructor(injector: HasAndroidInjector, connectorType: Type) : this(injector) {
|
||||||
this.connectorType = connectorType
|
this.connectorType = connectorType
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -120,7 +120,7 @@ class TriggerConnector(mainApp: MainApp) : Trigger(mainApp) {
|
||||||
|
|
||||||
override fun icon(): Optional<Int?> = Optional.absent()
|
override fun icon(): Optional<Int?> = Optional.absent()
|
||||||
|
|
||||||
override fun duplicate(): Trigger = TriggerConnector(mainApp, connectorType)
|
override fun duplicate(): Trigger = TriggerConnector(injector, connectorType)
|
||||||
|
|
||||||
override fun generateDialog(root: LinearLayout) {
|
override fun generateDialog(root: LinearLayout) {
|
||||||
val padding = resourceHelper.dpToPx(5)
|
val padding = resourceHelper.dpToPx(5)
|
||||||
|
|
|
@ -2,8 +2,8 @@ package info.nightscout.androidaps.plugins.general.automation.triggers
|
||||||
|
|
||||||
import android.widget.LinearLayout
|
import android.widget.LinearLayout
|
||||||
import com.google.common.base.Optional
|
import com.google.common.base.Optional
|
||||||
|
import dagger.android.HasAndroidInjector
|
||||||
import info.nightscout.androidaps.Constants
|
import info.nightscout.androidaps.Constants
|
||||||
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.logging.LTag
|
import info.nightscout.androidaps.logging.LTag
|
||||||
|
@ -18,11 +18,11 @@ import info.nightscout.androidaps.utils.JsonHelper
|
||||||
import org.json.JSONObject
|
import org.json.JSONObject
|
||||||
import java.text.DecimalFormat
|
import java.text.DecimalFormat
|
||||||
|
|
||||||
class TriggerDelta(mainApp: MainApp) : Trigger(mainApp) {
|
class TriggerDelta(injector: HasAndroidInjector) : Trigger(injector) {
|
||||||
|
|
||||||
var units: String = Constants.MGDL
|
var units: String = Constants.MGDL
|
||||||
private var delta: InputDelta = InputDelta(mainApp)
|
private var delta: InputDelta = InputDelta(injector)
|
||||||
var comparator: Comparator = Comparator(mainApp)
|
var comparator: Comparator = Comparator(injector)
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
private const val MMOL_MAX = 4.0
|
private const val MMOL_MAX = 4.0
|
||||||
|
@ -31,14 +31,14 @@ class TriggerDelta(mainApp: MainApp) : Trigger(mainApp) {
|
||||||
|
|
||||||
init {
|
init {
|
||||||
units = profileFunction.getUnits()
|
units = profileFunction.getUnits()
|
||||||
delta = if (units == Constants.MMOL) InputDelta(mainApp, 0.0, (-MMOL_MAX), MMOL_MAX, 0.1, DecimalFormat("0.1"), DeltaType.DELTA)
|
delta = if (units == Constants.MMOL) InputDelta(injector, 0.0, (-MMOL_MAX), MMOL_MAX, 0.1, DecimalFormat("0.1"), DeltaType.DELTA)
|
||||||
else InputDelta(mainApp, 0.0, (-MGDL_MAX), MGDL_MAX, 1.0, DecimalFormat("1"), DeltaType.DELTA)
|
else InputDelta(injector, 0.0, (-MGDL_MAX), MGDL_MAX, 1.0, DecimalFormat("1"), DeltaType.DELTA)
|
||||||
}
|
}
|
||||||
|
|
||||||
private constructor(mainApp: MainApp, triggerDelta: TriggerDelta) : this(mainApp) {
|
private constructor(injector: HasAndroidInjector, triggerDelta: TriggerDelta) : this(injector) {
|
||||||
units = triggerDelta.units
|
units = triggerDelta.units
|
||||||
delta = InputDelta(mainApp, triggerDelta.delta)
|
delta = InputDelta(injector, triggerDelta.delta)
|
||||||
comparator = Comparator(mainApp, triggerDelta.comparator.value)
|
comparator = Comparator(injector, triggerDelta.comparator.value)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun shouldRun(): Boolean {
|
override fun shouldRun(): Boolean {
|
||||||
|
@ -81,8 +81,8 @@ class TriggerDelta(mainApp: MainApp) : Trigger(mainApp) {
|
||||||
val type = DeltaType.valueOf(JsonHelper.safeGetString(d, "deltaType", ""))
|
val type = DeltaType.valueOf(JsonHelper.safeGetString(d, "deltaType", ""))
|
||||||
val value = JsonHelper.safeGetDouble(d, "value")
|
val value = JsonHelper.safeGetDouble(d, "value")
|
||||||
delta =
|
delta =
|
||||||
if (units == Constants.MMOL) InputDelta(mainApp, value, (-MMOL_MAX), MMOL_MAX, 0.1, DecimalFormat("0.1"), type)
|
if (units == Constants.MMOL) InputDelta(injector, value, (-MMOL_MAX), MMOL_MAX, 0.1, DecimalFormat("0.1"), type)
|
||||||
else InputDelta(mainApp, value, (-MGDL_MAX), MGDL_MAX, 1.0, DecimalFormat("1"), type)
|
else InputDelta(injector, value, (-MGDL_MAX), MGDL_MAX, 1.0, DecimalFormat("1"), type)
|
||||||
comparator.setValue(Comparator.Compare.valueOf(JsonHelper.safeGetString(d, "comparator")!!))
|
comparator.setValue(Comparator.Compare.valueOf(JsonHelper.safeGetString(d, "comparator")!!))
|
||||||
return this
|
return this
|
||||||
}
|
}
|
||||||
|
@ -94,13 +94,13 @@ class TriggerDelta(mainApp: MainApp) : Trigger(mainApp) {
|
||||||
|
|
||||||
override fun icon(): Optional<Int?> = Optional.of(R.drawable.icon_auto_delta)
|
override fun icon(): Optional<Int?> = Optional.of(R.drawable.icon_auto_delta)
|
||||||
|
|
||||||
override fun duplicate(): Trigger = TriggerDelta(mainApp, this)
|
override fun duplicate(): Trigger = TriggerDelta(injector, this)
|
||||||
|
|
||||||
override fun generateDialog(root: LinearLayout) {
|
override fun generateDialog(root: LinearLayout) {
|
||||||
LayoutBuilder()
|
LayoutBuilder()
|
||||||
.add(StaticLabel(mainApp, R.string.deltalabel, this))
|
.add(StaticLabel(injector, R.string.deltalabel, this))
|
||||||
.add(comparator)
|
.add(comparator)
|
||||||
.add(LabelWithElement(mainApp, resourceHelper.gs(R.string.deltalabel_u, units) + ": ", "", delta))
|
.add(LabelWithElement(injector, resourceHelper.gs(R.string.deltalabel_u, units) + ": ", "", delta))
|
||||||
.build(root)
|
.build(root)
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -1,10 +1,10 @@
|
||||||
package info.nightscout.androidaps.plugins.general.automation.triggers
|
package info.nightscout.androidaps.plugins.general.automation.triggers
|
||||||
|
|
||||||
import com.google.common.base.Optional
|
import com.google.common.base.Optional
|
||||||
import info.nightscout.androidaps.MainApp
|
import dagger.android.HasAndroidInjector
|
||||||
|
|
||||||
// Used for instantiation of other triggers only
|
// Used for instantiation of other triggers only
|
||||||
class TriggerDummy(mainApp: MainApp) : Trigger(mainApp) {
|
class TriggerDummy(injector: HasAndroidInjector) : Trigger(injector) {
|
||||||
|
|
||||||
override fun shouldRun(): Boolean {
|
override fun shouldRun(): Boolean {
|
||||||
throw NotImplementedError("An operation is not implemented")
|
throw NotImplementedError("An operation is not implemented")
|
||||||
|
|
|
@ -2,7 +2,7 @@ package info.nightscout.androidaps.plugins.general.automation.triggers
|
||||||
|
|
||||||
import android.widget.LinearLayout
|
import android.widget.LinearLayout
|
||||||
import com.google.common.base.Optional
|
import com.google.common.base.Optional
|
||||||
import info.nightscout.androidaps.MainApp
|
import dagger.android.HasAndroidInjector
|
||||||
import info.nightscout.androidaps.R
|
import info.nightscout.androidaps.R
|
||||||
import info.nightscout.androidaps.logging.LTag
|
import info.nightscout.androidaps.logging.LTag
|
||||||
import info.nightscout.androidaps.plugins.general.automation.elements.Comparator
|
import info.nightscout.androidaps.plugins.general.automation.elements.Comparator
|
||||||
|
@ -14,13 +14,13 @@ import info.nightscout.androidaps.utils.DateUtil
|
||||||
import info.nightscout.androidaps.utils.JsonHelper
|
import info.nightscout.androidaps.utils.JsonHelper
|
||||||
import org.json.JSONObject
|
import org.json.JSONObject
|
||||||
|
|
||||||
class TriggerIob(mainApp: MainApp) : Trigger(mainApp) {
|
class TriggerIob(injector: HasAndroidInjector) : Trigger(injector) {
|
||||||
private var insulin = InputInsulin(mainApp)
|
private var insulin = InputInsulin(injector)
|
||||||
var comparator: Comparator = Comparator(mainApp)
|
var comparator: Comparator = Comparator(injector)
|
||||||
|
|
||||||
constructor(mainApp: MainApp, triggerIob: TriggerIob) : this(mainApp) {
|
constructor(injector: HasAndroidInjector, triggerIob: TriggerIob) : this(injector) {
|
||||||
insulin = InputInsulin(mainApp, triggerIob.insulin)
|
insulin = InputInsulin(injector, triggerIob.insulin)
|
||||||
comparator = Comparator(mainApp, triggerIob.comparator.value)
|
comparator = Comparator(injector, triggerIob.comparator.value)
|
||||||
}
|
}
|
||||||
|
|
||||||
val value: Double = 0.0
|
val value: Double = 0.0
|
||||||
|
@ -60,13 +60,13 @@ class TriggerIob(mainApp: MainApp) : Trigger(mainApp) {
|
||||||
|
|
||||||
override fun icon(): Optional<Int?> = Optional.of(R.drawable.ic_keyboard_capslock)
|
override fun icon(): Optional<Int?> = Optional.of(R.drawable.ic_keyboard_capslock)
|
||||||
|
|
||||||
override fun duplicate(): Trigger = TriggerIob(mainApp, this)
|
override fun duplicate(): Trigger = TriggerIob(injector, this)
|
||||||
|
|
||||||
override fun generateDialog(root: LinearLayout) {
|
override fun generateDialog(root: LinearLayout) {
|
||||||
LayoutBuilder()
|
LayoutBuilder()
|
||||||
.add(StaticLabel(mainApp, R.string.iob, this))
|
.add(StaticLabel(injector, R.string.iob, this))
|
||||||
.add(comparator)
|
.add(comparator)
|
||||||
.add(LabelWithElement(mainApp, resourceHelper.gs(R.string.iob_u), "", insulin))
|
.add(LabelWithElement(injector, resourceHelper.gs(R.string.iob_u), "", insulin))
|
||||||
.build(root)
|
.build(root)
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -3,7 +3,7 @@ package info.nightscout.androidaps.plugins.general.automation.triggers
|
||||||
import android.location.Location
|
import android.location.Location
|
||||||
import android.widget.LinearLayout
|
import android.widget.LinearLayout
|
||||||
import com.google.common.base.Optional
|
import com.google.common.base.Optional
|
||||||
import info.nightscout.androidaps.MainApp
|
import dagger.android.HasAndroidInjector
|
||||||
import info.nightscout.androidaps.R
|
import info.nightscout.androidaps.R
|
||||||
import info.nightscout.androidaps.logging.LTag
|
import info.nightscout.androidaps.logging.LTag
|
||||||
import info.nightscout.androidaps.plugins.general.automation.elements.*
|
import info.nightscout.androidaps.plugins.general.automation.elements.*
|
||||||
|
@ -11,12 +11,12 @@ import info.nightscout.androidaps.utils.JsonHelper
|
||||||
import org.json.JSONObject
|
import org.json.JSONObject
|
||||||
import java.text.DecimalFormat
|
import java.text.DecimalFormat
|
||||||
|
|
||||||
class TriggerLocation(mainApp: MainApp) : Trigger(mainApp) {
|
class TriggerLocation(injector: HasAndroidInjector) : Trigger(injector) {
|
||||||
var latitude = InputDouble(mainApp, 0.0, -90.0, +90.0, 0.000001, DecimalFormat("0.000000"))
|
var latitude = InputDouble(injector, 0.0, -90.0, +90.0, 0.000001, DecimalFormat("0.000000"))
|
||||||
var longitude = InputDouble(mainApp, 0.0, -180.0, +180.0, 0.000001, DecimalFormat("0.000000"))
|
var longitude = InputDouble(injector, 0.0, -180.0, +180.0, 0.000001, DecimalFormat("0.000000"))
|
||||||
var distance = InputDouble(mainApp, 200.0, 0.0, 100000.0, 10.0, DecimalFormat("0"))
|
var distance = InputDouble(injector, 200.0, 0.0, 100000.0, 10.0, DecimalFormat("0"))
|
||||||
var modeSelected = InputLocationMode(mainApp)
|
var modeSelected = InputLocationMode(injector)
|
||||||
var name: InputString = InputString(mainApp)
|
var name: InputString = InputString(injector)
|
||||||
|
|
||||||
var lastMode = InputLocationMode.Mode.INSIDE
|
var lastMode = InputLocationMode.Mode.INSIDE
|
||||||
private val buttonAction = Runnable {
|
private val buttonAction = Runnable {
|
||||||
|
@ -27,11 +27,11 @@ class TriggerLocation(mainApp: MainApp) : Trigger(mainApp) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private constructor(mainApp: MainApp, triggerLocation: TriggerLocation) : this(mainApp) {
|
private constructor(injector: HasAndroidInjector, triggerLocation: TriggerLocation) : this(injector) {
|
||||||
latitude = InputDouble(mainApp, triggerLocation.latitude)
|
latitude = InputDouble(injector, triggerLocation.latitude)
|
||||||
longitude = InputDouble(mainApp, triggerLocation.longitude)
|
longitude = InputDouble(injector, triggerLocation.longitude)
|
||||||
distance = InputDouble(mainApp, triggerLocation.distance)
|
distance = InputDouble(injector, triggerLocation.distance)
|
||||||
modeSelected = InputLocationMode(mainApp, triggerLocation.modeSelected.value)
|
modeSelected = InputLocationMode(injector, triggerLocation.modeSelected.value)
|
||||||
if (modeSelected.value == InputLocationMode.Mode.GOING_OUT)
|
if (modeSelected.value == InputLocationMode.Mode.GOING_OUT)
|
||||||
lastMode = InputLocationMode.Mode.OUTSIDE
|
lastMode = InputLocationMode.Mode.OUTSIDE
|
||||||
name = triggerLocation.name
|
name = triggerLocation.name
|
||||||
|
@ -87,17 +87,17 @@ class TriggerLocation(mainApp: MainApp) : Trigger(mainApp) {
|
||||||
|
|
||||||
override fun icon(): Optional<Int?> = Optional.of(R.drawable.ic_location_on)
|
override fun icon(): Optional<Int?> = Optional.of(R.drawable.ic_location_on)
|
||||||
|
|
||||||
override fun duplicate(): Trigger = TriggerLocation(mainApp, this)
|
override fun duplicate(): Trigger = TriggerLocation(injector, this)
|
||||||
|
|
||||||
override fun generateDialog(root: LinearLayout) {
|
override fun generateDialog(root: LinearLayout) {
|
||||||
LayoutBuilder()
|
LayoutBuilder()
|
||||||
.add(StaticLabel(mainApp, R.string.location, this))
|
.add(StaticLabel(injector, R.string.location, this))
|
||||||
.add(LabelWithElement(mainApp, resourceHelper.gs(R.string.name_short), "", name))
|
.add(LabelWithElement(injector, resourceHelper.gs(R.string.name_short), "", name))
|
||||||
.add(LabelWithElement(mainApp, resourceHelper.gs(R.string.latitude_short), "", latitude))
|
.add(LabelWithElement(injector, resourceHelper.gs(R.string.latitude_short), "", latitude))
|
||||||
.add(LabelWithElement(mainApp, resourceHelper.gs(R.string.longitude_short), "", longitude))
|
.add(LabelWithElement(injector, resourceHelper.gs(R.string.longitude_short), "", longitude))
|
||||||
.add(LabelWithElement(mainApp, resourceHelper.gs(R.string.distance_short), "", distance))
|
.add(LabelWithElement(injector, resourceHelper.gs(R.string.distance_short), "", distance))
|
||||||
.add(LabelWithElement(mainApp, resourceHelper.gs(R.string.location_mode), "", modeSelected))
|
.add(LabelWithElement(injector, resourceHelper.gs(R.string.location_mode), "", modeSelected))
|
||||||
.add(InputButton(mainApp, resourceHelper.gs(R.string.currentlocation), buttonAction), locationDataContainer.lastLocation != null)
|
.add(InputButton(injector, resourceHelper.gs(R.string.currentlocation), buttonAction), locationDataContainer.lastLocation != null)
|
||||||
.build(root)
|
.build(root)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -2,7 +2,7 @@ package info.nightscout.androidaps.plugins.general.automation.triggers
|
||||||
|
|
||||||
import android.widget.LinearLayout
|
import android.widget.LinearLayout
|
||||||
import com.google.common.base.Optional
|
import com.google.common.base.Optional
|
||||||
import info.nightscout.androidaps.MainApp
|
import dagger.android.HasAndroidInjector
|
||||||
import info.nightscout.androidaps.R
|
import info.nightscout.androidaps.R
|
||||||
import info.nightscout.androidaps.logging.LTag
|
import info.nightscout.androidaps.logging.LTag
|
||||||
import info.nightscout.androidaps.plugins.general.automation.elements.Comparator
|
import info.nightscout.androidaps.plugins.general.automation.elements.Comparator
|
||||||
|
@ -13,18 +13,18 @@ import info.nightscout.androidaps.plugins.general.automation.elements.StaticLabe
|
||||||
import info.nightscout.androidaps.utils.JsonHelper
|
import info.nightscout.androidaps.utils.JsonHelper
|
||||||
import org.json.JSONObject
|
import org.json.JSONObject
|
||||||
|
|
||||||
class TriggerProfilePercent(mainApp: MainApp) : Trigger(mainApp) {
|
class TriggerProfilePercent(injector: HasAndroidInjector) : Trigger(injector) {
|
||||||
private var pct = InputPercent(mainApp)
|
private var pct = InputPercent(injector)
|
||||||
var comparator = Comparator(mainApp)
|
var comparator = Comparator(injector)
|
||||||
|
|
||||||
constructor(mainApp: MainApp, value: Double, compare: Comparator.Compare) : this(mainApp) {
|
constructor(injector: HasAndroidInjector, value: Double, compare: Comparator.Compare) : this(injector) {
|
||||||
pct = InputPercent(mainApp, value)
|
pct = InputPercent(injector, value)
|
||||||
comparator = Comparator(mainApp, compare)
|
comparator = Comparator(injector, compare)
|
||||||
}
|
}
|
||||||
|
|
||||||
constructor(mainApp: MainApp, triggerProfilePercent: TriggerProfilePercent) : this(mainApp) {
|
constructor(injector: HasAndroidInjector, triggerProfilePercent: TriggerProfilePercent) : this(injector) {
|
||||||
pct = InputPercent(mainApp, triggerProfilePercent.pct.value)
|
pct = InputPercent(injector, triggerProfilePercent.pct.value)
|
||||||
comparator = Comparator(mainApp, triggerProfilePercent.comparator.value)
|
comparator = Comparator(injector, triggerProfilePercent.comparator.value)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun shouldRun(): Boolean {
|
override fun shouldRun(): Boolean {
|
||||||
|
@ -69,13 +69,13 @@ class TriggerProfilePercent(mainApp: MainApp) : Trigger(mainApp) {
|
||||||
|
|
||||||
override fun icon(): Optional<Int?> = Optional.of(R.drawable.icon_actions_profileswitch)
|
override fun icon(): Optional<Int?> = Optional.of(R.drawable.icon_actions_profileswitch)
|
||||||
|
|
||||||
override fun duplicate(): Trigger = TriggerProfilePercent(mainApp, this)
|
override fun duplicate(): Trigger = TriggerProfilePercent(injector, this)
|
||||||
|
|
||||||
override fun generateDialog(root: LinearLayout) {
|
override fun generateDialog(root: LinearLayout) {
|
||||||
LayoutBuilder()
|
LayoutBuilder()
|
||||||
.add(StaticLabel(mainApp, R.string.profilepercentage, this))
|
.add(StaticLabel(injector, R.string.profilepercentage, this))
|
||||||
.add(comparator)
|
.add(comparator)
|
||||||
.add(LabelWithElement(mainApp, resourceHelper.gs(R.string.percent_u), "", pct))
|
.add(LabelWithElement(injector, resourceHelper.gs(R.string.percent_u), "", pct))
|
||||||
.build(root)
|
.build(root)
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -2,7 +2,7 @@ package info.nightscout.androidaps.plugins.general.automation.triggers
|
||||||
|
|
||||||
import android.widget.LinearLayout
|
import android.widget.LinearLayout
|
||||||
import com.google.common.base.Optional
|
import com.google.common.base.Optional
|
||||||
import info.nightscout.androidaps.MainApp
|
import dagger.android.HasAndroidInjector
|
||||||
import info.nightscout.androidaps.R
|
import info.nightscout.androidaps.R
|
||||||
import info.nightscout.androidaps.logging.LTag
|
import info.nightscout.androidaps.logging.LTag
|
||||||
import info.nightscout.androidaps.plugins.general.automation.elements.Comparator
|
import info.nightscout.androidaps.plugins.general.automation.elements.Comparator
|
||||||
|
@ -15,22 +15,22 @@ import info.nightscout.androidaps.utils.JsonHelper.safeGetInt
|
||||||
import info.nightscout.androidaps.utils.JsonHelper.safeGetString
|
import info.nightscout.androidaps.utils.JsonHelper.safeGetString
|
||||||
import org.json.JSONObject
|
import org.json.JSONObject
|
||||||
|
|
||||||
class TriggerPumpLastConnection(mainApp: MainApp) : Trigger(mainApp) {
|
class TriggerPumpLastConnection(injector: HasAndroidInjector) : Trigger(injector) {
|
||||||
private var minutesAgo = InputDuration(mainApp)
|
private var minutesAgo = InputDuration(injector)
|
||||||
private var comparator = Comparator(mainApp)
|
private var comparator = Comparator(injector)
|
||||||
|
|
||||||
constructor(mainApp: MainApp, value: Int, unit: InputDuration.TimeUnit, compare: Comparator.Compare) : this(mainApp) {
|
constructor(injector: HasAndroidInjector, value: Int, unit: InputDuration.TimeUnit, compare: Comparator.Compare) : this(injector) {
|
||||||
minutesAgo = InputDuration(mainApp, value, unit)
|
minutesAgo = InputDuration(injector, value, unit)
|
||||||
comparator = Comparator(mainApp, compare)
|
comparator = Comparator(injector, compare)
|
||||||
}
|
}
|
||||||
|
|
||||||
constructor(mainApp: MainApp, triggerPumpLastConnection: TriggerPumpLastConnection) : this(mainApp) {
|
constructor(injector: HasAndroidInjector, triggerPumpLastConnection: TriggerPumpLastConnection) : this(injector) {
|
||||||
minutesAgo = InputDuration(mainApp, triggerPumpLastConnection.minutesAgo.value, triggerPumpLastConnection.minutesAgo.unit)
|
minutesAgo = InputDuration(injector, triggerPumpLastConnection.minutesAgo.value, triggerPumpLastConnection.minutesAgo.unit)
|
||||||
comparator = Comparator(mainApp, triggerPumpLastConnection.comparator.value)
|
comparator = Comparator(injector, triggerPumpLastConnection.comparator.value)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun shouldRun(): Boolean {
|
override fun shouldRun(): Boolean {
|
||||||
val lastConnection = activePluginProvider.activePump?.lastDataTime() ?: return false
|
val lastConnection = activePlugin.activePumpPlugin?.lastDataTime() ?: return false
|
||||||
if (lastConnection == 0L && comparator.value === Comparator.Compare.IS_NOT_AVAILABLE) {
|
if (lastConnection == 0L && comparator.value === Comparator.Compare.IS_NOT_AVAILABLE) {
|
||||||
aapsLogger.debug(LTag.AUTOMATION, "Ready for execution: " + friendlyDescription())
|
aapsLogger.debug(LTag.AUTOMATION, "Ready for execution: " + friendlyDescription())
|
||||||
return true
|
return true
|
||||||
|
@ -69,13 +69,13 @@ class TriggerPumpLastConnection(mainApp: MainApp) : Trigger(mainApp) {
|
||||||
|
|
||||||
override fun icon(): Optional<Int?> = Optional.of(R.drawable.remove)
|
override fun icon(): Optional<Int?> = Optional.of(R.drawable.remove)
|
||||||
|
|
||||||
override fun duplicate(): Trigger = TriggerPumpLastConnection(mainApp, this)
|
override fun duplicate(): Trigger = TriggerPumpLastConnection(injector, this)
|
||||||
|
|
||||||
override fun generateDialog(root: LinearLayout) {
|
override fun generateDialog(root: LinearLayout) {
|
||||||
LayoutBuilder()
|
LayoutBuilder()
|
||||||
.add(StaticLabel(mainApp, R.string.automation_trigger_pump_last_connection_label, this))
|
.add(StaticLabel(injector, R.string.automation_trigger_pump_last_connection_label, this))
|
||||||
.add(comparator)
|
.add(comparator)
|
||||||
.add(LabelWithElement(mainApp, resourceHelper.gs(R.string.automation_trigger_pump_last_connection_description) + ": ", "", minutesAgo))
|
.add(LabelWithElement(injector, resourceHelper.gs(R.string.automation_trigger_pump_last_connection_description) + ": ", "", minutesAgo))
|
||||||
.build(root)
|
.build(root)
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -2,7 +2,7 @@ package info.nightscout.androidaps.plugins.general.automation.triggers
|
||||||
|
|
||||||
import android.widget.LinearLayout
|
import android.widget.LinearLayout
|
||||||
import com.google.common.base.Optional
|
import com.google.common.base.Optional
|
||||||
import info.nightscout.androidaps.MainApp
|
import dagger.android.HasAndroidInjector
|
||||||
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.logging.LTag
|
import info.nightscout.androidaps.logging.LTag
|
||||||
|
@ -17,11 +17,11 @@ import info.nightscout.androidaps.utils.T
|
||||||
import org.json.JSONObject
|
import org.json.JSONObject
|
||||||
import java.util.*
|
import java.util.*
|
||||||
|
|
||||||
class TriggerRecurringTime(mainApp: MainApp) : Trigger(mainApp) {
|
class TriggerRecurringTime(injector: HasAndroidInjector) : Trigger(injector) {
|
||||||
private val days = InputWeekDay(mainApp)
|
private val days = InputWeekDay(injector)
|
||||||
private val time = InputTime(mainApp)
|
private val time = InputTime(injector)
|
||||||
|
|
||||||
constructor(mainApp: MainApp, triggerRecurringTime: TriggerRecurringTime) : this(mainApp) {
|
constructor(injector: HasAndroidInjector, triggerRecurringTime: TriggerRecurringTime) : this(injector) {
|
||||||
this.time.value = triggerRecurringTime.time.value
|
this.time.value = triggerRecurringTime.time.value
|
||||||
if (days.weekdays.size >= 0)
|
if (days.weekdays.size >= 0)
|
||||||
System.arraycopy(triggerRecurringTime.days.weekdays, 0, days.weekdays, 0, triggerRecurringTime.days.weekdays.size)
|
System.arraycopy(triggerRecurringTime.days.weekdays, 0, days.weekdays, 0, triggerRecurringTime.days.weekdays.size)
|
||||||
|
@ -86,7 +86,7 @@ class TriggerRecurringTime(mainApp: MainApp) : Trigger(mainApp) {
|
||||||
|
|
||||||
override fun icon(): Optional<Int?> = Optional.of(R.drawable.ic_access_alarm_24dp)
|
override fun icon(): Optional<Int?> = Optional.of(R.drawable.ic_access_alarm_24dp)
|
||||||
|
|
||||||
override fun duplicate(): Trigger = TriggerRecurringTime(mainApp, this)
|
override fun duplicate(): Trigger = TriggerRecurringTime(injector, this)
|
||||||
|
|
||||||
private fun toMills(minutesSinceMidnight: Int): Long = MidnightTime.calc() + T.mins(minutesSinceMidnight.toLong()).msecs()
|
private fun toMills(minutesSinceMidnight: Int): Long = MidnightTime.calc() + T.mins(minutesSinceMidnight.toLong()).msecs()
|
||||||
|
|
||||||
|
@ -94,7 +94,7 @@ class TriggerRecurringTime(mainApp: MainApp) : Trigger(mainApp) {
|
||||||
|
|
||||||
override fun generateDialog(root: LinearLayout) {
|
override fun generateDialog(root: LinearLayout) {
|
||||||
LayoutBuilder()
|
LayoutBuilder()
|
||||||
.add(StaticLabel(mainApp, R.string.recurringTime, this))
|
.add(StaticLabel(injector, R.string.recurringTime, this))
|
||||||
.add(days)
|
.add(days)
|
||||||
.add(time)
|
.add(time)
|
||||||
.build(root)
|
.build(root)
|
||||||
|
|
|
@ -2,7 +2,7 @@ package info.nightscout.androidaps.plugins.general.automation.triggers
|
||||||
|
|
||||||
import android.widget.LinearLayout
|
import android.widget.LinearLayout
|
||||||
import com.google.common.base.Optional
|
import com.google.common.base.Optional
|
||||||
import info.nightscout.androidaps.MainApp
|
import dagger.android.HasAndroidInjector
|
||||||
import info.nightscout.androidaps.R
|
import info.nightscout.androidaps.R
|
||||||
import info.nightscout.androidaps.logging.LTag
|
import info.nightscout.androidaps.logging.LTag
|
||||||
import info.nightscout.androidaps.plugins.general.automation.elements.ComparatorExists
|
import info.nightscout.androidaps.plugins.general.automation.elements.ComparatorExists
|
||||||
|
@ -11,15 +11,15 @@ import info.nightscout.androidaps.plugins.general.automation.elements.StaticLabe
|
||||||
import info.nightscout.androidaps.utils.JsonHelper
|
import info.nightscout.androidaps.utils.JsonHelper
|
||||||
import org.json.JSONObject
|
import org.json.JSONObject
|
||||||
|
|
||||||
class TriggerTempTarget(mainApp: MainApp) : Trigger(mainApp) {
|
class TriggerTempTarget(injector: HasAndroidInjector) : Trigger(injector) {
|
||||||
var comparator = ComparatorExists(mainApp)
|
var comparator = ComparatorExists(injector)
|
||||||
|
|
||||||
constructor(mainApp: MainApp, compare: ComparatorExists.Compare) : this(mainApp) {
|
constructor(injector: HasAndroidInjector, compare: ComparatorExists.Compare) : this(injector) {
|
||||||
comparator = ComparatorExists(mainApp, compare)
|
comparator = ComparatorExists(injector, compare)
|
||||||
}
|
}
|
||||||
|
|
||||||
constructor(mainApp: MainApp, triggerTempTarget: TriggerTempTarget) : this(mainApp) {
|
constructor(injector: HasAndroidInjector, triggerTempTarget: TriggerTempTarget) : this(injector) {
|
||||||
comparator = ComparatorExists(mainApp, triggerTempTarget.comparator.value)
|
comparator = ComparatorExists(injector, triggerTempTarget.comparator.value)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun shouldRun(): Boolean {
|
override fun shouldRun(): Boolean {
|
||||||
|
@ -58,11 +58,11 @@ class TriggerTempTarget(mainApp: MainApp) : Trigger(mainApp) {
|
||||||
|
|
||||||
override fun icon(): Optional<Int?> = Optional.of(R.drawable.ic_keyboard_tab)
|
override fun icon(): Optional<Int?> = Optional.of(R.drawable.ic_keyboard_tab)
|
||||||
|
|
||||||
override fun duplicate(): Trigger = TriggerTempTarget(mainApp, this)
|
override fun duplicate(): Trigger = TriggerTempTarget(injector, this)
|
||||||
|
|
||||||
override fun generateDialog(root: LinearLayout) {
|
override fun generateDialog(root: LinearLayout) {
|
||||||
LayoutBuilder()
|
LayoutBuilder()
|
||||||
.add(StaticLabel(mainApp, R.string.careportal_temporarytarget, this))
|
.add(StaticLabel(injector, R.string.careportal_temporarytarget, this))
|
||||||
.add(comparator)
|
.add(comparator)
|
||||||
.build(root)
|
.build(root)
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,7 +2,7 @@ package info.nightscout.androidaps.plugins.general.automation.triggers
|
||||||
|
|
||||||
import android.widget.LinearLayout
|
import android.widget.LinearLayout
|
||||||
import com.google.common.base.Optional
|
import com.google.common.base.Optional
|
||||||
import info.nightscout.androidaps.MainApp
|
import dagger.android.HasAndroidInjector
|
||||||
import info.nightscout.androidaps.R
|
import info.nightscout.androidaps.R
|
||||||
import info.nightscout.androidaps.logging.LTag
|
import info.nightscout.androidaps.logging.LTag
|
||||||
import info.nightscout.androidaps.plugins.general.automation.elements.InputDateTime
|
import info.nightscout.androidaps.plugins.general.automation.elements.InputDateTime
|
||||||
|
@ -13,14 +13,14 @@ import info.nightscout.androidaps.utils.JsonHelper
|
||||||
import info.nightscout.androidaps.utils.T
|
import info.nightscout.androidaps.utils.T
|
||||||
import org.json.JSONObject
|
import org.json.JSONObject
|
||||||
|
|
||||||
class TriggerTime(mainApp: MainApp) : Trigger(mainApp) {
|
class TriggerTime(injector: HasAndroidInjector) : Trigger(injector) {
|
||||||
var time = InputDateTime(mainApp)
|
var time = InputDateTime(injector)
|
||||||
|
|
||||||
constructor(mainApp: MainApp, runAt: Long) : this(mainApp) {
|
constructor(injector: HasAndroidInjector, runAt: Long) : this(injector) {
|
||||||
this.time.value = runAt
|
this.time.value = runAt
|
||||||
}
|
}
|
||||||
|
|
||||||
constructor(mainApp: MainApp, triggerTime: TriggerTime) : this(mainApp) {
|
constructor(injector: HasAndroidInjector, triggerTime: TriggerTime) : this(injector) {
|
||||||
this.time.value = triggerTime.time.value
|
this.time.value = triggerTime.time.value
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -56,11 +56,11 @@ class TriggerTime(mainApp: MainApp) : Trigger(mainApp) {
|
||||||
|
|
||||||
override fun icon(): Optional<Int?> = Optional.of(R.drawable.ic_access_alarm_24dp)
|
override fun icon(): Optional<Int?> = Optional.of(R.drawable.ic_access_alarm_24dp)
|
||||||
|
|
||||||
override fun duplicate(): Trigger = TriggerTime(mainApp, time.value)
|
override fun duplicate(): Trigger = TriggerTime(injector, time.value)
|
||||||
|
|
||||||
override fun generateDialog(root: LinearLayout) {
|
override fun generateDialog(root: LinearLayout) {
|
||||||
LayoutBuilder()
|
LayoutBuilder()
|
||||||
.add(StaticLabel(mainApp, R.string.time, this))
|
.add(StaticLabel(injector, R.string.time, this))
|
||||||
.add(time)
|
.add(time)
|
||||||
.build(root)
|
.build(root)
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,7 +2,7 @@ package info.nightscout.androidaps.plugins.general.automation.triggers
|
||||||
|
|
||||||
import android.widget.LinearLayout
|
import android.widget.LinearLayout
|
||||||
import com.google.common.base.Optional
|
import com.google.common.base.Optional
|
||||||
import info.nightscout.androidaps.MainApp
|
import dagger.android.HasAndroidInjector
|
||||||
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.logging.LTag
|
import info.nightscout.androidaps.logging.LTag
|
||||||
|
@ -16,17 +16,17 @@ import info.nightscout.androidaps.utils.T
|
||||||
import org.json.JSONObject
|
import org.json.JSONObject
|
||||||
|
|
||||||
// Trigger for time range ( from 10:00AM till 13:00PM )
|
// Trigger for time range ( from 10:00AM till 13:00PM )
|
||||||
class TriggerTimeRange(mainApp: MainApp) : Trigger(mainApp) {
|
class TriggerTimeRange(injector: HasAndroidInjector) : Trigger(injector) {
|
||||||
|
|
||||||
// in minutes since midnight 60 means 1AM
|
// in minutes since midnight 60 means 1AM
|
||||||
var range = InputTimeRange(mainApp)
|
var range = InputTimeRange(injector)
|
||||||
|
|
||||||
constructor(mainApp: MainApp, start: Int, end: Int) : this(mainApp) {
|
constructor(injector: HasAndroidInjector, start: Int, end: Int) : this(injector) {
|
||||||
range.start = start
|
range.start = start
|
||||||
range.end = end
|
range.end = end
|
||||||
}
|
}
|
||||||
|
|
||||||
constructor(mainApp: MainApp, triggerTimeRange: TriggerTimeRange) : this(mainApp) {
|
constructor(injector: HasAndroidInjector, triggerTimeRange: TriggerTimeRange) : this(injector) {
|
||||||
range.start = triggerTimeRange.range.start
|
range.start = triggerTimeRange.range.start
|
||||||
range.end = triggerTimeRange.range.end
|
range.end = triggerTimeRange.range.end
|
||||||
}
|
}
|
||||||
|
@ -68,7 +68,7 @@ class TriggerTimeRange(mainApp: MainApp) : Trigger(mainApp) {
|
||||||
|
|
||||||
override fun icon(): Optional<Int?> = Optional.of(R.drawable.ic_access_alarm_24dp)
|
override fun icon(): Optional<Int?> = Optional.of(R.drawable.ic_access_alarm_24dp)
|
||||||
|
|
||||||
override fun duplicate(): Trigger = TriggerTimeRange(mainApp, range.start, range.end)
|
override fun duplicate(): Trigger = TriggerTimeRange(injector, range.start, range.end)
|
||||||
|
|
||||||
private fun toMills(minutesSinceMidnight: Int): Long = MidnightTime.calc() + T.mins(minutesSinceMidnight.toLong()).msecs()
|
private fun toMills(minutesSinceMidnight: Int): Long = MidnightTime.calc() + T.mins(minutesSinceMidnight.toLong()).msecs()
|
||||||
|
|
||||||
|
@ -76,7 +76,7 @@ class TriggerTimeRange(mainApp: MainApp) : Trigger(mainApp) {
|
||||||
|
|
||||||
override fun generateDialog(root: LinearLayout) {
|
override fun generateDialog(root: LinearLayout) {
|
||||||
LayoutBuilder()
|
LayoutBuilder()
|
||||||
.add(StaticLabel(mainApp, R.string.time_range, this))
|
.add(StaticLabel(injector, R.string.time_range, this))
|
||||||
.add(range)
|
.add(range)
|
||||||
.build(root)
|
.build(root)
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,7 +2,7 @@ package info.nightscout.androidaps.plugins.general.automation.triggers
|
||||||
|
|
||||||
import android.widget.LinearLayout
|
import android.widget.LinearLayout
|
||||||
import com.google.common.base.Optional
|
import com.google.common.base.Optional
|
||||||
import info.nightscout.androidaps.MainApp
|
import dagger.android.HasAndroidInjector
|
||||||
import info.nightscout.androidaps.R
|
import info.nightscout.androidaps.R
|
||||||
import info.nightscout.androidaps.logging.LTag
|
import info.nightscout.androidaps.logging.LTag
|
||||||
import info.nightscout.androidaps.plugins.general.automation.elements.Comparator
|
import info.nightscout.androidaps.plugins.general.automation.elements.Comparator
|
||||||
|
@ -14,18 +14,18 @@ import info.nightscout.androidaps.receivers.NetworkChangeReceiver
|
||||||
import info.nightscout.androidaps.utils.JsonHelper
|
import info.nightscout.androidaps.utils.JsonHelper
|
||||||
import org.json.JSONObject
|
import org.json.JSONObject
|
||||||
|
|
||||||
class TriggerWifiSsid(mainApp: MainApp) : Trigger(mainApp) {
|
class TriggerWifiSsid(injector: HasAndroidInjector) : Trigger(injector) {
|
||||||
private var ssid = InputString(mainApp)
|
private var ssid = InputString(injector)
|
||||||
var comparator = Comparator(mainApp)
|
var comparator = Comparator(injector)
|
||||||
|
|
||||||
constructor(mainApp: MainApp, ssid: String, compare: Comparator.Compare) : this(mainApp) {
|
constructor(injector: HasAndroidInjector, ssid: String, compare: Comparator.Compare) : this(injector) {
|
||||||
this.ssid = InputString(mainApp, ssid)
|
this.ssid = InputString(injector, ssid)
|
||||||
comparator = Comparator(mainApp, compare)
|
comparator = Comparator(injector, compare)
|
||||||
}
|
}
|
||||||
|
|
||||||
constructor(mainApp: MainApp, triggerWifiSsid: TriggerWifiSsid) : this(mainApp) {
|
constructor(injector: HasAndroidInjector, triggerWifiSsid: TriggerWifiSsid) : this(injector) {
|
||||||
this.ssid = InputString(mainApp, triggerWifiSsid.ssid.value)
|
this.ssid = InputString(injector, triggerWifiSsid.ssid.value)
|
||||||
comparator = Comparator(mainApp, triggerWifiSsid.comparator.value)
|
comparator = Comparator(injector, triggerWifiSsid.comparator.value)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun shouldRun(): Boolean {
|
override fun shouldRun(): Boolean {
|
||||||
|
@ -66,13 +66,13 @@ class TriggerWifiSsid(mainApp: MainApp) : Trigger(mainApp) {
|
||||||
|
|
||||||
override fun icon(): Optional<Int?> = Optional.of(R.drawable.ic_network_wifi)
|
override fun icon(): Optional<Int?> = Optional.of(R.drawable.ic_network_wifi)
|
||||||
|
|
||||||
override fun duplicate(): Trigger = TriggerWifiSsid(mainApp, this)
|
override fun duplicate(): Trigger = TriggerWifiSsid(injector, this)
|
||||||
|
|
||||||
override fun generateDialog(root: LinearLayout) {
|
override fun generateDialog(root: LinearLayout) {
|
||||||
LayoutBuilder()
|
LayoutBuilder()
|
||||||
.add(StaticLabel(mainApp, R.string.ns_wifi_ssids, this))
|
.add(StaticLabel(injector, R.string.ns_wifi_ssids, this))
|
||||||
.add(comparator)
|
.add(comparator)
|
||||||
.add(LabelWithElement(mainApp, resourceHelper.gs(R.string.ns_wifi_ssids) + ": ", "", ssid))
|
.add(LabelWithElement(injector, resourceHelper.gs(R.string.ns_wifi_ssids) + ": ", "", ssid))
|
||||||
.build(root)
|
.build(root)
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -6,12 +6,12 @@ import info.nightscout.androidaps.interfaces.PluginBase
|
||||||
import info.nightscout.androidaps.interfaces.PluginDescription
|
import info.nightscout.androidaps.interfaces.PluginDescription
|
||||||
import info.nightscout.androidaps.interfaces.PluginType
|
import info.nightscout.androidaps.interfaces.PluginType
|
||||||
import info.nightscout.androidaps.logging.AAPSLogger
|
import info.nightscout.androidaps.logging.AAPSLogger
|
||||||
import info.nightscout.androidaps.plugins.bus.RxBusWrapper
|
import info.nightscout.androidaps.utils.resources.ResourceHelper
|
||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
import javax.inject.Singleton
|
import javax.inject.Singleton
|
||||||
|
|
||||||
@Singleton
|
@Singleton
|
||||||
class CareportalPlugin @Inject constructor(rxBus: RxBusWrapper, aapsLogger: AAPSLogger
|
class CareportalPlugin @Inject constructor(aapsLogger: AAPSLogger, resourceHelper: ResourceHelper
|
||||||
) : PluginBase(PluginDescription()
|
) : PluginBase(PluginDescription()
|
||||||
.mainType(PluginType.GENERAL)
|
.mainType(PluginType.GENERAL)
|
||||||
.fragmentClass(CareportalFragment::class.java.name)
|
.fragmentClass(CareportalFragment::class.java.name)
|
||||||
|
@ -20,11 +20,6 @@ class CareportalPlugin @Inject constructor(rxBus: RxBusWrapper, aapsLogger: AAPS
|
||||||
.visibleByDefault(Config.NSCLIENT)
|
.visibleByDefault(Config.NSCLIENT)
|
||||||
.enableByDefault(Config.NSCLIENT)
|
.enableByDefault(Config.NSCLIENT)
|
||||||
.description(R.string.description_careportal),
|
.description(R.string.description_careportal),
|
||||||
rxBus, aapsLogger
|
aapsLogger, resourceHelper
|
||||||
|
|
||||||
) {
|
)
|
||||||
|
|
||||||
override fun specialEnableCondition(): Boolean {
|
|
||||||
return Config.NSCLIENT
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -5,19 +5,19 @@ import info.nightscout.androidaps.interfaces.PluginBase
|
||||||
import info.nightscout.androidaps.interfaces.PluginDescription
|
import info.nightscout.androidaps.interfaces.PluginDescription
|
||||||
import info.nightscout.androidaps.interfaces.PluginType
|
import info.nightscout.androidaps.interfaces.PluginType
|
||||||
import info.nightscout.androidaps.logging.AAPSLogger
|
import info.nightscout.androidaps.logging.AAPSLogger
|
||||||
import info.nightscout.androidaps.plugins.bus.RxBusWrapper
|
import info.nightscout.androidaps.utils.resources.ResourceHelper
|
||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
import javax.inject.Singleton
|
import javax.inject.Singleton
|
||||||
|
|
||||||
@Singleton
|
@Singleton
|
||||||
class FoodPlugin @Inject constructor(rxBus: RxBusWrapper, aapsLogger: AAPSLogger
|
class FoodPlugin @Inject constructor(aapsLogger: AAPSLogger, resourceHelper: ResourceHelper
|
||||||
) : PluginBase(PluginDescription()
|
) : PluginBase(PluginDescription()
|
||||||
.mainType(PluginType.GENERAL)
|
.mainType(PluginType.GENERAL)
|
||||||
.fragmentClass(FoodFragment::class.java.name)
|
.fragmentClass(FoodFragment::class.java.name)
|
||||||
.pluginName(R.string.food)
|
.pluginName(R.string.food)
|
||||||
.shortName(R.string.food_short)
|
.shortName(R.string.food_short)
|
||||||
.description(R.string.description_food),
|
.description(R.string.description_food),
|
||||||
rxBus, aapsLogger
|
aapsLogger, resourceHelper
|
||||||
) {
|
) {
|
||||||
|
|
||||||
var service: FoodService? = null
|
var service: FoodService? = null
|
||||||
|
|
|
@ -11,7 +11,6 @@ import info.nightscout.androidaps.interfaces.PluginBase
|
||||||
import info.nightscout.androidaps.interfaces.PluginDescription
|
import info.nightscout.androidaps.interfaces.PluginDescription
|
||||||
import info.nightscout.androidaps.interfaces.PluginType
|
import info.nightscout.androidaps.interfaces.PluginType
|
||||||
import info.nightscout.androidaps.logging.AAPSLogger
|
import info.nightscout.androidaps.logging.AAPSLogger
|
||||||
import info.nightscout.androidaps.plugins.bus.RxBusWrapper
|
|
||||||
import info.nightscout.androidaps.plugins.general.nsclient.data.NSSettingsStatus
|
import info.nightscout.androidaps.plugins.general.nsclient.data.NSSettingsStatus
|
||||||
import info.nightscout.androidaps.utils.resources.ResourceHelper
|
import info.nightscout.androidaps.utils.resources.ResourceHelper
|
||||||
import info.nightscout.androidaps.utils.sharedPreferences.SP
|
import info.nightscout.androidaps.utils.sharedPreferences.SP
|
||||||
|
@ -25,10 +24,10 @@ import javax.inject.Singleton
|
||||||
@Singleton
|
@Singleton
|
||||||
class MaintenancePlugin @Inject constructor(
|
class MaintenancePlugin @Inject constructor(
|
||||||
private val mainApp: MainApp,
|
private val mainApp: MainApp,
|
||||||
private val resourceHelper: ResourceHelper,
|
resourceHelper: ResourceHelper,
|
||||||
private val sp: SP,
|
private val sp: SP,
|
||||||
private val nsSettingsStatus: NSSettingsStatus,
|
private val nsSettingsStatus: NSSettingsStatus,
|
||||||
rxBus: RxBusWrapper, aapsLogger: AAPSLogger
|
aapsLogger: AAPSLogger
|
||||||
) : PluginBase(PluginDescription()
|
) : PluginBase(PluginDescription()
|
||||||
.mainType(PluginType.GENERAL)
|
.mainType(PluginType.GENERAL)
|
||||||
.fragmentClass(MaintenanceFragment::class.java.name)
|
.fragmentClass(MaintenanceFragment::class.java.name)
|
||||||
|
@ -38,7 +37,7 @@ class MaintenancePlugin @Inject constructor(
|
||||||
.shortName(R.string.maintenance_shortname)
|
.shortName(R.string.maintenance_shortname)
|
||||||
.preferencesId(R.xml.pref_maintenance)
|
.preferencesId(R.xml.pref_maintenance)
|
||||||
.description(R.string.description_maintenance),
|
.description(R.string.description_maintenance),
|
||||||
rxBus, aapsLogger
|
aapsLogger, resourceHelper
|
||||||
) {
|
) {
|
||||||
|
|
||||||
fun sendLogs() {
|
fun sendLogs() {
|
||||||
|
|
|
@ -13,8 +13,9 @@ import android.widget.CompoundButton;
|
||||||
import android.widget.ScrollView;
|
import android.widget.ScrollView;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
|
||||||
import androidx.fragment.app.Fragment;
|
import javax.inject.Inject;
|
||||||
|
|
||||||
|
import dagger.android.support.DaggerFragment;
|
||||||
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.bus.RxBus;
|
import info.nightscout.androidaps.plugins.bus.RxBus;
|
||||||
|
@ -27,7 +28,9 @@ import info.nightscout.androidaps.utils.SP;
|
||||||
import io.reactivex.android.schedulers.AndroidSchedulers;
|
import io.reactivex.android.schedulers.AndroidSchedulers;
|
||||||
import io.reactivex.disposables.CompositeDisposable;
|
import io.reactivex.disposables.CompositeDisposable;
|
||||||
|
|
||||||
public class NSClientFragment extends Fragment implements View.OnClickListener, CompoundButton.OnCheckedChangeListener {
|
public class NSClientFragment extends DaggerFragment implements View.OnClickListener, CompoundButton.OnCheckedChangeListener {
|
||||||
|
@Inject NSClientPlugin nsClientPlugin;
|
||||||
|
|
||||||
private CompositeDisposable disposable = new CompositeDisposable();
|
private CompositeDisposable disposable = new CompositeDisposable();
|
||||||
|
|
||||||
private TextView logTextView;
|
private TextView logTextView;
|
||||||
|
@ -50,10 +53,10 @@ public class NSClientFragment extends Fragment implements View.OnClickListener,
|
||||||
|
|
||||||
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(NSClientPlugin.getPlugin().autoscroll);
|
autoscrollCheckbox.setChecked(nsClientPlugin.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(NSClientPlugin.getPlugin().paused);
|
pausedCheckbox.setChecked(nsClientPlugin.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);
|
||||||
|
@ -104,11 +107,11 @@ public class NSClientFragment extends Fragment implements View.OnClickListener,
|
||||||
FabricPrivacy.getInstance().logCustom("NSClientRestart");
|
FabricPrivacy.getInstance().logCustom("NSClientRestart");
|
||||||
break;
|
break;
|
||||||
case R.id.nsclientinternal_delivernow:
|
case R.id.nsclientinternal_delivernow:
|
||||||
NSClientPlugin.getPlugin().resend("GUI");
|
nsClientPlugin.resend("GUI");
|
||||||
FabricPrivacy.getInstance().logCustom("NSClientDeliverNow");
|
FabricPrivacy.getInstance().logCustom("NSClientDeliverNow");
|
||||||
break;
|
break;
|
||||||
case R.id.nsclientinternal_clearlog:
|
case R.id.nsclientinternal_clearlog:
|
||||||
NSClientPlugin.getPlugin().clearLog();
|
nsClientPlugin.clearLog();
|
||||||
break;
|
break;
|
||||||
case R.id.nsclientinternal_clearqueue:
|
case R.id.nsclientinternal_clearqueue:
|
||||||
OKDialog.showConfirmation(getContext(), MainApp.gs(R.string.nsclientinternal), MainApp.gs(R.string.clearqueueconfirm), () -> {
|
OKDialog.showConfirmation(getContext(), MainApp.gs(R.string.nsclientinternal), MainApp.gs(R.string.clearqueueconfirm), () -> {
|
||||||
|
@ -118,7 +121,7 @@ public class NSClientFragment extends Fragment implements View.OnClickListener,
|
||||||
});
|
});
|
||||||
break;
|
break;
|
||||||
case R.id.nsclientinternal_showqueue:
|
case R.id.nsclientinternal_showqueue:
|
||||||
RxBus.Companion.getINSTANCE().send(new EventNSClientNewLog("QUEUE", NSClientPlugin.getPlugin().queue().textList()));
|
RxBus.Companion.getINSTANCE().send(new EventNSClientNewLog("QUEUE", nsClientPlugin.queue().textList()));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -127,29 +130,29 @@ public class NSClientFragment extends Fragment implements View.OnClickListener,
|
||||||
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
|
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
|
||||||
switch (buttonView.getId()) {
|
switch (buttonView.getId()) {
|
||||||
case R.id.nsclientinternal_paused:
|
case R.id.nsclientinternal_paused:
|
||||||
NSClientPlugin.getPlugin().pause(isChecked);
|
nsClientPlugin.pause(isChecked);
|
||||||
updateGui();
|
updateGui();
|
||||||
FabricPrivacy.getInstance().logCustom("NSClientPause");
|
FabricPrivacy.getInstance().logCustom("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);
|
||||||
NSClientPlugin.getPlugin().autoscroll = isChecked;
|
nsClientPlugin.autoscroll = isChecked;
|
||||||
updateGui();
|
updateGui();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void updateGui() {
|
protected void updateGui() {
|
||||||
NSClientPlugin.getPlugin().updateLog();
|
nsClientPlugin.updateLog();
|
||||||
pausedCheckbox.setChecked(SP.getBoolean(R.string.key_nsclientinternal_paused, false));
|
pausedCheckbox.setChecked(SP.getBoolean(R.string.key_nsclientinternal_paused, false));
|
||||||
logTextView.setText(NSClientPlugin.getPlugin().textLog);
|
logTextView.setText(nsClientPlugin.textLog);
|
||||||
if (NSClientPlugin.getPlugin().autoscroll) {
|
if (nsClientPlugin.autoscroll) {
|
||||||
logScrollview.fullScroll(ScrollView.FOCUS_DOWN);
|
logScrollview.fullScroll(ScrollView.FOCUS_DOWN);
|
||||||
}
|
}
|
||||||
urlTextView.setText(NSClientPlugin.getPlugin().url());
|
urlTextView.setText(nsClientPlugin.url());
|
||||||
Spanned queuetext = Html.fromHtml(MainApp.gs(R.string.queue) + " <b>" + UploadQueue.size() + "</b>");
|
Spanned queuetext = Html.fromHtml(MainApp.gs(R.string.queue) + " <b>" + UploadQueue.size() + "</b>");
|
||||||
queueTextView.setText(queuetext);
|
queueTextView.setText(queuetext);
|
||||||
statusTextView.setText(NSClientPlugin.getPlugin().status);
|
statusTextView.setText(nsClientPlugin.status);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue