From 738c3585d5c0fa489f682ebd3c995b76388fc6f8 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 11 Feb 2021 10:34:35 +0000 Subject: [PATCH 01/27] Bump wearableVersion from 2.4.0 to 2.8.1 Bumps `wearableVersion` from 2.4.0 to 2.8.1. Updates `wearable` from 2.4.0 to 2.8.1 Updates `wearable` from 2.4.0 to 2.8.1 Signed-off-by: dependabot[bot] --- wear/build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/wear/build.gradle b/wear/build.gradle index a5a93a3530..88bfa0bf24 100644 --- a/wear/build.gradle +++ b/wear/build.gradle @@ -19,7 +19,7 @@ jacoco { } ext { - wearableVersion = "2.4.0" + wearableVersion = "2.8.1" playServicesWearable = "17.0.0" } From c7e261d0e6686c0e7e431d254c2081973e7e88f2 Mon Sep 17 00:00:00 2001 From: AdrianLxM Date: Sat, 13 Feb 2021 18:30:35 +0100 Subject: [PATCH 02/27] weekday picker working without view --- .../automation/elements/InputWeekDay.kt | 21 +++--- .../androidaps/utils/ui/WeekdayPicker.kt | 68 +++++++++++++++++ .../src/main/res/color/weekday_background.xml | 5 ++ .../src/main/res/color/weekend_background.xml | 5 ++ .../drawable/weekday_circle_brackground.xml | 7 ++ core/src/main/res/layout/weekday_picker.xml | 74 +++++++++++++++++++ core/src/main/res/values/colors.xml | 5 ++ core/src/main/res/values/strings.xml | 9 +++ 8 files changed, 182 insertions(+), 12 deletions(-) create mode 100644 core/src/main/java/info/nightscout/androidaps/utils/ui/WeekdayPicker.kt create mode 100644 core/src/main/res/color/weekday_background.xml create mode 100644 core/src/main/res/color/weekend_background.xml create mode 100644 core/src/main/res/drawable/weekday_circle_brackground.xml create mode 100644 core/src/main/res/layout/weekday_picker.xml diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/general/automation/elements/InputWeekDay.kt b/app/src/main/java/info/nightscout/androidaps/plugins/general/automation/elements/InputWeekDay.kt index 1f2531d95b..dda616de14 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/general/automation/elements/InputWeekDay.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/general/automation/elements/InputWeekDay.kt @@ -1,12 +1,10 @@ package info.nightscout.androidaps.plugins.general.automation.elements -import android.view.View -import android.view.ViewGroup import android.widget.LinearLayout import androidx.annotation.StringRes -import com.dpro.widgets.WeekdaysPicker import dagger.android.HasAndroidInjector import info.nightscout.androidaps.R +import info.nightscout.androidaps.utils.ui.WeekdayPicker import java.util.* class InputWeekDay(injector: HasAndroidInjector) : Element(injector) { @@ -22,6 +20,7 @@ class InputWeekDay(injector: HasAndroidInjector) : Element(injector) { get() = shortNames[ordinal] companion object { + private val calendarInts = intArrayOf( Calendar.MONDAY, Calendar.TUESDAY, @@ -56,7 +55,7 @@ class InputWeekDay(injector: HasAndroidInjector) : Element(injector) { for (day in DayOfWeek.values()) set(day, false) } - fun setAll(value:Boolean) { + fun setAll(value: Boolean) { for (day in DayOfWeek.values()) set(day, value) } @@ -78,13 +77,11 @@ class InputWeekDay(injector: HasAndroidInjector) : Element(injector) { } override fun addToLayout(root: LinearLayout) { - val weekdaysPicker = WeekdaysPicker(root.context) - weekdaysPicker.setEditable(true) - weekdaysPicker.selectedDays = getSelectedDays() - weekdaysPicker.setOnWeekdaysChangeListener { _: View?, i: Int, list: List -> set(DayOfWeek.fromCalendarInt(i), list.contains(i)) } - weekdaysPicker.layoutParams = LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT) - weekdaysPicker.sundayFirstDay = Calendar.getInstance().firstDayOfWeek == Calendar.SUNDAY - weekdaysPicker.redrawDays() - root.addView(weekdaysPicker) + WeekdayPicker(root.context).apply { + setSelectedDays(getSelectedDays()) + setOnWeekdaysChangeListener { i: Int, selected: Boolean -> set(DayOfWeek.fromCalendarInt(i), selected) } + root.addView(this) + } + // TODO: remove library and dependency statement } } diff --git a/core/src/main/java/info/nightscout/androidaps/utils/ui/WeekdayPicker.kt b/core/src/main/java/info/nightscout/androidaps/utils/ui/WeekdayPicker.kt new file mode 100644 index 0000000000..0ac104a070 --- /dev/null +++ b/core/src/main/java/info/nightscout/androidaps/utils/ui/WeekdayPicker.kt @@ -0,0 +1,68 @@ +package info.nightscout.androidaps.utils.ui + +import android.content.Context +import android.util.AttributeSet +import android.view.LayoutInflater +import android.widget.Checkable +import android.widget.LinearLayout +import androidx.appcompat.widget.AppCompatCheckedTextView +import info.nightscout.androidaps.core.databinding.WeekdayPickerBinding +import info.nightscout.androidaps.utils.extensions.toVisibility +import java.util.* + +class WeekdayPicker @JvmOverloads constructor( + context: Context, attrs: AttributeSet? = null, defStyleAttr: Int = 0 +) : LinearLayout(context, attrs, defStyleAttr) { + + private var changeListener: ((Int, Boolean) -> Unit)? = null + + private var binding: WeekdayPickerBinding + + init { + val inflater = LayoutInflater.from(context) + binding = WeekdayPickerBinding.inflate(inflater, this, true) + determineBeginOfWeek() + setupClickListeners() + } + + private fun determineBeginOfWeek() { + (Calendar.getInstance().firstDayOfWeek == Calendar.SUNDAY).let { + binding.weekdayPickerSundayStart.visibility = it.toVisibility() + binding.weekdayPickerSundayEnd.visibility = it.not().toVisibility() + } + } + + fun setSelectedDays(list: List) { + binding.weekdayPickerSundayStart.isChecked = list.contains(Calendar.SUNDAY) + binding.weekdayPickerSundayEnd.isChecked = list.contains(Calendar.SUNDAY) + binding.weekdayPickerMonday.isChecked = list.contains(Calendar.MONDAY) + binding.weekdayPickerTuesday.isChecked = list.contains(Calendar.TUESDAY) + binding.weekdayPickerWednesday.isChecked = list.contains(Calendar.WEDNESDAY) + binding.weekdayPickerThursday.isChecked = list.contains(Calendar.THURSDAY) + binding.weekdayPickerFriday.isChecked = list.contains(Calendar.FRIDAY) + binding.weekdayPickerSaturday.isChecked = list.contains(Calendar.SATURDAY) + } + + private fun setupClickListeners() { + binding.weekdayPickerSundayStart.setupCallbackFor(Calendar.SUNDAY) + binding.weekdayPickerSundayEnd.setupCallbackFor(Calendar.SUNDAY) + binding.weekdayPickerMonday.setupCallbackFor(Calendar.MONDAY) + binding.weekdayPickerTuesday.setupCallbackFor(Calendar.TUESDAY) + binding.weekdayPickerWednesday.setupCallbackFor(Calendar.WEDNESDAY) + binding.weekdayPickerThursday.setupCallbackFor(Calendar.THURSDAY) + binding.weekdayPickerFriday.setupCallbackFor(Calendar.FRIDAY) + binding.weekdayPickerSaturday.setupCallbackFor(Calendar.SATURDAY) + } + + fun setOnWeekdaysChangeListener(changeListener: (Int, Boolean) -> Unit) { + this.changeListener = changeListener + } + + private fun AppCompatCheckedTextView.setupCallbackFor(day: Int) = setOnClickListener{ + val checkable = it as Checkable + val checked = checkable.isChecked + checkable.isChecked = !checked + changeListener?.invoke(day, !checked) + } + +} \ No newline at end of file diff --git a/core/src/main/res/color/weekday_background.xml b/core/src/main/res/color/weekday_background.xml new file mode 100644 index 0000000000..b345f818d2 --- /dev/null +++ b/core/src/main/res/color/weekday_background.xml @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/core/src/main/res/color/weekend_background.xml b/core/src/main/res/color/weekend_background.xml new file mode 100644 index 0000000000..1de73d0e17 --- /dev/null +++ b/core/src/main/res/color/weekend_background.xml @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/core/src/main/res/drawable/weekday_circle_brackground.xml b/core/src/main/res/drawable/weekday_circle_brackground.xml new file mode 100644 index 0000000000..861dda73c2 --- /dev/null +++ b/core/src/main/res/drawable/weekday_circle_brackground.xml @@ -0,0 +1,7 @@ + + + + \ No newline at end of file diff --git a/core/src/main/res/layout/weekday_picker.xml b/core/src/main/res/layout/weekday_picker.xml new file mode 100644 index 0000000000..82acbb829b --- /dev/null +++ b/core/src/main/res/layout/weekday_picker.xml @@ -0,0 +1,74 @@ + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/core/src/main/res/values/colors.xml b/core/src/main/res/values/colors.xml index 7842897b59..6bd15fb852 100644 --- a/core/src/main/res/values/colors.xml +++ b/core/src/main/res/values/colors.xml @@ -41,6 +41,11 @@ #00d2d2 #ffffff + #8000FF00 + #1000FF00 + #800000FF + #100000FF + #FF8C00 diff --git a/core/src/main/res/values/strings.xml b/core/src/main/res/values/strings.xml index e42bd8e553..06a686a867 100644 --- a/core/src/main/res/values/strings.xml +++ b/core/src/main/res/values/strings.xml @@ -315,6 +315,15 @@ Please reboot your phone or restart AndroidAPS from the System Settings \notherwise Android APS will not have logging (important to track and verify that the algorithms are working correctly)! + + M + T + W + T + F + S + S + %1$d day %1$d days From ff6a8f30c1c05cac3bde17dbf9df961102f35f51 Mon Sep 17 00:00:00 2001 From: AdrianLxM Date: Sat, 13 Feb 2021 19:10:12 +0100 Subject: [PATCH 03/27] weekday component working --- .../androidaps/utils/ui/WeekdayPicker.kt | 3 +- .../res/color/day_selection_background.xml | 5 + .../src/main/res/color/weekday_background.xml | 5 - .../src/main/res/color/weekend_background.xml | 5 - .../drawable/weekday_circle_brackground.xml | 6 +- .../drawable/weekend_circle_brackground.xml | 7 + core/src/main/res/layout/weekday_picker.xml | 124 +++++++++++++----- core/src/main/res/values/colors.xml | 7 +- 8 files changed, 114 insertions(+), 48 deletions(-) create mode 100644 core/src/main/res/color/day_selection_background.xml delete mode 100644 core/src/main/res/color/weekday_background.xml delete mode 100644 core/src/main/res/color/weekend_background.xml create mode 100644 core/src/main/res/drawable/weekend_circle_brackground.xml diff --git a/core/src/main/java/info/nightscout/androidaps/utils/ui/WeekdayPicker.kt b/core/src/main/java/info/nightscout/androidaps/utils/ui/WeekdayPicker.kt index 0ac104a070..07af86879f 100644 --- a/core/src/main/java/info/nightscout/androidaps/utils/ui/WeekdayPicker.kt +++ b/core/src/main/java/info/nightscout/androidaps/utils/ui/WeekdayPicker.kt @@ -6,13 +6,14 @@ import android.view.LayoutInflater import android.widget.Checkable import android.widget.LinearLayout import androidx.appcompat.widget.AppCompatCheckedTextView +import androidx.constraintlayout.widget.ConstraintLayout import info.nightscout.androidaps.core.databinding.WeekdayPickerBinding import info.nightscout.androidaps.utils.extensions.toVisibility import java.util.* class WeekdayPicker @JvmOverloads constructor( context: Context, attrs: AttributeSet? = null, defStyleAttr: Int = 0 -) : LinearLayout(context, attrs, defStyleAttr) { +) : ConstraintLayout(context, attrs, defStyleAttr) { private var changeListener: ((Int, Boolean) -> Unit)? = null diff --git a/core/src/main/res/color/day_selection_background.xml b/core/src/main/res/color/day_selection_background.xml new file mode 100644 index 0000000000..6dd68ef826 --- /dev/null +++ b/core/src/main/res/color/day_selection_background.xml @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/core/src/main/res/color/weekday_background.xml b/core/src/main/res/color/weekday_background.xml deleted file mode 100644 index b345f818d2..0000000000 --- a/core/src/main/res/color/weekday_background.xml +++ /dev/null @@ -1,5 +0,0 @@ - - - - - \ No newline at end of file diff --git a/core/src/main/res/color/weekend_background.xml b/core/src/main/res/color/weekend_background.xml deleted file mode 100644 index 1de73d0e17..0000000000 --- a/core/src/main/res/color/weekend_background.xml +++ /dev/null @@ -1,5 +0,0 @@ - - - - - \ No newline at end of file diff --git a/core/src/main/res/drawable/weekday_circle_brackground.xml b/core/src/main/res/drawable/weekday_circle_brackground.xml index 861dda73c2..df71b0310e 100644 --- a/core/src/main/res/drawable/weekday_circle_brackground.xml +++ b/core/src/main/res/drawable/weekday_circle_brackground.xml @@ -1,7 +1,7 @@ - + + android:width="4dp" + android:color="@color/weekdayOutline"/> \ No newline at end of file diff --git a/core/src/main/res/drawable/weekend_circle_brackground.xml b/core/src/main/res/drawable/weekend_circle_brackground.xml new file mode 100644 index 0000000000..658780df37 --- /dev/null +++ b/core/src/main/res/drawable/weekend_circle_brackground.xml @@ -0,0 +1,7 @@ + + + + \ No newline at end of file diff --git a/core/src/main/res/layout/weekday_picker.xml b/core/src/main/res/layout/weekday_picker.xml index 82acbb829b..db8219f583 100644 --- a/core/src/main/res/layout/weekday_picker.xml +++ b/core/src/main/res/layout/weekday_picker.xml @@ -1,74 +1,138 @@ - + android:layout_height="wrap_content"> + app:layout_constraintTop_toTopOf="parent" + app:layout_constraintEnd_toStartOf="@+id/weekdayPickerMonday" + app:layout_constraintStart_toStartOf="parent" /> + android:gravity="center" + android:textAlignment="gravity" + android:padding="8dp" + android:layout_margin="2dp" + app:layout_constraintDimensionRatio="H,1:1" + app:autoSizeTextType="uniform" + android:text="@string/monday_short" + app:layout_constraintEnd_toStartOf="@+id/weekdayPickerTuesday" + app:layout_constraintStart_toEndOf="@+id/weekdayPickerSundayStart" + app:layout_constraintTop_toTopOf="parent" /> + app:layout_constraintBaseline_toBaselineOf="@+id/weekdayPickerWednesday" + app:layout_constraintEnd_toStartOf="@+id/weekdayPickerWednesday" + app:layout_constraintStart_toEndOf="@+id/weekdayPickerMonday" /> + app:layout_constraintEnd_toStartOf="@+id/weekdayPickerThursday" + app:layout_constraintStart_toEndOf="@+id/weekdayPickerTuesday" + app:layout_constraintTop_toTopOf="parent" /> + app:layout_constraintTop_toTopOf="parent" + app:layout_constraintEnd_toStartOf="@+id/weekdayPickerFriday" + app:layout_constraintStart_toEndOf="@+id/weekdayPickerWednesday" /> + app:layout_constraintEnd_toStartOf="@+id/weekdayPickerSaturday" + app:layout_constraintStart_toEndOf="@+id/weekdayPickerThursday" + app:layout_constraintTop_toTopOf="parent" /> + app:layout_constraintTop_toTopOf="parent" + app:layout_constraintEnd_toStartOf="@+id/weekdayPickerSundayEnd" + app:layout_constraintStart_toEndOf="@+id/weekdayPickerFriday" /> + app:layout_constraintEnd_toEndOf="parent" + app:layout_constraintStart_toEndOf="@+id/weekdayPickerSaturday" + app:layout_constraintTop_toTopOf="parent" /> - \ No newline at end of file + \ No newline at end of file diff --git a/core/src/main/res/values/colors.xml b/core/src/main/res/values/colors.xml index 6bd15fb852..a533a5c3aa 100644 --- a/core/src/main/res/values/colors.xml +++ b/core/src/main/res/values/colors.xml @@ -41,10 +41,9 @@ #00d2d2 #ffffff - #8000FF00 - #1000FF00 - #800000FF - #100000FF + #D000FF00 + #1ea3e5 + #1e88e5 #FF8C00 From 7c8caa659b4662b676524a216eadd56fcdbae96e Mon Sep 17 00:00:00 2001 From: AdrianLxM Date: Sat, 13 Feb 2021 19:19:14 +0100 Subject: [PATCH 04/27] remove crashing library --- app/build.gradle | 3 --- app/libs/weekdaysselector-1.1.1.aar | Bin 17376 -> 0 bytes 2 files changed, 3 deletions(-) delete mode 100644 app/libs/weekdaysselector-1.1.1.aar diff --git a/app/build.gradle b/app/build.gradle index 5df54d7711..45e91a54d6 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -241,9 +241,6 @@ dependencies { implementation fileTree(include: ['*.jar'], dir: 'libs') - // https://github.com/DavidProdinger/Weekdays-Selector (used outdated 'com.amulyakhare:com.amulyakhare.textdrawable:1.0.1') - implementation(name: 'weekdaysselector-1.1.1', ext: 'aar') - testImplementation "junit:junit:$junit_version" testImplementation 'org.json:json:20201115' testImplementation "org.mockito:mockito-core:${mockitoVersion}" diff --git a/app/libs/weekdaysselector-1.1.1.aar b/app/libs/weekdaysselector-1.1.1.aar deleted file mode 100644 index 214a429e3ab71fb2118cfd13579ed882ad6ef9a5..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 17376 zcmZ^~V~j3Lur)fy9^1BU+qP}nwr$(CXP&WbduES~J-F}5cmJH+?{-r4qqC}$>Xr0L zI<*vKK*9b10YO0l0RagCNmO@FPeK3z0h0m&f&aIoOz-OHny0;MpUa8bzh99FIWfv; zwRK~LV^<@2S=|%WUZ+ko4T|3gVQVUzd}+P!m%wyD0Gp|63NpSQk>K|e3uopW5jL2S zM`%R@W<<4lWAHklxJp>Iao9}XNW*>foC~wp3|rQF0@Rl>7%$^Jh-qD4Ijb+ny@kIV>NWWwxE zvjvf|F_2V^q#pnk?hTSUs7n5X&p+;iTv?D`i^xb9WQMIm%RWcNY4az_%8WTQbUZ3VGfMypPPqbb|7^@630x`QIF{#F3$88`xTJw0 zu}%+eR!AM6(cSj01*<S(M>=|Q^F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b{p~SuLUuAMu^Og!l7pl%3$=QhHP#%Ag*iVMO*VSdUz1;Gar;8g^g_2H{JKV?K zr55Hf=lnVBGyR}2lYX`wHxCNqF(zC&Vu#ZLo^a-Q8ZTg8&*42JAW6V>)^qTr z1LX|k|DO`%|8>uFre<``qGJCa5|w+V2mJm+Ui=p%|JREDL(u)tv(f=KY; z3jyA!TF`f`f)s+llEyc{a~rViVMR9peN!kzJIH`@K%XIP5k=PsQiz;YAsPi3-Z~cA zK{6#i9iWVh&@mON0~(I#8qu>cOzV=y1E?AinHt>)kQSJ0K`9ghK(5trKrTXHk%O)u zJ-xzASkf4URX;}RMK=&+0L($4Bm@B<2T3@>6BIs8pag}`WDnPb@Bu3@1u!sh0bwlA Krd*&31_l6-L6s>0 From 0d601634e00445ad2b9191c8e3b3c29d50434f01 Mon Sep 17 00:00:00 2001 From: AdrianLxM Date: Sat, 13 Feb 2021 19:40:27 +0100 Subject: [PATCH 05/27] cleanups of new weekday selector --- .../automation/elements/InputWeekDay.kt | 2 - .../androidaps/utils/ui/WeekdayPicker.kt | 39 +++++---- core/src/main/res/layout/weekday_picker.xml | 81 +++++++++---------- 3 files changed, 59 insertions(+), 63 deletions(-) diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/general/automation/elements/InputWeekDay.kt b/app/src/main/java/info/nightscout/androidaps/plugins/general/automation/elements/InputWeekDay.kt index dda616de14..53733acfc8 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/general/automation/elements/InputWeekDay.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/general/automation/elements/InputWeekDay.kt @@ -20,7 +20,6 @@ class InputWeekDay(injector: HasAndroidInjector) : Element(injector) { get() = shortNames[ordinal] companion object { - private val calendarInts = intArrayOf( Calendar.MONDAY, Calendar.TUESDAY, @@ -82,6 +81,5 @@ class InputWeekDay(injector: HasAndroidInjector) : Element(injector) { setOnWeekdaysChangeListener { i: Int, selected: Boolean -> set(DayOfWeek.fromCalendarInt(i), selected) } root.addView(this) } - // TODO: remove library and dependency statement } } diff --git a/core/src/main/java/info/nightscout/androidaps/utils/ui/WeekdayPicker.kt b/core/src/main/java/info/nightscout/androidaps/utils/ui/WeekdayPicker.kt index 07af86879f..e3352ec94d 100644 --- a/core/src/main/java/info/nightscout/androidaps/utils/ui/WeekdayPicker.kt +++ b/core/src/main/java/info/nightscout/androidaps/utils/ui/WeekdayPicker.kt @@ -4,7 +4,6 @@ import android.content.Context import android.util.AttributeSet import android.view.LayoutInflater import android.widget.Checkable -import android.widget.LinearLayout import androidx.appcompat.widget.AppCompatCheckedTextView import androidx.constraintlayout.widget.ConstraintLayout import info.nightscout.androidaps.core.databinding.WeekdayPickerBinding @@ -33,33 +32,33 @@ class WeekdayPicker @JvmOverloads constructor( } } - fun setSelectedDays(list: List) { - binding.weekdayPickerSundayStart.isChecked = list.contains(Calendar.SUNDAY) - binding.weekdayPickerSundayEnd.isChecked = list.contains(Calendar.SUNDAY) - binding.weekdayPickerMonday.isChecked = list.contains(Calendar.MONDAY) - binding.weekdayPickerTuesday.isChecked = list.contains(Calendar.TUESDAY) - binding.weekdayPickerWednesday.isChecked = list.contains(Calendar.WEDNESDAY) - binding.weekdayPickerThursday.isChecked = list.contains(Calendar.THURSDAY) - binding.weekdayPickerFriday.isChecked = list.contains(Calendar.FRIDAY) - binding.weekdayPickerSaturday.isChecked = list.contains(Calendar.SATURDAY) + fun setSelectedDays(list: List) = with(binding) { + weekdayPickerSundayStart.isChecked = list.contains(Calendar.SUNDAY) + weekdayPickerSundayEnd.isChecked = list.contains(Calendar.SUNDAY) + weekdayPickerMonday.isChecked = list.contains(Calendar.MONDAY) + weekdayPickerTuesday.isChecked = list.contains(Calendar.TUESDAY) + weekdayPickerWednesday.isChecked = list.contains(Calendar.WEDNESDAY) + weekdayPickerThursday.isChecked = list.contains(Calendar.THURSDAY) + weekdayPickerFriday.isChecked = list.contains(Calendar.FRIDAY) + weekdayPickerSaturday.isChecked = list.contains(Calendar.SATURDAY) } - private fun setupClickListeners() { - binding.weekdayPickerSundayStart.setupCallbackFor(Calendar.SUNDAY) - binding.weekdayPickerSundayEnd.setupCallbackFor(Calendar.SUNDAY) - binding.weekdayPickerMonday.setupCallbackFor(Calendar.MONDAY) - binding.weekdayPickerTuesday.setupCallbackFor(Calendar.TUESDAY) - binding.weekdayPickerWednesday.setupCallbackFor(Calendar.WEDNESDAY) - binding.weekdayPickerThursday.setupCallbackFor(Calendar.THURSDAY) - binding.weekdayPickerFriday.setupCallbackFor(Calendar.FRIDAY) - binding.weekdayPickerSaturday.setupCallbackFor(Calendar.SATURDAY) + private fun setupClickListeners() = with(binding) { + weekdayPickerSundayStart.setupCallbackFor(Calendar.SUNDAY) + weekdayPickerSundayEnd.setupCallbackFor(Calendar.SUNDAY) + weekdayPickerMonday.setupCallbackFor(Calendar.MONDAY) + weekdayPickerTuesday.setupCallbackFor(Calendar.TUESDAY) + weekdayPickerWednesday.setupCallbackFor(Calendar.WEDNESDAY) + weekdayPickerThursday.setupCallbackFor(Calendar.THURSDAY) + weekdayPickerFriday.setupCallbackFor(Calendar.FRIDAY) + weekdayPickerSaturday.setupCallbackFor(Calendar.SATURDAY) } fun setOnWeekdaysChangeListener(changeListener: (Int, Boolean) -> Unit) { this.changeListener = changeListener } - private fun AppCompatCheckedTextView.setupCallbackFor(day: Int) = setOnClickListener{ + private fun AppCompatCheckedTextView.setupCallbackFor(day: Int) = setOnClickListener { val checkable = it as Checkable val checked = checkable.isChecked checkable.isChecked = !checked diff --git a/core/src/main/res/layout/weekday_picker.xml b/core/src/main/res/layout/weekday_picker.xml index db8219f583..f20fec423d 100644 --- a/core/src/main/res/layout/weekday_picker.xml +++ b/core/src/main/res/layout/weekday_picker.xml @@ -1,40 +1,39 @@ + android:layout_height="wrap_content" + android:padding="2dp"> + app:layout_constraintStart_toStartOf="parent" + app:layout_constraintTop_toTopOf="parent" /> @@ -43,15 +42,15 @@ android:id="@+id/weekdayPickerTuesday" android:layout_width="0dp" android:layout_height="0dp" + android:layout_margin="2dp" android:background="@drawable/weekday_circle_brackground" android:gravity="center" - android:textAlignment="gravity" android:padding="8dp" - android:layout_margin="2dp" - app:layout_constraintDimensionRatio="H,1:1" - app:autoSizeTextType="uniform" android:text="@string/tuesday_short" + android:textAlignment="gravity" + app:autoSizeTextType="uniform" app:layout_constraintBaseline_toBaselineOf="@+id/weekdayPickerWednesday" + app:layout_constraintDimensionRatio="H,1:1" app:layout_constraintEnd_toStartOf="@+id/weekdayPickerWednesday" app:layout_constraintStart_toEndOf="@+id/weekdayPickerMonday" /> @@ -59,14 +58,14 @@ android:id="@+id/weekdayPickerWednesday" android:layout_width="0dp" android:layout_height="0dp" + android:layout_margin="2dp" android:background="@drawable/weekday_circle_brackground" android:gravity="center" - android:textAlignment="gravity" android:padding="8dp" - android:layout_margin="2dp" - app:layout_constraintDimensionRatio="H,1:1" - app:autoSizeTextType="uniform" android:text="@string/wednesday_short" + android:textAlignment="gravity" + app:autoSizeTextType="uniform" + app:layout_constraintDimensionRatio="H,1:1" app:layout_constraintEnd_toStartOf="@+id/weekdayPickerThursday" app:layout_constraintStart_toEndOf="@+id/weekdayPickerTuesday" app:layout_constraintTop_toTopOf="parent" /> @@ -75,30 +74,30 @@ android:id="@+id/weekdayPickerThursday" android:layout_width="0dp" android:layout_height="0dp" + android:layout_margin="2dp" android:background="@drawable/weekday_circle_brackground" android:gravity="center" - android:textAlignment="gravity" android:padding="8dp" - android:layout_margin="2dp" - app:layout_constraintDimensionRatio="H,1:1" - app:autoSizeTextType="uniform" android:text="@string/thursday_short" - app:layout_constraintTop_toTopOf="parent" + android:textAlignment="gravity" + app:autoSizeTextType="uniform" + app:layout_constraintDimensionRatio="H,1:1" app:layout_constraintEnd_toStartOf="@+id/weekdayPickerFriday" - app:layout_constraintStart_toEndOf="@+id/weekdayPickerWednesday" /> + app:layout_constraintStart_toEndOf="@+id/weekdayPickerWednesday" + app:layout_constraintTop_toTopOf="parent" /> @@ -107,30 +106,30 @@ android:id="@+id/weekdayPickerSaturday" android:layout_width="0dp" android:layout_height="0dp" + android:layout_margin="2dp" android:background="@drawable/weekend_circle_brackground" android:gravity="center" - android:textAlignment="gravity" android:padding="8dp" - android:layout_margin="2dp" - app:layout_constraintDimensionRatio="H,1:1" - app:autoSizeTextType="uniform" android:text="@string/saturday_short" - app:layout_constraintTop_toTopOf="parent" + android:textAlignment="gravity" + app:autoSizeTextType="uniform" + app:layout_constraintDimensionRatio="H,1:1" app:layout_constraintEnd_toStartOf="@+id/weekdayPickerSundayEnd" - app:layout_constraintStart_toEndOf="@+id/weekdayPickerFriday" /> + app:layout_constraintStart_toEndOf="@+id/weekdayPickerFriday" + app:layout_constraintTop_toTopOf="parent" /> From 0ce35c6439d02c849081f20e3fbac269007ca89d Mon Sep 17 00:00:00 2001 From: Milos Kozak Date: Sat, 13 Feb 2021 22:14:06 +0100 Subject: [PATCH 06/27] TDDStatsActivity ->kt --- .../activities/TDDStatsActivity.java | 528 ------------------ .../androidaps/activities/TDDStatsActivity.kt | 429 ++++++++++++++ ...atsactivity.xml => activity_tdd_stats.xml} | 165 +++--- 3 files changed, 509 insertions(+), 613 deletions(-) delete mode 100644 core/src/main/java/info/nightscout/androidaps/activities/TDDStatsActivity.java create mode 100644 core/src/main/java/info/nightscout/androidaps/activities/TDDStatsActivity.kt rename core/src/main/res/layout/{danar_statsactivity.xml => activity_tdd_stats.xml} (58%) diff --git a/core/src/main/java/info/nightscout/androidaps/activities/TDDStatsActivity.java b/core/src/main/java/info/nightscout/androidaps/activities/TDDStatsActivity.java deleted file mode 100644 index b9cc88fc28..0000000000 --- a/core/src/main/java/info/nightscout/androidaps/activities/TDDStatsActivity.java +++ /dev/null @@ -1,528 +0,0 @@ -package info.nightscout.androidaps.activities; - -import android.graphics.Color; -import android.graphics.Rect; -import android.os.Bundle; -import android.text.TextUtils; -import android.view.MotionEvent; -import android.view.View; -import android.view.WindowManager; -import android.view.inputmethod.EditorInfo; -import android.view.inputmethod.InputMethodManager; -import android.widget.Button; -import android.widget.EditText; -import android.widget.TableLayout; -import android.widget.TableRow; -import android.widget.TextView; - -import androidx.recyclerview.widget.LinearLayoutManager; - -import java.text.DateFormat; -import java.text.DecimalFormat; -import java.text.SimpleDateFormat; -import java.util.ArrayList; -import java.util.Collections; -import java.util.Date; -import java.util.LinkedList; -import java.util.List; -import java.util.Locale; - -import javax.inject.Inject; - -import info.nightscout.androidaps.core.R; -import info.nightscout.androidaps.data.Profile; -import info.nightscout.androidaps.db.TDD; -import info.nightscout.androidaps.events.EventDanaRSyncStatus; -import info.nightscout.androidaps.events.EventPumpStatusChanged; -import info.nightscout.androidaps.interfaces.ActivePluginProvider; -import info.nightscout.androidaps.interfaces.CommandQueueProvider; -import info.nightscout.androidaps.interfaces.DatabaseHelperInterface; -import info.nightscout.androidaps.interfaces.ProfileFunction; -import info.nightscout.androidaps.logging.AAPSLogger; -import info.nightscout.androidaps.plugins.bus.RxBusWrapper; -import info.nightscout.androidaps.plugins.pump.common.defs.PumpType; -import info.nightscout.androidaps.queue.Callback; -import info.nightscout.androidaps.utils.FabricPrivacy; -import info.nightscout.androidaps.utils.SafeParse; -import info.nightscout.androidaps.utils.resources.ResourceHelper; -import info.nightscout.androidaps.utils.rx.AapsSchedulers; -import info.nightscout.androidaps.utils.sharedPreferences.SP; -import io.reactivex.android.schedulers.AndroidSchedulers; -import io.reactivex.disposables.CompositeDisposable; - -public class TDDStatsActivity extends NoSplashAppCompatActivity { - @Inject AAPSLogger aapsLogger; - @Inject ResourceHelper resourceHelper; - @Inject RxBusWrapper rxBus; - @Inject SP sp; - @Inject ProfileFunction profileFunction; - @Inject ActivePluginProvider activePlugin; - @Inject CommandQueueProvider commandQueue; - @Inject DatabaseHelperInterface databaseHelper; - @Inject FabricPrivacy fabricPrivacy; - @Inject AapsSchedulers aapsSchedulers; - - private final CompositeDisposable disposable = new CompositeDisposable(); - - TextView statusView, statsMessage, totalBaseBasal2; - EditText totalBaseBasal; - Button reloadButton; - LinearLayoutManager llm; - TableLayout tl, ctl, etl; - String TBB; - double magicNumber; - DecimalFormat decimalFormat; - - List historyList = new ArrayList<>(); - List dummies; - - public TDDStatsActivity() { - super(); - } - - @Override - protected void onResume() { - super.onResume(); - disposable.add(rxBus - .toObservable(EventPumpStatusChanged.class) - .observeOn(aapsSchedulers.getMain()) - .subscribe(event -> statusView.setText(event.getStatus(resourceHelper)), exception -> fabricPrivacy.logException(exception)) - ); - disposable.add(rxBus - .toObservable(EventDanaRSyncStatus.class) - .observeOn(aapsSchedulers.getMain()) - .subscribe(event -> { - aapsLogger.debug("EventDanaRSyncStatus: " + event.getMessage()); - statusView.setText(event.getMessage()); - }, exception -> fabricPrivacy.logException(exception)) - ); - } - - @Override - protected void onPause() { - super.onPause(); - disposable.clear(); - } - - @Override - public boolean dispatchTouchEvent(MotionEvent event) { - if (event.getAction() == MotionEvent.ACTION_DOWN) { - View myView = getCurrentFocus(); - if (myView instanceof EditText) { - Rect rect = new Rect(); - myView.getGlobalVisibleRect(rect); - if (!rect.contains((int) event.getRawX(), (int) event.getRawY())) { - myView.clearFocus(); - } - } - } - return super.dispatchTouchEvent(event); - } - - @Override - public void onCreate(Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - setContentView(R.layout.danar_statsactivity); - getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_PAN); - statusView = findViewById(R.id.danar_stats_connection_status); - reloadButton = findViewById(R.id.danar_statsreload); - totalBaseBasal = findViewById(R.id.danar_stats_editTotalBaseBasal); - totalBaseBasal2 = findViewById(R.id.danar_stats_editTotalBaseBasal2); - statsMessage = findViewById(R.id.danar_stats_Message); - - statusView.setVisibility(View.GONE); - statsMessage.setVisibility(View.GONE); - - totalBaseBasal2.setEnabled(false); - totalBaseBasal2.setClickable(false); - totalBaseBasal2.setFocusable(false); - totalBaseBasal2.setInputType(0); - - decimalFormat = new DecimalFormat("0.000"); - llm = new LinearLayoutManager(this); - - TBB = sp.getString("TBB", "10.00"); - - Profile profile = profileFunction.getProfile(); - if (profile != null) { - double cppTBB = profile.baseBasalSum(); - TBB = decimalFormat.format(cppTBB); - sp.putString("TBB", TBB); - } - totalBaseBasal.setText(TBB); - - if (!activePlugin.getActivePump().getPumpDescription().needsManualTDDLoad) - reloadButton.setVisibility(View.GONE); - - // stats table - tl = findViewById(R.id.main_table); - TableRow tr_head = new TableRow(this); - tr_head.setBackgroundColor(Color.DKGRAY); - tr_head.setLayoutParams(new TableLayout.LayoutParams( - TableLayout.LayoutParams.MATCH_PARENT, - TableLayout.LayoutParams.WRAP_CONTENT)); - - TextView label_date = new TextView(this); - label_date.setText(resourceHelper.gs(R.string.date)); - label_date.setTextColor(Color.WHITE); - tr_head.addView(label_date); - - TextView label_basalrate = new TextView(this); - label_basalrate.setText(resourceHelper.gs(R.string.basalrate)); - label_basalrate.setTextColor(Color.WHITE); - tr_head.addView(label_basalrate); - - TextView label_bolus = new TextView(this); - label_bolus.setText(resourceHelper.gs(R.string.bolus)); - label_bolus.setTextColor(Color.WHITE); - tr_head.addView(label_bolus); - - TextView label_tdd = new TextView(this); - label_tdd.setText(resourceHelper.gs(R.string.tdd)); - label_tdd.setTextColor(Color.WHITE); - tr_head.addView(label_tdd); - - TextView label_ratio = new TextView(this); - label_ratio.setText(resourceHelper.gs(R.string.ratio)); - label_ratio.setTextColor(Color.WHITE); - tr_head.addView(label_ratio); - - // add stats headers to tables - tl.addView(tr_head, new TableLayout.LayoutParams( - TableLayout.LayoutParams.MATCH_PARENT, - TableLayout.LayoutParams.WRAP_CONTENT)); - - // cumulative table - ctl = findViewById(R.id.cumulative_table); - TableRow ctr_head = new TableRow(this); - ctr_head.setBackgroundColor(Color.DKGRAY); - ctr_head.setLayoutParams(new TableLayout.LayoutParams( - TableLayout.LayoutParams.MATCH_PARENT, - TableLayout.LayoutParams.WRAP_CONTENT)); - - TextView label_cum_amount_days = new TextView(this); - label_cum_amount_days.setText(resourceHelper.gs(R.string.amount_days)); - label_cum_amount_days.setTextColor(Color.WHITE); - ctr_head.addView(label_cum_amount_days); - - TextView label_cum_tdd = new TextView(this); - label_cum_tdd.setText(resourceHelper.gs(R.string.tdd)); - label_cum_tdd.setTextColor(Color.WHITE); - ctr_head.addView(label_cum_tdd); - - TextView label_cum_ratio = new TextView(this); - label_cum_ratio.setText(resourceHelper.gs(R.string.ratio)); - label_cum_ratio.setTextColor(Color.WHITE); - ctr_head.addView(label_cum_ratio); - - // add cummulative headers to tables - ctl.addView(ctr_head, new TableLayout.LayoutParams( - TableLayout.LayoutParams.MATCH_PARENT, - TableLayout.LayoutParams.WRAP_CONTENT)); - - // expontial table - etl = findViewById(R.id.expweight_table); - TableRow etr_head = new TableRow(this); - etr_head.setBackgroundColor(Color.DKGRAY); - etr_head.setLayoutParams(new TableLayout.LayoutParams( - TableLayout.LayoutParams.MATCH_PARENT, - TableLayout.LayoutParams.WRAP_CONTENT)); - - TextView label_exp_weight = new TextView(this); - label_exp_weight.setText(resourceHelper.gs(R.string.weight)); - label_exp_weight.setTextColor(Color.WHITE); - etr_head.addView(label_exp_weight); - - TextView label_exp_tdd = new TextView(this); - label_exp_tdd.setText(resourceHelper.gs(R.string.tdd)); - label_exp_tdd.setTextColor(Color.WHITE); - etr_head.addView(label_exp_tdd); - - TextView label_exp_ratio = new TextView(this); - label_exp_ratio.setText(resourceHelper.gs(R.string.ratio)); - label_exp_ratio.setTextColor(Color.WHITE); - etr_head.addView(label_exp_ratio); - - // add expontial headers to tables - etl.addView(etr_head, new TableLayout.LayoutParams( - TableLayout.LayoutParams.MATCH_PARENT, - TableLayout.LayoutParams.WRAP_CONTENT)); - - reloadButton.setOnClickListener(v -> { - runOnUiThread(() -> { - reloadButton.setVisibility(View.GONE); - statusView.setVisibility(View.VISIBLE); - statsMessage.setVisibility(View.VISIBLE); - statsMessage.setText(resourceHelper.gs(R.string.warning_Message)); - }); - commandQueue.loadTDDs(new Callback() { - @Override - public void run() { - loadDataFromDB(); - runOnUiThread(() -> { - reloadButton.setVisibility(View.VISIBLE); - statusView.setVisibility(View.GONE); - statsMessage.setVisibility(View.GONE); - }); - } - }); - }); - - totalBaseBasal.setOnEditorActionListener((v, actionId, event) -> { - if (actionId == EditorInfo.IME_ACTION_DONE) { - totalBaseBasal.clearFocus(); - return true; - } - return false; - }); - - totalBaseBasal.setOnFocusChangeListener((v, hasFocus) -> { - if (hasFocus) { - totalBaseBasal.getText().clear(); - } else { - sp.putString("TBB", totalBaseBasal.getText().toString()); - TBB = sp.getString("TBB", ""); - loadDataFromDB(); - InputMethodManager imm = (InputMethodManager) getSystemService(INPUT_METHOD_SERVICE); - imm.hideSoftInputFromWindow(totalBaseBasal.getWindowToken(), 0); - } - }); - - loadDataFromDB(); - } - - private void loadDataFromDB() { - historyList = databaseHelper.getTDDs(); - - //only use newest 10 - historyList = historyList.subList(0, Math.min(10, historyList.size())); - - //fill single gaps - dummies = new LinkedList<>(); - DateFormat df = new SimpleDateFormat("dd.MM.", Locale.getDefault()); - for (int i = 0; i < historyList.size() - 1; i++) { - TDD elem1 = historyList.get(i); - TDD elem2 = historyList.get(i + 1); - - if (!df.format(new Date(elem1.date)).equals(df.format(new Date(elem2.date + 25 * 60 * 60 * 1000)))) { - TDD dummy = new TDD(); - dummy.date = elem1.date - 24 * 60 * 60 * 1000; - dummy.basal = elem1.basal / 2; - dummy.bolus = elem1.bolus / 2; - dummies.add(dummy); - elem1.basal /= 2; - elem1.bolus /= 2; - } - } - historyList.addAll(dummies); - Collections.sort(historyList, (lhs, rhs) -> (int) (rhs.date - lhs.date)); - - runOnUiThread(() -> { - cleanTable(tl); - cleanTable(ctl); - cleanTable(etl); - DateFormat df1 = new SimpleDateFormat("dd.MM.", Locale.getDefault()); - - if (TextUtils.isEmpty(TBB)) { - totalBaseBasal.setError("Please Enter Total Base Basal"); - return; - } else { - magicNumber = SafeParse.stringToDouble(TBB); - } - - magicNumber *= 2; - totalBaseBasal2.setText(decimalFormat.format(magicNumber)); - - int i = 0; - double sum = 0d; - double weighted03 = 0d; - double weighted05 = 0d; - double weighted07 = 0d; - - - //TDD table - for (TDD record : historyList) { - double tdd = record.getTotal(); - - // Create the table row - TableRow tr = new TableRow(TDDStatsActivity.this); - if (i % 2 != 0) tr.setBackgroundColor(Color.DKGRAY); - if (dummies.contains(record)) { - tr.setBackgroundColor(Color.argb(125, 255, 0, 0)); - } - tr.setId(100 + i); - tr.setLayoutParams(new TableLayout.LayoutParams( - TableLayout.LayoutParams.MATCH_PARENT, - TableLayout.LayoutParams.WRAP_CONTENT)); - - // Here create the TextView dynamically - TextView labelDATE = new TextView(TDDStatsActivity.this); - labelDATE.setId(200 + i); - labelDATE.setText(df1.format(new Date(record.date))); - labelDATE.setTextColor(Color.WHITE); - tr.addView(labelDATE); - - TextView labelBASAL = new TextView(TDDStatsActivity.this); - labelBASAL.setId(300 + i); - labelBASAL.setText(resourceHelper.gs(R.string.formatinsulinunits, record.basal)); - labelBASAL.setTextColor(Color.WHITE); - tr.addView(labelBASAL); - - TextView labelBOLUS = new TextView(TDDStatsActivity.this); - labelBOLUS.setId(400 + i); - labelBOLUS.setText(resourceHelper.gs(R.string.formatinsulinunits, record.bolus)); - labelBOLUS.setTextColor(Color.WHITE); - tr.addView(labelBOLUS); - - TextView labelTDD = new TextView(TDDStatsActivity.this); - labelTDD.setId(500 + i); - labelTDD.setText(resourceHelper.gs(R.string.formatinsulinunits, tdd)); - labelTDD.setTextColor(Color.WHITE); - tr.addView(labelTDD); - - TextView labelRATIO = new TextView(TDDStatsActivity.this); - labelRATIO.setId(600 + i); - labelRATIO.setText(Math.round(100 * tdd / magicNumber) + "%"); - labelRATIO.setTextColor(Color.WHITE); - tr.addView(labelRATIO); - - // add stats rows to tables - tl.addView(tr, new TableLayout.LayoutParams( - TableLayout.LayoutParams.MATCH_PARENT, - TableLayout.LayoutParams.WRAP_CONTENT)); - - i++; - } - - i = 0; - - //cumulative TDDs - for (TDD record : historyList) { - if (!historyList.isEmpty() && df1.format(new Date(record.date)).equals(df1.format(new Date()))) { - //Today should not be included - continue; - } - i++; - - sum = sum + record.getTotal(); - - // Create the cumtable row - TableRow ctr = new TableRow(TDDStatsActivity.this); - if (i % 2 == 0) ctr.setBackgroundColor(Color.DKGRAY); - ctr.setId(700 + i); - ctr.setLayoutParams(new TableLayout.LayoutParams( - TableLayout.LayoutParams.MATCH_PARENT, - TableLayout.LayoutParams.WRAP_CONTENT)); - - // Here create the TextView dynamically - TextView labelDAYS = new TextView(TDDStatsActivity.this); - labelDAYS.setId(800 + i); - labelDAYS.setText("" + i); - labelDAYS.setTextColor(Color.WHITE); - ctr.addView(labelDAYS); - - TextView labelCUMTDD = new TextView(TDDStatsActivity.this); - labelCUMTDD.setId(900 + i); - labelCUMTDD.setText(resourceHelper.gs(R.string.formatinsulinunits, sum / i)); - labelCUMTDD.setTextColor(Color.WHITE); - ctr.addView(labelCUMTDD); - - TextView labelCUMRATIO = new TextView(TDDStatsActivity.this); - labelCUMRATIO.setId(1000 + i); - labelCUMRATIO.setText(Math.round(100 * sum / i / magicNumber) + "%"); - labelCUMRATIO.setTextColor(Color.WHITE); - ctr.addView(labelCUMRATIO); - - // add cummulative rows to tables - ctl.addView(ctr, new TableLayout.LayoutParams( - TableLayout.LayoutParams.MATCH_PARENT, - TableLayout.LayoutParams.WRAP_CONTENT)); - } - - if (isOldData(historyList) && activePlugin.getActivePump().getPumpDescription().needsManualTDDLoad) { - statsMessage.setVisibility(View.VISIBLE); - statsMessage.setText(resourceHelper.gs(R.string.olddata_Message)); - - } else { - tl.setBackgroundColor(Color.TRANSPARENT); - } - - if (!historyList.isEmpty() && df1.format(new Date(historyList.get(0).date)).equals(df1.format(new Date()))) { - //Today should not be included - historyList.remove(0); - } - - Collections.reverse(historyList); - - i = 0; - - for (TDD record : historyList) { - double tdd = record.getTotal(); - if (i == 0) { - weighted03 = tdd; - weighted05 = tdd; - weighted07 = tdd; - - } else { - weighted07 = (weighted07 * 0.3 + tdd * 0.7); - weighted05 = (weighted05 * 0.5 + tdd * 0.5); - weighted03 = (weighted03 * 0.7 + tdd * 0.3); - } - i++; - } - - // Create the exptable row - TableRow etr = new TableRow(TDDStatsActivity.this); - if (i % 2 != 0) etr.setBackgroundColor(Color.DKGRAY); - etr.setId(1100 + i); - etr.setLayoutParams(new TableLayout.LayoutParams( - TableLayout.LayoutParams.MATCH_PARENT, - TableLayout.LayoutParams.WRAP_CONTENT)); - - // Here create the TextView dynamically - TextView labelWEIGHT = new TextView(TDDStatsActivity.this); - labelWEIGHT.setId(1200 + i); - labelWEIGHT.setText("0.3\n" + "0.5\n" + "0.7"); - labelWEIGHT.setTextColor(Color.WHITE); - etr.addView(labelWEIGHT); - - TextView labelEXPTDD = new TextView(TDDStatsActivity.this); - labelEXPTDD.setId(1300 + i); - labelEXPTDD.setText(resourceHelper.gs(R.string.formatinsulinunits, weighted03) + "\n" + - resourceHelper.gs(R.string.formatinsulinunits, weighted05) + "\n" + - resourceHelper.gs(R.string.formatinsulinunits, weighted07)); - labelEXPTDD.setTextColor(Color.WHITE); - etr.addView(labelEXPTDD); - - TextView labelEXPRATIO = new TextView(TDDStatsActivity.this); - labelEXPRATIO.setId(1400 + i); - labelEXPRATIO.setText(Math.round(100 * weighted03 / magicNumber) + "%\n" - + Math.round(100 * weighted05 / magicNumber) + "%\n" - + Math.round(100 * weighted07 / magicNumber) + "%"); - labelEXPRATIO.setTextColor(Color.WHITE); - etr.addView(labelEXPRATIO); - - // add exponentail rows to tables - etl.addView(etr, new TableLayout.LayoutParams( - TableLayout.LayoutParams.MATCH_PARENT, - TableLayout.LayoutParams.WRAP_CONTENT)); - }); - } - - private void cleanTable(TableLayout table) { - int childCount = table.getChildCount(); - // Remove all rows except the first one - if (childCount > 1) { - table.removeViews(1, childCount - 1); - } - } - - public boolean isOldData(List historyList) { - - PumpType type = activePlugin.getActivePump().getPumpDescription().pumpType; - boolean startsYesterday = type == PumpType.DanaR || type == PumpType.DanaRS || type == PumpType.DanaRv2 || type == PumpType.DanaRKorean || type == PumpType.AccuChekInsight; - - DateFormat df = new SimpleDateFormat("dd.MM.", Locale.getDefault()); - return (historyList.size() < 3 || !(df.format(new Date(historyList.get(0).date)).equals(df.format(new Date(System.currentTimeMillis() - (startsYesterday ? 1000 * 60 * 60 * 24 : 0)))))); - } -} \ No newline at end of file diff --git a/core/src/main/java/info/nightscout/androidaps/activities/TDDStatsActivity.kt b/core/src/main/java/info/nightscout/androidaps/activities/TDDStatsActivity.kt new file mode 100644 index 0000000000..ba650bace7 --- /dev/null +++ b/core/src/main/java/info/nightscout/androidaps/activities/TDDStatsActivity.kt @@ -0,0 +1,429 @@ +package info.nightscout.androidaps.activities + +import android.annotation.SuppressLint +import android.graphics.Color +import android.graphics.Rect +import android.os.Bundle +import android.text.TextUtils +import android.view.KeyEvent +import android.view.MotionEvent +import android.view.View +import android.view.WindowManager +import android.view.inputmethod.EditorInfo +import android.view.inputmethod.InputMethodManager +import android.widget.EditText +import android.widget.TableLayout +import android.widget.TableRow +import android.widget.TextView +import info.nightscout.androidaps.core.R +import info.nightscout.androidaps.core.databinding.ActivityTddStatsBinding +import info.nightscout.androidaps.db.TDD +import info.nightscout.androidaps.events.EventDanaRSyncStatus +import info.nightscout.androidaps.events.EventPumpStatusChanged +import info.nightscout.androidaps.interfaces.ActivePluginProvider +import info.nightscout.androidaps.interfaces.CommandQueueProvider +import info.nightscout.androidaps.interfaces.DatabaseHelperInterface +import info.nightscout.androidaps.interfaces.ProfileFunction +import info.nightscout.androidaps.logging.AAPSLogger +import info.nightscout.androidaps.plugins.bus.RxBusWrapper +import info.nightscout.androidaps.plugins.pump.common.defs.PumpType +import info.nightscout.androidaps.queue.Callback +import info.nightscout.androidaps.utils.FabricPrivacy +import info.nightscout.androidaps.utils.SafeParse +import info.nightscout.androidaps.utils.rx.AapsSchedulers +import info.nightscout.androidaps.utils.sharedPreferences.SP +import io.reactivex.disposables.CompositeDisposable +import java.text.DateFormat +import java.text.DecimalFormat +import java.text.SimpleDateFormat +import java.util.* +import javax.inject.Inject +import kotlin.math.min +import kotlin.math.roundToInt + +class TDDStatsActivity : NoSplashAppCompatActivity() { + + @Inject lateinit var aapsLogger: AAPSLogger + @Inject lateinit var rxBus: RxBusWrapper + @Inject lateinit var sp: SP + @Inject lateinit var profileFunction: ProfileFunction + @Inject lateinit var activePlugin: ActivePluginProvider + @Inject lateinit var commandQueue: CommandQueueProvider + @Inject lateinit var databaseHelper: DatabaseHelperInterface + @Inject lateinit var fabricPrivacy: FabricPrivacy + @Inject lateinit var aapsSchedulers: AapsSchedulers + + private lateinit var binding: ActivityTddStatsBinding + private val disposable = CompositeDisposable() + + lateinit var tbb: String + private var magicNumber = 0.0 + private var decimalFormat: DecimalFormat = DecimalFormat("0.000") + private var historyList: MutableList = mutableListOf() + private var dummies: MutableList = mutableListOf() + + override fun onCreate(savedInstanceState: Bundle?) { + super.onCreate(savedInstanceState) + binding = ActivityTddStatsBinding.inflate(layoutInflater) + setContentView(binding.root) + + window.setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_PAN) + binding.connectionStatus.visibility = View.GONE + binding.message.visibility = View.GONE + binding.totalBaseBasal2.isEnabled = false + binding.totalBaseBasal2.isClickable = false + binding.totalBaseBasal2.isFocusable = false + binding.totalBaseBasal2.inputType = 0 + tbb = sp.getString("TBB", "10.00") + val profile = profileFunction.getProfile() + if (profile != null) { + val cppTBB = profile.baseBasalSum() + tbb = decimalFormat.format(cppTBB) + sp.putString("TBB", tbb) + } + binding.totalBaseBasal.setText(tbb) + if (!activePlugin.activePump.pumpDescription.needsManualTDDLoad) binding.reload.visibility = View.GONE + + // stats table + + // add stats headers to tables + binding.mainTable.addView( + TableRow(this).also { trHead -> + trHead.setBackgroundColor(Color.DKGRAY) + trHead.layoutParams = TableLayout.LayoutParams(TableLayout.LayoutParams.MATCH_PARENT, TableLayout.LayoutParams.WRAP_CONTENT) + trHead.addView(TextView(this).also { labelDate -> + labelDate.text = resourceHelper.gs(R.string.date) + labelDate.setTextColor(Color.WHITE) + }) + trHead.addView(TextView(this).also { labelBasalRate -> + labelBasalRate.text = resourceHelper.gs(R.string.basalrate) + labelBasalRate.setTextColor(Color.WHITE) + }) + trHead.addView(TextView(this).also { labelBolus -> + labelBolus.text = resourceHelper.gs(R.string.bolus) + labelBolus.setTextColor(Color.WHITE) + }) + trHead.addView(TextView(this).also { labelTdd -> + labelTdd.text = resourceHelper.gs(R.string.tdd) + labelTdd.setTextColor(Color.WHITE) + }) + trHead.addView(TextView(this).also { labelRatio -> + labelRatio.text = resourceHelper.gs(R.string.ratio) + labelRatio.setTextColor(Color.WHITE) + }) + }, TableLayout.LayoutParams(TableLayout.LayoutParams.MATCH_PARENT, TableLayout.LayoutParams.WRAP_CONTENT) + ) + + // cumulative table + binding.cumulativeTable.addView( + TableRow(this).also { ctrHead -> + ctrHead.setBackgroundColor(Color.DKGRAY) + ctrHead.layoutParams = TableLayout.LayoutParams(TableLayout.LayoutParams.MATCH_PARENT, TableLayout.LayoutParams.WRAP_CONTENT) + ctrHead.addView(TextView(this).also { labelCumAmountDays -> + labelCumAmountDays.text = resourceHelper.gs(R.string.amount_days) + labelCumAmountDays.setTextColor(Color.WHITE) + }) + ctrHead.addView(TextView(this).also { labelCumTdd -> + labelCumTdd.text = resourceHelper.gs(R.string.tdd) + labelCumTdd.setTextColor(Color.WHITE) + }) + ctrHead.addView(TextView(this).also { labelCumRatio -> + labelCumRatio.text = resourceHelper.gs(R.string.ratio) + labelCumRatio.setTextColor(Color.WHITE) + }) + }, TableLayout.LayoutParams(TableLayout.LayoutParams.MATCH_PARENT, TableLayout.LayoutParams.WRAP_CONTENT) + ) + + // exponential table + binding.expweightTable.addView( + TableRow(this).also { etrHead -> + etrHead.setBackgroundColor(Color.DKGRAY) + etrHead.layoutParams = TableLayout.LayoutParams(TableLayout.LayoutParams.MATCH_PARENT, TableLayout.LayoutParams.WRAP_CONTENT) + etrHead.addView(TextView(this).also { labelExpWeight -> + labelExpWeight.text = resourceHelper.gs(R.string.weight) + labelExpWeight.setTextColor(Color.WHITE) + }) + etrHead.addView(TextView(this).also { labelExpTdd -> + labelExpTdd.text = resourceHelper.gs(R.string.tdd) + labelExpTdd.setTextColor(Color.WHITE) + }) + etrHead.addView(TextView(this).also { labelExpRatio -> + labelExpRatio.text = resourceHelper.gs(R.string.ratio) + labelExpRatio.setTextColor(Color.WHITE) + }) + }, TableLayout.LayoutParams(TableLayout.LayoutParams.MATCH_PARENT, TableLayout.LayoutParams.WRAP_CONTENT) + ) + + binding.reload.setOnClickListener { + binding.reload.visibility = View.GONE + binding.connectionStatus.visibility = View.VISIBLE + binding.message.visibility = View.VISIBLE + binding.message.text = resourceHelper.gs(R.string.warning_Message) + commandQueue.loadTDDs(object : Callback() { + override fun run() { + loadDataFromDB() + runOnUiThread { + binding.reload.visibility = View.VISIBLE + binding.connectionStatus.visibility = View.GONE + binding.message.visibility = View.GONE + } + } + }) + } + binding.totalBaseBasal.setOnEditorActionListener { _: TextView?, actionId: Int, _: KeyEvent? -> + if (actionId == EditorInfo.IME_ACTION_DONE) { + binding.totalBaseBasal.clearFocus() + return@setOnEditorActionListener true + } + false + } + binding.totalBaseBasal.setOnFocusChangeListener { _: View?, hasFocus: Boolean -> + if (hasFocus) { + binding.totalBaseBasal.text.clear() + } else { + sp.putString("TBB", binding.totalBaseBasal.text.toString()) + tbb = sp.getString("TBB", "") + loadDataFromDB() + val imm = getSystemService(INPUT_METHOD_SERVICE) as InputMethodManager + imm.hideSoftInputFromWindow(binding.totalBaseBasal.windowToken, 0) + } + } + loadDataFromDB() + } + + override fun onResume() { + super.onResume() + disposable.add(rxBus + .toObservable(EventPumpStatusChanged::class.java) + .observeOn(aapsSchedulers.main) + .subscribe({ event -> binding.connectionStatus.text = event.getStatus(resourceHelper) }, fabricPrivacy::logException) + ) + disposable.add(rxBus + .toObservable(EventDanaRSyncStatus::class.java) + .observeOn(aapsSchedulers.main) + .subscribe({ event -> + aapsLogger.debug("EventDanaRSyncStatus: " + event.message) + binding.connectionStatus.text = event.message + }, fabricPrivacy::logException) + ) + } + + override fun onPause() { + super.onPause() + disposable.clear() + } + + override fun dispatchTouchEvent(event: MotionEvent): Boolean { + if (event.action == MotionEvent.ACTION_DOWN) { + val myView = currentFocus + if (myView is EditText) { + val rect = Rect() + myView.getGlobalVisibleRect(rect) + if (!rect.contains(event.rawX.toInt(), event.rawY.toInt())) { + myView.clearFocus() + } + } + } + return super.dispatchTouchEvent(event) + } + + @SuppressLint("SetTextI18n") + private fun loadDataFromDB() { + historyList.clear() + historyList.addAll(databaseHelper.getTDDs()) + + //only use newest 10 + historyList = historyList.subList(0, min(10, historyList.size)) + + //fill single gaps + val df: DateFormat = SimpleDateFormat("dd.MM.", Locale.getDefault()) + for (i in 0 until historyList.size - 1) { + val elem1 = historyList[i] + val elem2 = historyList[i + 1] + if (df.format(Date(elem1.date)) != df.format(Date(elem2.date + 25 * 60 * 60 * 1000))) { + val dummy = TDD() + dummy.date = elem1.date - 24 * 60 * 60 * 1000 + dummy.basal = elem1.basal / 2 + dummy.bolus = elem1.bolus / 2 + dummies.add(dummy) + elem1.basal /= 2.0 + elem1.bolus /= 2.0 + } + } + historyList.addAll(dummies) + historyList.sortWith { lhs: TDD, rhs: TDD -> (rhs.date - lhs.date).toInt() } + runOnUiThread { + cleanTable(binding.mainTable) + cleanTable(binding.cumulativeTable) + cleanTable(binding.expweightTable) + val df1: DateFormat = SimpleDateFormat("dd.MM.", Locale.getDefault()) + if (TextUtils.isEmpty(tbb)) { + binding.totalBaseBasal.error = "Please Enter Total Base Basal" + return@runOnUiThread + } else { + magicNumber = SafeParse.stringToDouble(tbb) + } + magicNumber *= 2.0 + binding.totalBaseBasal2.text = decimalFormat.format(magicNumber) + var i = 0 + var sum = 0.0 + var weighted03 = 0.0 + var weighted05 = 0.0 + var weighted07 = 0.0 + + //TDD table + for (record in historyList) { + val tdd = record.getTotal() + + // Create the table row + binding.mainTable.addView( + TableRow(this@TDDStatsActivity).also { tr -> + if (i % 2 != 0) tr.setBackgroundColor(Color.DKGRAY) + if (dummies.contains(record)) + tr.setBackgroundColor(Color.argb(125, 255, 0, 0)) + + tr.id = 100 + i + tr.layoutParams = TableLayout.LayoutParams( + TableLayout.LayoutParams.MATCH_PARENT, + TableLayout.LayoutParams.WRAP_CONTENT) + + // Here create the TextView dynamically + tr.addView(TextView(this@TDDStatsActivity).also { labelDATE -> + labelDATE.id = 200 + i + labelDATE.text = df1.format(Date(record.date)) + labelDATE.setTextColor(Color.WHITE) + }) + tr.addView(TextView(this@TDDStatsActivity).also { labelBASAL -> + labelBASAL.id = 300 + i + labelBASAL.text = resourceHelper.gs(R.string.formatinsulinunits, record.basal) + labelBASAL.setTextColor(Color.WHITE) + }) + tr.addView(TextView(this@TDDStatsActivity).also { labelBOLUS -> + labelBOLUS.id = 400 + i + labelBOLUS.text = resourceHelper.gs(R.string.formatinsulinunits, record.bolus) + labelBOLUS.setTextColor(Color.WHITE) + }) + tr.addView(TextView(this@TDDStatsActivity).also { labelTDD -> + labelTDD.id = 500 + i + labelTDD.text = resourceHelper.gs(R.string.formatinsulinunits, tdd) + labelTDD.setTextColor(Color.WHITE) + }) + tr.addView(TextView(this@TDDStatsActivity).also { labelRATIO -> + labelRATIO.id = 600 + i + labelRATIO.text = (100 * tdd / magicNumber).roundToInt().toString() + "%" + labelRATIO.setTextColor(Color.WHITE) + }) + }, TableLayout.LayoutParams(TableLayout.LayoutParams.MATCH_PARENT, TableLayout.LayoutParams.WRAP_CONTENT)) + i++ + } + i = 0 + + //cumulative TDDs + for (record in historyList) { + if (historyList.isNotEmpty() && df1.format(Date(record.date)) == df1.format(Date())) + //Today should not be included + continue + i++ + sum += record.getTotal() + + // Create the cumulative table row + binding.cumulativeTable.addView( + TableRow(this@TDDStatsActivity).also { ctr -> + if (i % 2 == 0) ctr.setBackgroundColor(Color.DKGRAY) + ctr.id = 700 + i + ctr.layoutParams = TableLayout.LayoutParams(TableLayout.LayoutParams.MATCH_PARENT, TableLayout.LayoutParams.WRAP_CONTENT) + + // Here create the TextView dynamically + ctr.addView(TextView(this@TDDStatsActivity).also { labelDAYS -> + labelDAYS.id = 800 + i + labelDAYS.text = i.toString() + labelDAYS.setTextColor(Color.WHITE) + }) + + ctr.addView(TextView(this@TDDStatsActivity).also { labelCUMTDD -> + labelCUMTDD.id = 900 + i + labelCUMTDD.text = resourceHelper.gs(R.string.formatinsulinunits, sum / i) + labelCUMTDD.setTextColor(Color.WHITE) + }) + + ctr.addView(TextView(this@TDDStatsActivity).also { labelCUMRATIO -> + labelCUMRATIO.id = 1000 + i + labelCUMRATIO.text = (100 * sum / i / magicNumber).roundToInt().toString() + "%" + labelCUMRATIO.setTextColor(Color.WHITE) + }) + }, TableLayout.LayoutParams(TableLayout.LayoutParams.MATCH_PARENT, TableLayout.LayoutParams.WRAP_CONTENT) + ) + } + if (isOldData(historyList) && activePlugin.activePump.pumpDescription.needsManualTDDLoad) { + binding.message.visibility = View.VISIBLE + binding.message.text = resourceHelper.gs(R.string.olddata_Message) + } else binding.mainTable.setBackgroundColor(Color.TRANSPARENT) + if (historyList.isNotEmpty() && df1.format(Date(historyList[0].date)) == df1.format(Date())) { + //Today should not be included + historyList.removeAt(0) + } + historyList.reverse() + i = 0 + for (record in historyList) { + val tdd = record.getTotal() + if (i == 0) { + weighted03 = tdd + weighted05 = tdd + weighted07 = tdd + } else { + weighted07 = weighted07 * 0.3 + tdd * 0.7 + weighted05 = weighted05 * 0.5 + tdd * 0.5 + weighted03 = weighted03 * 0.7 + tdd * 0.3 + } + i++ + } + + // Create the exponential table row + binding.expweightTable.addView( + TableRow(this@TDDStatsActivity).also { etr -> + if (i % 2 != 0) etr.setBackgroundColor(Color.DKGRAY) + etr.id = 1100 + i + etr.layoutParams = TableLayout.LayoutParams(TableLayout.LayoutParams.MATCH_PARENT, TableLayout.LayoutParams.WRAP_CONTENT) + + // Here create the TextView dynamically + etr.addView(TextView(this@TDDStatsActivity).also { labelWEIGHT -> + labelWEIGHT.id = 1200 + i + labelWEIGHT.text = "0.3\n0.5\n0.7" + labelWEIGHT.setTextColor(Color.WHITE) + }) + etr.addView(TextView(this@TDDStatsActivity).also { labelEXPTDD -> + labelEXPTDD.id = 1300 + i + labelEXPTDD.text = """ + ${resourceHelper.gs(R.string.formatinsulinunits, weighted03)} + ${resourceHelper.gs(R.string.formatinsulinunits, weighted05)} + ${resourceHelper.gs(R.string.formatinsulinunits, weighted07)} + """.trimIndent() + labelEXPTDD.setTextColor(Color.WHITE) + }) + etr.addView(TextView(this@TDDStatsActivity).also { labelEXPRATIO -> + labelEXPRATIO.id = 1400 + i + labelEXPRATIO.text = """ + ${(100 * weighted03 / magicNumber).roundToInt()}% + ${(100 * weighted05 / magicNumber).roundToInt()}% + ${(100 * weighted07 / magicNumber).roundToInt()}% + """.trimIndent() + labelEXPRATIO.setTextColor(Color.WHITE) + }) + }, TableLayout.LayoutParams(TableLayout.LayoutParams.MATCH_PARENT, TableLayout.LayoutParams.WRAP_CONTENT) + ) + } + } + + private fun cleanTable(table: TableLayout) { + val childCount = table.childCount + // Remove all rows except the first one + if (childCount > 1) table.removeViews(1, childCount - 1) + } + + private fun isOldData(historyList: List): Boolean { + val type = activePlugin.activePump.pumpDescription.pumpType + val startsYesterday = type == PumpType.DanaR || type == PumpType.DanaRS || type == PumpType.DanaRv2 || type == PumpType.DanaRKorean || type == PumpType.AccuChekInsight + val df: DateFormat = SimpleDateFormat("dd.MM.", Locale.getDefault()) + return historyList.size < 3 || df.format(Date(historyList[0].date)) != df.format(Date(System.currentTimeMillis() - if (startsYesterday) 1000 * 60 * 60 * 24 else 0)) + } +} \ No newline at end of file diff --git a/core/src/main/res/layout/danar_statsactivity.xml b/core/src/main/res/layout/activity_tdd_stats.xml similarity index 58% rename from core/src/main/res/layout/danar_statsactivity.xml rename to core/src/main/res/layout/activity_tdd_stats.xml index 3b19dcc30d..f7967bfebf 100644 --- a/core/src/main/res/layout/danar_statsactivity.xml +++ b/core/src/main/res/layout/activity_tdd_stats.xml @@ -3,14 +3,15 @@ xmlns:tools="http://schemas.android.com/tools" android:layout_width="fill_parent" android:layout_height="fill_parent" - android:paddingBottom="@dimen/activity_vertical_margin" android:paddingTop="@dimen/activity_vertical_margin" + android:paddingBottom="@dimen/activity_vertical_margin" tools:context="info.nightscout.androidaps.activities.TDDStatsActivity"> + + android:gravity="center_horizontal" + android:text="@string/tdd" + android:textColor="@color/mdtp_white" /> - + android:layout_weight="1" + android:stretchColumns="0,1,2,3,4" /> + android:layout_weight="1" + android:orientation="horizontal"> + android:layout_height="wrap_content" + android:orientation="vertical"> + android:text="@string/cumulative_tdd" + android:textColor="@color/mdtp_white" /> + android:layout_height="0dp" + android:layout_weight="1" + android:stretchColumns="0,1,2"> @@ -71,78 +71,78 @@ android:layout_height="10dp" /> + android:focusableInTouchMode="true" + android:orientation="vertical"> + android:gravity="center_horizontal" + android:text="@string/expweight" + android:textColor="@color/mdtp_white" /> - + android:layout_height="0dp" + android:layout_weight="1" + android:stretchColumns="0,1,2" /> + android:layout_height="match_parent" + android:orientation="horizontal"> + android:labelFor="@+id/total_base_basal" + android:text="@string/tbb" /> + android:gravity="center_vertical|center_horizontal" + android:inputType="numberDecimal" + android:textAppearance="?android:attr/textAppearanceMedium" + android:textColor="@color/mdtp_white" /> + android:layout_height="match_parent" + android:orientation="horizontal"> + android:labelFor="@+id/total_base_basal_2" + android:text="@string/tbb2" /> + android:textAppearance="?android:attr/textAppearanceMedium" + android:textColor="@color/mdtp_white" /> @@ -150,52 +150,47 @@ + + android:gravity="center_horizontal" + android:orientation="vertical"> - + + + android:layout_height="wrap_content" + android:layout_gravity="center_horizontal" + android:background="@drawable/pillborder" + android:paddingLeft="10dp" + android:paddingRight="10dp" + android:text="@string/warning_Message" + android:textColor="#ff0000" + android:textSize="15sp" + android:textStyle="bold" /> - + - + - - -