diff --git a/app/build.gradle b/app/build.gradle index 080422af46..72af0a8020 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -15,8 +15,7 @@ apply plugin: "jacoco-android" apply plugin: 'com.jakewharton.butterknife' ext { - supportLibraryVersion = "27.0.2" - sdkBuildVersion = "27.0.3" + supportLibraryVersion = "27.1.0" ormLiteVersion = "4.46" powermockVersion = "1.7.3" dexmakerVersion = "1.2" @@ -57,12 +56,11 @@ tasks.matching {it instanceof Test}.all { android { compileSdkVersion 27 - buildToolsVersion "${sdkBuildVersion}" defaultConfig { applicationId "info.nightscout.androidaps" minSdkVersion 21 - targetSdkVersion 27 + targetSdkVersion 25 multiDexEnabled true versionCode 1500 version "1.60c-dev" @@ -78,7 +76,7 @@ android { // 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 // build with a deprecation warning - // abortOnError false + abortOnError false // (disabled entirely to avoid reports on the error, which would still be displayed // and it's easy to overlook that it's ignored) checkReleaseBuilds false @@ -183,7 +181,7 @@ dependencies { implementation("com.crashlytics.sdk.android:answers:1.3.12@aar") { transitive = true; } - libs 'MilosKozak:danars-support-lib:master@zip' + libs "MilosKozak:danars-support-lib:master@zip" implementation "com.android.support:appcompat-v7:${supportLibraryVersion}" implementation "com.android.support:support-v4:${supportLibraryVersion}" diff --git a/app/src/main/java/info/nightscout/androidaps/Config.java b/app/src/main/java/info/nightscout/androidaps/Config.java index babaccb2b1..bbd96a6c61 100644 --- a/app/src/main/java/info/nightscout/androidaps/Config.java +++ b/app/src/main/java/info/nightscout/androidaps/Config.java @@ -32,7 +32,6 @@ public class Config { public static final boolean logPumpComm = true; public static final boolean logPrefsChange = true; public static final boolean logConfigBuilder = true; - public static final boolean logConstraintsChanges = true; public static final boolean logNSUpload = true; public static final boolean logPumpActions = true; public static final boolean logCongigBuilderActions = true; diff --git a/app/src/main/java/info/nightscout/androidaps/MainActivity.java b/app/src/main/java/info/nightscout/androidaps/MainActivity.java index 0ae1e48775..956d2c46e6 100644 --- a/app/src/main/java/info/nightscout/androidaps/MainActivity.java +++ b/app/src/main/java/info/nightscout/androidaps/MainActivity.java @@ -403,7 +403,8 @@ public class MainActivity extends AppCompatActivity implements View.OnClickListe else builder.setIcon(R.mipmap.blueowl); String message = "Build: " + BuildConfig.BUILDVERSION + "\n"; - message += MainApp.sResources.getString(R.string.configbuilder_nightscoutversion_label) + " " + ConfigBuilderPlugin.nightscoutVersionName; + message += "Flavor: " + BuildConfig.FLAVOR + BuildConfig.BUILD_TYPE + "\n"; + message += getString(R.string.configbuilder_nightscoutversion_label) + " " + ConfigBuilderPlugin.nightscoutVersionName; if (MainApp.engineeringMode) message += "\n" + MainApp.gs(R.string.engineering_mode_enabled); message += getString(R.string.about_link_urls); diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/IobCobCalculator/IobCobThread.java b/app/src/main/java/info/nightscout/androidaps/plugins/IobCobCalculator/IobCobThread.java index da7d0fbbbd..1605ee8e10 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/IobCobCalculator/IobCobThread.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/IobCobCalculator/IobCobThread.java @@ -155,7 +155,8 @@ public class IobCobThread extends Thread { AutosensData hourAgoData = iobCobCalculatorPlugin.getAutosensData(hourago); if (hourAgoData != null) { int initialIndex = autosensDataTable.indexOfKey(hourAgoData.time); - log.debug(">>>>> bucketed_data.size()=" + bucketed_data.size() + " i=" + i + "hourAgoData=" + hourAgoData.toString()); + if (Config.logAutosensData) + log.debug(">>>>> bucketed_data.size()=" + bucketed_data.size() + " i=" + i + "hourAgoData=" + hourAgoData.toString()); int past = 1; try { for (; past < 12; past++) { @@ -242,7 +243,8 @@ public class IobCobThread extends Thread { previous = autosensData; autosensDataTable.put(bgTime, autosensData); - log.debug("Running detectSensitivity from: " + DateUtil.dateAndTimeString(oldestTimeWithData) + " to: " + DateUtil.dateAndTimeString(bgTime)); + if (Config.logAutosensData) + log.debug("Running detectSensitivity from: " + DateUtil.dateAndTimeString(oldestTimeWithData) + " to: " + DateUtil.dateAndTimeString(bgTime)); autosensData.autosensRatio = iobCobCalculatorPlugin.detectSensitivity(oldestTimeWithData, bgTime).ratio; if (Config.logAutosensData) log.debug(autosensData.toString()); diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/Loop/LoopPlugin.java b/app/src/main/java/info/nightscout/androidaps/plugins/Loop/LoopPlugin.java index fed92404e5..e29eda04dc 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/Loop/LoopPlugin.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/Loop/LoopPlugin.java @@ -1,11 +1,14 @@ package info.nightscout.androidaps.plugins.Loop; +import android.annotation.SuppressLint; import android.app.Notification; +import android.app.NotificationChannel; import android.app.NotificationManager; import android.app.PendingIntent; import android.app.TaskStackBuilder; import android.content.Context; import android.content.Intent; +import android.os.Build; import android.support.v4.app.NotificationCompat; import com.crashlytics.android.answers.CustomEvent; @@ -48,6 +51,9 @@ import info.nightscout.utils.SP; public class LoopPlugin extends PluginBase { private static Logger log = LoggerFactory.getLogger(LoopPlugin.class); + public static final String CHANNEL_ID = "AndroidAPS-Openloop"; + + protected static LoopPlugin loopPlugin; public static LoopPlugin getPlugin() { @@ -90,9 +96,22 @@ public class LoopPlugin extends PluginBase { @Override protected void onStart() { MainApp.bus().register(this); + createNotificationChannel(); super.onStart(); } + private void createNotificationChannel() { + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { + + NotificationManager mNotificationManager = + (NotificationManager) MainApp.instance().getApplicationContext().getSystemService(Context.NOTIFICATION_SERVICE); + @SuppressLint("WrongConstant") NotificationChannel channel = new NotificationChannel(CHANNEL_ID, + CHANNEL_ID, + NotificationManager.IMPORTANCE_HIGH); + mNotificationManager.createNotificationChannel(channel); + } + } + @Override protected void onStop() { super.onStop(); @@ -322,7 +341,7 @@ public class LoopPlugin extends PluginBase { } else { if (result.isChangeRequested() && allowNotification) { NotificationCompat.Builder builder = - new NotificationCompat.Builder(MainApp.instance().getApplicationContext()); + new NotificationCompat.Builder(MainApp.instance().getApplicationContext(), CHANNEL_ID); builder.setSmallIcon(R.drawable.notif_icon) .setContentTitle(MainApp.sResources.getString(R.string.openloop_newsuggestion)) .setContentText(resultAfterConstraints.toString()) diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/Overview/notifications/NotificationStore.java b/app/src/main/java/info/nightscout/androidaps/plugins/Overview/notifications/NotificationStore.java index aa61b48097..a8c2a37891 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/Overview/notifications/NotificationStore.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/Overview/notifications/NotificationStore.java @@ -1,5 +1,7 @@ package info.nightscout.androidaps.plugins.Overview.notifications; +import android.annotation.SuppressLint; +import android.app.NotificationChannel; import android.app.NotificationManager; import android.content.Context; import android.content.Intent; @@ -8,6 +10,7 @@ import android.graphics.BitmapFactory; import android.media.AudioAttributes; import android.media.RingtoneManager; import android.net.Uri; +import android.os.Build; import android.support.v4.app.NotificationCompat; import org.slf4j.Logger; @@ -28,11 +31,15 @@ import info.nightscout.utils.SP; */ public class NotificationStore { + + public static final String CHANNEL_ID = "AndroidAPS-Overview"; + private static Logger log = LoggerFactory.getLogger(NotificationStore.class); public List store = new ArrayList(); public long snoozedUntil = 0L; public NotificationStore() { + createNotificationChannel(); } public class NotificationComparator implements Comparator { @@ -110,7 +117,7 @@ public class NotificationStore { Bitmap largeIcon = BitmapFactory.decodeResource(context.getResources(), R.mipmap.blueowl); Uri sound = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_ALARM); NotificationCompat.Builder notificationBuilder = - new NotificationCompat.Builder(context) + new NotificationCompat.Builder(context, CHANNEL_ID) .setSmallIcon(R.drawable.ic_notification) .setLargeIcon(largeIcon) .setContentText(n.text) @@ -127,4 +134,17 @@ public class NotificationStore { } mgr.notify(n.id, notificationBuilder.build()); } + + private void createNotificationChannel() { + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { + + NotificationManager mNotificationManager = + (NotificationManager) MainApp.instance().getApplicationContext().getSystemService(Context.NOTIFICATION_SERVICE); + @SuppressLint("WrongConstant") NotificationChannel channel = new NotificationChannel(CHANNEL_ID, + CHANNEL_ID, + NotificationManager.IMPORTANCE_HIGH); + mNotificationManager.createNotificationChannel(channel); + } + } + } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/Persistentnotification/PersistentNotificationPlugin.java b/app/src/main/java/info/nightscout/androidaps/plugins/Persistentnotification/PersistentNotificationPlugin.java index ee04843080..789c9df143 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/Persistentnotification/PersistentNotificationPlugin.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/Persistentnotification/PersistentNotificationPlugin.java @@ -1,11 +1,14 @@ package info.nightscout.androidaps.plugins.Persistentnotification; +import android.annotation.SuppressLint; +import android.app.NotificationChannel; import android.app.NotificationManager; import android.app.PendingIntent; import android.content.Context; import android.content.Intent; import android.graphics.Bitmap; import android.graphics.BitmapFactory; +import android.os.Build; import android.support.v4.app.NotificationCompat; import android.support.v4.app.TaskStackBuilder; @@ -41,6 +44,8 @@ import info.nightscout.utils.DecimalFormatter; public class PersistentNotificationPlugin extends PluginBase { + public static final String CHANNEL_ID = "AndroidAPS-Ongoing"; + private static final int ONGOING_NOTIFICATION_ID = 4711; private final Context ctx; @@ -57,10 +62,23 @@ public class PersistentNotificationPlugin extends PluginBase { @Override protected void onStart() { MainApp.bus().register(this); + createNotificationChannel(); updateNotification(); super.onStart(); } + private void createNotificationChannel() { + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { + + NotificationManager mNotificationManager = + (NotificationManager) ctx.getSystemService(Context.NOTIFICATION_SERVICE); + @SuppressLint("WrongConstant") NotificationChannel channel = new NotificationChannel(CHANNEL_ID, + CHANNEL_ID, + NotificationManager.IMPORTANCE_HIGH); + mNotificationManager.createNotificationChannel(channel); + } + } + @Override protected void onStop() { MainApp.bus().unregister(this); @@ -118,7 +136,7 @@ public class PersistentNotificationPlugin extends PluginBase { line3 += " - " + MainApp.getConfigBuilder().getProfileName(); - NotificationCompat.Builder builder = new NotificationCompat.Builder(ctx); + NotificationCompat.Builder builder = new NotificationCompat.Builder(ctx, CHANNEL_ID); builder.setOngoing(true); builder.setCategory(NotificationCompat.CATEGORY_STATUS); builder.setSmallIcon(R.drawable.ic_notification); diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/SensitivityAAPS/SensitivityAAPSPlugin.java b/app/src/main/java/info/nightscout/androidaps/plugins/SensitivityAAPS/SensitivityAAPSPlugin.java index 6b072a3a17..0725823ac9 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/SensitivityAAPS/SensitivityAAPSPlugin.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/SensitivityAAPS/SensitivityAAPSPlugin.java @@ -30,7 +30,7 @@ import info.nightscout.utils.SafeParse; * Created by mike on 24.06.2017. */ -public class SensitivityAAPSPlugin extends PluginBase implements SensitivityInterface{ +public class SensitivityAAPSPlugin extends PluginBase implements SensitivityInterface { private static Logger log = LoggerFactory.getLogger(SensitivityAAPSPlugin.class); static SensitivityAAPSPlugin plugin = null; @@ -118,7 +118,9 @@ public class SensitivityAAPSPlugin extends PluginBase implements SensitivityInte String ratioLimit = ""; String sensResult = ""; - log.debug("Records: " + index + " " + pastSensitivity); + if (Config.logAutosensData) + log.debug("Records: " + index + " " + pastSensitivity); + Arrays.sort(deviations); double percentile = IobCobCalculatorPlugin.percentile(deviations, 0.50); @@ -133,7 +135,8 @@ public class SensitivityAAPSPlugin extends PluginBase implements SensitivityInte sensResult = "Sensitivity normal"; } - log.debug(sensResult); + if (Config.logAutosensData) + log.debug(sensResult); double rawRatio = ratio; ratio = Math.max(ratio, SafeParse.stringToDouble(SP.getString("openapsama_autosens_min", "0.7"))); diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/SensitivityOref0/SensitivityOref0Plugin.java b/app/src/main/java/info/nightscout/androidaps/plugins/SensitivityOref0/SensitivityOref0Plugin.java index 46e00427bf..842c4c83bc 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/SensitivityOref0/SensitivityOref0Plugin.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/SensitivityOref0/SensitivityOref0Plugin.java @@ -118,7 +118,9 @@ public class SensitivityOref0Plugin extends PluginBase implements SensitivityInt String ratioLimit = ""; String sensResult = ""; - log.debug("Records: " + index + " " + pastSensitivity); + if (Config.logAutosensData) + log.debug("Records: " + index + " " + pastSensitivity); + Arrays.sort(deviations); for (double i = 0.9; i > 0.1; i = i - 0.02) { @@ -140,7 +142,10 @@ public class SensitivityOref0Plugin extends PluginBase implements SensitivityInt } else { sensResult = "Sensitivity normal"; } - log.debug(sensResult); + + if (Config.logAutosensData) + log.debug(sensResult); + ratio = 1 + (basalOff / profile.getMaxDailyBasal()); double rawRatio = ratio; diff --git a/build.gradle b/build.gradle index 7cfd0f7ea4..b958e8ab96 100644 --- a/build.gradle +++ b/build.gradle @@ -18,8 +18,8 @@ buildscript { allprojects { repositories { - jcenter() google() + jcenter() maven { url "https://maven.google.com" diff --git a/wear/build.gradle b/wear/build.gradle index e842aae62f..aef05d79c4 100644 --- a/wear/build.gradle +++ b/wear/build.gradle @@ -1,8 +1,7 @@ apply plugin: 'com.android.application' ext { - supportLibraryVersion = "23.0.1" - wearableVersion = "2.0.1" + wearableVersion = "2.0.1" } def generateGitBuild = { -> @@ -27,13 +26,12 @@ def generateGitBuild = { -> } android { - compileSdkVersion 23 - buildToolsVersion "27.0.3" + compileSdkVersion 27 defaultConfig { applicationId "info.nightscout.androidaps" - minSdkVersion 20 - targetSdkVersion 23 + minSdkVersion 21 + targetSdkVersion 25 versionCode 1 versionName "1.0.2" buildConfigField "String", "BUILDVERSION", generateGitBuild()