diff --git a/app/src/main/java/info/nightscout/androidaps/Constants.java b/app/src/main/java/info/nightscout/androidaps/Constants.java
index 92833ac283..7f3b0b99b5 100644
--- a/app/src/main/java/info/nightscout/androidaps/Constants.java
+++ b/app/src/main/java/info/nightscout/androidaps/Constants.java
@@ -82,4 +82,11 @@ public class Constants {
public static final double LOWMARK = 76.0;
public static final double HIGHMARK = 180.0;
+ // STATISTICS
+ public static final double STATS_TARGET_LOW_MMOL = 3.9;
+ public static final double STATS_TARGET_HIGH_MMOL = 7.8;
+ public static final double STATS_RANGE_LOW_MMOL = 3.9;
+ public static final double STATS_RANGE_HIGH_MMOL = 10.0;
+
+
}
diff --git a/app/src/main/java/info/nightscout/androidaps/activities/SingleFragmentActivity.java b/app/src/main/java/info/nightscout/androidaps/activities/SingleFragmentActivity.java
index 688ba82c6a..a9a72adf09 100644
--- a/app/src/main/java/info/nightscout/androidaps/activities/SingleFragmentActivity.java
+++ b/app/src/main/java/info/nightscout/androidaps/activities/SingleFragmentActivity.java
@@ -39,8 +39,7 @@ public class SingleFragmentActivity extends AppCompatActivity {
if (item.getItemId() == android.R.id.home) {
finish();
return true;
- }
- else if (item.getItemId() == R.id.nav_plugin_preferences) {
+ } else if (item.getItemId() == R.id.nav_plugin_preferences) {
PasswordProtection.QueryPassword(this, R.string.settings_password, "settings_password", () -> {
Intent i = new Intent(this, PreferencesActivity.class);
i.putExtra("id", plugin.getPreferencesId());
diff --git a/app/src/main/java/info/nightscout/androidaps/activities/StatsActivity.kt b/app/src/main/java/info/nightscout/androidaps/activities/StatsActivity.kt
index e5feb2e0ed..4877eea492 100644
--- a/app/src/main/java/info/nightscout/androidaps/activities/StatsActivity.kt
+++ b/app/src/main/java/info/nightscout/androidaps/activities/StatsActivity.kt
@@ -9,7 +9,6 @@ import info.nightscout.androidaps.utils.TddCalculator
import info.nightscout.androidaps.utils.TirCalculator
import kotlinx.android.synthetic.main.stats_activity.*
-
class StatsActivity : NoSplashAppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
diff --git a/app/src/main/java/info/nightscout/androidaps/activities/SurveyActivity.kt b/app/src/main/java/info/nightscout/androidaps/activities/SurveyActivity.kt
index d8ec286916..74fe35f90f 100644
--- a/app/src/main/java/info/nightscout/androidaps/activities/SurveyActivity.kt
+++ b/app/src/main/java/info/nightscout/androidaps/activities/SurveyActivity.kt
@@ -4,25 +4,21 @@ import android.os.Bundle
import android.widget.ArrayAdapter
import com.google.firebase.auth.FirebaseAuth
import com.google.firebase.database.FirebaseDatabase
-import info.nightscout.androidaps.Constants
-import info.nightscout.androidaps.MainApp
import info.nightscout.androidaps.R
import info.nightscout.androidaps.data.defaultProfile.DefaultProfile
import info.nightscout.androidaps.plugins.configBuilder.ConfigBuilderPlugin
import info.nightscout.androidaps.plugins.configBuilder.ProfileFunctions
import info.nightscout.androidaps.plugins.treatments.fragments.ProfileViewerDialog
import info.nightscout.androidaps.utils.*
-import kotlinx.android.synthetic.main.survey_fragment.*
+import kotlinx.android.synthetic.main.survey_activity.*
import org.slf4j.LoggerFactory
-import java.util.*
-
class SurveyActivity : NoSplashAppCompatActivity() {
private val log = LoggerFactory.getLogger(SurveyActivity::class.java)
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
- setContentView(R.layout.survey_fragment)
+ setContentView(R.layout.survey_activity)
survey_id.text = InstanceId.instanceId()
@@ -85,21 +81,21 @@ class SurveyActivity : NoSplashAppCompatActivity() {
val auth = FirebaseAuth.getInstance()
auth.signInAnonymously()
- .addOnCompleteListener(this) { task ->
- if (task.isSuccessful) {
- log.debug("signInAnonymously:success")
- val user = auth.currentUser
+ .addOnCompleteListener(this) { task ->
+ if (task.isSuccessful) {
+ log.debug("signInAnonymously:success")
+ val user = auth.currentUser // TODO: do we need this, seems unused?
- val database = FirebaseDatabase.getInstance().reference
- database.child("survey").child(r.id).setValue(r)
- } else {
- log.error("signInAnonymously:failure", task.exception)
- ToastUtils.showToastInUiThread(this, "Authentication failed.")
- //updateUI(null)
- }
-
- // ...
+ val database = FirebaseDatabase.getInstance().reference
+ database.child("survey").child(r.id).setValue(r)
+ } else {
+ log.error("signInAnonymously:failure", task.exception)
+ ToastUtils.showToastInUiThread(this, "Authentication failed.")
+ //updateUI(null)
}
+
+ // ...
+ }
finish()
}
}
diff --git a/app/src/main/java/info/nightscout/androidaps/utils/ActivityMonitor.kt b/app/src/main/java/info/nightscout/androidaps/utils/ActivityMonitor.kt
index deac4a2877..1b3ba7bec8 100644
--- a/app/src/main/java/info/nightscout/androidaps/utils/ActivityMonitor.kt
+++ b/app/src/main/java/info/nightscout/androidaps/utils/ActivityMonitor.kt
@@ -62,7 +62,7 @@ object ActivityMonitor : Application.ActivityLifecycleCallbacks {
return result
}
- fun stats() :Spanned {
+ fun stats(): Spanned {
return HtmlHelper.fromHtml("
" + MainApp.gs(R.string.activitymonitor) + ":
" + toText())
}
diff --git a/app/src/main/java/info/nightscout/androidaps/utils/TddCalculator.kt b/app/src/main/java/info/nightscout/androidaps/utils/TddCalculator.kt
index b119fe72b9..0210247eb3 100644
--- a/app/src/main/java/info/nightscout/androidaps/utils/TddCalculator.kt
+++ b/app/src/main/java/info/nightscout/androidaps/utils/TddCalculator.kt
@@ -19,7 +19,6 @@ object TddCalculator : TreatmentsPlugin() {
val endTime = MidnightTime.calc(DateUtil.now())
initializeData(range)
-
val result = LongSparseArray()
for (t in treatmentsFromHistory) {
if (!t.isValid) continue
@@ -65,10 +64,10 @@ object TddCalculator : TreatmentsPlugin() {
val tdds = calculate(7)
val averageTdd = averageTDD(tdds)
return HtmlHelper.fromHtml(
- "" + MainApp.gs(R.string.tdd) + ":
" +
- toText(tdds) +
- "" + MainApp.gs(R.string.average) + ":
" +
- averageTdd.toText(tdds.size())
+ "" + MainApp.gs(R.string.tdd) + ":
" +
+ toText(tdds) +
+ "" + MainApp.gs(R.string.average) + ":
" +
+ averageTdd.toText(tdds.size())
)
}
diff --git a/app/src/main/java/info/nightscout/androidaps/utils/TirCalculator.kt b/app/src/main/java/info/nightscout/androidaps/utils/TirCalculator.kt
index 52d303ea39..4e41f9a331 100644
--- a/app/src/main/java/info/nightscout/androidaps/utils/TirCalculator.kt
+++ b/app/src/main/java/info/nightscout/androidaps/utils/TirCalculator.kt
@@ -32,9 +32,11 @@ object TirCalculator {
}
fun averageTIR(tirs: LongSparseArray): TIR {
- val totalTir =
- if (tirs.size() > 0) TIR(tirs.valueAt(0).date, tirs.valueAt(0).lowThreshold, tirs.valueAt(0).highThreshold)
- else TIR(7, 70.0, 180.0)
+ val totalTir = if (tirs.size() > 0) {
+ TIR(tirs.valueAt(0).date, tirs.valueAt(0).lowThreshold, tirs.valueAt(0).highThreshold)
+ } else {
+ TIR(7, 70.0, 180.0)
+ }
for (i in 0 until tirs.size()) {
val tir = tirs.valueAt(i)
totalTir.below += tir.below
@@ -47,10 +49,10 @@ object TirCalculator {
}
fun stats(): Spanned {
- val lowTirMgdl = 3.9 * Constants.MMOLL_TO_MGDL
- val highTirMgdl = 10.0 * Constants.MMOLL_TO_MGDL
- val lowTitMgdl = 3.9 * Constants.MMOLL_TO_MGDL
- val highTitMgdl = 7.8 * Constants.MMOLL_TO_MGDL
+ val lowTirMgdl = Constants.STATS_RANGE_LOW_MMOL * Constants.MMOLL_TO_MGDL
+ val highTirMgdl = Constants.STATS_RANGE_HIGH_MMOL * Constants.MMOLL_TO_MGDL
+ val lowTitMgdl = Constants.STATS_TARGET_LOW_MMOL * Constants.MMOLL_TO_MGDL
+ val highTitMgdl = Constants.STATS_TARGET_HIGH_MMOL * Constants.MMOLL_TO_MGDL
val tir7 = calculate(7, lowTirMgdl, highTirMgdl)
val averageTir7 = averageTIR(tir7)
@@ -61,14 +63,14 @@ object TirCalculator {
val tit30 = calculate(30, lowTitMgdl, highTitMgdl)
val averageTit30 = averageTIR(tit30)
return HtmlHelper.fromHtml(
- "
" + MainApp.gs(R.string.tir) + ":
" +
- toText(tir7) +
- "
" + MainApp.gs(R.string.average) + " (" + Profile.toCurrentUnitsString(lowTirMgdl) + "-" + Profile.toCurrentUnitsString(highTirMgdl) + "):
" +
- averageTir7.toText(tir7.size()) + "
" +
- averageTir30.toText(tir30.size()) +
- "
" + MainApp.gs(R.string.average) + " (" + Profile.toCurrentUnitsString(lowTitMgdl) + "-" + Profile.toCurrentUnitsString(highTitMgdl) + "):
" +
- averageTit7.toText(tit7.size()) + "
" +
- averageTit30.toText(tit30.size())
+ "
" + MainApp.gs(R.string.tir) + ":
" +
+ toText(tir7) +
+ "
" + MainApp.gs(R.string.average) + " (" + Profile.toCurrentUnitsString(lowTirMgdl) + "-" + Profile.toCurrentUnitsString(highTirMgdl) + "):
" +
+ averageTir7.toText(tir7.size()) + "
" +
+ averageTir30.toText(tir30.size()) +
+ "
" + MainApp.gs(R.string.average) + " (" + Profile.toCurrentUnitsString(lowTitMgdl) + "-" + Profile.toCurrentUnitsString(highTitMgdl) + "):
" +
+ averageTit7.toText(tit7.size()) + "
" +
+ averageTit30.toText(tit30.size())
)
}
diff --git a/app/src/main/res/layout/survey_fragment.xml b/app/src/main/res/layout/survey_activity.xml
similarity index 100%
rename from app/src/main/res/layout/survey_fragment.xml
rename to app/src/main/res/layout/survey_activity.xml