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'
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}"

View file

@ -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;

View file

@ -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);

View file

@ -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());

View file

@ -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())

View file

@ -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<Notification> store = new ArrayList<Notification>();
public long snoozedUntil = 0L;
public NotificationStore() {
createNotificationChannel();
}
public class NotificationComparator implements Comparator<Notification> {
@ -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);
}
}
}

View file

@ -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);

View file

@ -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")));

View file

@ -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;

View file

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

View file

@ -1,7 +1,6 @@
apply plugin: 'com.android.application'
ext {
supportLibraryVersion = "23.0.1"
wearableVersion = "2.0.1"
}
@ -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()