From e32801ca6b2e5097c548a0c99bfb4cc463cc7439 Mon Sep 17 00:00:00 2001 From: Milos Kozak Date: Tue, 4 Jun 2019 07:38:17 +0200 Subject: [PATCH] preferences, button --- .../androidaps/activities/PreferencesActivity.java | 2 ++ .../plugins/general/tidepool/TidepoolJavaFragment.java | 5 +++++ .../androidaps/plugins/general/tidepool/TidepoolPlugin.kt | 2 ++ .../androidaps/plugins/general/tidepool/comm/UploadChunk.kt | 3 +-- app/src/main/res/xml/pref_tidepool.xml | 3 ++- 5 files changed, 12 insertions(+), 3 deletions(-) diff --git a/app/src/main/java/info/nightscout/androidaps/activities/PreferencesActivity.java b/app/src/main/java/info/nightscout/androidaps/activities/PreferencesActivity.java index ef2639e9ac..3d065d24d3 100644 --- a/app/src/main/java/info/nightscout/androidaps/activities/PreferencesActivity.java +++ b/app/src/main/java/info/nightscout/androidaps/activities/PreferencesActivity.java @@ -21,6 +21,7 @@ import info.nightscout.androidaps.interfaces.PluginBase; import info.nightscout.androidaps.interfaces.PluginType; import info.nightscout.androidaps.plugins.general.careportal.CareportalPlugin; import info.nightscout.androidaps.plugins.constraints.safety.SafetyPlugin; +import info.nightscout.androidaps.plugins.general.tidepool.TidepoolPlugin; import info.nightscout.androidaps.plugins.insulin.InsulinOrefFreePeakPlugin; import info.nightscout.androidaps.plugins.aps.loop.LoopPlugin; import info.nightscout.androidaps.plugins.general.nsclient.NSClientPlugin; @@ -182,6 +183,7 @@ public class PreferencesActivity extends PreferenceActivity implements SharedPre addPreferencesFromResourceIfEnabled(InsulinOrefFreePeakPlugin.getPlugin(), PluginType.INSULIN); addPreferencesFromResourceIfEnabled(NSClientPlugin.getPlugin(), PluginType.GENERAL); + addPreferencesFromResourceIfEnabled(TidepoolPlugin.INSTANCE, PluginType.GENERAL); addPreferencesFromResourceIfEnabled(SmsCommunicatorPlugin.getPlugin(), PluginType.GENERAL); addPreferencesFromResource(R.xml.pref_others); diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/general/tidepool/TidepoolJavaFragment.java b/app/src/main/java/info/nightscout/androidaps/plugins/general/tidepool/TidepoolJavaFragment.java index 24b465bda6..f9a802ddef 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/general/tidepool/TidepoolJavaFragment.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/general/tidepool/TidepoolJavaFragment.java @@ -10,6 +10,7 @@ import info.nightscout.androidaps.MainApp; import info.nightscout.androidaps.R; import info.nightscout.androidaps.plugins.common.SubscriberFragment; import info.nightscout.androidaps.plugins.general.tidepool.comm.TidepoolUploader; +import info.nightscout.androidaps.plugins.general.tidepool.events.EventTidepoolDoUpload; import info.nightscout.androidaps.plugins.general.tidepool.events.EventTidepoolResetData; public class TidepoolJavaFragment extends SubscriberFragment { @@ -22,6 +23,10 @@ public class TidepoolJavaFragment extends SubscriberFragment { login.setOnClickListener(v -> { TidepoolUploader.INSTANCE.doLogin(); }); + Button uploadnow = view.findViewById(R.id.tidepool_uploadnow); + uploadnow.setOnClickListener(v -> { + MainApp.bus().post(new EventTidepoolDoUpload()); + }); Button removeall = view.findViewById(R.id.tidepool_removeall); removeall.setOnClickListener(v -> { MainApp.bus().post(new EventTidepoolResetData()); diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/general/tidepool/TidepoolPlugin.kt b/app/src/main/java/info/nightscout/androidaps/plugins/general/tidepool/TidepoolPlugin.kt index 8f01ac6b37..330b6ec5a5 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/general/tidepool/TidepoolPlugin.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/general/tidepool/TidepoolPlugin.kt @@ -11,6 +11,7 @@ import info.nightscout.androidaps.interfaces.PluginType import info.nightscout.androidaps.logging.L import info.nightscout.androidaps.plugins.general.tidepool.comm.Session import info.nightscout.androidaps.plugins.general.tidepool.comm.TidepoolUploader +import info.nightscout.androidaps.plugins.general.tidepool.comm.UploadChunk import info.nightscout.androidaps.plugins.general.tidepool.events.EventTidepoolDoUpload import info.nightscout.androidaps.plugins.general.tidepool.events.EventTidepoolResetData import info.nightscout.androidaps.plugins.general.tidepool.utils.RateLimit @@ -70,6 +71,7 @@ object TidepoolPlugin : PluginBase(PluginDescription() session = TidepoolUploader.doLogin() if (session != null) { TidepoolUploader.deleteDataSet(session!!) + SP.putLong(R.string.key_tidepool_last_end, 0) TidepoolUploader.doLogin() } } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/general/tidepool/comm/UploadChunk.kt b/app/src/main/java/info/nightscout/androidaps/plugins/general/tidepool/comm/UploadChunk.kt index bcedcf246d..bcda8af839 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/general/tidepool/comm/UploadChunk.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/general/tidepool/comm/UploadChunk.kt @@ -81,8 +81,7 @@ object UploadChunk { fun setLastEnd(time: Long) { if (time > getLastEnd()) { - //TODO SP.putLong(R.string.key_tidepool_last_end, time) - SP.putLong(R.string.key_tidepool_last_end, 0) + SP.putLong(R.string.key_tidepool_last_end, time) if (L.isEnabled(L.TIDEPOOL)) log.debug("Updating last end to: " + DateUtil.dateAndTimeFullString(time)) } else { if (L.isEnabled(L.TIDEPOOL)) log.debug("Cannot set last end to: " + DateUtil.dateAndTimeFullString(time) + " vs " + DateUtil.dateAndTimeFullString(getLastEnd())) diff --git a/app/src/main/res/xml/pref_tidepool.xml b/app/src/main/res/xml/pref_tidepool.xml index a01b600df1..229b0fa3c0 100644 --- a/app/src/main/res/xml/pref_tidepool.xml +++ b/app/src/main/res/xml/pref_tidepool.xml @@ -30,7 +30,8 @@ android:summary="" android:title="@string/title_tidepool_window_latency" />