From 6c0853d49a8849d9a37211b6ed12ec368d8f0272 Mon Sep 17 00:00:00 2001 From: AdrianLxM Date: Wed, 10 Apr 2019 00:33:05 +0200 Subject: [PATCH 01/42] kotlin support --- app/build.gradle | 7 +++++++ build.gradle | 2 ++ 2 files changed, 9 insertions(+) diff --git a/app/build.gradle b/app/build.gradle index 5cdb5bfd6a..8637ac27d8 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -10,6 +10,8 @@ buildscript { } } apply plugin: "com.android.application" +apply plugin: 'kotlin-android-extensions' +apply plugin: 'kotlin-android' apply plugin: 'com.google.gms.google-services' apply plugin: "io.fabric" apply plugin: "jacoco-android" @@ -27,6 +29,7 @@ ext { repositories { maven { url 'https://maven.fabric.io/public' } jcenter { url "https://jcenter.bintray.com/" } + mavenCentral() } def generateGitBuild = { -> @@ -75,6 +78,9 @@ android { moduleName "BleCommandUtil" } } + kotlinOptions { + jvmTarget = '1.8' + } lintOptions { // TODO remove once wear dependency com.google.android.gms:play-services-wearable:7.3.0 // has been upgraded (requiring significant code changes), which currently fails release @@ -233,6 +239,7 @@ dependencies { androidTestImplementation "org.mockito:mockito-core:2.8.47" androidTestImplementation "com.google.dexmaker:dexmaker:${dexmakerVersion}" androidTestImplementation "com.google.dexmaker:dexmaker-mockito:${dexmakerVersion}" + implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version" } task unzip(type: Copy) { diff --git a/build.gradle b/build.gradle index 57745d34ab..6826c29a13 100644 --- a/build.gradle +++ b/build.gradle @@ -1,6 +1,7 @@ // Top-level build file where you can add configuration options common to all sub-projects/modules. buildscript { + ext.kotlin_version = '1.3.21' repositories { google() jcenter() @@ -16,6 +17,7 @@ buildscript { // in the individual module build.gradle files classpath 'com.jakewharton:butterknife-gradle-plugin:9.0.0-SNAPSHOT' + classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" } } From bd5d31a4a31f290bbba304dd8b321c5b24a161bd Mon Sep 17 00:00:00 2001 From: AdrianLxM Date: Wed, 10 Apr 2019 00:36:02 +0200 Subject: [PATCH 02/42] check version Java -> Kotlin --- .../nightscout/androidaps/MainActivity.java | 4 +- .../versionChecker/VersionCheckerUtils.kt | 63 +++++++++++ .../androidaps/utils/VersionChecker.java | 100 ------------------ 3 files changed, 65 insertions(+), 102 deletions(-) create mode 100644 app/src/main/java/info/nightscout/androidaps/plugins/general/versionChecker/VersionCheckerUtils.kt delete mode 100644 app/src/main/java/info/nightscout/androidaps/utils/VersionChecker.java diff --git a/app/src/main/java/info/nightscout/androidaps/MainActivity.java b/app/src/main/java/info/nightscout/androidaps/MainActivity.java index f441a8b243..7ce5ae2beb 100644 --- a/app/src/main/java/info/nightscout/androidaps/MainActivity.java +++ b/app/src/main/java/info/nightscout/androidaps/MainActivity.java @@ -51,6 +51,7 @@ import info.nightscout.androidaps.interfaces.PluginBase; import info.nightscout.androidaps.logging.L; import info.nightscout.androidaps.plugins.configBuilder.ProfileFunctions; import info.nightscout.androidaps.plugins.general.nsclient.data.NSSettingsStatus; +import info.nightscout.androidaps.plugins.general.versionChecker.VersionCheckerUtilsKt; import info.nightscout.androidaps.setupwizard.SetupWizardActivity; import info.nightscout.androidaps.tabs.TabPageAdapter; import info.nightscout.androidaps.utils.AndroidPermission; @@ -59,7 +60,6 @@ import info.nightscout.androidaps.utils.LocaleHelper; import info.nightscout.androidaps.utils.OKDialog; import info.nightscout.androidaps.utils.PasswordProtection; import info.nightscout.androidaps.utils.SP; -import info.nightscout.androidaps.utils.VersionChecker; public class MainActivity extends AppCompatActivity { private static Logger log = LoggerFactory.getLogger(L.CORE); @@ -115,7 +115,7 @@ public class MainActivity extends AppCompatActivity { public void onPageScrollStateChanged(int state) { } }); - VersionChecker.check(); + VersionCheckerUtilsKt.checkVersion(); FabricPrivacy.setUserStats(); } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/general/versionChecker/VersionCheckerUtils.kt b/app/src/main/java/info/nightscout/androidaps/plugins/general/versionChecker/VersionCheckerUtils.kt new file mode 100644 index 0000000000..e2d79e99a9 --- /dev/null +++ b/app/src/main/java/info/nightscout/androidaps/plugins/general/versionChecker/VersionCheckerUtils.kt @@ -0,0 +1,63 @@ +package info.nightscout.androidaps.plugins.general.versionChecker + +import android.content.Context +import android.net.ConnectivityManager +import info.nightscout.androidaps.BuildConfig +import info.nightscout.androidaps.MainApp +import info.nightscout.androidaps.R +import info.nightscout.androidaps.logging.L +import info.nightscout.androidaps.plugins.general.overview.events.EventNewNotification +import info.nightscout.androidaps.plugins.general.overview.notifications.Notification +import org.apache.http.HttpResponse +import org.apache.http.client.methods.HttpGet +import org.apache.http.impl.client.DefaultHttpClient +import org.slf4j.LoggerFactory +import java.io.IOException +import java.io.InputStream + +// check network connection +fun isConnected(): Boolean { + val connMgr = MainApp.instance().applicationContext.getSystemService(Context.CONNECTIVITY_SERVICE) as ConnectivityManager + return connMgr.activeNetworkInfo?.isConnected ?: false +} + +// convert inputstream to String +@Throws(IOException::class) +fun InputStream.findVersion(): String? { + var version: String? = null + val regex = "(.*)version(.*)\"(((\\d+)\\.)+(\\d+))\"(.*)" + + this.bufferedReader().forEachLine { + if (regex.toRegex().matches(it)) { + version = regex.toRegex().matchEntire(it)?.groupValues?.getOrNull(3) + return@forEachLine + } + } + return version +} + +private val log = LoggerFactory.getLogger(L.CORE) + +@Suppress("DEPRECATION") +fun checkVersion() = if (isConnected()) { + Thread { + try { + val request = HttpGet("https://raw.githubusercontent.com/MilosKozak/AndroidAPS/master/app/build.gradle") + val response: HttpResponse = DefaultHttpClient().execute(request) + val version: String? = response.entity.content?.findVersion() + val comparison = version?.compareTo(BuildConfig.VERSION_NAME.replace("\"", "")) ?: 0 + if (comparison == 0) { + log.debug("Version equal to master of fetch failed") + } else if (comparison > 0) { + log.debug("Version outdated. Found $version") + val notification = Notification(Notification.NEWVERSIONDETECTED, String.format(MainApp.gs(R.string.versionavailable), version.toString()), Notification.LOW) + MainApp.bus().post(EventNewNotification(notification)) + } else { + log.debug("Version newer than master. Are you developer?") + } + } catch (e: IOException) { + log.debug("Github master version check error: $e") + } + }.start() +} else + log.debug("Github master version no checked. No connectivity") \ No newline at end of file diff --git a/app/src/main/java/info/nightscout/androidaps/utils/VersionChecker.java b/app/src/main/java/info/nightscout/androidaps/utils/VersionChecker.java deleted file mode 100644 index fd636b4596..0000000000 --- a/app/src/main/java/info/nightscout/androidaps/utils/VersionChecker.java +++ /dev/null @@ -1,100 +0,0 @@ -package info.nightscout.androidaps.utils; - -import android.net.ConnectivityManager; -import android.net.NetworkInfo; - -import org.apache.http.HttpResponse; -import org.apache.http.client.HttpClient; -import org.apache.http.client.methods.HttpGet; -import org.apache.http.impl.client.DefaultHttpClient; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import java.io.BufferedReader; -import java.io.IOException; -import java.io.InputStream; -import java.io.InputStreamReader; -import java.util.regex.Matcher; -import java.util.regex.Pattern; - -import info.nightscout.androidaps.BuildConfig; -import info.nightscout.androidaps.MainApp; -import info.nightscout.androidaps.R; -import info.nightscout.androidaps.logging.L; -import info.nightscout.androidaps.plugins.general.overview.events.EventNewNotification; -import info.nightscout.androidaps.plugins.general.overview.notifications.Notification; - -import static android.content.Context.CONNECTIVITY_SERVICE; - -public class VersionChecker { - private static Logger log = LoggerFactory.getLogger(L.CORE); - - public static void check() { - if (isConnected()) - new Thread(() -> { - HttpClient client = new DefaultHttpClient(); - HttpGet request = new HttpGet("https://raw.githubusercontent.com/MilosKozak/AndroidAPS/master/app/build.gradle"); - HttpResponse response; - - try { - response = client.execute(request); - InputStream inputStream = response.getEntity().getContent(); - - if (inputStream != null) { - String result = findLine(inputStream); - if (result != null) { - int compare = result.compareTo(BuildConfig.VERSION_NAME.replace("\"", "")); - if (compare == 0) { - log.debug("Version equal to master"); - return; - } else if (compare > 0) { - log.debug("Version outdated. Found " + result); - Notification notification = new Notification(Notification.NEWVERSIONDETECTED, String.format(MainApp.gs(R.string.versionavailable), result), Notification.LOW); - MainApp.bus().post(new EventNewNotification(notification)); - return; - } else { - log.debug("Version newer than master. Are you developer?"); - return; - } - } - } - - log.debug("Github master version not found"); - - } catch (IOException e) { - e.printStackTrace(); - log.debug("Github master version check error"); - } - }).start(); - else - log.debug("Github master version no checked. No connectivity"); - } - - // convert inputstream to String - private static String findLine(InputStream inputStream) throws IOException { - BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(inputStream)); - String line; - String regex = "(.*)version(.*)\"(((\\d+)\\.)+(\\d+))\"(.*)"; - Pattern p = Pattern.compile(regex); - - while ((line = bufferedReader.readLine()) != null) { - Matcher m = p.matcher(line); - if (m.matches()) { - log.debug("+++ " + line); - return m.group(3); - } else { - log.debug("--- " + line); - } - } - inputStream.close(); - return null; - } - - // check network connection - public static boolean isConnected() { - ConnectivityManager connMgr = (ConnectivityManager) MainApp.instance().getApplicationContext().getSystemService(CONNECTIVITY_SERVICE); - NetworkInfo networkInfo = connMgr.getActiveNetworkInfo(); - return networkInfo != null && networkInfo.isConnected(); - } - -} From c34cf576e5f386b3872ecafd34fb41c4ba62aeff Mon Sep 17 00:00:00 2001 From: AdrianLxM Date: Wed, 10 Apr 2019 00:41:48 +0200 Subject: [PATCH 03/42] VersionCheckerPlugin nightly stub --- .../versionChecker/VersionCheckerPlugin.kt | 22 +++++++++++++++++++ app/src/main/res/values/strings.xml | 1 + 2 files changed, 23 insertions(+) create mode 100644 app/src/main/java/info/nightscout/androidaps/plugins/general/versionChecker/VersionCheckerPlugin.kt diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/general/versionChecker/VersionCheckerPlugin.kt b/app/src/main/java/info/nightscout/androidaps/plugins/general/versionChecker/VersionCheckerPlugin.kt new file mode 100644 index 0000000000..99268bcdd9 --- /dev/null +++ b/app/src/main/java/info/nightscout/androidaps/plugins/general/versionChecker/VersionCheckerPlugin.kt @@ -0,0 +1,22 @@ +package info.nightscout.androidaps.plugins.general.versionChecker + +import info.nightscout.androidaps.R +import info.nightscout.androidaps.interfaces.* + +/** + * Usually we would have a class here. + * Instead of having a class we can use an object directly inherited from PluginBase. + * This is a lazy loading singleton only loaded when actually used. + * */ + +object VersionCheckerPlugin : PluginBase(PluginDescription() + .mainType(PluginType.CONSTRAINTS) + .neverVisible(true) + .alwaysEnabled(true) + .showInList(false) + .pluginName(R.string.versionChecker)), ConstraintsInterface { + + override fun isClosedLoopAllowed(value: Constraint): Constraint { + return value + } +} diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 79d626f9be..3d7d2a3c60 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -1326,6 +1326,7 @@ Wrong code. Command cancelled. Not configured Profile switch created + Version Checker %1$d day %1$d days From 85cc61934cc33a7f6316e52d50908918d5dbddeb Mon Sep 17 00:00:00 2001 From: Johannes Mockenhaupt Date: Wed, 10 Apr 2019 14:49:23 +0200 Subject: [PATCH 04/42] add test --- .../VersionCheckerUtilsKtTest.kt | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 app/src/test/java/info/nightscout/androidaps/plugins/general/versionChecker/VersionCheckerUtilsKtTest.kt diff --git a/app/src/test/java/info/nightscout/androidaps/plugins/general/versionChecker/VersionCheckerUtilsKtTest.kt b/app/src/test/java/info/nightscout/androidaps/plugins/general/versionChecker/VersionCheckerUtilsKtTest.kt new file mode 100644 index 0000000000..237012e74c --- /dev/null +++ b/app/src/test/java/info/nightscout/androidaps/plugins/general/versionChecker/VersionCheckerUtilsKtTest.kt @@ -0,0 +1,19 @@ +package info.nightscout.androidaps.plugins.general.versionChecker + +import org.junit.Assert.assertEquals +import org.junit.Test + +class VersionCheckerUtilsKtTest { + @Test + fun findVersionMatches() { + val buildGradle = """blabla + | android { + | aosenuthoae + | } + | version = "2.2.2" + | appName = "Aaoeu" + """.trimMargin() + val detectedVersion: String? = buildGradle.byteInputStream().findVersion() + assertEquals("2.2.2", detectedVersion) + } +} \ No newline at end of file From a33afc99f611cc581251cf4d258da27ef191b606 Mon Sep 17 00:00:00 2001 From: Johannes Mockenhaupt Date: Wed, 10 Apr 2019 14:50:26 +0200 Subject: [PATCH 05/42] JUST PLAYING AROUND --- .../versionChecker/VersionCheckerUtils.kt | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/general/versionChecker/VersionCheckerUtils.kt b/app/src/main/java/info/nightscout/androidaps/plugins/general/versionChecker/VersionCheckerUtils.kt index e2d79e99a9..a7d167d801 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/general/versionChecker/VersionCheckerUtils.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/general/versionChecker/VersionCheckerUtils.kt @@ -24,16 +24,12 @@ fun isConnected(): Boolean { // convert inputstream to String @Throws(IOException::class) fun InputStream.findVersion(): String? { - var version: String? = null - val regex = "(.*)version(.*)\"(((\\d+)\\.)+(\\d+))\"(.*)" - - this.bufferedReader().forEachLine { - if (regex.toRegex().matches(it)) { - version = regex.toRegex().matchEntire(it)?.groupValues?.getOrNull(3) - return@forEachLine - } - } - return version + val regex = "(.*)version(.*)\"(((\\d+)\\.)+(\\d+))\"(.*)".toRegex() + return bufferedReader() + .readLines() + .filter { regex.matches(it) } + .mapNotNull { regex.matchEntire(it)?.groupValues?.getOrNull(3) } + .firstOrNull() } private val log = LoggerFactory.getLogger(L.CORE) From cefee4827bd37d5745b06a515fabe1a958cc7502 Mon Sep 17 00:00:00 2001 From: Johannes Mockenhaupt Date: Wed, 10 Apr 2019 14:58:01 +0200 Subject: [PATCH 06/42] TDDing --- .../VersionCheckerUtilsKtTest.kt | 23 ++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/app/src/test/java/info/nightscout/androidaps/plugins/general/versionChecker/VersionCheckerUtilsKtTest.kt b/app/src/test/java/info/nightscout/androidaps/plugins/general/versionChecker/VersionCheckerUtilsKtTest.kt index 237012e74c..d5af3a9409 100644 --- a/app/src/test/java/info/nightscout/androidaps/plugins/general/versionChecker/VersionCheckerUtilsKtTest.kt +++ b/app/src/test/java/info/nightscout/androidaps/plugins/general/versionChecker/VersionCheckerUtilsKtTest.kt @@ -5,7 +5,7 @@ import org.junit.Test class VersionCheckerUtilsKtTest { @Test - fun findVersionMatches() { + fun findVersionMatchesRegularVersion() { val buildGradle = """blabla | android { | aosenuthoae @@ -16,4 +16,25 @@ class VersionCheckerUtilsKtTest { val detectedVersion: String? = buildGradle.byteInputStream().findVersion() assertEquals("2.2.2", detectedVersion) } + + // 04. Break stuff.mp3 like it's 1999. Again. Pizza delivery! For i c wiener ... + //@Test + fun findVersionMatchesCustomVersion() { + val buildGradle = """blabla + | android { + | aosenuthoae + | } + | version = "2.2.2-nefarious-underground-mod" + | appName = "Aaoeu" + """.trimMargin() + val detectedVersion: String? = buildGradle.byteInputStream().findVersion() + assertEquals("2.2.2", detectedVersion) + } + + @Test + fun findVersionMatchesDoesNotMatchErrorResponse() { + val buildGradle = """Balls! No build.gradle here. Move along""" + val detectedVersion: String? = buildGradle.byteInputStream().findVersion() + assertEquals(null, detectedVersion) + } } \ No newline at end of file From d786a2a89871ce75846bd4e272cea6ef90397226 Mon Sep 17 00:00:00 2001 From: Tebbe Ubben Date: Wed, 10 Apr 2019 16:15:18 +0200 Subject: [PATCH 07/42] Insight: Set SQLite Sequence to current time millis on table creation --- .../java/info/nightscout/androidaps/db/DatabaseHelper.java | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/app/src/main/java/info/nightscout/androidaps/db/DatabaseHelper.java b/app/src/main/java/info/nightscout/androidaps/db/DatabaseHelper.java index c23d797c8c..b024f64711 100644 --- a/app/src/main/java/info/nightscout/androidaps/db/DatabaseHelper.java +++ b/app/src/main/java/info/nightscout/androidaps/db/DatabaseHelper.java @@ -131,6 +131,8 @@ public class DatabaseHelper extends OrmLiteSqliteOpenHelper { TableUtils.createTableIfNotExists(connectionSource, InsightHistoryOffset.class); TableUtils.createTableIfNotExists(connectionSource, InsightBolusID.class); TableUtils.createTableIfNotExists(connectionSource, InsightPumpID.class); + database.execSQL("UPDATE SQLITE_SEQUENCE SET seq = " + System.currentTimeMillis() + " WHERE name = " + DATABASE_INSIGHT_BOLUS_IDS); + database.execSQL("UPDATE SQLITE_SEQUENCE SET seq = " + System.currentTimeMillis() + " WHERE name = " + DATABASE_INSIGHT_PUMP_IDS); } catch (SQLException e) { log.error("Can't create database", e); throw new RuntimeException(e); @@ -151,6 +153,8 @@ public class DatabaseHelper extends OrmLiteSqliteOpenHelper { TableUtils.createTableIfNotExists(connectionSource, InsightHistoryOffset.class); TableUtils.createTableIfNotExists(connectionSource, InsightBolusID.class); TableUtils.createTableIfNotExists(connectionSource, InsightPumpID.class); + database.execSQL("UPDATE SQLITE_SEQUENCE SET seq = " + System.currentTimeMillis() + " WHERE name = " + DATABASE_INSIGHT_BOLUS_IDS); + database.execSQL("UPDATE SQLITE_SEQUENCE SET seq = " + System.currentTimeMillis() + " WHERE name = " + DATABASE_INSIGHT_PUMP_IDS); } else { log.info(DatabaseHelper.class.getName(), "onUpgrade"); TableUtils.dropTable(connectionSource, TempTarget.class, true); From 1286aabb5b9b777557bedfa2c6a837065487afd5 Mon Sep 17 00:00:00 2001 From: Milos Kozak Date: Thu, 11 Apr 2019 10:16:52 +0200 Subject: [PATCH 08/42] log remote --- app/build.gradle | 17 +++++++++++++++++ .../info/nightscout/androidaps/MainApp.java | 2 +- .../general/maintenance/MaintenancePlugin.java | 1 + .../androidaps/utils/FabricPrivacy.java | 9 +++++++++ 4 files changed, 28 insertions(+), 1 deletion(-) diff --git a/app/build.gradle b/app/build.gradle index 2daf1dfc2b..46a2ee19dd 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -45,6 +45,22 @@ def generateGitBuild = { -> return stringBuilder.toString() } +def generateGitRemote = { -> + StringBuilder stringBuilder = new StringBuilder(); + try { + def stdout = new ByteArrayOutputStream() + exec { + commandLine 'git', 'remote', 'get-url', 'origin' + standardOutput = stdout + } + String commitObject = stdout.toString().trim() + stringBuilder.append(commitObject) + } catch (ignored) { + stringBuilder.append('NoGitSystemAvailable') + } + return stringBuilder.toString() +} + def generateDate = { -> StringBuilder stringBuilder = new StringBuilder(); stringBuilder.append((new Date()).format('yyyy.MM.dd-HH:mm')) @@ -67,6 +83,7 @@ android { version "2.2.3-dev" buildConfigField "String", "VERSION", '"' + version + '"' buildConfigField "String", "BUILDVERSION", '"' + generateGitBuild() + '-' + generateDate() + '"' + buildConfigField "String", "REMOTE", '"' + generateGitRemote()+ '"' buildConfigField "String", "HEAD", '"' + generateGitBuild() + '"' testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" // if you change minSdkVersion to less than 11, you need to change executeTask for wear diff --git a/app/src/main/java/info/nightscout/androidaps/MainApp.java b/app/src/main/java/info/nightscout/androidaps/MainApp.java index 8f626365d9..a00f23fc10 100644 --- a/app/src/main/java/info/nightscout/androidaps/MainApp.java +++ b/app/src/main/java/info/nightscout/androidaps/MainApp.java @@ -125,7 +125,6 @@ public class MainApp extends Application { try { if (FabricPrivacy.fabricEnabled()) { Fabric.with(this, new Crashlytics()); - Crashlytics.setString("BUILDVERSION", BuildConfig.BUILDVERSION); } } catch (Exception e) { log.error("Error with Fabric init! " + e); @@ -137,6 +136,7 @@ public class MainApp extends Application { log.info("Version: " + BuildConfig.VERSION_NAME); log.info("BuildVersion: " + BuildConfig.BUILDVERSION); + log.info("Remote: " + BuildConfig.REMOTE); String extFilesDir = LoggerUtils.getLogDirectory(); File engineeringModeSemaphore = new File(extFilesDir, "engineering_mode"); diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/general/maintenance/MaintenancePlugin.java b/app/src/main/java/info/nightscout/androidaps/plugins/general/maintenance/MaintenancePlugin.java index bd5e67345d..35bd9f9d06 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/general/maintenance/MaintenancePlugin.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/general/maintenance/MaintenancePlugin.java @@ -222,6 +222,7 @@ public class MaintenancePlugin extends PluginBase { builder.append("NSCLIENT" + System.lineSeparator()); builder.append("Build: " + BuildConfig.BUILDVERSION + System.lineSeparator()); + builder.append("Remote: " + BuildConfig.REMOTE + System.lineSeparator()); builder.append("Flavor: " + BuildConfig.FLAVOR + BuildConfig.BUILD_TYPE + System.lineSeparator()); builder.append(MainApp.gs(R.string.configbuilder_nightscoutversion_label) + " " + NSSettingsStatus.getInstance().nightscoutVersionName + System.lineSeparator()); if (MainApp.engineeringMode) diff --git a/app/src/main/java/info/nightscout/androidaps/utils/FabricPrivacy.java b/app/src/main/java/info/nightscout/androidaps/utils/FabricPrivacy.java index f375a78910..54f06bfaf0 100644 --- a/app/src/main/java/info/nightscout/androidaps/utils/FabricPrivacy.java +++ b/app/src/main/java/info/nightscout/androidaps/utils/FabricPrivacy.java @@ -111,11 +111,20 @@ public class FabricPrivacy { if (!fabricEnabled()) return; String closedLoopEnabled = MainApp.getConstraintChecker().isClosedLoopAllowed().value() ? "CLOSED_LOOP_ENABLED" : "CLOSED_LOOP_DISABLED"; + // Size is limited to 36 chars + String remote = BuildConfig.REMOTE + .replace("https://","") + .replace("http://","") + .replace(".git", "") + .replace(".com/", ":") + .replace(".org/", ":") + .replace(".net/", ":"); MainApp.getFirebaseAnalytics().setUserProperty("Mode", BuildConfig.APPLICATION_ID + "-" + closedLoopEnabled); MainApp.getFirebaseAnalytics().setUserProperty("Language", LocaleHelper.getLanguage(MainApp.instance())); MainApp.getFirebaseAnalytics().setUserProperty("Version", BuildConfig.VERSION); MainApp.getFirebaseAnalytics().setUserProperty("HEAD", BuildConfig.HEAD); + MainApp.getFirebaseAnalytics().setUserProperty("Remote", remote); if (ConfigBuilderPlugin.getPlugin().getActivePump() != null) MainApp.getFirebaseAnalytics().setUserProperty("Pump", ConfigBuilderPlugin.getPlugin().getActivePump().getClass().getSimpleName()); if (ConfigBuilderPlugin.getPlugin().getActiveAPS() != null) From 04618156cc03c50bf901f0d9d8afb1ca4c9d2168 Mon Sep 17 00:00:00 2001 From: AdrianLxM Date: Thu, 11 Apr 2019 12:43:52 +0200 Subject: [PATCH 09/42] restructure and test version checker --- .../versionChecker/VersionCheckerUtils.kt | 36 +++++--- .../VersionCheckerUtilsKtTest.kt | 88 ++++++++++++++++++- 2 files changed, 108 insertions(+), 16 deletions(-) diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/general/versionChecker/VersionCheckerUtils.kt b/app/src/main/java/info/nightscout/androidaps/plugins/general/versionChecker/VersionCheckerUtils.kt index a7d167d801..c1378451df 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/general/versionChecker/VersionCheckerUtils.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/general/versionChecker/VersionCheckerUtils.kt @@ -23,7 +23,7 @@ fun isConnected(): Boolean { // convert inputstream to String @Throws(IOException::class) -fun InputStream.findVersion(): String? { +inline fun InputStream.findVersion(): String? { val regex = "(.*)version(.*)\"(((\\d+)\\.)+(\\d+))\"(.*)".toRegex() return bufferedReader() .readLines() @@ -41,19 +41,31 @@ fun checkVersion() = if (isConnected()) { val request = HttpGet("https://raw.githubusercontent.com/MilosKozak/AndroidAPS/master/app/build.gradle") val response: HttpResponse = DefaultHttpClient().execute(request) val version: String? = response.entity.content?.findVersion() - val comparison = version?.compareTo(BuildConfig.VERSION_NAME.replace("\"", "")) ?: 0 - if (comparison == 0) { - log.debug("Version equal to master of fetch failed") - } else if (comparison > 0) { - log.debug("Version outdated. Found $version") - val notification = Notification(Notification.NEWVERSIONDETECTED, String.format(MainApp.gs(R.string.versionavailable), version.toString()), Notification.LOW) - MainApp.bus().post(EventNewNotification(notification)) - } else { - log.debug("Version newer than master. Are you developer?") - } + compareWithCurrentVersion(version, BuildConfig.VERSION_NAME) } catch (e: IOException) { log.debug("Github master version check error: $e") } }.start() } else - log.debug("Github master version no checked. No connectivity") \ No newline at end of file + log.debug("Github master version no checked. No connectivity") + +fun compareWithCurrentVersion(newVersion: String?, currentVersion: String) { + val comparison = newVersion?.versionStrip()?.compareTo(currentVersion.versionStrip()) ?: 0 + when { + comparison == 0 -> log.debug("Version equal to master of fetch failed") + comparison > 0 -> { + log.debug("Version ${currentVersion} outdated. Found $newVersion") + val notification = Notification(Notification.NEWVERSIONDETECTED, String.format(MainApp.gs(R.string.versionavailable), newVersion.toString()), Notification.LOW) + MainApp.bus().post(EventNewNotification(notification)) + } + else -> log.debug("Version newer than master. Are you developer?") + } +} + + fun String.versionStrip() = this.mapNotNull { + when (it) { + in '0'..'9' -> it + '.' -> it + else -> null + } + }.joinToString (separator = "") \ No newline at end of file diff --git a/app/src/test/java/info/nightscout/androidaps/plugins/general/versionChecker/VersionCheckerUtilsKtTest.kt b/app/src/test/java/info/nightscout/androidaps/plugins/general/versionChecker/VersionCheckerUtilsKtTest.kt index d5af3a9409..503c8d46be 100644 --- a/app/src/test/java/info/nightscout/androidaps/plugins/general/versionChecker/VersionCheckerUtilsKtTest.kt +++ b/app/src/test/java/info/nightscout/androidaps/plugins/general/versionChecker/VersionCheckerUtilsKtTest.kt @@ -1,8 +1,18 @@ package info.nightscout.androidaps.plugins.general.versionChecker +import com.squareup.otto.Bus +import info.nightscout.androidaps.MainApp +import info.nightscout.androidaps.logging.L import org.junit.Assert.assertEquals import org.junit.Test +import org.junit.runner.RunWith +import org.mockito.ArgumentMatchers +import org.mockito.Mockito.* +import org.powermock.api.mockito.PowerMockito +import org.powermock.core.classloader.annotations.PrepareForTest +import org.powermock.modules.junit4.PowerMockRunner +@RunWith(PowerMockRunner::class) class VersionCheckerUtilsKtTest { @Test fun findVersionMatchesRegularVersion() { @@ -17,9 +27,10 @@ class VersionCheckerUtilsKtTest { assertEquals("2.2.2", detectedVersion) } - // 04. Break stuff.mp3 like it's 1999. Again. Pizza delivery! For i c wiener ... - //@Test - fun findVersionMatchesCustomVersion() { + + // In case we merge a "x.x.x-dev" into master, don't see it as update. + @Test + fun `should return null on non-digit versions on master`() { val buildGradle = """blabla | android { | aosenuthoae @@ -28,7 +39,7 @@ class VersionCheckerUtilsKtTest { | appName = "Aaoeu" """.trimMargin() val detectedVersion: String? = buildGradle.byteInputStream().findVersion() - assertEquals("2.2.2", detectedVersion) + assertEquals(null, detectedVersion) } @Test @@ -37,4 +48,73 @@ class VersionCheckerUtilsKtTest { val detectedVersion: String? = buildGradle.byteInputStream().findVersion() assertEquals(null, detectedVersion) } + + @Test + fun testVersionStrip() { + assertEquals("2.2.2", "2.2.2".versionStrip()) + assertEquals("2.2.2", "2.2.2-dev".versionStrip()) + assertEquals("2.2.2", "2.2.2dev".versionStrip()) + assertEquals("2.2.2", """"2.2.2"""".versionStrip()) + } + + @Test + @PrepareForTest(MainApp::class, L::class) + fun `should find update1`() { + val bus = prepareCompareTests() + compareWithCurrentVersion(newVersion = "2.2.3", currentVersion = "2.2.1") + verify(bus, times(1)).post(any()) + } + + @Test + @PrepareForTest(MainApp::class, L::class) + fun `should find update2`() { + val bus = prepareCompareTests() + compareWithCurrentVersion(newVersion = "2.2.3", currentVersion = "2.2.1-dev") + verify(bus, times(1)).post(any()) + } + + @Test + @PrepareForTest(MainApp::class, L::class) + fun `should find update3`() { + val bus = prepareCompareTests() + compareWithCurrentVersion(newVersion = "2.2.3", currentVersion = "2.1") + verify(bus, times(1)).post(any()) + } + + @Test + @PrepareForTest(MainApp::class, L::class) + fun `should find update4`() { + val bus = prepareCompareTests() + + compareWithCurrentVersion(newVersion = "2.2", currentVersion = "2.1.1") + + verify(bus, times(1)).post(any()) + } + + @Test + @PrepareForTest(MainApp::class, L::class) + fun `should find update5`() { + val bus = prepareCompareTests() + compareWithCurrentVersion(newVersion = "2.2.1", currentVersion = "2.2-dev") + verify(bus, times(1)).post(any()) + } + + @Test + @PrepareForTest(MainApp::class, L::class) + fun `should find update6`() { + val bus = prepareCompareTests() + compareWithCurrentVersion(newVersion = "2.2.1", currentVersion = "2.2dev") + verify(bus, times(1)).post(any()) + } + + + private fun prepareCompareTests(): Bus { + PowerMockito.mockStatic(MainApp::class.java) + val mainApp = mock(MainApp::class.java) + `when`(MainApp.instance()).thenReturn(mainApp) + val bus = mock(Bus::class.java) + `when`(MainApp.bus()).thenReturn(bus) + `when`(MainApp.gs(ArgumentMatchers.anyInt())).thenReturn("some dummy string") + return bus + } } \ No newline at end of file From 64abfa518fc23e7d0eed21ca40d5a5e8bcdc5201 Mon Sep 17 00:00:00 2001 From: Milos Kozak Date: Fri, 12 Apr 2019 11:34:38 +0200 Subject: [PATCH 10/42] New translations strings.xml (Lithuanian) --- app/src/main/res/values-lt/strings.xml | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/app/src/main/res/values-lt/strings.xml b/app/src/main/res/values-lt/strings.xml index 03abb77bc9..11d4733c9b 100644 --- a/app/src/main/res/values-lt/strings.xml +++ b/app/src/main/res/values-lt/strings.xml @@ -9,6 +9,7 @@ Iš naujo nustatyti duomenų bazę Ar tikrai norite iš naujo nustatyti duomenų bazę? Išeiti + Naudoti ištęstinį bolusą >200%% DanaR Bluetooth įrenginys Visada naudoti bazės absoliučias vertes Prašome iš naujo paleisti telefoną arba sistemos nustatymuose iš naujo paleisti AndroidAPS \nkitaip AndroidAPS negalės registruoti prisijungimų (svarbu stebint ir tikrinant, ar algoritmai veikia tinkamai)! @@ -313,6 +314,7 @@ Stop Paspausta STOP Laukiama ryšio su pompa + Bus suleista %1$.2fvv Nustatymai vizualizacijai, monitoringui ir bazės verčių bei koeficientų analizei Įsitikinkite, kad gliukozės duomenys rodomi Nightscout, o pompos insulino duomenys yra įkelti Aktyvuojamas atviras ciklas @@ -335,6 +337,7 @@ Ciklas išjungtas Ciklas įjungtas %1$.2f apribotas iki %2$.2f + Vertė %1$s viršija griežtą limitą Nuotolinis valdymas negalimas Nuotolinis bolusas negalimas. Bandykite vėliau. Norėdami aktyvuoti %1$.2fvv/val bazę, kurios trukmė %2$d min, atsakykite kodu %3$s @@ -461,6 +464,7 @@ Profilis Numatytoji reikšmė: 3 tai pagrindinis OpenAPS saugiklis. Jis apriboja Jūsų valandinę bazę iki trigubos maksimalios valandinės bazės (standartiniu atveju). Jums greičiausiai neprireiks šios reikšmės keisti, tačiau turėtumėte žinoti, kad ji naudojama kaip saugiklis apskaičiuojant \"3x maksimali dienos bazė; 4x dabartinė valandinė bazė\". Numatytoji reikšmė: 4 tai antras pagrindinis OpenAPS saugiklis, apskaičiuojant \"3x maksimali dienos bazė; 4x dabartinė valandinė bazė\". Jis reiškia, kad jūsų valandinė bazė, nepriklausomai nuo to, kokia maksimali valandinė bazė suprogramuota pompoje, negali būti didesnė, nei keturguba dabartinė valandinė bazė. Tai apsaugo Jus nuo pavojingų situacijų, kai nustatoma pernelyg didelė valandinė bazė, pilnai nesuprantant, kaip veikia algoritmas. Numatytoji reikšmė yra 4x; daugumai vartotojų niekada neprireikia šio skaičiaus keisti, o pajutus, kad \"atsitrenkiama\" į saugiklį, rekomenduojama peržiūrėti kitus nustatymus. + Numatytoji reikšmė: 1.2\nTai daugiklis Autosens (ir netrukus Autotune) funkcijoje, kuris nustato 20%% maksimalią ribą iki kurios Autosens gali padidinti valandinę bazę, sumažinti JIF ir tikslinę gliukozės vertę. Numatytoji reikšmė: 0.7\nTai antras daugiklis Autosens funkcijoje, kuris nustato, kad Autosens gali iki minimalios 70 % ribos sumažinti valandinę bazę bei padidinti JIF ir tikslinę gliukozės vertę. Autosens nustatomi tikslai Numatytoji reikšmė: true\nTai suteikia Autosens funkcijai leidimą keisti tikslinės gliukozės vertes, JIF ir valandinę bazę. @@ -473,6 +477,7 @@ Telefono numeris negalioja Neteisingas SMS telefono numeris Kalibravimas + Siųsti kalibraciją %1$.1f į xDrip? xDrip+ neįdiegta Kalibracija nusiųsta į xDrip Kalibracija išsiųsta. xDrip programoje turi būti įgalintas gavimas. @@ -613,6 +618,7 @@ Angliavandenių įsisavinimo parametrai Maksimalus angliavandenių įsisavinimo laikas [h] Laikas, per kurį visi maisto angliavandeniai, tikėtina, bus įsisavinti + Rodyti ištęstinį boliusą kaip %% SAMŽ IAMŽ KAMŽ @@ -725,6 +731,8 @@ Siųsti KG duomenis į xDrip+ Xdrip+ pasirinkite 640g/Eversense duomenų šaltinį NSClient KG + Valandinė bazė pakeista mažiausia palaikoma verte: %1$s + Valandinė bazė pakeista didžiausia palaikoma verte: %1$s KG apskaičiavimas Bolusų AIO apskaičiavimas Bazės AIO apskaičiavimas @@ -742,6 +750,8 @@ Uždaras ciklas aktyvus Maksimalus AIO nustatytas tinkamai KG šaltinis pasirinktas teisingai + Bazės reikšmės nesuderintos su valandomis: %1$s + Netinkamas profilis: %1$s Programuojamas bolusas Atnaujinti Būsena @@ -1083,6 +1093,7 @@ Įrašyti darbo režimo pakeitimus Įrašyti įspėjimus Aktyvuoti LBD emuliaciją + Naudoti ištęstinius bolusus vietoj laikinos bazės, kai viršijama 250%% riba Atjungimo vėlavimas [s] Serijos numeris Išleistos programinės įrangos versija From 59d3c79ed54a638d751e19b86515401edcebb67a Mon Sep 17 00:00:00 2001 From: Johannes Mockenhaupt Date: Sat, 13 Apr 2019 14:13:37 +0200 Subject: [PATCH 11/42] Split up receivers for local BG broadcasts and SMS. Receiving local BG values probably fails silently when SMS permission is not granted (due to SMS plugin not being used). --- app/src/main/AndroidManifest.xml | 39 ++++++++++++------- .../androidaps/receivers/SmsReceiver.java | 3 ++ 2 files changed, 27 insertions(+), 15 deletions(-) create mode 100644 app/src/main/java/info/nightscout/androidaps/receivers/SmsReceiver.java diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 179fc23373..e7ec8493be 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -73,31 +73,40 @@ + + android:name=".receivers.DataReceiver" + android:enabled="true" + android:exported="true"> - - - - + - + - + - - - + + + - + - + + + + + + + + + diff --git a/app/src/main/java/info/nightscout/androidaps/receivers/SmsReceiver.java b/app/src/main/java/info/nightscout/androidaps/receivers/SmsReceiver.java new file mode 100644 index 0000000000..5a0cb6a803 --- /dev/null +++ b/app/src/main/java/info/nightscout/androidaps/receivers/SmsReceiver.java @@ -0,0 +1,3 @@ +package info.nightscout.androidaps.receivers; + +public class SmsReceiver extends DataReceiver {} From 0f6b05206f7f7d8a288a56f497415c3396a23b6e Mon Sep 17 00:00:00 2001 From: Milos Kozak Date: Sat, 13 Apr 2019 21:49:15 +0200 Subject: [PATCH 12/42] clear MidnightTime cache --- .../nightscout/androidaps/utils/MidnightTime.java | 11 ++++++++++- .../nightscout/androidaps/utils/MidnightTimeTest.java | 7 +++++++ 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/info/nightscout/androidaps/utils/MidnightTime.java b/app/src/main/java/info/nightscout/androidaps/utils/MidnightTime.java index 668ca02e96..235bb9c6e9 100644 --- a/app/src/main/java/info/nightscout/androidaps/utils/MidnightTime.java +++ b/app/src/main/java/info/nightscout/androidaps/utils/MidnightTime.java @@ -5,11 +5,13 @@ import android.util.LongSparseArray; import java.util.Calendar; public class MidnightTime { - private static final LongSparseArray times = new LongSparseArray<>(); + static final LongSparseArray times = new LongSparseArray<>(); private static long hits = 0; private static long misses = 0; + private static final int THRESHOLD = 100000; + public static long calc() { Calendar c = Calendar.getInstance(); c.set(Calendar.HOUR_OF_DAY, 0); @@ -36,10 +38,17 @@ public class MidnightTime { m = c.getTimeInMillis(); times.append(time, m); ++misses; + if (times.size() > THRESHOLD) resetCache(); } return m; } + static void resetCache() { + hits = 0; + misses = 0; + times.clear(); + } + public static String log() { return "Hits: " + hits + " misses: " + misses + " stored: " + times.size(); } diff --git a/app/src/test/java/info/nightscout/androidaps/utils/MidnightTimeTest.java b/app/src/test/java/info/nightscout/androidaps/utils/MidnightTimeTest.java index a15efa6c24..823653c5ab 100644 --- a/app/src/test/java/info/nightscout/androidaps/utils/MidnightTimeTest.java +++ b/app/src/test/java/info/nightscout/androidaps/utils/MidnightTimeTest.java @@ -53,6 +53,13 @@ public class MidnightTimeTest { Assert.assertEquals(midnight, MidnightTime.calc(now)); } + @Test + public void resetCache() { + long now = DateUtil.now(); + MidnightTime.calc(now); + MidnightTime.resetCache(); + Assert.assertEquals(0, MidnightTime.times.size()); + } @Test public void log() { long now = DateUtil.now(); From e27f16f5f8b3603fe05ad7d2bdb959c42afd152e Mon Sep 17 00:00:00 2001 From: Johannes Mockenhaupt Date: Sun, 14 Apr 2019 17:55:43 +0200 Subject: [PATCH 13/42] Javadoc. --- app/src/main/AndroidManifest.xml | 2 +- .../info/nightscout/androidaps/receivers/SmsReceiver.java | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index e7ec8493be..3eaa81ba45 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -73,7 +73,7 @@ - + Date: Mon, 15 Apr 2019 08:04:56 +0200 Subject: [PATCH 14/42] testing and SP logic --- .../versionChecker/VersionCheckerUtils.kt | 41 +++++++---- app/src/main/res/values/strings.xml | 1 + .../VersionCheckerUtilsKtTest.kt | 71 +++++++++++++++---- 3 files changed, 86 insertions(+), 27 deletions(-) diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/general/versionChecker/VersionCheckerUtils.kt b/app/src/main/java/info/nightscout/androidaps/plugins/general/versionChecker/VersionCheckerUtils.kt index c1378451df..b8cfa7fffc 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/general/versionChecker/VersionCheckerUtils.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/general/versionChecker/VersionCheckerUtils.kt @@ -8,6 +8,7 @@ import info.nightscout.androidaps.R import info.nightscout.androidaps.logging.L import info.nightscout.androidaps.plugins.general.overview.events.EventNewNotification import info.nightscout.androidaps.plugins.general.overview.notifications.Notification +import info.nightscout.androidaps.utils.SP import org.apache.http.HttpResponse import org.apache.http.client.methods.HttpGet import org.apache.http.impl.client.DefaultHttpClient @@ -50,22 +51,34 @@ fun checkVersion() = if (isConnected()) { log.debug("Github master version no checked. No connectivity") fun compareWithCurrentVersion(newVersion: String?, currentVersion: String) { - val comparison = newVersion?.versionStrip()?.compareTo(currentVersion.versionStrip()) ?: 0 + val comparison: Int? = newVersion?.versionStrip()?.compareTo(currentVersion.versionStrip()) when { - comparison == 0 -> log.debug("Version equal to master of fetch failed") - comparison > 0 -> { - log.debug("Version ${currentVersion} outdated. Found $newVersion") - val notification = Notification(Notification.NEWVERSIONDETECTED, String.format(MainApp.gs(R.string.versionavailable), newVersion.toString()), Notification.LOW) - MainApp.bus().post(EventNewNotification(notification)) - } + comparison == null -> onVersionNotDetectable() + comparison == 0 -> onSameVersionDetected() + comparison > 0 -> onNewVersionDetected(currentVersion = currentVersion, newVersion = newVersion) else -> log.debug("Version newer than master. Are you developer?") } } - fun String.versionStrip() = this.mapNotNull { - when (it) { - in '0'..'9' -> it - '.' -> it - else -> null - } - }.joinToString (separator = "") \ No newline at end of file +fun onSameVersionDetected() { + SP.remove(R.string.key_new_version_available_since) +} + +fun onVersionNotDetectable() { + log.debug("fetch failed, ignore and smartcast to non-null") +} + +fun onNewVersionDetected(currentVersion: String, newVersion: String?) { + log.debug("Version ${currentVersion} outdated. Found $newVersion") + val notification = Notification(Notification.NEWVERSIONDETECTED, String.format(MainApp.gs(R.string.versionavailable), newVersion.toString()), Notification.LOW) + MainApp.bus().post(EventNewNotification(notification)) + SP.putLong(R.string.key_new_version_available_since, System.currentTimeMillis()) +} + +fun String.versionStrip() = this.mapNotNull { + when (it) { + in '0'..'9' -> it + '.' -> it + else -> null + } +}.joinToString(separator = "") \ No newline at end of file diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 3d7d2a3c60..feaab74c41 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -1327,6 +1327,7 @@ Not configured Profile switch created Version Checker + new_version_available_since %1$d day %1$d days diff --git a/app/src/test/java/info/nightscout/androidaps/plugins/general/versionChecker/VersionCheckerUtilsKtTest.kt b/app/src/test/java/info/nightscout/androidaps/plugins/general/versionChecker/VersionCheckerUtilsKtTest.kt index 503c8d46be..b1b62b589d 100644 --- a/app/src/test/java/info/nightscout/androidaps/plugins/general/versionChecker/VersionCheckerUtilsKtTest.kt +++ b/app/src/test/java/info/nightscout/androidaps/plugins/general/versionChecker/VersionCheckerUtilsKtTest.kt @@ -2,7 +2,9 @@ package info.nightscout.androidaps.plugins.general.versionChecker import com.squareup.otto.Bus import info.nightscout.androidaps.MainApp +import info.nightscout.androidaps.R import info.nightscout.androidaps.logging.L +import info.nightscout.androidaps.utils.SP import org.junit.Assert.assertEquals import org.junit.Test import org.junit.runner.RunWith @@ -58,33 +60,33 @@ class VersionCheckerUtilsKtTest { } @Test - @PrepareForTest(MainApp::class, L::class) + @PrepareForTest(MainApp::class, L::class, SP::class) fun `should find update1`() { - val bus = prepareCompareTests() + val bus = prepareBus() compareWithCurrentVersion(newVersion = "2.2.3", currentVersion = "2.2.1") verify(bus, times(1)).post(any()) } @Test - @PrepareForTest(MainApp::class, L::class) + @PrepareForTest(MainApp::class, L::class, SP::class) fun `should find update2`() { - val bus = prepareCompareTests() + val bus = prepareBus() compareWithCurrentVersion(newVersion = "2.2.3", currentVersion = "2.2.1-dev") verify(bus, times(1)).post(any()) } @Test - @PrepareForTest(MainApp::class, L::class) + @PrepareForTest(MainApp::class, L::class, SP::class) fun `should find update3`() { - val bus = prepareCompareTests() + val bus = prepareBus() compareWithCurrentVersion(newVersion = "2.2.3", currentVersion = "2.1") verify(bus, times(1)).post(any()) } @Test - @PrepareForTest(MainApp::class, L::class) + @PrepareForTest(MainApp::class, L::class, SP::class) fun `should find update4`() { - val bus = prepareCompareTests() + val bus = prepareBus() compareWithCurrentVersion(newVersion = "2.2", currentVersion = "2.1.1") @@ -92,29 +94,72 @@ class VersionCheckerUtilsKtTest { } @Test - @PrepareForTest(MainApp::class, L::class) + @PrepareForTest(MainApp::class, L::class, SP::class) fun `should find update5`() { - val bus = prepareCompareTests() + val bus = prepareBus() compareWithCurrentVersion(newVersion = "2.2.1", currentVersion = "2.2-dev") verify(bus, times(1)).post(any()) } @Test - @PrepareForTest(MainApp::class, L::class) + @PrepareForTest(MainApp::class, L::class, SP::class) fun `should find update6`() { - val bus = prepareCompareTests() + val bus = prepareBus() + val sp = prepareSP() compareWithCurrentVersion(newVersion = "2.2.1", currentVersion = "2.2dev") verify(bus, times(1)).post(any()) } + @Test + @PrepareForTest(MainApp::class, L::class, SP::class) + fun `find same version`() { + val buildGradle = """blabla + | android { + | aosenuthoae + | } + | version = "2.2.2" + | appName = "Aaoeu" + """.trimMargin() + val bus = prepareBus() + compareWithCurrentVersion(buildGradle.byteInputStream().findVersion(), currentVersion = "2.2.2") + verify(bus, times(0)).post(any()) + verify(SP, times(1)).remove(R.string.key_new_version_available_since) + } - private fun prepareCompareTests(): Bus { + @Test + @PrepareForTest(MainApp::class, L::class, SP::class) + fun `find higher version`() { + val buildGradle = """blabla + | android { + | aosenuthoae + | } + | version = "3.0" + | appName = "Aaoeu" + """.trimMargin() + val bus = prepareBus() + compareWithCurrentVersion(buildGradle.byteInputStream().findVersion(), currentVersion = "2.2.2") + verify(bus, times(1)).post(any()) + } + + + private fun prepareBus(): Bus { PowerMockito.mockStatic(MainApp::class.java) val mainApp = mock(MainApp::class.java) `when`(MainApp.instance()).thenReturn(mainApp) val bus = mock(Bus::class.java) `when`(MainApp.bus()).thenReturn(bus) `when`(MainApp.gs(ArgumentMatchers.anyInt())).thenReturn("some dummy string") + prepareSP() return bus } + + private fun prepareSP() { + PowerMockito.mockStatic(SP::class.java) + } + + private fun prepareLogging() { + PowerMockito.mockStatic(L::class.java) + `when`(L.isEnabled(any())).thenReturn(true) + } + } \ No newline at end of file From 7e54db64be171c5c8013f5ef2a74ace48ccac5ed Mon Sep 17 00:00:00 2001 From: Milos Kozak Date: Mon, 15 Apr 2019 15:19:19 +0200 Subject: [PATCH 15/42] Glucose logging --- .../androidaps/data/GlucoseStatus.java | 40 ++++++++++++------- .../info/nightscout/androidaps/logging/L.java | 2 + .../androidaps/data/GlucoseStatusTest.java | 2 +- 3 files changed, 29 insertions(+), 15 deletions(-) diff --git a/app/src/main/java/info/nightscout/androidaps/data/GlucoseStatus.java b/app/src/main/java/info/nightscout/androidaps/data/GlucoseStatus.java index d7895e518a..be3e981fb4 100644 --- a/app/src/main/java/info/nightscout/androidaps/data/GlucoseStatus.java +++ b/app/src/main/java/info/nightscout/androidaps/data/GlucoseStatus.java @@ -8,9 +8,8 @@ import org.slf4j.LoggerFactory; import java.util.ArrayList; import java.util.List; -import info.nightscout.androidaps.MainApp; -import info.nightscout.androidaps.R; import info.nightscout.androidaps.db.BgReading; +import info.nightscout.androidaps.logging.L; import info.nightscout.androidaps.plugins.iob.iobCobCalculator.IobCobCalculatorPlugin; import info.nightscout.androidaps.utils.DateUtil; import info.nightscout.androidaps.utils.DecimalFormatter; @@ -30,12 +29,11 @@ public class GlucoseStatus { public long date = 0L; - @Override - public String toString() { - return MainApp.gs(R.string.glucose) + " " + DecimalFormatter.to0Decimal(glucose) + " mg/dl\n" + - MainApp.gs(R.string.delta) + " " + DecimalFormatter.to0Decimal(delta) + " mg/dl\n" + - MainApp.gs(R.string.short_avgdelta) + " " + DecimalFormatter.to2Decimal(short_avgdelta) + " mg/dl\n" + - MainApp.gs(R.string.long_avgdelta) + " " + DecimalFormatter.to2Decimal(long_avgdelta) + " mg/dl"; + public String log() { + return "Glucose: " + DecimalFormatter.to0Decimal(glucose) + " mg/dl " + + "Delta: " + DecimalFormatter.to0Decimal(delta) + " mg/dl" + + "Short avg. delta: " + " " + DecimalFormatter.to2Decimal(short_avgdelta) + " mg/dl " + + "Long avg. delta: " + DecimalFormatter.to2Decimal(long_avgdelta) + " mg/dl"; } public GlucoseStatus() { @@ -64,15 +62,22 @@ public class GlucoseStatus { List data = IobCobCalculatorPlugin.getPlugin().getBgReadings(); - if (data == null) + if (data == null) { + if (L.isEnabled(L.GLUCOSE)) + log.debug("data=null"); return null; + } int sizeRecords = data.size(); if (sizeRecords == 0) { + if (L.isEnabled(L.GLUCOSE)) + log.debug("sizeRecords==0"); return null; } if (data.get(0).date < DateUtil.now() - 7 * 60 * 1000L && !allowOldData) { + if (L.isEnabled(L.GLUCOSE)) + log.debug("olddata"); return null; } @@ -88,13 +93,15 @@ public class GlucoseStatus { status.long_avgdelta = 0d; status.avgdelta = 0d; // for OpenAPS MA status.date = now_date; + if (L.isEnabled(L.GLUCOSE)) + log.debug("sizeRecords==1"); return status.round(); } - ArrayList now_value_list = new ArrayList(); - ArrayList last_deltas = new ArrayList(); - ArrayList short_deltas = new ArrayList(); - ArrayList long_deltas = new ArrayList(); + ArrayList now_value_list = new ArrayList<>(); + ArrayList last_deltas = new ArrayList<>(); + ArrayList short_deltas = new ArrayList<>(); + ArrayList long_deltas = new ArrayList<>(); // Use the latest sgv value in the now calculations now_value_list.add(now.value); @@ -103,7 +110,7 @@ public class GlucoseStatus { if (data.get(i).value > 38) { BgReading then = data.get(i); long then_date = then.date; - double avgdelta = 0; + double avgdelta; long minutesago; minutesago = Math.round((now_date - then_date) / (1000d * 60)); @@ -111,6 +118,9 @@ public class GlucoseStatus { change = now.value - then.value; avgdelta = change / minutesago * 5; + if (L.isEnabled(L.GLUCOSE)) + log.debug(then.toString() + " minutesago=" + minutesago + " avgdelta=" + avgdelta); + // use the average of all data points in the last 2.5m for all further "now" calculations if (0 < minutesago && minutesago < 2.5) { // Keep and average all values within the last 2.5 minutes @@ -149,6 +159,8 @@ public class GlucoseStatus { status.long_avgdelta = average(long_deltas); status.avgdelta = status.short_avgdelta; // for OpenAPS MA + if (L.isEnabled(L.GLUCOSE)) + log.debug(status.log()); return status.round(); } diff --git a/app/src/main/java/info/nightscout/androidaps/logging/L.java b/app/src/main/java/info/nightscout/androidaps/logging/L.java index 583969c739..f685bbd424 100644 --- a/app/src/main/java/info/nightscout/androidaps/logging/L.java +++ b/app/src/main/java/info/nightscout/androidaps/logging/L.java @@ -78,6 +78,7 @@ public class L { public static final String CORE = "CORE"; public static final String AUTOSENS = "AUTOSENS"; public static final String EVENTS = "EVENTS"; + public static final String GLUCOSE = "GLUCOSE"; public static final String BGSOURCE = "BGSOURCE"; public static final String OVERVIEW = "OVERVIEW"; public static final String NOTIFICATION = "NOTIFICATION"; @@ -102,6 +103,7 @@ public class L { logElements.add(new LogElement(APS, true)); logElements.add(new LogElement(AUTOSENS, false)); logElements.add(new LogElement(BGSOURCE, true)); + logElements.add(new LogElement(GLUCOSE, false)); logElements.add(new LogElement(CONFIGBUILDER, false)); logElements.add(new LogElement(CONSTRAINTS, true)); logElements.add(new LogElement(CORE, true)); diff --git a/app/src/test/java/info/nightscout/androidaps/data/GlucoseStatusTest.java b/app/src/test/java/info/nightscout/androidaps/data/GlucoseStatusTest.java index b7a1d8b0b2..8bcdf0ed26 100644 --- a/app/src/test/java/info/nightscout/androidaps/data/GlucoseStatusTest.java +++ b/app/src/test/java/info/nightscout/androidaps/data/GlucoseStatusTest.java @@ -36,7 +36,7 @@ public class GlucoseStatusTest { @Test public void toStringShouldBeOverloaded() { GlucoseStatus glucoseStatus = new GlucoseStatus(); - Assert.assertEquals(true, glucoseStatus.toString().contains("Delta")); + Assert.assertEquals(true, glucoseStatus.log().contains("Delta")); } @Test From be252c937417939f1661bc5db9e1fc5bc315dde7 Mon Sep 17 00:00:00 2001 From: Milos Kozak Date: Mon, 15 Apr 2019 16:47:42 +0200 Subject: [PATCH 16/42] Clear basalDataTable on significant change --- .../plugins/iob/iobCobCalculator/IobCobCalculatorPlugin.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/iob/iobCobCalculator/IobCobCalculatorPlugin.java b/app/src/main/java/info/nightscout/androidaps/plugins/iob/iobCobCalculator/IobCobCalculatorPlugin.java index 39982010ae..4897ff55ac 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/iob/iobCobCalculator/IobCobCalculatorPlugin.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/iob/iobCobCalculator/IobCobCalculatorPlugin.java @@ -630,6 +630,7 @@ public class IobCobCalculatorPlugin extends PluginBase { log.debug("Invalidating cached data because of new profile. IOB: " + iobTable.size() + " Autosens: " + autosensDataTable.size() + " records"); iobTable = new LongSparseArray<>(); autosensDataTable = new LongSparseArray<>(); + basalDataTable = new LongSparseArray<>(); } runCalculation("onNewProfile", System.currentTimeMillis(), false, true, ev); } @@ -652,9 +653,10 @@ public class IobCobCalculatorPlugin extends PluginBase { stopCalculation("onEventPreferenceChange"); synchronized (dataLock) { if (L.isEnabled(L.AUTOSENS)) - log.debug("Invalidating cached data because of preference change. IOB: " + iobTable.size() + " Autosens: " + autosensDataTable.size() + " records"); + log.debug("Invalidating cached data because of preference change. IOB: " + iobTable.size() + " Autosens: " + autosensDataTable.size() + " records" + " BasalData: " + basalDataTable.size() + " records"); iobTable = new LongSparseArray<>(); autosensDataTable = new LongSparseArray<>(); + basalDataTable = new LongSparseArray<>(); } runCalculation("onEventPreferenceChange", System.currentTimeMillis(), false, true, ev); } @@ -730,6 +732,7 @@ public class IobCobCalculatorPlugin extends PluginBase { log.debug("Clearing cached data."); iobTable = new LongSparseArray<>(); autosensDataTable = new LongSparseArray<>(); + basalDataTable = new LongSparseArray<>(); } } From 76932d68995678012aed7af363704f0bb53d7e54 Mon Sep 17 00:00:00 2001 From: Milos Kozak Date: Mon, 15 Apr 2019 16:48:18 +0200 Subject: [PATCH 17/42] EventProfileSwitchChange -> EventProfileNeedsUpdate --- .../java/info/nightscout/androidaps/db/DatabaseHelper.java | 6 +++--- ...ofileSwitchChange.java => EventProfileNeedsUpdate.java} | 2 +- .../androidaps/plugins/configBuilder/ProfileFunctions.java | 7 ++++--- .../plugins/general/overview/OverviewFragment.java | 6 +++--- .../plugins/pump/danaR/services/DanaRExecutionService.java | 4 ++-- .../danaRKorean/services/DanaRKoreanExecutionService.java | 4 ++-- .../plugins/pump/danaRS/services/DanaRSService.java | 4 ++-- .../pump/danaRv2/services/DanaRv2ExecutionService.java | 4 ++-- .../fragments/TreatmentsProfileSwitchFragment.java | 4 ++-- .../info/nightscout/androidaps/queue/CommandQueue.java | 4 ++-- .../nightscout/androidaps/receivers/KeepAliveReceiver.java | 4 ++-- .../androidaps/setupwizard/SetupWizardActivity.java | 4 ++-- 12 files changed, 27 insertions(+), 26 deletions(-) rename app/src/main/java/info/nightscout/androidaps/events/{EventProfileSwitchChange.java => EventProfileNeedsUpdate.java} (62%) diff --git a/app/src/main/java/info/nightscout/androidaps/db/DatabaseHelper.java b/app/src/main/java/info/nightscout/androidaps/db/DatabaseHelper.java index c23d797c8c..a41939b326 100644 --- a/app/src/main/java/info/nightscout/androidaps/db/DatabaseHelper.java +++ b/app/src/main/java/info/nightscout/androidaps/db/DatabaseHelper.java @@ -35,7 +35,7 @@ import info.nightscout.androidaps.data.ProfileStore; import info.nightscout.androidaps.events.EventCareportalEventChange; import info.nightscout.androidaps.events.EventExtendedBolusChange; import info.nightscout.androidaps.events.EventNewBG; -import info.nightscout.androidaps.events.EventProfileSwitchChange; +import info.nightscout.androidaps.events.EventProfileNeedsUpdate; import info.nightscout.androidaps.events.EventRefreshOverview; import info.nightscout.androidaps.events.EventReloadProfileSwitchData; import info.nightscout.androidaps.events.EventReloadTempBasalData; @@ -1574,9 +1574,9 @@ public class DatabaseHelper extends OrmLiteSqliteOpenHelper { class PostRunnable implements Runnable { public void run() { if (L.isEnabled(L.DATABASE)) - log.debug("Firing EventProfileSwitchChange"); + log.debug("Firing EventProfileNeedsUpdate"); MainApp.bus().post(new EventReloadProfileSwitchData()); - MainApp.bus().post(new EventProfileSwitchChange()); + MainApp.bus().post(new EventProfileNeedsUpdate()); scheduledProfileSwitchEventPost = null; } } diff --git a/app/src/main/java/info/nightscout/androidaps/events/EventProfileSwitchChange.java b/app/src/main/java/info/nightscout/androidaps/events/EventProfileNeedsUpdate.java similarity index 62% rename from app/src/main/java/info/nightscout/androidaps/events/EventProfileSwitchChange.java rename to app/src/main/java/info/nightscout/androidaps/events/EventProfileNeedsUpdate.java index 7bab9d4518..9e3f3b08c7 100644 --- a/app/src/main/java/info/nightscout/androidaps/events/EventProfileSwitchChange.java +++ b/app/src/main/java/info/nightscout/androidaps/events/EventProfileNeedsUpdate.java @@ -4,5 +4,5 @@ package info.nightscout.androidaps.events; * Created by mike on 02.06.2017. */ -public class EventProfileSwitchChange extends Event { +public class EventProfileNeedsUpdate extends Event { } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/configBuilder/ProfileFunctions.java b/app/src/main/java/info/nightscout/androidaps/plugins/configBuilder/ProfileFunctions.java index ba7a245269..0360ba4a68 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/configBuilder/ProfileFunctions.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/configBuilder/ProfileFunctions.java @@ -19,7 +19,7 @@ import info.nightscout.androidaps.data.ProfileStore; import info.nightscout.androidaps.db.ProfileSwitch; import info.nightscout.androidaps.db.Source; import info.nightscout.androidaps.events.EventNewBasalProfile; -import info.nightscout.androidaps.events.EventProfileSwitchChange; +import info.nightscout.androidaps.events.EventProfileNeedsUpdate; import info.nightscout.androidaps.interfaces.ProfileInterface; import info.nightscout.androidaps.interfaces.TreatmentsInterface; import info.nightscout.androidaps.logging.L; @@ -48,7 +48,7 @@ public class ProfileFunctions { } @Subscribe - public void onProfileSwitch(EventProfileSwitchChange ignored) { + public void onProfileSwitch(EventProfileNeedsUpdate ignored) { if (L.isEnabled(L.PROFILE)) log.debug("onProfileSwitch"); ConfigBuilderPlugin.getPlugin().getCommandQueue().setProfile(getProfile(), new Callback() { @@ -62,7 +62,8 @@ public class ProfileFunctions { i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); MainApp.instance().startActivity(i); } - MainApp.bus().post(new EventNewBasalProfile()); + if (result.enacted) + MainApp.bus().post(new EventNewBasalProfile()); } }); } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/general/overview/OverviewFragment.java b/app/src/main/java/info/nightscout/androidaps/plugins/general/overview/OverviewFragment.java index d8a7c82cf7..c4d8655ca8 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/general/overview/OverviewFragment.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/general/overview/OverviewFragment.java @@ -72,7 +72,7 @@ import info.nightscout.androidaps.events.EventCareportalEventChange; import info.nightscout.androidaps.events.EventExtendedBolusChange; import info.nightscout.androidaps.events.EventInitializationChanged; import info.nightscout.androidaps.events.EventPreferenceChange; -import info.nightscout.androidaps.events.EventProfileSwitchChange; +import info.nightscout.androidaps.events.EventProfileNeedsUpdate; import info.nightscout.androidaps.events.EventPumpStatusChanged; import info.nightscout.androidaps.events.EventRefreshOverview; import info.nightscout.androidaps.events.EventTempBasalChange; @@ -982,8 +982,8 @@ public class OverviewFragment extends Fragment implements View.OnClickListener, } @Subscribe - public void onStatusEvent(final EventProfileSwitchChange ev) { - scheduleUpdateGUI("EventProfileSwitchChange"); + public void onStatusEvent(final EventProfileNeedsUpdate ev) { + scheduleUpdateGUI("EventProfileNeedsUpdate"); } @Subscribe diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaR/services/DanaRExecutionService.java b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaR/services/DanaRExecutionService.java index 2d636037c6..22d98368a6 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaR/services/DanaRExecutionService.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaR/services/DanaRExecutionService.java @@ -18,7 +18,7 @@ import info.nightscout.androidaps.data.PumpEnactResult; import info.nightscout.androidaps.events.EventAppExit; import info.nightscout.androidaps.events.EventInitializationChanged; import info.nightscout.androidaps.events.EventPreferenceChange; -import info.nightscout.androidaps.events.EventProfileSwitchChange; +import info.nightscout.androidaps.events.EventProfileNeedsUpdate; import info.nightscout.androidaps.events.EventPumpStatusChanged; import info.nightscout.androidaps.interfaces.PumpInterface; import info.nightscout.androidaps.logging.L; @@ -166,7 +166,7 @@ public class DanaRExecutionService extends AbstractDanaRExecutionService { MainApp.bus().post(new EventPumpStatusChanged(MainApp.gs(R.string.gettingpumpsettings))); mSerialIOThread.sendMessage(new MsgSettingBasal()); if (!pump.isThisProfileSet(profile) && !ConfigBuilderPlugin.getPlugin().getCommandQueue().isRunning(Command.CommandType.BASALPROFILE)) { - MainApp.bus().post(new EventProfileSwitchChange()); + MainApp.bus().post(new EventProfileNeedsUpdate()); } } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRKorean/services/DanaRKoreanExecutionService.java b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRKorean/services/DanaRKoreanExecutionService.java index c35b17620a..749b977c2c 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRKorean/services/DanaRKoreanExecutionService.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRKorean/services/DanaRKoreanExecutionService.java @@ -18,7 +18,7 @@ import info.nightscout.androidaps.data.PumpEnactResult; import info.nightscout.androidaps.events.EventAppExit; import info.nightscout.androidaps.events.EventInitializationChanged; import info.nightscout.androidaps.events.EventPreferenceChange; -import info.nightscout.androidaps.events.EventProfileSwitchChange; +import info.nightscout.androidaps.events.EventProfileNeedsUpdate; import info.nightscout.androidaps.events.EventPumpStatusChanged; import info.nightscout.androidaps.interfaces.PumpInterface; import info.nightscout.androidaps.logging.L; @@ -171,7 +171,7 @@ public class DanaRKoreanExecutionService extends AbstractDanaRExecutionService { MainApp.bus().post(new EventPumpStatusChanged(MainApp.gs(R.string.gettingpumpsettings))); mSerialIOThread.sendMessage(new MsgSettingBasal()); if (!pump.isThisProfileSet(profile) && !ConfigBuilderPlugin.getPlugin().getCommandQueue().isRunning(Command.CommandType.BASALPROFILE)) { - MainApp.bus().post(new EventProfileSwitchChange()); + MainApp.bus().post(new EventProfileNeedsUpdate()); } } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/services/DanaRSService.java b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/services/DanaRSService.java index a31bf01c8e..06a3a651ca 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/services/DanaRSService.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/services/DanaRSService.java @@ -20,7 +20,7 @@ import info.nightscout.androidaps.data.Profile; import info.nightscout.androidaps.data.PumpEnactResult; import info.nightscout.androidaps.events.EventAppExit; import info.nightscout.androidaps.events.EventInitializationChanged; -import info.nightscout.androidaps.events.EventProfileSwitchChange; +import info.nightscout.androidaps.events.EventProfileNeedsUpdate; import info.nightscout.androidaps.events.EventPumpStatusChanged; import info.nightscout.androidaps.interfaces.PumpInterface; import info.nightscout.androidaps.logging.L; @@ -149,7 +149,7 @@ public class DanaRSService extends Service { MainApp.bus().post(new EventPumpStatusChanged(MainApp.gs(R.string.gettingpumpsettings))); bleComm.sendMessage(new DanaRS_Packet_Basal_Get_Basal_Rate()); // basal profile, basalStep, maxBasal if (!pump.isThisProfileSet(profile) && !ConfigBuilderPlugin.getPlugin().getCommandQueue().isRunning(Command.CommandType.BASALPROFILE)) { - MainApp.bus().post(new EventProfileSwitchChange()); + MainApp.bus().post(new EventProfileNeedsUpdate()); } } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRv2/services/DanaRv2ExecutionService.java b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRv2/services/DanaRv2ExecutionService.java index 66c6e22eba..2d2d2526dd 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRv2/services/DanaRv2ExecutionService.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRv2/services/DanaRv2ExecutionService.java @@ -19,7 +19,7 @@ import info.nightscout.androidaps.data.PumpEnactResult; import info.nightscout.androidaps.events.EventAppExit; import info.nightscout.androidaps.events.EventInitializationChanged; import info.nightscout.androidaps.events.EventPreferenceChange; -import info.nightscout.androidaps.events.EventProfileSwitchChange; +import info.nightscout.androidaps.events.EventProfileNeedsUpdate; import info.nightscout.androidaps.events.EventPumpStatusChanged; import info.nightscout.androidaps.interfaces.PumpInterface; import info.nightscout.androidaps.logging.L; @@ -188,7 +188,7 @@ public class DanaRv2ExecutionService extends AbstractDanaRExecutionService { MainApp.bus().post(new EventPumpStatusChanged(MainApp.gs(R.string.gettingpumpsettings))); mSerialIOThread.sendMessage(new MsgSettingBasal()); if (!pump.isThisProfileSet(profile) && !ConfigBuilderPlugin.getPlugin().getCommandQueue().isRunning(Command.CommandType.BASALPROFILE)) { - MainApp.bus().post(new EventProfileSwitchChange()); + MainApp.bus().post(new EventProfileNeedsUpdate()); } } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/treatments/fragments/TreatmentsProfileSwitchFragment.java b/app/src/main/java/info/nightscout/androidaps/plugins/treatments/fragments/TreatmentsProfileSwitchFragment.java index 5da86217f0..c59d5e1836 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/treatments/fragments/TreatmentsProfileSwitchFragment.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/treatments/fragments/TreatmentsProfileSwitchFragment.java @@ -27,13 +27,13 @@ import java.util.List; import info.nightscout.androidaps.MainApp; import info.nightscout.androidaps.R; +import info.nightscout.androidaps.events.EventProfileNeedsUpdate; import info.nightscout.androidaps.logging.L; import info.nightscout.androidaps.plugins.configBuilder.ProfileFunctions; import info.nightscout.androidaps.services.Intents; import info.nightscout.androidaps.data.Profile; import info.nightscout.androidaps.db.ProfileSwitch; import info.nightscout.androidaps.db.Source; -import info.nightscout.androidaps.events.EventProfileSwitchChange; import info.nightscout.androidaps.plugins.common.SubscriberFragment; import info.nightscout.androidaps.plugins.general.nsclient.UploadQueue; import info.nightscout.androidaps.utils.DateUtil; @@ -216,7 +216,7 @@ public class TreatmentsProfileSwitchFragment extends SubscriberFragment implemen } @Subscribe - public void onStatusEvent(final EventProfileSwitchChange ev) { + public void onStatusEvent(final EventProfileNeedsUpdate ev) { updateGUI(); } diff --git a/app/src/main/java/info/nightscout/androidaps/queue/CommandQueue.java b/app/src/main/java/info/nightscout/androidaps/queue/CommandQueue.java index 58502e3a3d..e4fbacc43c 100644 --- a/app/src/main/java/info/nightscout/androidaps/queue/CommandQueue.java +++ b/app/src/main/java/info/nightscout/androidaps/queue/CommandQueue.java @@ -381,7 +381,7 @@ public class CommandQueue { Notification notification = new Notification(Notification.NOT_ENG_MODE_OR_RELEASE, MainApp.gs(R.string.not_eng_mode_or_release), Notification.URGENT); MainApp.bus().post(new EventNewNotification(notification)); if (callback != null) - callback.result(new PumpEnactResult().success(false).comment(MainApp.gs(R.string.not_eng_mode_or_release))).run(); + callback.result(new PumpEnactResult().success(false).enacted(false).comment(MainApp.gs(R.string.not_eng_mode_or_release))).run(); return false; } @@ -394,7 +394,7 @@ public class CommandQueue { Notification notification = new Notification(Notification.BASAL_VALUE_BELOW_MINIMUM, MainApp.gs(R.string.basalvaluebelowminimum), Notification.URGENT); MainApp.bus().post(new EventNewNotification(notification)); if (callback != null) - callback.result(new PumpEnactResult().success(false).comment(MainApp.gs(R.string.basalvaluebelowminimum))).run(); + callback.result(new PumpEnactResult().success(false).enacted(false).comment(MainApp.gs(R.string.basalvaluebelowminimum))).run(); return false; } } diff --git a/app/src/main/java/info/nightscout/androidaps/receivers/KeepAliveReceiver.java b/app/src/main/java/info/nightscout/androidaps/receivers/KeepAliveReceiver.java index 9acc217904..7a9aa31c46 100644 --- a/app/src/main/java/info/nightscout/androidaps/receivers/KeepAliveReceiver.java +++ b/app/src/main/java/info/nightscout/androidaps/receivers/KeepAliveReceiver.java @@ -13,7 +13,7 @@ import org.slf4j.LoggerFactory; import info.nightscout.androidaps.Constants; import info.nightscout.androidaps.MainApp; import info.nightscout.androidaps.data.Profile; -import info.nightscout.androidaps.events.EventProfileSwitchChange; +import info.nightscout.androidaps.events.EventProfileNeedsUpdate; import info.nightscout.androidaps.interfaces.PumpInterface; import info.nightscout.androidaps.logging.L; import info.nightscout.androidaps.plugins.configBuilder.ConfigBuilderPlugin; @@ -73,7 +73,7 @@ public class KeepAliveReceiver extends BroadcastReceiver { } if (!pump.isThisProfileSet(profile) && !ConfigBuilderPlugin.getPlugin().getCommandQueue().isRunning(Command.CommandType.BASALPROFILE)) { - MainApp.bus().post(new EventProfileSwitchChange()); + MainApp.bus().post(new EventProfileNeedsUpdate()); } else if (isStatusOutdated && !pump.isBusy()) { lastReadStatus = System.currentTimeMillis(); ConfigBuilderPlugin.getPlugin().getCommandQueue().readStatus("KeepAlive. Status outdated.", null); diff --git a/app/src/main/java/info/nightscout/androidaps/setupwizard/SetupWizardActivity.java b/app/src/main/java/info/nightscout/androidaps/setupwizard/SetupWizardActivity.java index 3dad4535ac..9049ad7463 100644 --- a/app/src/main/java/info/nightscout/androidaps/setupwizard/SetupWizardActivity.java +++ b/app/src/main/java/info/nightscout/androidaps/setupwizard/SetupWizardActivity.java @@ -22,7 +22,7 @@ import info.nightscout.androidaps.MainActivity; import info.nightscout.androidaps.MainApp; import info.nightscout.androidaps.R; import info.nightscout.androidaps.events.EventProfileStoreChanged; -import info.nightscout.androidaps.events.EventProfileSwitchChange; +import info.nightscout.androidaps.events.EventProfileNeedsUpdate; import info.nightscout.androidaps.events.EventPumpStatusChanged; import info.nightscout.androidaps.plugins.constraints.objectives.events.EventObjectivesSaved; import info.nightscout.androidaps.plugins.general.nsclient.events.EventNSClientStatus; @@ -115,7 +115,7 @@ public class SetupWizardActivity extends AppCompatActivity { } @Subscribe - public void onEventProfileSwitchChange(EventProfileSwitchChange ignored) { + public void onEventProfileSwitchChange(EventProfileNeedsUpdate ignored) { updateButtons(); } From 78f2da405f975a13820a217d89a2d9b6a8f71535 Mon Sep 17 00:00:00 2001 From: Lee Braiden Date: Mon, 15 Apr 2019 19:09:56 +0100 Subject: [PATCH 18/42] Fix potential NPE in AlarmSoundService destructor. --- .../nightscout/androidaps/services/AlarmSoundService.java | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/info/nightscout/androidaps/services/AlarmSoundService.java b/app/src/main/java/info/nightscout/androidaps/services/AlarmSoundService.java index e95cd7c479..4917789db1 100644 --- a/app/src/main/java/info/nightscout/androidaps/services/AlarmSoundService.java +++ b/app/src/main/java/info/nightscout/androidaps/services/AlarmSoundService.java @@ -75,8 +75,11 @@ public class AlarmSoundService extends Service { @Override public void onDestroy() { - player.stop(); - player.release(); + if (player != null) { + player.stop(); + player.release(); + } + if (L.isEnabled(L.CORE)) log.debug("onDestroy"); } From ee4fdcd6401585a15578c1e11cbdceda93acef5c Mon Sep 17 00:00:00 2001 From: Milos Kozak Date: Tue, 16 Apr 2019 11:15:40 +0200 Subject: [PATCH 19/42] Test for uncommited changes in gradle --- app/build.gradle | 41 +++++++++++++++++++++++++++++++++++------ 1 file changed, 35 insertions(+), 6 deletions(-) diff --git a/app/build.gradle b/app/build.gradle index 46a2ee19dd..23705b9bee 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -67,6 +67,26 @@ def generateDate = { -> return stringBuilder.toString() } +def isMaster = { -> + return !version.contains('-') +} + +def allCommited = { -> + StringBuilder stringBuilder = new StringBuilder(); + try { + def stdout = new ByteArrayOutputStream() + exec { + commandLine 'git', 'status' + standardOutput = stdout + } + String commitObject = stdout.toString().trim() + stringBuilder.append(commitObject) + } catch (ignored) { + return false; // NoGitSystemAvailable + } + return stringBuilder.toString().contains("nothing to commit") +} + tasks.matching { it instanceof Test }.all { testLogging.events = ["failed", "skipped", "started"] testLogging.exceptionFormat = "full" @@ -83,7 +103,7 @@ android { version "2.2.3-dev" buildConfigField "String", "VERSION", '"' + version + '"' buildConfigField "String", "BUILDVERSION", '"' + generateGitBuild() + '-' + generateDate() + '"' - buildConfigField "String", "REMOTE", '"' + generateGitRemote()+ '"' + buildConfigField "String", "REMOTE", '"' + generateGitRemote() + '"' buildConfigField "String", "HEAD", '"' + generateGitBuild() + '"' testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" // if you change minSdkVersion to less than 11, you need to change executeTask for wear @@ -120,7 +140,7 @@ android { resValue "string", "app_name", "AndroidAPS" versionName version manifestPlaceholders = [ - appIcon: "@mipmap/ic_launcher", + appIcon : "@mipmap/ic_launcher", appIconRound: "@mipmap/ic_launcher_round" ] } @@ -130,7 +150,7 @@ android { resValue "string", "app_name", "Pumpcontrol" versionName version + "-pumpcontrol" manifestPlaceholders = [ - appIcon: "@mipmap/ic_pumpcontrol", + appIcon : "@mipmap/ic_pumpcontrol", appIconRound: "@null" ] } @@ -140,7 +160,7 @@ android { resValue "string", "app_name", "NSClient" versionName version + "-nsclient" manifestPlaceholders = [ - appIcon: "@mipmap/ic_yellowowl", + appIcon : "@mipmap/ic_yellowowl", appIconRound: "@null" ] } @@ -150,7 +170,7 @@ android { resValue "string", "app_name", "NSClient2" versionName version + "-nsclient" manifestPlaceholders = [ - appIcon: "@mipmap/ic_yellowowl", + appIcon : "@mipmap/ic_yellowowl", appIconRound: "@null" ] } @@ -165,7 +185,7 @@ android { unitTests.includeAndroidResources = true } - useLibrary "org.apache.http.legacy" + useLibrary "org.apache.http.legacy" } allprojects { @@ -274,3 +294,12 @@ task full_clean(type: Delete) { clean.dependsOn full_clean preBuild.dependsOn copyLibs + +printf('--------------\n') +printf('isMaster: %s\n', isMaster().toString()) +printf('allCommited: %s\n', allCommited().toString()) +printf('--------------\n') +if (isMaster() && !allCommited()) { + throw new GradleException('There are uncommitted changes or git system is not available. Clone sources again as described in wiki and do not allow gradle update') +} + From 952a6fe5097ee67a92157ecb0233abeb730f0651 Mon Sep 17 00:00:00 2001 From: Milos Kozak Date: Tue, 16 Apr 2019 20:36:18 +0200 Subject: [PATCH 20/42] fix GlucoseStatus calculation --- .../androidaps/data/GlucoseStatus.java | 178 ----------------- .../androidaps/data/QuickWizardEntry.java | 1 + .../DetermineBasalAdapterAMAJS.java | 2 +- .../aps/openAPSAMA/OpenAPSAMAPlugin.java | 2 +- .../openAPSMA/DetermineBasalAdapterMAJS.java | 2 +- .../aps/openAPSMA/OpenAPSMAPlugin.java | 2 +- .../DetermineBasalAdapterSMBJS.java | 2 +- .../aps/openAPSSMB/OpenAPSSMBPlugin.java | 2 +- .../Dialogs/NewNSTreatmentDialog.java | 2 +- .../general/overview/OverviewFragment.java | 2 +- .../overview/dialogs/CalibrationDialog.java | 2 +- .../PersistentNotificationPlugin.java | 2 +- .../SmsCommunicatorPlugin.java | 2 +- .../wearintegration/WatchUpdaterService.java | 12 +- .../iob/iobCobCalculator/GlucoseStatus.java | 180 ++++++++++++++++++ .../androidaps/utils/BolusWizard.java | 2 +- .../androidaps/data/GlucoseStatusTest.java | 1 + .../androidaps/utils/BolusWizardTest.java | 2 +- 18 files changed, 196 insertions(+), 202 deletions(-) delete mode 100644 app/src/main/java/info/nightscout/androidaps/data/GlucoseStatus.java create mode 100644 app/src/main/java/info/nightscout/androidaps/plugins/iob/iobCobCalculator/GlucoseStatus.java diff --git a/app/src/main/java/info/nightscout/androidaps/data/GlucoseStatus.java b/app/src/main/java/info/nightscout/androidaps/data/GlucoseStatus.java deleted file mode 100644 index be3e981fb4..0000000000 --- a/app/src/main/java/info/nightscout/androidaps/data/GlucoseStatus.java +++ /dev/null @@ -1,178 +0,0 @@ -package info.nightscout.androidaps.data; - -import android.support.annotation.Nullable; - -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import java.util.ArrayList; -import java.util.List; - -import info.nightscout.androidaps.db.BgReading; -import info.nightscout.androidaps.logging.L; -import info.nightscout.androidaps.plugins.iob.iobCobCalculator.IobCobCalculatorPlugin; -import info.nightscout.androidaps.utils.DateUtil; -import info.nightscout.androidaps.utils.DecimalFormatter; -import info.nightscout.androidaps.utils.Round; - -/** - * Created by mike on 04.01.2017. - */ - -public class GlucoseStatus { - private static Logger log = LoggerFactory.getLogger(GlucoseStatus.class); - public double glucose = 0d; - public double delta = 0d; - public double avgdelta = 0d; - public double short_avgdelta = 0d; - public double long_avgdelta = 0d; - public long date = 0L; - - - public String log() { - return "Glucose: " + DecimalFormatter.to0Decimal(glucose) + " mg/dl " + - "Delta: " + DecimalFormatter.to0Decimal(delta) + " mg/dl" + - "Short avg. delta: " + " " + DecimalFormatter.to2Decimal(short_avgdelta) + " mg/dl " + - "Long avg. delta: " + DecimalFormatter.to2Decimal(long_avgdelta) + " mg/dl"; - } - - public GlucoseStatus() { - } - - public GlucoseStatus round() { - this.glucose = Round.roundTo(this.glucose, 0.1); - this.delta = Round.roundTo(this.delta, 0.01); - this.avgdelta = Round.roundTo(this.avgdelta, 0.01); - this.short_avgdelta = Round.roundTo(this.short_avgdelta, 0.01); - this.long_avgdelta = Round.roundTo(this.long_avgdelta, 0.01); - return this; - } - - - @Nullable - public static GlucoseStatus getGlucoseStatusData() { - return getGlucoseStatusData(false); - } - - @Nullable - public static GlucoseStatus getGlucoseStatusData(boolean allowOldData) { - // load 45min - //long fromtime = DateUtil.now() - 60 * 1000L * 45; - //List data = MainApp.getDbHelper().getBgreadingsDataFromTime(fromtime, false); - - List data = IobCobCalculatorPlugin.getPlugin().getBgReadings(); - - if (data == null) { - if (L.isEnabled(L.GLUCOSE)) - log.debug("data=null"); - return null; - } - - int sizeRecords = data.size(); - if (sizeRecords == 0) { - if (L.isEnabled(L.GLUCOSE)) - log.debug("sizeRecords==0"); - return null; - } - - if (data.get(0).date < DateUtil.now() - 7 * 60 * 1000L && !allowOldData) { - if (L.isEnabled(L.GLUCOSE)) - log.debug("olddata"); - return null; - } - - BgReading now = data.get(0); - long now_date = now.date; - double change; - - if (sizeRecords == 1) { - GlucoseStatus status = new GlucoseStatus(); - status.glucose = now.value; - status.short_avgdelta = 0d; - status.delta = 0d; - status.long_avgdelta = 0d; - status.avgdelta = 0d; // for OpenAPS MA - status.date = now_date; - if (L.isEnabled(L.GLUCOSE)) - log.debug("sizeRecords==1"); - return status.round(); - } - - ArrayList now_value_list = new ArrayList<>(); - ArrayList last_deltas = new ArrayList<>(); - ArrayList short_deltas = new ArrayList<>(); - ArrayList long_deltas = new ArrayList<>(); - - // Use the latest sgv value in the now calculations - now_value_list.add(now.value); - - for (int i = 1; i < sizeRecords; i++) { - if (data.get(i).value > 38) { - BgReading then = data.get(i); - long then_date = then.date; - double avgdelta; - long minutesago; - - minutesago = Math.round((now_date - then_date) / (1000d * 60)); - // multiply by 5 to get the same units as delta, i.e. mg/dL/5m - change = now.value - then.value; - avgdelta = change / minutesago * 5; - - if (L.isEnabled(L.GLUCOSE)) - log.debug(then.toString() + " minutesago=" + minutesago + " avgdelta=" + avgdelta); - - // use the average of all data points in the last 2.5m for all further "now" calculations - if (0 < minutesago && minutesago < 2.5) { - // Keep and average all values within the last 2.5 minutes - now_value_list.add(then.value); - now.value = average(now_value_list); - // short_deltas are calculated from everything ~5-15 minutes ago - } else if (2.5 < minutesago && minutesago < 17.5) { - //console.error(minutesago, avgdelta); - short_deltas.add(avgdelta); - // last_deltas are calculated from everything ~5 minutes ago - if (2.5 < minutesago && minutesago < 7.5) { - last_deltas.add(avgdelta); - } - // long_deltas are calculated from everything ~20-40 minutes ago - } else if (17.5 < minutesago && minutesago < 42.5) { - long_deltas.add(avgdelta); - } else { - // Do not process any more records after >= 42.5 minutes - break; - } - } - } - - GlucoseStatus status = new GlucoseStatus(); - status.glucose = now.value; - status.date = now_date; - - status.short_avgdelta = average(short_deltas); - - if (last_deltas.isEmpty()) { - status.delta = status.short_avgdelta; - } else { - status.delta = average(last_deltas); - } - - status.long_avgdelta = average(long_deltas); - status.avgdelta = status.short_avgdelta; // for OpenAPS MA - - if (L.isEnabled(L.GLUCOSE)) - log.debug(status.log()); - return status.round(); - } - - public static double average(ArrayList array) { - double sum = 0d; - - if (array.size() == 0) - return 0d; - - for (Double value : array) { - sum += value; - } - return sum / array.size(); - } -} diff --git a/app/src/main/java/info/nightscout/androidaps/data/QuickWizardEntry.java b/app/src/main/java/info/nightscout/androidaps/data/QuickWizardEntry.java index 4262fe2133..0bfcbb1002 100644 --- a/app/src/main/java/info/nightscout/androidaps/data/QuickWizardEntry.java +++ b/app/src/main/java/info/nightscout/androidaps/data/QuickWizardEntry.java @@ -12,6 +12,7 @@ import info.nightscout.androidaps.db.BgReading; import info.nightscout.androidaps.db.TempTarget; import info.nightscout.androidaps.interfaces.TreatmentsInterface; import info.nightscout.androidaps.plugins.iob.iobCobCalculator.CobInfo; +import info.nightscout.androidaps.plugins.iob.iobCobCalculator.GlucoseStatus; import info.nightscout.androidaps.plugins.iob.iobCobCalculator.IobCobCalculatorPlugin; import info.nightscout.androidaps.plugins.aps.loop.LoopPlugin; import info.nightscout.androidaps.plugins.treatments.TreatmentsPlugin; diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/aps/openAPSAMA/DetermineBasalAdapterAMAJS.java b/app/src/main/java/info/nightscout/androidaps/plugins/aps/openAPSAMA/DetermineBasalAdapterAMAJS.java index 7eb9a2d81d..5b5c8cb63d 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/aps/openAPSAMA/DetermineBasalAdapterAMAJS.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/aps/openAPSAMA/DetermineBasalAdapterAMAJS.java @@ -20,7 +20,7 @@ import java.lang.reflect.InvocationTargetException; import info.nightscout.androidaps.Constants; import info.nightscout.androidaps.MainApp; import info.nightscout.androidaps.R; -import info.nightscout.androidaps.data.GlucoseStatus; +import info.nightscout.androidaps.plugins.iob.iobCobCalculator.GlucoseStatus; import info.nightscout.androidaps.data.IobTotal; import info.nightscout.androidaps.data.MealData; import info.nightscout.androidaps.data.Profile; diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/aps/openAPSAMA/OpenAPSAMAPlugin.java b/app/src/main/java/info/nightscout/androidaps/plugins/aps/openAPSAMA/OpenAPSAMAPlugin.java index 3447c7c4f4..1f7deebea4 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/aps/openAPSAMA/OpenAPSAMAPlugin.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/aps/openAPSAMA/OpenAPSAMAPlugin.java @@ -6,7 +6,7 @@ import org.slf4j.LoggerFactory; import info.nightscout.androidaps.MainApp; import info.nightscout.androidaps.R; -import info.nightscout.androidaps.data.GlucoseStatus; +import info.nightscout.androidaps.plugins.iob.iobCobCalculator.GlucoseStatus; import info.nightscout.androidaps.data.IobTotal; import info.nightscout.androidaps.data.MealData; import info.nightscout.androidaps.data.Profile; diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/aps/openAPSMA/DetermineBasalAdapterMAJS.java b/app/src/main/java/info/nightscout/androidaps/plugins/aps/openAPSMA/DetermineBasalAdapterMAJS.java index 4baabf22ab..ae1f390ded 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/aps/openAPSMA/DetermineBasalAdapterMAJS.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/aps/openAPSMA/DetermineBasalAdapterMAJS.java @@ -17,7 +17,7 @@ import java.lang.reflect.InvocationTargetException; import info.nightscout.androidaps.Constants; import info.nightscout.androidaps.R; -import info.nightscout.androidaps.data.GlucoseStatus; +import info.nightscout.androidaps.plugins.iob.iobCobCalculator.GlucoseStatus; import info.nightscout.androidaps.data.IobTotal; import info.nightscout.androidaps.data.MealData; import info.nightscout.androidaps.data.Profile; diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/aps/openAPSMA/OpenAPSMAPlugin.java b/app/src/main/java/info/nightscout/androidaps/plugins/aps/openAPSMA/OpenAPSMAPlugin.java index 24b4cb7929..2dd78bdb82 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/aps/openAPSMA/OpenAPSMAPlugin.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/aps/openAPSMA/OpenAPSMAPlugin.java @@ -6,7 +6,7 @@ import org.slf4j.LoggerFactory; import info.nightscout.androidaps.MainApp; import info.nightscout.androidaps.R; -import info.nightscout.androidaps.data.GlucoseStatus; +import info.nightscout.androidaps.plugins.iob.iobCobCalculator.GlucoseStatus; import info.nightscout.androidaps.data.IobTotal; import info.nightscout.androidaps.data.MealData; import info.nightscout.androidaps.data.Profile; diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/aps/openAPSSMB/DetermineBasalAdapterSMBJS.java b/app/src/main/java/info/nightscout/androidaps/plugins/aps/openAPSSMB/DetermineBasalAdapterSMBJS.java index edaddd62c9..bfb75503c1 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/aps/openAPSSMB/DetermineBasalAdapterSMBJS.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/aps/openAPSSMB/DetermineBasalAdapterSMBJS.java @@ -20,7 +20,7 @@ import java.lang.reflect.InvocationTargetException; import info.nightscout.androidaps.Constants; import info.nightscout.androidaps.MainApp; import info.nightscout.androidaps.R; -import info.nightscout.androidaps.data.GlucoseStatus; +import info.nightscout.androidaps.plugins.iob.iobCobCalculator.GlucoseStatus; import info.nightscout.androidaps.data.IobTotal; import info.nightscout.androidaps.data.MealData; import info.nightscout.androidaps.data.Profile; diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/aps/openAPSSMB/OpenAPSSMBPlugin.java b/app/src/main/java/info/nightscout/androidaps/plugins/aps/openAPSSMB/OpenAPSSMBPlugin.java index 73914662d7..728e3145d6 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/aps/openAPSSMB/OpenAPSSMBPlugin.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/aps/openAPSSMB/OpenAPSSMBPlugin.java @@ -6,7 +6,7 @@ import org.slf4j.LoggerFactory; import info.nightscout.androidaps.MainApp; import info.nightscout.androidaps.R; -import info.nightscout.androidaps.data.GlucoseStatus; +import info.nightscout.androidaps.plugins.iob.iobCobCalculator.GlucoseStatus; import info.nightscout.androidaps.data.IobTotal; import info.nightscout.androidaps.data.MealData; import info.nightscout.androidaps.data.Profile; diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/general/careportal/Dialogs/NewNSTreatmentDialog.java b/app/src/main/java/info/nightscout/androidaps/plugins/general/careportal/Dialogs/NewNSTreatmentDialog.java index e94cc658ca..57414927b4 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/general/careportal/Dialogs/NewNSTreatmentDialog.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/general/careportal/Dialogs/NewNSTreatmentDialog.java @@ -39,7 +39,7 @@ import java.util.List; import info.nightscout.androidaps.Constants; import info.nightscout.androidaps.MainApp; import info.nightscout.androidaps.R; -import info.nightscout.androidaps.data.GlucoseStatus; +import info.nightscout.androidaps.plugins.iob.iobCobCalculator.GlucoseStatus; import info.nightscout.androidaps.data.Profile; import info.nightscout.androidaps.data.ProfileStore; import info.nightscout.androidaps.db.BgReading; diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/general/overview/OverviewFragment.java b/app/src/main/java/info/nightscout/androidaps/plugins/general/overview/OverviewFragment.java index c4d8655ca8..6d41303540 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/general/overview/OverviewFragment.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/general/overview/OverviewFragment.java @@ -56,7 +56,7 @@ import info.nightscout.androidaps.Constants; import info.nightscout.androidaps.MainApp; import info.nightscout.androidaps.R; import info.nightscout.androidaps.data.DetailedBolusInfo; -import info.nightscout.androidaps.data.GlucoseStatus; +import info.nightscout.androidaps.plugins.iob.iobCobCalculator.GlucoseStatus; import info.nightscout.androidaps.data.IobTotal; import info.nightscout.androidaps.data.Profile; import info.nightscout.androidaps.data.QuickWizardEntry; diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/general/overview/dialogs/CalibrationDialog.java b/app/src/main/java/info/nightscout/androidaps/plugins/general/overview/dialogs/CalibrationDialog.java index 53c571aad7..0ab1b98ff6 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/general/overview/dialogs/CalibrationDialog.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/general/overview/dialogs/CalibrationDialog.java @@ -18,7 +18,7 @@ import java.text.DecimalFormat; import info.nightscout.androidaps.Constants; import info.nightscout.androidaps.R; -import info.nightscout.androidaps.data.GlucoseStatus; +import info.nightscout.androidaps.plugins.iob.iobCobCalculator.GlucoseStatus; import info.nightscout.androidaps.data.Profile; import info.nightscout.androidaps.plugins.configBuilder.ProfileFunctions; import info.nightscout.androidaps.utils.NumberPicker; diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/general/persistentNotification/PersistentNotificationPlugin.java b/app/src/main/java/info/nightscout/androidaps/plugins/general/persistentNotification/PersistentNotificationPlugin.java index 0287c21260..987d9374bd 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/general/persistentNotification/PersistentNotificationPlugin.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/general/persistentNotification/PersistentNotificationPlugin.java @@ -20,7 +20,7 @@ import info.nightscout.androidaps.Constants; import info.nightscout.androidaps.MainActivity; import info.nightscout.androidaps.MainApp; import info.nightscout.androidaps.R; -import info.nightscout.androidaps.data.GlucoseStatus; +import info.nightscout.androidaps.plugins.iob.iobCobCalculator.GlucoseStatus; import info.nightscout.androidaps.data.IobTotal; import info.nightscout.androidaps.db.BgReading; import info.nightscout.androidaps.db.DatabaseHelper; diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/general/smsCommunicator/SmsCommunicatorPlugin.java b/app/src/main/java/info/nightscout/androidaps/plugins/general/smsCommunicator/SmsCommunicatorPlugin.java index 7703561aa9..181bdd86d2 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/general/smsCommunicator/SmsCommunicatorPlugin.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/general/smsCommunicator/SmsCommunicatorPlugin.java @@ -20,7 +20,7 @@ import info.nightscout.androidaps.Constants; import info.nightscout.androidaps.MainApp; import info.nightscout.androidaps.R; import info.nightscout.androidaps.data.DetailedBolusInfo; -import info.nightscout.androidaps.data.GlucoseStatus; +import info.nightscout.androidaps.plugins.iob.iobCobCalculator.GlucoseStatus; import info.nightscout.androidaps.data.IobTotal; import info.nightscout.androidaps.data.Profile; import info.nightscout.androidaps.data.ProfileStore; diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/general/wear/wearintegration/WatchUpdaterService.java b/app/src/main/java/info/nightscout/androidaps/plugins/general/wear/wearintegration/WatchUpdaterService.java index 86b56ba130..d121c5c55d 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/general/wear/wearintegration/WatchUpdaterService.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/general/wear/wearintegration/WatchUpdaterService.java @@ -32,17 +32,11 @@ import com.google.android.gms.wearable.PutDataRequest; import com.google.android.gms.wearable.Wearable; import com.google.android.gms.wearable.WearableListenerService; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import java.util.ArrayList; -import java.util.List; - import info.nightscout.androidaps.Config; import info.nightscout.androidaps.Constants; import info.nightscout.androidaps.MainApp; import info.nightscout.androidaps.R; -import info.nightscout.androidaps.data.GlucoseStatus; +import info.nightscout.androidaps.plugins.iob.iobCobCalculator.GlucoseStatus; import info.nightscout.androidaps.data.IobTotal; import info.nightscout.androidaps.data.Profile; import info.nightscout.androidaps.db.BgReading; @@ -55,15 +49,11 @@ import info.nightscout.androidaps.interfaces.PluginType; import info.nightscout.androidaps.interfaces.TreatmentsInterface; import info.nightscout.androidaps.plugins.aps.loop.LoopPlugin; import info.nightscout.androidaps.plugins.configBuilder.ConfigBuilderPlugin; -import info.nightscout.androidaps.plugins.configBuilder.ProfileFunctions; import info.nightscout.androidaps.plugins.general.nsclient.data.NSDeviceStatus; import info.nightscout.androidaps.plugins.general.overview.OverviewPlugin; import info.nightscout.androidaps.plugins.treatments.TreatmentsPlugin; import info.nightscout.androidaps.plugins.general.wear.ActionStringHandler; import info.nightscout.androidaps.plugins.general.wear.WearPlugin; -import info.nightscout.androidaps.plugins.iob.iobCobCalculator.IobCobCalculatorPlugin; -import info.nightscout.androidaps.plugins.treatments.Treatment; -import info.nightscout.androidaps.plugins.treatments.TreatmentsPlugin; import info.nightscout.androidaps.utils.DecimalFormatter; import info.nightscout.androidaps.utils.SP; import info.nightscout.androidaps.utils.SafeParse; diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/iob/iobCobCalculator/GlucoseStatus.java b/app/src/main/java/info/nightscout/androidaps/plugins/iob/iobCobCalculator/GlucoseStatus.java new file mode 100644 index 0000000000..94fab37d8b --- /dev/null +++ b/app/src/main/java/info/nightscout/androidaps/plugins/iob/iobCobCalculator/GlucoseStatus.java @@ -0,0 +1,180 @@ +package info.nightscout.androidaps.plugins.iob.iobCobCalculator; + +import android.support.annotation.Nullable; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import java.util.ArrayList; +import java.util.List; + +import info.nightscout.androidaps.db.BgReading; +import info.nightscout.androidaps.logging.L; +import info.nightscout.androidaps.utils.DateUtil; +import info.nightscout.androidaps.utils.DecimalFormatter; +import info.nightscout.androidaps.utils.Round; + +/** + * Created by mike on 04.01.2017. + */ + +public class GlucoseStatus { + private static Logger log = LoggerFactory.getLogger(GlucoseStatus.class); + public double glucose = 0d; + public double delta = 0d; + public double avgdelta = 0d; + public double short_avgdelta = 0d; + public double long_avgdelta = 0d; + public long date = 0L; + + + public String log() { + return "Glucose: " + DecimalFormatter.to0Decimal(glucose) + " mg/dl " + + "Delta: " + DecimalFormatter.to0Decimal(delta) + " mg/dl" + + "Short avg. delta: " + " " + DecimalFormatter.to2Decimal(short_avgdelta) + " mg/dl " + + "Long avg. delta: " + DecimalFormatter.to2Decimal(long_avgdelta) + " mg/dl"; + } + + public GlucoseStatus() { + } + + public GlucoseStatus round() { + this.glucose = Round.roundTo(this.glucose, 0.1); + this.delta = Round.roundTo(this.delta, 0.01); + this.avgdelta = Round.roundTo(this.avgdelta, 0.01); + this.short_avgdelta = Round.roundTo(this.short_avgdelta, 0.01); + this.long_avgdelta = Round.roundTo(this.long_avgdelta, 0.01); + return this; + } + + + @Nullable + public static GlucoseStatus getGlucoseStatusData() { + return getGlucoseStatusData(false); + } + + @Nullable + public static GlucoseStatus getGlucoseStatusData(boolean allowOldData) { + // load 45min + //long fromtime = DateUtil.now() - 60 * 1000L * 45; + //List data = MainApp.getDbHelper().getBgreadingsDataFromTime(fromtime, false); + + synchronized (IobCobCalculatorPlugin.getPlugin().dataLock) { + + List data = IobCobCalculatorPlugin.getPlugin().getBgReadings(); + + if (data == null) { + if (L.isEnabled(L.GLUCOSE)) + log.debug("data=null"); + return null; + } + + int sizeRecords = data.size(); + if (sizeRecords == 0) { + if (L.isEnabled(L.GLUCOSE)) + log.debug("sizeRecords==0"); + return null; + } + + if (data.get(0).date < DateUtil.now() - 7 * 60 * 1000L && !allowOldData) { + if (L.isEnabled(L.GLUCOSE)) + log.debug("olddata"); + return null; + } + + BgReading now = data.get(0); + long now_date = now.date; + double change; + + if (sizeRecords == 1) { + GlucoseStatus status = new GlucoseStatus(); + status.glucose = now.value; + status.short_avgdelta = 0d; + status.delta = 0d; + status.long_avgdelta = 0d; + status.avgdelta = 0d; // for OpenAPS MA + status.date = now_date; + if (L.isEnabled(L.GLUCOSE)) + log.debug("sizeRecords==1"); + return status.round(); + } + + ArrayList now_value_list = new ArrayList<>(); + ArrayList last_deltas = new ArrayList<>(); + ArrayList short_deltas = new ArrayList<>(); + ArrayList long_deltas = new ArrayList<>(); + + // Use the latest sgv value in the now calculations + now_value_list.add(now.value); + + for (int i = 1; i < sizeRecords; i++) { + if (data.get(i).value > 38) { + BgReading then = data.get(i); + long then_date = then.date; + double avgdelta; + long minutesago; + + minutesago = Math.round((now_date - then_date) / (1000d * 60)); + // multiply by 5 to get the same units as delta, i.e. mg/dL/5m + change = now.value - then.value; + avgdelta = change / minutesago * 5; + + if (L.isEnabled(L.GLUCOSE)) + log.debug(then.toString() + " minutesago=" + minutesago + " avgdelta=" + avgdelta); + + // use the average of all data points in the last 2.5m for all further "now" calculations + if (0 < minutesago && minutesago < 2.5) { + // Keep and average all values within the last 2.5 minutes + now_value_list.add(then.value); + now.value = average(now_value_list); + // short_deltas are calculated from everything ~5-15 minutes ago + } else if (2.5 < minutesago && minutesago < 17.5) { + //console.error(minutesago, avgdelta); + short_deltas.add(avgdelta); + // last_deltas are calculated from everything ~5 minutes ago + if (2.5 < minutesago && minutesago < 7.5) { + last_deltas.add(avgdelta); + } + // long_deltas are calculated from everything ~20-40 minutes ago + } else if (17.5 < minutesago && minutesago < 42.5) { + long_deltas.add(avgdelta); + } else { + // Do not process any more records after >= 42.5 minutes + break; + } + } + } + + GlucoseStatus status = new GlucoseStatus(); + status.glucose = now.value; + status.date = now_date; + + status.short_avgdelta = average(short_deltas); + + if (last_deltas.isEmpty()) { + status.delta = status.short_avgdelta; + } else { + status.delta = average(last_deltas); + } + + status.long_avgdelta = average(long_deltas); + status.avgdelta = status.short_avgdelta; // for OpenAPS MA + + if (L.isEnabled(L.GLUCOSE)) + log.debug(status.log()); + return status.round(); + } + } + + public static double average(ArrayList array) { + double sum = 0d; + + if (array.size() == 0) + return 0d; + + for (Double value : array) { + sum += value; + } + return sum / array.size(); + } +} diff --git a/app/src/main/java/info/nightscout/androidaps/utils/BolusWizard.java b/app/src/main/java/info/nightscout/androidaps/utils/BolusWizard.java index e47a74e17f..cd789ee225 100644 --- a/app/src/main/java/info/nightscout/androidaps/utils/BolusWizard.java +++ b/app/src/main/java/info/nightscout/androidaps/utils/BolusWizard.java @@ -3,7 +3,7 @@ package info.nightscout.androidaps.utils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import info.nightscout.androidaps.data.GlucoseStatus; +import info.nightscout.androidaps.plugins.iob.iobCobCalculator.GlucoseStatus; import info.nightscout.androidaps.data.IobTotal; import info.nightscout.androidaps.data.Profile; import info.nightscout.androidaps.db.TempTarget; diff --git a/app/src/test/java/info/nightscout/androidaps/data/GlucoseStatusTest.java b/app/src/test/java/info/nightscout/androidaps/data/GlucoseStatusTest.java index 8bcdf0ed26..cdbd276bae 100644 --- a/app/src/test/java/info/nightscout/androidaps/data/GlucoseStatusTest.java +++ b/app/src/test/java/info/nightscout/androidaps/data/GlucoseStatusTest.java @@ -16,6 +16,7 @@ import java.util.List; import info.AAPSMocker; import info.nightscout.androidaps.MainApp; import info.nightscout.androidaps.db.BgReading; +import info.nightscout.androidaps.plugins.iob.iobCobCalculator.GlucoseStatus; import info.nightscout.androidaps.plugins.iob.iobCobCalculator.IobCobCalculatorPlugin; import info.nightscout.androidaps.plugins.general.nsclient.data.NSSgv; import info.nightscout.androidaps.utils.DateUtil; diff --git a/app/src/test/java/info/nightscout/androidaps/utils/BolusWizardTest.java b/app/src/test/java/info/nightscout/androidaps/utils/BolusWizardTest.java index 945c813674..2143a7101c 100644 --- a/app/src/test/java/info/nightscout/androidaps/utils/BolusWizardTest.java +++ b/app/src/test/java/info/nightscout/androidaps/utils/BolusWizardTest.java @@ -9,7 +9,7 @@ import org.powermock.modules.junit4.PowerMockRunner; import info.AAPSMocker; import info.nightscout.androidaps.MainApp; -import info.nightscout.androidaps.data.GlucoseStatus; +import info.nightscout.androidaps.plugins.iob.iobCobCalculator.GlucoseStatus; import info.nightscout.androidaps.data.IobTotal; import info.nightscout.androidaps.data.Profile; import info.nightscout.androidaps.interfaces.PumpInterface; From a6bd81a1b9f5bc77fc5329177dfb0cfed9f03857 Mon Sep 17 00:00:00 2001 From: Milos Kozak Date: Tue, 16 Apr 2019 21:28:21 +0200 Subject: [PATCH 21/42] fix tests --- .../plugins/iob/iobCobCalculator/GlucoseStatus.java | 2 +- .../iob/iobCobCalculator/IobCobCalculatorPlugin.java | 6 +++++- .../plugins/iob/iobCobCalculator/IobCobOref1Thread.java | 2 +- .../plugins/iob/iobCobCalculator/IobCobThread.java | 2 +- app/src/test/java/info/AAPSMocker.java | 5 ++++- .../iob/iobCobCalculatorPlugin}/GlucoseStatusTest.java | 7 ++----- 6 files changed, 14 insertions(+), 10 deletions(-) rename app/src/test/java/info/nightscout/androidaps/{data => plugins/iob/iobCobCalculatorPlugin}/GlucoseStatusTest.java (97%) diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/iob/iobCobCalculator/GlucoseStatus.java b/app/src/main/java/info/nightscout/androidaps/plugins/iob/iobCobCalculator/GlucoseStatus.java index 94fab37d8b..191ce9e1cd 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/iob/iobCobCalculator/GlucoseStatus.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/iob/iobCobCalculator/GlucoseStatus.java @@ -59,7 +59,7 @@ public class GlucoseStatus { //long fromtime = DateUtil.now() - 60 * 1000L * 45; //List data = MainApp.getDbHelper().getBgreadingsDataFromTime(fromtime, false); - synchronized (IobCobCalculatorPlugin.getPlugin().dataLock) { + synchronized (IobCobCalculatorPlugin.getPlugin().getDataLock()) { List data = IobCobCalculatorPlugin.getPlugin().getBgReadings(); diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/iob/iobCobCalculator/IobCobCalculatorPlugin.java b/app/src/main/java/info/nightscout/androidaps/plugins/iob/iobCobCalculator/IobCobCalculatorPlugin.java index 4897ff55ac..94b687b863 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/iob/iobCobCalculator/IobCobCalculatorPlugin.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/iob/iobCobCalculator/IobCobCalculatorPlugin.java @@ -65,7 +65,7 @@ public class IobCobCalculatorPlugin extends PluginBase { private volatile List bgReadings = null; // newest at index 0 private volatile List bucketed_data = null; - final Object dataLock = new Object(); + private final Object dataLock = new Object(); boolean stopCalculationTrigger = false; private Thread thread = null; @@ -108,6 +108,10 @@ public class IobCobCalculatorPlugin extends PluginBase { return bucketed_data; } + public Object getDataLock() { + return dataLock; + } + // roundup to whole minute public static long roundUpTime(long time) { if (time % 60000 == 0) diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/iob/iobCobCalculator/IobCobOref1Thread.java b/app/src/main/java/info/nightscout/androidaps/plugins/iob/iobCobCalculator/IobCobOref1Thread.java index 492f3c0ff1..c483ffd2a6 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/iob/iobCobCalculator/IobCobOref1Thread.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/iob/iobCobCalculator/IobCobOref1Thread.java @@ -96,7 +96,7 @@ public class IobCobOref1Thread extends Thread { long oldestTimeWithData = iobCobCalculatorPlugin.calculateDetectionStart(end, limitDataToOldestAvailable); - synchronized (iobCobCalculatorPlugin.dataLock) { + synchronized (iobCobCalculatorPlugin.getDataLock()) { if (bgDataReload) { iobCobCalculatorPlugin.loadBgData(end); iobCobCalculatorPlugin.createBucketedData(); diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/iob/iobCobCalculator/IobCobThread.java b/app/src/main/java/info/nightscout/androidaps/plugins/iob/iobCobCalculator/IobCobThread.java index 2aacb4f453..9ddf18abb0 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/iob/iobCobCalculator/IobCobThread.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/iob/iobCobCalculator/IobCobThread.java @@ -95,7 +95,7 @@ public class IobCobThread extends Thread { long oldestTimeWithData = iobCobCalculatorPlugin.calculateDetectionStart(end, limitDataToOldestAvailable); - synchronized (iobCobCalculatorPlugin.dataLock) { + synchronized (iobCobCalculatorPlugin.getDataLock()) { if (bgDataReload) { iobCobCalculatorPlugin.loadBgData(end); iobCobCalculatorPlugin.createBucketedData(); diff --git a/app/src/test/java/info/AAPSMocker.java b/app/src/test/java/info/AAPSMocker.java index 850affa224..50bd20d198 100644 --- a/app/src/test/java/info/AAPSMocker.java +++ b/app/src/test/java/info/AAPSMocker.java @@ -282,10 +282,13 @@ public class AAPSMocker { PowerMockito.when(ProfileFunctions.getInstance().getProfileName()).thenReturn(TESTPROFILENAME); } - public static void mockIobCobCalculatorPlugin() { + public static IobCobCalculatorPlugin mockIobCobCalculatorPlugin() { PowerMockito.mockStatic(IobCobCalculatorPlugin.class); IobCobCalculatorPlugin iobCobCalculatorPlugin = PowerMockito.mock(IobCobCalculatorPlugin.class); PowerMockito.when(IobCobCalculatorPlugin.getPlugin()).thenReturn(iobCobCalculatorPlugin); + Object dataLock = new Object(); + PowerMockito.when(iobCobCalculatorPlugin.getDataLock()).thenReturn(dataLock); + return iobCobCalculatorPlugin; } private static MockedBus bus = new MockedBus(); diff --git a/app/src/test/java/info/nightscout/androidaps/data/GlucoseStatusTest.java b/app/src/test/java/info/nightscout/androidaps/plugins/iob/iobCobCalculatorPlugin/GlucoseStatusTest.java similarity index 97% rename from app/src/test/java/info/nightscout/androidaps/data/GlucoseStatusTest.java rename to app/src/test/java/info/nightscout/androidaps/plugins/iob/iobCobCalculatorPlugin/GlucoseStatusTest.java index cdbd276bae..19e497b834 100644 --- a/app/src/test/java/info/nightscout/androidaps/data/GlucoseStatusTest.java +++ b/app/src/test/java/info/nightscout/androidaps/plugins/iob/iobCobCalculatorPlugin/GlucoseStatusTest.java @@ -1,4 +1,4 @@ -package info.nightscout.androidaps.data; +package info.nightscout.androidaps.plugins.iob.iobCobCalculatorPlugin; import org.json.JSONException; import org.json.JSONObject; @@ -134,10 +134,7 @@ public class GlucoseStatusTest { public void initMocking() { AAPSMocker.mockMainApp(); AAPSMocker.mockStrings(); - - PowerMockito.mockStatic(IobCobCalculatorPlugin.class); - iobCobCalculatorPlugin = mock(IobCobCalculatorPlugin.class); - when(IobCobCalculatorPlugin.getPlugin()).thenReturn(iobCobCalculatorPlugin); + iobCobCalculatorPlugin = AAPSMocker.mockIobCobCalculatorPlugin(); PowerMockito.mockStatic(DateUtil.class); when(DateUtil.now()).thenReturn(1514766900000L + T.mins(1).msecs()); From 39412ae032acdd8a13b9364fca648ad584a946f6 Mon Sep 17 00:00:00 2001 From: Tebbe Ubben Date: Wed, 17 Apr 2019 17:31:10 +0200 Subject: [PATCH 22/42] Fix initial sqlite_sequence for Insight driver --- .../nightscout/androidaps/db/DatabaseHelper.java | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/app/src/main/java/info/nightscout/androidaps/db/DatabaseHelper.java b/app/src/main/java/info/nightscout/androidaps/db/DatabaseHelper.java index b024f64711..ad16cb90f6 100644 --- a/app/src/main/java/info/nightscout/androidaps/db/DatabaseHelper.java +++ b/app/src/main/java/info/nightscout/androidaps/db/DatabaseHelper.java @@ -131,8 +131,10 @@ public class DatabaseHelper extends OrmLiteSqliteOpenHelper { TableUtils.createTableIfNotExists(connectionSource, InsightHistoryOffset.class); TableUtils.createTableIfNotExists(connectionSource, InsightBolusID.class); TableUtils.createTableIfNotExists(connectionSource, InsightPumpID.class); - database.execSQL("UPDATE SQLITE_SEQUENCE SET seq = " + System.currentTimeMillis() + " WHERE name = " + DATABASE_INSIGHT_BOLUS_IDS); - database.execSQL("UPDATE SQLITE_SEQUENCE SET seq = " + System.currentTimeMillis() + " WHERE name = " + DATABASE_INSIGHT_PUMP_IDS); + database.execSQL("INSERT INTO sqlite_sequence (name, seq) SELECT \"" + DATABASE_INSIGHT_BOLUS_IDS + "\", " + System.currentTimeMillis() + " " + + "WHERE NOT EXISTS (SELECT 1 FROM sqlite_sequence WHERE name = \"" + DATABASE_INSIGHT_BOLUS_IDS + "\")"); + database.execSQL("INSERT INTO sqlite_sequence (name, seq) SELECT \"" + DATABASE_INSIGHT_PUMP_IDS + "\", " + System.currentTimeMillis() + " " + + "WHERE NOT EXISTS (SELECT 1 FROM sqlite_sequence WHERE name = \"" + DATABASE_INSIGHT_PUMP_IDS + "\")"); } catch (SQLException e) { log.error("Can't create database", e); throw new RuntimeException(e); @@ -153,8 +155,10 @@ public class DatabaseHelper extends OrmLiteSqliteOpenHelper { TableUtils.createTableIfNotExists(connectionSource, InsightHistoryOffset.class); TableUtils.createTableIfNotExists(connectionSource, InsightBolusID.class); TableUtils.createTableIfNotExists(connectionSource, InsightPumpID.class); - database.execSQL("UPDATE SQLITE_SEQUENCE SET seq = " + System.currentTimeMillis() + " WHERE name = " + DATABASE_INSIGHT_BOLUS_IDS); - database.execSQL("UPDATE SQLITE_SEQUENCE SET seq = " + System.currentTimeMillis() + " WHERE name = " + DATABASE_INSIGHT_PUMP_IDS); + database.execSQL("INSERT INTO sqlite_sequence (name, seq) SELECT \"" + DATABASE_INSIGHT_BOLUS_IDS + "\", " + System.currentTimeMillis() + " " + + "WHERE NOT EXISTS (SELECT 1 FROM sqlite_sequence WHERE name = \"" + DATABASE_INSIGHT_BOLUS_IDS + "\")"); + database.execSQL("INSERT INTO sqlite_sequence (name, seq) SELECT \"" + DATABASE_INSIGHT_PUMP_IDS + "\", " + System.currentTimeMillis() + " " + + "WHERE NOT EXISTS (SELECT 1 FROM sqlite_sequence WHERE name = \"" + DATABASE_INSIGHT_PUMP_IDS + "\")"); } else { log.info(DatabaseHelper.class.getName(), "onUpgrade"); TableUtils.dropTable(connectionSource, TempTarget.class, true); From 0eee1c341274e216baac47be71e2af2587a09195 Mon Sep 17 00:00:00 2001 From: Milos Kozak Date: Wed, 17 Apr 2019 20:31:00 +0200 Subject: [PATCH 23/42] New Crowdin translations (#1745) * New translations strings.xml (Russian) * New translations strings.xml (Russian) --- app/src/main/res/values-ru/strings.xml | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/app/src/main/res/values-ru/strings.xml b/app/src/main/res/values-ru/strings.xml index e970c21d48..26d330f64b 100644 --- a/app/src/main/res/values-ru/strings.xml +++ b/app/src/main/res/values-ru/strings.xml @@ -1,11 +1,11 @@ - Безопасность назначений + Безопасность терапии Макс разрешенный болюс [U] ед. макс разрешенные углеводы (г) опции - синхронисировать назначения с NS + Синхронизировать назначения с NS обнулить базы Вы действительно хотите обнулить базы данных? Выход @@ -116,7 +116,7 @@ профиль NS простой профиль ВремБазал - назначения + Терапия виртуальная помпа Портал лечения / назначений помпа @@ -154,7 +154,7 @@ калькулятор применено ограничение! подтверждение - введите новое назначение + Ввести новое назначение: болюс болюс: базал @@ -690,7 +690,7 @@ Получение времени помпы повторное использование Контроль с часов - Поставить временные цели и ввести назначения с часов. + Ставить временные цели и вводить назначения с часов. Истекло время ожидания соединения Еда грамм @@ -1044,7 +1044,7 @@ Context | Edit Context AndroidAPS перезапущен Найдены сохраненные параметры Внимание: Если вы активируете подключение к невиртуальной помпе, AndroidAPS скопирует настройки базала в профиль помпы, перезаписывая существующие настройки, хранящиеся в ней. Убедитесь, что настройки базала в AndroidAPS корректны. Если вы не уверены или не хотите перезаписать настройки базала на помпу, нажмите отменить и повторите подключение в другое время. - Данные назначений неполные + Данные терапии неполные Параметры обслуживания Адрес электронной почты Недопустимый e-mail From 9be0ffffa9f37274c22833f1c112fb1ffd260277 Mon Sep 17 00:00:00 2001 From: AdrianLxM Date: Wed, 17 Apr 2019 21:28:32 +0200 Subject: [PATCH 24/42] verify static calls on mocked classes --- .../VersionCheckerUtilsKtTest.kt | 45 ++++++++++++++++++- 1 file changed, 43 insertions(+), 2 deletions(-) diff --git a/app/src/test/java/info/nightscout/androidaps/plugins/general/versionChecker/VersionCheckerUtilsKtTest.kt b/app/src/test/java/info/nightscout/androidaps/plugins/general/versionChecker/VersionCheckerUtilsKtTest.kt index b1b62b589d..d711c4f958 100644 --- a/app/src/test/java/info/nightscout/androidaps/plugins/general/versionChecker/VersionCheckerUtilsKtTest.kt +++ b/app/src/test/java/info/nightscout/androidaps/plugins/general/versionChecker/VersionCheckerUtilsKtTest.kt @@ -63,24 +63,43 @@ class VersionCheckerUtilsKtTest { @PrepareForTest(MainApp::class, L::class, SP::class) fun `should find update1`() { val bus = prepareBus() + compareWithCurrentVersion(newVersion = "2.2.3", currentVersion = "2.2.1") + verify(bus, times(1)).post(any()) + + PowerMockito.verifyStatic(SP::class.java, times(1)) + SP.putLong(eq(R.string.key_new_version_available_since), ArgumentMatchers.anyLong()) + PowerMockito.verifyNoMoreInteractions(SP::class.java) + } @Test @PrepareForTest(MainApp::class, L::class, SP::class) fun `should find update2`() { val bus = prepareBus() + compareWithCurrentVersion(newVersion = "2.2.3", currentVersion = "2.2.1-dev") + verify(bus, times(1)).post(any()) + + PowerMockito.verifyStatic(SP::class.java, times(1)) + SP.putLong(eq(R.string.key_new_version_available_since), ArgumentMatchers.anyLong()) + PowerMockito.verifyNoMoreInteractions(SP::class.java) } @Test @PrepareForTest(MainApp::class, L::class, SP::class) fun `should find update3`() { val bus = prepareBus() + compareWithCurrentVersion(newVersion = "2.2.3", currentVersion = "2.1") + verify(bus, times(1)).post(any()) + + PowerMockito.verifyStatic(SP::class.java, times(1)) + SP.putLong(eq(R.string.key_new_version_available_since), ArgumentMatchers.anyLong()) + PowerMockito.verifyNoMoreInteractions(SP::class.java) } @Test @@ -91,6 +110,10 @@ class VersionCheckerUtilsKtTest { compareWithCurrentVersion(newVersion = "2.2", currentVersion = "2.1.1") verify(bus, times(1)).post(any()) + + PowerMockito.verifyStatic(SP::class.java, times(1)) + SP.putLong(eq(R.string.key_new_version_available_since), ArgumentMatchers.anyLong()) + PowerMockito.verifyNoMoreInteractions(SP::class.java) } @Test @@ -98,16 +121,25 @@ class VersionCheckerUtilsKtTest { fun `should find update5`() { val bus = prepareBus() compareWithCurrentVersion(newVersion = "2.2.1", currentVersion = "2.2-dev") + verify(bus, times(1)).post(any()) + + PowerMockito.verifyStatic(SP::class.java, times(1)) + SP.putLong(eq(R.string.key_new_version_available_since), ArgumentMatchers.anyLong()) + PowerMockito.verifyNoMoreInteractions(SP::class.java) } @Test @PrepareForTest(MainApp::class, L::class, SP::class) fun `should find update6`() { val bus = prepareBus() - val sp = prepareSP() compareWithCurrentVersion(newVersion = "2.2.1", currentVersion = "2.2dev") + verify(bus, times(1)).post(any()) + + PowerMockito.verifyStatic(SP::class.java, times(1)) + SP.putLong(eq(R.string.key_new_version_available_since), ArgumentMatchers.anyLong()) + PowerMockito.verifyNoMoreInteractions(SP::class.java) } @Test @@ -122,8 +154,12 @@ class VersionCheckerUtilsKtTest { """.trimMargin() val bus = prepareBus() compareWithCurrentVersion(buildGradle.byteInputStream().findVersion(), currentVersion = "2.2.2") + verify(bus, times(0)).post(any()) - verify(SP, times(1)).remove(R.string.key_new_version_available_since) + + PowerMockito.verifyStatic(SP::class.java, times(1)) + SP.remove(eq(R.string.key_new_version_available_since)) + PowerMockito.verifyNoMoreInteractions(SP::class.java) } @Test @@ -138,7 +174,12 @@ class VersionCheckerUtilsKtTest { """.trimMargin() val bus = prepareBus() compareWithCurrentVersion(buildGradle.byteInputStream().findVersion(), currentVersion = "2.2.2") + verify(bus, times(1)).post(any()) + + PowerMockito.verifyStatic(SP::class.java, times(1)) + SP.putLong(eq(R.string.key_new_version_available_since), ArgumentMatchers.anyLong()) + PowerMockito.verifyNoMoreInteractions(SP::class.java) } From 84573cc0ccdf6797532d177888f04043d1a70433 Mon Sep 17 00:00:00 2001 From: AdrianLxM Date: Wed, 17 Apr 2019 21:29:16 +0200 Subject: [PATCH 25/42] refactor constraints checker --- .../info/nightscout/androidaps/MainApp.java | 2 +- .../androidaps/data/ConstraintChecker.java | 67 +++++++++---------- .../versionChecker/VersionCheckerPlugin.kt | 21 +++++- .../interfaces/ConstraintsCheckerTest.java | 2 +- 4 files changed, 54 insertions(+), 38 deletions(-) diff --git a/app/src/main/java/info/nightscout/androidaps/MainApp.java b/app/src/main/java/info/nightscout/androidaps/MainApp.java index 8f626365d9..088f0a4bc3 100644 --- a/app/src/main/java/info/nightscout/androidaps/MainApp.java +++ b/app/src/main/java/info/nightscout/androidaps/MainApp.java @@ -119,7 +119,7 @@ public class MainApp extends Application { log.debug("onCreate"); sInstance = this; sResources = getResources(); - sConstraintsChecker = new ConstraintChecker(this); + sConstraintsChecker = new ConstraintChecker(); sDatabaseHelper = OpenHelperManager.getHelper(sInstance, DatabaseHelper.class); try { diff --git a/app/src/main/java/info/nightscout/androidaps/data/ConstraintChecker.java b/app/src/main/java/info/nightscout/androidaps/data/ConstraintChecker.java index 68664033d0..b1267e81bc 100644 --- a/app/src/main/java/info/nightscout/androidaps/data/ConstraintChecker.java +++ b/app/src/main/java/info/nightscout/androidaps/data/ConstraintChecker.java @@ -1,7 +1,11 @@ package info.nightscout.androidaps.data; +import android.support.annotation.NonNull; + import java.util.ArrayList; +import javax.annotation.Nonnull; + import info.nightscout.androidaps.Constants; import info.nightscout.androidaps.MainApp; import info.nightscout.androidaps.interfaces.Constraint; @@ -15,13 +19,6 @@ import info.nightscout.androidaps.interfaces.PluginType; public class ConstraintChecker implements ConstraintsInterface { - private MainApp mainApp; - - public ConstraintChecker(MainApp mainApp) { - this.mainApp = mainApp; - } - - public Constraint isLoopInvokationAllowed() { return isLoopInvocationAllowed(new Constraint<>(true)); } @@ -79,9 +76,9 @@ public class ConstraintChecker implements ConstraintsInterface { } @Override - public Constraint isLoopInvocationAllowed(Constraint value) { + public Constraint isLoopInvocationAllowed(@NonNull Constraint value) { - ArrayList constraintsPlugins = mainApp.getSpecificPluginsListByInterface(ConstraintsInterface.class); + ArrayList constraintsPlugins = MainApp.getSpecificPluginsListByInterface(ConstraintsInterface.class); for (PluginBase p : constraintsPlugins) { ConstraintsInterface constraint = (ConstraintsInterface) p; if (!p.isEnabled(PluginType.CONSTRAINTS)) continue; @@ -91,9 +88,9 @@ public class ConstraintChecker implements ConstraintsInterface { } @Override - public Constraint isClosedLoopAllowed(Constraint value) { + public Constraint isClosedLoopAllowed(@NonNull Constraint value) { - ArrayList constraintsPlugins = mainApp.getSpecificPluginsListByInterface(ConstraintsInterface.class); + ArrayList constraintsPlugins = MainApp.getSpecificPluginsListByInterface(ConstraintsInterface.class); for (PluginBase p : constraintsPlugins) { ConstraintsInterface constraint = (ConstraintsInterface) p; if (!p.isEnabled(PluginType.CONSTRAINTS)) continue; @@ -103,9 +100,9 @@ public class ConstraintChecker implements ConstraintsInterface { } @Override - public Constraint isAutosensModeEnabled(Constraint value) { + public Constraint isAutosensModeEnabled(@NonNull Constraint value) { - ArrayList constraintsPlugins = mainApp.getSpecificPluginsListByInterface(ConstraintsInterface.class); + ArrayList constraintsPlugins = MainApp.getSpecificPluginsListByInterface(ConstraintsInterface.class); for (PluginBase p : constraintsPlugins) { ConstraintsInterface constraint = (ConstraintsInterface) p; if (!p.isEnabled(PluginType.CONSTRAINTS)) continue; @@ -115,9 +112,9 @@ public class ConstraintChecker implements ConstraintsInterface { } @Override - public Constraint isAMAModeEnabled(Constraint value) { + public Constraint isAMAModeEnabled(@NonNull Constraint value) { - ArrayList constraintsPlugins = mainApp.getSpecificPluginsListByInterface(ConstraintsInterface.class); + ArrayList constraintsPlugins = MainApp.getSpecificPluginsListByInterface(ConstraintsInterface.class); for (PluginBase p : constraintsPlugins) { ConstraintsInterface constrain = (ConstraintsInterface) p; if (!p.isEnabled(PluginType.CONSTRAINTS)) continue; @@ -127,9 +124,9 @@ public class ConstraintChecker implements ConstraintsInterface { } @Override - public Constraint isSMBModeEnabled(Constraint value) { + public Constraint isSMBModeEnabled(@NonNull Constraint value) { - ArrayList constraintsPlugins = mainApp.getSpecificPluginsListByInterface(ConstraintsInterface.class); + ArrayList constraintsPlugins = MainApp.getSpecificPluginsListByInterface(ConstraintsInterface.class); for (PluginBase p : constraintsPlugins) { ConstraintsInterface constraint = (ConstraintsInterface) p; if (!p.isEnabled(PluginType.CONSTRAINTS)) continue; @@ -139,9 +136,9 @@ public class ConstraintChecker implements ConstraintsInterface { } @Override - public Constraint isUAMEnabled(Constraint value) { + public Constraint isUAMEnabled(@NonNull Constraint value) { - ArrayList constraintsPlugins = mainApp.getSpecificPluginsListByInterface(ConstraintsInterface.class); + ArrayList constraintsPlugins = MainApp.getSpecificPluginsListByInterface(ConstraintsInterface.class); for (PluginBase p : constraintsPlugins) { ConstraintsInterface constraint = (ConstraintsInterface) p; if (!p.isEnabled(PluginType.CONSTRAINTS)) continue; @@ -151,8 +148,8 @@ public class ConstraintChecker implements ConstraintsInterface { } @Override - public Constraint isAdvancedFilteringEnabled(Constraint value) { - ArrayList constraintsPlugins = mainApp.getSpecificPluginsListByInterface(ConstraintsInterface.class); + public Constraint isAdvancedFilteringEnabled(@NonNull Constraint value) { + ArrayList constraintsPlugins = MainApp.getSpecificPluginsListByInterface(ConstraintsInterface.class); for (PluginBase p : constraintsPlugins) { ConstraintsInterface constraint = (ConstraintsInterface) p; if (!p.isEnabled(PluginType.CONSTRAINTS)) continue; @@ -162,8 +159,8 @@ public class ConstraintChecker implements ConstraintsInterface { } @Override - public Constraint isSuperBolusEnabled(Constraint value) { - ArrayList constraintsPlugins = mainApp.getSpecificPluginsListByInterface(ConstraintsInterface.class); + public Constraint isSuperBolusEnabled(@NonNull Constraint value) { + ArrayList constraintsPlugins = MainApp.getSpecificPluginsListByInterface(ConstraintsInterface.class); for (PluginBase p : constraintsPlugins) { ConstraintsInterface constraint = (ConstraintsInterface) p; if (!p.isEnabled(PluginType.CONSTRAINTS)) continue; @@ -173,8 +170,8 @@ public class ConstraintChecker implements ConstraintsInterface { } @Override - public Constraint applyBasalConstraints(Constraint absoluteRate, Profile profile) { - ArrayList constraintsPlugins = mainApp.getSpecificPluginsListByInterface(ConstraintsInterface.class); + public Constraint applyBasalConstraints(@NonNull Constraint absoluteRate, Profile profile) { + ArrayList constraintsPlugins = MainApp.getSpecificPluginsListByInterface(ConstraintsInterface.class); for (PluginBase p : constraintsPlugins) { ConstraintsInterface constraint = (ConstraintsInterface) p; if (!p.isEnabled(PluginType.CONSTRAINTS)) continue; @@ -184,8 +181,8 @@ public class ConstraintChecker implements ConstraintsInterface { } @Override - public Constraint applyBasalPercentConstraints(Constraint percentRate, Profile profile) { - ArrayList constraintsPlugins = mainApp.getSpecificPluginsListByInterface(ConstraintsInterface.class); + public Constraint applyBasalPercentConstraints(@NonNull Constraint percentRate, Profile profile) { + ArrayList constraintsPlugins = MainApp.getSpecificPluginsListByInterface(ConstraintsInterface.class); for (PluginBase p : constraintsPlugins) { ConstraintsInterface constrain = (ConstraintsInterface) p; if (!p.isEnabled(PluginType.CONSTRAINTS)) continue; @@ -195,8 +192,8 @@ public class ConstraintChecker implements ConstraintsInterface { } @Override - public Constraint applyBolusConstraints(Constraint insulin) { - ArrayList constraintsPlugins = mainApp.getSpecificPluginsListByInterface(ConstraintsInterface.class); + public Constraint applyBolusConstraints(@NonNull Constraint insulin) { + ArrayList constraintsPlugins = MainApp.getSpecificPluginsListByInterface(ConstraintsInterface.class); for (PluginBase p : constraintsPlugins) { ConstraintsInterface constrain = (ConstraintsInterface) p; if (!p.isEnabled(PluginType.CONSTRAINTS)) continue; @@ -206,8 +203,8 @@ public class ConstraintChecker implements ConstraintsInterface { } @Override - public Constraint applyExtendedBolusConstraints(Constraint insulin) { - ArrayList constraintsPlugins = mainApp.getSpecificPluginsListByInterface(ConstraintsInterface.class); + public Constraint applyExtendedBolusConstraints(@NonNull Constraint insulin) { + ArrayList constraintsPlugins = MainApp.getSpecificPluginsListByInterface(ConstraintsInterface.class); for (PluginBase p : constraintsPlugins) { ConstraintsInterface constrain = (ConstraintsInterface) p; if (!p.isEnabled(PluginType.CONSTRAINTS)) continue; @@ -217,8 +214,8 @@ public class ConstraintChecker implements ConstraintsInterface { } @Override - public Constraint applyCarbsConstraints(Constraint carbs) { - ArrayList constraintsPlugins = mainApp.getSpecificPluginsListByInterface(ConstraintsInterface.class); + public Constraint applyCarbsConstraints(@NonNull Constraint carbs) { + ArrayList constraintsPlugins = MainApp.getSpecificPluginsListByInterface(ConstraintsInterface.class); for (PluginBase p : constraintsPlugins) { ConstraintsInterface constrain = (ConstraintsInterface) p; if (!p.isEnabled(PluginType.CONSTRAINTS)) continue; @@ -228,8 +225,8 @@ public class ConstraintChecker implements ConstraintsInterface { } @Override - public Constraint applyMaxIOBConstraints(Constraint maxIob) { - ArrayList constraintsPlugins = mainApp.getSpecificPluginsListByInterface(ConstraintsInterface.class); + public Constraint applyMaxIOBConstraints(@NonNull Constraint maxIob) { + ArrayList constraintsPlugins = MainApp.getSpecificPluginsListByInterface(ConstraintsInterface.class); for (PluginBase p : constraintsPlugins) { ConstraintsInterface constrain = (ConstraintsInterface) p; if (!p.isEnabled(PluginType.CONSTRAINTS)) continue; diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/general/versionChecker/VersionCheckerPlugin.kt b/app/src/main/java/info/nightscout/androidaps/plugins/general/versionChecker/VersionCheckerPlugin.kt index 99268bcdd9..e3410549ee 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/general/versionChecker/VersionCheckerPlugin.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/general/versionChecker/VersionCheckerPlugin.kt @@ -17,6 +17,25 @@ object VersionCheckerPlugin : PluginBase(PluginDescription() .pluginName(R.string.versionChecker)), ConstraintsInterface { override fun isClosedLoopAllowed(value: Constraint): Constraint { - return value + return if (isVeryOldVersion()) + Constraint(false) + else + value } + + override fun applyMaxIOBConstraints(maxIob: Constraint): Constraint { + return if (isOldVersion()) + Constraint(0.toDouble()) + else + maxIob + } + + private fun isOldVersion(): Boolean { + return true + } + + private fun isVeryOldVersion(): Boolean { + return true + } + } diff --git a/app/src/test/java/info/nightscout/androidaps/interfaces/ConstraintsCheckerTest.java b/app/src/test/java/info/nightscout/androidaps/interfaces/ConstraintsCheckerTest.java index ee03ef73d7..fbbd72f064 100644 --- a/app/src/test/java/info/nightscout/androidaps/interfaces/ConstraintsCheckerTest.java +++ b/app/src/test/java/info/nightscout/androidaps/interfaces/ConstraintsCheckerTest.java @@ -289,7 +289,7 @@ public class ConstraintsCheckerTest { //SafetyPlugin when(ConfigBuilderPlugin.getPlugin().getActivePump()).thenReturn(pump); - constraintChecker = new ConstraintChecker(mainApp); + constraintChecker = new ConstraintChecker(); safetyPlugin = SafetyPlugin.getPlugin(); objectivesPlugin = ObjectivesPlugin.getPlugin(); From 4bde759a503c44800ec694095ffaeb5dc0263dd2 Mon Sep 17 00:00:00 2001 From: AdrianLxM Date: Wed, 17 Apr 2019 22:23:35 +0200 Subject: [PATCH 26/42] version checker plugin logic --- .../info/nightscout/androidaps/MainApp.java | 2 + .../overview/notifications/Notification.java | 1 + .../versionChecker/VersionCheckerPlugin.kt | 47 ++++++++++++++----- app/src/main/res/values/strings.xml | 5 ++ 4 files changed, 43 insertions(+), 12 deletions(-) diff --git a/app/src/main/java/info/nightscout/androidaps/MainApp.java b/app/src/main/java/info/nightscout/androidaps/MainApp.java index 088f0a4bc3..e390d12007 100644 --- a/app/src/main/java/info/nightscout/androidaps/MainApp.java +++ b/app/src/main/java/info/nightscout/androidaps/MainApp.java @@ -50,6 +50,7 @@ import info.nightscout.androidaps.plugins.general.nsclient.receivers.DBAccessRec import info.nightscout.androidaps.plugins.general.overview.OverviewPlugin; import info.nightscout.androidaps.plugins.general.persistentNotification.PersistentNotificationPlugin; import info.nightscout.androidaps.plugins.general.smsCommunicator.SmsCommunicatorPlugin; +import info.nightscout.androidaps.plugins.general.versionChecker.VersionCheckerPlugin; import info.nightscout.androidaps.plugins.general.wear.WearPlugin; import info.nightscout.androidaps.plugins.general.xdripStatusline.StatuslinePlugin; import info.nightscout.androidaps.plugins.insulin.InsulinOrefFreePeakPlugin; @@ -179,6 +180,7 @@ public class MainApp extends Application { if (Config.OTHERPROFILES) pluginsList.add(LocalProfilePlugin.getPlugin()); pluginsList.add(TreatmentsPlugin.getPlugin()); if (Config.SAFETY) pluginsList.add(SafetyPlugin.getPlugin()); + if (Config.SAFETY) pluginsList.add(VersionCheckerPlugin.INSTANCE); if (Config.SAFETY) pluginsList.add(StorageConstraintPlugin.getPlugin()); if (Config.APS) pluginsList.add(ObjectivesPlugin.getPlugin()); pluginsList.add(SourceXdripPlugin.getPlugin()); diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/general/overview/notifications/Notification.java b/app/src/main/java/info/nightscout/androidaps/plugins/general/overview/notifications/Notification.java index 3b6bcf615d..f7a4c32360 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/general/overview/notifications/Notification.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/general/overview/notifications/Notification.java @@ -74,6 +74,7 @@ public class Notification { public static final int DST_LOOP_DISABLED = 49; public static final int DST_IN_24H = 50; public static final int DISKFULL = 51; + public static final int OLDVERSION = 52; public int id; diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/general/versionChecker/VersionCheckerPlugin.kt b/app/src/main/java/info/nightscout/androidaps/plugins/general/versionChecker/VersionCheckerPlugin.kt index e3410549ee..d80b3cc7d0 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/general/versionChecker/VersionCheckerPlugin.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/general/versionChecker/VersionCheckerPlugin.kt @@ -1,7 +1,12 @@ package info.nightscout.androidaps.plugins.general.versionChecker +import info.nightscout.androidaps.MainApp import info.nightscout.androidaps.R import info.nightscout.androidaps.interfaces.* +import info.nightscout.androidaps.plugins.general.overview.events.EventNewNotification +import info.nightscout.androidaps.plugins.general.overview.notifications.Notification +import info.nightscout.androidaps.utils.SP +import java.util.concurrent.TimeUnit /** * Usually we would have a class here. @@ -17,25 +22,43 @@ object VersionCheckerPlugin : PluginBase(PluginDescription() .pluginName(R.string.versionChecker)), ConstraintsInterface { override fun isClosedLoopAllowed(value: Constraint): Constraint { - return if (isVeryOldVersion()) - Constraint(false) + checkWarning() + return if (isOldVersion(GRACE_PERIOD_VERY_OLD)) + value.set(false, MainApp.gs(R.string.very_old_version), this) else value } - override fun applyMaxIOBConstraints(maxIob: Constraint): Constraint { - return if (isOldVersion()) - Constraint(0.toDouble()) - else - maxIob + private fun checkWarning() { + val now = System.currentTimeMillis() + if (isOldVersion(GRACE_PERIOD_WARNING) && shouldWarnAgain(now)) { + // store last notification time + SP.putLong(R.string.key_last_versionchecker_waring, now) + + //notify + val message = MainApp.gs(R.string.new_version_warning, Math.round(now / TimeUnit.DAYS.toMillis(1).toDouble())) + val notification = Notification(Notification.OLDVERSION, message, Notification.NORMAL) + MainApp.bus().post(EventNewNotification(notification)) + } } - private fun isOldVersion(): Boolean { - return true + private fun shouldWarnAgain(now: Long) = + now > SP.getLong(R.string.key_last_versionchecker_waring, 0) + WARN_EVERY + + override fun applyMaxIOBConstraints(maxIob: Constraint): Constraint = + if (isOldVersion(GRACE_PERIOD_OLD)) + maxIob.set(0.toDouble(), MainApp.gs(R.string.old_version), this) + else + maxIob + + private fun isOldVersion(gracePeriod: Long): Boolean { + val now = System.currentTimeMillis() + return now > SP.getLong(R.string.key_new_version_available_since, 0) + gracePeriod } - private fun isVeryOldVersion(): Boolean { - return true - } + val WARN_EVERY = TimeUnit.DAYS.toMillis(1) + val GRACE_PERIOD_WARNING = TimeUnit.DAYS.toMillis(30) + val GRACE_PERIOD_OLD = TimeUnit.DAYS.toMillis(60) + val GRACE_PERIOD_VERY_OLD = TimeUnit.DAYS.toMillis(90) } diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index feaab74c41..b149bd0f40 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -1328,6 +1328,11 @@ Profile switch created Version Checker new_version_available_since + last_versionchecker_waring + old version + very old version + New version for at least %1$d days available! Fallback to LGS after 60 days, loop will be disabled after 90 days + %1$d day %1$d days From 092400f7a01a52847cbf2507ee00188b84de217d Mon Sep 17 00:00:00 2001 From: AdrianLxM Date: Wed, 17 Apr 2019 22:45:21 +0200 Subject: [PATCH 27/42] check regularly --- .../nightscout/androidaps/MainActivity.java | 8 ++++++- .../versionChecker/VersionCheckerPlugin.kt | 21 ++++++++++++++++--- app/src/main/res/values/strings.xml | 4 +++- 3 files changed, 28 insertions(+), 5 deletions(-) diff --git a/app/src/main/java/info/nightscout/androidaps/MainActivity.java b/app/src/main/java/info/nightscout/androidaps/MainActivity.java index 7ce5ae2beb..31d462a007 100644 --- a/app/src/main/java/info/nightscout/androidaps/MainActivity.java +++ b/app/src/main/java/info/nightscout/androidaps/MainActivity.java @@ -48,7 +48,9 @@ import info.nightscout.androidaps.events.EventFeatureRunning; import info.nightscout.androidaps.events.EventPreferenceChange; import info.nightscout.androidaps.events.EventRefreshGui; import info.nightscout.androidaps.interfaces.PluginBase; +import info.nightscout.androidaps.interfaces.PluginType; import info.nightscout.androidaps.logging.L; +import info.nightscout.androidaps.plugins.aps.loop.LoopPlugin; import info.nightscout.androidaps.plugins.configBuilder.ProfileFunctions; import info.nightscout.androidaps.plugins.general.nsclient.data.NSSettingsStatus; import info.nightscout.androidaps.plugins.general.versionChecker.VersionCheckerUtilsKt; @@ -115,7 +117,11 @@ public class MainActivity extends AppCompatActivity { public void onPageScrollStateChanged(int state) { } }); - VersionCheckerUtilsKt.checkVersion(); + + //Check here if loop plugin is disabled. Else check via constraints + if (!LoopPlugin.getPlugin().isEnabled(PluginType.LOOP)) + VersionCheckerUtilsKt.checkVersion(); + FabricPrivacy.setUserStats(); } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/general/versionChecker/VersionCheckerPlugin.kt b/app/src/main/java/info/nightscout/androidaps/plugins/general/versionChecker/VersionCheckerPlugin.kt index d80b3cc7d0..7be99e2369 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/general/versionChecker/VersionCheckerPlugin.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/general/versionChecker/VersionCheckerPlugin.kt @@ -23,6 +23,7 @@ object VersionCheckerPlugin : PluginBase(PluginDescription() override fun isClosedLoopAllowed(value: Constraint): Constraint { checkWarning() + checkUpdate() return if (isOldVersion(GRACE_PERIOD_VERY_OLD)) value.set(false, MainApp.gs(R.string.very_old_version), this) else @@ -33,7 +34,7 @@ object VersionCheckerPlugin : PluginBase(PluginDescription() val now = System.currentTimeMillis() if (isOldVersion(GRACE_PERIOD_WARNING) && shouldWarnAgain(now)) { // store last notification time - SP.putLong(R.string.key_last_versionchecker_waring, now) + SP.putLong(R.string.key_last_versionchecker_warning, now) //notify val message = MainApp.gs(R.string.new_version_warning, Math.round(now / TimeUnit.DAYS.toMillis(1).toDouble())) @@ -42,8 +43,21 @@ object VersionCheckerPlugin : PluginBase(PluginDescription() } } + private fun checkUpdate() { + val now = System.currentTimeMillis() + if (shouldCheckVersionAgain(now)) { + // store last notification time + SP.putLong(R.string.key_last_versioncheck, now) + + checkVersion() + } + } + + private fun shouldCheckVersionAgain(now: Long) = + now > SP.getLong(R.string.key_last_versioncheck, 0) + CHECK_EVERY + private fun shouldWarnAgain(now: Long) = - now > SP.getLong(R.string.key_last_versionchecker_waring, 0) + WARN_EVERY + now > SP.getLong(R.string.key_last_versionchecker_warning, 0) + WARN_EVERY override fun applyMaxIOBConstraints(maxIob: Constraint): Constraint = if (isOldVersion(GRACE_PERIOD_OLD)) @@ -53,9 +67,10 @@ object VersionCheckerPlugin : PluginBase(PluginDescription() private fun isOldVersion(gracePeriod: Long): Boolean { val now = System.currentTimeMillis() - return now > SP.getLong(R.string.key_new_version_available_since, 0) + gracePeriod + return now > SP.getLong(R.string.key_new_version_available_since, 0) + gracePeriod } + val CHECK_EVERY = TimeUnit.DAYS.toMillis(1) val WARN_EVERY = TimeUnit.DAYS.toMillis(1) val GRACE_PERIOD_WARNING = TimeUnit.DAYS.toMillis(30) val GRACE_PERIOD_OLD = TimeUnit.DAYS.toMillis(60) diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index b149bd0f40..9aa326361b 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -1328,7 +1328,9 @@ Profile switch created Version Checker new_version_available_since - last_versionchecker_waring + last_versionchecker_waring + key_last_versioncheck + old version very old version New version for at least %1$d days available! Fallback to LGS after 60 days, loop will be disabled after 90 days From 6c6b23066bf1fe1ed45bf34d560e6606f7daf9a1 Mon Sep 17 00:00:00 2001 From: AdrianLxM Date: Thu, 18 Apr 2019 00:33:24 +0200 Subject: [PATCH 28/42] mocking the time --- .../versionChecker/VersionCheckerUtilsKtTest.kt | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/app/src/test/java/info/nightscout/androidaps/plugins/general/versionChecker/VersionCheckerUtilsKtTest.kt b/app/src/test/java/info/nightscout/androidaps/plugins/general/versionChecker/VersionCheckerUtilsKtTest.kt index d711c4f958..29725e4d9e 100644 --- a/app/src/test/java/info/nightscout/androidaps/plugins/general/versionChecker/VersionCheckerUtilsKtTest.kt +++ b/app/src/test/java/info/nightscout/androidaps/plugins/general/versionChecker/VersionCheckerUtilsKtTest.kt @@ -14,6 +14,7 @@ import org.powermock.api.mockito.PowerMockito import org.powermock.core.classloader.annotations.PrepareForTest import org.powermock.modules.junit4.PowerMockRunner + @RunWith(PowerMockRunner::class) class VersionCheckerUtilsKtTest { @Test @@ -183,6 +184,15 @@ class VersionCheckerUtilsKtTest { } + @Test + @PrepareForTest(System::class) + fun `set time`() { + PowerMockito.spy(System::class.java) + PowerMockito.`when`(System.currentTimeMillis()).thenReturn(100L) + + assertEquals(100L, System.currentTimeMillis()) + } + private fun prepareBus(): Bus { PowerMockito.mockStatic(MainApp::class.java) val mainApp = mock(MainApp::class.java) @@ -199,8 +209,8 @@ class VersionCheckerUtilsKtTest { } private fun prepareLogging() { - PowerMockito.mockStatic(L::class.java) - `when`(L.isEnabled(any())).thenReturn(true) + PowerMockito.mockStatic(L::class.java) + `when`(L.isEnabled(any())).thenReturn(true) } } \ No newline at end of file From cb5197950e7c32fda4cb12a2d7779101899dfb35 Mon Sep 17 00:00:00 2001 From: Milos Kozak Date: Thu, 18 Apr 2019 14:05:19 +0200 Subject: [PATCH 29/42] New translations strings.xml (Portuguese) --- app/src/main/res/values-pt/strings.xml | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/app/src/main/res/values-pt/strings.xml b/app/src/main/res/values-pt/strings.xml index 6499f63e59..33d67541f7 100644 --- a/app/src/main/res/values-pt/strings.xml +++ b/app/src/main/res/values-pt/strings.xml @@ -9,6 +9,7 @@ Reinicializar base de dados Quer realmente reiniciar a base de dados? Sair + Usar bólus prolongado de >200%% Dispositivo Bluetooth DanaR Usar sempre valores absolutos de basal Por favor, reinicie o seu telefone ou reinicie o AndroidAPS a partir das Configurações do Sistema \ncaso contrário, o AndroidAPS não terá registro (importante para controlar e verificar se os algoritmos estão a funcionar corretamente)! @@ -313,6 +314,7 @@ Parar STOP PRESSIONADO À espera da bomba + Vão ser administradas %1$.2fU Configuração da visualização e monitoramento, e análise de rácios e basals Verificar se a BG está disponível no Nightscout, e se os dados de insulina da bomba estão a ser carregados A iniciar um open loop @@ -335,11 +337,23 @@ Loop desactivado Loop activado %1$.2f limitado a %2$.2f + O valor %1$s está fora dos limites permitidos O comando remoto não é permitido + O bólus remoto não está disponível. Tente novamente mais tarde. + Para começar a basal %1$.2fU/h durante%2$d min responda com o código %3$s + Para mudar o perfil para %1$s %2$d%% responda com o código %3$s + Para começar o bólus estendido %1$.2fU/h para %2$d min responda com o código %3$s + Para começar a basal %1$d% U/h durante %2$d min responda com o código %3$s Para suspender o loop por %1$d minutos resposta com código %2$s Basal temporária %1$.2fU/h para %2$d min iniciada com êxito + Bólus estendido %1$.2fU/h para %2$d min iniciado com êxito + Basal temporária %1$d% U/h durante%2$d min iniciada com êxito Início basal temp falhou + Falha ao iniciar o bólus estendido + Para parar a basal temporária responda com o código %1$s + Para parar o bólus temporário responda com o código %1$s Basal temp cancelada + Bólus estendido cancelado Não foi possivel cancelar a basal temp Falhou o cancelamento do bolus extendido Comando desconhecido ou resposta errada @@ -450,6 +464,7 @@ Perfil Valor padrão: 3 Por segurança é o valor limite estabelecido por OpenAPS. O que faz é limitar a basal a x3 a basal mázima. Se necessário modificar este valor, por favor ter em conta que os dados apontam para que os limites de segurança sejam - 3 x max diario ou 4x valor actual (qual seja menor) como valores máximos. Valor padrão: 4 Esta é a outra parte dos valores limites de segurança - 3 x max diário ou 4x valor actual - do OpenAPS. Isto define que não importa o valor da basal máxima definido na bomba, o valor máximo da basal temporária não pode ser maior que 4 x o valor da basal definida na bomba. O objectivo é evitar que sejam determinadas basais temporárias demasiado elevadas antes que se perceba como o algoritmo funciona. 4x é um valor que a maior parte das pessoas nunca necessitará de alterar pois o mais provável é necessitar de alterar outras definições para não necessitar de \"ultrapassar\" este limite de segurança. + Valor predefinido: 1.2\n Este é um multiplicador para autosens (e em breve autotune) que coloca um limite máximo de 20%% aos rácios superiores e inferiores de autosens, o que por sua vez calcula o quão alto autosens pode ajustar a basal, quão pode baixar o Factor de Sensibilidade (FSI) e baixar o valor alvo de glicose no sangue. Valor padrão: 0.7\nO outro lado dos limites de segurança do autosens. Coloca um tecto no quão baixo autosens pode ajustar as basais, e quão alto pode ajustar os valores de ISF e valor alvo de glucose no sangue (BG). Autosens também ajusta os alvos Valor padrão: true\nÉ usado para permitir que autosens possa ajustar os valores alvo de glucose no sangue (BG), além de ISF e basais. @@ -462,6 +477,7 @@ Número de telefone não é válido SMS número de telefone inválido Calibração + Enviar calibração %1$.1f para o xDrip? xDrip+ não está instalado Calibração enviada para o xDrip Calibração enviada. Recepção têm de estar activada no xDrip. @@ -602,6 +618,7 @@ Configurações de absorção Tempo máx. absorção refeição [h] Tempo em horas, espectável para que todos os hidratos de carbono da refeição sejam absorvidos + Visualizar bólus prolongado como %% SAGE IAGE CAGE @@ -714,6 +731,8 @@ Enviar dados Glic. para xDrip+ Seleccionar 640g/Eversense como fonte no xDrip+ Glic NSCliente + Valor da basal alterado para o valor mínimo suportado: %1$s + Valor da basal alterado para o valor máximo suportado: %1$s Cálculos Glic Cálculo de Bólus IOB Cálculo de Basal IOB @@ -731,6 +750,8 @@ Modo fechado ativado IOB máxima definida correctamente Glicemia disponivel desde a fonte selecionada + Valores das basais não definidos por horas: %1$s + Perfil inválido: %1$s A programar a bomba para injectar o bolus Actualizar Estado @@ -1072,6 +1093,7 @@ Alterações do modo de funcionamento de registo Alertas de registo Ativar a emulação TBR + Usar bólus prolongados em vez de basais temporárias para contornar o limite de 250%% Atraso de desconexão [s] Número de série Lançar versão de software @@ -1111,11 +1133,13 @@ Basal temporária: %1$d%% para %2$d / %3$d minutos Estendido: %1$.2f / %2$.2f U por %3$d min Multionda: %1$.2f / %2$.2f U por %3$d min + TDD: %1$.2f Reser:%1$.2fU Bat.: %1$d%% Duração máxima da recuperação [s] Duração mínima da recuperação [s] Duração da recuperação + Tempo de operação excedido - reset bluetooth == ∑ %1$s U U/h g/U @@ -1124,6 +1148,8 @@ Criar evento \"Mudança de Sensor\" automaticamente no NS aquando do início do sensor Tomato (MiaoMiao) Tomato + Horário de Verão em 24h ou menos + Horário de Verão a menos de 3 horas - Closed Loop desligado restrição de armazenamento interno Liberte pelo menos %1$d MB do armazenamento interno! Loop desativado! Formato incorrecto From 619514e159feda8e86b3b7a8acd7da0791c3689f Mon Sep 17 00:00:00 2001 From: Milos Kozak Date: Sun, 21 Apr 2019 10:22:27 +0200 Subject: [PATCH 30/42] fix bugs in strings.xml --- app/src/main/res/values/strings.xml | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 79d626f9be..010005d55f 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -152,8 +152,8 @@ Constraints violation Bolus delivery error Tempbasal delivery error - Basal value [%] - % (100% = current) + Basal value [%%] + %% (100%% = current) Accept new temp basal: Treatment Calculator @@ -276,7 +276,7 @@ Pump IOB Daily units Last bolus - %.1fh ago + %1$.1fh ago Invalid input data Value not set properly Reload profile @@ -582,7 +582,7 @@ Please select patient age to setup safety limits I_understand Glimp - %s needs battery optimalization whitelisting for proper performance + %1$s needs battery optimalization whitelisting for proper performance Loop suspended Suspended (%1$d m) Superbolus (%1$d m) @@ -624,9 +624,9 @@ key_statuslights_res_critical Threshold critical reservoir level [U] key_statuslights_bat_warning - Threshold warning battery level [%] + Threshold warning battery level [%%] key_statuslights_bat_critical - Threshold critical battery level [%] + Threshold critical battery level [%%] IOB COB Firmware @@ -869,7 +869,7 @@ Running Cancelling TBR Setting TBR (%1$d%% / %2$d min) - Bolusing (%.1f U) + Bolusing (%1$.1f U) Refreshing Requested operation not supported by pump Unsafe usage: extended or multiwave boluses are active. Loop mode has been set to low-suspend only 6 hours. Only normal boluses are supported in loop mode From 0361ee858944fff8bab395aaa35e35a62a9cc207 Mon Sep 17 00:00:00 2001 From: AdrianLxM Date: Mon, 22 Apr 2019 14:10:12 +0200 Subject: [PATCH 31/42] update logic version checker --- .../nightscout/androidaps/MainActivity.java | 2 +- .../info/nightscout/androidaps/MainApp.java | 5 +++ .../versionChecker/VersionCheckerPlugin.kt | 22 ++--------- .../versionChecker/VersionCheckerUtils.kt | 37 +++++++++++++++---- app/src/main/res/values/strings.xml | 4 +- .../VersionCheckerUtilsKtTest.kt | 30 +++++++++++---- 6 files changed, 63 insertions(+), 37 deletions(-) diff --git a/app/src/main/java/info/nightscout/androidaps/MainActivity.java b/app/src/main/java/info/nightscout/androidaps/MainActivity.java index 31d462a007..6779b0a467 100644 --- a/app/src/main/java/info/nightscout/androidaps/MainActivity.java +++ b/app/src/main/java/info/nightscout/androidaps/MainActivity.java @@ -120,7 +120,7 @@ public class MainActivity extends AppCompatActivity { //Check here if loop plugin is disabled. Else check via constraints if (!LoopPlugin.getPlugin().isEnabled(PluginType.LOOP)) - VersionCheckerUtilsKt.checkVersion(); + VersionCheckerUtilsKt.triggerCheckVersion(); FabricPrivacy.setUserStats(); } diff --git a/app/src/main/java/info/nightscout/androidaps/MainApp.java b/app/src/main/java/info/nightscout/androidaps/MainApp.java index e390d12007..37372ae0d4 100644 --- a/app/src/main/java/info/nightscout/androidaps/MainApp.java +++ b/app/src/main/java/info/nightscout/androidaps/MainApp.java @@ -89,6 +89,8 @@ import info.nightscout.androidaps.services.Intents; import info.nightscout.androidaps.utils.FabricPrivacy; import io.fabric.sdk.android.Fabric; +import static info.nightscout.androidaps.plugins.general.versionChecker.VersionCheckerUtilsKt.triggerCheckVersion; + public class MainApp extends Application { private static Logger log = LoggerFactory.getLogger(L.CORE); @@ -149,6 +151,9 @@ public class MainApp extends Application { registerLocalBroadcastReceiver(); + //trigger here to see the new version on app start after an update + triggerCheckVersion(); + if (pluginsList == null) { pluginsList = new ArrayList<>(); // Register all tabs in app here diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/general/versionChecker/VersionCheckerPlugin.kt b/app/src/main/java/info/nightscout/androidaps/plugins/general/versionChecker/VersionCheckerPlugin.kt index 7be99e2369..fc773aaaaf 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/general/versionChecker/VersionCheckerPlugin.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/general/versionChecker/VersionCheckerPlugin.kt @@ -23,7 +23,7 @@ object VersionCheckerPlugin : PluginBase(PluginDescription() override fun isClosedLoopAllowed(value: Constraint): Constraint { checkWarning() - checkUpdate() + triggerCheckVersion() return if (isOldVersion(GRACE_PERIOD_VERY_OLD)) value.set(false, MainApp.gs(R.string.very_old_version), this) else @@ -34,7 +34,7 @@ object VersionCheckerPlugin : PluginBase(PluginDescription() val now = System.currentTimeMillis() if (isOldVersion(GRACE_PERIOD_WARNING) && shouldWarnAgain(now)) { // store last notification time - SP.putLong(R.string.key_last_versionchecker_warning, now) + SP.putLong(R.string.key_last_versionchecker_plugin_warning, now) //notify val message = MainApp.gs(R.string.new_version_warning, Math.round(now / TimeUnit.DAYS.toMillis(1).toDouble())) @@ -43,21 +43,8 @@ object VersionCheckerPlugin : PluginBase(PluginDescription() } } - private fun checkUpdate() { - val now = System.currentTimeMillis() - if (shouldCheckVersionAgain(now)) { - // store last notification time - SP.putLong(R.string.key_last_versioncheck, now) - - checkVersion() - } - } - - private fun shouldCheckVersionAgain(now: Long) = - now > SP.getLong(R.string.key_last_versioncheck, 0) + CHECK_EVERY - private fun shouldWarnAgain(now: Long) = - now > SP.getLong(R.string.key_last_versionchecker_warning, 0) + WARN_EVERY + now > SP.getLong(R.string.key_last_versionchecker_plugin_warning, 0) + WARN_EVERY override fun applyMaxIOBConstraints(maxIob: Constraint): Constraint = if (isOldVersion(GRACE_PERIOD_OLD)) @@ -67,10 +54,9 @@ object VersionCheckerPlugin : PluginBase(PluginDescription() private fun isOldVersion(gracePeriod: Long): Boolean { val now = System.currentTimeMillis() - return now > SP.getLong(R.string.key_new_version_available_since, 0) + gracePeriod + return now > SP.getLong(R.string.key_last_time_this_version_detected, 0) + gracePeriod } - val CHECK_EVERY = TimeUnit.DAYS.toMillis(1) val WARN_EVERY = TimeUnit.DAYS.toMillis(1) val GRACE_PERIOD_WARNING = TimeUnit.DAYS.toMillis(30) val GRACE_PERIOD_OLD = TimeUnit.DAYS.toMillis(60) diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/general/versionChecker/VersionCheckerUtils.kt b/app/src/main/java/info/nightscout/androidaps/plugins/general/versionChecker/VersionCheckerUtils.kt index b8cfa7fffc..1b01ea70de 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/general/versionChecker/VersionCheckerUtils.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/general/versionChecker/VersionCheckerUtils.kt @@ -15,6 +15,7 @@ import org.apache.http.impl.client.DefaultHttpClient import org.slf4j.LoggerFactory import java.io.IOException import java.io.InputStream +import java.util.concurrent.TimeUnit // check network connection fun isConnected(): Boolean { @@ -35,8 +36,16 @@ inline fun InputStream.findVersion(): String? { private val log = LoggerFactory.getLogger(L.CORE) + +fun triggerCheckVersion() { + // If we are good, only check once every day. + if(System.currentTimeMillis() > SP.getLong(R.string.key_last_time_this_version_detected, 0) + CHECK_EVERY){ + checkVersion() + } +} + @Suppress("DEPRECATION") -fun checkVersion() = if (isConnected()) { +private fun checkVersion() = if (isConnected()) { Thread { try { val request = HttpGet("https://raw.githubusercontent.com/MilosKozak/AndroidAPS/master/app/build.gradle") @@ -56,12 +65,17 @@ fun compareWithCurrentVersion(newVersion: String?, currentVersion: String) { comparison == null -> onVersionNotDetectable() comparison == 0 -> onSameVersionDetected() comparison > 0 -> onNewVersionDetected(currentVersion = currentVersion, newVersion = newVersion) - else -> log.debug("Version newer than master. Are you developer?") + else -> onOlderVersionDetected() } } +private fun onOlderVersionDetected() { + log.debug("Version newer than master. Are you developer?") + SP.putLong(R.string.key_last_time_this_version_detected, System.currentTimeMillis()) +} + fun onSameVersionDetected() { - SP.remove(R.string.key_new_version_available_since) + SP.putLong(R.string.key_last_time_this_version_detected, System.currentTimeMillis()) } fun onVersionNotDetectable() { @@ -69,10 +83,13 @@ fun onVersionNotDetectable() { } fun onNewVersionDetected(currentVersion: String, newVersion: String?) { - log.debug("Version ${currentVersion} outdated. Found $newVersion") - val notification = Notification(Notification.NEWVERSIONDETECTED, String.format(MainApp.gs(R.string.versionavailable), newVersion.toString()), Notification.LOW) - MainApp.bus().post(EventNewNotification(notification)) - SP.putLong(R.string.key_new_version_available_since, System.currentTimeMillis()) + val now = System.currentTimeMillis() + if(now > SP.getLong(R.string.key_last_versionchecker_warning, 0) + WARN_EVERY) { + log.debug("Version ${currentVersion} outdated. Found $newVersion") + val notification = Notification(Notification.NEWVERSIONDETECTED, String.format(MainApp.gs(R.string.versionavailable), newVersion.toString()), Notification.LOW) + MainApp.bus().post(EventNewNotification(notification)) + SP.putLong(R.string.key_last_versionchecker_warning, now) + } } fun String.versionStrip() = this.mapNotNull { @@ -81,4 +98,8 @@ fun String.versionStrip() = this.mapNotNull { '.' -> it else -> null } -}.joinToString(separator = "") \ No newline at end of file +}.joinToString(separator = "") + + +val CHECK_EVERY = TimeUnit.DAYS.toMillis(1) +val WARN_EVERY = TimeUnit.DAYS.toMillis(1) diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 9aa326361b..6722bc7786 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -1327,9 +1327,9 @@ Not configured Profile switch created Version Checker - new_version_available_since + last_time_this_version_detected last_versionchecker_waring - key_last_versioncheck + last_versionchecker_plugin_waring old version very old version diff --git a/app/src/test/java/info/nightscout/androidaps/plugins/general/versionChecker/VersionCheckerUtilsKtTest.kt b/app/src/test/java/info/nightscout/androidaps/plugins/general/versionChecker/VersionCheckerUtilsKtTest.kt index 29725e4d9e..2d07e40c1d 100644 --- a/app/src/test/java/info/nightscout/androidaps/plugins/general/versionChecker/VersionCheckerUtilsKtTest.kt +++ b/app/src/test/java/info/nightscout/androidaps/plugins/general/versionChecker/VersionCheckerUtilsKtTest.kt @@ -70,7 +70,9 @@ class VersionCheckerUtilsKtTest { verify(bus, times(1)).post(any()) PowerMockito.verifyStatic(SP::class.java, times(1)) - SP.putLong(eq(R.string.key_new_version_available_since), ArgumentMatchers.anyLong()) + SP.getLong(eq(R.string.key_last_versionchecker_warning), ArgumentMatchers.anyLong()) + PowerMockito.verifyStatic(SP::class.java, times(1)) + SP.putLong(eq(R.string.key_last_versionchecker_warning), ArgumentMatchers.anyLong()) PowerMockito.verifyNoMoreInteractions(SP::class.java) } @@ -85,7 +87,9 @@ class VersionCheckerUtilsKtTest { verify(bus, times(1)).post(any()) PowerMockito.verifyStatic(SP::class.java, times(1)) - SP.putLong(eq(R.string.key_new_version_available_since), ArgumentMatchers.anyLong()) + SP.getLong(eq(R.string.key_last_versionchecker_warning), ArgumentMatchers.anyLong()) + PowerMockito.verifyStatic(SP::class.java, times(1)) + SP.putLong(eq(R.string.key_last_versionchecker_warning), ArgumentMatchers.anyLong()) PowerMockito.verifyNoMoreInteractions(SP::class.java) } @@ -99,7 +103,9 @@ class VersionCheckerUtilsKtTest { verify(bus, times(1)).post(any()) PowerMockito.verifyStatic(SP::class.java, times(1)) - SP.putLong(eq(R.string.key_new_version_available_since), ArgumentMatchers.anyLong()) + SP.getLong(eq(R.string.key_last_versionchecker_warning), ArgumentMatchers.anyLong()) + PowerMockito.verifyStatic(SP::class.java, times(1)) + SP.putLong(eq(R.string.key_last_versionchecker_warning), ArgumentMatchers.anyLong()) PowerMockito.verifyNoMoreInteractions(SP::class.java) } @@ -113,7 +119,9 @@ class VersionCheckerUtilsKtTest { verify(bus, times(1)).post(any()) PowerMockito.verifyStatic(SP::class.java, times(1)) - SP.putLong(eq(R.string.key_new_version_available_since), ArgumentMatchers.anyLong()) + SP.getLong(eq(R.string.key_last_versionchecker_warning), ArgumentMatchers.anyLong()) + PowerMockito.verifyStatic(SP::class.java, times(1)) + SP.putLong(eq(R.string.key_last_versionchecker_warning), ArgumentMatchers.anyLong()) PowerMockito.verifyNoMoreInteractions(SP::class.java) } @@ -126,7 +134,9 @@ class VersionCheckerUtilsKtTest { verify(bus, times(1)).post(any()) PowerMockito.verifyStatic(SP::class.java, times(1)) - SP.putLong(eq(R.string.key_new_version_available_since), ArgumentMatchers.anyLong()) + SP.getLong(eq(R.string.key_last_versionchecker_warning), ArgumentMatchers.anyLong()) + PowerMockito.verifyStatic(SP::class.java, times(1)) + SP.putLong(eq(R.string.key_last_versionchecker_warning), ArgumentMatchers.anyLong()) PowerMockito.verifyNoMoreInteractions(SP::class.java) } @@ -139,7 +149,9 @@ class VersionCheckerUtilsKtTest { verify(bus, times(1)).post(any()) PowerMockito.verifyStatic(SP::class.java, times(1)) - SP.putLong(eq(R.string.key_new_version_available_since), ArgumentMatchers.anyLong()) + SP.getLong(eq(R.string.key_last_versionchecker_warning), ArgumentMatchers.anyLong()) + PowerMockito.verifyStatic(SP::class.java, times(1)) + SP.putLong(eq(R.string.key_last_versionchecker_warning), ArgumentMatchers.anyLong()) PowerMockito.verifyNoMoreInteractions(SP::class.java) } @@ -159,7 +171,7 @@ class VersionCheckerUtilsKtTest { verify(bus, times(0)).post(any()) PowerMockito.verifyStatic(SP::class.java, times(1)) - SP.remove(eq(R.string.key_new_version_available_since)) + SP.putLong(eq(R.string.key_last_time_this_version_detected), ArgumentMatchers.anyLong()) PowerMockito.verifyNoMoreInteractions(SP::class.java) } @@ -179,7 +191,9 @@ class VersionCheckerUtilsKtTest { verify(bus, times(1)).post(any()) PowerMockito.verifyStatic(SP::class.java, times(1)) - SP.putLong(eq(R.string.key_new_version_available_since), ArgumentMatchers.anyLong()) + SP.getLong(eq(R.string.key_last_versionchecker_warning), ArgumentMatchers.anyLong()) + PowerMockito.verifyStatic(SP::class.java, times(1)) + SP.putLong(eq(R.string.key_last_versionchecker_warning), ArgumentMatchers.anyLong()) PowerMockito.verifyNoMoreInteractions(SP::class.java) } From 249121f80de6b31e01ae50ffbd1a9ffc80d421de Mon Sep 17 00:00:00 2001 From: AdrianLxM Date: Tue, 23 Apr 2019 21:22:44 +0200 Subject: [PATCH 32/42] outdated on install edge case --- .../plugins/general/versionChecker/VersionCheckerUtils.kt | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/general/versionChecker/VersionCheckerUtils.kt b/app/src/main/java/info/nightscout/androidaps/plugins/general/versionChecker/VersionCheckerUtils.kt index 1b01ea70de..8791030abb 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/general/versionChecker/VersionCheckerUtils.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/general/versionChecker/VersionCheckerUtils.kt @@ -38,6 +38,12 @@ private val log = LoggerFactory.getLogger(L.CORE) fun triggerCheckVersion() { + + if(!SP.contains(R.string.key_last_time_this_version_detected)) { + // On a new installation, set it as 30 days old in order to warn that there is a new version. + SP.putLong(R.string.key_last_time_this_version_detected, System.currentTimeMillis() - TimeUnit.DAYS.toMillis(30)) + } + // If we are good, only check once every day. if(System.currentTimeMillis() > SP.getLong(R.string.key_last_time_this_version_detected, 0) + CHECK_EVERY){ checkVersion() From 0cab8c1d898e57c466741373c7d44e62cbdce9c1 Mon Sep 17 00:00:00 2001 From: AdrianLxM Date: Tue, 23 Apr 2019 21:40:10 +0200 Subject: [PATCH 33/42] warn at date --- .../plugins/general/versionChecker/VersionCheckerPlugin.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/general/versionChecker/VersionCheckerPlugin.kt b/app/src/main/java/info/nightscout/androidaps/plugins/general/versionChecker/VersionCheckerPlugin.kt index fc773aaaaf..2a4c08a585 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/general/versionChecker/VersionCheckerPlugin.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/general/versionChecker/VersionCheckerPlugin.kt @@ -37,7 +37,7 @@ object VersionCheckerPlugin : PluginBase(PluginDescription() SP.putLong(R.string.key_last_versionchecker_plugin_warning, now) //notify - val message = MainApp.gs(R.string.new_version_warning, Math.round(now / TimeUnit.DAYS.toMillis(1).toDouble())) + val message = MainApp.gs(R.string.new_version_warning, Math.round((now - SP.getLong(R.string.key_last_time_this_version_detected, now)) / TimeUnit.DAYS.toMillis(1).toDouble())) val notification = Notification(Notification.OLDVERSION, message, Notification.NORMAL) MainApp.bus().post(EventNewNotification(notification)) } From ee82976fc5ab6a87d9d1b37a08ce6f6432ffe340 Mon Sep 17 00:00:00 2001 From: Milos Kozak Date: Wed, 24 Apr 2019 09:07:12 +0200 Subject: [PATCH 34/42] New Crowdin translations (#1752) * New translations strings.xml (Portuguese) * New translations strings.xml (Portuguese) * New translations strings.xml (Slovak) * New translations strings.xml (French) * New translations strings.xml (Chinese Simplified) * New translations strings.xml (Polish) * New translations strings.xml (Korean) * New translations strings.xml (Portuguese) * New translations strings.xml (Italian) * New translations strings.xml (Portuguese, Brazilian) * New translations strings.xml (Greek) * New translations strings.xml (French) * New translations strings.xml (Romanian) * New translations strings.xml (Turkish) * New translations strings.xml (Swedish) * New translations strings.xml (Spanish) * New translations strings.xml (Dutch) * New translations strings.xml (Russian) * New translations strings.xml (Lithuanian) * New translations strings.xml (German) * New translations strings.xml (Czech) * New translations strings.xml (Bulgarian) * New translations strings.xml (Afrikaans) * New translations strings.xml (Slovak) * New translations strings.xml (Russian) * New translations strings.xml (Russian) * New translations strings.xml (German) * New translations strings.xml (Russian) * New translations strings.xml (German) * New translations strings.xml (Portuguese, Brazilian) * New translations strings.xml (Lithuanian) * New translations strings.xml (Slovak) * New translations strings.xml (Polish) * New translations strings.xml (Polish) * New translations strings.xml (Polish) * New translations strings.xml (Polish) * New translations strings.xml (Chinese Simplified) * New translations strings.xml (Chinese Simplified) * New translations strings.xml (Chinese Simplified) * New translations strings.xml (Chinese Simplified) * New translations strings.xml (Chinese Simplified) * New translations strings.xml (Chinese Simplified) * New translations strings.xml (Czech) * New translations strings.xml (Polish) * New translations strings.xml (Lithuanian) * New translations strings.xml (Lithuanian) * New translations strings.xml (French) * New translations strings.xml (Bulgarian) * New translations strings.xml (Greek) * New translations strings.xml (Portuguese) --- app/src/main/res/values-af/strings.xml | 7 ---- app/src/main/res/values-bg/strings.xml | 18 +++++---- app/src/main/res/values-cs/strings.xml | 18 +++++---- app/src/main/res/values-de/strings.xml | 16 +++++--- app/src/main/res/values-el/strings.xml | 18 +++++---- app/src/main/res/values-es/strings.xml | 7 ---- app/src/main/res/values-fr/strings.xml | 18 +++++---- app/src/main/res/values-it/strings.xml | 5 --- app/src/main/res/values-ko/strings.xml | 5 --- app/src/main/res/values-lt/strings.xml | 20 ++++++---- app/src/main/res/values-nl/strings.xml | 7 ---- app/src/main/res/values-pl/strings.xml | 51 ++++++++++++++++++++++---- app/src/main/res/values-pt/strings.xml | 22 ++++++----- app/src/main/res/values-ro/strings.xml | 7 ---- app/src/main/res/values-ru/strings.xml | 18 +++++---- app/src/main/res/values-sk/strings.xml | 18 +++++---- app/src/main/res/values-sv/strings.xml | 7 ---- app/src/main/res/values-tr/strings.xml | 5 --- app/src/main/res/values-zh/strings.xml | 39 ++++++++++++++++---- 19 files changed, 177 insertions(+), 129 deletions(-) diff --git a/app/src/main/res/values-af/strings.xml b/app/src/main/res/values-af/strings.xml index 1200a8e2e3..a0a0048ca1 100644 --- a/app/src/main/res/values-af/strings.xml +++ b/app/src/main/res/values-af/strings.xml @@ -147,8 +147,6 @@ Beperkings skending Bolus aflewering fout Tempbasal aflewering fout - Basale waarde [%] - % (100% =huidig) Aanvaar nuwe tydelike basale: Behandeling Rekenaar @@ -248,7 +246,6 @@ Pomp IAB Daaglikse eenhede Laaste bolus - %.1fh gelede Ongeldige invoer Waarde nie behoorlik gestel Herlaai profiel @@ -528,7 +525,6 @@ Insulien weerstandige volwasse Kies asseblief pasiënt ouderdom om veiligheids limiete te stel Glimp - %s benodig battery optimisering whitelisting vir behoorlike prestasie Lus opgeskort Opgeskort (%1$d m) Superbolus (%1$d m) @@ -564,8 +560,6 @@ Wys status vlae vir cage, iage, sage, stoor en battery vlak op tuisskerm. Drempel waarskuwings stoor vlak [U] Drempel kritieke stoor vlak [U] - Drempel waarskuwing battery vlak [%] - Drempel kritieke battery vlak [%] IAB KOB Firmware @@ -764,7 +758,6 @@ Loop tans Kanselleer TBR Stel TBR (%1$d%% / %2$d min) - Bolusing (%.1f U) Verfris Versoekte bewerking nie ondersteun deur pomp Onveilige gebruik: uitgebreide of multigolf boluses is aktief. Lus modus is gestel om laag te opskort net 6 ure. Net gewone boluses is ondersteun in lus modus diff --git a/app/src/main/res/values-bg/strings.xml b/app/src/main/res/values-bg/strings.xml index 61b87d0f13..8453a50ffe 100644 --- a/app/src/main/res/values-bg/strings.xml +++ b/app/src/main/res/values-bg/strings.xml @@ -147,8 +147,8 @@ Нарушено ограничение Грешка при подаване на болус Грешка при подаване на временен базал - Стойност на базал [%] - % (100% = текущ) + Базална стойност [%%] + %% (100%% = текущ) Приложи нов временен базал: Болус Калкулатор @@ -248,7 +248,7 @@ IOB на помпата Инсулин за деня Последен болус: - преди %.1fч + преди %1$.1fч Грешни входящи данни Неправилна стойност Презареди профил @@ -528,7 +528,7 @@ Възрастни с голяма инсулинова резистентност Изберете възраст за определяне лимитите на безопасност Glimp - %s се нуждае от зключване на оптимизиране на батерията за пълна функционалност + %1$s се нуждае от изключване от списъка за оптимизиране на батерията за пълна функционалност Loop изключен Изключен (%1$d мин) Суперболус (%1$d мин) @@ -564,8 +564,8 @@ Покажи статус светлини за канула, инсулин, сензор, резервоар и батерията на началния екран. Ниво за аларма за останал инсулин в резервоара [Е] Критично ниво на останал инсулин в резервоар [Е] - Аларма за заряд на батерия [%] - Критично ниво на батерията под [%] + Ниско ниво на батерията под [%%] + Критично ниво на батерията под [%%] IOB СОВ Фърмуер @@ -764,7 +764,7 @@ Изпълнява Отказва временен базал Задава временен базал (%1$d%% / %2$d min) - Болус (%.1f U) + Болус (%1$.1f Е) Обновява Исканата операция не се поддържа от помпата Опасно използване: удължени или многовълнови болуси са активни. Помпата е изключена за само 6 часа. Само нормални болуси се поддържат. @@ -1156,6 +1156,10 @@ Грешен код. Командата не е изпълнена. Не е конфигуриран Създаден запис - Промяна на профил + Проверка на версията + стара версия + много стара версия + Има нова версия от най-малко %1$d дни! Връщане към LGS след 60 дни, цикълът ще бъде изключен след 90 дни %1$d дeн %1$d дни diff --git a/app/src/main/res/values-cs/strings.xml b/app/src/main/res/values-cs/strings.xml index 61864568d3..96a66c5b8b 100644 --- a/app/src/main/res/values-cs/strings.xml +++ b/app/src/main/res/values-cs/strings.xml @@ -147,8 +147,8 @@ Mimo povolený rozsah Chyba podání bolusu Chyba nastavování dočasného bazálu - Hodnota bazálu [%] - % (100% = současný) + Hodnota bazálu [%%] + %% (100%% = současný) Spustit nový dočasný bazál: Bolus Kalkulačka @@ -248,7 +248,7 @@ IOB z pumpy Jednotek za den Poslední bolus - před %.1fh + před %1$.1fh Chybná vstupní data Hodnota nenastavena správně Obnovit profil @@ -528,7 +528,7 @@ Dospělý s nízkou citlivostí Vyberte věk pacienta pro nastavení bezpečnostních limitů Glimp - %s potřebuje vypnout optimalizace baterie pro optimální výkon + %1$s potřebuje vypnout optimalizace baterie pro optimální výkon Smyčka pozastavena Pozastaveno (%1$d min) Superbolus (%1$d m) @@ -564,8 +564,8 @@ Povolte stavové indikátory pro stáří kanyly, inzulínu, senzoru, zásobníku a baterie na domovské obrazovce. Úroveň varování stavu zásobníku [U] Úroveň kritického varování stavu zásobníku [U] - Úroveň varování stavu baterie [%] - Úroveň kritického varování stavu baterie [%] + Úroveň varování stavu baterie [%%] + Úroveň kritického varování stavu baterie [%%] IOB COB Firmware @@ -764,7 +764,7 @@ Běží Rušení dočasného bazálu Nastavování doč. bazálu (%1$d%% / %2$d min) - Bolus (%.1f U) + Bolus (%1$.1f U) Obnovování Požadovaná operace není pumpou podporována Nebezpečné použití: extended nebo multiwave bolus je aktivní. Pumpa byla vypnuta jen na 6 hodin. Povolené jsou pouze normální bolusy. @@ -1156,6 +1156,10 @@ Nesprávný kód. Příkaz zrušen. Není nakonfigurováno Přepnutí profilu vytvořeno + Kontrola verze + stará verze + velmi stará verze + Nová verze je dostupná minimálně %1$d dní! Přepnutí na ochranu před nízkou glykémií po 60 dnech, vypnutí smyčky po 90 dnech %1$d den %1$d dnů diff --git a/app/src/main/res/values-de/strings.xml b/app/src/main/res/values-de/strings.xml index ed46e6a8ea..2d0a15d6ac 100644 --- a/app/src/main/res/values-de/strings.xml +++ b/app/src/main/res/values-de/strings.xml @@ -147,8 +147,8 @@ Beschränkungen wurden verletzt oder Limit erreicht. Bolus-Abgabefehler TBR Abgabe-Fehler - Basal-Wert [%] - % (100% = aktuell) + Basal-Wert [%%] + %% (100%% = aktuell) Akzeptiere neue TBR: Bolus Rechner @@ -248,7 +248,7 @@ Pumpen-IOB Tägliche Einheiten Letzter Bolus: - vor %.1f h + vor %1$.1f Stunde Ungültige Eingabedaten Wert nicht korrekt gesetzt Profil neuladen @@ -529,7 +529,7 @@ maxIOB = durchschnittlicher Essensbolus + 3 x maximale Basalrate Insulinresistenter Erwachsener Bitte wähle das Patientenalter, um die Sicherheits-Limits festzulegen Glimp - %s benötigt eine deaktivierte Akku-Leistungsoptimierung, um korrekt arbeiten zu können. + %1$s benötigt eine deaktivierte Akku-Leistungsoptimierung, um korrekt arbeiten zu können. Loop pausiert Pausiert (%1$d min) Superbolus (%1$d m) @@ -565,8 +565,8 @@ maxIOB = durchschnittlicher Essensbolus + 3 x maximale Basalrate Statusanzeige für CAGE, IAGE, SAGE, Reservoir- und Batteriestand auf dem Homescreen. Warnschwelle Reservoirstand [IE] Warnschwelle kritischer Reservoirstand [IE] - Warnschwelle Batteriestand [%] - Warnschwelle kritischer Batteriestand [%] + Warnschwelle Batteriestand [%%] + Warnschwelle kritischer Batteriestand [%%] IOB COB Firmware @@ -1158,6 +1158,10 @@ Unerwartetes Verhalten. Falscher Code. Befehl wurde abgebrochen. Nicht konfiguriert Profilwechsel wurde erstellt + Versionsprüfer + Vorherige Version + sehr alte Version + Neue Version für mindestens %1$d Tage verfügbar! Rückfall zur sensorunterstützten Pumpentherapie nach 60 Tagen, Loop wird nach 90 Tagen deaktiviert %1$d Tag %1$d Tage diff --git a/app/src/main/res/values-el/strings.xml b/app/src/main/res/values-el/strings.xml index 155afd10d0..9872c77080 100644 --- a/app/src/main/res/values-el/strings.xml +++ b/app/src/main/res/values-el/strings.xml @@ -147,8 +147,8 @@ Παραβίαση Περιορισμών Σφάλμα παράδοσης Bolus Σφάλμα παράδοσης Προσ Ρυθμού - Τιμή Βασικού [%] - % (100% = τρέχων) + Τιμή Βασικού [%%] + %% (100%% = τρέχων) Αποδοχή νέου Προσ Ρυθμού: Θεραπεία Υπολογιστής @@ -248,7 +248,7 @@ IOB αντλίας Μονάδες ανά ημέρα Τελευταίο Bolus: - πριν από %.1fh + %1$.1fώρες πριν Μη έγκυρα δεδομένα Η τιμή δεν μπήκε σωστά Ξαναφορτώστε το προφίλ @@ -528,7 +528,7 @@ Αντίσταση ινσουλίνης ενηλίκων Παρακαλώ επιλέξτε ηλικία χρήστη για να ορισθούν όρια ασφαλείας Glimp - Το %s πρέπει να απενεργοποιήσει τη βελτιστοποίηση της μπαταρίας για βέλτιστη απόδοση + %1$s χρειάζεται λίστα βελτιστοποίησης μπαταρίας για σωστή απόδοση Κύκλωμα σε αναστολή Αναστολή (%1$d m) Superbolus (%1$d m) @@ -564,8 +564,8 @@ Ενεργοποίηση του φωτισμού κατάστασης για cage, iage, sage, reservoir και επίπεδο μπεταρίας στην αρχική οθόνη. Όριο προειδοποίησης χαμηλής αμπούλας [U] Όριο προειδοποίησης πολύ χαμηλής αμπούλας [U] - Όριο προειδοποίησης χαμηλής μπαταρίας [%] - Όριο προειδοποίησης πολύ χαμηλής μπαταρίας [%] + Όριο προειδοποίησης χαμηλής μπαταρίας [%%] + Όριο προειδοποίησης πολύ χαμηλής μπαταρίας [%%] IOB COB Έκδοση @@ -764,7 +764,7 @@ Εκτελείτε Ακυρώνεται TBR Ρύθμιση TBR (%1$d%% / %2$d λεπτά) - Bolus (%.1f U) + Bolus (%1$.1f U) Ανανέωση Η λειτουργία που ζητήθηκε δεν υποστηρίζεται από την αντλία Επικίνδυνη χρήση: Εκτεταμένο ή πολλαπλά bolus είναι ενεργό. Το κύκλωμα απενεργοποιήθηκε λόγω low-suspend μόνο για 6 ώρες. Επιτρέπονται μόνο κανονικά bolus @@ -1156,6 +1156,10 @@ Λάθος κωδικός. Η εντολή ακυρώθηκε. Δεν έχει ρυθμιστεί Δημιουργήθηκε αλλαγή προφίλ + Έλεγχος Έκδοσης + παλιά έκδοση + πολύ παλιά έκδοση + Νέα έκδοση για τουλάχιστον %1$d ημέρες διαθέσιμη! Επιστροφή σε LGS μετά από 60 ημέρες, το κύκλωμα θα απενεργοποιηθεί μετά από 90 ημέρες %1$d ημέρα %1$d ημέρες diff --git a/app/src/main/res/values-es/strings.xml b/app/src/main/res/values-es/strings.xml index 9d800ccc59..93d2498e5a 100644 --- a/app/src/main/res/values-es/strings.xml +++ b/app/src/main/res/values-es/strings.xml @@ -143,8 +143,6 @@ Violación restricciones Error de administración del bolo Basal Temporal no emitida - Valor basal [%] - % (100% = actual) Aceptar nueva basal temporal: Tratamiento Calculadora @@ -244,7 +242,6 @@ Bomba IOB Unidades diarias Último bolo - Hace %.1fh Datos inválidos Valor no establecido correctamente Recargar Perfil @@ -503,7 +500,6 @@ Adulto resistente a la insulina Por favor elige la edad del paciente para ajustar los límites de seguridad Glimp - %s necesita optimización de batería lista blanca para funcionar bien Loop desactivado Desactivado (%1$d m) Superbolo (%1$d m) @@ -539,8 +535,6 @@ Habilitar las luces de estado para tiempo de la canula, tiempo de la insulina, tiempo del sensor y nivel de bateria en la pantalla de inicio. Umbral de advertencia de nivel de reservorio [U] Umbral crítico de nivel de reservorio [U] - Umbral de advertencia de nivel de pila [%] - Umbral crítico de nivel de batería [%] IOB COB Firmware @@ -734,7 +728,6 @@ Funcionando Cancelando TBR Poniendo TBR (%1$d%% / %2$d min) - Emitiendo bolo (%.1f U) Actualizando Acción requerida no disponible por la bomba Uso inseguro: bolo extendido o multionda activo. El modo del lazo ha sido fijado a sólo suspensión en baja glucosa durante 6 horas. En modo lazo sólo se soportan los bolo estándar. diff --git a/app/src/main/res/values-fr/strings.xml b/app/src/main/res/values-fr/strings.xml index 0b5ef3c187..0ae7423e5d 100644 --- a/app/src/main/res/values-fr/strings.xml +++ b/app/src/main/res/values-fr/strings.xml @@ -147,8 +147,8 @@ Violation des restrictions Erreur injection bolus Erreur injection basal temporaire - Valeur Basal [%] - % (100% = actuel) + Valeur de Basal [%%] + %% (100%% = actuel) Accepter nouveau basal temporaire : Traitement Calculatrice @@ -249,7 +249,7 @@ L\'ENSEMBLE DES RISQUES LIÉS À LA QUALITÉ ET À LA PERFORMANCE DU PROGRAMME S Insuline Active pompe Unités journalières Dernier bolus - %.1fh passées + il y a %1$.1fh Données saisies invalides Valeur pas correctement définie Actualiser le profil @@ -529,7 +529,7 @@ L\'ENSEMBLE DES RISQUES LIÉS À LA QUALITÉ ET À LA PERFORMANCE DU PROGRAMME S Adulte résistant à l\'insuline Veuillez svp sélectionner l’âge du patient pour définir les limites de sécurité Glimp - %s a besoin de la liste blanche de l’optimisation batterie pour une bonne performance + %1$s a besoin d\'optimisation de la batterie (whitelisting) pour une performance correcte La Boucle est suspendue Suspendu (%1$d m) Superbolus (%1$d m) @@ -565,8 +565,8 @@ L\'ENSEMBLE DES RISQUES LIÉS À LA QUALITÉ ET À LA PERFORMANCE DU PROGRAMME S Activer les lumières d\'état pour AgeC, AgeI, AgeS, niveaux du réservoir et de batterie sur l\'écran d\'accueil. Seuil d\'avertissement de niveau du réservoir [U] Seuil critique de niveau du réservoir [U] - Seuil d’avertissement du niveau de batterie [%] - Seuil critique du niveau de la batterie [%] + Seuil d’avertissement du niveau de batterie [%%] + Seuil critique du niveau de la batterie [%%] IA GA Firmware @@ -765,7 +765,7 @@ L\'ENSEMBLE DES RISQUES LIÉS À LA QUALITÉ ET À LA PERFORMANCE DU PROGRAMME S En cours d\'exécution Annulation en cours du TBR Paramétrer TBR (%1$d%% / %2$d min) - Injection du bolus en cours (%.1f U) + Injection du Bolus en cours (%1$.1f U) Actualisation en cours L\'opération demandée n\'est pas prise en charge par la pompe Utilisation dangereuse : les bolus étendus ou carrés sont actifs. Le mode Boucle a été programmé pour des suspensions seulement pour 6 heures. Uniquement les bolus normaux sont pris en charge par le mode Boucle @@ -1157,6 +1157,10 @@ L\'ENSEMBLE DES RISQUES LIÉS À LA QUALITÉ ET À LA PERFORMANCE DU PROGRAMME S Code incorrect. Commande annulée. Non configuré Changement de profil effectué + Vérificateur de version + ancienne version + très ancienne version + Une nouvelle version est disponible depuis au moins %1$d jours ! Retour au traitement par pompe assistée par capteur (Arrêt par Glycémie Basse (AGB), Low Glucose Suspend (LGS) ) après 60 jours et la Boucle sera désactivée après 90 jours %1$d jour %1$d jours diff --git a/app/src/main/res/values-it/strings.xml b/app/src/main/res/values-it/strings.xml index cbb98e7289..5d942f4818 100644 --- a/app/src/main/res/values-it/strings.xml +++ b/app/src/main/res/values-it/strings.xml @@ -143,8 +143,6 @@ Vincolo Violato Errore di erogazione del bolo Errore di somministrazione basale temporale - Valore Basale [%] - % (100% = corrente) Accettare il nuovo basale temp Boli Calcolatore @@ -244,7 +242,6 @@ IOB Microinfusore Unita\' giornaliera Ultimo Bolo - %.1fh fa Data Errata Valore non impostato correttamente Aggiorna Profilo @@ -502,7 +499,6 @@ Insulina resistente Si prega di selezionare l\'età paziente e di impostare i limiti di sicurezza Glimp - %s ha bisogno di whitelisting di ottimizzazione della batteria per un buon funzionamento Sospensione Loop Sospendi (%1$d m) Superbolo (%1$d m) @@ -722,7 +718,6 @@ In esecuzione Annullamento di TBR L\'impostazione di TBR (%1$d%% / %2$d min) - Bolusing (%.1f U) Aggiornando Richiesta operazione non supportata dal micro L\'utilizzo non sicuro: estesi o multiwave boli sono attivi. Modalità loop è stato impostato basso-sospendere solo 6 ore. Solo normali boli sono supportati in modalità loop diff --git a/app/src/main/res/values-ko/strings.xml b/app/src/main/res/values-ko/strings.xml index 80b2994a0e..46b451b602 100644 --- a/app/src/main/res/values-ko/strings.xml +++ b/app/src/main/res/values-ko/strings.xml @@ -143,8 +143,6 @@ 제한 위반 Bolus 주입 에러 임시Basal 주입 에러 - Basal값[%] - % (100% = 현재) 새 임시Basal 적용: 관리 계산기 @@ -244,7 +242,6 @@ 펌프 IOB 일 인슐린 총량 최근 Bolus: - %.1f시간 전 사용할수 없는 입력 데이터 값이 제대로 설정되지 않았습니다 프로파일 새로고침 @@ -502,7 +499,6 @@ 인슐린 저항성 높은 성인 안전제한을 설정하기 위해 당뇨인의 나이를 선택하세요 Glimp - 최적의 성능을 위해 %s에서 배터리 최적화를 해제해야합니다. Loop 일시중지 일시중지중 (%d분) Superbolus (%1$d 분) @@ -722,7 +718,6 @@ 실행중 임시기초주입 취소중 임시기초주입 설정중 (%1$d%% / %2$d분) - Bolus 주입중(%.1f U) 새로고침중 요청하신 동작은 펌프에서 지원하지 않습니다. 위험한 사용: 확장Bolus 혹은 멀티웨이브Bolus가 활성화 됩니다. Loop 모드가 저혈당 방지로 오직 6시간만 설정됩니다. Loop 모드에선 일반 Bolus만 지원합니다. diff --git a/app/src/main/res/values-lt/strings.xml b/app/src/main/res/values-lt/strings.xml index 11d4733c9b..f95cd7627f 100644 --- a/app/src/main/res/values-lt/strings.xml +++ b/app/src/main/res/values-lt/strings.xml @@ -12,7 +12,7 @@ Naudoti ištęstinį bolusą >200%% DanaR Bluetooth įrenginys Visada naudoti bazės absoliučias vertes - Prašome iš naujo paleisti telefoną arba sistemos nustatymuose iš naujo paleisti AndroidAPS \nkitaip AndroidAPS negalės registruoti prisijungimų (svarbu stebint ir tikrinant, ar algoritmai veikia tinkamai)! + Prašome iš naujo paleisti telefoną arba sistemos nustatymuose iš naujo paleisti AndroidAPS \nkitaip AndroidAPS negalės registruoti prisijungimų (svarbu stebėti ir tikrinti ar algoritmai veikia tinkamai)! Mygtukai greitesniam pagrindinių funkcijų paleidimui Papildomų įrašų žurnalas. Naudojama aktyvių įskiepių konfigūravimui @@ -147,8 +147,8 @@ Apribojimų pažeidimas Boluso suleidimo klaida Laikinos bazės suleidimo klaida - Valandinė bazė [%] - % (100 % = dabartinis) + Valandinė bazė [%%] + %%(100%% - pasirinkta) Patvirtinti naują laikiną bazę: Terapija Skaičiuotuvas @@ -248,7 +248,7 @@ Pompos AIO Paros insulinas Paskutinis bolusas - prieš %.1fval + Prieš %1$.1f valandų Neteisingai įvesti duomenys Vertė nėra tinkamai nustatyta Atnaujinti profilį @@ -528,7 +528,7 @@ Insulinui rezistentiškas suaugęs Pasirinkite paciento amžių saugumo riboms nustatyti Glimp - %s įtraukite baterijos optimizavimą į baltąjį sąrašą, tinkamam veikimui užtikrinti + %1$s įtraukite į baterijos optimizavimo baltąjį sąrašą tinkamam veikimui užtikrinti Ciklas sustabdytas Sustabdyta (%1$d m) Superbolusas (%1$d m) @@ -564,8 +564,8 @@ Pradžios ekrane rodyti spalvotus indikatorius adatos, insulino, sensoriaus naudojimo trukmei bei baterijos įkrovimo lygiui. Įspėjimo apie žemą rezervuaro lygį riba [U] Įspėjimo apie kritiškai žemą rezervuaro lygį riba [U] - Įspėjimo apie žemą baterijos įkrovimo lygį riba [%] - Įspėjimo apie kritiškai žemą baterijos įkrovimo lygį riba [%] + Įspėjimo apie žemą baterijos įkrovimo lygį riba [%%] + Įspėjimo apie kritiškai žemą baterijos įkrovimo lygį riba [%%] AIO AAO Programinė įranga @@ -764,7 +764,7 @@ Vykdoma Laikina bazė atšaukiama Nustatyti laikiną bazę (%1$d%% / %2$d min) - Bolusas (%.1f vv) + Leidžiamas bolusas (%1$.1f vv) Atnaujinama Pompa negali įvykdyti prašomos operacijos Nesaugu: aktyvus ištęstinis arba dvibangis bolusas. Ciklas nustatytas stabdymui prie žemo tik 6 valandoms. Aktyvūs tik paprasti bolusai. @@ -1156,6 +1156,10 @@ Neteisingas kodas. Komanda atšaukta. Nesukonfigūruota Profilio perjungimas sukurtas + Versijos tikrintuvas + sena versija + labai sena versija + Nauja versija pasiekiama mažiausiai %1$d dienų! Po 60 d. grįšite prie stabdymo prie žemo, po 90 d. ciklas bus išjungtas. %1$d diena %1$d diena diff --git a/app/src/main/res/values-nl/strings.xml b/app/src/main/res/values-nl/strings.xml index 405918431f..313c3fdde5 100644 --- a/app/src/main/res/values-nl/strings.xml +++ b/app/src/main/res/values-nl/strings.xml @@ -145,8 +145,6 @@ In strijd met beperkingen Bolus toedien storing Tijdelijk basaal toedien storing - Basale waarde [%] - % (100% = actueel) Accepteer nieuw tijdelijk basaal: Bolus Bolus wizard @@ -246,7 +244,6 @@ Pomp IOB Dag totaal Laatste bolus - %.1fu geleden Verkeerde ingave Waarde niet correct ingesteld Herlaad profiel @@ -506,7 +503,6 @@ Stel in en gebruik tijdelijk en standaard tijdelijke streefdoelen (bv. bij sport insuline resistente volwassene Kies leeftijd van de patient voor veiligheids limieten Glimp - %s benodigd batterij optimalistaie vrijwaring voor goede werking Loop pauzeren Gepauzeerd (%1$d m) Superbolus (%1$d m) @@ -542,8 +538,6 @@ Stel in en gebruik tijdelijk en standaard tijdelijke streefdoelen (bv. bij sport Statusindicatoren inschakelen voor cage, iage, sage, reservoir en batterijniveau op het beginscherm. Drempel waarschuwing reservoir niveau [E] Drempel alarm reservoir niveau [E] - Drempel waarschuwing batterij niveau [%] - Drempel alarm batterij niveau [%] IOB COB Firmware @@ -737,7 +731,6 @@ Stel in en gebruik tijdelijk en standaard tijdelijke streefdoelen (bv. bij sport Actief Annuleren van TB Instellen TBR (%1$d%% / %2$d min) - Bolus (%.1f E) Vernieuwen Gevraagde is niet mogelijk met de pomp Opgelet: verlengde en multi wave bolussen zijn actief. Loop is overgeschakeld naar low-suspend modus gedurende 6 uur. Alleen gewone bolussen worden ondersteund in loop modus diff --git a/app/src/main/res/values-pl/strings.xml b/app/src/main/res/values-pl/strings.xml index 18f711530c..b06da87522 100644 --- a/app/src/main/res/values-pl/strings.xml +++ b/app/src/main/res/values-pl/strings.xml @@ -9,6 +9,7 @@ Zresetuj bazy danych Na pewno chcesz zresetować bazy danych? Wyjście + Używaj przedłużonych bolusów dla >200%% Urządzenie Bluetooth DanaR Zawsze używaj wartości bezwzględnych bazy Proszę uruchomić ponownie telefon lub zrestartować AndroidAPS w ustawieniach systemu telefonu \ninaczej AndroidAPS nie będzie otrzymywał logowań (ważne ze względu na śledzenie i sprawdzanie poprawności działania algorytmów)! @@ -146,8 +147,8 @@ Naruszenie ograniczeń Błąd podania bolusa Błąd podania bazy tymczasowej - Wartość bazy [%] - % (100% = aktualny) + Wartość bazy [%%] + %% (100%% = aktualny) Akceptuj nową bazę tymczasową: Leczenie Kalkulator @@ -247,7 +248,7 @@ IOB w pompie Jednostki dzienne Ostatni bolus - %.1fh temu + %1$.1fh temu Błędne dane wejściowe Wartość ustawiona nieprawidłowo Załaduj profil ponownie @@ -313,6 +314,7 @@ Stop NACIŚNIĘTY STOP Czekam na pompę + Zamierzam dostarczyć %1$.2fU Konfiguracja wizualizacji i monitorowania, analiza dawek i wartości bazowych Sprawdź czy BG (pomiary cukru) są dostępne w Nightscout, i dane pompy insulinowej są ładowane Uruchamiam otwartą pętle (OpenLoop) @@ -335,12 +337,26 @@ Pętla (Loop) jest wyłączona Pętla (Loop) jest włączona %1$.2f ograniczone do %2$.2f + Wartość %1$s jest poza dopuszczalną granicą Zdalne komendy nie są dozwolone + Bolus zdalny niedostępny. Spróbuj ponownie później. + Aby rozpocząć bazę %1$.2fU/h przez %2$d min. odpowiedz kodem %3$s + Aby przełączyć profil na %1$s %2$d%% odpowiedz kodem %3$s + Aby rozpocząć bolus przedłużony %1$.2fU przez %2$d min. odpowiedz kodem %3$s + Aby rozpocząć bolus przedłużony %1$d%% przez %2$d min. odpowiedz kodem %3$s Aby wstrzymać pętle na %1$d minut odpowiedz kodem %2$s Tymczasowa baza %1$.2fU/h przez %2$d min rozpoczęta + Bolus przedłużony %1$.2fU na %2$d min. rozpoczęty pomyślnie + Tymczasowa baza %1$d%% przez %2$d min. pomyślnie rozpoczęta Rozpoczęcie tymczasowej bazy nie powiodło się + Nie powiodło się podanie bolusa przedłużonego + Aby zatrzymać bazę tymczasową wprowadź kod %1$s + Aby zatrzymać bolus przedłużony wprowadź kod %1$s Baza tymczasowa anulowana + Przedłużony bolus anulowano Anulowanie tymczasowej bazy nie powiodło się + Anulowanie bolusa przedłużonego nie powiodło się + Nieznane polecenie lub błędna odpowiedź Bolus zdefiniowany Ustaw szybkie bolusy Tekst przycisku: @@ -448,6 +464,7 @@ Profil Wartość domyślna: 3 To jest kluczowy współczynnik bezpieczeństwa OpenAPS. Ogranicza dawki bazowe do 3x twojej największej dawki bazowej. Prawdopodobnie nie będziesz musiał tego zmieniać, ale powinieneś być świadomy tego, co się rozumie przez “3x max dzienna; 4x aktualna” dla współczynników bezpieczeństwa. Wartość domyślna: 4 To jest drugi kluczowy współczynnik bezpieczeństwa OpenAPS, i druga wartość z “3x max dzienna; 4x aktualna”. To oznacza, że Twoja dawka bazowa niezależnie od maksymalnej bazy ustawionej na pompie nie może być większa niż ta ustawiona wartość razy twoja aktualna dawka bazowa. To ma na celu przestrzec ludzi przed ustawieniem zbyt wysokiej dawki maksymalnej przed zrozumieniem jak działa algorytm. Ponownie, wartość domyślna to 4x; większość ludzi nie będzie potrzebowała tego zmienić i raczej będą potrzebować dostosować inne ustawienia, jeśli czują, że zbliżają się do współczynnika bezpieczeństwa. + Wartość domyślna: 1.2\nTo jest mnożnik dla autosens (wkrótce autotune), ustawia 20%% maks. limit dla najwyższej wartości jaką autosens może przyjąć, co z kolei określa jak wysoko autosens może zwiększyć bazę, jak nisko może ustawić współczynnik wrażliwości insuliny ISF, i jak nisko może ustawić docelową wartość glikemii. Wartość domyślna: 0.7\nDruga strona limitu bezpieczeństwa dla autosens, ustawia mnożnik minimalny dla wartości, do jakiej autosens może obniżyć bazę, i jak wysoko może ustawić ISF i wartość docelową BG. Autosens wpływa na wartości docelowe Domyślnie włączone\nTa funkcja pozwala wpływać na zmianę wartości docelowe BG, wartości bazy i oraz współczynnika wrażliwości na insulinę ISF. @@ -460,6 +477,7 @@ Nieprawidłowy numer telefonu Nieprawidłowy numer telefonu SMS Kalibracja + Wysłać kalibrację %1$.1f do xDrip? xDrip+ nie zainstalowany Kalibracja przesłana do xDrip Kalibracja wysłana. Odbiór musi być dozwolony w xDrip. @@ -510,7 +528,7 @@ Osoba dorosła insulino odporna Proszę wybierz wiek pacjenta w celu ustawienia wartości limitów bezpieczeństwa Glimp - %s Potrzebuję wpisu na białą listę optymalizacji baterii, w celu zapewnienia poprawnego działania + %1$s potrzebuję wyłączenia z optymalizacji baterii, w celu zapewnienia poprawnego działania Pętla wstrzymana Wstrzymana (%1$d m) Superbolus (%1$d m) @@ -546,8 +564,8 @@ Włącz diody stanu dla cage, iage, sage, rezerwuar i poziom baterii na ekranie głównym. Próg ostrzeżenia o poziomie zbiornika [U] Próg ostrzeżenia o krytycznym poziomie zbiornika [U] - Próg ostrzeżenia o poziomie baterii [%] - Próg ostrzeżenia o krytycznym poziomie baterii [%] + Próg ostrzeżenia o poziomie baterii [%%] + Próg ostrzeżenia o krytycznym poziomie baterii [%%] IOB COB Firmware @@ -601,6 +619,7 @@ Ustawienia wchłaniania Maks. czas wchłaniania posiłku [h] Oczekiwany czas w godzinach, w którym wszystkie węglowodany zostają wchłonięte + Wizualizacja bolusa przedłużonego jako %% SAGE IAGE CAGE @@ -713,6 +732,8 @@ Prześlij dane BG do xDrip+ W xDrip+ wybierz źródło danych 640g/Eversense NSClient BG + Wartość bazy zastąpiona minimalną obsługiwaną wartością: %1$s + Wartość bazy zastąpiona maksymalną obsługiwaną wartością: %1$s Obliczenia BG Obliczenia Bolus IOB Obliczenia IOB @@ -730,6 +751,8 @@ Tryb zamknięty włączony Maks. IOB ustawione poprawnie BG dostępne z wybranego źródła + Wartości bazy nie są ustawione w pełnych godzinach: %1$s + Nieprawidłowy profil: %1$s Programowanie pompy do podawania bolusa Odśwież Stan @@ -742,7 +765,7 @@ W działaniu Anulowanie TBR Ustawianie TBR (%1$d%% / %2$d min) - Podawanie bolusa (%.1f U) + Podawanie bolusa (%1$.1f U) Odświeżanie Żądana operacja nie jest obsługiwana przez pompę Niebezpieczne użycie: aktywne są bolusy przedłużone lub wielofalowe. Tryb pętli został ustawiony tylko na 6 godzinne zawieszenie z uwagi na niski poziom (BG). W trybie pętli obsługiwane są tylko normalne bolusy @@ -1065,11 +1088,13 @@ Wycisz Alarm pompy Melduj zmianę miejsca wkłucia + Zapisz zmianę zbiornika Melduj zmianę drenu Melduj zmiany baterii Melduj zmiany trybu pracy Melduj ostrzeżenia Włącz emulację TBR + Użyj rozszerzonych bolusów zamiast TBR by ominąć limit 250%% bazy Opóźnienie rozłączenie [s] Numer seryjny Wersja oprogramowania @@ -1124,6 +1149,18 @@ Podaj \"Zmiana Sensora\" do NS do NS automatycznie przy uruchomieniu sensora Tomato (MiaoMiao) Tomato + Zmiana na czas letni w ciągu 24 godzin lub krócej + Zmiana czasu nastąpiła mniej niż 3 godziny temu - Zamknięta pętla wyłączona + limit wielkości pamięci wewnętrznej + Zwolnij co najmniej %1$d MB z pamięci wewnętrznej! Pętla zatrzymana! + Błędny format + Zły kod. Polecenie anulowano. + Nie skonfigurowano + Zmiana profilu wykonana + Kontroler wersji + stara wersja + bardzo stara wersja + Nowa wersja dostępna co najmniej %1$d dni! Powrót do LGS (zawieszania podawania bazy przy niskim poziomie) po 60 dniach, pętla zostanie wyłączona po 90 dniach %1$d dzień %1$d dni diff --git a/app/src/main/res/values-pt/strings.xml b/app/src/main/res/values-pt/strings.xml index 33d67541f7..36ffb7c5e9 100644 --- a/app/src/main/res/values-pt/strings.xml +++ b/app/src/main/res/values-pt/strings.xml @@ -147,8 +147,8 @@ Violação das restrições Erro na entrega do bolus Erro na entrega da basal temporária - Valor da Basal [%] - % (100% = atual) + Valor da Basal [%%] + %% (100%% = actual) Aceitar nova basal temporária: Tratamento Calculadora @@ -248,7 +248,7 @@ IOB Bomba Unidades diárias Último bólus - %.1fh atrás + %1$.1fh atrás Entrada Inválida Valor não definido corretamente Recarregar perfil @@ -528,7 +528,7 @@ Adulto resistente insulina Por favor seleccione a idade do diabético para definir os limites de segurança Glimp - %s necessita de autorizar a não optimização da bateria para assegurar a performance necessária + %1$s necessita de autorizar a não optimização da bateria para assegurar a performance necessária Loop suspenso Suspendido (%1$d m) Superbólus (%1$d m) @@ -564,8 +564,8 @@ Ativar as luzes de status para idade da cânula, idade da insulina, idade do sensor, reservatório e bateria no ecrã inicial. Limite de aviso de nível de reservatório [U] Limite crítico de nível de reservatório [U] - Limite de aviso de nível de bateria [%] - Limite crítico de nível de bateria [%] + Limite de aviso de nível de bateria [%%] + Limite crítico de nível de bateria [%%] IOB COB Firmware @@ -764,7 +764,7 @@ A correr Cancelar TBR A definir TBR (%1$d%% / %2$d min) - Injectando (%.1f U) + Injectando (%1$.1f U) A actualizar Operação solicitada não suportada pela bomba Ultilização nao segura: bolus estendudos ou multionda estão activos. Modo do loop foi alterado para apenas suspender em limite inferior por 6h. Apenas são suportados bolus normais em modo loop @@ -1129,7 +1129,7 @@ Actualizar Integração de bomba para bombas Accu-Chek Insight Não inserido - Última conexão:%1$d minutos atrás + Última ligação:%1$d minutos atrás Basal temporária: %1$d%% para %2$d / %3$d minutos Estendido: %1$.2f / %2$.2f U por %3$d min Multionda: %1$.2f / %2$.2f U por %3$d min @@ -1139,7 +1139,7 @@ Duração máxima da recuperação [s] Duração mínima da recuperação [s] Duração da recuperação - Tempo de operação excedido - reset bluetooth + Tempo de operação excedido - reinicar bluetooth == ∑ %1$s U U/h g/U @@ -1156,6 +1156,10 @@ Código errado. Comando cancelado. Não configurado Troca de perfil criada + Verificador de Versão + versão antiga + versão muito antiga + Nova versão para pelo menos %1$d dias disponíveis! Voltar para o LGS após 60 dias, o loop será desativado após 90 dias %1$d dia %1$d dias diff --git a/app/src/main/res/values-ro/strings.xml b/app/src/main/res/values-ro/strings.xml index 67868f930a..12267b972b 100644 --- a/app/src/main/res/values-ro/strings.xml +++ b/app/src/main/res/values-ro/strings.xml @@ -145,8 +145,6 @@ Încălcare a unei limite Eroare la livrarea bolusului Eroare la setare bazală temporară - Valoare bazală [%] - % (100% = curent) Acceptă noua bazală temporară: Tratament Calculator @@ -246,7 +244,6 @@ IOB din pompă Unități zilnic Ultimul bolus - %.1f o în urmă Date de intrare incorecte Valoare setată incorect Reîncarcă profilul @@ -505,7 +502,6 @@ Adult rezistent la insulină Vă rog să selectați vârsta pacientului în vederea stabilirii valorilor maxime admise de siguranță Glimp - %s necesită excluderea din lista de optimizare a bateriei pentru funcționare corespunzătoare Buclă suspendată Suspendat (%1$d min) Superbolus (%1$d min) @@ -541,8 +537,6 @@ Activați indicatori pentru CAGE, IAGE, SAGE, nivel baterie și rezervor pe ecranul principal. Pragul de avertisment pentru insulina din rezervor [U] Pragul critic al nivelului insulinei în rezervor [U] - Pragul de avertizare nivel baterie [%] - Pragul critic al nivelului baterie [%] IOB COB Firmware @@ -736,7 +730,6 @@ Rulează Se oprește TBR Se setează TBR (%1$d%% / %2$d min) - Bolusare (%.1f U) Reîncărcare Operațiunea nu este suportată de pompă Folosire nesigură: un bolus extins sau multiwave este activ. Modul buclă este setat să funcționeze în low-suspend pentru 6 ore. Doar bolusurile normale sunt posibile. diff --git a/app/src/main/res/values-ru/strings.xml b/app/src/main/res/values-ru/strings.xml index 26d330f64b..aaa07dfec0 100644 --- a/app/src/main/res/values-ru/strings.xml +++ b/app/src/main/res/values-ru/strings.xml @@ -147,8 +147,8 @@ ограничение нарушено Ошибка подачи болюса Ошибка подачи врем базала - величина базала (%) - % (100% = текущий) + Величина базала [%%] + %% (100%% = текущее) принять новый врем базал: болюс калькулятор @@ -248,7 +248,7 @@ активный инсулин на помпе суточные единицы предыдущий болюс - %.1fч назад + %1$.1fч назад введенные данные неверны величина не задана должным образом обновить профиль @@ -528,7 +528,7 @@ Инсулинорезистентный взрослый выберите возраст пациента для определения ограничителей безопасности Glimp - %s необходимо включить в белый список для корректной работы + %1$s необходимо включить в белый список оптимизации батареи для корректной работы ЗЦ остановлен Остановлен на(%1$d m) Суперболюс(%1$d m) @@ -564,8 +564,8 @@ Включить на главном экране индикаторы отработанного времени для канюли помпы, инсулина, сенсора, резервуара, а также показать уровень аккумулятора. Порог уровня наполненности резервуара для оповещения [ед.] Порог критического уровня наполненности резервуара [U] - Порог предупреждения о разрядке батареи [%] - Порог предупреждения о критическом уровне разрядки батареи [%] + Порог предупреждения о разрядке батареи [%%] + Порог предупреждения о критическом уровне разрядки батареи [%%] IOB акт инс акт углев прошивка @@ -764,7 +764,7 @@ Выполняется Отмена врем базала TBR Установка врем базала TBR на (%1$d%% / %2$d мин) - Введение болюса (%.1f ед) + Введение болюса (%1$.1f ед) Обновление Запрашиваемая операция не поддерживается помпой Небезопасное использование: Удлиненный или многоволновой болюс активны. Режим цикла Loop установлен на приостановку при низкой гликемии только на 6 часов. В режиме loop поддерживаются только обычные болюсы @@ -1158,4 +1158,8 @@ Context | Edit Context Неверный код. Команда отменена. Не сконфигурировано Переключатель профиля создан + Проверка версии + старая версия + очень старая версия + Новая версия доступна не менее %1$d дней! После 60 дней переход на остановку при низкой гликемии LGS, замкнутый цикл будет отключен через 90 дней diff --git a/app/src/main/res/values-sk/strings.xml b/app/src/main/res/values-sk/strings.xml index d2cdb050cd..f9dacaef8b 100644 --- a/app/src/main/res/values-sk/strings.xml +++ b/app/src/main/res/values-sk/strings.xml @@ -147,8 +147,8 @@ Mimo povolený rozsah Chyba podania bolusu Chyba podávania dočasného bazálu - Hodnota bazálu [%] - % (100% = aktuálny) + Hodnota bazálu [%%] + %% (100%% = aktuálny) Povoliť nový dočasný bazál: Bolus Kalkulačka @@ -248,7 +248,7 @@ IOB z pumpy Jednotiek za deň Posledný bolus - pred %.1fh + pred %1$.1fh Chybné vstupné dáta Hodnota nenastavená správne Obnoviť profil @@ -528,7 +528,7 @@ Dospelý z nízkou citlivosťou Vyberte vek pacienta pre nastavenie bezpečnostných limitov Glimp - %s potrebuje vypnúť optimalizáciu baterie pre optimálny výkon + %1$s potrebuje vypnúť optimalizáciu batérie pre optimálny výkon Uzavretý okruh pozastavený Pozastavený (%1$d min) Superbolus (%1$d m) @@ -564,8 +564,8 @@ Povoliť indikátory stavu pre CAGE, IAGE, SAGE, Reservoir a Battery Level na domovskej obrazovke. Prah upozornenia na úroveň hladiny zásobníka [U] Prah kritickej úrovne hladiny zásobníka [U] - Prah upozornenia na úroveň batérie [%] - Prah kritickej úrovne batérie [%] + Prah upozornenia na úroveň batérie [%%] + Prah kritickej úrovne batérie [%%] IOB COB Firmware @@ -764,7 +764,7 @@ V prevádzke Rušenie dočasného bazálu Nastavovanie doč. bazálu (%1$d%% / %2$d min) - Podávanie bolusu (%.1f U) + Podávanie bolusu (%1$.1f U) Aktualizuje sa stav Požadovaná operácia nie je pumpou podporovaná Nebezpečné použitie: predĺžený alebo multiwave bolus je aktívny. Pumpa bola vypnutá len na 6 hodín. Povolené sú iba normálne bolusy. @@ -1156,6 +1156,10 @@ Nesprávný kód. Príkaz zrušený. Nie je nakonfigurované Prepnutie profilu vytvorené + Kontrola verzie + stará verzia + veľmi stará verzia + Nová verzia dostupná najmenej %1$d dní! Návrat k liečbe inzulínovou pumpou s podporou senzora po 60 dňoch, okruh bude deaktivovaný po 90 dňoch. %1$d deň %1$d dní diff --git a/app/src/main/res/values-sv/strings.xml b/app/src/main/res/values-sv/strings.xml index 74378fb8d9..409b7f21a6 100644 --- a/app/src/main/res/values-sv/strings.xml +++ b/app/src/main/res/values-sv/strings.xml @@ -148,8 +148,6 @@ Eversense-appen. Begränsning nådd Fel vid bolusleverans Fel vid justering av temp basal - Basal [%] - % (100% = profilens värde) Acceptera ny temp basal: Behandling Kalkylator @@ -249,7 +247,6 @@ Eversense-appen. Pumpens IOB Enheter per dag Senaste bolus - %.1f tim sedan Fel på inmatning Misslyckades med inställning Ladda om profil @@ -529,7 +526,6 @@ Eversense-appen. Insulinresistent vuxen Vg ange personens ålder för inställningar av gränser Glimp - %s behöver kunna kringgå batterisparfunktionerna för att fungera korrekt Loop pausad Pausad (%1$d min) Superbolus (%1$d min) @@ -565,8 +561,6 @@ Eversense-appen. Aktivera statusindikationerna för cage, iage, sage, reservoar och batterinivå på hemskärmen. Varningsnivå för reservoar [U] Akut varningsnivå för reservoar [U] - Varningsnivå för batteri [%] - Akut varningsnivå för batteri [%] IOB COB Firmwareversion @@ -765,7 +759,6 @@ Eversense-appen. Körs Avbryter temp basal Sätter temp basal (%1$d%% / %2$d min) - Levererar bolus (%.1f enheter) Uppdaterar Önskad åtgärd stöds inte av pumpen Osäker användning: Förlängd- eller kombibolus är aktiv. Loop mode är satt till att bromsa vid lågt BG i 6 timmar. Endast normala bolusar tillåtna i loopläge. diff --git a/app/src/main/res/values-tr/strings.xml b/app/src/main/res/values-tr/strings.xml index dcc3af86e3..d858630fff 100644 --- a/app/src/main/res/values-tr/strings.xml +++ b/app/src/main/res/values-tr/strings.xml @@ -143,8 +143,6 @@ Kısıtlamalar ihlali Bolus teslimat hatası Geçici Bazal teslimat hatası - Bazal değeri [%] - % ( 100% = aktuel) Yeni geçici bazal oranını kabul et: Tedavi Hesap makinesi @@ -244,7 +242,6 @@ IOB(Aktif insülin) pompa Günlük birimleri Son bolus - %.1fs önce Geçersiz bilgi girişi Değer düzgün ayarlanmamış Dosyayı yeniden yükle @@ -503,7 +500,6 @@ Aktif Karbonhidratın ne kadar hızlı sindirildiğine ve KŞ\'nin beklenenden d Yetişkin İnsülin direnci Güvenlik sınırlarını ayarlamak için lütfen hasta yaşını seçiniz Glimp - %s, düzgün bir şekilde çalışması için devre dışı bırakılmış pil performans ayarlaması gerektirir Döngü durduldu Askıya alındı (%1$d m) Superbolus (%1$d m) @@ -725,7 +721,6 @@ Aktif Karbonhidratın ne kadar hızlı sindirildiğine ve KŞ\'nin beklenenden d Çalışıyor TBR (Geçici Bazal Oranı) İptal ediliyor TBR(Geçici Bazal Oranı) ayarı (%1$d%% / %2$d dak) - Bolus (%.1f U) teslim ediliyor Yenileniyor... İstenen işlem pompası tarafından desteklenmiyor Güvensiz kullanım: yayım veya çoklu dalgalı (kare dalgalı) boluslar aktiftir. Döngü modu 6 saat içinde ekstra insülin vermeyecektir. Döngü modunda sadece normal boluslar desteklenir diff --git a/app/src/main/res/values-zh/strings.xml b/app/src/main/res/values-zh/strings.xml index 2e1874e5ef..7e4b22eacd 100644 --- a/app/src/main/res/values-zh/strings.xml +++ b/app/src/main/res/values-zh/strings.xml @@ -53,6 +53,7 @@ 使用您的 WearOS 手表监视和控制 AndroidAPS。 在 xDrip + 表盘上显示有关闭环的信息。 远程控制 AndroidAPS 使用 SMS 短信命令。 + 返回 开始 校验 单位 @@ -145,8 +146,6 @@ 违反约束条件 大剂量输注错误 临时基础输注错误 - 基础率数值 [%] - % (100% = 当前) 接受新的临时基础率 治疗 计算器 @@ -246,7 +245,6 @@ 泵 IOB 每日单位数 上次大剂量 - %.1fh 前 无效的输入数据 数值设定的不正确 重新加载配置文件 @@ -264,6 +262,10 @@ 要输注大剂量胰岛素%1$.2fU 回复如下代码 %2$s 要发送校准值 %1$.2f 回复如下代码 %2$s 大剂量输注失败 + 已经成功输注大剂量%1$.2fU + 将要输注 %1$.2fU + 已经成功输注大剂量%1$.2fU + 正在输注 %1$.2fU 通过SMS短信允许远程命令 手指 传感器 @@ -331,11 +333,24 @@ 闭环被启用 %1$.2f 超过 %2$.2f的限制 远程命令没有被允许 + 远程大剂量不可用。请稍后再试。 + 要开始基础率 %1$.2fU/h 持续时间%2$d 分钟,请回复如下代码 %3$s + 要切换配置文件到 %1$s %2$d%% 请回复代码 %3$s + 要开始扩展大剂量 %1$.2fU/h 持续时间%2$d 分钟,请回复如下代码 %3$s + 要开始基础率 %1$d%% 持续时间%2$d 分钟,请回复如下代码 %3$s 要暂停闭环 %1$d 分钟请回复如下代码 %2$s 临时基础率 %1$.2fU/h 持续 %2$d 分钟启用成功了 + 扩展大剂量 %1$.2fU/h 持续时间 %2$d 分钟已经启用成功了 + 临时基础率 %1$d%% 持续时间 %2$d 分钟 启用成功了 开始临时基础率失败了 + 开始扩展大剂量失败了 + 要停止临时基础率,请回复如下代码 %1$s + 要停止扩展大剂量,请回复如下代码 %1$s 临时基础率取消了 + 扩展大剂量已经取消了 取消临时基础率失败 + 取消扩展大剂量失败 + 未知的命令或者错误的回复 快速向导 快速向导设置 按钮文本: @@ -505,7 +520,6 @@ 胰岛素抵抗成人 请选择患者年龄以设置安全限制 Glimp - %s 需要加入电池优化白名单才能正常运行 闭环暂停了 暂停了 (%1$d m) 超级大剂量 (%1$d m) @@ -541,8 +555,6 @@ 在主屏幕上启用cage(碳水时间)、iage(胰岛素时间)、sage(探头使用时间)、储药器和电池电量的状态指示灯。 储药器药量低于阈值[U] 警告 储药器药量低于阈值[U] 严重警告 - 电池电量低于阈值[%] 警告 - 电池电量低于阈值[%] 严重警告 IOB活性胰岛素 COB活性碳水 固件 @@ -550,6 +562,7 @@ 蓝牙状态 关于 缺少 SMS 短信权限 + 缺少手机状态权限 xDrip 状态 (手表) xDrip 状态线 (手表) xdrip @@ -735,7 +748,6 @@ 正在运行 正在取消临时基础率 正在设置临时基础率 (%1$d%% / %2$d 分钟) - 正在输注大剂量 (%.1f U) 正在刷新 泵不支持请求的操作 不安全的用法: 扩展大剂量(方波) 或者双波被启用了,闭环只支持常规大剂量, 闭环已经被设置为6个小时的低血糖暂停模式(low-suspend only 6 hours). @@ -1001,6 +1013,7 @@ %1$d.目标 Poctech 从 Poctech app 接收血糖值。 + 从番茄app(喵喵设备) 接收血糖值 高临时目标增加灵敏度 =100 mg/dl (5.5 mmol/l) 时提高灵敏度]]> 低临时目标降低灵敏度 @@ -1057,6 +1070,7 @@ 静音 泵警报 记录位置更换 + 记录储药器更换 记录管路更换 记录电池更换 记录操作模式更改 @@ -1100,6 +1114,7 @@ 最后一次连接: %1$d 分钟前 临时基础率: %1$d%% for %2$d / %3$d 分钟 扩展: %1$.2f / %2$.2f U 为 %3$d 分钟 + 多波: %1$.2f / %2$.2f U 持续时间 %3$d 分钟 TDD(日输注总量): %1$.2f Reser.: %1$.2fU 电池: %1$d%% @@ -1113,6 +1128,16 @@ /U 记录传感器更换至NS服务器 在传感器启动时在 NS服务器 自动创建事件 \"传感器更改\" + 番茄(喵喵) + 番茄 + 在24小时内或更少时间内更夏令时时间 + 不到3小时前夏令时时间变化了-已禁用闭环 + 内部储存空间不足 + 至少 剩余%1$d MB 内部存储!闭环已禁用! + 格式错误 + 错误的代码。命令取消 + 未配置 + 配置文件切换已创建 %1$d 天 From ffbb37348108efb6b4b43e30329508927cb3dfef Mon Sep 17 00:00:00 2001 From: Tebbe Ubben Date: Wed, 24 Apr 2019 22:36:29 +0200 Subject: [PATCH 35/42] Insight: Update sqlite_sequence on DB update --- .../androidaps/db/DatabaseHelper.java | 29 +++++++++---------- 1 file changed, 14 insertions(+), 15 deletions(-) diff --git a/app/src/main/java/info/nightscout/androidaps/db/DatabaseHelper.java b/app/src/main/java/info/nightscout/androidaps/db/DatabaseHelper.java index 1b2c21bf18..1f071a2f18 100644 --- a/app/src/main/java/info/nightscout/androidaps/db/DatabaseHelper.java +++ b/app/src/main/java/info/nightscout/androidaps/db/DatabaseHelper.java @@ -45,9 +45,9 @@ import info.nightscout.androidaps.events.EventTempTargetChange; import info.nightscout.androidaps.interfaces.ProfileInterface; import info.nightscout.androidaps.logging.L; import info.nightscout.androidaps.plugins.configBuilder.ConfigBuilderPlugin; +import info.nightscout.androidaps.plugins.general.nsclient.NSUpload; import info.nightscout.androidaps.plugins.iob.iobCobCalculator.IobCobCalculatorPlugin; import info.nightscout.androidaps.plugins.iob.iobCobCalculator.events.EventNewHistoryData; -import info.nightscout.androidaps.plugins.general.nsclient.NSUpload; import info.nightscout.androidaps.plugins.pump.danaR.activities.DanaRNSHistorySync; import info.nightscout.androidaps.plugins.pump.danaR.comm.RecordTypes; import info.nightscout.androidaps.plugins.pump.insight.database.InsightBolusID; @@ -83,7 +83,7 @@ public class DatabaseHelper extends OrmLiteSqliteOpenHelper { public static final String DATABASE_INSIGHT_BOLUS_IDS = "InsightBolusIDs"; public static final String DATABASE_INSIGHT_PUMP_IDS = "InsightPumpIDs"; - private static final int DATABASE_VERSION = 10; + private static final int DATABASE_VERSION = 11; public static Long earliestDataChange = null; @@ -147,19 +147,7 @@ public class DatabaseHelper extends OrmLiteSqliteOpenHelper { this.oldVersion = oldVersion; this.newVersion = newVersion; - if (oldVersion == 7 && newVersion == 8) { - log.debug("Upgrading database from v7 to v8"); - } else if (oldVersion == 8 && newVersion == 9) { - log.debug("Upgrading database from v8 to v9"); - } else if (oldVersion == 9 && newVersion == 10) { - TableUtils.createTableIfNotExists(connectionSource, InsightHistoryOffset.class); - TableUtils.createTableIfNotExists(connectionSource, InsightBolusID.class); - TableUtils.createTableIfNotExists(connectionSource, InsightPumpID.class); - database.execSQL("INSERT INTO sqlite_sequence (name, seq) SELECT \"" + DATABASE_INSIGHT_BOLUS_IDS + "\", " + System.currentTimeMillis() + " " + - "WHERE NOT EXISTS (SELECT 1 FROM sqlite_sequence WHERE name = \"" + DATABASE_INSIGHT_BOLUS_IDS + "\")"); - database.execSQL("INSERT INTO sqlite_sequence (name, seq) SELECT \"" + DATABASE_INSIGHT_PUMP_IDS + "\", " + System.currentTimeMillis() + " " + - "WHERE NOT EXISTS (SELECT 1 FROM sqlite_sequence WHERE name = \"" + DATABASE_INSIGHT_PUMP_IDS + "\")"); - } else { + if (oldVersion < 7) { log.info(DatabaseHelper.class.getName(), "onUpgrade"); TableUtils.dropTable(connectionSource, TempTarget.class, true); TableUtils.dropTable(connectionSource, BgReading.class, true); @@ -170,6 +158,17 @@ public class DatabaseHelper extends OrmLiteSqliteOpenHelper { TableUtils.dropTable(connectionSource, CareportalEvent.class, true); TableUtils.dropTable(connectionSource, ProfileSwitch.class, true); onCreate(database, connectionSource); + } else if (oldVersion < 10) { + TableUtils.createTableIfNotExists(connectionSource, InsightHistoryOffset.class); + TableUtils.createTableIfNotExists(connectionSource, InsightBolusID.class); + TableUtils.createTableIfNotExists(connectionSource, InsightPumpID.class); + database.execSQL("INSERT INTO sqlite_sequence (name, seq) SELECT \"" + DATABASE_INSIGHT_BOLUS_IDS + "\", " + System.currentTimeMillis() + " " + + "WHERE NOT EXISTS (SELECT 1 FROM sqlite_sequence WHERE name = \"" + DATABASE_INSIGHT_BOLUS_IDS + "\")"); + database.execSQL("INSERT INTO sqlite_sequence (name, seq) SELECT \"" + DATABASE_INSIGHT_PUMP_IDS + "\", " + System.currentTimeMillis() + " " + + "WHERE NOT EXISTS (SELECT 1 FROM sqlite_sequence WHERE name = \"" + DATABASE_INSIGHT_PUMP_IDS + "\")"); + } else if (oldVersion < 11) { + database.execSQL("UPDATE sqlite_sequence SET seq = " + System.currentTimeMillis() + " WHERE name = \"" + DATABASE_INSIGHT_BOLUS_IDS + "\""); + database.execSQL("UPDATE sqlite_sequence SET seq = " + System.currentTimeMillis() + " WHERE name = \"" + DATABASE_INSIGHT_PUMP_IDS + "\""); } } catch (SQLException e) { log.error("Can't drop databases", e); From 4d66e0c1be793c428005a20067b901f4c8d3f599 Mon Sep 17 00:00:00 2001 From: AdrianLxM Date: Thu, 25 Apr 2019 00:32:40 +0200 Subject: [PATCH 36/42] 2.3 bump --- app/build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/build.gradle b/app/build.gradle index f3a1139a38..f4f4ca7add 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -83,7 +83,7 @@ android { targetSdkVersion 25 multiDexEnabled true versionCode 1500 - version "2.2.3-dev" + version "2.3" buildConfigField "String", "VERSION", '"' + version + '"' buildConfigField "String", "BUILDVERSION", '"' + generateGitBuild() + '-' + generateDate() + '"' buildConfigField "String", "REMOTE", '"' + generateGitRemote()+ '"' From 0bab2e6c11df052b22a29727f6fc20b21efa9179 Mon Sep 17 00:00:00 2001 From: Milos Kozak Date: Thu, 25 Apr 2019 14:19:39 +0200 Subject: [PATCH 37/42] 2.3.1-dev --- app/build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/build.gradle b/app/build.gradle index 676c9b6287..10a52b8ca1 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -103,7 +103,7 @@ android { targetSdkVersion 25 multiDexEnabled true versionCode 1500 - version "2.3" + version "2.3.1-dev" buildConfigField "String", "VERSION", '"' + version + '"' buildConfigField "String", "BUILDVERSION", '"' + generateGitBuild() + '-' + generateDate() + '"' buildConfigField "String", "REMOTE", '"' + generateGitRemote() + '"' From 8b18a7ffb341d4d0f1457fe01fdcf9044e9609b9 Mon Sep 17 00:00:00 2001 From: Milos Kozak Date: Thu, 25 Apr 2019 18:59:10 +0200 Subject: [PATCH 38/42] German git --- app/build.gradle | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/app/build.gradle b/app/build.gradle index 676c9b6287..a8d8f2a0fe 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -87,7 +87,8 @@ def allCommited = { -> } catch (ignored) { return false; // NoGitSystemAvailable } - return stringBuilder.toString().contains("nothing to commit") + return stringBuilder.toString().contains("nothing to commit") || stringBuilder.toString().contains("nichts zu committen") + } tasks.matching { it instanceof Test }.all { From 6fd8d7ae3cbbd2fc57583056f8a9e960eb32db30 Mon Sep 17 00:00:00 2001 From: AdrianLxM Date: Thu, 25 Apr 2019 20:42:34 +0200 Subject: [PATCH 39/42] not language dependent git command --- app/build.gradle | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/build.gradle b/app/build.gradle index a8d8f2a0fe..8c153a9e81 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -79,7 +79,7 @@ def allCommited = { -> try { def stdout = new ByteArrayOutputStream() exec { - commandLine 'git', 'status' + commandLine 'git', 'status', '-s' standardOutput = stdout } String commitObject = stdout.toString().trim() @@ -87,7 +87,7 @@ def allCommited = { -> } catch (ignored) { return false; // NoGitSystemAvailable } - return stringBuilder.toString().contains("nothing to commit") || stringBuilder.toString().contains("nichts zu committen") + return stringBuilder.toString().isEmpty() } From f2c18cbc1ff7ceab3659f3e96fb36d64c0d2c956 Mon Sep 17 00:00:00 2001 From: AdrianLxM Date: Thu, 25 Apr 2019 22:13:31 +0200 Subject: [PATCH 40/42] Don't warn if next loop invocation is prior to update check --- .../plugins/general/versionChecker/VersionCheckerPlugin.kt | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/general/versionChecker/VersionCheckerPlugin.kt b/app/src/main/java/info/nightscout/androidaps/plugins/general/versionChecker/VersionCheckerPlugin.kt index 2a4c08a585..c0335ea64a 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/general/versionChecker/VersionCheckerPlugin.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/general/versionChecker/VersionCheckerPlugin.kt @@ -32,6 +32,13 @@ object VersionCheckerPlugin : PluginBase(PluginDescription() private fun checkWarning() { val now = System.currentTimeMillis() + + if (!SP.contains(R.string.key_last_versionchecker_plugin_warning)) { + SP.putLong(R.string.key_last_versionchecker_plugin_warning, now) + return + } + + if (isOldVersion(GRACE_PERIOD_WARNING) && shouldWarnAgain(now)) { // store last notification time SP.putLong(R.string.key_last_versionchecker_plugin_warning, now) From c35fbad80a57536a85bbee93080bf5acfdc4d185 Mon Sep 17 00:00:00 2001 From: Milos Kozak Date: Fri, 26 Apr 2019 15:13:10 +0200 Subject: [PATCH 41/42] New translations strings.xml (Romanian) --- app/src/main/res/values-ro/strings.xml | 89 ++++++++++++++++++++++++++ 1 file changed, 89 insertions(+) diff --git a/app/src/main/res/values-ro/strings.xml b/app/src/main/res/values-ro/strings.xml index 12267b972b..894641e880 100644 --- a/app/src/main/res/values-ro/strings.xml +++ b/app/src/main/res/values-ro/strings.xml @@ -9,6 +9,7 @@ Resetează bazele de date Sigur resetați bazele de date? Ieșire + Folosiți bolusuri extinse pentru >200%% Dispozitive bluetooth DanaR Folosește întotdeauna valori absolute ale bazalei Restartați telefonul sau reporniți aplicația AndroidAPS din System Settings \naltfel AndroidAPS nu va putea face loguri (importante pentru verificarea corectitudinii funcționării algoritmilor)! @@ -53,6 +54,7 @@ Monitorizează și controlează aplicația AndroidAPS folosind smartwatchul WearOS. Afișează informații privind starea buclei pe watchface-ul xDrip+. Controlare de la distanță a AndroidAPS folosind comenzi date prin SMS. + Înapoi Start Verifică Unități @@ -145,6 +147,8 @@ Încălcare a unei limite Eroare la livrarea bolusului Eroare la setare bazală temporară + Valoare bazală [%%] + %% (100%% = curent) Acceptă noua bazală temporară: Tratament Calculator @@ -244,6 +248,7 @@ IOB din pompă Unități zilnic Ultimul bolus + %1$.1f o în urmă Date de intrare incorecte Valoare setată incorect Reîncarcă profilul @@ -261,6 +266,10 @@ Pentru a livra un bolus de %1$.2fU răspundeți cu codul %2$s Pentru a trimite calibrarea cu %1$.2f răspundeți cu codul %2$s Bolusare eșuată + Bolusul de %1$.2fU a fost livrat cu succes + Se va livra un bolus de %1$.2fU + Bolusul de %1$.2fU a fost livrat cu succes + Se livrează %1$.2fU Permite comenzi de la distanță, prin SMS Deget Senzor @@ -305,6 +314,7 @@ Stop STOP APĂSAT Se așteaptă pompa + Se va livra un bolus de %1$.2fU Se stabilesc vizualizările și monitorizarea și se analizează bazalele și valorile ratelor Verificați că vedeți glicemia în Nightscout și că datele despre insulină date de pompă sunt înregistrate în site Pornire în mod buclă deschisă @@ -327,12 +337,26 @@ Bucla este dezactivată Bucla este activată %1$.2f este limitată la %2$.2f + Valoarea %1$s este mai mare decât limita stabilită Comanda de la distanță nu este permisă + Bolus de la distanță nu este disponibil. Încearcă din nou mai târziu. + Pentru a iniția bazala de %1$.2fU/h pentru %2$d min trimiteți codul %3$s + Pentru a schimba profilul în %1$s %2$d%% trimiteți codul %3$s + Pentru a stabili bazala de %1$.2fU/h pentru %2$d min trimiteți codul %3$s + Pentru a iniția bazala de %1$d%% pentru %2$d min trimiteți codul %3$s Pentru suspendarea buclei pentru %1$d minute trimiteți codul %2$s Bazala temporară %1$.2fU/h pentru %2$d minute a fost trimisă cu succes + Bolusul extins de %1$.2fU pentru %2$d min a fost inițiat + Bazala temporară %1$d% pentru %2$d minute a fost stabilită cu succes Trimiterea bazalei temporare a eșuat + Pornirea bolusului extins a eșuat + Pentru oprirea bazalei temporare, răspundeți cu codul %1$s + Pentru oprirea bolusului extins, răspundeți cu codul %1$s Bazala temporară a fost anulată + Bolus extins anulat Renunțarea la bazala temporară a eșuat + Anularea bolusului extins a eșuat + Comandă necunoscută sau răspuns greșit AsistentRapid Setări AsistentRapid Text buton: @@ -440,6 +464,7 @@ Profil Valoare implicită: 3\nAceasta este o setare de critică de securitate a OpenAPS. Asta înseamnă că se limitează bazala lade 3x valoarea maximă a bazalelor tale.Cel mai probabil nu veți schimba această valoare, dar trebuie să țineți cont de ce se discută despre “3x max zilnic; 4x curent” ca valori de siguranță. Valoare implicită: 4\nAceasta este cealaltă jumătate a cheii de siguranță a OpenAPS și cealaltă jumătate a \"3x max zilnic; 4x curent\" al setărilor de siguranță.Aceasta înseamnă că bazala dumneavoastră, indiferent de bazala maximă configurată în pompă, nu poate fi mai mare de acest număr înmulțit cu nivelul curent al bazalei active. Această limitare este impusă pentru a evita posibilitatea de a intra pe un teritoriu periculos prin setarea unei bazale maxime excesiv de mari înainte de a înțelege funcționarea algoritmului. Din nou, valoarea implictă este 4x; majoritatea oamenilor nu vor trebui să ajusteze această valoare și vor modifica, mai degrabă, alte valori dacă vor simți că această valoare le stă în cale. + Valoare implicită: 1.2\nAceasta este valoarea limită de multiplicare pentru autosens (și pentru autotune, în curând) pentru a seta o limită maximă de 20%% din cât de mare poate fi raportul autosens, care, la rândul ei, determină cât de mult poate autosens să modifice bazalele, cât de jos poate modifica ISF și cât de jos poate pune ținta glicemiei. Valoare implicită: 0.7\nCealaltă parte a limitelor autosens, care limitează cât de jos poate ajusta bazalele și cât de mult poate mări ISF și țintele de glicemie. Autosens ajustează țintele la Valoare implicită: adevărat\nAceasta se folosește pentru a permite autosens să ajusteze țintele de glicemie, pe lângă modificările asupra ISF și bazalelor. @@ -452,6 +477,7 @@ Numărul de telefon este invalid Număr de telefon SMS invalid Calibrare + Trimite calibrarea %1$.1f către xDrip? xDrip+ nu este instalat. Calibrare trimisă către xDrip Calibrare trimisă. Recepționarea trebuie să fie activată și în xDrip. @@ -502,6 +528,7 @@ Adult rezistent la insulină Vă rog să selectați vârsta pacientului în vederea stabilirii valorilor maxime admise de siguranță Glimp + %1$s necesită excluderea din lista de optimizare a bateriei pentru o funcționare corespunzătoare Buclă suspendată Suspendat (%1$d min) Superbolus (%1$d min) @@ -537,6 +564,8 @@ Activați indicatori pentru CAGE, IAGE, SAGE, nivel baterie și rezervor pe ecranul principal. Pragul de avertisment pentru insulina din rezervor [U] Pragul critic al nivelului insulinei în rezervor [U] + Pragul de avertizare nivel baterie [%%] + Pragul critic al nivelului baterie [%%] IOB COB Firmware @@ -589,6 +618,7 @@ Setări absorbție Timp maxim absorbție masă [o] Timp în ore la care se presupune că toți carbohidrații sunt absorbiți + Afișati bolusul extins ca %% VS VI VC @@ -701,6 +731,8 @@ Trimite date glicemie la xDrip+ Selectați 640g/Eversense ca sursă de date în xDrip+ Glicemie NSClient + Valoarea bazalei a fost înlocuită cu valoarea minimă posibilă: %1$s + Valoarea bazalei a fost înlocuită cu valoarea maximă posibilă: %1$s Calcul glicemie Calcul IOB bolus Calcul IOB bazală @@ -718,6 +750,8 @@ Mod buclă închisă activat IOB maxim configurat corect Glicemie disponibilă din sursa selectată + Valori bazale nesincronizate cu ora: %1$s + Profil invalid: %1$s Se programează pompa pentru livrare bolus Reîncarcă Stare @@ -730,6 +764,7 @@ Rulează Se oprește TBR Se setează TBR (%1$d%% / %2$d min) + Bolusare (%1$.1f U) Reîncărcare Operațiunea nu este suportată de pompă Folosire nesigură: un bolus extins sau multiwave este activ. Modul buclă este setat să funcționeze în low-suspend pentru 6 ore. Doar bolusurile normale sunt posibile. @@ -1052,11 +1087,13 @@ Liniște Alertă a pompei Înregistrează schimbările locului de inserție + Jurnal al schimbărilor rezervorului Înregistrează schimbările canulei Înregistrează schimbările bateriei Înregistrează schimbările modului de operare Înregistrează alertele Activează emularea RBT + Folosește bolus extins în locul RBT pentru a trece de limita de 250%% Întârziere a deconectării [s] Număr de serie Versiunea de software @@ -1071,6 +1108,58 @@ Șterge asocierea Informații despre asociere Reîmprospătare stare + Porniți pompa + Opriți pompa + Modul de funcționare + Stare + Bolus TDD + Bazală TDD + Total TDD + Se recuperează... + Nu există asociere + Ultima conexiune + Pornit + Oprit + %1$d%% pentru %2$d / %3$d min + Bolus extins + Bolus multiwave + %1$.2f / %2$.2f U pentru %3$d min + Permiteți notificarea de terminare RBT\n(setare a pompei) + Nu permiteți notificarea terminării RBT\n(setare a pompei) + Actualizează + Integrare pentru pompele Accu-Chek Insight + Nu este introdus + Ultima conexiune: acum %1$d min + TBR: %1$d%% pentru %2$d / %3$d min + Extins: %1$.2f / %2$.2f U pentru %3$d min + Multiwave: %1$.2f / %2$.2f U pentru %3$d min + TDD: %1$.2f + Rzvr.: %1$.2fU + Bat.: %1$d%% + Timpul maxim de restabilire [s] + Timpul minim de restabilire [s] + Durata restabilirii + Durată timp expirat pe timpul negocierii - resetare bluetooth + == ∑ %1$s U + U/h + g/U + /U + Înregistrează schimbarea senzorului în NS + Crează eveniment ”Schimbare Senzor” în NS la pornirea senzorului + Tomato (MiaoMiao) + Tomato + Schimbare oră vară/iarnă în mai puțin de 24h + Schimbare oră vară/iarnă în mai puțin de 3 ore - buclă dezactivată + restricție de stocare internă + Eliberați cel puțin %1$d MB din spațiunl de stocare al telefonlui! Buclă dezactivată! + Format greșit + Cod greșit. Comandă anulată. + Nu este configurat + Schimbare de profil creată + Verificator versiune + versiune veche + versiune foarte veche + Noua versiune este disponibilă de cel puțin %1$d zile! Revenire la LGS după 60 zile, bucla va fi dezactivată după 90 zile %1$d zi %1$d zi From 3a7b00f424677967a09cd1527253c241d9613517 Mon Sep 17 00:00:00 2001 From: AdrianLxM Date: Sun, 28 Apr 2019 14:33:04 +0200 Subject: [PATCH 42/42] Include 39 as valid value --- .../main/java/info/nightscout/androidaps/db/DatabaseHelper.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/src/main/java/info/nightscout/androidaps/db/DatabaseHelper.java b/app/src/main/java/info/nightscout/androidaps/db/DatabaseHelper.java index 1f071a2f18..eb51f5e2ba 100644 --- a/app/src/main/java/info/nightscout/androidaps/db/DatabaseHelper.java +++ b/app/src/main/java/info/nightscout/androidaps/db/DatabaseHelper.java @@ -434,7 +434,7 @@ public class DatabaseHelper extends OrmLiteSqliteOpenHelper { return null; for (int i = 0; i < bgList.size(); i++) - if (bgList.get(i).value > 39) + if (bgList.get(i).value >= 39) return bgList.get(i); return null; }