From 5dbdd5e4374c97ed18d7ac5a597e141dbd9212ef Mon Sep 17 00:00:00 2001 From: Milos Kozak Date: Thu, 6 Jun 2019 23:25:21 +0200 Subject: [PATCH] layout improvement --- .../tidepool/TidepoolJavaFragment.java | 3 + .../general/tidepool/TidepoolPlugin.kt | 1 - .../general/tidepool/comm/TidepoolUploader.kt | 2 +- .../general/tidepool/comm/UploadChunk.kt | 10 ++- app/src/main/res/layout/tidepool_fragment.xml | 76 +++++++++++-------- 5 files changed, 54 insertions(+), 38 deletions(-) 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 709e2ff834..e0294d2f7b 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 @@ -21,6 +21,7 @@ import info.nightscout.androidaps.utils.SP; public class TidepoolJavaFragment extends SubscriberFragment { private TextView logTextView; + private TextView statusTextView; @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, @@ -43,6 +44,7 @@ public class TidepoolJavaFragment extends SubscriberFragment { }); logTextView = view.findViewById(R.id.tidepool_log); + statusTextView = view.findViewById(R.id.tidepool_status); return view; } @@ -58,6 +60,7 @@ public class TidepoolJavaFragment extends SubscriberFragment { if (activity != null) activity.runOnUiThread(() -> { TidepoolPlugin.INSTANCE.updateLog(); + statusTextView.setText(TidepoolUploader.INSTANCE.getConnectionStatus().name()); logTextView.setText(TidepoolPlugin.INSTANCE.getTextLog()); }); } 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 5a40ec00e4..4941462fd4 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 @@ -37,7 +37,6 @@ object TidepoolPlugin : PluginBase(PluginDescription() private val listLog = ArrayList() var textLog = Html.fromHtml("") - var status = "" var paused: Boolean = false diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/general/tidepool/comm/TidepoolUploader.kt b/app/src/main/java/info/nightscout/androidaps/plugins/general/tidepool/comm/TidepoolUploader.kt index db90f88161..efb57ff783 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/general/tidepool/comm/TidepoolUploader.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/general/tidepool/comm/TidepoolUploader.kt @@ -205,7 +205,7 @@ object TidepoolUploader { } - private fun status(status: String) { + fun status(status: String) { if (L.isEnabled(L.TIDEPOOL)) log.debug("New status: $status") MainApp.bus().post(EventTidepoolStatus(status)) 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 1d620dfc19..b26e0dce78 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 @@ -35,9 +35,9 @@ object UploadChunk { operator fun get(start: Long, end: Long): String { - if (L.isEnabled(L.TIDEPOOL)) log.debug("Syncing data between: " + DateUtil.dateAndTimeFullString(start) + " -> " + DateUtil.dateAndTimeFullString(end)) + if (L.isEnabled(L.TIDEPOOL)) log.debug("Syncing data between: " + DateUtil.dateAndTimeString(start) + " -> " + DateUtil.dateAndTimeString(end)) if (end <= start) { - if (L.isEnabled(L.TIDEPOOL)) log.debug("End is <= start: " + DateUtil.dateAndTimeFullString(start) + " " + DateUtil.dateAndTimeFullString(end)) + if (L.isEnabled(L.TIDEPOOL)) log.debug("End is <= start: " + DateUtil.dateAndTimeString(start) + " " + DateUtil.dateAndTimeString(end)) return "" } if (end - start > MAX_UPLOAD_SIZE) { @@ -64,9 +64,11 @@ object UploadChunk { fun setLastEnd(time: Long) { if (time > getLastEnd()) { SP.putLong(R.string.key_tidepool_last_end, time) - if (L.isEnabled(L.TIDEPOOL)) log.debug("Updating last end to: " + DateUtil.dateAndTimeFullString(time)) + val friendlyEnd = DateUtil.dateAndTimeString(time) + TidepoolUploader.status("Marking uploaded data up to $friendlyEnd") + if (L.isEnabled(L.TIDEPOOL)) log.debug("Updating last end to: " + DateUtil.dateAndTimeString(time)) } else { - if (L.isEnabled(L.TIDEPOOL)) log.debug("Cannot set last end to: " + DateUtil.dateAndTimeFullString(time) + " vs " + DateUtil.dateAndTimeFullString(getLastEnd())) + if (L.isEnabled(L.TIDEPOOL)) log.debug("Cannot set last end to: " + DateUtil.dateAndTimeString(time) + " vs " + DateUtil.dateAndTimeString(getLastEnd())) } } diff --git a/app/src/main/res/layout/tidepool_fragment.xml b/app/src/main/res/layout/tidepool_fragment.xml index 6ba23b2347..6e125eda6f 100644 --- a/app/src/main/res/layout/tidepool_fragment.xml +++ b/app/src/main/res/layout/tidepool_fragment.xml @@ -1,6 +1,5 @@ - - -