Merge branch 'dev' of github.com:MilosKozak/AndroidAPS into carbs-required

This commit is contained in:
Tim Gunn 2020-06-01 02:14:17 +12:00
commit 8fefa0b5aa
No known key found for this signature in database
GPG key ID: C9BC1E9D0D0AED8C
20 changed files with 89 additions and 110 deletions

View file

@ -1,13 +1,10 @@
buildscript {
repositories {
maven { url 'https://maven.fabric.io/public' }
jcenter()
}
dependencies {
classpath 'io.fabric.tools:gradle:1.+'
classpath 'com.dicedmelon.gradle:jacoco-android:0.1.4'
classpath 'de.undercouch:gradle-download-task:3.4.3'
}
}
apply plugin: 'com.android.application'
@ -15,10 +12,8 @@ apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
apply plugin: 'kotlin-kapt'
apply plugin: 'com.google.gms.google-services'
apply plugin: 'io.fabric'
apply plugin: 'jacoco-android'
apply plugin: 'de.undercouch.download'
apply plugin: 'com.google.firebase.crashlytics'
jacoco {
toolVersion = "0.8.3"
@ -27,13 +22,12 @@ jacoco {
ext {
powermockVersion = "1.7.3"
dexmakerVersion = "1.2"
retrofit2Version = '2.8.1'
okhttp3Version = '4.6.0'
retrofit2Version = '2.9.0'
okhttp3Version = '4.7.2'
}
repositories {
maven { url 'https://maven.fabric.io/public' }
jcenter { url "https://jcenter.bintray.com/" }
mavenCentral()
}
@ -249,12 +243,9 @@ 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.0'
implementation 'com.google.firebase:firebase-core:17.4.2'
implementation 'com.google.firebase:firebase-auth:19.3.1'
implementation 'com.google.firebase:firebase-database:19.3.0'
implementation('com.crashlytics.sdk.android:crashlytics:2.10.1@aar') {
transitive = true;
}
implementation 'androidx.appcompat:appcompat:1.1.0'
implementation 'androidx.legacy:legacy-support-v13:1.0.0'
@ -265,12 +256,11 @@ dependencies {
implementation 'androidx.gridlayout:gridlayout:1.0.0'
implementation 'androidx.percentlayout:percentlayout:1.0.0'
implementation "androidx.preference:preference-ktx:1.1.1"
implementation "androidx.activity:activity:${activityVersion}"
implementation "androidx.activity:activity-ktx:${activityVersion}"
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
implementation 'com.google.android.material:material:1.1.0'
implementation "io.reactivex.rxjava2:rxandroid:2.1.1"
implementation "io.reactivex.rxjava2:rxandroid:${rxandroid_version}"
implementation "com.j256.ormlite:ormlite-core:${ormLiteVersion}"
implementation "com.j256.ormlite:ormlite-android:${ormLiteVersion}"
@ -283,6 +273,7 @@ dependencies {
implementation "com.jjoe64:graphview:4.0.1"
implementation "com.joanzapata.iconify:android-iconify-fontawesome:2.2.2"
implementation 'com.madgag.spongycastle:core:1.58.0.0'
// Omnipod wizard
implementation(name: "com.atech-software.android.library.wizardpager-1.1.1", ext: "aar")
implementation("com.google.android:flexbox:0.3.0") {
@ -308,7 +299,7 @@ dependencies {
implementation 'com.eatthepath:java-otp:0.2.0'
testImplementation "junit:junit:4.13"
testImplementation "org.json:json:20190722"
testImplementation 'org.json:json:20200518'
testImplementation "org.mockito:mockito-core:2.8.47"
testImplementation "org.powermock:powermock-api-mockito2:${powermockVersion}"
testImplementation "org.powermock:powermock-module-junit4-rule-agent:${powermockVersion}"

View file

@ -174,6 +174,7 @@ class MainActivity : NoSplashAppCompatActivity() {
private fun processPreferenceChange(ev: EventPreferenceChange) {
if (ev.isChanged(resourceHelper, R.string.key_keep_screen_on)) setWakeLock()
if (ev.isChanged(resourceHelper, R.string.key_skin)) recreate()
}
private fun setupViews() {

View file

@ -69,7 +69,7 @@ public class MainApp extends DaggerApplication {
sResources = getResources();
LocaleHelper.INSTANCE.update(this);
sDatabaseHelper = OpenHelperManager.getHelper(sInstance, DatabaseHelper.class);
/*
Thread.setDefaultUncaughtExceptionHandler((thread, ex) -> {
if (ex instanceof InternalError) {
// usually the app trying to spawn a thread while being killed
@ -77,7 +77,7 @@ public class MainApp extends DaggerApplication {
}
aapsLogger.error("Uncaught exception crashing app", ex);
});
*/
registerActivityLifecycleCallbacks(activityMonitor);
JodaTimeAndroid.init(this);

View file

@ -8,6 +8,7 @@ import dagger.multibindings.IntoMap
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 javax.inject.Qualifier
@Module
@ -25,6 +26,12 @@ open class SkinsModule {
@IntKey(10)
fun bindsSkinButtonsOn(skinButtonsOn: SkinButtonsOn): SkinInterface = skinButtonsOn
@Provides
@Skin
@IntoMap
@IntKey(20)
fun bindsSkinLargeDisplay(skinLargeDisplay: SkinLargeDisplay): SkinInterface = skinLargeDisplay
@Qualifier
annotation class Skin
}

View file

@ -7,7 +7,6 @@ import android.content.Context
import android.content.Intent
import android.content.pm.PackageManager
import android.provider.Settings
import androidx.activity.invoke
import androidx.annotation.StringRes
import androidx.core.content.ContextCompat
import androidx.fragment.app.Fragment
@ -221,7 +220,7 @@ class ImportExportPrefs @Inject constructor(
importSharedPreferences(fragmentAct, it)
}
}
callForPrefFile.invoke()
callForPrefFile.launch(null)
}
}
@ -231,7 +230,7 @@ class ImportExportPrefs @Inject constructor(
importSharedPreferences(activity, it)
}
}
callForPrefFile.invoke()
callForPrefFile.launch(null)
}
private fun importSharedPreferences(activity: Activity, importFile: PrefsFile) {

View file

@ -187,6 +187,7 @@ class OverviewFragment : DaggerFragment(), View.OnClickListener, OnLongClickList
overview_bggraph?.gridLabelRenderer?.gridColor = resourceHelper.gc(R.color.graphgrid)
overview_bggraph?.gridLabelRenderer?.reloadStyles()
overview_bggraph?.gridLabelRenderer?.labelVerticalWidth = axisWidth
overview_bggraph?.layoutParams?.height = resourceHelper.dpToPx(skinProvider.activeSkin().mainGraphHeight)
carbAnimation = overview_carbs_icon.background as AnimationDrawable
carbAnimation.setEnterFadeDuration(1200)
@ -489,7 +490,7 @@ class OverviewFragment : DaggerFragment(), View.OnClickListener, OnLongClickList
overview_iobgraph.addView(label)
secondaryGraphsLabel.add(label)
val graph = GraphView(context)
graph.layoutParams = LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, resourceHelper.dpToPx(100)).also { it.setMargins(0, resourceHelper.dpToPx(35), 0, resourceHelper.dpToPx(15)) }
graph.layoutParams = LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, resourceHelper.dpToPx(skinProvider.activeSkin().secondaryGraphHeight)).also { it.setMargins(0, resourceHelper.dpToPx(35), 0, resourceHelper.dpToPx(15)) }
graph.gridLabelRenderer?.gridColor = resourceHelper.gc(R.color.graphgrid)
graph.gridLabelRenderer?.reloadStyles()
graph.gridLabelRenderer?.isHorizontalLabelsVisible = false

View file

@ -61,16 +61,16 @@ class OverviewMenus @Inject constructor(
private val config: Config
) {
enum class CharType(@StringRes val nameId: Int, @ColorRes val colorId: Int, val primary: Boolean, val secondary: Boolean) {
PRE(R.string.overview_show_predictions, R.color.prediction, primary = true, secondary = false),
BAS(R.string.overview_show_basals, R.color.basal, primary = true, secondary = false),
IOB(R.string.overview_show_iob, R.color.iob, primary = false, secondary = true),
COB(R.string.overview_show_cob, R.color.cob, primary = false, secondary = true),
DEV(R.string.overview_show_deviations, R.color.deviations, primary = false, secondary = true),
SEN(R.string.overview_show_sensitivity, R.color.ratio, primary = false, secondary = true),
ACT(R.string.overview_show_activity, R.color.activity, primary = true, secondary = true),
ABS(R.string.overview_show_absinsulin, R.color.iob, primary = false, secondary = true),
DEVSLOPE(R.string.overview_show_deviationslope, R.color.devslopepos, primary = false, secondary = true)
enum class CharType(@StringRes val nameId: Int, @ColorRes val colorId: Int, val primary: Boolean, val secondary: Boolean, @StringRes val shortnameId: Int) {
PRE(R.string.overview_show_predictions, R.color.prediction, primary = true, secondary = false, shortnameId = R.string.prediction_shortname),
BAS(R.string.overview_show_basals, R.color.basal, primary = true, secondary = false,shortnameId = R.string.basal_shortname),
IOB(R.string.overview_show_iob, R.color.iob, primary = false, secondary = true,shortnameId = R.string.iob),
COB(R.string.overview_show_cob, R.color.cob, primary = false, secondary = true,shortnameId = R.string.cob),
DEV(R.string.overview_show_deviations, R.color.deviations, primary = false, secondary = true,shortnameId = R.string.deviation_shortname),
SEN(R.string.overview_show_sensitivity, R.color.ratio, primary = false, secondary = true,shortnameId = R.string.sensitivity_shortname),
ACT(R.string.overview_show_activity, R.color.activity, primary = true, secondary = true,shortnameId = R.string.activity_shortname),
ABS(R.string.overview_show_absinsulin, R.color.iob, primary = false, secondary = true,shortnameId = R.string.abs_insulin_shortname),
DEVSLOPE(R.string.overview_show_deviationslope, R.color.devslopepos, primary = false, secondary = true,shortnameId = R.string.devslope_shortname)
}
companion object {
@ -80,7 +80,7 @@ class OverviewMenus @Inject constructor(
fun enabledTypes(graph: Int): String {
val r = StringBuilder()
for (type in CharType.values()) if (setting[graph][type.ordinal]) {
r.append(type.name)
r.append(resourceHelper.gs(type.shortnameId))
r.append(" ")
}
return r.toString()

View file

@ -8,7 +8,9 @@ import javax.inject.Singleton
@Singleton
class SkinButtonsOn @Inject constructor(private val config: Config) : SkinInterface {
override val description: Int get() = R.string.buttonson_desrciption
override val description: Int get() = R.string.buttonson_description
override val mainGraphHeight: Int get() = 200
override val secondaryGraphHeight: Int get() = 100
override fun overviewLayout(isLandscape: Boolean, isTablet: Boolean, isSmallHeight: Boolean): Int =
when {

View file

@ -8,7 +8,9 @@ import javax.inject.Singleton
@Singleton
class SkinClassic @Inject constructor(private val config: Config): SkinInterface {
override val description: Int get() = R.string.classic_desrciption
override val description: Int get() = R.string.classic_description
override val mainGraphHeight: Int get() = 200
override val secondaryGraphHeight: Int get() = 100
override fun overviewLayout(isLandscape: Boolean, isTablet: Boolean, isSmallHeight: Boolean): Int =
when {

View file

@ -6,5 +6,7 @@ import androidx.annotation.StringRes
interface SkinInterface {
@get:StringRes val description : Int
val mainGraphHeight : Int // in dp
val secondaryGraphHeight : Int // in dp
@LayoutRes fun overviewLayout(isLandscape : Boolean, isTablet : Boolean, isSmallHeight : Boolean): Int
}

View file

@ -0,0 +1,23 @@
package info.nightscout.androidaps.skins
import info.nightscout.androidaps.Config
import info.nightscout.androidaps.R
import javax.inject.Inject
import javax.inject.Singleton
@Singleton
class SkinLargeDisplay @Inject constructor(private val config: Config): SkinInterface {
override val description: Int get() = R.string.largedisplay_description
override val mainGraphHeight: Int get() = 400
override val secondaryGraphHeight: Int get() = 150
override fun overviewLayout(isLandscape: Boolean, isTablet: Boolean, isSmallHeight: Boolean): Int =
when {
config.NSCLIENT && isTablet -> R.layout.overview_fragment_nsclient_tablet
config.NSCLIENT -> R.layout.overview_fragment_nsclient
isSmallHeight || isLandscape -> R.layout.overview_fragment_landscape
else -> R.layout.overview_fragment
}
}

View file

@ -532,8 +532,14 @@
<string name="statuslights_bat_warning">Threshold warning battery level [%]</string>
<string name="key_statuslights_bat_critical" translatable="false">statuslights_bat_critical</string>
<string name="statuslights_bat_critical">Threshold critical battery level [%]</string>
<string name="prediction_shortname">PRED</string>
<string name="iob">IOB</string>
<string name="cob">COB</string>
<string name="basal_shortname">BAS</string>
<string name="deviation_shortname">DEV</string>
<string name="activity_shortname">ACT</string>
<string name="abs_insulin_shortname">ABS</string>
<string name="devslope_shortname">DEVSLOPE</string>
<string name="nav_about">About</string>
<string name="smscommunicator_missingsmspermission">Missing SMS permission</string>
<string name="smscommunicator_missingphonestatepermission">Missing phone state permission</string>
@ -1556,8 +1562,9 @@
<string name="key_statuslights_copy_ns" translatable="false">statuslights_copy_ns</string>
<string name="copyexistingvalues">Copy NS settings (if exists)?</string>
<string name="key_statuslights_overview_advanced" translatable="false">statuslights_overview_advanced</string>
<string name="classic_desrciption">Original skin</string>
<string name="buttonson_desrciption">Buttons are always displayed on bottom of screen</string>
<string name="classic_description">Original skin</string>
<string name="buttonson_description">Buttons are always displayed on bottom of screen</string>
<string name="largedisplay_description">Large display</string>
<string name="key_skin" translatable="false">skin</string>
<string name="skin">Skin</string>

View file

@ -9,20 +9,19 @@ buildscript {
rxkotlin_version = '2.4.0'
room_version = '2.2.5'
lifecycle_version = '2.2.0'
dagger_version = '2.27'
coroutinesVersion = '1.3.5'
activityVersion = '1.2.0-alpha04'
dagger_version = '2.28'
coroutinesVersion = '1.3.7'
activityVersion = '1.2.0-alpha05'
ormLiteVersion = "4.46"
}
repositories {
google()
jcenter()
maven { url 'https://maven.fabric.io/public' }
}
dependencies {
classpath 'com.android.tools.build:gradle:3.6.3'
classpath 'com.google.gms:google-services:4.3.3'
classpath 'io.fabric.tools:gradle:1.31.2'
classpath 'com.google.firebase:firebase-crashlytics-gradle:2.1.1'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files

View file

@ -58,12 +58,11 @@ dependencies {
//Logger
implementation 'org.slf4j:slf4j-api:1.7.30'
//Fabric
implementation 'com.google.firebase:firebase-core:17.4.0'
implementation('com.crashlytics.sdk.android:crashlytics:2.10.1@aar') {
transitive = true;
}
implementation 'com.google.firebase:firebase-analytics-ktx:17.4.2'
implementation 'com.google.firebase:firebase-crashlytics:17.0.0'
//RxBus
implementation "io.reactivex.rxjava2:rxandroid:2.1.1"
implementation "io.reactivex.rxjava2:rxandroid:${rxandroid_version}"
implementation 'org.apache.commons:commons-lang3:3.10'
// Graphview cannot be upgraded

View file

@ -82,7 +82,7 @@ public class Profile {
if (units != null)
this.units = units;
else {
fabricPrivacy.log("Profile failover failed too");
fabricPrivacy.logCustom("Profile failover failed too");
this.units = Constants.MGDL;
}
}

View file

@ -2,13 +2,12 @@ package info.nightscout.androidaps.utils
import android.content.Context
import android.os.Bundle
import com.crashlytics.android.Crashlytics
import com.google.firebase.analytics.FirebaseAnalytics
import com.google.firebase.crashlytics.FirebaseCrashlytics
import info.nightscout.androidaps.core.R
import info.nightscout.androidaps.logging.AAPSLogger
import info.nightscout.androidaps.logging.LTag
import info.nightscout.androidaps.utils.sharedPreferences.SP
import io.fabric.sdk.android.Fabric
import javax.inject.Inject
import javax.inject.Singleton
@ -27,21 +26,9 @@ class FabricPrivacy @Inject constructor(
var firebaseAnalytics: FirebaseAnalytics
init {
instance = this
firebaseAnalytics = FirebaseAnalytics.getInstance(context)
firebaseAnalytics.setAnalyticsCollectionEnabled(!java.lang.Boolean.getBoolean("disableFirebase") && fabricEnabled())
if (fabricEnabled()) {
Fabric.with(context, Crashlytics())
}
}
companion object {
private lateinit var instance: FabricPrivacy
@JvmStatic
@Deprecated("Use Dagger")
fun getInstance(): FabricPrivacy = instance
FirebaseCrashlytics.getInstance().setCrashlyticsCollectionEnabled(!java.lang.Boolean.getBoolean("disableFirebase") && fabricEnabled())
}
// Analytics logCustom
@ -76,39 +63,8 @@ class FabricPrivacy @Inject constructor(
// Crashlytics logException
fun logException(throwable: Throwable) {
try {
val crashlytics = Crashlytics.getInstance()
crashlytics.core.logException(throwable)
aapsLogger.debug(LTag.CORE, "Exception: ", throwable)
} catch (e: NullPointerException) {
aapsLogger.debug(LTag.CORE, "Ignoring opted out non-initialized log: $throwable")
} catch (e: IllegalStateException) {
aapsLogger.debug(LTag.CORE, "Ignoring opted out non-initialized log: $throwable")
}
}
// Crashlytics log
fun log(msg: String) {
try {
val crashlytics = Crashlytics.getInstance()
crashlytics.core.log(msg)
} catch (e: NullPointerException) {
aapsLogger.debug(LTag.CORE, "Ignoring opted out non-initialized log: $msg")
} catch (e: IllegalStateException) {
aapsLogger.debug(LTag.CORE, "Ignoring opted out non-initialized log: $msg")
}
}
// Crashlytics log
fun log(priority: Int, tag: String?, msg: String) {
try {
val crashlytics = Crashlytics.getInstance()
crashlytics.core.log(priority, tag, msg)
} catch (e: NullPointerException) {
aapsLogger.debug(LTag.CORE, "Ignoring opted out non-initialized log: $msg")
} catch (e: IllegalStateException) {
aapsLogger.debug(LTag.CORE, "Ignoring opted out non-initialized log: $msg")
}
FirebaseCrashlytics.getInstance().recordException(throwable)
aapsLogger.debug(LTag.CORE, "Exception: ", throwable)
}
fun fabricEnabled(): Boolean {

View file

@ -51,10 +51,9 @@ dependencies {
implementation 'androidx.appcompat:appcompat:1.1.0'
implementation 'androidx.core:core-ktx:1.2.0'
implementation "androidx.preference:preference-ktx:1.1.1"
implementation "androidx.activity:activity:${activityVersion}"
implementation "androidx.activity:activity-ktx:${activityVersion}"
implementation "io.reactivex.rxjava2:rxandroid:2.1.1"
implementation "io.reactivex.rxjava2:rxandroid:${rxandroid_version}"
// Graphview cannot be upgraded
implementation "com.jjoe64:graphview:4.0.1"

View file

@ -53,14 +53,8 @@ dependencies {
implementation 'androidx.appcompat:appcompat:1.1.0'
implementation 'androidx.core:core-ktx:1.2.0'
implementation "androidx.preference:preference-ktx:1.1.1"
implementation "androidx.activity:activity:${activityVersion}"
implementation "androidx.activity:activity-ktx:${activityVersion}"
implementation "io.reactivex.rxjava2:rxandroid:2.1.1"
// remove after conversion to aapslogger
implementation 'org.slf4j:slf4j-api:1.7.30'
// Graphview cannot be upgraded
implementation "com.jjoe64:graphview:4.0.1"
@ -74,7 +68,7 @@ dependencies {
kapt "com.google.dagger:dagger-compiler:$dagger_version"
//RxBus
implementation "io.reactivex.rxjava2:rxandroid:2.1.1"
implementation "io.reactivex.rxjava2:rxandroid:${rxandroid_version}"
testImplementation 'junit:junit:4.13'
androidTestImplementation 'androidx.test.ext:junit:1.1.1'

View file

@ -52,11 +52,8 @@ dependencies {
implementation 'androidx.appcompat:appcompat:1.1.0'
implementation 'androidx.core:core-ktx:1.2.0'
implementation "androidx.preference:preference-ktx:1.1.1"
implementation "androidx.activity:activity:${activityVersion}"
implementation "androidx.activity:activity-ktx:${activityVersion}"
implementation "io.reactivex.rxjava2:rxandroid:2.1.1"
// Graphview cannot be upgraded
implementation "com.jjoe64:graphview:4.0.1"
@ -70,7 +67,7 @@ dependencies {
kapt "com.google.dagger:dagger-compiler:$dagger_version"
//RxBus
implementation "io.reactivex.rxjava2:rxandroid:2.1.1"
implementation "io.reactivex.rxjava2:rxandroid:${rxandroid_version}"
testImplementation 'junit:junit:4.13'
androidTestImplementation 'androidx.test.ext:junit:1.1.1'

View file

@ -124,7 +124,7 @@ dependencies {
implementation('com.github.lecho:hellocharts-library:1.5.8@aar')
testImplementation 'junit:junit:4.13'
testImplementation 'org.json:json:20190722'
testImplementation 'org.json:json:20200518'
testImplementation ("org.mockito:mockito-core:2.8.47") {
exclude group: 'net.bytebuddy', module: 'byte-buddy'
exclude group: 'net.bytebuddy', module: 'byte-buddy-android'