RS -> danaRS finished
This commit is contained in:
parent
040c76d839
commit
7fc631a729
104 changed files with 666 additions and 407 deletions
|
@ -23,6 +23,7 @@ import javax.inject.Inject;
|
|||
import dagger.android.AndroidInjector;
|
||||
import dagger.android.DaggerApplication;
|
||||
import info.nightscout.androidaps.db.BgReading;
|
||||
import info.nightscout.androidaps.db.CareportalEvent;
|
||||
import info.nightscout.androidaps.db.DatabaseHelper;
|
||||
import info.nightscout.androidaps.db.StaticInjector;
|
||||
import info.nightscout.androidaps.dependencyInjection.DaggerAppComponent;
|
||||
|
@ -45,7 +46,7 @@ import info.nightscout.androidaps.utils.ActivityMonitor;
|
|||
import info.nightscout.androidaps.utils.LocaleHelper;
|
||||
import info.nightscout.androidaps.utils.sharedPreferences.SP;
|
||||
|
||||
public class MainApp extends DaggerApplication implements DatabaseHelperInterface {
|
||||
public class MainApp extends DaggerApplication {
|
||||
|
||||
static MainApp sInstance;
|
||||
private static Resources sResources;
|
||||
|
@ -57,6 +58,7 @@ public class MainApp extends DaggerApplication implements DatabaseHelperInterfac
|
|||
@Inject ActivityMonitor activityMonitor;
|
||||
@Inject VersionCheckerUtils versionCheckersUtils;
|
||||
@Inject SP sp;
|
||||
@Inject NSUpload nsUpload;
|
||||
|
||||
@Inject ConfigBuilderPlugin configBuilderPlugin;
|
||||
@Inject KeepAliveReceiver.KeepAliveManager keepAliveManager;
|
||||
|
@ -99,7 +101,7 @@ public class MainApp extends DaggerApplication implements DatabaseHelperInterfac
|
|||
pluginStore.setPlugins(plugins);
|
||||
configBuilderPlugin.initialize();
|
||||
|
||||
NSUpload.uploadAppStart();
|
||||
nsUpload.uploadAppStart();
|
||||
|
||||
new Thread(() -> keepAliveManager.setAlarm(this)).start();
|
||||
doMigrations();
|
||||
|
@ -173,8 +175,4 @@ public class MainApp extends DaggerApplication implements DatabaseHelperInterfac
|
|||
keepAliveManager.cancelAlarm(this);
|
||||
super.onTerminate();
|
||||
}
|
||||
|
||||
@NotNull @Override public List<BgReading> getAllBgreadingsDataFromTime(long mills, boolean ascending) {
|
||||
return getDbHelper().getAllBgreadingsDataFromTime(mills, ascending);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1733,7 +1733,7 @@ public class DatabaseHelper extends OrmLiteSqliteOpenHelper {
|
|||
}
|
||||
*/
|
||||
|
||||
public void createProfileSwitchFromJsonIfNotExists(ActivePluginProvider activePluginProvider, JSONObject trJson) {
|
||||
public void createProfileSwitchFromJsonIfNotExists(ActivePluginProvider activePluginProvider, NSUpload nsUpload, JSONObject trJson) {
|
||||
try {
|
||||
ProfileSwitch profileSwitch = new ProfileSwitch(MainApp.instance());
|
||||
profileSwitch.date = trJson.getLong("mills");
|
||||
|
@ -1759,7 +1759,7 @@ public class DatabaseHelper extends OrmLiteSqliteOpenHelper {
|
|||
if (L.isEnabled(LTag.DATABASE))
|
||||
log.debug("Profile switch prefilled with JSON from local store");
|
||||
// Update data in NS
|
||||
NSUpload.updateProfileSwitch(profileSwitch);
|
||||
nsUpload.updateProfileSwitch(profileSwitch);
|
||||
} else {
|
||||
if (L.isEnabled(LTag.DATABASE))
|
||||
log.debug("JSON for profile switch doesn't exist. Ignoring: " + trJson.toString());
|
||||
|
|
|
@ -0,0 +1,68 @@
|
|||
package info.nightscout.androidaps.db;
|
||||
|
||||
import com.j256.ormlite.dao.CloseableIterator;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.sql.SQLException;
|
||||
import java.util.List;
|
||||
|
||||
import javax.inject.Inject;
|
||||
import javax.inject.Singleton;
|
||||
|
||||
import info.nightscout.androidaps.MainApp;
|
||||
import info.nightscout.androidaps.interfaces.DatabaseHelperInterface;
|
||||
|
||||
@Singleton
|
||||
public class DatabaseHelperProvider implements DatabaseHelperInterface {
|
||||
|
||||
@Inject DatabaseHelperProvider() {}
|
||||
|
||||
@NotNull @Override public List<BgReading> getAllBgreadingsDataFromTime(long mills, boolean ascending) {
|
||||
return MainApp.getDbHelper().getAllBgreadingsDataFromTime(mills, ascending);
|
||||
}
|
||||
|
||||
@Override public void createOrUpdate(@NotNull CareportalEvent careportalEvent) {
|
||||
MainApp.getDbHelper().createOrUpdate(careportalEvent);
|
||||
}
|
||||
|
||||
@Override public void createOrUpdate(@NotNull DanaRHistoryRecord record) {
|
||||
MainApp.getDbHelper().createOrUpdate(record);
|
||||
}
|
||||
|
||||
@NotNull @Override public List<DanaRHistoryRecord> getDanaRHistoryRecordsByType(byte type) {
|
||||
return MainApp.getDbHelper().getDanaRHistoryRecordsByType(type);
|
||||
}
|
||||
|
||||
@NotNull @Override public List<TDD> getTDDs() {
|
||||
return MainApp.getDbHelper().getTDDs();
|
||||
}
|
||||
|
||||
@Override public long size(@NotNull String table) {
|
||||
return MainApp.getDbHelper().size(table);
|
||||
}
|
||||
|
||||
@Override public void create(@NotNull DbRequest record) {
|
||||
try {
|
||||
MainApp.getDbHelper().create(record);
|
||||
} catch (SQLException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
@Override public void deleteAllDbRequests() {
|
||||
MainApp.getDbHelper().deleteAllDbRequests();
|
||||
}
|
||||
|
||||
@Override public int deleteDbRequest(@NotNull String id) {
|
||||
return MainApp.getDbHelper().deleteDbRequest(id);
|
||||
}
|
||||
|
||||
@Override public void deleteDbRequestbyMongoId(@NotNull String action, @NotNull String _id) {
|
||||
MainApp.getDbHelper().deleteDbRequestbyMongoId(action, _id);
|
||||
}
|
||||
|
||||
@NotNull @Override public CloseableIterator<DbRequest> getDbRequestInterator() {
|
||||
return MainApp.getDbHelper().getDbRequestInterator();
|
||||
}
|
||||
}
|
|
@ -8,13 +8,16 @@ import dagger.Provides
|
|||
import dagger.android.HasAndroidInjector
|
||||
import info.nightscout.androidaps.Config
|
||||
import info.nightscout.androidaps.MainApp
|
||||
import info.nightscout.androidaps.db.DatabaseHelperProvider
|
||||
import info.nightscout.androidaps.interfaces.*
|
||||
import info.nightscout.androidaps.logging.AAPSLogger
|
||||
import info.nightscout.androidaps.plugins.configBuilder.PluginStore
|
||||
import info.nightscout.androidaps.plugins.configBuilder.ProfileFunctionImplementation
|
||||
import info.nightscout.androidaps.plugins.general.nsclient.UploadQueue
|
||||
import info.nightscout.androidaps.plugins.treatments.TreatmentsPlugin
|
||||
import info.nightscout.androidaps.queue.CommandQueue
|
||||
import info.nightscout.androidaps.utils.FabricPrivacy
|
||||
import info.nightscout.androidaps.utils.androidNotification.NotificationHolder
|
||||
import info.nightscout.androidaps.utils.resources.ResourceHelper
|
||||
import info.nightscout.androidaps.utils.sharedPreferences.SP
|
||||
import info.nightscout.androidaps.utils.storage.FileStorage
|
||||
|
@ -61,11 +64,12 @@ open class AppModule {
|
|||
|
||||
@Binds fun bindContext(mainApp: MainApp): Context
|
||||
@Binds fun bindInjector(mainApp: MainApp): HasAndroidInjector
|
||||
@Binds fun bindDatabaseHelperInterface(mainApp: MainApp): DatabaseHelperInterface
|
||||
@Binds fun bindActivePluginProvider(pluginStore: PluginStore): ActivePluginProvider
|
||||
@Binds fun commandQueueProvider(commandQueue: CommandQueue): CommandQueueProvider
|
||||
@Binds fun configInterfaceProvider(config: Config): ConfigInterface
|
||||
@Binds fun treatmentInterfaceProvider(treatmentsPlugin: TreatmentsPlugin): TreatmentsInterface
|
||||
|
||||
@Binds fun provideDatabaseHelperInterface(databaseHelperProvider: DatabaseHelperProvider): DatabaseHelperInterface
|
||||
@Binds fun provideUploadQueueInterface(uploadQueue: UploadQueue): UploadQueueInterface
|
||||
@Binds fun provideNotificationHolderInterface(notificationHolder: NotificationHolder): NotificationHolderInterface
|
||||
}
|
||||
}
|
||||
|
|
|
@ -10,7 +10,7 @@ import info.nightscout.androidaps.plugins.aps.openAPSSMB.OpenAPSSMBFragment
|
|||
import info.nightscout.androidaps.plugins.configBuilder.ConfigBuilderFragment
|
||||
import info.nightscout.androidaps.plugins.constraints.objectives.ObjectivesFragment
|
||||
import info.nightscout.androidaps.plugins.constraints.objectives.activities.ObjectivesExamDialog
|
||||
import info.nightscout.androidaps.plugins.constraints.objectives.dialogs.NtpProgressDialog
|
||||
import info.nightscout.androidaps.dialogs.NtpProgressDialog
|
||||
import info.nightscout.androidaps.plugins.general.actions.ActionsFragment
|
||||
import info.nightscout.androidaps.plugins.general.automation.AutomationFragment
|
||||
import info.nightscout.androidaps.plugins.general.automation.dialogs.ChooseActionDialog
|
||||
|
|
|
@ -40,6 +40,7 @@ class CarbsDialog : DialogFragmentWithDate() {
|
|||
@Inject lateinit var treatmentsPlugin: TreatmentsPlugin
|
||||
@Inject lateinit var profileFunction: ProfileFunction
|
||||
@Inject lateinit var iobCobCalculatorPlugin: IobCobCalculatorPlugin
|
||||
@Inject lateinit var nsUpload: NSUpload
|
||||
@Inject lateinit var carbsGenerator: CarbsGenerator
|
||||
|
||||
companion object {
|
||||
|
@ -233,7 +234,7 @@ class CarbsDialog : DialogFragmentWithDate() {
|
|||
} else {
|
||||
aapsLogger.debug("USER ENTRY: CARBS $carbsAfterConstraints time: $time duration: $duration")
|
||||
carbsGenerator.generateCarbs(carbsAfterConstraints, time, duration, notes)
|
||||
NSUpload.uploadEvent(CareportalEvent.NOTE, DateUtil.now() - 2000, resourceHelper.gs(R.string.generated_ecarbs_note, carbsAfterConstraints, duration, timeOffset))
|
||||
nsUpload.uploadEvent(CareportalEvent.NOTE, DateUtil.now() - 2000, resourceHelper.gs(R.string.generated_ecarbs_note, carbsAfterConstraints, duration, timeOffset))
|
||||
}
|
||||
}
|
||||
}, null)
|
||||
|
|
|
@ -36,6 +36,7 @@ class CareDialog : DialogFragmentWithDate() {
|
|||
@Inject lateinit var mainApp: MainApp
|
||||
@Inject lateinit var resourceHelper: ResourceHelper
|
||||
@Inject lateinit var profileFunction: ProfileFunction
|
||||
@Inject lateinit var nsUpload: NSUpload
|
||||
@Inject lateinit var translator: Translator
|
||||
|
||||
enum class EventType {
|
||||
|
@ -197,7 +198,7 @@ class CareDialog : DialogFragmentWithDate() {
|
|||
careportalEvent.json = json.toString()
|
||||
aapsLogger.debug("USER ENTRY: CAREPORTAL ${careportalEvent.eventType} json: ${careportalEvent.json}")
|
||||
MainApp.getDbHelper().createOrUpdate(careportalEvent)
|
||||
NSUpload.uploadCareportalEntryToNS(json)
|
||||
nsUpload.uploadCareportalEntryToNS(json)
|
||||
}, null)
|
||||
}
|
||||
return true
|
||||
|
|
|
@ -40,9 +40,9 @@ class FillDialog : DialogFragmentWithDate() {
|
|||
@Inject lateinit var constraintChecker: ConstraintChecker
|
||||
@Inject lateinit var resourceHelper: ResourceHelper
|
||||
@Inject lateinit var ctx: Context
|
||||
@Inject lateinit var nsUpload: NSUpload
|
||||
@Inject lateinit var commandQueue: CommandQueueProvider
|
||||
@Inject lateinit var activePlugin: ActivePluginProvider
|
||||
@Inject lateinit var injector: HasAndroidInjector
|
||||
|
||||
override fun onSaveInstanceState(savedInstanceState: Bundle) {
|
||||
super.onSaveInstanceState(savedInstanceState)
|
||||
|
@ -124,12 +124,12 @@ class FillDialog : DialogFragmentWithDate() {
|
|||
}
|
||||
if (siteChange) {
|
||||
aapsLogger.debug("USER ENTRY: SITE CHANGE")
|
||||
generateCareportalEvent(CareportalEvent.SITECHANGE, eventTime, notes, resourceHelper, sp, injector)
|
||||
nsUpload.generateCareportalEvent(CareportalEvent.SITECHANGE, eventTime, notes)
|
||||
}
|
||||
if (insulinChange) {
|
||||
// add a second for case of both checked
|
||||
aapsLogger.debug("USER ENTRY: INSULIN CHANGE")
|
||||
generateCareportalEvent(CareportalEvent.INSULINCHANGE, eventTime + 1000, notes, resourceHelper, sp, injector)
|
||||
nsUpload.generateCareportalEvent(CareportalEvent.INSULINCHANGE, eventTime + 1000, notes)
|
||||
}
|
||||
}, null)
|
||||
}
|
||||
|
@ -162,29 +162,4 @@ class FillDialog : DialogFragmentWithDate() {
|
|||
}
|
||||
})
|
||||
}
|
||||
|
||||
companion object {
|
||||
fun generateCareportalEvent(eventType: String, time: Long, notes: String, resourceHelper: ResourceHelper, sp: SP, injector: HasAndroidInjector) {
|
||||
val careportalEvent = CareportalEvent(injector)
|
||||
careportalEvent.source = Source.USER
|
||||
careportalEvent.date = time
|
||||
careportalEvent.json = generateJson(eventType, time, notes, resourceHelper, sp).toString()
|
||||
careportalEvent.eventType = eventType
|
||||
MainApp.getDbHelper().createOrUpdate(careportalEvent)
|
||||
NSUpload.uploadEvent(eventType, time, notes)
|
||||
}
|
||||
|
||||
private fun generateJson(careportalEvent: String, time: Long, notes: String, resourceHelper: ResourceHelper, sp: SP): JSONObject {
|
||||
val data = JSONObject()
|
||||
try {
|
||||
data.put("eventType", careportalEvent)
|
||||
data.put("created_at", DateUtil.toISOString(time))
|
||||
data.put("mills", time)
|
||||
data.put("enteredBy", sp.getString("careportal_enteredby", resourceHelper.gs(R.string.app_name)))
|
||||
if (notes.isNotEmpty()) data.put("notes", notes)
|
||||
} catch (ignored: JSONException) {
|
||||
}
|
||||
return data
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -22,6 +22,7 @@ import javax.inject.Singleton;
|
|||
|
||||
import dagger.Lazy;
|
||||
import dagger.android.HasAndroidInjector;
|
||||
import info.nightscout.androidaps.BuildConfig;
|
||||
import info.nightscout.androidaps.Constants;
|
||||
import info.nightscout.androidaps.MainActivity;
|
||||
import info.nightscout.androidaps.MainApp;
|
||||
|
@ -103,7 +104,7 @@ public class LoopPlugin extends PluginBase implements LoopInterface {
|
|||
private boolean isSuperBolus;
|
||||
private boolean isDisconnected;
|
||||
|
||||
@Nullable public LastRun lastRun = null;
|
||||
@Nullable private LastRun lastRun = null;
|
||||
|
||||
@Nullable @Override public LastRun getLastRun() {
|
||||
return lastRun;
|
||||
|
@ -412,7 +413,7 @@ public class LoopPlugin extends PluginBase implements LoopInterface {
|
|||
lastRun.setLastSMBEnact(0);
|
||||
lastRun.setLastSMBRequest(0);
|
||||
|
||||
nsUpload.uploadDeviceStatus(this, iobCobCalculatorPlugin, profileFunction, activePlugin.getActivePump(), receiverStatusStore);
|
||||
nsUpload.uploadDeviceStatus(this, iobCobCalculatorPlugin, profileFunction, activePlugin.getActivePump(), receiverStatusStore, BuildConfig.VERSION_NAME + "-" + BuildConfig.BUILDVERSION);
|
||||
|
||||
if (isSuspended()) {
|
||||
getAapsLogger().debug(LTag.APS, resourceHelper.gs(R.string.loopsuspended));
|
||||
|
@ -537,7 +538,7 @@ public class LoopPlugin extends PluginBase implements LoopInterface {
|
|||
lastRun.setLastTBRRequest(lastRun.getLastAPSRun());
|
||||
lastRun.setLastTBREnact(DateUtil.now());
|
||||
lastRun.setLastOpenModeAccept(DateUtil.now());
|
||||
nsUpload.uploadDeviceStatus(lp, iobCobCalculatorPlugin, profileFunction, activePlugin.getActivePump(), receiverStatusStore);
|
||||
nsUpload.uploadDeviceStatus(lp, iobCobCalculatorPlugin, profileFunction, activePlugin.getActivePump(), receiverStatusStore, BuildConfig.VERSION_NAME + "-" + BuildConfig.BUILDVERSION);
|
||||
sp.incInt(R.string.key_ObjectivesmanualEnacts);
|
||||
}
|
||||
rxBus.send(new EventAcceptOpenLoopChange());
|
||||
|
|
|
@ -22,8 +22,8 @@ import info.nightscout.androidaps.R
|
|||
import info.nightscout.androidaps.logging.AAPSLogger
|
||||
import info.nightscout.androidaps.plugins.bus.RxBusWrapper
|
||||
import info.nightscout.androidaps.plugins.constraints.objectives.activities.ObjectivesExamDialog
|
||||
import info.nightscout.androidaps.plugins.constraints.objectives.dialogs.NtpProgressDialog
|
||||
import info.nightscout.androidaps.plugins.constraints.objectives.events.EventNtpStatus
|
||||
import info.nightscout.androidaps.dialogs.NtpProgressDialog
|
||||
import info.nightscout.androidaps.events.EventNtpStatus
|
||||
import info.nightscout.androidaps.plugins.constraints.objectives.events.EventObjectivesUpdateGui
|
||||
import info.nightscout.androidaps.plugins.constraints.objectives.objectives.Objective.ExamTask
|
||||
import info.nightscout.androidaps.receivers.ReceiverStatusStore
|
||||
|
|
|
@ -22,6 +22,7 @@ import javax.inject.Inject
|
|||
class ActionNotification(injector: HasAndroidInjector) : Action(injector) {
|
||||
@Inject lateinit var resourceHelper: ResourceHelper
|
||||
@Inject lateinit var rxBus: RxBusWrapper
|
||||
@Inject lateinit var nsUpload: NSUpload
|
||||
|
||||
var text = InputString(injector)
|
||||
|
||||
|
@ -32,7 +33,7 @@ class ActionNotification(injector: HasAndroidInjector) : Action(injector) {
|
|||
override fun doAction(callback: Callback) {
|
||||
val notification = NotificationUserMessage(text.value)
|
||||
rxBus.send(EventNewNotification(notification))
|
||||
NSUpload.uploadError(text.value)
|
||||
nsUpload.uploadError(text.value)
|
||||
rxBus.send(EventRefreshOverview("ActionNotification"))
|
||||
callback.result(PumpEnactResult(injector).success(true).comment(R.string.ok))?.run()
|
||||
}
|
||||
|
|
|
@ -78,6 +78,7 @@ public class NewNSTreatmentDialog extends DaggerDialogFragment implements View.O
|
|||
@Inject ActivePluginProvider activePlugin;
|
||||
@Inject TreatmentsPlugin treatmentsPlugin;
|
||||
@Inject HardLimits hardLimits;
|
||||
@Inject NSUpload nsUpload;
|
||||
@Inject Translator translator;
|
||||
@Inject DateUtil dateUtil;
|
||||
|
||||
|
@ -714,7 +715,7 @@ public class NewNSTreatmentDialog extends DaggerDialogFragment implements View.O
|
|||
|
||||
private void confirmNSTreatmentCreation() {
|
||||
final JSONObject data = gatherData();
|
||||
OKDialog.showConfirmation(getContext(), translator.translate(JsonHelper.safeGetString(data, "eventType", resourceHelper.gs(R.string.overview_treatment_label))), buildConfirmText(data), () -> NSUpload.createNSTreatment(data, profileStore, profileFunction, eventTime.getTime()));
|
||||
OKDialog.showConfirmation(getContext(), translator.translate(JsonHelper.safeGetString(data, "eventType", resourceHelper.gs(R.string.overview_treatment_label))), buildConfirmText(data), () -> nsUpload.createNSTreatment(data, profileStore, profileFunction, eventTime.getTime()));
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -35,6 +35,7 @@ class FoodFragment : DaggerFragment() {
|
|||
@Inject lateinit var resourceHelper: ResourceHelper
|
||||
@Inject lateinit var fabricPrivacy: FabricPrivacy
|
||||
@Inject lateinit var foodPlugin: FoodPlugin
|
||||
@Inject lateinit var nsUpload: NSUpload
|
||||
|
||||
private val disposable = CompositeDisposable()
|
||||
private lateinit var unfiltered: List<Food>
|
||||
|
@ -200,7 +201,7 @@ class FoodFragment : DaggerFragment() {
|
|||
activity?.let { activity ->
|
||||
showConfirmation(activity, resourceHelper.gs(R.string.confirmation), resourceHelper.gs(R.string.removerecord) + "\n" + food.name, DialogInterface.OnClickListener { _: DialogInterface?, _: Int ->
|
||||
if (food._id != null && food._id != "") {
|
||||
NSUpload.removeFoodFromNS(food._id)
|
||||
nsUpload.removeFoodFromNS(food._id)
|
||||
}
|
||||
foodPlugin.service?.delete(food)
|
||||
}, null)
|
||||
|
|
|
@ -33,6 +33,7 @@ public class NSClientFragment extends DaggerFragment implements View.OnClickList
|
|||
@Inject SP sp;
|
||||
@Inject ResourceHelper resourceHelper;
|
||||
@Inject RxBusWrapper rxBus;
|
||||
@Inject UploadQueue uploadQueue;
|
||||
@Inject FabricPrivacy fabricPrivacy;
|
||||
|
||||
private CompositeDisposable disposable = new CompositeDisposable();
|
||||
|
@ -119,13 +120,13 @@ public class NSClientFragment extends DaggerFragment implements View.OnClickList
|
|||
break;
|
||||
case R.id.nsclientinternal_clearqueue:
|
||||
OKDialog.showConfirmation(getContext(), resourceHelper.gs(R.string.nsclientinternal), resourceHelper.gs(R.string.clearqueueconfirm), () -> {
|
||||
UploadQueue.clearQueue();
|
||||
uploadQueue.clearQueue();
|
||||
updateGui();
|
||||
fabricPrivacy.logCustom("NSClientClearQueue");
|
||||
});
|
||||
break;
|
||||
case R.id.nsclientinternal_showqueue:
|
||||
rxBus.send(new EventNSClientNewLog("QUEUE", nsClientPlugin.queue().textList()));
|
||||
rxBus.send(new EventNSClientNewLog("QUEUE", uploadQueue.textList()));
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -154,7 +155,7 @@ public class NSClientFragment extends DaggerFragment implements View.OnClickList
|
|||
logScrollview.fullScroll(ScrollView.FOCUS_DOWN);
|
||||
}
|
||||
urlTextView.setText(nsClientPlugin.url());
|
||||
Spanned queuetext = Html.fromHtml(resourceHelper.gs(R.string.queue) + " <b>" + UploadQueue.size() + "</b>");
|
||||
Spanned queuetext = Html.fromHtml(resourceHelper.gs(R.string.queue) + " <b>" + uploadQueue.size() + "</b>");
|
||||
queueTextView.setText(queuetext);
|
||||
statusTextView.setText(nsClientPlugin.status);
|
||||
}
|
||||
|
|
|
@ -253,10 +253,6 @@ public class NSClientPlugin extends PluginBase {
|
|||
rxBus.send(new EventPreferenceChange(resourceHelper, R.string.key_nsclientinternal_paused));
|
||||
}
|
||||
|
||||
public UploadQueue queue() {
|
||||
return NSClientService.uploadQueue;
|
||||
}
|
||||
|
||||
public String url() {
|
||||
return NSClientService.nsURL;
|
||||
}
|
||||
|
|
|
@ -8,71 +8,86 @@ import com.j256.ormlite.dao.CloseableIterator;
|
|||
|
||||
import org.json.JSONException;
|
||||
import org.json.JSONObject;
|
||||
import org.slf4j.Logger;
|
||||
|
||||
import java.sql.SQLException;
|
||||
|
||||
import info.nightscout.androidaps.MainApp;
|
||||
import javax.inject.Inject;
|
||||
|
||||
import info.nightscout.androidaps.R;
|
||||
import info.nightscout.androidaps.db.DatabaseHelper;
|
||||
import info.nightscout.androidaps.db.DbRequest;
|
||||
import info.nightscout.androidaps.interfaces.DatabaseHelperInterface;
|
||||
import info.nightscout.androidaps.interfaces.UploadQueueInterface;
|
||||
import info.nightscout.androidaps.logging.L;
|
||||
import info.nightscout.androidaps.logging.AAPSLogger;
|
||||
import info.nightscout.androidaps.logging.LTag;
|
||||
import info.nightscout.androidaps.logging.StacktraceLoggerWrapper;
|
||||
import info.nightscout.androidaps.plugins.bus.RxBus;
|
||||
import info.nightscout.androidaps.plugins.bus.RxBusWrapper;
|
||||
import info.nightscout.androidaps.plugins.general.nsclient.events.EventNSClientResend;
|
||||
import info.nightscout.androidaps.plugins.general.nsclient.services.NSClientService;
|
||||
import info.nightscout.androidaps.utils.SP;
|
||||
import info.nightscout.androidaps.utils.sharedPreferences.SP;
|
||||
|
||||
/**
|
||||
* Created by mike on 21.02.2016.
|
||||
*/
|
||||
public class UploadQueue implements UploadQueueInterface {
|
||||
private static Logger log = StacktraceLoggerWrapper.getLogger(LTag.NSCLIENT);
|
||||
private final AAPSLogger aapsLogger;
|
||||
private final DatabaseHelperInterface databaseHelper;
|
||||
private final Context context;
|
||||
private final SP sp;
|
||||
private final RxBusWrapper rxBus;
|
||||
|
||||
public static String status() {
|
||||
return "QUEUE: " + MainApp.getDbHelper().size(DatabaseHelper.DATABASE_DBREQUESTS);
|
||||
@Inject
|
||||
public UploadQueue(
|
||||
AAPSLogger aapsLogger,
|
||||
DatabaseHelperInterface databaseHelper,
|
||||
Context context,
|
||||
SP sp,
|
||||
RxBusWrapper rxBus
|
||||
) {
|
||||
this.aapsLogger = aapsLogger;
|
||||
this.databaseHelper = databaseHelper;
|
||||
this.context = context;
|
||||
this.sp = sp;
|
||||
this.rxBus = rxBus;
|
||||
}
|
||||
|
||||
public static long size() {
|
||||
return MainApp.getDbHelper().size(DatabaseHelper.DATABASE_DBREQUESTS);
|
||||
public String status() {
|
||||
return "QUEUE: " + databaseHelper.size(DatabaseHelper.DATABASE_DBREQUESTS);
|
||||
}
|
||||
|
||||
private static void startService() {
|
||||
public long size() {
|
||||
return databaseHelper.size(DatabaseHelper.DATABASE_DBREQUESTS);
|
||||
}
|
||||
|
||||
private void startService() {
|
||||
if (NSClientService.handler == null) {
|
||||
Context context = MainApp.instance();
|
||||
context.startService(new Intent(context, NSClientService.class));
|
||||
SystemClock.sleep(2000);
|
||||
}
|
||||
}
|
||||
|
||||
public static void add(final DbRequest dbr) {
|
||||
if (SP.getBoolean(R.string.key_ns_noupload, false)) return;
|
||||
if (L.isEnabled(LTag.NSCLIENT))
|
||||
log.debug("Adding to queue: " + dbr.log());
|
||||
public void add(final DbRequest dbr) {
|
||||
if (sp.getBoolean(R.string.key_ns_noupload, false)) return;
|
||||
aapsLogger.debug(LTag.NSCLIENT, "Adding to queue: " + dbr.log());
|
||||
try {
|
||||
MainApp.getDbHelper().create(dbr);
|
||||
databaseHelper.create(dbr);
|
||||
} catch (Exception e) {
|
||||
log.error("Unhandled exception", e);
|
||||
aapsLogger.error("Unhandled exception", e);
|
||||
}
|
||||
RxBus.getINSTANCE().send(new EventNSClientResend("newdata"));
|
||||
rxBus.send(new EventNSClientResend("newdata"));
|
||||
}
|
||||
|
||||
static void clearQueue() {
|
||||
void clearQueue() {
|
||||
startService();
|
||||
if (NSClientService.handler != null) {
|
||||
NSClientService.handler.post(() -> {
|
||||
if (L.isEnabled(LTag.NSCLIENT))
|
||||
log.debug("ClearQueue");
|
||||
MainApp.getDbHelper().deleteAllDbRequests();
|
||||
if (L.isEnabled(LTag.NSCLIENT))
|
||||
log.debug(status());
|
||||
aapsLogger.debug(LTag.NSCLIENT, "ClearQueue");
|
||||
databaseHelper.deleteAllDbRequests();
|
||||
aapsLogger.debug(LTag.NSCLIENT, status());
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
public static void removeID(final JSONObject record) {
|
||||
public void removeID(final JSONObject record) {
|
||||
startService();
|
||||
if (NSClientService.handler != null) {
|
||||
NSClientService.handler.post(() -> {
|
||||
|
@ -83,26 +98,24 @@ public class UploadQueue implements UploadQueueInterface {
|
|||
} else {
|
||||
return;
|
||||
}
|
||||
if (MainApp.getDbHelper().deleteDbRequest(id) == 1) {
|
||||
if (L.isEnabled(LTag.NSCLIENT))
|
||||
log.debug("Removed item from UploadQueue. " + UploadQueue.status());
|
||||
if (databaseHelper.deleteDbRequest(id) == 1) {
|
||||
aapsLogger.debug(LTag.NSCLIENT, "Removed item from UploadQueue. " + status());
|
||||
}
|
||||
} catch (JSONException e) {
|
||||
log.error("Unhandled exception", e);
|
||||
aapsLogger.error("Unhandled exception", e);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
public static void removeID(final String action, final String _id) {
|
||||
public void removeID(final String action, final String _id) {
|
||||
if (_id == null || _id.equals(""))
|
||||
return;
|
||||
startService();
|
||||
if (NSClientService.handler != null) {
|
||||
NSClientService.handler.post(() -> {
|
||||
MainApp.getDbHelper().deleteDbRequestbyMongoId(action, _id);
|
||||
if (L.isEnabled(LTag.NSCLIENT))
|
||||
log.debug("Removing " + _id + " from UploadQueue. " + UploadQueue.status());
|
||||
databaseHelper.deleteDbRequestbyMongoId(action, _id);
|
||||
aapsLogger.debug(LTag.NSCLIENT, "Removing " + _id + " from UploadQueue. " + status());
|
||||
});
|
||||
}
|
||||
}
|
||||
|
@ -111,7 +124,7 @@ public class UploadQueue implements UploadQueueInterface {
|
|||
String result = "";
|
||||
CloseableIterator<DbRequest> iterator;
|
||||
try {
|
||||
iterator = MainApp.getDbHelper().getDbRequestInterator();
|
||||
iterator = databaseHelper.getDbRequestInterator();
|
||||
try {
|
||||
while (iterator.hasNext()) {
|
||||
DbRequest dbr = iterator.next();
|
||||
|
@ -124,7 +137,7 @@ public class UploadQueue implements UploadQueueInterface {
|
|||
iterator.close();
|
||||
}
|
||||
} catch (SQLException e) {
|
||||
log.error("Unhandled exception", e);
|
||||
aapsLogger.error("Unhandled exception", e);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
|
|
@ -31,15 +31,15 @@ import javax.inject.Inject;
|
|||
import dagger.android.DaggerService;
|
||||
import dagger.android.HasAndroidInjector;
|
||||
import info.nightscout.androidaps.Config;
|
||||
import info.nightscout.androidaps.MainApp;
|
||||
import info.nightscout.androidaps.R;
|
||||
import info.nightscout.androidaps.interfaces.ProfileStore;
|
||||
import info.nightscout.androidaps.db.DbRequest;
|
||||
import info.nightscout.androidaps.events.EventAppExit;
|
||||
import info.nightscout.androidaps.events.EventConfigBuilderChange;
|
||||
import info.nightscout.androidaps.events.EventNsFood;
|
||||
import info.nightscout.androidaps.events.EventPreferenceChange;
|
||||
import info.nightscout.androidaps.interfaces.DatabaseHelperInterface;
|
||||
import info.nightscout.androidaps.interfaces.PluginType;
|
||||
import info.nightscout.androidaps.interfaces.ProfileStore;
|
||||
import info.nightscout.androidaps.logging.AAPSLogger;
|
||||
import info.nightscout.androidaps.logging.L;
|
||||
import info.nightscout.androidaps.logging.LTag;
|
||||
|
@ -83,7 +83,7 @@ public class NSClientService extends DaggerService {
|
|||
@Inject AAPSLogger aapsLogger;
|
||||
@Inject NSSettingsStatus nsSettingsStatus;
|
||||
@Inject NSDeviceStatus nsDeviceStatus;
|
||||
@Inject MainApp mainApp;
|
||||
@Inject DatabaseHelperInterface databaseHelper;
|
||||
@Inject RxBusWrapper rxBus;
|
||||
@Inject ResourceHelper resourceHelper;
|
||||
@Inject SP sp;
|
||||
|
@ -91,6 +91,7 @@ public class NSClientService extends DaggerService {
|
|||
@Inject BuildHelper buildHelper;
|
||||
@Inject Config config;
|
||||
@Inject DateUtil dateUtil;
|
||||
@Inject UploadQueue uploadQueue;
|
||||
|
||||
private static Logger log = StacktraceLoggerWrapper.getLogger(LTag.NSCLIENT);
|
||||
private CompositeDisposable disposable = new CompositeDisposable();
|
||||
|
@ -124,8 +125,6 @@ public class NSClientService extends DaggerService {
|
|||
|
||||
private String nsAPIhashCode = "";
|
||||
|
||||
public static UploadQueue uploadQueue = new UploadQueue();
|
||||
|
||||
private final ArrayList<Long> reconnections = new ArrayList<>();
|
||||
private int WATCHDOG_INTERVAL_MINUTES = 2;
|
||||
private int WATCHDOG_RECONNECT_IN = 15;
|
||||
|
@ -143,7 +142,7 @@ public class NSClientService extends DaggerService {
|
|||
@Override
|
||||
public void onCreate() {
|
||||
super.onCreate();
|
||||
PowerManager powerManager = (PowerManager) mainApp.getApplicationContext().getSystemService(Context.POWER_SERVICE);
|
||||
PowerManager powerManager = (PowerManager) getSystemService(Context.POWER_SERVICE);
|
||||
mWakeLock = powerManager.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, "AndroidAPS:NSClientService");
|
||||
mWakeLock.acquire();
|
||||
|
||||
|
@ -528,7 +527,7 @@ public class NSClientService extends DaggerService {
|
|||
@Override
|
||||
public void call(final Object... args) {
|
||||
NSClientService.handler.post(() -> {
|
||||
PowerManager powerManager = (PowerManager) mainApp.getApplicationContext().getSystemService(Context.POWER_SERVICE);
|
||||
PowerManager powerManager = (PowerManager) getSystemService(Context.POWER_SERVICE);
|
||||
PowerManager.WakeLock wakeLock = powerManager.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK,
|
||||
"AndroidAPS:NSClientService_onDataUpdate");
|
||||
wakeLock.acquire();
|
||||
|
@ -604,7 +603,7 @@ public class NSClientService extends DaggerService {
|
|||
NSTreatment treatment = new NSTreatment(jsonTreatment);
|
||||
|
||||
// remove from upload queue if Ack is failing
|
||||
UploadQueue.removeID(jsonTreatment);
|
||||
uploadQueue.removeID(jsonTreatment);
|
||||
//Find latest date in treatment
|
||||
if (treatment.getMills() != null && treatment.getMills() < System.currentTimeMillis())
|
||||
if (treatment.getMills() > latestDateInReceivedData)
|
||||
|
@ -636,7 +635,7 @@ public class NSClientService extends DaggerService {
|
|||
for (Integer index = 0; index < devicestatuses.length(); index++) {
|
||||
JSONObject jsonStatus = devicestatuses.getJSONObject(index);
|
||||
// remove from upload queue if Ack is failing
|
||||
UploadQueue.removeID(jsonStatus);
|
||||
uploadQueue.removeID(jsonStatus);
|
||||
}
|
||||
nsDeviceStatus.handleNewData(devicestatuses);
|
||||
}
|
||||
|
@ -652,7 +651,7 @@ public class NSClientService extends DaggerService {
|
|||
JSONObject jsonFood = foods.getJSONObject(index);
|
||||
|
||||
// remove from upload queue if Ack is failing
|
||||
UploadQueue.removeID(jsonFood);
|
||||
uploadQueue.removeID(jsonFood);
|
||||
|
||||
String action = JsonHelper.safeGetString(jsonFood, "action");
|
||||
|
||||
|
@ -684,7 +683,7 @@ public class NSClientService extends DaggerService {
|
|||
for (Integer index = 0; index < mbgs.length(); index++) {
|
||||
JSONObject jsonMbg = mbgs.getJSONObject(index);
|
||||
// remove from upload queue if Ack is failing
|
||||
UploadQueue.removeID(jsonMbg);
|
||||
uploadQueue.removeID(jsonMbg);
|
||||
}
|
||||
handleNewMbg(mbgs, isDelta);
|
||||
}
|
||||
|
@ -695,7 +694,7 @@ public class NSClientService extends DaggerService {
|
|||
// Retreive actual calibration
|
||||
for (Integer index = 0; index < cals.length(); index++) {
|
||||
// remove from upload queue if Ack is failing
|
||||
UploadQueue.removeID(cals.optJSONObject(index));
|
||||
uploadQueue.removeID(cals.optJSONObject(index));
|
||||
}
|
||||
handleNewCal(cals, isDelta);
|
||||
}
|
||||
|
@ -709,7 +708,7 @@ public class NSClientService extends DaggerService {
|
|||
NSSgv sgv = new NSSgv(jsonSgv);
|
||||
// Handle new sgv here
|
||||
// remove from upload queue if Ack is failing
|
||||
UploadQueue.removeID(jsonSgv);
|
||||
uploadQueue.removeID(jsonSgv);
|
||||
//Find latest date in sgv
|
||||
if (sgv.getMills() != null && sgv.getMills() < System.currentTimeMillis())
|
||||
if (sgv.getMills() > latestDateInReceivedData)
|
||||
|
@ -795,7 +794,7 @@ public class NSClientService extends DaggerService {
|
|||
}
|
||||
|
||||
public void resend(final String reason) {
|
||||
if (UploadQueue.size() == 0)
|
||||
if (uploadQueue.size() == 0)
|
||||
return;
|
||||
|
||||
if (!isConnected || !hasWriteAuth) return;
|
||||
|
@ -804,8 +803,7 @@ public class NSClientService extends DaggerService {
|
|||
if (mSocket == null || !mSocket.connected()) return;
|
||||
|
||||
if (lastResendTime > System.currentTimeMillis() - 10 * 1000L) {
|
||||
if (L.isEnabled(LTag.NSCLIENT))
|
||||
log.debug("Skipping resend by lastResendTime: " + ((System.currentTimeMillis() - lastResendTime) / 1000L) + " sec");
|
||||
aapsLogger.debug(LTag.NSCLIENT, "Skipping resend by lastResendTime: " + ((System.currentTimeMillis() - lastResendTime) / 1000L) + " sec");
|
||||
return;
|
||||
}
|
||||
lastResendTime = System.currentTimeMillis();
|
||||
|
@ -815,7 +813,7 @@ public class NSClientService extends DaggerService {
|
|||
CloseableIterator<DbRequest> iterator;
|
||||
int maxcount = 30;
|
||||
try {
|
||||
iterator = mainApp.getDbHelper().getDbRequestInterator();
|
||||
iterator = databaseHelper.getDbRequestInterator();
|
||||
try {
|
||||
while (iterator.hasNext() && maxcount > 0) {
|
||||
DbRequest dbr = iterator.next();
|
||||
|
@ -852,7 +850,7 @@ public class NSClientService extends DaggerService {
|
|||
|
||||
private void handleAnnouncement(JSONObject announcement) {
|
||||
NSAlarm nsAlarm = new NSAlarm(announcement);
|
||||
Notification notification = new NotificationWithAction(mainApp, nsAlarm);
|
||||
Notification notification = new NotificationWithAction(injector, nsAlarm);
|
||||
rxBus.send(new EventNewNotification(notification));
|
||||
rxBus.send(new EventNSClientNewLog("ANNOUNCEMENT", JsonHelper.safeGetString(announcement, "message", "received")));
|
||||
aapsLogger.debug(LTag.NSCLIENT, announcement.toString());
|
||||
|
@ -862,7 +860,7 @@ public class NSClientService extends DaggerService {
|
|||
long snoozedTo = sp.getLong(R.string.key_snoozedTo, 0L);
|
||||
if (snoozedTo == 0L || System.currentTimeMillis() > snoozedTo) {
|
||||
NSAlarm nsAlarm = new NSAlarm(alarm);
|
||||
Notification notification = new NotificationWithAction(mainApp, nsAlarm);
|
||||
Notification notification = new NotificationWithAction(injector, nsAlarm);
|
||||
rxBus.send(new EventNewNotification(notification));
|
||||
}
|
||||
rxBus.send(new EventNSClientNewLog("ALARM", JsonHelper.safeGetString(alarm, "message", "received")));
|
||||
|
@ -873,7 +871,7 @@ public class NSClientService extends DaggerService {
|
|||
long snoozedTo = sp.getLong(R.string.key_snoozedTo, 0L);
|
||||
if (snoozedTo == 0L || System.currentTimeMillis() > snoozedTo) {
|
||||
NSAlarm nsAlarm = new NSAlarm(alarm);
|
||||
Notification notification = new NotificationWithAction(mainApp, nsAlarm);
|
||||
Notification notification = new NotificationWithAction(injector, nsAlarm);
|
||||
rxBus.send(new EventNewNotification(notification));
|
||||
}
|
||||
rxBus.send(new EventNSClientNewLog("URGENTALARM", JsonHelper.safeGetString(alarm, "message", "received")));
|
||||
|
@ -887,7 +885,7 @@ public class NSClientService extends DaggerService {
|
|||
Intent intent = new Intent(Intents.ACTION_NEW_CAL);
|
||||
intent.putExtras(bundle);
|
||||
intent.addFlags(Intent.FLAG_INCLUDE_STOPPED_PACKAGES);
|
||||
LocalBroadcastManager.getInstance(mainApp).sendBroadcast(intent);
|
||||
LocalBroadcastManager.getInstance(this).sendBroadcast(intent);
|
||||
}
|
||||
|
||||
public void handleNewMbg(JSONArray mbgs, boolean isDelta) {
|
||||
|
@ -897,7 +895,7 @@ public class NSClientService extends DaggerService {
|
|||
Intent intent = new Intent(Intents.ACTION_NEW_MBG);
|
||||
intent.putExtras(bundle);
|
||||
intent.addFlags(Intent.FLAG_INCLUDE_STOPPED_PACKAGES);
|
||||
LocalBroadcastManager.getInstance(mainApp).sendBroadcast(intent);
|
||||
LocalBroadcastManager.getInstance(this).sendBroadcast(intent);
|
||||
}
|
||||
|
||||
public void handleNewProfile(ProfileStore profile, boolean isDelta) {
|
||||
|
@ -907,7 +905,7 @@ public class NSClientService extends DaggerService {
|
|||
Intent intent = new Intent(Intents.ACTION_NEW_PROFILE);
|
||||
intent.putExtras(bundle);
|
||||
intent.addFlags(Intent.FLAG_INCLUDE_STOPPED_PACKAGES);
|
||||
LocalBroadcastManager.getInstance(mainApp).sendBroadcast(intent);
|
||||
LocalBroadcastManager.getInstance(this).sendBroadcast(intent);
|
||||
|
||||
if (sp.getBoolean(R.string.key_nsclient_localbroadcasts, false)) {
|
||||
bundle = new Bundle();
|
||||
|
@ -916,7 +914,7 @@ public class NSClientService extends DaggerService {
|
|||
intent = new Intent(Intents.ACTION_NEW_PROFILE);
|
||||
intent.putExtras(bundle);
|
||||
intent.addFlags(Intent.FLAG_INCLUDE_STOPPED_PACKAGES);
|
||||
mainApp.sendBroadcast(intent);
|
||||
this.sendBroadcast(intent);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -929,7 +927,7 @@ public class NSClientService extends DaggerService {
|
|||
Intent intent = new Intent(Intents.ACTION_NEW_SGV);
|
||||
intent.putExtras(bundle);
|
||||
intent.addFlags(Intent.FLAG_INCLUDE_STOPPED_PACKAGES);
|
||||
LocalBroadcastManager.getInstance(mainApp).sendBroadcast(intent);
|
||||
LocalBroadcastManager.getInstance(this).sendBroadcast(intent);
|
||||
}
|
||||
|
||||
if (sp.getBoolean(R.string.key_nsclient_localbroadcasts, false)) {
|
||||
|
@ -940,7 +938,7 @@ public class NSClientService extends DaggerService {
|
|||
Intent intent = new Intent(Intents.ACTION_NEW_SGV);
|
||||
intent.putExtras(bundle);
|
||||
intent.addFlags(Intent.FLAG_INCLUDE_STOPPED_PACKAGES);
|
||||
mainApp.sendBroadcast(intent);
|
||||
this.sendBroadcast(intent);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -954,7 +952,7 @@ public class NSClientService extends DaggerService {
|
|||
Intent intent = new Intent(Intents.ACTION_NEW_TREATMENT);
|
||||
intent.putExtras(bundle);
|
||||
intent.addFlags(Intent.FLAG_INCLUDE_STOPPED_PACKAGES);
|
||||
LocalBroadcastManager.getInstance(mainApp).sendBroadcast(intent);
|
||||
LocalBroadcastManager.getInstance(this).sendBroadcast(intent);
|
||||
}
|
||||
|
||||
if (sp.getBoolean(R.string.key_nsclient_localbroadcasts, false)) {
|
||||
|
@ -966,7 +964,7 @@ public class NSClientService extends DaggerService {
|
|||
Intent intent = new Intent(Intents.ACTION_NEW_TREATMENT);
|
||||
intent.putExtras(bundle);
|
||||
intent.addFlags(Intent.FLAG_INCLUDE_STOPPED_PACKAGES);
|
||||
mainApp.getApplicationContext().sendBroadcast(intent);
|
||||
this.getApplicationContext().sendBroadcast(intent);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -980,7 +978,7 @@ public class NSClientService extends DaggerService {
|
|||
Intent intent = new Intent(Intents.ACTION_CHANGED_TREATMENT);
|
||||
intent.putExtras(bundle);
|
||||
intent.addFlags(Intent.FLAG_INCLUDE_STOPPED_PACKAGES);
|
||||
LocalBroadcastManager.getInstance(mainApp).sendBroadcast(intent);
|
||||
LocalBroadcastManager.getInstance(this).sendBroadcast(intent);
|
||||
}
|
||||
|
||||
if (sp.getBoolean(R.string.key_nsclient_localbroadcasts, false)) {
|
||||
|
@ -992,7 +990,7 @@ public class NSClientService extends DaggerService {
|
|||
Intent intent = new Intent(Intents.ACTION_CHANGED_TREATMENT);
|
||||
intent.putExtras(bundle);
|
||||
intent.addFlags(Intent.FLAG_INCLUDE_STOPPED_PACKAGES);
|
||||
mainApp.getApplicationContext().sendBroadcast(intent);
|
||||
this.getApplicationContext().sendBroadcast(intent);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1004,7 +1002,7 @@ public class NSClientService extends DaggerService {
|
|||
Intent intent = new Intent(Intents.ACTION_REMOVED_TREATMENT);
|
||||
intent.putExtras(bundle);
|
||||
intent.addFlags(Intent.FLAG_INCLUDE_STOPPED_PACKAGES);
|
||||
LocalBroadcastManager.getInstance(mainApp).sendBroadcast(intent);
|
||||
LocalBroadcastManager.getInstance(this).sendBroadcast(intent);
|
||||
|
||||
|
||||
if (sp.getBoolean(R.string.key_nsclient_localbroadcasts, false)) {
|
||||
|
@ -1014,7 +1012,7 @@ public class NSClientService extends DaggerService {
|
|||
intent = new Intent(Intents.ACTION_REMOVED_TREATMENT);
|
||||
intent.putExtras(bundle);
|
||||
intent.addFlags(Intent.FLAG_INCLUDE_STOPPED_PACKAGES);
|
||||
mainApp.getApplicationContext().sendBroadcast(intent);
|
||||
this.getApplicationContext().sendBroadcast(intent);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -20,6 +20,7 @@ import android.view.View.OnLongClickListener
|
|||
import android.view.ViewGroup
|
||||
import android.widget.LinearLayout
|
||||
import android.widget.TextView
|
||||
import androidx.core.text.toSpanned
|
||||
import androidx.recyclerview.widget.LinearLayoutManager
|
||||
import com.jjoe64.graphview.GraphView
|
||||
import dagger.android.HasAndroidInjector
|
||||
|
@ -344,8 +345,9 @@ class OverviewFragment : DaggerFragment(), View.OnClickListener, OnLongClickList
|
|||
if (loopPlugin.isEnabled(PluginType.LOOP)) {
|
||||
val lastRun = loopPlugin.lastRun
|
||||
loopPlugin.invoke("Accept temp button", false)
|
||||
if (lastRun?.lastAPSRun != null && lastRun.constraintsProcessed.isChangeRequested) {
|
||||
OKDialog.showConfirmation(activity, resourceHelper.gs(R.string.pump_tempbasal_label), lastRun.constraintsProcessed.toSpanned(), Runnable {
|
||||
if (lastRun?.lastAPSRun != null && lastRun.constraintsProcessed?.isChangeRequested == true) {
|
||||
OKDialog.showConfirmation(activity, resourceHelper.gs(R.string.pump_tempbasal_label), lastRun.constraintsProcessed?.toSpanned()
|
||||
?: "".toSpanned(), Runnable {
|
||||
aapsLogger.debug("USER ENTRY: ACCEPT TEMP BASAL")
|
||||
overview_accepttempbutton?.visibility = View.GONE
|
||||
(context?.getSystemService(Context.NOTIFICATION_SERVICE) as NotificationManager).cancel(Constants.notificationID)
|
||||
|
@ -442,7 +444,7 @@ class OverviewFragment : DaggerFragment(), View.OnClickListener, OnLongClickList
|
|||
val showAcceptButton = !closedLoopEnabled.value() && // Open mode needed
|
||||
lastRun != null &&
|
||||
(lastRun.lastOpenModeAccept == 0L || lastRun.lastOpenModeAccept < lastRun.lastAPSRun) &&// never accepted or before last result
|
||||
lastRun.constraintsProcessed.isChangeRequested // change is requested
|
||||
lastRun.constraintsProcessed?.isChangeRequested == true // change is requested
|
||||
|
||||
if (showAcceptButton && pump.isInitialized && !pump.isSuspended && loopPlugin.isEnabled(PluginType.LOOP)) {
|
||||
overview_accepttempbutton?.visibility = View.VISIBLE
|
||||
|
|
|
@ -16,10 +16,10 @@ import info.nightscout.androidaps.data.IobTotal
|
|||
import info.nightscout.androidaps.data.Profile
|
||||
import info.nightscout.androidaps.db.BgReading
|
||||
import info.nightscout.androidaps.interfaces.ActivePluginProvider
|
||||
import info.nightscout.androidaps.interfaces.LoopInterface
|
||||
import info.nightscout.androidaps.interfaces.TreatmentsInterface
|
||||
import info.nightscout.androidaps.logging.AAPSLogger
|
||||
import info.nightscout.androidaps.logging.LTag
|
||||
import info.nightscout.androidaps.plugins.aps.loop.LoopPlugin.LastRun
|
||||
import info.nightscout.androidaps.plugins.aps.openAPSSMB.SMBDefaults
|
||||
import info.nightscout.androidaps.interfaces.ProfileFunction
|
||||
import info.nightscout.androidaps.plugins.general.overview.graphExtensions.*
|
||||
|
@ -197,7 +197,7 @@ class GraphData(injector: HasAndroidInjector, private val graph: GraphView, priv
|
|||
basalScale.setMultiplier(maxY * scale / maxBasalValueFound)
|
||||
}
|
||||
|
||||
fun addTargetLine(fromTime: Long, toTimeParam: Long, profile: Profile, lastRun: LastRun?) {
|
||||
fun addTargetLine(fromTime: Long, toTimeParam: Long, profile: Profile, lastRun: LoopInterface.LastRun?) {
|
||||
var toTime = toTimeParam
|
||||
val targetsSeriesArray: MutableList<DataPoint> = ArrayList()
|
||||
var lastTarget = -1.0
|
||||
|
|
|
@ -104,7 +104,7 @@ class WearPlugin @Inject constructor(
|
|||
.observeOn(Schedulers.io())
|
||||
.subscribe({ event: EventDismissBolusProgressIfRunning ->
|
||||
if (event.result == null) return@subscribe
|
||||
val status: String = if (event.result.success) {
|
||||
val status: String = if (event.result!!.success) {
|
||||
resourceHelper.gs(R.string.success)
|
||||
} else {
|
||||
resourceHelper.gs(R.string.nosuccess)
|
||||
|
|
|
@ -531,9 +531,9 @@ public class WatchUpdaterService extends WearableListenerService implements Goog
|
|||
|
||||
}
|
||||
|
||||
final LoopPlugin.LastRun finalLastRun = loopPlugin.lastRun;
|
||||
if (sp.getBoolean("wear_predictions", true) && finalLastRun != null && finalLastRun.request.hasPredictions && finalLastRun.constraintsProcessed != null) {
|
||||
List<BgReading> predArray = finalLastRun.constraintsProcessed.getPredictions();
|
||||
final LoopPlugin.LastRun finalLastRun = loopPlugin.getLastRun();
|
||||
if (sp.getBoolean("wear_predictions", true) && finalLastRun != null && finalLastRun.getRequest().hasPredictions && finalLastRun.getConstraintsProcessed() != null) {
|
||||
List<BgReading> predArray = finalLastRun.getConstraintsProcessed().getPredictions();
|
||||
|
||||
if (!predArray.isEmpty()) {
|
||||
for (BgReading bg : predArray) {
|
||||
|
@ -715,7 +715,7 @@ public class WatchUpdaterService extends WearableListenerService implements Goog
|
|||
//OpenAPS status
|
||||
if (config.getAPS()) {
|
||||
//we are AndroidAPS
|
||||
openApsStatus = loopPlugin.lastRun != null && loopPlugin.lastRun.lastTBREnact != 0 ? loopPlugin.lastRun.lastTBREnact : -1;
|
||||
openApsStatus = loopPlugin.getLastRun() != null && loopPlugin.getLastRun().getLastTBREnact() != 0 ? loopPlugin.getLastRun().getLastTBREnact() : -1;
|
||||
} else {
|
||||
//NSClient or remote
|
||||
openApsStatus = NSDeviceStatus.getOpenApsTimestamp();
|
||||
|
|
|
@ -37,7 +37,8 @@ class LocalProfilePlugin @Inject constructor(
|
|||
private val rxBus: RxBusWrapper,
|
||||
resourceHelper: ResourceHelper,
|
||||
private val sp: SP,
|
||||
private val profileFunction: ProfileFunction
|
||||
private val profileFunction: ProfileFunction,
|
||||
private val nsUpload: NSUpload
|
||||
) : PluginBase(PluginDescription()
|
||||
.mainType(PluginType.PROFILE)
|
||||
.fragmentClass(LocalProfileFragment::class.java.name)
|
||||
|
@ -140,7 +141,7 @@ class LocalProfilePlugin @Inject constructor(
|
|||
if (name.contains(".")) namesOK = false
|
||||
}
|
||||
if (namesOK)
|
||||
rawProfile?.let { NSUpload.uploadProfileStore(it.data) }
|
||||
rawProfile?.let { nsUpload.uploadProfileStore(it.data) }
|
||||
else
|
||||
activity?.let {
|
||||
OKDialog.show(it, "", resourceHelper.gs(R.string.profilenamecontainsdot))
|
||||
|
|
|
@ -1259,7 +1259,7 @@ public class ComboPlugin extends PumpPluginBase implements PumpInterface, Constr
|
|||
}
|
||||
|
||||
@NonNull @Override
|
||||
public JSONObject getJSONStatus(Profile profile, String profileName) {
|
||||
public JSONObject getJSONStatus(Profile profile, String profileName, String version) {
|
||||
if (!pump.initialized) {
|
||||
return null;
|
||||
}
|
||||
|
@ -1281,7 +1281,7 @@ public class ComboPlugin extends PumpPluginBase implements PumpInterface, Constr
|
|||
pumpJson.put("status", statusJson);
|
||||
|
||||
JSONObject extendedJson = new JSONObject();
|
||||
extendedJson.put("Version", BuildConfig.VERSION_NAME + "-" + BuildConfig.BUILDVERSION);
|
||||
extendedJson.put("Version", version);
|
||||
extendedJson.put("ActiveProfile", profileFunction.getProfileName());
|
||||
PumpState ps = pump.state;
|
||||
if (ps.tbrActive) {
|
||||
|
|
|
@ -324,7 +324,7 @@ public abstract class PumpPluginAbstract extends PumpPluginBase implements PumpI
|
|||
|
||||
|
||||
@NonNull @Override
|
||||
public JSONObject getJSONStatus(Profile profile, String profileName) {
|
||||
public JSONObject getJSONStatus(Profile profile, String profileName, String version) {
|
||||
|
||||
if ((getPumpStatusData().lastConnection + 5 * 60 * 1000L) < System.currentTimeMillis()) {
|
||||
return new JSONObject();
|
||||
|
@ -337,7 +337,7 @@ public abstract class PumpPluginAbstract extends PumpPluginBase implements PumpI
|
|||
try {
|
||||
battery.put("percent", getPumpStatusData().batteryRemaining);
|
||||
status.put("status", getPumpStatusData().pumpStatusType != null ? getPumpStatusData().pumpStatusType.getStatus() : "normal");
|
||||
extended.put("Version", BuildConfig.VERSION_NAME + "-" + BuildConfig.BUILDVERSION);
|
||||
extended.put("Version", version);
|
||||
try {
|
||||
extended.put("ActiveProfile", profileName);
|
||||
} catch (Exception ignored) {
|
||||
|
|
|
@ -366,7 +366,7 @@ public abstract class AbstractDanaRPlugin extends PumpPluginBase implements Pump
|
|||
}
|
||||
|
||||
@NonNull @Override
|
||||
public JSONObject getJSONStatus(Profile profile, String profilename) {
|
||||
public JSONObject getJSONStatus(Profile profile, String profilename, String version) {
|
||||
DanaRPump pump = danaRPump;
|
||||
long now = System.currentTimeMillis();
|
||||
if (pump.getLastConnection() + 5 * 60 * 1000L < System.currentTimeMillis()) {
|
||||
|
@ -380,7 +380,7 @@ public abstract class AbstractDanaRPlugin extends PumpPluginBase implements Pump
|
|||
battery.put("percent", pump.getBatteryRemaining());
|
||||
status.put("status", pump.getPumpSuspended() ? "suspended" : "normal");
|
||||
status.put("timestamp", DateUtil.toISOString(pump.getLastConnection()));
|
||||
extended.put("Version", BuildConfig.VERSION_NAME + "-" + BuildConfig.BUILDVERSION);
|
||||
extended.put("Version", version);
|
||||
if (pump.getLastBolusTime() != 0) {
|
||||
extended.put("LastBolus", dateUtil.dateAndTimeString(pump.getLastBolusTime()));
|
||||
extended.put("LastBolusAmount", pump.getLastBolusAmount());
|
||||
|
|
|
@ -7,6 +7,7 @@ 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.ConstraintChecker
|
||||
import info.nightscout.androidaps.plugins.general.nsclient.NSUpload
|
||||
import info.nightscout.androidaps.plugins.pump.danaR.DanaRPlugin
|
||||
import info.nightscout.androidaps.plugins.pump.danaR.DanaRPump
|
||||
import info.nightscout.androidaps.plugins.pump.danaRKorean.DanaRKoreanPlugin
|
||||
|
@ -28,6 +29,7 @@ class MessageHashTableR @Inject constructor(
|
|||
configBuilderPlugin: ConfigBuilderPlugin,
|
||||
commandQueue: CommandQueueProvider,
|
||||
activePlugin: ActivePluginProvider,
|
||||
nsUpload: NSUpload,
|
||||
injector: HasAndroidInjector,
|
||||
dateUtil: DateUtil
|
||||
) : MessageHashTableBase {
|
||||
|
@ -54,7 +56,7 @@ class MessageHashTableR @Inject constructor(
|
|||
put(MsgSetTempBasalStop(aapsLogger)) // 0x0403 CMD_PUMPSET_EXERCISE_STOP
|
||||
put(MsgSetExtendedBolusStop(aapsLogger)) // 0x0406 CMD_PUMPSET_EXPANS_INS_STOP
|
||||
put(MsgSetExtendedBolusStart(aapsLogger, constraintChecker, 0.0, 0)) // 0x0407 CMD_PUMPSET_EXPANS_INS_S
|
||||
put(MsgError(aapsLogger, rxBus, resourceHelper, danaRPump)) // 0x0601 CMD_PUMPOWAY_SYSTEM_STATUS
|
||||
put(MsgError(aapsLogger, rxBus, resourceHelper, danaRPump, nsUpload)) // 0x0601 CMD_PUMPOWAY_SYSTEM_STATUS
|
||||
put(MsgPCCommStart(aapsLogger)) // 0x3001 CMD_CONNECT
|
||||
put(MsgPCCommStop(aapsLogger)) // 0x3002 CMD_DISCONNECT
|
||||
put(MsgHistoryBolus(aapsLogger, rxBus, dateUtil)) // 0x3101 CMD_HISTORY_MEAL_INS
|
||||
|
|
|
@ -13,7 +13,8 @@ class MsgError(
|
|||
private val aapsLogger: AAPSLogger,
|
||||
private val rxBus: RxBusWrapper,
|
||||
private val resourceHelper: ResourceHelper,
|
||||
private val danaRPump: DanaRPump
|
||||
private val danaRPump: DanaRPump,
|
||||
private val nsUpload: NSUpload
|
||||
) : MessageBase() {
|
||||
|
||||
init {
|
||||
|
@ -41,6 +42,6 @@ class MsgError(
|
|||
failed = false
|
||||
}
|
||||
aapsLogger.debug(LTag.PUMPCOMM, "Error detected: $errorString")
|
||||
NSUpload.uploadError(errorString)
|
||||
nsUpload.uploadError(errorString)
|
||||
}
|
||||
}
|
|
@ -5,7 +5,7 @@ import info.nightscout.androidaps.db.DanaRHistoryRecord
|
|||
import info.nightscout.androidaps.logging.AAPSLogger
|
||||
import info.nightscout.androidaps.logging.LTag
|
||||
import info.nightscout.androidaps.plugins.bus.RxBusWrapper
|
||||
import info.nightscout.androidaps.plugins.pump.danaR.events.EventDanaRSyncStatus
|
||||
import info.nightscout.androidaps.events.EventDanaRSyncStatus
|
||||
import info.nightscout.androidaps.utils.DateUtil
|
||||
|
||||
open class MsgHistoryAll(
|
||||
|
|
|
@ -83,6 +83,7 @@ public class DanaRExecutionService extends AbstractDanaRExecutionService {
|
|||
@Inject MessageHashTableR messageHashTableR;
|
||||
@Inject ActivePluginProvider activePlugin;
|
||||
@Inject ProfileFunction profileFunction;
|
||||
@Inject NSUpload nsUpload;
|
||||
@Inject SP sp;
|
||||
@Inject HasAndroidInjector injector;
|
||||
|
||||
|
@ -214,7 +215,7 @@ public class DanaRExecutionService extends AbstractDanaRExecutionService {
|
|||
if (System.currentTimeMillis() > lastApproachingDailyLimit + 30 * 60 * 1000) {
|
||||
Notification reportFail = new Notification(Notification.APPROACHING_DAILY_LIMIT, resourceHelper.gs(R.string.approachingdailylimit), Notification.URGENT);
|
||||
rxBus.send(new EventNewNotification(reportFail));
|
||||
NSUpload.uploadError(resourceHelper.gs(R.string.approachingdailylimit) + ": " + danaRPump.getDailyTotalUnits() + "/" + danaRPump.getMaxDailyTotalUnits() + "U");
|
||||
nsUpload.uploadError(resourceHelper.gs(R.string.approachingdailylimit) + ": " + danaRPump.getDailyTotalUnits() + "/" + danaRPump.getMaxDailyTotalUnits() + "U");
|
||||
lastApproachingDailyLimit = System.currentTimeMillis();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -7,6 +7,7 @@ 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.ConstraintChecker
|
||||
import info.nightscout.androidaps.plugins.general.nsclient.NSUpload
|
||||
import info.nightscout.androidaps.plugins.pump.danaR.DanaRPlugin
|
||||
import info.nightscout.androidaps.plugins.pump.danaR.DanaRPump
|
||||
import info.nightscout.androidaps.plugins.pump.danaR.comm.*
|
||||
|
@ -30,6 +31,7 @@ class MessageHashTableRKorean @Inject constructor(
|
|||
commandQueue: CommandQueueProvider,
|
||||
activePlugin: ActivePluginProvider,
|
||||
dateUtil: DateUtil,
|
||||
nsUpload: NSUpload,
|
||||
injector: HasAndroidInjector
|
||||
) : MessageHashTableBase {
|
||||
|
||||
|
@ -52,7 +54,7 @@ class MessageHashTableRKorean @Inject constructor(
|
|||
put(MsgSetTempBasalStop(aapsLogger)) // 0x0403 CMD_PUMPSET_EXERCISE_STOP
|
||||
put(MsgSetExtendedBolusStop(aapsLogger)) // 0x0406 CMD_PUMPSET_EXPANS_INS_STOP
|
||||
put(MsgSetExtendedBolusStart(aapsLogger, constraintChecker, 0.0, 0)) // 0x0407 CMD_PUMPSET_EXPANS_INS_S
|
||||
put(MsgError(aapsLogger, rxBus, resourceHelper, danaRPump)) // 0x0601 CMD_PUMPOWAY_SYSTEM_STATUS
|
||||
put(MsgError(aapsLogger, rxBus, resourceHelper, danaRPump, nsUpload)) // 0x0601 CMD_PUMPOWAY_SYSTEM_STATUS
|
||||
put(MsgPCCommStart(aapsLogger)) // 0x3001 CMD_CONNECT
|
||||
put(MsgPCCommStop(aapsLogger)) // 0x3002 CMD_DISCONNECT
|
||||
put(MsgHistoryBolus(aapsLogger, rxBus, dateUtil)) // 0x3101 CMD_HISTORY_MEAL_INS
|
||||
|
|
|
@ -75,6 +75,7 @@ public class DanaRKoreanExecutionService extends AbstractDanaRExecutionService {
|
|||
@Inject MessageHashTableRKorean messageHashTableRKorean;
|
||||
@Inject ActivePluginProvider activePlugin;
|
||||
@Inject ProfileFunction profileFunction;
|
||||
@Inject NSUpload nsUpload;
|
||||
@Inject DateUtil dateUtil;
|
||||
|
||||
public DanaRKoreanExecutionService() {
|
||||
|
@ -203,7 +204,7 @@ public class DanaRKoreanExecutionService extends AbstractDanaRExecutionService {
|
|||
if (System.currentTimeMillis() > lastApproachingDailyLimit + 30 * 60 * 1000) {
|
||||
Notification reportFail = new Notification(Notification.APPROACHING_DAILY_LIMIT, resourceHelper.gs(R.string.approachingdailylimit), Notification.URGENT);
|
||||
rxBus.send(new EventNewNotification(reportFail));
|
||||
NSUpload.uploadError(resourceHelper.gs(R.string.approachingdailylimit) + ": " + danaRPump.getDailyTotalUnits() + "/" + danaRPump.getMaxDailyTotalUnits() + "U");
|
||||
nsUpload.uploadError(resourceHelper.gs(R.string.approachingdailylimit) + ": " + danaRPump.getDailyTotalUnits() + "/" + danaRPump.getMaxDailyTotalUnits() + "U");
|
||||
lastApproachingDailyLimit = System.currentTimeMillis();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -7,6 +7,7 @@ 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.ConstraintChecker
|
||||
import info.nightscout.androidaps.plugins.general.nsclient.NSUpload
|
||||
import info.nightscout.androidaps.plugins.pump.common.bolusInfo.DetailedBolusInfoStorage
|
||||
import info.nightscout.androidaps.plugins.pump.danaR.DanaRPlugin
|
||||
import info.nightscout.androidaps.plugins.pump.danaR.DanaRPump
|
||||
|
@ -35,6 +36,7 @@ class MessageHashTableRv2 @Inject constructor(
|
|||
activePlugin: ActivePluginProvider,
|
||||
detailedBolusInfoStorage: DetailedBolusInfoStorage,
|
||||
treatmentsPlugin: TreatmentsPlugin,
|
||||
nsUpload: NSUpload,
|
||||
injector: HasAndroidInjector,
|
||||
dateUtil: DateUtil
|
||||
) : MessageHashTableBase {
|
||||
|
@ -60,7 +62,7 @@ class MessageHashTableRv2 @Inject constructor(
|
|||
put(MsgSetTempBasalStop(aapsLogger)) // 0x0403 CMD_PUMPSET_EXERCISE_STOP
|
||||
put(MsgSetExtendedBolusStop(aapsLogger)) // 0x0406 CMD_PUMPSET_EXPANS_INS_STOP
|
||||
put(MsgSetExtendedBolusStart(aapsLogger, constraintChecker, 0.0, 0)) // 0x0407 CMD_PUMPSET_EXPANS_INS_S
|
||||
put(MsgError(aapsLogger, rxBus, resourceHelper, danaRPump)) // 0x0601 CMD_PUMPOWAY_SYSTEM_STATUS
|
||||
put(MsgError(aapsLogger, rxBus, resourceHelper, danaRPump, nsUpload)) // 0x0601 CMD_PUMPOWAY_SYSTEM_STATUS
|
||||
put(MsgPCCommStart(aapsLogger)) // 0x3001 CMD_CONNECT
|
||||
put(MsgPCCommStop(aapsLogger)) // 0x3002 CMD_DISCONNECT
|
||||
put(MsgHistoryBolus(aapsLogger, rxBus, dateUtil)) // 0x3101 CMD_HISTORY_MEAL_INS
|
||||
|
|
|
@ -99,6 +99,7 @@ public class DanaRv2ExecutionService extends AbstractDanaRExecutionService {
|
|||
@Inject DetailedBolusInfoStorage detailedBolusInfoStorage;
|
||||
@Inject TreatmentsPlugin treatmentsPlugin;
|
||||
@Inject ProfileFunction profileFunction;
|
||||
@Inject NSUpload nsUpload;
|
||||
@Inject SP sp;
|
||||
@Inject DateUtil dateUtil;
|
||||
|
||||
|
@ -255,7 +256,7 @@ public class DanaRv2ExecutionService extends AbstractDanaRExecutionService {
|
|||
if (System.currentTimeMillis() > lastApproachingDailyLimit + 30 * 60 * 1000) {
|
||||
Notification reportFail = new Notification(Notification.APPROACHING_DAILY_LIMIT, resourceHelper.gs(R.string.approachingdailylimit), Notification.URGENT);
|
||||
rxBus.send(new EventNewNotification(reportFail));
|
||||
NSUpload.uploadError(resourceHelper.gs(R.string.approachingdailylimit) + ": " + danaRPump.getDailyTotalUnits() + "/" + danaRPump.getMaxDailyTotalUnits() + "U");
|
||||
nsUpload.uploadError(resourceHelper.gs(R.string.approachingdailylimit) + ": " + danaRPump.getDailyTotalUnits() + "/" + danaRPump.getMaxDailyTotalUnits() + "U");
|
||||
lastApproachingDailyLimit = System.currentTimeMillis();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -27,7 +27,6 @@ import javax.inject.Inject;
|
|||
import javax.inject.Singleton;
|
||||
|
||||
import dagger.android.HasAndroidInjector;
|
||||
import info.nightscout.androidaps.BuildConfig;
|
||||
import info.nightscout.androidaps.Config;
|
||||
import info.nightscout.androidaps.MainApp;
|
||||
import info.nightscout.androidaps.R;
|
||||
|
@ -39,6 +38,7 @@ import info.nightscout.androidaps.db.ExtendedBolus;
|
|||
import info.nightscout.androidaps.db.Source;
|
||||
import info.nightscout.androidaps.db.TDD;
|
||||
import info.nightscout.androidaps.db.TemporaryBasal;
|
||||
import info.nightscout.androidaps.db.Treatment;
|
||||
import info.nightscout.androidaps.events.EventInitializationChanged;
|
||||
import info.nightscout.androidaps.events.EventRefreshOverview;
|
||||
import info.nightscout.androidaps.interfaces.CommandQueueProvider;
|
||||
|
@ -46,6 +46,7 @@ import info.nightscout.androidaps.interfaces.Constraint;
|
|||
import info.nightscout.androidaps.interfaces.ConstraintsInterface;
|
||||
import info.nightscout.androidaps.interfaces.PluginDescription;
|
||||
import info.nightscout.androidaps.interfaces.PluginType;
|
||||
import info.nightscout.androidaps.interfaces.ProfileFunction;
|
||||
import info.nightscout.androidaps.interfaces.PumpDescription;
|
||||
import info.nightscout.androidaps.interfaces.PumpInterface;
|
||||
import info.nightscout.androidaps.interfaces.PumpPluginBase;
|
||||
|
@ -53,7 +54,6 @@ import info.nightscout.androidaps.logging.AAPSLogger;
|
|||
import info.nightscout.androidaps.logging.LTag;
|
||||
import info.nightscout.androidaps.plugins.bus.RxBusWrapper;
|
||||
import info.nightscout.androidaps.plugins.common.ManufacturerType;
|
||||
import info.nightscout.androidaps.interfaces.ProfileFunction;
|
||||
import info.nightscout.androidaps.plugins.general.actions.defs.CustomAction;
|
||||
import info.nightscout.androidaps.plugins.general.actions.defs.CustomActionType;
|
||||
import info.nightscout.androidaps.plugins.general.nsclient.NSUpload;
|
||||
|
@ -132,7 +132,6 @@ import info.nightscout.androidaps.plugins.pump.insight.exceptions.app_layer_erro
|
|||
import info.nightscout.androidaps.plugins.pump.insight.exceptions.app_layer_errors.NoActiveTBRToCanceLException;
|
||||
import info.nightscout.androidaps.plugins.pump.insight.utils.ExceptionTranslator;
|
||||
import info.nightscout.androidaps.plugins.pump.insight.utils.ParameterBlockUtil;
|
||||
import info.nightscout.androidaps.db.Treatment;
|
||||
import info.nightscout.androidaps.plugins.treatments.TreatmentsPlugin;
|
||||
import info.nightscout.androidaps.utils.DateUtil;
|
||||
import info.nightscout.androidaps.utils.TimeChangeType;
|
||||
|
@ -149,7 +148,9 @@ public class LocalInsightPlugin extends PumpPluginBase implements PumpInterface,
|
|||
private final SP sp;
|
||||
private final CommandQueueProvider commandQueue;
|
||||
private final ProfileFunction profileFunction;
|
||||
private final NSUpload nsUpload;
|
||||
private final Context context;
|
||||
private final UploadQueue uploadQueue;
|
||||
private final DateUtil dateUtil;
|
||||
|
||||
public static final String ALERT_CHANNEL_ID = "AndroidAPS-InsightAlert";
|
||||
|
@ -209,7 +210,9 @@ public class LocalInsightPlugin extends PumpPluginBase implements PumpInterface,
|
|||
SP sp,
|
||||
CommandQueueProvider commandQueue,
|
||||
ProfileFunction profileFunction,
|
||||
NSUpload nsUpload,
|
||||
Context context,
|
||||
UploadQueue uploadQueue,
|
||||
Config config,
|
||||
DateUtil dateUtil
|
||||
) {
|
||||
|
@ -230,7 +233,9 @@ public class LocalInsightPlugin extends PumpPluginBase implements PumpInterface,
|
|||
this.sp = sp;
|
||||
this.commandQueue = commandQueue;
|
||||
this.profileFunction = profileFunction;
|
||||
this.nsUpload = nsUpload;
|
||||
this.context = context;
|
||||
this.uploadQueue = uploadQueue;
|
||||
this.dateUtil = dateUtil;
|
||||
|
||||
pumpDescription = new PumpDescription();
|
||||
|
@ -929,8 +934,8 @@ public class LocalInsightPlugin extends PumpPluginBase implements PumpInterface,
|
|||
if (extendedBolus.durationInMinutes <= 0) {
|
||||
final String _id = extendedBolus._id;
|
||||
if (NSUpload.isIdValid(_id))
|
||||
NSUpload.removeCareportalEntryFromNS(_id);
|
||||
else UploadQueue.removeID("dbAdd", _id);
|
||||
nsUpload.removeCareportalEntryFromNS(_id);
|
||||
else uploadQueue.removeID("dbAdd", _id);
|
||||
MainApp.getDbHelper().delete(extendedBolus);
|
||||
} else
|
||||
treatmentsPlugin.addToHistoryExtendedBolus(extendedBolus);
|
||||
|
@ -978,7 +983,7 @@ public class LocalInsightPlugin extends PumpPluginBase implements PumpInterface,
|
|||
}
|
||||
|
||||
@NonNull @Override
|
||||
public JSONObject getJSONStatus(Profile profile, String profileName) {
|
||||
public JSONObject getJSONStatus(Profile profile, String profileName, String version) {
|
||||
long now = System.currentTimeMillis();
|
||||
if (connectionService == null) return null;
|
||||
if (System.currentTimeMillis() - connectionService.getLastConnected() > (60 * 60 * 1000)) {
|
||||
|
@ -991,7 +996,7 @@ public class LocalInsightPlugin extends PumpPluginBase implements PumpInterface,
|
|||
final JSONObject extended = new JSONObject();
|
||||
try {
|
||||
status.put("timestamp", DateUtil.toISOString(connectionService.getLastConnected()));
|
||||
extended.put("Version", BuildConfig.VERSION_NAME + "-" + BuildConfig.BUILDVERSION);
|
||||
extended.put("Version", version);
|
||||
try {
|
||||
extended.put("ActiveProfile", profileFunction.getProfileName());
|
||||
} catch (Exception e) {
|
||||
|
@ -1451,8 +1456,8 @@ public class LocalInsightPlugin extends PumpPluginBase implements PumpInterface,
|
|||
ExtendedBolus extendedBolus = MainApp.getDbHelper().getExtendedBolusByPumpId(bolusID.id);
|
||||
if (extendedBolus != null) {
|
||||
final String _id = extendedBolus._id;
|
||||
if (NSUpload.isIdValid(_id)) NSUpload.removeCareportalEntryFromNS(_id);
|
||||
else UploadQueue.removeID("dbAdd", _id);
|
||||
if (NSUpload.isIdValid(_id)) nsUpload.removeCareportalEntryFromNS(_id);
|
||||
else uploadQueue.removeID("dbAdd", _id);
|
||||
MainApp.getDbHelper().delete(extendedBolus);
|
||||
}
|
||||
} else {
|
||||
|
@ -1583,7 +1588,7 @@ public class LocalInsightPlugin extends PumpPluginBase implements PumpInterface,
|
|||
careportalEvent.eventType = CareportalEvent.NOTE;
|
||||
careportalEvent.json = data.toString();
|
||||
MainApp.getDbHelper().createOrUpdate(careportalEvent);
|
||||
NSUpload.uploadCareportalEntryToNS(data);
|
||||
nsUpload.uploadCareportalEntryToNS(data);
|
||||
} catch (JSONException e) {
|
||||
aapsLogger.error("Unhandled exception", e);
|
||||
}
|
||||
|
@ -1617,7 +1622,7 @@ public class LocalInsightPlugin extends PumpPluginBase implements PumpInterface,
|
|||
careportalEvent.eventType = event;
|
||||
careportalEvent.json = data.toString();
|
||||
MainApp.getDbHelper().createOrUpdate(careportalEvent);
|
||||
NSUpload.uploadCareportalEntryToNS(data);
|
||||
nsUpload.uploadCareportalEntryToNS(data);
|
||||
} catch (JSONException e) {
|
||||
aapsLogger.error("Unhandled exception", e);
|
||||
}
|
||||
|
|
|
@ -227,14 +227,14 @@ public class MDIPlugin extends PumpPluginBase implements PumpInterface {
|
|||
}
|
||||
|
||||
@NonNull @Override
|
||||
public JSONObject getJSONStatus(Profile profile, String profileName) {
|
||||
public JSONObject getJSONStatus(Profile profile, String profileName, String version) {
|
||||
long now = System.currentTimeMillis();
|
||||
JSONObject pump = new JSONObject();
|
||||
JSONObject status = new JSONObject();
|
||||
JSONObject extended = new JSONObject();
|
||||
try {
|
||||
status.put("status", "normal");
|
||||
extended.put("Version", BuildConfig.VERSION_NAME + "-" + BuildConfig.BUILDVERSION);
|
||||
extended.put("Version", version);
|
||||
try {
|
||||
extended.put("ActiveProfile", profileName);
|
||||
} catch (Exception e) {
|
||||
|
|
|
@ -78,6 +78,7 @@ public class MedtronicHistoryData {
|
|||
private final AAPSLogger aapsLogger;
|
||||
private final SP sp;
|
||||
private final ActivePluginProvider activePlugin;
|
||||
private final NSUpload nsUpload;
|
||||
private final MedtronicUtil medtronicUtil;
|
||||
private final MedtronicPumpHistoryDecoder medtronicPumpHistoryDecoder;
|
||||
|
||||
|
@ -106,6 +107,7 @@ public class MedtronicHistoryData {
|
|||
AAPSLogger aapsLogger,
|
||||
SP sp,
|
||||
ActivePluginProvider activePlugin,
|
||||
NSUpload nsUpload,
|
||||
MedtronicUtil medtronicUtil,
|
||||
MedtronicPumpHistoryDecoder medtronicPumpHistoryDecoder
|
||||
) {
|
||||
|
@ -115,6 +117,7 @@ public class MedtronicHistoryData {
|
|||
this.aapsLogger = aapsLogger;
|
||||
this.sp = sp;
|
||||
this.activePlugin = activePlugin;
|
||||
this.nsUpload = nsUpload;
|
||||
this.medtronicUtil = medtronicUtil;
|
||||
this.medtronicPumpHistoryDecoder = medtronicPumpHistoryDecoder;
|
||||
}
|
||||
|
@ -543,7 +546,7 @@ public class MedtronicHistoryData {
|
|||
careportalEvent.eventType = event;
|
||||
careportalEvent.json = data.toString();
|
||||
MainApp.getDbHelper().createOrUpdate(careportalEvent);
|
||||
NSUpload.uploadCareportalEntryToNS(data);
|
||||
nsUpload.uploadCareportalEntryToNS(data);
|
||||
} catch (JSONException e) {
|
||||
aapsLogger.error("Unhandled exception", e);
|
||||
}
|
||||
|
|
|
@ -35,6 +35,7 @@ public class InitPodRefreshAction extends AbstractCancelAction implements Finish
|
|||
@Inject OmnipodUtil omnipodUtil;
|
||||
@Inject AAPSLogger aapsLogger;
|
||||
@Inject SP sp;
|
||||
@Inject NSUpload nsUpload;
|
||||
|
||||
public InitPodRefreshAction(HasAndroidInjector injector, PodManagementActivity podManagementActivity, PodActionType actionType) {
|
||||
injector.androidInjector().inject(this);
|
||||
|
@ -86,7 +87,7 @@ public class InitPodRefreshAction extends AbstractCancelAction implements Finish
|
|||
careportalEvent.eventType = event;
|
||||
careportalEvent.json = data.toString();
|
||||
MainApp.getDbHelper().createOrUpdate(careportalEvent);
|
||||
NSUpload.uploadCareportalEntryToNS(data);
|
||||
nsUpload.uploadCareportalEntryToNS(data);
|
||||
} catch (JSONException e) {
|
||||
aapsLogger.error(LTag.PUMPCOMM, "Unhandled exception when uploading SiteChange event.", e);
|
||||
}
|
||||
|
|
|
@ -337,7 +337,7 @@ class VirtualPumpPlugin @Inject constructor(
|
|||
return result
|
||||
}
|
||||
|
||||
override fun getJSONStatus(profile: Profile, profileName: String): JSONObject {
|
||||
override fun getJSONStatus(profile: Profile, profileName: String, version: String): JSONObject {
|
||||
val now = System.currentTimeMillis()
|
||||
if (!sp.getBoolean("virtualpump_uploadstatus", false)) {
|
||||
return JSONObject()
|
||||
|
@ -349,7 +349,7 @@ class VirtualPumpPlugin @Inject constructor(
|
|||
try {
|
||||
battery.put("percent", batteryPercent)
|
||||
status.put("status", "normal")
|
||||
extended.put("Version", BuildConfig.VERSION_NAME + "-" + BuildConfig.BUILDVERSION)
|
||||
extended.put("Version", version)
|
||||
try {
|
||||
extended.put("ActiveProfile", profileName)
|
||||
} catch (ignored: Exception) {
|
||||
|
|
|
@ -31,7 +31,8 @@ class DexcomPlugin @Inject constructor(
|
|||
private val sp: SP,
|
||||
private val mainApp: MainApp,
|
||||
resourceHelper: ResourceHelper,
|
||||
aapsLogger: AAPSLogger
|
||||
aapsLogger: AAPSLogger,
|
||||
private val nsUpload: NSUpload
|
||||
) : PluginBase(PluginDescription()
|
||||
.mainType(PluginType.BGSOURCE)
|
||||
.fragmentClass(BGSourceFragment::class.java.name)
|
||||
|
@ -78,10 +79,10 @@ class DexcomPlugin @Inject constructor(
|
|||
bgReading.raw = 0.0
|
||||
if (MainApp.getDbHelper().createIfNotExists(bgReading, "Dexcom$sensorType")) {
|
||||
if (sp.getBoolean(R.string.key_dexcomg5_nsupload, false)) {
|
||||
NSUpload.uploadBg(bgReading, "AndroidAPS-Dexcom$sensorType")
|
||||
nsUpload.uploadBg(bgReading, "AndroidAPS-Dexcom$sensorType")
|
||||
}
|
||||
if (sp.getBoolean(R.string.key_dexcomg5_xdripupload, false)) {
|
||||
NSUpload.sendToXdrip(bgReading)
|
||||
nsUpload.sendToXdrip(bgReading)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -108,7 +109,7 @@ class DexcomPlugin @Inject constructor(
|
|||
careportalEvent.eventType = CareportalEvent.BGCHECK
|
||||
careportalEvent.json = jsonObject.toString()
|
||||
MainApp.getDbHelper().createOrUpdate(careportalEvent)
|
||||
NSUpload.uploadCareportalEntryToNS(jsonObject)
|
||||
nsUpload.uploadCareportalEntryToNS(jsonObject)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -128,7 +129,7 @@ class DexcomPlugin @Inject constructor(
|
|||
careportalEvent.eventType = CareportalEvent.SENSORCHANGE
|
||||
careportalEvent.json = jsonObject.toString()
|
||||
MainApp.getDbHelper().createOrUpdate(careportalEvent)
|
||||
NSUpload.uploadCareportalEntryToNS(jsonObject)
|
||||
nsUpload.uploadCareportalEntryToNS(jsonObject)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -29,7 +29,8 @@ class EversensePlugin @Inject constructor(
|
|||
private val sp: SP,
|
||||
resourceHelper: ResourceHelper,
|
||||
aapsLogger: AAPSLogger,
|
||||
private val dateUtil: DateUtil
|
||||
private val dateUtil: DateUtil,
|
||||
private val nsUpload: NSUpload
|
||||
) : PluginBase(PluginDescription()
|
||||
.mainType(PluginType.BGSOURCE)
|
||||
.fragmentClass(BGSourceFragment::class.java.name)
|
||||
|
@ -77,10 +78,10 @@ class EversensePlugin @Inject constructor(
|
|||
bgReading.raw = 0.0
|
||||
val isNew = MainApp.getDbHelper().createIfNotExists(bgReading, "Eversense")
|
||||
if (isNew && sp.getBoolean(R.string.key_dexcomg5_nsupload, false)) {
|
||||
NSUpload.uploadBg(bgReading, "AndroidAPS-Eversense")
|
||||
nsUpload.uploadBg(bgReading, "AndroidAPS-Eversense")
|
||||
}
|
||||
if (isNew && sp.getBoolean(R.string.key_dexcomg5_xdripupload, false)) {
|
||||
NSUpload.sendToXdrip(bgReading)
|
||||
nsUpload.sendToXdrip(bgReading)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -103,7 +104,7 @@ class EversensePlugin @Inject constructor(
|
|||
data.put("glucoseType", "Finger")
|
||||
data.put("glucose", calibrationGlucoseLevels[i])
|
||||
data.put("units", Constants.MGDL)
|
||||
NSUpload.uploadCareportalEntryToNS(data)
|
||||
nsUpload.uploadCareportalEntryToNS(data)
|
||||
}
|
||||
} catch (e: JSONException) {
|
||||
aapsLogger.error("Unhandled exception", e)
|
||||
|
|
|
@ -26,7 +26,8 @@ class PoctechPlugin @Inject constructor(
|
|||
injector: HasAndroidInjector,
|
||||
resourceHelper: ResourceHelper,
|
||||
aapsLogger: AAPSLogger,
|
||||
private val sp: SP
|
||||
private val sp: SP,
|
||||
private val nsUpload: NSUpload
|
||||
) : PluginBase(PluginDescription()
|
||||
.mainType(PluginType.BGSOURCE)
|
||||
.fragmentClass(BGSourceFragment::class.java.name)
|
||||
|
@ -58,10 +59,10 @@ class PoctechPlugin @Inject constructor(
|
|||
if (safeGetString(json, "units", Constants.MGDL) == "mmol/L") bgReading.value = bgReading.value * Constants.MMOLL_TO_MGDL
|
||||
val isNew = MainApp.getDbHelper().createIfNotExists(bgReading, "Poctech")
|
||||
if (isNew && sp.getBoolean(R.string.key_dexcomg5_nsupload, false)) {
|
||||
NSUpload.uploadBg(bgReading, "AndroidAPS-Poctech")
|
||||
nsUpload.uploadBg(bgReading, "AndroidAPS-Poctech")
|
||||
}
|
||||
if (isNew && sp.getBoolean(R.string.key_dexcomg5_xdripupload, false)) {
|
||||
NSUpload.sendToXdrip(bgReading)
|
||||
nsUpload.sendToXdrip(bgReading)
|
||||
}
|
||||
}
|
||||
} catch (e: JSONException) {
|
||||
|
|
|
@ -22,7 +22,8 @@ class TomatoPlugin @Inject constructor(
|
|||
injector: HasAndroidInjector,
|
||||
resourceHelper: ResourceHelper,
|
||||
aapsLogger: AAPSLogger,
|
||||
private val sp: SP
|
||||
private val sp: SP,
|
||||
private val nsUpload: NSUpload
|
||||
) : PluginBase(PluginDescription()
|
||||
.mainType(PluginType.BGSOURCE)
|
||||
.fragmentClass(BGSourceFragment::class.java.name)
|
||||
|
@ -46,10 +47,10 @@ class TomatoPlugin @Inject constructor(
|
|||
bgReading.date = bundle.getLong("com.fanqies.tomatofn.Extras.Time")
|
||||
val isNew = MainApp.getDbHelper().createIfNotExists(bgReading, "Tomato")
|
||||
if (isNew && sp.getBoolean(R.string.key_dexcomg5_nsupload, false)) {
|
||||
NSUpload.uploadBg(bgReading, "AndroidAPS-Tomato")
|
||||
nsUpload.uploadBg(bgReading, "AndroidAPS-Tomato")
|
||||
}
|
||||
if (isNew && sp.getBoolean(R.string.key_dexcomg5_xdripupload, false)) {
|
||||
NSUpload.sendToXdrip(bgReading)
|
||||
nsUpload.sendToXdrip(bgReading)
|
||||
}
|
||||
}
|
||||
}
|
|
@ -42,6 +42,8 @@ class TreatmentsBolusFragment : DaggerFragment() {
|
|||
@Inject lateinit var fabricPrivacy: FabricPrivacy
|
||||
@Inject lateinit var treatmentsPlugin: TreatmentsPlugin
|
||||
@Inject lateinit var profileFunction: ProfileFunction
|
||||
@Inject lateinit var nsUpload: NSUpload
|
||||
@Inject lateinit var uploadQueue: UploadQueue
|
||||
@Inject lateinit var dateUtil: DateUtil
|
||||
|
||||
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?,
|
||||
|
@ -68,9 +70,9 @@ class TreatmentsBolusFragment : DaggerFragment() {
|
|||
val futureTreatments = treatmentsPlugin.service.getTreatmentDataFromTime(DateUtil.now() + 1000, true)
|
||||
for (treatment in futureTreatments) {
|
||||
if (NSUpload.isIdValid(treatment._id))
|
||||
NSUpload.removeCareportalEntryFromNS(treatment._id)
|
||||
nsUpload.removeCareportalEntryFromNS(treatment._id)
|
||||
else
|
||||
UploadQueue.removeID("dbAdd", treatment._id)
|
||||
uploadQueue.removeID("dbAdd", treatment._id)
|
||||
treatmentsPlugin.service.delete(treatment)
|
||||
}
|
||||
updateGui()
|
||||
|
@ -166,9 +168,9 @@ class TreatmentsBolusFragment : DaggerFragment() {
|
|||
treatmentsPlugin.service.update(treatment)
|
||||
} else {
|
||||
if (NSUpload.isIdValid(treatment._id))
|
||||
NSUpload.removeCareportalEntryFromNS(treatment._id)
|
||||
nsUpload.removeCareportalEntryFromNS(treatment._id)
|
||||
else
|
||||
UploadQueue.removeID("dbAdd", treatment._id)
|
||||
uploadQueue.removeID("dbAdd", treatment._id)
|
||||
treatmentsPlugin.service.delete(treatment)
|
||||
}
|
||||
updateGui()
|
||||
|
|
|
@ -38,6 +38,8 @@ class TreatmentsCareportalFragment : DaggerFragment() {
|
|||
@Inject lateinit var resourceHelper: ResourceHelper
|
||||
@Inject lateinit var fabricPrivacy: FabricPrivacy
|
||||
@Inject lateinit var translator: Translator
|
||||
@Inject lateinit var nsUpload: NSUpload
|
||||
@Inject lateinit var uploadQueue: UploadQueue
|
||||
@Inject lateinit var dateUtil: DateUtil
|
||||
|
||||
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?,
|
||||
|
@ -66,9 +68,9 @@ class TreatmentsCareportalFragment : DaggerFragment() {
|
|||
val careportalEvent = events[i]
|
||||
if (careportalEvent.json.contains(resourceHelper.gs(R.string.androidaps_start))) {
|
||||
if (NSUpload.isIdValid(careportalEvent._id))
|
||||
NSUpload.removeCareportalEntryFromNS(careportalEvent._id)
|
||||
nsUpload.removeCareportalEntryFromNS(careportalEvent._id)
|
||||
else
|
||||
UploadQueue.removeID("dbAdd", careportalEvent._id)
|
||||
uploadQueue.removeID("dbAdd", careportalEvent._id)
|
||||
MainApp.getDbHelper().delete(careportalEvent)
|
||||
}
|
||||
}
|
||||
|
@ -136,9 +138,9 @@ class TreatmentsCareportalFragment : DaggerFragment() {
|
|||
resourceHelper.gs(R.string.date) + ": " + dateUtil.dateAndTimeString(careportalEvent.date)
|
||||
OKDialog.showConfirmation(activity, resourceHelper.gs(R.string.removerecord), text, Runnable {
|
||||
if (NSUpload.isIdValid(careportalEvent._id))
|
||||
NSUpload.removeCareportalEntryFromNS(careportalEvent._id)
|
||||
nsUpload.removeCareportalEntryFromNS(careportalEvent._id)
|
||||
else
|
||||
UploadQueue.removeID("dbAdd", careportalEvent._id)
|
||||
uploadQueue.removeID("dbAdd", careportalEvent._id)
|
||||
MainApp.getDbHelper().delete(careportalEvent)
|
||||
}, null)
|
||||
}
|
||||
|
|
|
@ -40,6 +40,8 @@ class TreatmentsExtendedBolusesFragment : DaggerFragment() {
|
|||
@Inject lateinit var rxBus: RxBusWrapper
|
||||
@Inject lateinit var resourceHelper: ResourceHelper
|
||||
@Inject lateinit var fabricPrivacy: FabricPrivacy
|
||||
@Inject lateinit var nsUpload: NSUpload
|
||||
@Inject lateinit var uploadQueue: UploadQueue
|
||||
@Inject lateinit var dateUtil: DateUtil
|
||||
|
||||
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?,
|
||||
|
@ -116,8 +118,8 @@ class TreatmentsExtendedBolusesFragment : DaggerFragment() {
|
|||
${resourceHelper.gs(R.string.date)}: ${dateUtil.dateAndTimeString(extendedBolus.date)}
|
||||
""".trimIndent(), DialogInterface.OnClickListener { _: DialogInterface, _: Int ->
|
||||
val id = extendedBolus._id
|
||||
if (NSUpload.isIdValid(id)) NSUpload.removeCareportalEntryFromNS(id)
|
||||
else UploadQueue.removeID("dbAdd", id)
|
||||
if (NSUpload.isIdValid(id)) nsUpload.removeCareportalEntryFromNS(id)
|
||||
else uploadQueue.removeID("dbAdd", id)
|
||||
MainApp.getDbHelper().delete(extendedBolus)
|
||||
}, null)
|
||||
}
|
||||
|
|
|
@ -43,6 +43,8 @@ class TreatmentsProfileSwitchFragment : DaggerFragment() {
|
|||
@Inject lateinit var localProfilePlugin: LocalProfilePlugin
|
||||
@Inject lateinit var resourceHelper: ResourceHelper
|
||||
@Inject lateinit var fabricPrivacy: FabricPrivacy
|
||||
@Inject lateinit var nsUpload: NSUpload
|
||||
@Inject lateinit var uploadQueue: UploadQueue
|
||||
@Inject lateinit var dateUtil: DateUtil
|
||||
|
||||
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?,
|
||||
|
@ -135,8 +137,8 @@ class TreatmentsProfileSwitchFragment : DaggerFragment() {
|
|||
resourceHelper.gs(R.string.careportal_profileswitch) + ": " + profileSwitch.profileName +
|
||||
"\n" + resourceHelper.gs(R.string.date) + ": " + dateUtil.dateAndTimeString(profileSwitch.date), Runnable {
|
||||
val id = profileSwitch._id
|
||||
if (NSUpload.isIdValid(id)) NSUpload.removeCareportalEntryFromNS(id)
|
||||
else UploadQueue.removeID("dbAdd", id)
|
||||
if (NSUpload.isIdValid(id)) nsUpload.removeCareportalEntryFromNS(id)
|
||||
else uploadQueue.removeID("dbAdd", id)
|
||||
MainApp.getDbHelper().delete(profileSwitch)
|
||||
})
|
||||
}
|
||||
|
|
|
@ -47,6 +47,8 @@ public class TreatmentsTempTargetFragment extends DaggerFragment {
|
|||
@Inject RxBusWrapper rxBus;
|
||||
@Inject ProfileFunction profileFunction;
|
||||
@Inject ResourceHelper resourceHelper;
|
||||
@Inject NSUpload nsUpload;
|
||||
@Inject UploadQueue uploadQueue;
|
||||
@Inject FabricPrivacy fabricPrivacy;
|
||||
@Inject DateUtil dateUtil;
|
||||
|
||||
|
@ -146,9 +148,9 @@ public class TreatmentsTempTargetFragment extends DaggerFragment {
|
|||
(dialog, id) -> {
|
||||
final String _id = tempTarget._id;
|
||||
if (NSUpload.isIdValid(_id)) {
|
||||
NSUpload.removeCareportalEntryFromNS(_id);
|
||||
nsUpload.removeCareportalEntryFromNS(_id);
|
||||
} else {
|
||||
UploadQueue.removeID("dbAdd", _id);
|
||||
uploadQueue.removeID("dbAdd", _id);
|
||||
}
|
||||
MainApp.getDbHelper().delete(tempTarget);
|
||||
}, null);
|
||||
|
|
|
@ -44,6 +44,8 @@ class TreatmentsTemporaryBasalsFragment : DaggerFragment() {
|
|||
@Inject lateinit var fabricPrivacy: FabricPrivacy
|
||||
@Inject lateinit var activePlugin: ActivePluginProvider
|
||||
@Inject lateinit var profileFunction: ProfileFunction
|
||||
@Inject lateinit var nsUpload: NSUpload
|
||||
@Inject lateinit var uploadQueue: UploadQueue
|
||||
@Inject lateinit var dateUtil: DateUtil
|
||||
|
||||
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?,
|
||||
|
@ -165,8 +167,8 @@ class TreatmentsTemporaryBasalsFragment : DaggerFragment() {
|
|||
""".trimIndent(),
|
||||
DialogInterface.OnClickListener { _: DialogInterface?, _: Int ->
|
||||
val id = tempBasal._id
|
||||
if (NSUpload.isIdValid(id)) NSUpload.removeCareportalEntryFromNS(id)
|
||||
else UploadQueue.removeID("dbAdd", id)
|
||||
if (NSUpload.isIdValid(id)) nsUpload.removeCareportalEntryFromNS(id)
|
||||
else uploadQueue.removeID("dbAdd", id)
|
||||
MainApp.getDbHelper().delete(tempBasal)
|
||||
}, null)
|
||||
}
|
||||
|
|
|
@ -8,15 +8,16 @@ import android.content.Intent
|
|||
import android.os.PowerManager
|
||||
import android.os.SystemClock
|
||||
import dagger.android.DaggerBroadcastReceiver
|
||||
import info.nightscout.androidaps.BuildConfig
|
||||
import info.nightscout.androidaps.Config
|
||||
import info.nightscout.androidaps.events.EventProfileNeedsUpdate
|
||||
import info.nightscout.androidaps.interfaces.ActivePluginProvider
|
||||
import info.nightscout.androidaps.interfaces.CommandQueueProvider
|
||||
import info.nightscout.androidaps.interfaces.ProfileFunction
|
||||
import info.nightscout.androidaps.logging.AAPSLogger
|
||||
import info.nightscout.androidaps.logging.LTag
|
||||
import info.nightscout.androidaps.plugins.aps.loop.LoopPlugin
|
||||
import info.nightscout.androidaps.plugins.bus.RxBusWrapper
|
||||
import info.nightscout.androidaps.interfaces.ProfileFunction
|
||||
import info.nightscout.androidaps.plugins.general.nsclient.NSUpload
|
||||
import info.nightscout.androidaps.plugins.iob.iobCobCalculator.IobCobCalculatorPlugin
|
||||
import info.nightscout.androidaps.queue.commands.Command
|
||||
|
@ -39,6 +40,7 @@ class KeepAliveReceiver : DaggerBroadcastReceiver() {
|
|||
@Inject lateinit var fabricPrivacy: FabricPrivacy
|
||||
@Inject lateinit var receiverStatusStore: ReceiverStatusStore
|
||||
@Inject lateinit var config: Config
|
||||
@Inject lateinit var nsUpload: NSUpload
|
||||
@Inject lateinit var dateUtil: DateUtil
|
||||
|
||||
companion object {
|
||||
|
@ -108,7 +110,7 @@ class KeepAliveReceiver : DaggerBroadcastReceiver() {
|
|||
else if (DateUtil.isOlderThan(activePlugin.activeAPS.lastAPSRun, 5)) shouldUploadStatus = true
|
||||
if (DateUtil.isOlderThan(lastIobUpload, IOB_UPDATE_FREQUENCY) && shouldUploadStatus) {
|
||||
lastIobUpload = DateUtil.now()
|
||||
NSUpload.uploadDeviceStatus(loopPlugin, iobCobCalculatorPlugin, profileFunction, activePlugin.activePump, receiverStatusStore)
|
||||
nsUpload.uploadDeviceStatus(loopPlugin, iobCobCalculatorPlugin, profileFunction, activePlugin.activePump, receiverStatusStore, BuildConfig.VERSION_NAME + "-" + BuildConfig.BUILDVERSION)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -20,6 +20,7 @@ import info.nightscout.androidaps.logging.AAPSLogger;
|
|||
import info.nightscout.androidaps.logging.BundleLogger;
|
||||
import info.nightscout.androidaps.logging.LTag;
|
||||
import info.nightscout.androidaps.plugins.bus.RxBusWrapper;
|
||||
import info.nightscout.androidaps.plugins.general.nsclient.NSUpload;
|
||||
import info.nightscout.androidaps.plugins.general.nsclient.data.NSMbg;
|
||||
import info.nightscout.androidaps.plugins.general.overview.events.EventNewNotification;
|
||||
import info.nightscout.androidaps.plugins.general.overview.notifications.Notification;
|
||||
|
@ -42,6 +43,7 @@ public class DataService extends DaggerIntentService {
|
|||
@Inject AAPSLogger aapsLogger;
|
||||
@Inject SP sp;
|
||||
@Inject RxBusWrapper rxBus;
|
||||
@Inject NSUpload nsUpload;
|
||||
@Inject SmsCommunicatorPlugin smsCommunicatorPlugin;
|
||||
@Inject DexcomPlugin dexcomPlugin;
|
||||
@Inject EversensePlugin eversensePlugin;
|
||||
|
@ -210,7 +212,7 @@ public class DataService extends DaggerIntentService {
|
|||
} else if (eventType.equals(CareportalEvent.COMBOBOLUS)) {
|
||||
MainApp.getDbHelper().createExtendedBolusFromJsonIfNotExists(json);
|
||||
} else if (eventType.equals(CareportalEvent.PROFILESWITCH)) {
|
||||
MainApp.getDbHelper().createProfileSwitchFromJsonIfNotExists(activePlugin, json);
|
||||
MainApp.getDbHelper().createProfileSwitchFromJsonIfNotExists(activePlugin, nsUpload, json);
|
||||
} else if (eventType.equals(CareportalEvent.SITECHANGE) ||
|
||||
eventType.equals(CareportalEvent.INSULINCHANGE) ||
|
||||
eventType.equals(CareportalEvent.SENSORCHANGE) ||
|
||||
|
|
|
@ -12,11 +12,12 @@ import javax.inject.Singleton
|
|||
|
||||
@Singleton
|
||||
class HardLimits @Inject constructor(
|
||||
val aapsLogger: AAPSLogger,
|
||||
val rxBus: RxBusWrapper,
|
||||
val sp: SP,
|
||||
val resourceHelper: ResourceHelper,
|
||||
val context: Context
|
||||
private val aapsLogger: AAPSLogger,
|
||||
private val rxBus: RxBusWrapper,
|
||||
private val sp: SP,
|
||||
private val resourceHelper: ResourceHelper,
|
||||
private val context: Context,
|
||||
private val nsUpload: NSUpload
|
||||
) {
|
||||
|
||||
val CHILD = 0
|
||||
|
@ -90,7 +91,7 @@ class HardLimits @Inject constructor(
|
|||
msg += ".\n"
|
||||
msg += String.format(resourceHelper.gs(R.string.valuelimitedto), value, newvalue)
|
||||
aapsLogger.error(msg)
|
||||
NSUpload.uploadError(msg)
|
||||
nsUpload.uploadError(msg)
|
||||
ToastUtils.showToastInUiThread(context, rxBus, msg, R.raw.error)
|
||||
}
|
||||
return newvalue
|
||||
|
|
|
@ -31,6 +31,7 @@ class LocalAlertUtils @Inject constructor(
|
|||
private val profileFunction: ProfileFunction,
|
||||
private val iobCobCalculatorPlugin: IobCobCalculatorPlugin,
|
||||
private val config: Config,
|
||||
private val nsUpload: NSUpload,
|
||||
private val dateUtil: DateUtil
|
||||
) {
|
||||
|
||||
|
@ -53,7 +54,7 @@ class LocalAlertUtils @Inject constructor(
|
|||
sp.putLong("nextPumpDisconnectedAlarm", System.currentTimeMillis() + pumpUnreachableThreshold())
|
||||
rxBus.send(EventNewNotification(n))
|
||||
if (sp.getBoolean(R.string.key_ns_create_announcements_from_errors, true)) {
|
||||
NSUpload.uploadError(n.text)
|
||||
nsUpload.uploadError(n.text)
|
||||
}
|
||||
}
|
||||
if (!isStatusOutdated && !alarmTimeoutExpired) rxBus.send(EventDismissNotification(Notification.PUMP_UNREACHABLE))
|
||||
|
@ -101,7 +102,7 @@ class LocalAlertUtils @Inject constructor(
|
|||
sp.putLong("nextMissedReadingsAlarm", System.currentTimeMillis() + missedReadingsThreshold())
|
||||
rxBus.send(EventNewNotification(n))
|
||||
if (sp.getBoolean(R.string.key_ns_create_announcements_from_errors, true)) {
|
||||
NSUpload.uploadError(n.text)
|
||||
nsUpload.uploadError(n.text)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -11,6 +11,7 @@ import info.nightscout.androidaps.logging.AAPSLogger
|
|||
import info.nightscout.androidaps.logging.LTag
|
||||
import info.nightscout.androidaps.plugins.bus.RxBusWrapper
|
||||
import info.nightscout.androidaps.interfaces.ProfileFunction
|
||||
import info.nightscout.androidaps.plugins.general.nsclient.NSUpload
|
||||
import info.nightscout.androidaps.plugins.treatments.TreatmentService
|
||||
import info.nightscout.androidaps.plugins.treatments.TreatmentsPlugin
|
||||
import info.nightscout.androidaps.utils.DateUtil
|
||||
|
@ -32,8 +33,9 @@ class TddCalculator @Inject constructor(
|
|||
val activePlugin: ActivePluginProvider,
|
||||
val profileFunction: ProfileFunction,
|
||||
fabricPrivacy: FabricPrivacy,
|
||||
nsUpload: NSUpload,
|
||||
private val dateUtil: DateUtil
|
||||
) : TreatmentsPlugin(injector, aapsLogger, rxBus, resourceHelper, mainApp, sp, profileFunction, activePlugin, fabricPrivacy, dateUtil) {
|
||||
) : TreatmentsPlugin(injector, aapsLogger, rxBus, resourceHelper, mainApp, sp, profileFunction, activePlugin, nsUpload, fabricPrivacy, dateUtil) {
|
||||
|
||||
init {
|
||||
service = TreatmentService(injector) // plugin is not started
|
||||
|
|
44
app/src/main/res/layout/okcancel.xml
Normal file
44
app/src/main/res/layout/okcancel.xml
Normal file
|
@ -0,0 +1,44 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- Copyright (C) 2013 The Android Open Source Project
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
-->
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:id="@+id/done_background"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="56dp"
|
||||
android:orientation="horizontal"
|
||||
android:background="@android:color/transparent"
|
||||
android:gravity="end|right"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:paddingBottom="8dp">
|
||||
|
||||
<Button
|
||||
android:id="@+id/cancel"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_marginRight="8dp"
|
||||
android:layout_marginEnd="8dp"
|
||||
style="@style/mdtp_ActionButton.Text"
|
||||
android:text="@string/mdtp_cancel" />
|
||||
|
||||
<Button
|
||||
android:id="@+id/ok"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginRight="16dp"
|
||||
android:layout_marginEnd="16dp"
|
||||
style="@style/mdtp_ActionButton.Text"
|
||||
android:text="@string/mdtp_ok" />
|
||||
</LinearLayout>
|
||||
<!-- From: file:/Users/wdullaer/Documents/Programming%20Projects/MaterialDateTimePicker/library/src/main/res/layout/mdtp_done_button.xml -->
|
|
@ -9,7 +9,6 @@
|
|||
<color name="devslopepos">#FFFFFF00</color>
|
||||
<color name="devslopeneg">#FFFF00FF</color>
|
||||
<color name="actionsConfirm">#FFFF00</color>
|
||||
<color name="listdelimiter">#505050</color>
|
||||
<color name="tabBgColorSelected">#FF33B5E5</color>
|
||||
<color name="deviations">#FF0000</color>
|
||||
<color name="cobAlert">#7484E2</color>
|
||||
|
@ -30,7 +29,6 @@
|
|||
|
||||
|
||||
<color name="mdtp_accent_color">#40bbaa</color>
|
||||
<color name="colorInitializingBorder">#00695c</color>
|
||||
|
||||
<color name="cardColorBackground">#121212</color>
|
||||
<color name="cardObjectiveText">#779ECB</color>
|
||||
|
|
|
@ -124,7 +124,6 @@
|
|||
<string name="sms_delta">Delta:</string>
|
||||
|
||||
<string name="configbuilder">Config Builder</string>
|
||||
<string name="objectives">Objectives</string>
|
||||
<string name="overview">Overview</string>
|
||||
<string name="nsprofile">NS Profile</string>
|
||||
<string name="simpleprofile">Simple profile</string>
|
||||
|
@ -288,7 +287,6 @@
|
|||
<string name="save">Save</string>
|
||||
<string name="nobtadapter">No bluetooth adapter found</string>
|
||||
<string name="devicenotfound">Selected device not found</string>
|
||||
<string name="connectionerror">Pump connection error</string>
|
||||
<string name="danar_iob_label">Pump IOB</string>
|
||||
<string name="danar_dailyunits">Daily units</string>
|
||||
<string name="pump_lastbolus_label">Last bolus</string>
|
||||
|
@ -316,7 +314,6 @@
|
|||
<string name="smscommunicator_mealbolusdelivered_tt">Target %1$s for %2$d minutes</string>
|
||||
<string name="smscommunicator_tt_set">Target %1$s for %2$d minutes set successfully</string>
|
||||
<string name="smscommunicator_tt_canceled">Temp Target canceled successfully</string>
|
||||
<string name="bolusdelivering">Delivering %1$.2fU</string>
|
||||
<string name="smscommunicator_remotecommandsallowed">Allow remote commands via SMS</string>
|
||||
<string name="danarprofile">DanaR profile settings</string>
|
||||
<string name="danarprofile_dia">DIA [h]</string>
|
||||
|
@ -334,27 +331,12 @@
|
|||
<string name="danar_alarm">alarm</string>
|
||||
<string name="danar_totaluploaded">Total %1$d records uploaded</string>
|
||||
<string name="danar_sbolus">S bolus</string>
|
||||
<string name="danar_history_alarm">Alarms</string>
|
||||
<string name="danar_history_basalhours">Basal Hours</string>
|
||||
<string name="danar_history_bolus">Boluses</string>
|
||||
<string name="danar_history_carbohydrates">Carbohydrates</string>
|
||||
<string name="danar_history_dailyinsulin">Daily insulin</string>
|
||||
<string name="danar_history_errors">Errors</string>
|
||||
<string name="danar_history_glucose">Glucose</string>
|
||||
<string name="danar_history_refill">Refill</string>
|
||||
<string name="danar_history_syspend">Suspend</string>
|
||||
<string name="danars_password_title">Pump password (v1 only)</string>
|
||||
<string name="danar_password_title">Pump password</string>
|
||||
<string name="wrongpumppassword">Wrong pump password!</string>
|
||||
<string name="pumpbusy">Pump is busy</string>
|
||||
<string name="overview_bolusprogress_delivered">Delivered</string>
|
||||
<string name="overview_bolusprogress_stoped">Stopped</string>
|
||||
<string name="bolusstopped">Bolus stopped</string>
|
||||
<string name="bolusstopping">Stopping bolus</string>
|
||||
<string name="occlusion">Occlusion</string>
|
||||
<string name="overview_bolusprogress_stop">Stop</string>
|
||||
<string name="overview_bolusprogress_stoppressed">STOP PRESSED</string>
|
||||
<string name="youareonallowedlimit">You reached allowed limit</string>
|
||||
<string name="smscommunicator_loophasbeendisabled">Loop has been disabled</string>
|
||||
<string name="smscommunicator_loophasbeenenabled">Loop has been enabled</string>
|
||||
<string name="smscommunicator_loopisdisabled">Loop is disabled</string>
|
||||
|
@ -418,16 +400,10 @@
|
|||
<string name="wear">Wear</string>
|
||||
<string name="resend_all_data">Resend All Data</string>
|
||||
<string name="open_settings_on_wear">Open Settings on Wear</string>
|
||||
<string name="pumperror">Pump Error</string>
|
||||
<string name="lowbattery">Low Battery</string>
|
||||
<string name="basalcompare">Delivering less than preset basal rate</string>
|
||||
<string name="pumpshutdown">Pump Shutdown</string>
|
||||
<string name="batterydischarged">Pump Battery Discharged</string>
|
||||
<string name="danarkoreanpump">DanaR Korean</string>
|
||||
<string name="basal_rate">Basal rate:</string>
|
||||
<string name="profile_set_failed">Setting of basal profile failed</string>
|
||||
<string name="danar_disableeasymode">Disable EasyUI mode in pump</string>
|
||||
<string name="danar_enableextendedbolus">Enable extended boluses on pump</string>
|
||||
<string name="danar_switchtouhmode">Change mode from U/d to U/h on pump</string>
|
||||
<string name="basalvaluebelowminimum">Basal value below minimum. Profile not set!</string>
|
||||
<string name="sms_actualbg">BG:</string>
|
||||
|
@ -451,20 +427,6 @@
|
|||
<string name="hypo">Hypo</string>
|
||||
<string name="activity">Activity</string>
|
||||
<string name="removerecord">Remove record</string>
|
||||
<string name="danar_stats">DanaR Stats</string>
|
||||
<string name="danar_stats_cumulative_tdd">Cumulative TDD</string>
|
||||
<string name="danar_stats_expweight">Exponentially Weighted TDD</string>
|
||||
<string name="danar_stats_basalrate">Basal</string>
|
||||
<string name="danar_stats_bolus">Bolus</string>
|
||||
<string name="danar_stats_tdd">TDD</string>
|
||||
<string name="danar_stats_date">Date</string>
|
||||
<string name="danar_stats_ratio">Ratio</string>
|
||||
<string name="danar_stats_amount_days"># Days</string>
|
||||
<string name="danar_stats_weight">Weight</string>
|
||||
<string name="danar_stats_warning_Message">Possibly inaccurate if using boluses for priming/filling!</string>
|
||||
<string name="danar_stats_olddata_Message">Old Data Please Press "RELOAD"</string>
|
||||
<string name="danar_stats_tbb">Total Base Basal</string>
|
||||
<string name="danar_stats_tbb2">TBB * 2</string>
|
||||
<string name="initializing">Initializing ...</string>
|
||||
<string name="actions_shortname">ACT</string>
|
||||
<string name="configbuilder_shortname">CONF</string>
|
||||
|
@ -486,7 +448,6 @@
|
|||
<string name="always_use_shortavg_summary">Useful when data from unfiltered sources like xDrip gets noisy.</string>
|
||||
<string name="advancedsettings_title">Advanced Settings</string>
|
||||
<string name="key_advancedsettings" translatable="false">key_advancedsettings</string>
|
||||
<string name="dana_model">%1$s\nModel: %2$02X\nProtocol: %3$02X\nCode: %4$02X</string>
|
||||
<string name="profile">Profile</string>
|
||||
<string name="openapsama_max_daily_safety_multiplier_summary">Default value: 3 This is a key OpenAPS safety cap. What this does is limit your basals to be 3x (in this people) your biggest basal rate. You likely will not need to change this, but you should be aware that’s what is discussed about “3x max daily; 4x current” for safety caps.</string>
|
||||
<string name="openapsama_current_basal_safety_multiplier_summary">Default value: 4 This is the other half of the key OpenAPS safety caps, and the other half of “3x max daily; 4x current” of the safety caps. This means your basal, regardless of max basal set on your pump, cannot be any higher than this number times the current level of your basal. This is to prevent people from getting into dangerous territory by setting excessively high max basals before understanding how the algorithm works. Again, the default is 4x; most people will never need to adjust this and are instead more likely to need to adjust other settings if they feel like they are “running into” this safety cap.</string>
|
||||
|
@ -511,17 +472,9 @@
|
|||
<string name="smscommunicator_calibrationsent">Calibration sent. Receiving must be enabled in xDrip.</string>
|
||||
<string name="smscommunicator_calibrationfailed">xDrip is not receiving calibrations</string>
|
||||
<string name="pumpsuspended">Pump suspended</string>
|
||||
<string name="gettingpumpstatus">Getting pump status</string>
|
||||
<string name="settingtempbasal">Setting temp basal</string>
|
||||
<string name="stoppingtempbasal">Stopping temp basal</string>
|
||||
<string name="settingextendedbolus">Setting extended bolus</string>
|
||||
<string name="stoppingextendedbolus">Stopping extended bolus</string>
|
||||
<string name="updatingbasalrates">Updating basal rates</string>
|
||||
<string name="executing">Executing</string>
|
||||
<string name="virtualpump_settings">Virtual pump settings</string>
|
||||
<string name="virtualpump_uploadstatus_title">Upload status to NS</string>
|
||||
<string name="wrongpassword">Wrong password</string>
|
||||
<string name="approachingdailylimit">Approaching insulin daily limit</string>
|
||||
<string name="nsclientinternal">NSClient</string>
|
||||
<string name="nsclientinternal_shortname">NSCI</string>
|
||||
<string name="nsclientinternal_url">URL:</string>
|
||||
|
@ -735,10 +688,6 @@
|
|||
<string name="date">Date</string>
|
||||
<string name="invalid">INVALID</string>
|
||||
<string name="pairing">Pairing</string>
|
||||
<string name="emptyreservoir">Empty reservoir</string>
|
||||
<string name="bloodsugarmeasurementalert">Blood sugar measurement alert</string>
|
||||
<string name="remaininsulinalert">Remaining insulin level</string>
|
||||
<string name="missedbolus">Missed bolus</string>
|
||||
<string name="selectedpump">Selected pump</string>
|
||||
<string name="bolusspeed">Bolus speed</string>
|
||||
<string name="serialnumber">Serial number</string>
|
||||
|
@ -753,12 +702,6 @@
|
|||
<string name="activity_target">activity target</string>
|
||||
<string name="hypo_duration">hypo duration</string>
|
||||
<string name="hypo_target">hypo target</string>
|
||||
<string name="danar_history_prime">Prime</string>
|
||||
<string name="gettingextendedbolusstatus">Getting extended bolus status</string>
|
||||
<string name="gettingbolusstatus">Getting bolus status</string>
|
||||
<string name="gettingtempbasalstatus">Getting temporary basal status</string>
|
||||
<string name="gettingpumpsettings">Getting pump settings</string>
|
||||
<string name="gettingpumptime">Getting pump time</string>
|
||||
<string name="reuse">reuse</string>
|
||||
<string name="wearcontrol_title">Controls from Watch</string>
|
||||
<string name="wearcontrol_summary">Set Temp-Targets and enter Treatments from the watch.</string>
|
||||
|
@ -770,9 +713,6 @@
|
|||
<string name="shortprotein">Pr</string>
|
||||
<string name="shortfat">Fat</string>
|
||||
<string name="active"><![CDATA[<Active>]]></string>
|
||||
<string name="waitingforestimatedbolusend">Waiting for bolus end. Remaining %1$d sec.</string>
|
||||
<string name="processinghistory">Processing event</string>
|
||||
<string name="startingbolus">Starting bolus delivery</string>
|
||||
<string name="executingrightnow">Command is executed right now</string>
|
||||
<string name="pumpdrivercorrected">Pump driver corrected</string>
|
||||
<string name="pump_unreachable">Pump unreachable</string>
|
||||
|
@ -809,7 +749,6 @@
|
|||
<string name="key_carbsReqThreshold" translatable="false">carbsReqThreshold</string>
|
||||
<string name="carbsReqThreshold">Carb suggestion threshold</string>
|
||||
<string name="carbsReqThreshold_summary">When Carbs are suggested, how many carbs will prompt a notification</string>
|
||||
<string name="unsupportedfirmware">Unsupported pump firmware</string>
|
||||
<string name="dexcomg5_xdripupload_title">Send BG data to xDrip+</string>
|
||||
<string name="key_dexcomg5_xdripupload" translatable="false">dexcomg5_xdripupload</string>
|
||||
<string name="dexcomg5_xdripupload_summary">In xDrip+ select 640g/Eversense data source</string>
|
||||
|
@ -871,10 +810,7 @@
|
|||
<string name="extendedbolusdeliveryerror">Extended bolus delivery error</string>
|
||||
<string name="insightpump_shortname">Sight</string>
|
||||
<string name="ago">ago</string>
|
||||
<string name="format_hours">%1$.2f h</string>
|
||||
<string name="format_mins">%1$d mins</string>
|
||||
<string name="format_mins_short">%1$dm</string>
|
||||
<string name="key_enableSMB_always" translatable="false">enableSMB_always</string>
|
||||
<string name="key_enableSMB_always" translatable="false">enableSMB_always</string>
|
||||
<string name="key_enableSMB_with_COB" translatable="false">enableSMB_with_COB</string>
|
||||
<string name="key_enableSMB_with_temptarget" translatable="false">enableSMB_with_temptarget</string>
|
||||
<string name="key_enableSMB_after_carbs" translatable="false">enableSMB_after_carbs</string>
|
||||
|
@ -946,7 +882,6 @@
|
|||
<string name="key_fromNSAreCommingFakedExtendedBoluses" translatable="false">fromNSAreCommingFakedExtendedBoluses</string>
|
||||
<string name="engineering_mode_enabled">Engineering mode enabled</string>
|
||||
<string name="not_eng_mode_or_release">Engineering mode not enabled and not on release branch</string>
|
||||
<string name="pump_basebasalrate">%1$.2fU/h</string>
|
||||
<string name="combo_actvity_reading_basal_profile">Reading basal profile</string>
|
||||
<string name="combo_bolus_rejected_due_to_pump_history_change">The pump history has changed after the bolus calculation was performed. The bolus was not delivered. Please recalculate if a bolus is still needed.</string>
|
||||
<string name="combo_error_updating_treatment_record">Bolus successfully delivered, but adding the treatment entry failed. This can happen if two small boluses of the same size are administered within the last two minutes. Please check the pump history and treatment entries and use the Careportal to add missing entries. Make sure not to add any entries for the exact same minute and same amount.</string>
|
||||
|
@ -995,7 +930,6 @@
|
|||
<string name="food_short">Food</string>
|
||||
<string name="iobcobcalculator" translatable="false">IobCobCalculator</string>
|
||||
<string name="reset">reset</string>
|
||||
<string name="waitingfortimesynchronization">Waiting for time synchronization (%1$d sec)</string>
|
||||
<string name="loopdisconnectedfor">Disconnected (%1$d m)</string>
|
||||
<string name="key_openapssmb_max_iob" translatable="false">openapsmb_max_iob</string>
|
||||
<string name="openapssmb_maxiob_title">Maximum total IOB OpenAPS can\'t go over [U]</string>
|
||||
|
@ -1079,20 +1013,6 @@
|
|||
<string name="request">Request</string>
|
||||
<string name="insulinsourcesetup">Configure Insulin plugin</string>
|
||||
<string name="exit">Exit</string>
|
||||
<string name="danar_useroptions">User options</string>
|
||||
<string name="danar_timedisplay">Display time format</string>
|
||||
<string name="danar_buttonscroll">Button scroll</string>
|
||||
<string name="danar_beep">Beep on button press</string>
|
||||
<string name="danar_pumpalarm">Alarm</string>
|
||||
<string name="danar_pumpalarm_sound">Sound</string>
|
||||
<string name="danar_pumpalarm_vibrate">Vibrate</string>
|
||||
<string name="danar_pumpalarm_both">Both</string>
|
||||
<string name="danar_screentimeout">LCD on time [seconds]</string>
|
||||
<string name="danar_backlight">Backlight on time [seconds]</string>
|
||||
<string name="danar_glucoseunits">Glucose units</string>
|
||||
<string name="danar_shutdown">Shutdown [hours]</string>
|
||||
<string name="danar_lowreservoir">Low reservoir [Units]</string>
|
||||
<string name="danar_saveuseroptions">Save options to pump</string>
|
||||
<string name="option_on">On</string>
|
||||
<string name="option_off">Off</string>
|
||||
<string name="open_navigation">Open navigation</string>
|
||||
|
@ -1118,8 +1038,6 @@
|
|||
<string name="sensitivity_raises_target_summary">When sensitivity is detected, raise the target glucose</string>
|
||||
<string name="combo_invalid_setup">Invalid pump setup, check the docs and verify that the Quick Info menu is named QUICK INFO using the 360 configuration software.</string>
|
||||
<string name="custom">Custom</string>
|
||||
<string name="largetimedifftitle">Large Time Difference</string>
|
||||
<string name="largetimediff">Large time difference:\nTime in pump is off by more than 1.5 hours.\nPlease adjust the time manually on the pump and make sure that reading the history from the pump does not cause unexpected behaviour.\nIf possible, remove the history from the pump before changing the time or disable the closed loop for one DIA after the last wrong history entry but minimum one DIA from now.</string>
|
||||
<string name="key_keep_screen_on" translatable="false">keep_screen_on</string>
|
||||
<string name="careportal_removestartedevents">Clean AndroidAPS started</string>
|
||||
<string name="storedsettingsfound">Stored settings found</string>
|
||||
|
@ -1156,9 +1074,7 @@
|
|||
<string name="loop_openmode_min_change">Minimal request change [%]</string>
|
||||
<string name="loop_openmode_min_change_summary" formatted="false">Open Loop will popup new change request only if change is bigger than this value in %. Default value is 20%</string>
|
||||
<string name="key_short_tabtitles" translatable="false">short_tabtitles</string>
|
||||
<string name="pairfirst">Please pair your pump with your phone!</string>
|
||||
<string name="searching_for_devices">Searching for devices…</string>
|
||||
<string name="please_wait">Please wait…</string>
|
||||
<string name="pairing_completed">Pairing completed</string>
|
||||
<string name="code_compare">Do the codes displayed on this device and on your pump match?</string>
|
||||
<string name="insight_pairing">Insight pairing</string>
|
||||
|
@ -1334,7 +1250,6 @@
|
|||
<string name="very_old_version">very old version</string>
|
||||
<string name="new_version_warning">New version for at least %1$d days available! Fallback to LGS after %2$d days, loop will be disabled after %3$d days</string>
|
||||
<string name="twohours">2h</string>
|
||||
<string name="formatinsulinunits">%1$.2fU</string>
|
||||
|
||||
<string name="dexcom_app_patched">Dexcom App (patched)</string>
|
||||
<string name="dexcom_short">DXCM</string>
|
||||
|
@ -1565,7 +1480,6 @@
|
|||
<string name="insulinFromCob"><![CDATA[COB vs IOB: <font color=\'%1$s\'>%2$+.2fU</font>]]></string>
|
||||
<string name="bolusconstraintappliedwarning"><![CDATA[<font color=\'%1$s\'>Bolus constraint applied: %2$.2fU to %3$.2fU</font>]]></string>
|
||||
<string name="slowabsorptiondetected"><![CDATA[<font color=\'%1$s\'>!!!!! Slow carbs absorption detected: %2$d%% of time. Double check your calculation. COB can be overestimated thus more insulin could be given !!!!!</font>]]></string>
|
||||
<string name="reservoirvalue">%1$.0f / %2$d U</string>
|
||||
<string name="key_boluswizard_percentage" translatable="false">boluswizard_percentage</string>
|
||||
<string name="partialboluswizard">Deliver this part of bolus wizard result [%]</string>
|
||||
<string name="deliverpartofboluswizard">Bolus wizard performs calculation but only this part of calculated insulin is delivered. Useful with SMB algorithm.</string>
|
||||
|
@ -1575,7 +1489,6 @@
|
|||
<string name="timerange_value">Time is between %1$s and %2$s</string>
|
||||
<string name="between">Between </string>
|
||||
|
||||
<string name="close">Close</string>
|
||||
<string name="increasingmaxbasal">Increasing max basal value because setting is lower than your max basal in profile</string>
|
||||
<string name="smscommunicator_messagebody">Invalid message body</string>
|
||||
<string name="format_bg_isf">%1$s ISF: %2$.1f</string>
|
||||
|
@ -1594,7 +1507,6 @@
|
|||
<string name="common_off">Off</string>
|
||||
<string name="objectives_button_unfinish">Clear finished</string>
|
||||
<string name="objectives_button_unstart">Clear started</string>
|
||||
<string name="timedetection">Time detection</string>
|
||||
<string name="doyouwantresetstart">Do you want reset objective start? You may lose your progress.</string>
|
||||
<string name="time_or_timezone_change">Time and/or Timezone change on pump</string>
|
||||
<string name="nopumpselected">No pump selected</string>
|
||||
|
@ -1695,8 +1607,6 @@
|
|||
<string name="press_ok_on_the_pump">Press OK on the pump\nand enter 2 displayed numbers\nKeep display on pump ON by pressing minus button until you finish entering code.</string>
|
||||
<string name="num1pin">1: (12 digits)</string>
|
||||
<string name="num2pin">2: (8 digits)</string>
|
||||
<string name="resetpairing">Reset pairing information?</string>
|
||||
<string name="invalidpairing">Invalid pairing information. Requesting new pairing</string>
|
||||
<string name="onconnect">On connect</string>
|
||||
<string name="ondisconnect">On disconnect</string>
|
||||
<string name="overview_show_predictions">Predictions</string>
|
||||
|
|
|
@ -29,23 +29,18 @@ import java.util.Locale;
|
|||
|
||||
import javax.inject.Inject;
|
||||
|
||||
import info.nightscout.androidaps.MainApp;
|
||||
import info.nightscout.androidaps.R;
|
||||
import info.nightscout.androidaps.core.R;
|
||||
import info.nightscout.androidaps.data.Profile;
|
||||
import info.nightscout.androidaps.db.TDD;
|
||||
import info.nightscout.androidaps.events.EventDanaRSyncStatus;
|
||||
import info.nightscout.androidaps.events.EventPumpStatusChanged;
|
||||
import info.nightscout.androidaps.interfaces.ActivePluginProvider;
|
||||
import info.nightscout.androidaps.interfaces.CommandQueueProvider;
|
||||
import info.nightscout.androidaps.interfaces.DatabaseHelperInterface;
|
||||
import info.nightscout.androidaps.interfaces.ProfileFunction;
|
||||
import info.nightscout.androidaps.logging.AAPSLogger;
|
||||
import info.nightscout.androidaps.plugins.bus.RxBusWrapper;
|
||||
import info.nightscout.androidaps.plugins.configBuilder.ConfigBuilderPlugin;
|
||||
import info.nightscout.androidaps.interfaces.ProfileFunction;
|
||||
import info.nightscout.androidaps.plugins.pump.danaR.DanaRPlugin;
|
||||
import info.nightscout.androidaps.plugins.pump.danaR.events.EventDanaRSyncStatus;
|
||||
import info.nightscout.androidaps.plugins.pump.danaRKorean.DanaRKoreanPlugin;
|
||||
import info.nightscout.androidaps.plugins.pump.danaRS.DanaRSPlugin;
|
||||
import info.nightscout.androidaps.plugins.pump.danaRv2.DanaRv2Plugin;
|
||||
import info.nightscout.androidaps.plugins.pump.insight.LocalInsightPlugin;
|
||||
import info.nightscout.androidaps.plugins.pump.common.defs.PumpType;
|
||||
import info.nightscout.androidaps.queue.Callback;
|
||||
import info.nightscout.androidaps.utils.FabricPrivacy;
|
||||
import info.nightscout.androidaps.utils.SafeParse;
|
||||
|
@ -61,13 +56,8 @@ public class TDDStatsActivity extends NoSplashAppCompatActivity {
|
|||
@Inject SP sp;
|
||||
@Inject ProfileFunction profileFunction;
|
||||
@Inject ActivePluginProvider activePlugin;
|
||||
@Inject DanaRSPlugin danaRSPlugin;
|
||||
@Inject DanaRPlugin danaRPlugin;
|
||||
@Inject DanaRv2Plugin danaRv2Plugin;
|
||||
@Inject DanaRKoreanPlugin danaRKoreanPlugin;
|
||||
@Inject LocalInsightPlugin localInsightPlugin;
|
||||
@Inject ConfigBuilderPlugin configBuilderPlugin;
|
||||
@Inject CommandQueueProvider commandQueue;
|
||||
@Inject DatabaseHelperInterface databaseHelper;
|
||||
@Inject FabricPrivacy fabricPrivacy;
|
||||
|
||||
private CompositeDisposable disposable = new CompositeDisposable();
|
||||
|
@ -300,7 +290,7 @@ public class TDDStatsActivity extends NoSplashAppCompatActivity {
|
|||
}
|
||||
|
||||
private void loadDataFromDB() {
|
||||
historyList = MainApp.getDbHelper().getTDDs();
|
||||
historyList = databaseHelper.getTDDs();
|
||||
|
||||
//only use newest 10
|
||||
historyList = historyList.subList(0, Math.min(10, historyList.size()));
|
||||
|
@ -527,7 +517,8 @@ public class TDDStatsActivity extends NoSplashAppCompatActivity {
|
|||
|
||||
public boolean isOldData(List<TDD> historyList) {
|
||||
|
||||
boolean startsYesterday = danaRPlugin.isEnabled() || danaRSPlugin.isEnabled() || danaRv2Plugin.isEnabled() || danaRKoreanPlugin.isEnabled() || localInsightPlugin.isEnabled();
|
||||
PumpType type = activePlugin.getActivePump().getPumpDescription().pumpType;
|
||||
boolean startsYesterday = type == PumpType.DanaR || type == PumpType.DanaRS || type == PumpType.DanaRv2 || type == PumpType.DanaRKorean || type == PumpType.AccuChekInsight;
|
||||
|
||||
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))))));
|
|
@ -1,4 +1,4 @@
|
|||
package info.nightscout.androidaps.plugins.constraints.objectives.dialogs
|
||||
package info.nightscout.androidaps.dialogs
|
||||
|
||||
import android.os.Bundle
|
||||
import android.os.SystemClock
|
||||
|
@ -6,11 +6,11 @@ import android.view.LayoutInflater
|
|||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import dagger.android.support.DaggerDialogFragment
|
||||
import info.nightscout.androidaps.R
|
||||
import info.nightscout.androidaps.core.R
|
||||
import info.nightscout.androidaps.events.EventNtpStatus
|
||||
import info.nightscout.androidaps.logging.AAPSLogger
|
||||
import info.nightscout.androidaps.logging.LTag
|
||||
import info.nightscout.androidaps.plugins.bus.RxBusWrapper
|
||||
import info.nightscout.androidaps.plugins.constraints.objectives.events.EventNtpStatus
|
||||
import info.nightscout.androidaps.utils.FabricPrivacy
|
||||
import info.nightscout.androidaps.utils.extensions.plusAssign
|
||||
import info.nightscout.androidaps.utils.resources.ResourceHelper
|
|
@ -9,9 +9,9 @@ import android.view.WindowManager
|
|||
import dagger.android.HasAndroidInjector
|
||||
import dagger.android.support.DaggerDialogFragment
|
||||
import info.nightscout.androidaps.Constants
|
||||
import info.nightscout.androidaps.R
|
||||
import info.nightscout.androidaps.core.R
|
||||
import info.nightscout.androidaps.data.Profile
|
||||
import info.nightscout.androidaps.plugins.treatments.TreatmentsPlugin
|
||||
import info.nightscout.androidaps.interfaces.ActivePluginProvider
|
||||
import info.nightscout.androidaps.utils.DateUtil
|
||||
import info.nightscout.androidaps.utils.resources.ResourceHelper
|
||||
import kotlinx.android.synthetic.main.close.*
|
||||
|
@ -22,7 +22,7 @@ import javax.inject.Inject
|
|||
class ProfileViewerDialog : DaggerDialogFragment() {
|
||||
@Inject lateinit var injector: HasAndroidInjector
|
||||
@Inject lateinit var resourceHelper: ResourceHelper
|
||||
@Inject lateinit var treatmentsPlugin: TreatmentsPlugin
|
||||
@Inject lateinit var activePlugin: ActivePluginProvider
|
||||
@Inject lateinit var dateUtil: DateUtil
|
||||
|
||||
private var time: Long = 0
|
||||
|
@ -66,9 +66,9 @@ class ProfileViewerDialog : DaggerDialogFragment() {
|
|||
val date: String?
|
||||
when (mode) {
|
||||
Mode.RUNNING_PROFILE -> {
|
||||
profile = treatmentsPlugin.getProfileSwitchFromHistory(time)?.profileObject
|
||||
profileName = treatmentsPlugin.getProfileSwitchFromHistory(time)?.customizedName
|
||||
date = dateUtil.dateAndTimeString(treatmentsPlugin.getProfileSwitchFromHistory(time)?.date
|
||||
profile = activePlugin.activeTreatments.getProfileSwitchFromHistory(time)?.profileObject
|
||||
profileName = activePlugin.activeTreatments.getProfileSwitchFromHistory(time)?.customizedName
|
||||
date = dateUtil.dateAndTimeString(activePlugin.activeTreatments.getProfileSwitchFromHistory(time)?.date
|
||||
?: 0)
|
||||
profileview_datelayout.visibility = View.VISIBLE
|
||||
}
|
|
@ -1,4 +1,4 @@
|
|||
package info.nightscout.androidaps.plugins.pump.danaR.events
|
||||
package info.nightscout.androidaps.events
|
||||
|
||||
import info.nightscout.androidaps.events.Event
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
package info.nightscout.androidaps.plugins.constraints.objectives.events
|
||||
package info.nightscout.androidaps.events
|
||||
|
||||
import info.nightscout.androidaps.events.Event
|
||||
|
|
@ -1,8 +1,24 @@
|
|||
package info.nightscout.androidaps.interfaces
|
||||
|
||||
import com.j256.ormlite.dao.CloseableIterator
|
||||
import info.nightscout.androidaps.db.BgReading
|
||||
import info.nightscout.androidaps.db.CareportalEvent
|
||||
import info.nightscout.androidaps.db.DanaRHistoryRecord
|
||||
import info.nightscout.androidaps.db.DbRequest
|
||||
import info.nightscout.androidaps.db.TDD
|
||||
|
||||
@Deprecated("Remove with new DB")
|
||||
interface DatabaseHelperInterface {
|
||||
fun getAllBgreadingsDataFromTime(mills : Long, ascending: Boolean): List<BgReading>
|
||||
|
||||
fun getAllBgreadingsDataFromTime(mills: Long, ascending: Boolean): List<BgReading>
|
||||
fun createOrUpdate(careportalEvent: CareportalEvent)
|
||||
fun createOrUpdate(record: DanaRHistoryRecord)
|
||||
fun create(record: DbRequest)
|
||||
fun getDanaRHistoryRecordsByType(type: Byte): List<DanaRHistoryRecord>
|
||||
fun getTDDs(): List<TDD>
|
||||
fun size(table: String) : Long
|
||||
fun deleteAllDbRequests()
|
||||
fun deleteDbRequest(id: String) : Int
|
||||
fun deleteDbRequestbyMongoId(action: String, _id: String)
|
||||
fun getDbRequestInterator() : CloseableIterator<DbRequest>
|
||||
}
|
|
@ -79,7 +79,7 @@ public interface PumpInterface {
|
|||
|
||||
// Status to be passed to NS
|
||||
@NotNull
|
||||
JSONObject getJSONStatus(Profile profile, String profileName);
|
||||
JSONObject getJSONStatus(Profile profile, String profileName, String version);
|
||||
|
||||
@NotNull
|
||||
ManufacturerType manufacturer();
|
||||
|
|
|
@ -18,8 +18,10 @@ import java.util.Date;
|
|||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
|
||||
import javax.inject.Inject;
|
||||
import javax.inject.Singleton;
|
||||
|
||||
import dagger.android.HasAndroidInjector;
|
||||
import info.nightscout.androidaps.core.R;
|
||||
import info.nightscout.androidaps.data.DetailedBolusInfo;
|
||||
import info.nightscout.androidaps.data.IobTotal;
|
||||
|
@ -29,8 +31,10 @@ import info.nightscout.androidaps.db.CareportalEvent;
|
|||
import info.nightscout.androidaps.db.DbRequest;
|
||||
import info.nightscout.androidaps.db.ExtendedBolus;
|
||||
import info.nightscout.androidaps.db.ProfileSwitch;
|
||||
import info.nightscout.androidaps.db.Source;
|
||||
import info.nightscout.androidaps.db.TempTarget;
|
||||
import info.nightscout.androidaps.db.TemporaryBasal;
|
||||
import info.nightscout.androidaps.interfaces.DatabaseHelperInterface;
|
||||
import info.nightscout.androidaps.interfaces.IobCobCalculatorInterface;
|
||||
import info.nightscout.androidaps.interfaces.LoopInterface;
|
||||
import info.nightscout.androidaps.interfaces.ProfileFunction;
|
||||
|
@ -54,24 +58,31 @@ import info.nightscout.androidaps.utils.sharedPreferences.SP;
|
|||
@Singleton
|
||||
public class NSUpload {
|
||||
|
||||
private final HasAndroidInjector injector;
|
||||
private final AAPSLogger aapsLogger;
|
||||
private final ResourceHelper resourceHelper;
|
||||
private final SP sp;
|
||||
private final Context context;
|
||||
private final UploadQueueInterface uploadQueue;
|
||||
private final DatabaseHelperInterface databaseHelper;
|
||||
|
||||
@Inject
|
||||
public NSUpload(
|
||||
HasAndroidInjector injector,
|
||||
AAPSLogger aapsLogger,
|
||||
ResourceHelper resourceHelper,
|
||||
SP sp,
|
||||
Context context,
|
||||
UploadQueueInterface uploadQueue
|
||||
UploadQueueInterface uploadQueue,
|
||||
DatabaseHelperInterface databaseHelper
|
||||
) {
|
||||
this.injector = injector;
|
||||
this.aapsLogger = aapsLogger;
|
||||
this.resourceHelper = resourceHelper;
|
||||
this.sp = sp;
|
||||
this.context = context;
|
||||
this.uploadQueue = uploadQueue;
|
||||
this.databaseHelper = databaseHelper;
|
||||
}
|
||||
|
||||
public void uploadTempBasalStartAbsolute(TemporaryBasal temporaryBasal, Double originalExtendedAmount) {
|
||||
|
@ -179,7 +190,7 @@ public class NSUpload {
|
|||
}
|
||||
}
|
||||
|
||||
public void uploadDeviceStatus(LoopInterface loopPlugin, IobCobCalculatorInterface iobCobCalculatorPlugin, ProfileFunction profileFunction, PumpInterface pumpInterface, ReceiverStatusStore receiverStatusStore) {
|
||||
public void uploadDeviceStatus(LoopInterface loopPlugin, IobCobCalculatorInterface iobCobCalculatorPlugin, ProfileFunction profileFunction, PumpInterface pumpInterface, ReceiverStatusStore receiverStatusStore, String version) {
|
||||
Profile profile = profileFunction.getProfile();
|
||||
String profileName = profileFunction.getProfileName();
|
||||
|
||||
|
@ -230,7 +241,7 @@ public class NSUpload {
|
|||
}
|
||||
}
|
||||
deviceStatus.device = "openaps://" + Build.MANUFACTURER + " " + Build.MODEL;
|
||||
JSONObject pumpstatus = pumpInterface.getJSONStatus(profile, profileName);
|
||||
JSONObject pumpstatus = pumpInterface.getJSONStatus(profile, profileName, version);
|
||||
if (pumpstatus != null) {
|
||||
deviceStatus.pump = pumpstatus;
|
||||
}
|
||||
|
@ -508,4 +519,28 @@ public class NSUpload {
|
|||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
public void generateCareportalEvent(String eventType, long time, String notes) {
|
||||
CareportalEvent careportalEvent = new CareportalEvent(injector);
|
||||
careportalEvent.source = Source.USER;
|
||||
careportalEvent.date = time;
|
||||
careportalEvent.json = generateJson(eventType, time, notes).toString();
|
||||
careportalEvent.eventType = eventType;
|
||||
databaseHelper.createOrUpdate(careportalEvent);
|
||||
uploadEvent(eventType, time, notes);
|
||||
}
|
||||
|
||||
private JSONObject generateJson(String careportalEvent, long time, String notes) {
|
||||
JSONObject data = new JSONObject();
|
||||
try {
|
||||
data.put("eventType", careportalEvent);
|
||||
data.put("created_at", DateUtil.toISOString(time));
|
||||
data.put("mills", time);
|
||||
data.put("enteredBy", sp.getString("careportal_enteredby", "AndroidAPS"));
|
||||
if (!notes.isEmpty()) data.put("notes", notes);
|
||||
} catch (JSONException ignored) {
|
||||
}
|
||||
return data;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -19,7 +19,7 @@ import java.util.concurrent.Executors;
|
|||
import java.util.concurrent.ScheduledExecutorService;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import info.nightscout.androidaps.R;
|
||||
import info.nightscout.androidaps.core.R;
|
||||
|
||||
/**
|
||||
* Created by mike on 28.06.2016.
|
|
@ -2,7 +2,7 @@ package info.nightscout.androidaps.utils
|
|||
|
||||
import android.graphics.Color
|
||||
import android.widget.TextView
|
||||
import info.nightscout.androidaps.R
|
||||
import info.nightscout.androidaps.core.R
|
||||
import info.nightscout.androidaps.db.CareportalEvent
|
||||
import info.nightscout.androidaps.utils.resources.ResourceHelper
|
||||
import javax.inject.Inject
|
19
core/src/main/res/layout/close.xml
Normal file
19
core/src/main/res/layout/close.xml
Normal file
|
@ -0,0 +1,19 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:id="@+id/done_background"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="56dp"
|
||||
android:orientation="horizontal"
|
||||
android:background="@android:color/transparent"
|
||||
android:gravity="end"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:paddingBottom="8dp">
|
||||
|
||||
<Button
|
||||
android:id="@+id/close"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginEnd="16dp"
|
||||
style="@style/mdtp_ActionButton.Text"
|
||||
android:text="@string/close" />
|
||||
</LinearLayout>
|
|
@ -4,6 +4,9 @@
|
|||
<color name="colorPrimaryDark">#000000</color>
|
||||
<color name="colorAccent">#40bbaa</color>
|
||||
|
||||
<!-- Fragments-->
|
||||
<color name="colorInitializingBorder">#00695c</color>
|
||||
|
||||
<!-- Dialogs-->
|
||||
<color name="dialog_title_background">#303030</color>
|
||||
<color name="activity_title_background">#121212</color>
|
||||
|
@ -16,6 +19,7 @@
|
|||
|
||||
<!-- Treatment-->
|
||||
<color name="tempbasal">#C803A9F4</color>
|
||||
<color name="listdelimiter">#505050</color>
|
||||
|
||||
<!-- BgReading-->
|
||||
<color name="inrange">#00FF00</color>
|
||||
|
|
|
@ -31,12 +31,25 @@
|
|||
<string name="goingtodeliver">Going to deliver %1$.2fU</string>
|
||||
<string name="waitingforpump">Waiting for pump</string>
|
||||
<string name="connectingfor">Connecting for %1$d s</string>
|
||||
<string name="bolusdelivering">Delivering %1$.2fU</string>
|
||||
<string name="handshaking">Handshaking</string>
|
||||
<string name="connecting">Connecting</string>
|
||||
<string name="connected">Connected</string>
|
||||
<string name="disconnected">Disconnected</string>
|
||||
<string name="disconnecting">Disconnecting</string>
|
||||
<string name="androidaps_start">AndroidAPS started</string>
|
||||
<string name="formatinsulinunits">%1$.2fU</string>
|
||||
<string name="reservoirvalue">%1$.0f / %2$d U</string>
|
||||
<string name="pump_basebasalrate">%1$.2fU/h</string>
|
||||
<string name="format_hours">%1$.2f h</string>
|
||||
<string name="format_mins">%1$d mins</string>
|
||||
<string name="format_mins_short">%1$dm</string>
|
||||
<string name="pumpbusy">Pump is busy</string>
|
||||
<string name="connectionerror">Pump connection error</string>
|
||||
<string name="youareonallowedlimit">You reached allowed limit</string>
|
||||
<string name="objectives">Objectives</string>
|
||||
<string name="close">Close</string>
|
||||
<string name="please_wait">Please wait…</string>
|
||||
|
||||
<!-- Constraints-->
|
||||
<string name="limitingbasalratio">Limiting max basal rate to %1$.2f U/h because of %2$s</string>
|
||||
|
@ -150,4 +163,23 @@
|
|||
<string name="waitingforpumpresult">Waiting for result</string>
|
||||
<string name="smb_shortname">SMB</string>
|
||||
|
||||
<!-- TDDStatsActivity-->
|
||||
<string name="danar_stats">DanaR Stats</string>
|
||||
<string name="danar_stats_cumulative_tdd">Cumulative TDD</string>
|
||||
<string name="danar_stats_expweight">Exponentially Weighted TDD</string>
|
||||
<string name="danar_stats_basalrate">Basal</string>
|
||||
<string name="danar_stats_bolus">Bolus</string>
|
||||
<string name="danar_stats_tdd">TDD</string>
|
||||
<string name="danar_stats_date">Date</string>
|
||||
<string name="danar_stats_ratio">Ratio</string>
|
||||
<string name="danar_stats_amount_days"># Days</string>
|
||||
<string name="danar_stats_weight">Weight</string>
|
||||
<string name="danar_stats_warning_Message">Possibly inaccurate if using boluses for priming/filling!</string>
|
||||
<string name="danar_stats_olddata_Message">Old Data Please Press "RELOAD"</string>
|
||||
<string name="danar_stats_tbb">Total Base Basal</string>
|
||||
<string name="danar_stats_tbb2">TBB * 2</string>
|
||||
|
||||
<!-- Ntp-->
|
||||
<string name="timedetection">Time detection</string>
|
||||
|
||||
</resources>
|
|
@ -54,9 +54,15 @@ dependencies {
|
|||
implementation "androidx.activity:activity:${activityVersion}"
|
||||
implementation "androidx.activity:activity-ktx:${activityVersion}"
|
||||
|
||||
implementation "io.reactivex.rxjava2:rxandroid:2.1.1"
|
||||
|
||||
implementation 'net.danlew:android.joda:2.10.6'
|
||||
|
||||
// Graphview cannot be upgraded
|
||||
implementation "com.jjoe64:graphview:4.0.1"
|
||||
|
||||
implementation "com.joanzapata.iconify:android-iconify-fontawesome:2.2.2"
|
||||
|
||||
implementation "com.google.dagger:dagger-android:$dagger_version"
|
||||
implementation "com.google.dagger:dagger-android-support:$dagger_version"
|
||||
annotationProcessor "com.google.dagger:dagger-compiler:$dagger_version"
|
||||
|
|
|
@ -7,8 +7,8 @@ import android.view.LayoutInflater
|
|||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import dagger.android.support.DaggerFragment
|
||||
import info.nightscout.androidaps.R
|
||||
import info.nightscout.androidaps.activities.TDDStatsActivity
|
||||
import info.nightscout.androidaps.danars.R
|
||||
import info.nightscout.androidaps.dialogs.ProfileViewerDialog
|
||||
import info.nightscout.androidaps.events.EventExtendedBolusChange
|
||||
import info.nightscout.androidaps.events.EventInitializationChanged
|
||||
|
@ -16,15 +16,14 @@ import info.nightscout.androidaps.events.EventPumpStatusChanged
|
|||
import info.nightscout.androidaps.events.EventTempBasalChange
|
||||
import info.nightscout.androidaps.interfaces.ActivePluginProvider
|
||||
import info.nightscout.androidaps.interfaces.CommandQueueProvider
|
||||
import info.nightscout.androidaps.interfaces.PluginType
|
||||
import info.nightscout.androidaps.interfaces.PumpInterface
|
||||
import info.nightscout.androidaps.logging.AAPSLogger
|
||||
import info.nightscout.androidaps.logging.LTag
|
||||
import info.nightscout.androidaps.plugins.bus.RxBusWrapper
|
||||
import info.nightscout.androidaps.plugins.pump.common.defs.PumpType
|
||||
import info.nightscout.androidaps.plugins.pump.danaR.activities.DanaRHistoryActivity
|
||||
import info.nightscout.androidaps.plugins.pump.danaR.activities.DanaRUserOptionsActivity
|
||||
import info.nightscout.androidaps.plugins.pump.danaR.events.EventDanaRNewStatus
|
||||
import info.nightscout.androidaps.plugins.pump.danaRKorean.DanaRKoreanPlugin
|
||||
import info.nightscout.androidaps.plugins.pump.danaRS.DanaRSPlugin
|
||||
import info.nightscout.androidaps.queue.events.EventQueueChanged
|
||||
import info.nightscout.androidaps.utils.DateUtil
|
||||
|
@ -46,7 +45,6 @@ class DanaRFragment : DaggerFragment() {
|
|||
@Inject lateinit var fabricPrivacy: FabricPrivacy
|
||||
@Inject lateinit var commandQueue: CommandQueueProvider
|
||||
@Inject lateinit var activePlugin: ActivePluginProvider
|
||||
@Inject lateinit var danaRKoreanPlugin: DanaRKoreanPlugin
|
||||
@Inject lateinit var danaRSPlugin: DanaRSPlugin
|
||||
@Inject lateinit var danaRPump: DanaRPump
|
||||
@Inject lateinit var resourceHelper: ResourceHelper
|
||||
|
@ -223,7 +221,7 @@ class DanaRFragment : DaggerFragment() {
|
|||
}
|
||||
//hide user options button if not an RS pump or old firmware
|
||||
// also excludes pump with model 03 because of untested error
|
||||
val isKorean = danaRKoreanPlugin.isEnabled(PluginType.PUMP)
|
||||
val isKorean = activePlugin.activePump.pumpDescription.pumpType == PumpType.DanaRKorean
|
||||
if (isKorean || pump.hwModel == 0 || pump.hwModel == 3) {
|
||||
danar_user_options?.visibility = View.GONE
|
||||
}
|
||||
|
|
|
@ -10,22 +10,21 @@ import android.widget.TextView
|
|||
import androidx.recyclerview.widget.LinearLayoutManager
|
||||
import androidx.recyclerview.widget.RecyclerView
|
||||
import info.nightscout.androidaps.Constants
|
||||
import info.nightscout.androidaps.MainApp
|
||||
import info.nightscout.androidaps.R
|
||||
import info.nightscout.androidaps.activities.NoSplashAppCompatActivity
|
||||
import info.nightscout.androidaps.danars.R
|
||||
import info.nightscout.androidaps.data.Profile
|
||||
import info.nightscout.androidaps.db.DanaRHistoryRecord
|
||||
import info.nightscout.androidaps.events.EventPumpStatusChanged
|
||||
import info.nightscout.androidaps.interfaces.ActivePluginProvider
|
||||
import info.nightscout.androidaps.interfaces.CommandQueueProvider
|
||||
import info.nightscout.androidaps.interfaces.PluginType
|
||||
import info.nightscout.androidaps.interfaces.DatabaseHelperInterface
|
||||
import info.nightscout.androidaps.interfaces.ProfileFunction
|
||||
import info.nightscout.androidaps.logging.AAPSLogger
|
||||
import info.nightscout.androidaps.logging.LTag
|
||||
import info.nightscout.androidaps.plugins.bus.RxBusWrapper
|
||||
import info.nightscout.androidaps.interfaces.ProfileFunction
|
||||
import info.nightscout.androidaps.plugins.pump.common.defs.PumpType
|
||||
import info.nightscout.androidaps.plugins.pump.danaR.comm.RecordTypes
|
||||
import info.nightscout.androidaps.plugins.pump.danaR.events.EventDanaRSyncStatus
|
||||
import info.nightscout.androidaps.plugins.pump.danaRKorean.DanaRKoreanPlugin
|
||||
import info.nightscout.androidaps.plugins.pump.danaRS.DanaRSPlugin
|
||||
import info.nightscout.androidaps.events.EventDanaRSyncStatus
|
||||
import info.nightscout.androidaps.queue.Callback
|
||||
import info.nightscout.androidaps.utils.DateUtil
|
||||
import info.nightscout.androidaps.utils.DecimalFormatter
|
||||
|
@ -44,9 +43,9 @@ class DanaRHistoryActivity : NoSplashAppCompatActivity() {
|
|||
@Inject lateinit var resourceHelper: ResourceHelper
|
||||
@Inject lateinit var profileFunction: ProfileFunction
|
||||
@Inject lateinit var fabricPrivacy: FabricPrivacy
|
||||
@Inject lateinit var danaRKoreanPlugin: DanaRKoreanPlugin
|
||||
@Inject lateinit var danaRSPlugin: DanaRSPlugin
|
||||
@Inject lateinit var activePlugin: ActivePluginProvider
|
||||
@Inject lateinit var commandQueue: CommandQueueProvider
|
||||
@Inject lateinit var databaseHelper: DatabaseHelperInterface
|
||||
@Inject lateinit var dateUtil: DateUtil
|
||||
|
||||
private val disposable = CompositeDisposable()
|
||||
|
@ -87,8 +86,9 @@ class DanaRHistoryActivity : NoSplashAppCompatActivity() {
|
|||
danar_history_recyclerview.adapter = RecyclerViewAdapter(historyList)
|
||||
danar_history_status.visibility = View.GONE
|
||||
|
||||
val isKorean = danaRKoreanPlugin.isEnabled(PluginType.PUMP)
|
||||
val isRS = danaRSPlugin.isEnabled(PluginType.PUMP)
|
||||
val pump = activePlugin.activePump
|
||||
val isKorean = pump.pumpDescription.pumpType == PumpType.DanaRKorean
|
||||
val isRS = pump.pumpDescription.pumpType == PumpType.DanaRS
|
||||
|
||||
// Types
|
||||
val typeList = ArrayList<TypeList>()
|
||||
|
@ -151,7 +151,7 @@ class DanaRHistoryActivity : NoSplashAppCompatActivity() {
|
|||
holder.duration.text = DecimalFormatter.to0Decimal(record.recordDuration.toDouble())
|
||||
holder.alarm.text = record.recordAlarm
|
||||
when (showingType) {
|
||||
RecordTypes.RECORD_TYPE_ALARM -> {
|
||||
RecordTypes.RECORD_TYPE_ALARM -> {
|
||||
holder.time.visibility = View.VISIBLE
|
||||
holder.value.visibility = View.VISIBLE
|
||||
holder.stringValue.visibility = View.GONE
|
||||
|
@ -163,7 +163,7 @@ class DanaRHistoryActivity : NoSplashAppCompatActivity() {
|
|||
holder.alarm.visibility = View.VISIBLE
|
||||
}
|
||||
|
||||
RecordTypes.RECORD_TYPE_BOLUS -> {
|
||||
RecordTypes.RECORD_TYPE_BOLUS -> {
|
||||
holder.time.visibility = View.VISIBLE
|
||||
holder.value.visibility = View.VISIBLE
|
||||
holder.stringValue.visibility = View.GONE
|
||||
|
@ -175,7 +175,7 @@ class DanaRHistoryActivity : NoSplashAppCompatActivity() {
|
|||
holder.alarm.visibility = View.GONE
|
||||
}
|
||||
|
||||
RecordTypes.RECORD_TYPE_DAILY -> {
|
||||
RecordTypes.RECORD_TYPE_DAILY -> {
|
||||
holder.dailyBasal.text = resourceHelper.gs(R.string.formatinsulinunits, record.recordDailyBasal)
|
||||
holder.dailyBolus.text = resourceHelper.gs(R.string.formatinsulinunits, record.recordDailyBolus)
|
||||
holder.dailyTotal.text = resourceHelper.gs(R.string.formatinsulinunits, record.recordDailyBolus + record.recordDailyBasal)
|
||||
|
@ -191,7 +191,7 @@ class DanaRHistoryActivity : NoSplashAppCompatActivity() {
|
|||
holder.alarm.visibility = View.GONE
|
||||
}
|
||||
|
||||
RecordTypes.RECORD_TYPE_GLUCOSE -> {
|
||||
RecordTypes.RECORD_TYPE_GLUCOSE -> {
|
||||
holder.value.text = Profile.toUnitsString(record.recordValue, record.recordValue * Constants.MGDL_TO_MMOLL, profileFunction.getUnits())
|
||||
holder.time.visibility = View.VISIBLE
|
||||
holder.value.visibility = View.VISIBLE
|
||||
|
@ -216,7 +216,7 @@ class DanaRHistoryActivity : NoSplashAppCompatActivity() {
|
|||
holder.alarm.visibility = View.GONE
|
||||
}
|
||||
|
||||
RecordTypes.RECORD_TYPE_SUSPEND -> {
|
||||
RecordTypes.RECORD_TYPE_SUSPEND -> {
|
||||
holder.time.visibility = View.VISIBLE
|
||||
holder.value.visibility = View.GONE
|
||||
holder.stringValue.visibility = View.VISIBLE
|
||||
|
@ -248,7 +248,7 @@ class DanaRHistoryActivity : NoSplashAppCompatActivity() {
|
|||
}
|
||||
|
||||
private fun loadDataFromDB(type: Byte) {
|
||||
historyList = MainApp.getDbHelper().getDanaRHistoryRecordsByType(type)
|
||||
historyList = databaseHelper.getDanaRHistoryRecordsByType(type)
|
||||
runOnUiThread { danar_history_recyclerview?.swapAdapter(RecyclerViewAdapter(historyList), false) }
|
||||
}
|
||||
|
|
@ -1,22 +1,20 @@
|
|||
package info.nightscout.androidaps.plugins.pump.danaR.activities
|
||||
|
||||
import android.content.Context
|
||||
import android.content.Intent
|
||||
import android.os.Bundle
|
||||
import info.nightscout.androidaps.Constants
|
||||
import info.nightscout.androidaps.MainApp
|
||||
import info.nightscout.androidaps.R
|
||||
import info.nightscout.androidaps.activities.ErrorHelperActivity
|
||||
import info.nightscout.androidaps.activities.NoSplashAppCompatActivity
|
||||
import info.nightscout.androidaps.danars.R
|
||||
import info.nightscout.androidaps.events.EventInitializationChanged
|
||||
import info.nightscout.androidaps.interfaces.ActivePluginProvider
|
||||
import info.nightscout.androidaps.interfaces.CommandQueueProvider
|
||||
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.pump.danaR.DanaRPlugin
|
||||
import info.nightscout.androidaps.plugins.pump.common.defs.PumpType
|
||||
import info.nightscout.androidaps.plugins.pump.danaR.DanaRPump
|
||||
import info.nightscout.androidaps.plugins.pump.danaRS.DanaRSPlugin
|
||||
import info.nightscout.androidaps.plugins.pump.danaRv2.DanaRv2Plugin
|
||||
import info.nightscout.androidaps.queue.Callback
|
||||
import info.nightscout.androidaps.utils.FabricPrivacy
|
||||
import info.nightscout.androidaps.utils.extensions.plusAssign
|
||||
|
@ -34,20 +32,17 @@ class DanaRUserOptionsActivity : NoSplashAppCompatActivity() {
|
|||
@Inject lateinit var rxBus: RxBusWrapper
|
||||
@Inject lateinit var fabricPrivacy: FabricPrivacy
|
||||
@Inject lateinit var resourceHelper: ResourceHelper
|
||||
@Inject lateinit var mainApp: MainApp
|
||||
@Inject lateinit var danaRSPlugin: DanaRSPlugin
|
||||
@Inject lateinit var danaRPlugin: DanaRPlugin
|
||||
@Inject lateinit var danaRv2Plugin: DanaRv2Plugin
|
||||
@Inject lateinit var context: Context
|
||||
@Inject lateinit var danaRPump: DanaRPump
|
||||
@Inject lateinit var activePlugin: ActivePluginProvider
|
||||
@Inject lateinit var commandQueue: CommandQueueProvider
|
||||
|
||||
private val disposable = CompositeDisposable()
|
||||
|
||||
// This is for Dana pumps only
|
||||
private fun isRS() = danaRSPlugin.isEnabled(PluginType.PUMP)
|
||||
|
||||
private fun isDanaR() = danaRPlugin.isEnabled(PluginType.PUMP)
|
||||
private fun isDanaRv2() = danaRv2Plugin.isEnabled(PluginType.PUMP)
|
||||
private fun isRS() = activePlugin.activePump.pumpDescription.pumpType == PumpType.DanaRS
|
||||
private fun isDanaR() = activePlugin.activePump.pumpDescription.pumpType == PumpType.DanaR
|
||||
private fun isDanaRv2() = activePlugin.activePump.pumpDescription.pumpType == PumpType.DanaRv2
|
||||
|
||||
@Synchronized
|
||||
override fun onResume() {
|
||||
|
@ -153,12 +148,12 @@ class DanaRUserOptionsActivity : NoSplashAppCompatActivity() {
|
|||
commandQueue.setUserOptions(object : Callback() {
|
||||
override fun run() {
|
||||
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("status", result.comment)
|
||||
i.putExtra("title", resourceHelper.gs(R.string.pumperror))
|
||||
i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
|
||||
mainApp.startActivity(i)
|
||||
context.startActivity(i)
|
||||
}
|
||||
}
|
||||
})
|
|
@ -562,7 +562,7 @@ class DanaRSPlugin @Inject constructor(
|
|||
}
|
||||
}
|
||||
|
||||
override fun getJSONStatus(profile: Profile, profileName: String): JSONObject {
|
||||
override fun getJSONStatus(profile: Profile, profileName: String, version: String): JSONObject {
|
||||
val now = System.currentTimeMillis()
|
||||
if (danaRPump.lastConnection + 5 * 60 * 1000L < System.currentTimeMillis()) {
|
||||
return JSONObject()
|
||||
|
@ -575,7 +575,7 @@ class DanaRSPlugin @Inject constructor(
|
|||
battery.put("percent", danaRPump.batteryRemaining)
|
||||
status.put("status", if (danaRPump.pumpSuspended) "suspended" else "normal")
|
||||
status.put("timestamp", DateUtil.toISOString(danaRPump.lastConnection))
|
||||
extended.put("Version", BuildConfig.VERSION_NAME + "-" + BuildConfig.BUILDVERSION)
|
||||
extended.put("Version", version)
|
||||
if (danaRPump.lastBolusTime != 0L) {
|
||||
extended.put("LastBolus", dateUtil.dateAndTimeString(danaRPump.lastBolusTime))
|
||||
extended.put("LastBolusAmount", danaRPump.lastBolusAmount)
|
||||
|
|
|
@ -3,20 +3,15 @@ package info.nightscout.androidaps.plugins.pump.danaRS.comm;
|
|||
import android.annotation.TargetApi;
|
||||
import android.os.Build;
|
||||
|
||||
import dagger.android.HasAndroidInjector;
|
||||
import info.nightscout.androidaps.MainApp;
|
||||
import info.nightscout.androidaps.logging.AAPSLogger;
|
||||
import info.nightscout.androidaps.logging.LTag;
|
||||
import info.nightscout.androidaps.plugins.pump.danaRS.encryption.BleEncryption;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.Date;
|
||||
|
||||
import javax.inject.Inject;
|
||||
|
||||
import info.nightscout.androidaps.logging.StacktraceLoggerWrapper;
|
||||
import dagger.android.HasAndroidInjector;
|
||||
import info.nightscout.androidaps.logging.AAPSLogger;
|
||||
import info.nightscout.androidaps.logging.LTag;
|
||||
import info.nightscout.androidaps.plugins.pump.danaRS.encryption.BleEncryption;
|
||||
import info.nightscout.androidaps.utils.DateUtil;
|
||||
|
||||
public class DanaRS_Packet {
|
||||
|
|
|
@ -7,11 +7,11 @@ import info.nightscout.androidaps.db.CareportalEvent
|
|||
import info.nightscout.androidaps.db.ExtendedBolus
|
||||
import info.nightscout.androidaps.db.Source
|
||||
import info.nightscout.androidaps.db.TemporaryBasal
|
||||
import info.nightscout.androidaps.dialogs.FillDialog
|
||||
import info.nightscout.androidaps.events.EventPumpStatusChanged
|
||||
import info.nightscout.androidaps.interfaces.ActivePluginProvider
|
||||
import info.nightscout.androidaps.logging.LTag
|
||||
import info.nightscout.androidaps.plugins.bus.RxBusWrapper
|
||||
import info.nightscout.androidaps.plugins.general.nsclient.NSUpload
|
||||
import info.nightscout.androidaps.plugins.pump.common.bolusInfo.DetailedBolusInfoStorage
|
||||
import info.nightscout.androidaps.plugins.pump.danaR.DanaRPump
|
||||
import info.nightscout.androidaps.plugins.pump.danaRS.encryption.BleEncryption
|
||||
|
@ -32,6 +32,7 @@ open class DanaRS_Packet_APS_History_Events(
|
|||
@Inject lateinit var danaRPump: DanaRPump
|
||||
@Inject lateinit var detailedBolusInfoStorage: DetailedBolusInfoStorage
|
||||
@Inject lateinit var sp: SP
|
||||
@Inject lateinit var nsUpload: NSUpload
|
||||
|
||||
private var year = 0
|
||||
private var month = 0
|
||||
|
@ -163,14 +164,14 @@ open class DanaRS_Packet_APS_History_Events(
|
|||
DanaRPump.REFILL -> {
|
||||
aapsLogger.debug(LTag.PUMPCOMM, "EVENT REFILL (" + recordCode + ") " + dateUtil.dateAndTimeString(datetime) + " (" + datetime + ")" + " Amount: " + param1 / 100.0 + "U")
|
||||
if (sp.getBoolean(R.string.key_rs_loginsulinchange, true))
|
||||
FillDialog.generateCareportalEvent(CareportalEvent.INSULINCHANGE, datetime, resourceHelper.gs(R.string.danarspump), resourceHelper, sp, injector)
|
||||
nsUpload.generateCareportalEvent(CareportalEvent.INSULINCHANGE, datetime, resourceHelper.gs(R.string.danarspump))
|
||||
status = "REFILL " + dateUtil.timeString(datetime)
|
||||
}
|
||||
|
||||
DanaRPump.PRIME -> {
|
||||
aapsLogger.debug(LTag.PUMPCOMM, "EVENT PRIME (" + recordCode + ") " + dateUtil.dateAndTimeString(datetime) + " (" + datetime + ")" + " Amount: " + param1 / 100.0 + "U")
|
||||
if (sp.getBoolean(R.string.key_rs_logcanulachange, true))
|
||||
FillDialog.generateCareportalEvent(CareportalEvent.SITECHANGE, datetime, resourceHelper.gs(R.string.danarspump), resourceHelper, sp, injector)
|
||||
nsUpload.generateCareportalEvent(CareportalEvent.SITECHANGE, datetime, resourceHelper.gs(R.string.danarspump))
|
||||
status = "PRIME " + dateUtil.timeString(datetime)
|
||||
}
|
||||
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
package info.nightscout.androidaps.plugins.pump.danaRS.comm
|
||||
|
||||
import dagger.android.HasAndroidInjector
|
||||
import info.nightscout.androidaps.R
|
||||
import info.nightscout.androidaps.danars.R
|
||||
import info.nightscout.androidaps.logging.LTag
|
||||
import info.nightscout.androidaps.plugins.bus.RxBusWrapper
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
package info.nightscout.androidaps.plugins.pump.danaRS.comm
|
||||
|
||||
import dagger.android.HasAndroidInjector
|
||||
import info.nightscout.androidaps.R
|
||||
import info.nightscout.androidaps.danars.R
|
||||
import info.nightscout.androidaps.logging.LTag
|
||||
import info.nightscout.androidaps.plugins.bus.RxBusWrapper
|
||||
import info.nightscout.androidaps.plugins.general.overview.events.EventOverviewBolusProgress
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
package info.nightscout.androidaps.plugins.pump.danaRS.comm
|
||||
|
||||
import dagger.android.HasAndroidInjector
|
||||
import info.nightscout.androidaps.R
|
||||
import info.nightscout.androidaps.danars.R
|
||||
import info.nightscout.androidaps.logging.LTag
|
||||
import info.nightscout.androidaps.plugins.bus.RxBusWrapper
|
||||
import info.nightscout.androidaps.plugins.general.overview.events.EventNewNotification
|
||||
|
|
|
@ -1,12 +1,12 @@
|
|||
package info.nightscout.androidaps.plugins.pump.danaRS.comm
|
||||
|
||||
import dagger.android.HasAndroidInjector
|
||||
import info.nightscout.androidaps.MainApp
|
||||
import info.nightscout.androidaps.db.DanaRHistoryRecord
|
||||
import info.nightscout.androidaps.interfaces.DatabaseHelperInterface
|
||||
import info.nightscout.androidaps.logging.LTag
|
||||
import info.nightscout.androidaps.plugins.bus.RxBusWrapper
|
||||
import info.nightscout.androidaps.plugins.pump.danaR.comm.RecordTypes
|
||||
import info.nightscout.androidaps.plugins.pump.danaR.events.EventDanaRSyncStatus
|
||||
import info.nightscout.androidaps.events.EventDanaRSyncStatus
|
||||
import org.joda.time.DateTime
|
||||
import java.util.*
|
||||
import javax.inject.Inject
|
||||
|
@ -17,6 +17,7 @@ abstract class DanaRS_Packet_History_(
|
|||
) : DanaRS_Packet(injector) {
|
||||
|
||||
@Inject lateinit var rxBus: RxBusWrapper
|
||||
@Inject lateinit var databaseHelper: DatabaseHelperInterface
|
||||
|
||||
protected var year = 0
|
||||
protected var month = 0
|
||||
|
@ -198,7 +199,7 @@ abstract class DanaRS_Packet_History_(
|
|||
danaRHistoryRecord.stringRecordValue = strRecordValue
|
||||
}
|
||||
}
|
||||
MainApp.getDbHelper().createOrUpdate(danaRHistoryRecord)
|
||||
databaseHelper.createOrUpdate(danaRHistoryRecord)
|
||||
rxBus.send(EventDanaRSyncStatus(dateUtil.dateAndTimeString(danaRHistoryRecord.recordDate) + " " + messageType))
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
package info.nightscout.androidaps.plugins.pump.danaRS.comm
|
||||
|
||||
import dagger.android.HasAndroidInjector
|
||||
import info.nightscout.androidaps.R
|
||||
import info.nightscout.androidaps.danars.R
|
||||
import info.nightscout.androidaps.logging.LTag
|
||||
import info.nightscout.androidaps.plugins.bus.RxBusWrapper
|
||||
import info.nightscout.androidaps.plugins.general.nsclient.NSUpload
|
||||
|
@ -17,6 +17,7 @@ class DanaRS_Packet_Notify_Alarm(
|
|||
|
||||
@Inject lateinit var rxBus: RxBusWrapper
|
||||
@Inject lateinit var resourceHelper: ResourceHelper
|
||||
@Inject lateinit var nsUpload: NSUpload
|
||||
|
||||
init {
|
||||
type = BleEncryption.DANAR_PACKET__TYPE_NOTIFY
|
||||
|
@ -57,7 +58,7 @@ class DanaRS_Packet_Notify_Alarm(
|
|||
}
|
||||
val notification = Notification(Notification.USERMESSAGE, errorString, Notification.URGENT)
|
||||
rxBus.send(EventNewNotification(notification))
|
||||
NSUpload.uploadError(errorString)
|
||||
nsUpload.uploadError(errorString)
|
||||
}
|
||||
|
||||
override fun getFriendlyName(): String {
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
package info.nightscout.androidaps.plugins.pump.danaRS.comm
|
||||
|
||||
import dagger.android.HasAndroidInjector
|
||||
import info.nightscout.androidaps.R
|
||||
import info.nightscout.androidaps.danars.R
|
||||
import info.nightscout.androidaps.logging.LTag
|
||||
import info.nightscout.androidaps.plugins.bus.RxBusWrapper
|
||||
import info.nightscout.androidaps.plugins.general.overview.events.EventOverviewBolusProgress
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
package info.nightscout.androidaps.plugins.pump.danaRS.comm
|
||||
|
||||
import dagger.android.HasAndroidInjector
|
||||
import info.nightscout.androidaps.R
|
||||
import info.nightscout.androidaps.danars.R
|
||||
import info.nightscout.androidaps.logging.LTag
|
||||
import info.nightscout.androidaps.plugins.bus.RxBusWrapper
|
||||
import info.nightscout.androidaps.plugins.general.overview.events.EventOverviewBolusProgress
|
||||
|
|
|
@ -6,7 +6,7 @@ import android.content.Intent
|
|||
import android.os.SystemClock
|
||||
import android.util.Base64
|
||||
import dagger.android.HasAndroidInjector
|
||||
import info.nightscout.androidaps.R
|
||||
import info.nightscout.androidaps.danars.R
|
||||
import info.nightscout.androidaps.events.EventPumpStatusChanged
|
||||
import info.nightscout.androidaps.logging.AAPSLogger
|
||||
import info.nightscout.androidaps.logging.LTag
|
||||
|
@ -45,7 +45,8 @@ class BLEComm @Inject internal constructor(
|
|||
private val danaRSMessageHashTable: DanaRSMessageHashTable,
|
||||
private val danaRPump: DanaRPump,
|
||||
private val danaRSPlugin: DanaRSPlugin,
|
||||
private val bleEncryption: BleEncryption
|
||||
private val bleEncryption: BleEncryption,
|
||||
private val nsUpload: NSUpload
|
||||
) {
|
||||
|
||||
companion object {
|
||||
|
@ -481,7 +482,7 @@ class BLEComm @Inject internal constructor(
|
|||
aapsLogger.debug(LTag.PUMPBTCOMM, "<<<<< " + "ENCRYPTION__PUMP_CHECK (PUMP)" + " " + DanaRS_Packet.toHexString(decryptedBuffer))
|
||||
mSendQueue.clear()
|
||||
rxBus.send(EventPumpStatusChanged(EventPumpStatusChanged.Status.DISCONNECTED, resourceHelper.gs(R.string.pumperror)))
|
||||
NSUpload.uploadError(resourceHelper.gs(R.string.pumperror))
|
||||
nsUpload.uploadError(resourceHelper.gs(R.string.pumperror))
|
||||
val n = Notification(Notification.PUMPERROR, resourceHelper.gs(R.string.pumperror), Notification.URGENT)
|
||||
rxBus.send(EventNewNotification(n))
|
||||
// response BUSY: error status
|
||||
|
|
|
@ -10,6 +10,7 @@ import dagger.android.DaggerService
|
|||
import dagger.android.HasAndroidInjector
|
||||
import info.nightscout.androidaps.Constants
|
||||
import info.nightscout.androidaps.activities.ErrorHelperActivity
|
||||
import info.nightscout.androidaps.danars.R
|
||||
import info.nightscout.androidaps.data.Profile
|
||||
import info.nightscout.androidaps.data.PumpEnactResult
|
||||
import info.nightscout.androidaps.db.Treatment
|
||||
|
@ -65,6 +66,7 @@ class DanaRSService : DaggerService() {
|
|||
@Inject lateinit var detailedBolusInfoStorage: DetailedBolusInfoStorage
|
||||
@Inject lateinit var bleComm: BLEComm
|
||||
@Inject lateinit var fabricPrivacy: FabricPrivacy
|
||||
@Inject lateinit var nsUpload: NSUpload
|
||||
@Inject lateinit var dateUtil: DateUtil
|
||||
|
||||
private val disposable = CompositeDisposable()
|
||||
|
@ -192,7 +194,7 @@ class DanaRSService : DaggerService() {
|
|||
if (System.currentTimeMillis() > lastApproachingDailyLimit + 30 * 60 * 1000) {
|
||||
val reportFail = Notification(Notification.APPROACHING_DAILY_LIMIT, resourceHelper.gs(R.string.approachingdailylimit), Notification.URGENT)
|
||||
rxBus.send(EventNewNotification(reportFail))
|
||||
NSUpload.uploadError(resourceHelper.gs(R.string.approachingdailylimit) + ": " + danaRPump.dailyTotalUnits + "/" + danaRPump.maxDailyTotalUnits + "U")
|
||||
nsUpload.uploadError(resourceHelper.gs(R.string.approachingdailylimit) + ": " + danaRPump.dailyTotalUnits + "/" + danaRPump.maxDailyTotalUnits + "U")
|
||||
lastApproachingDailyLimit = System.currentTimeMillis()
|
||||
}
|
||||
}
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue