diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/constraints/objectives/ObjectivesFragment.kt b/app/src/main/java/info/nightscout/androidaps/plugins/constraints/objectives/ObjectivesFragment.kt index db37d92cf5..34aadf84c6 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/constraints/objectives/ObjectivesFragment.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/constraints/objectives/ObjectivesFragment.kt @@ -225,8 +225,9 @@ class ObjectivesFragment : Fragment() { SntpClient.ntpTime(object : SntpClient.Callback() { override fun run() { log.debug("NTP time: $time System time: ${DateUtil.now()}") + SystemClock.sleep(300) if (!networkConnected) { - RxBus.send(EventNtpStatus(MainApp.gs(R.string.notconnected), 100)) + RxBus.send(EventNtpStatus(MainApp.gs(R.string.notconnected), 99)) } else if (success) { if (objective.isCompleted(time)) { objective.accomplishedOn = time @@ -236,10 +237,10 @@ class ObjectivesFragment : Fragment() { SystemClock.sleep(100) scrollToCurrentObjective() } else { - RxBus.send(EventNtpStatus(MainApp.gs(R.string.requirementnotmet), 100)) + RxBus.send(EventNtpStatus(MainApp.gs(R.string.requirementnotmet), 99)) } } else { - RxBus.send(EventNtpStatus(MainApp.gs(R.string.failedretrievetime), 100)) + RxBus.send(EventNtpStatus(MainApp.gs(R.string.failedretrievetime), 99)) } } }, NetworkChangeReceiver.isConnected()) @@ -261,26 +262,29 @@ class ObjectivesFragment : Fragment() { SntpClient.ntpTime(object : SntpClient.Callback() { override fun run() { log.debug("NTP time: $time System time: ${DateUtil.now()}") + SystemClock.sleep(300) if (!networkConnected) { - RxBus.send(EventNtpStatus(MainApp.gs(R.string.notconnected), 100)) + RxBus.send(EventNtpStatus(MainApp.gs(R.string.notconnected), 99)) } else if (success) { - objective.startedOn = time - RxBus.send(EventNtpStatus(MainApp.gs(R.string.success), 100)) - SystemClock.sleep(1000) - RxBus.send(EventObjectivesUpdateGui()) - SystemClock.sleep(100) - scrollToCurrentObjective() + objective.startedOn = time + RxBus.send(EventNtpStatus(MainApp.gs(R.string.success), 100)) + SystemClock.sleep(1000) + RxBus.send(EventObjectivesUpdateGui()) + SystemClock.sleep(100) + scrollToCurrentObjective() } else { - RxBus.send(EventNtpStatus(MainApp.gs(R.string.failedretrievetime), 100)) + RxBus.send(EventNtpStatus(MainApp.gs(R.string.failedretrievetime), 99)) } } }, NetworkChangeReceiver.isConnected()) }.start() } holder.unStart.setOnClickListener { - objective.startedOn = 0 - scrollToCurrentObjective() - RxBus.send(EventObjectivesUpdateGui()) + OKDialog.showConfirmation(activity, MainApp.gs(R.string.doyouwantresetstart)) { + objective.startedOn = 0 + scrollToCurrentObjective() + RxBus.send(EventObjectivesUpdateGui()) + } } holder.unFinish.setOnClickListener { objective.accomplishedOn = 0 diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/constraints/objectives/dialogs/NtpProgressDialog.kt b/app/src/main/java/info/nightscout/androidaps/plugins/constraints/objectives/dialogs/NtpProgressDialog.kt index de5ae50007..cef9bc232a 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/constraints/objectives/dialogs/NtpProgressDialog.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/constraints/objectives/dialogs/NtpProgressDialog.kt @@ -42,6 +42,7 @@ class NtpProgressDialog : DialogFragment() { overview_bolusprogress_status.setText(state) overview_bolusprogress_progressbar.setMax(100) overview_bolusprogress_progressbar.setProgress(percent) + overview_bolusprogress_stop.text = MainApp.gs(R.string.close) } override fun onResume() { diff --git a/app/src/main/java/info/nightscout/androidaps/utils/SntpClient.java b/app/src/main/java/info/nightscout/androidaps/utils/SntpClient.java index fcee3638b9..60de82a93c 100644 --- a/app/src/main/java/info/nightscout/androidaps/utils/SntpClient.java +++ b/app/src/main/java/info/nightscout/androidaps/utils/SntpClient.java @@ -16,12 +16,16 @@ package info.nightscout.androidaps.utils; */ import android.os.SystemClock; -import android.util.Log; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import java.net.DatagramPacket; import java.net.DatagramSocket; import java.net.InetAddress; +import info.nightscout.androidaps.logging.L; + /** * {@hide} *
@@ -35,7 +39,7 @@ import java.net.InetAddress;
*
*/
public class SntpClient {
- private static final String TAG = "SntpClient";
+ private static Logger log = LoggerFactory.getLogger(L.CORE);
//private static final int REFERENCE_TIME_OFFSET = 16;
private static final int ORIGINATE_TIME_OFFSET = 24;
@@ -76,8 +80,10 @@ public class SntpClient {
}
static void doNtpTime(final Callback callback) {
+ log.debug("Time detection started");
callback.success = requestTime("time.google.com", 5000);
callback.time = getNtpTime() + SystemClock.elapsedRealtime() - getNtpTimeReference();
+ log.debug("Time detection ended: " + callback.success + " " + DateUtil.dateAndTimeString(getNtpTime()));
callback.run();
}
@@ -138,7 +144,7 @@ public class SntpClient {
mNtpTimeReference = responseTicks;
mRoundTripTime = roundTripTime;
} catch (Exception e) {
- Log.d(TAG, "request time failed: " + e);
+ log.debug("request time failed: " + e);
return false;
}
diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml
index a842a2e4c1..a0da2038ad 100644
--- a/app/src/main/res/values/strings.xml
+++ b/app/src/main/res/values/strings.xml
@@ -1634,5 +1634,6 @@