Merge branch 'dev' into PoweRGbg/patch-15

This commit is contained in:
Milos Kozak 2018-04-05 22:05:47 +02:00
commit b520a077f8
11 changed files with 88 additions and 25 deletions

View file

@ -15,8 +15,7 @@ apply plugin: "jacoco-android"
apply plugin: 'com.jakewharton.butterknife' apply plugin: 'com.jakewharton.butterknife'
ext { ext {
supportLibraryVersion = "27.0.2" supportLibraryVersion = "27.1.0"
sdkBuildVersion = "27.0.3"
ormLiteVersion = "4.46" ormLiteVersion = "4.46"
powermockVersion = "1.7.3" powermockVersion = "1.7.3"
dexmakerVersion = "1.2" dexmakerVersion = "1.2"
@ -57,12 +56,11 @@ tasks.matching {it instanceof Test}.all {
android { android {
compileSdkVersion 27 compileSdkVersion 27
buildToolsVersion "${sdkBuildVersion}"
defaultConfig { defaultConfig {
applicationId "info.nightscout.androidaps" applicationId "info.nightscout.androidaps"
minSdkVersion 21 minSdkVersion 21
targetSdkVersion 27 targetSdkVersion 25
multiDexEnabled true multiDexEnabled true
versionCode 1500 versionCode 1500
version "1.60c-dev" version "1.60c-dev"
@ -78,7 +76,7 @@ android {
// TODO remove once wear dependency com.google.android.gms:play-services-wearable:7.3.0 // 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 // has been upgraded (requiring significant code changes), which currently fails release
// build with a deprecation warning // build with a deprecation warning
// abortOnError false abortOnError false
// (disabled entirely to avoid reports on the error, which would still be displayed // (disabled entirely to avoid reports on the error, which would still be displayed
// and it's easy to overlook that it's ignored) // and it's easy to overlook that it's ignored)
checkReleaseBuilds false checkReleaseBuilds false
@ -183,7 +181,7 @@ dependencies {
implementation("com.crashlytics.sdk.android:answers:1.3.12@aar") { implementation("com.crashlytics.sdk.android:answers:1.3.12@aar") {
transitive = true; 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:appcompat-v7:${supportLibraryVersion}"
implementation "com.android.support:support-v4:${supportLibraryVersion}" implementation "com.android.support:support-v4:${supportLibraryVersion}"

View file

@ -32,7 +32,6 @@ public class Config {
public static final boolean logPumpComm = true; public static final boolean logPumpComm = true;
public static final boolean logPrefsChange = true; public static final boolean logPrefsChange = true;
public static final boolean logConfigBuilder = true; public static final boolean logConfigBuilder = true;
public static final boolean logConstraintsChanges = true;
public static final boolean logNSUpload = true; public static final boolean logNSUpload = true;
public static final boolean logPumpActions = true; public static final boolean logPumpActions = true;
public static final boolean logCongigBuilderActions = true; public static final boolean logCongigBuilderActions = true;

View file

@ -403,7 +403,8 @@ public class MainActivity extends AppCompatActivity implements View.OnClickListe
else else
builder.setIcon(R.mipmap.blueowl); builder.setIcon(R.mipmap.blueowl);
String message = "Build: " + BuildConfig.BUILDVERSION + "\n"; 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) if (MainApp.engineeringMode)
message += "\n" + MainApp.gs(R.string.engineering_mode_enabled); message += "\n" + MainApp.gs(R.string.engineering_mode_enabled);
message += getString(R.string.about_link_urls); message += getString(R.string.about_link_urls);

View file

@ -155,7 +155,8 @@ public class IobCobThread extends Thread {
AutosensData hourAgoData = iobCobCalculatorPlugin.getAutosensData(hourago); AutosensData hourAgoData = iobCobCalculatorPlugin.getAutosensData(hourago);
if (hourAgoData != null) { if (hourAgoData != null) {
int initialIndex = autosensDataTable.indexOfKey(hourAgoData.time); 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; int past = 1;
try { try {
for (; past < 12; past++) { for (; past < 12; past++) {
@ -242,7 +243,8 @@ public class IobCobThread extends Thread {
previous = autosensData; previous = autosensData;
autosensDataTable.put(bgTime, 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; autosensData.autosensRatio = iobCobCalculatorPlugin.detectSensitivity(oldestTimeWithData, bgTime).ratio;
if (Config.logAutosensData) if (Config.logAutosensData)
log.debug(autosensData.toString()); log.debug(autosensData.toString());

View file

@ -1,11 +1,14 @@
package info.nightscout.androidaps.plugins.Loop; package info.nightscout.androidaps.plugins.Loop;
import android.annotation.SuppressLint;
import android.app.Notification; import android.app.Notification;
import android.app.NotificationChannel;
import android.app.NotificationManager; import android.app.NotificationManager;
import android.app.PendingIntent; import android.app.PendingIntent;
import android.app.TaskStackBuilder; import android.app.TaskStackBuilder;
import android.content.Context; import android.content.Context;
import android.content.Intent; import android.content.Intent;
import android.os.Build;
import android.support.v4.app.NotificationCompat; import android.support.v4.app.NotificationCompat;
import com.crashlytics.android.answers.CustomEvent; import com.crashlytics.android.answers.CustomEvent;
@ -48,6 +51,9 @@ import info.nightscout.utils.SP;
public class LoopPlugin extends PluginBase { public class LoopPlugin extends PluginBase {
private static Logger log = LoggerFactory.getLogger(LoopPlugin.class); private static Logger log = LoggerFactory.getLogger(LoopPlugin.class);
public static final String CHANNEL_ID = "AndroidAPS-Openloop";
protected static LoopPlugin loopPlugin; protected static LoopPlugin loopPlugin;
public static LoopPlugin getPlugin() { public static LoopPlugin getPlugin() {
@ -90,9 +96,22 @@ public class LoopPlugin extends PluginBase {
@Override @Override
protected void onStart() { protected void onStart() {
MainApp.bus().register(this); MainApp.bus().register(this);
createNotificationChannel();
super.onStart(); 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 @Override
protected void onStop() { protected void onStop() {
super.onStop(); super.onStop();
@ -322,7 +341,7 @@ public class LoopPlugin extends PluginBase {
} else { } else {
if (result.isChangeRequested() && allowNotification) { if (result.isChangeRequested() && allowNotification) {
NotificationCompat.Builder builder = NotificationCompat.Builder builder =
new NotificationCompat.Builder(MainApp.instance().getApplicationContext()); new NotificationCompat.Builder(MainApp.instance().getApplicationContext(), CHANNEL_ID);
builder.setSmallIcon(R.drawable.notif_icon) builder.setSmallIcon(R.drawable.notif_icon)
.setContentTitle(MainApp.sResources.getString(R.string.openloop_newsuggestion)) .setContentTitle(MainApp.sResources.getString(R.string.openloop_newsuggestion))
.setContentText(resultAfterConstraints.toString()) .setContentText(resultAfterConstraints.toString())

View file

@ -1,5 +1,7 @@
package info.nightscout.androidaps.plugins.Overview.notifications; package info.nightscout.androidaps.plugins.Overview.notifications;
import android.annotation.SuppressLint;
import android.app.NotificationChannel;
import android.app.NotificationManager; import android.app.NotificationManager;
import android.content.Context; import android.content.Context;
import android.content.Intent; import android.content.Intent;
@ -8,6 +10,7 @@ import android.graphics.BitmapFactory;
import android.media.AudioAttributes; import android.media.AudioAttributes;
import android.media.RingtoneManager; import android.media.RingtoneManager;
import android.net.Uri; import android.net.Uri;
import android.os.Build;
import android.support.v4.app.NotificationCompat; import android.support.v4.app.NotificationCompat;
import org.slf4j.Logger; import org.slf4j.Logger;
@ -28,11 +31,15 @@ import info.nightscout.utils.SP;
*/ */
public class NotificationStore { public class NotificationStore {
public static final String CHANNEL_ID = "AndroidAPS-Overview";
private static Logger log = LoggerFactory.getLogger(NotificationStore.class); private static Logger log = LoggerFactory.getLogger(NotificationStore.class);
public List<Notification> store = new ArrayList<Notification>(); public List<Notification> store = new ArrayList<Notification>();
public long snoozedUntil = 0L; public long snoozedUntil = 0L;
public NotificationStore() { public NotificationStore() {
createNotificationChannel();
} }
public class NotificationComparator implements Comparator<Notification> { public class NotificationComparator implements Comparator<Notification> {
@ -110,7 +117,7 @@ public class NotificationStore {
Bitmap largeIcon = BitmapFactory.decodeResource(context.getResources(), R.mipmap.blueowl); Bitmap largeIcon = BitmapFactory.decodeResource(context.getResources(), R.mipmap.blueowl);
Uri sound = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_ALARM); Uri sound = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_ALARM);
NotificationCompat.Builder notificationBuilder = NotificationCompat.Builder notificationBuilder =
new NotificationCompat.Builder(context) new NotificationCompat.Builder(context, CHANNEL_ID)
.setSmallIcon(R.drawable.ic_notification) .setSmallIcon(R.drawable.ic_notification)
.setLargeIcon(largeIcon) .setLargeIcon(largeIcon)
.setContentText(n.text) .setContentText(n.text)
@ -127,4 +134,17 @@ public class NotificationStore {
} }
mgr.notify(n.id, notificationBuilder.build()); 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);
}
}
} }

View file

@ -1,11 +1,14 @@
package info.nightscout.androidaps.plugins.Persistentnotification; package info.nightscout.androidaps.plugins.Persistentnotification;
import android.annotation.SuppressLint;
import android.app.NotificationChannel;
import android.app.NotificationManager; import android.app.NotificationManager;
import android.app.PendingIntent; import android.app.PendingIntent;
import android.content.Context; import android.content.Context;
import android.content.Intent; import android.content.Intent;
import android.graphics.Bitmap; import android.graphics.Bitmap;
import android.graphics.BitmapFactory; import android.graphics.BitmapFactory;
import android.os.Build;
import android.support.v4.app.NotificationCompat; import android.support.v4.app.NotificationCompat;
import android.support.v4.app.TaskStackBuilder; import android.support.v4.app.TaskStackBuilder;
@ -41,6 +44,8 @@ import info.nightscout.utils.DecimalFormatter;
public class PersistentNotificationPlugin extends PluginBase { public class PersistentNotificationPlugin extends PluginBase {
public static final String CHANNEL_ID = "AndroidAPS-Ongoing";
private static final int ONGOING_NOTIFICATION_ID = 4711; private static final int ONGOING_NOTIFICATION_ID = 4711;
private final Context ctx; private final Context ctx;
@ -57,10 +62,23 @@ public class PersistentNotificationPlugin extends PluginBase {
@Override @Override
protected void onStart() { protected void onStart() {
MainApp.bus().register(this); MainApp.bus().register(this);
createNotificationChannel();
updateNotification(); updateNotification();
super.onStart(); 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 @Override
protected void onStop() { protected void onStop() {
MainApp.bus().unregister(this); MainApp.bus().unregister(this);
@ -118,7 +136,7 @@ public class PersistentNotificationPlugin extends PluginBase {
line3 += " - " + MainApp.getConfigBuilder().getProfileName(); line3 += " - " + MainApp.getConfigBuilder().getProfileName();
NotificationCompat.Builder builder = new NotificationCompat.Builder(ctx); NotificationCompat.Builder builder = new NotificationCompat.Builder(ctx, CHANNEL_ID);
builder.setOngoing(true); builder.setOngoing(true);
builder.setCategory(NotificationCompat.CATEGORY_STATUS); builder.setCategory(NotificationCompat.CATEGORY_STATUS);
builder.setSmallIcon(R.drawable.ic_notification); builder.setSmallIcon(R.drawable.ic_notification);

View file

@ -30,7 +30,7 @@ import info.nightscout.utils.SafeParse;
* Created by mike on 24.06.2017. * 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); private static Logger log = LoggerFactory.getLogger(SensitivityAAPSPlugin.class);
static SensitivityAAPSPlugin plugin = null; static SensitivityAAPSPlugin plugin = null;
@ -118,7 +118,9 @@ public class SensitivityAAPSPlugin extends PluginBase implements SensitivityInte
String ratioLimit = ""; String ratioLimit = "";
String sensResult = ""; String sensResult = "";
log.debug("Records: " + index + " " + pastSensitivity); if (Config.logAutosensData)
log.debug("Records: " + index + " " + pastSensitivity);
Arrays.sort(deviations); Arrays.sort(deviations);
double percentile = IobCobCalculatorPlugin.percentile(deviations, 0.50); double percentile = IobCobCalculatorPlugin.percentile(deviations, 0.50);
@ -133,7 +135,8 @@ public class SensitivityAAPSPlugin extends PluginBase implements SensitivityInte
sensResult = "Sensitivity normal"; sensResult = "Sensitivity normal";
} }
log.debug(sensResult); if (Config.logAutosensData)
log.debug(sensResult);
double rawRatio = ratio; double rawRatio = ratio;
ratio = Math.max(ratio, SafeParse.stringToDouble(SP.getString("openapsama_autosens_min", "0.7"))); ratio = Math.max(ratio, SafeParse.stringToDouble(SP.getString("openapsama_autosens_min", "0.7")));

View file

@ -118,7 +118,9 @@ public class SensitivityOref0Plugin extends PluginBase implements SensitivityInt
String ratioLimit = ""; String ratioLimit = "";
String sensResult = ""; String sensResult = "";
log.debug("Records: " + index + " " + pastSensitivity); if (Config.logAutosensData)
log.debug("Records: " + index + " " + pastSensitivity);
Arrays.sort(deviations); Arrays.sort(deviations);
for (double i = 0.9; i > 0.1; i = i - 0.02) { for (double i = 0.9; i > 0.1; i = i - 0.02) {
@ -140,7 +142,10 @@ public class SensitivityOref0Plugin extends PluginBase implements SensitivityInt
} else { } else {
sensResult = "Sensitivity normal"; sensResult = "Sensitivity normal";
} }
log.debug(sensResult);
if (Config.logAutosensData)
log.debug(sensResult);
ratio = 1 + (basalOff / profile.getMaxDailyBasal()); ratio = 1 + (basalOff / profile.getMaxDailyBasal());
double rawRatio = ratio; double rawRatio = ratio;

View file

@ -18,8 +18,8 @@ buildscript {
allprojects { allprojects {
repositories { repositories {
jcenter()
google() google()
jcenter()
maven { maven {
url "https://maven.google.com" url "https://maven.google.com"

View file

@ -1,7 +1,6 @@
apply plugin: 'com.android.application' apply plugin: 'com.android.application'
ext { ext {
supportLibraryVersion = "23.0.1"
wearableVersion = "2.0.1" wearableVersion = "2.0.1"
} }
@ -27,13 +26,12 @@ def generateGitBuild = { ->
} }
android { android {
compileSdkVersion 23 compileSdkVersion 27
buildToolsVersion "27.0.3"
defaultConfig { defaultConfig {
applicationId "info.nightscout.androidaps" applicationId "info.nightscout.androidaps"
minSdkVersion 20 minSdkVersion 21
targetSdkVersion 23 targetSdkVersion 25
versionCode 1 versionCode 1
versionName "1.0.2" versionName "1.0.2"
buildConfigField "String", "BUILDVERSION", generateGitBuild() buildConfigField "String", "BUILDVERSION", generateGitBuild()