Skip to content

Commit

Permalink
Merge pull request #2 from nightscout/dev
Browse files Browse the repository at this point in the history
head:dev to dev
  • Loading branch information
rICTx-T1D authored Nov 12, 2020
2 parents 3c5e8de + d165e02 commit f87193c
Show file tree
Hide file tree
Showing 335 changed files with 8,788 additions and 3,295 deletions.
39 changes: 20 additions & 19 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ ext {
powermockVersion = "1.7.3"
dexmakerVersion = "1.2"
retrofit2Version = '2.9.0'
okhttp3Version = '4.7.2'
okhttp3Version = '4.9.0'
}


Expand Down Expand Up @@ -128,7 +128,7 @@ android {
targetSdkVersion 28
multiDexEnabled true
versionCode 1500
version "2.7.0-dev"
version "2.7.1-dev"
buildConfigField "String", "VERSION", '"' + version + '"'
buildConfigField "String", "BUILDVERSION", '"' + generateGitBuild() + '-' + generateDate() + '"'
buildConfigField "String", "REMOTE", '"' + generateGitRemote() + '"'
Expand Down Expand Up @@ -251,26 +251,27 @@ dependencies {

implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation 'com.google.android.gms:play-services-wearable:17.0.0'
implementation "com.google.android.gms:play-services-location:17.0.0"
implementation 'com.google.firebase:firebase-core:17.4.3'
implementation 'com.google.firebase:firebase-auth:19.3.1'
implementation 'com.google.firebase:firebase-database:19.3.1'
implementation 'com.google.android.gms:play-services-location:17.1.0'
implementation platform('com.google.firebase:firebase-bom:25.12.0')
implementation "com.google.firebase:firebase-analytics-ktx"
implementation 'com.google.firebase:firebase-auth-ktx'
implementation 'com.google.firebase:firebase-database-ktx'

implementation 'androidx.appcompat:appcompat:1.1.0'
implementation "androidx.appcompat:appcompat:$appcompat_verison"
implementation 'androidx.legacy:legacy-support-v13:1.0.0'
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
implementation 'androidx.cardview:cardview:1.0.0'
implementation 'androidx.biometric:biometric:1.0.1'
implementation 'androidx.recyclerview:recyclerview:1.1.0'
implementation 'androidx.gridlayout:gridlayout:1.0.0'
implementation 'androidx.percentlayout:percentlayout:1.0.0'
implementation "androidx.preference:preference-ktx:1.1.1"
implementation "androidx.preference:preference-ktx:$preferencektx_version"
implementation "androidx.activity:activity-ktx:${activityVersion}"
implementation "androidx.fragment:fragment:${fragmentVersion}"
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
implementation "androidx.fragment:fragment-ktx:${fragmentktx_version}"
implementation "androidx.constraintlayout:constraintlayout:$constraintlayout_version"
implementation "androidx.navigation:navigation-fragment-ktx:$nav_version"
implementation "androidx.navigation:navigation-ui-ktx:$nav_version"
implementation 'com.google.android.material:material:1.1.0'
implementation "com.google.android.material:material:$material_version"

implementation "io.reactivex.rxjava2:rxandroid:${rxandroid_version}"

Expand All @@ -279,7 +280,7 @@ dependencies {
implementation("com.github.tony19:logback-android-classic:1.1.1-6") {
exclude group: "com.google.android", module: "android"
}
implementation 'org.apache.commons:commons-lang3:3.10'
implementation "org.apache.commons:commons-lang3:$commonslang3_version"
implementation 'org.slf4j:slf4j-api:1.7.30'
// Graphview cannot be upgraded
implementation "com.jjoe64:graphview:4.0.1"
Expand All @@ -293,21 +294,21 @@ dependencies {
exclude group: "org.json", module: "json"
}
implementation "com.google.code.gson:gson:2.8.6"
implementation('com.google.guava:guava:29.0-jre') {
implementation('com.google.guava:guava:30.0-jre') {
exclude group: "com.google.code.findbugs", module: "jsr305"
}
implementation 'com.google.code.findbugs:jsr305:3.0.2'

implementation 'net.danlew:android.joda:2.10.6'

implementation 'org.mozilla:rhino:1.7.12'
implementation 'org.mozilla:rhino:1.7.13'

implementation 'com.github.DavidProdinger:weekdays-selector:1.1.0'

implementation 'com.github.kenglxn.QRGen:android:2.6.0'
implementation 'com.eatthepath:java-otp:0.2.0'

testImplementation "junit:junit:4.13"
testImplementation "junit:junit:$junit_version"
testImplementation 'org.json:json:20200518'
testImplementation "org.mockito:mockito-core:2.8.47"
testImplementation "org.powermock:powermock-api-mockito2:${powermockVersion}"
Expand Down Expand Up @@ -357,11 +358,11 @@ dependencies {
androidTestImplementation 'androidx.test.uiautomator:uiautomator:2.2.0'

//WorkManager
implementation 'androidx.work:work-runtime:2.3.4'
implementation 'androidx.work:work-runtime-ktx:2.3.4'
implementation 'androidx.work:work-rxjava2:2.3.4'
implementation "androidx.work:work-runtime:$work_version"
implementation "androidx.work:work-runtime-ktx:$work_version"
implementation "androidx.work:work-rxjava2:$work_version"

implementation 'com.google.androidbrowserhelper:androidbrowserhelper:1.1.0'
implementation 'com.google.androidbrowserhelper:androidbrowserhelper:2.0.0'

implementation 'com.google.guava:listenablefuture:9999.0-empty-to-avoid-conflict-with-guava'
}
Expand Down
4 changes: 2 additions & 2 deletions app/src/main/assets/OpenAPSSMB/determine-basal.js
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ function enable_smb(
return false;
}

var determine_basal = function determine_basal(glucose_status, currenttemp, iob_data, profile, autosens_data, meal_data, tempBasalFunctions, microBolusAllowed, reservoir_data, currentTime) {
var determine_basal = function determine_basal(glucose_status, currenttemp, iob_data, profile, autosens_data, meal_data, tempBasalFunctions, microBolusAllowed, reservoir_data, currentTime, isSaveCgmSource) {
var rT = {}; //short for requestedTemp

var deliverAt = new Date();
Expand Down Expand Up @@ -143,7 +143,7 @@ var determine_basal = function determine_basal(glucose_status, currenttemp, iob_
rT.reason = "If current system time "+systemTime+" is correct, then BG data is too old. The last BG data was read "+minAgo+"m ago at "+bgTime;
// if BG is too old/noisy, or is changing less than 1 mg/dL/5m for 45m, cancel any high temps and shorten any long zero temps
//cherry pick from oref upstream dev cb8e94990301277fb1016c778b4e9efa55a6edbc
} else if ( bg > 60 && glucose_status.delta == 0 && glucose_status.short_avgdelta > -1 && glucose_status.short_avgdelta < 1 && glucose_status.long_avgdelta > -1 && glucose_status.long_avgdelta < 1 ) {
} else if ( bg > 60 && glucose_status.delta == 0 && glucose_status.short_avgdelta > -1 && glucose_status.short_avgdelta < 1 && glucose_status.long_avgdelta > -1 && glucose_status.long_avgdelta < 1 && !isSaveCgmSource) {
if ( glucose_status.last_cal && glucose_status.last_cal < 3 ) {
rT.reason = "CGM was just calibrated";
} else {
Expand Down
9 changes: 9 additions & 0 deletions app/src/main/java/info/nightscout/androidaps/MainActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@ import info.nightscout.androidaps.plugins.bus.RxBusWrapper
import info.nightscout.androidaps.plugins.configBuilder.ConstraintChecker
import info.nightscout.androidaps.plugins.constraints.signatureVerifier.SignatureVerifierPlugin
import info.nightscout.androidaps.plugins.constraints.versionChecker.VersionCheckerUtils
import info.nightscout.androidaps.plugins.general.maintenance.ImportExportPrefs
import info.nightscout.androidaps.plugins.general.maintenance.PrefsFileContract
import info.nightscout.androidaps.plugins.general.nsclient.data.NSSettingsStatus
import info.nightscout.androidaps.plugins.general.smsCommunicator.SmsCommunicatorPlugin
import info.nightscout.androidaps.setupwizard.SetupWizardActivity
Expand Down Expand Up @@ -87,10 +89,17 @@ class MainActivity : NoSplashAppCompatActivity() {
@Inject lateinit var constraintChecker: ConstraintChecker
@Inject lateinit var signatureVerifierPlugin: SignatureVerifierPlugin
@Inject lateinit var config: Config
@Inject lateinit var importExportPrefs: ImportExportPrefs

private lateinit var actionBarDrawerToggle: ActionBarDrawerToggle
private var pluginPreferencesMenuItem: MenuItem? = null

val callForPrefFile = registerForActivityResult(PrefsFileContract()) {
it?.let {
importExportPrefs.importSharedPreferences(this, it)
}
}

override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
Iconify.with(FontAwesomeModule())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,8 @@ class MyPreferenceFragment : PreferenceFragmentCompat(), OnSharedPreferenceChang
addPreferencesFromResourceIfEnabled(localInsightPlugin, rootKey, config.PUMPDRIVERS)
addPreferencesFromResourceIfEnabled(comboPlugin, rootKey, config.PUMPDRIVERS)
addPreferencesFromResourceIfEnabled(medtronicPumpPlugin, rootKey, config.PUMPDRIVERS)
addPreferencesFromResourceIfEnabled(virtualPumpPlugin, rootKey, !config.NSCLIENT)
addPreferencesFromResource(R.xml.pref_pump, rootKey, config.PUMPDRIVERS)
addPreferencesFromResourceIfEnabled(virtualPumpPlugin, rootKey)
addPreferencesFromResourceIfEnabled(insulinOrefFreePeakPlugin, rootKey)
addPreferencesFromResourceIfEnabled(nsClientPlugin, rootKey)
addPreferencesFromResourceIfEnabled(tidepoolPlugin, rootKey)
Expand Down Expand Up @@ -251,6 +252,10 @@ class MyPreferenceFragment : PreferenceFragmentCompat(), OnSharedPreferenceChang
}
}

private fun addPreferencesFromResource(@XmlRes preferencesResId: Int, key: String?, enabled: Boolean) {
if (enabled) addPreferencesFromResource(preferencesResId, key)
}

@SuppressLint("RestrictedApi")
private fun addPreferencesFromResource(@XmlRes preferencesResId: Int, key: String?) {
val xmlRoot = preferenceManager.inflateFromResource(context,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,25 @@ import dagger.android.support.DaggerAppCompatActivity
import info.nightscout.androidaps.R
import info.nightscout.androidaps.interfaces.PluginBase
import info.nightscout.androidaps.plugins.configBuilder.PluginStore
import info.nightscout.androidaps.plugins.general.maintenance.ImportExportPrefs
import info.nightscout.androidaps.plugins.general.maintenance.PrefsFileContract
import info.nightscout.androidaps.utils.locale.LocaleHelper
import info.nightscout.androidaps.utils.protection.ProtectionCheck
import javax.inject.Inject

class SingleFragmentActivity : DaggerAppCompatActivity() {
@Inject lateinit var pluginStore: PluginStore
@Inject lateinit var protectionCheck: ProtectionCheck
@Inject lateinit var importExportPrefs: ImportExportPrefs

private var plugin: PluginBase? = null

val callForPrefFile = registerForActivityResult(PrefsFileContract()) {
it?.let {
importExportPrefs.importSharedPreferences(this, it)
}
}

public override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_single_fragment)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import info.nightscout.androidaps.skins.SkinButtonsOn
import info.nightscout.androidaps.skins.SkinClassic
import info.nightscout.androidaps.skins.SkinInterface
import info.nightscout.androidaps.skins.SkinLargeDisplay
import info.nightscout.androidaps.skins.SkinLowRes
import javax.inject.Qualifier

@Module
Expand All @@ -32,6 +33,12 @@ open class SkinsModule {
@IntKey(20)
fun bindsSkinLargeDisplay(skinLargeDisplay: SkinLargeDisplay): SkinInterface = skinLargeDisplay

@Provides
@Skin
@IntoMap
@IntKey(30)
fun bindsSkinLowRes(skinLowRes: SkinLowRes): SkinInterface = skinLowRes

@Qualifier
annotation class Skin
}
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ class WizardDialog : DaggerDialogFragment() {

if (profileFunction.getUnits() == Constants.MGDL)
treatments_wizard_bg_input.setParams(savedInstanceState?.getDouble("treatments_wizard_bg_input")
?: 0.0, 0.0, 500.0, 1.0, DecimalFormat("0.0"), false, ok, textWatcher)
?: 0.0, 0.0, 500.0, 1.0, DecimalFormat("0"), false, ok, textWatcher)
else
treatments_wizard_bg_input.setParams(savedInstanceState?.getDouble("treatments_wizard_bg_input")
?: 0.0, 0.0, 30.0, 0.1, DecimalFormat("0.0"), false, ok, textWatcher)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -189,9 +189,9 @@ public void invoke(String initiator, boolean tempBasalFallback) {
}


if (!hardLimits.checkOnlyHardLimits(profile.getDia(), "dia", hardLimits.getMINDIA(), hardLimits.getMAXDIA()))
if (!hardLimits.checkOnlyHardLimits(profile.getDia(), "dia", hardLimits.minDia(), hardLimits.maxDia()))
return;
if (!hardLimits.checkOnlyHardLimits(profile.getIcTimeFromMidnight(Profile.secondsFromMidnight()), "carbratio", hardLimits.getMINIC(), hardLimits.getMAXIC()))
if (!hardLimits.checkOnlyHardLimits(profile.getIcTimeFromMidnight(Profile.secondsFromMidnight()), "carbratio", hardLimits.minIC(), hardLimits.maxIC()))
return;
if (!hardLimits.checkOnlyHardLimits(profile.getIsfMgdl(), "sens", hardLimits.getMINISF(), hardLimits.getMAXISF()))
return;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ public class DetermineBasalAdapterSMBJS {
private boolean mMicrobolusAllowed;
private boolean mSMBAlwaysAllowed;
private long mCurrentTime;
private boolean mIsSaveCgmSource;

private String storedCurrentTemp = null;
private String storedIobData = null;
Expand Down Expand Up @@ -108,6 +109,7 @@ public DetermineBasalResultSMB invoke() {
aapsLogger.debug(LTag.APS, "MicroBolusAllowed: " + (storedMicroBolusAllowed = "" + mMicrobolusAllowed));
aapsLogger.debug(LTag.APS, "SMBAlwaysAllowed: " + (storedSMBAlwaysAllowed = "" + mSMBAlwaysAllowed));
aapsLogger.debug(LTag.APS, "CurrentTime: " + (storedCurrentTime = "" + mCurrentTime));
aapsLogger.debug(LTag.APS, "isSaveCgmSource: " + mIsSaveCgmSource);


DetermineBasalResultSMB determineBasalResultSMB = null;
Expand Down Expand Up @@ -237,7 +239,8 @@ public void setData(Profile profile,
boolean tempTargetSet,
boolean microBolusAllowed,
boolean uamAllowed,
boolean advancedFiltering
boolean advancedFiltering,
boolean isSaveCgmSource
) throws JSONException {

String units = profile.getUnits();
Expand Down Expand Up @@ -354,6 +357,7 @@ public void setData(Profile profile,

mCurrentTime = now;

mIsSaveCgmSource = isSaveCgmSource;
}

private Object makeParam(JSONObject jsonObject, Context rhino, Scriptable scope) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -220,9 +220,9 @@ public void invoke(String initiator, boolean tempBasalFallback) {
}


if (!hardLimits.checkOnlyHardLimits(profile.getDia(), "dia", hardLimits.getMINDIA(), hardLimits.getMAXDIA()))
if (!hardLimits.checkOnlyHardLimits(profile.getDia(), "dia", hardLimits.minDia(), hardLimits.maxDia()))
return;
if (!hardLimits.checkOnlyHardLimits(profile.getIcTimeFromMidnight(Profile.secondsFromMidnight()), "carbratio", hardLimits.getMINIC(), hardLimits.getMAXIC()))
if (!hardLimits.checkOnlyHardLimits(profile.getIcTimeFromMidnight(Profile.secondsFromMidnight()), "carbratio", hardLimits.minIC(), hardLimits.maxIC()))
return;
if (!hardLimits.checkOnlyHardLimits(profile.getIsfMgdl(), "sens", hardLimits.getMINISF(), hardLimits.getMAXISF()))
return;
Expand Down Expand Up @@ -270,7 +270,8 @@ public void invoke(String initiator, boolean tempBasalFallback) {
isTempTarget,
smbAllowed.value(),
uam.value(),
advancedFiltering.value()
advancedFiltering.value(),
activePlugin.getActiveBgSource().getClass().getSimpleName().equals("DexcomPlugin")
);
} catch (JSONException e) {
fabricPrivacy.logException(e);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package info.nightscout.androidaps.plugins.constraints.objectives

import android.app.Activity
import androidx.fragment.app.FragmentActivity
import com.google.common.base.Charsets
import com.google.common.hash.Hashing
import dagger.android.HasAndroidInjector
Expand Down Expand Up @@ -116,7 +116,7 @@ class ObjectivesPlugin @Inject constructor(
sp.putBoolean(R.string.key_objectiveusescale, false)
}

fun completeObjectives(activity: Activity, request: String) {
fun completeObjectives(activity: FragmentActivity, request: String) {
val requestCode = sp.getString(R.string.key_objectives_request_code, "")
var url = sp.getString(R.string.key_nsclientinternal_url, "").toLowerCase(Locale.getDefault())
if (!url.endsWith("/")) url = "$url/"
Expand Down Expand Up @@ -145,7 +145,7 @@ class ObjectivesPlugin @Inject constructor(
}
}

fun allPriorAccomplished(position: Int) : Boolean {
fun allPriorAccomplished(position: Int): Boolean {
var accomplished = true
for (i in 0 until position) {
accomplished = accomplished && objectives[i].isAccomplished
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import android.widget.TextView;

import androidx.annotation.StringRes;
import androidx.fragment.app.FragmentActivity;

import java.util.ArrayList;
import java.util.List;
Expand Down Expand Up @@ -110,7 +111,7 @@ public boolean specialActionEnabled() {
return true;
}

public void specialAction(Activity activity, String input) {
public void specialAction(FragmentActivity activity, String input) {
}

public abstract class Task {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public boolean isCompleted() {
tasks.add(new Task(R.string.virtualpump_uploadstatus_title) {
@Override
public boolean isCompleted() {
return sp.getBoolean("virtualpump_uploadstatus", false);
return sp.getBoolean(R.string.key_virtualpump_uploadstatus, false);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package info.nightscout.androidaps.plugins.constraints.objectives.objectives;

import android.app.Activity;
import androidx.fragment.app.FragmentActivity;

import java.util.List;

Expand Down Expand Up @@ -54,7 +54,7 @@ public boolean specialActionEnabled() {
}

@Override
public void specialAction(Activity activity, String input) {
public void specialAction(FragmentActivity activity, String input) {
objectivesPlugin.completeObjectives(activity, input);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -37,17 +37,17 @@
@Singleton
public class SafetyPlugin extends PluginBase implements ConstraintsInterface {

private SP sp;
private RxBusWrapper rxBus;
private ConstraintChecker constraintChecker;
private OpenAPSAMAPlugin openAPSAMAPlugin;
private OpenAPSSMBPlugin openAPSSMBPlugin;
private SensitivityOref1Plugin sensitivityOref1Plugin;
private ActivePluginProvider activePlugin;
private HardLimits hardLimits;
private BuildHelper buildHelper;
private TreatmentsPlugin treatmentsPlugin;
private Config config;
private final SP sp;
private final RxBusWrapper rxBus;
private final ConstraintChecker constraintChecker;
private final OpenAPSAMAPlugin openAPSAMAPlugin;
private final OpenAPSSMBPlugin openAPSSMBPlugin;
private final SensitivityOref1Plugin sensitivityOref1Plugin;
private final ActivePluginProvider activePlugin;
private final HardLimits hardLimits;
private final BuildHelper buildHelper;
private final TreatmentsPlugin treatmentsPlugin;
private final Config config;

@Inject
public SafetyPlugin(
Expand Down
Loading

0 comments on commit f87193c

Please sign in to comment.