From a3de99b993d481219a4e64948f06a54563cabde1 Mon Sep 17 00:00:00 2001 From: Theo van Elsberg Date: Sun, 3 Jul 2022 19:36:46 +0200 Subject: [PATCH 01/39] Fixing on problem introduced by fixing "Fake TBR": wipe pod adsress on Discard but keep state object --- .../driver/manager/ErosPodStateManager.java | 22 +++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/omnipod-eros/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/eros/driver/manager/ErosPodStateManager.java b/omnipod-eros/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/eros/driver/manager/ErosPodStateManager.java index 27eb849931..caa6d72f4d 100644 --- a/omnipod-eros/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/eros/driver/manager/ErosPodStateManager.java +++ b/omnipod-eros/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/eros/driver/manager/ErosPodStateManager.java @@ -49,24 +49,38 @@ public abstract class ErosPodStateManager { this.gsonInstance = createGson(); } + /** + * Discard Pod state + */ public final void discardState() { - this.podState = new PodState(this.podState.address); + // Change on commit 4cea57acf6d74baffef83e1f04376b10bb5c1978 Nov 2021 + // As by commit, keep podState object but wipe address to 0x0 to signal hasPodState() + // there is no state ( = no Pod address). + this.podState = new PodState(0x0); storePodState(); } + /** + * Init Pod state but only if it has valid state. + * @param address New Pod address + */ public final void initState(int address) { if (hasPodState()) { - throw new IllegalStateException("Can not init a new pod state: podState <> null"); + throw new IllegalStateException("Can not init a new pod state: State is " + + "null or discarded?"); } podState = new PodState(address); storePodState(); } /** - * @return true if we have a Pod state (which at least contains an address), indicating it is legal to call getters on PodStateManager + * @return true if we have a Pod state (which at least contains an valid address), indicating + * it is legal to call getters on PodStateManager */ public final boolean hasPodState() { - return podState != null; + + return this.podState != null + && this.podState.getAddress() != 0x0; // 0x0=discarded } /** From e344ecae205032760ce4cc109212faba7f1d3256 Mon Sep 17 00:00:00 2001 From: Andries Smit Date: Mon, 4 Jul 2022 10:22:42 +0200 Subject: [PATCH 02/39] feat: add tdd stats today --- .../androidaps/utils/stats/TddCalculator.kt | 22 ++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/app/src/main/java/info/nightscout/androidaps/utils/stats/TddCalculator.kt b/app/src/main/java/info/nightscout/androidaps/utils/stats/TddCalculator.kt index e07e492e9a..f9b7ba509a 100644 --- a/app/src/main/java/info/nightscout/androidaps/utils/stats/TddCalculator.kt +++ b/app/src/main/java/info/nightscout/androidaps/utils/stats/TddCalculator.kt @@ -1,6 +1,5 @@ package info.nightscout.androidaps.utils.stats -import android.annotation.SuppressLint import android.content.Context import android.graphics.Typeface import android.util.LongSparseArray @@ -99,9 +98,19 @@ class TddCalculator @Inject constructor( return result } + fun calculateToday(): TotalDailyDose { + var startTime = MidnightTime.calc(dateUtil.now()) + val endTime = dateUtil.now() + return calculate(startTime, endTime) + } + fun calculateDaily(startHours: Long, endHours: Long): TotalDailyDose { val startTime = dateUtil.now() + T.hours(hour = startHours).msecs() val endTime = dateUtil.now() + T.hours(hour = endHours).msecs() + return calculate(startTime, endTime) + } + + fun calculate(startTime: Long, endTime: Long): TotalDailyDose { val tdd = TotalDailyDose(timestamp = startTime) repository.getBolusesDataFromTimeToTime(startTime, endTime, true).blockingGet() .filter { it.type != Bolus.Type.PRIMING } @@ -147,10 +156,10 @@ class TddCalculator @Inject constructor( return totalTdd } - @SuppressLint("SetTextI18n") fun stats(context: Context): TableLayout { val tdds = calculate(7) val averageTdd = averageTDD(tdds) + val todayTdd = calculateToday() val lp = TableRow.LayoutParams(TableRow.LayoutParams.WRAP_CONTENT, TableRow.LayoutParams.WRAP_CONTENT) return TableLayout(context).also { layout -> layout.layoutParams = TableLayout.LayoutParams(0, ViewGroup.LayoutParams.WRAP_CONTENT, 1f) @@ -172,6 +181,13 @@ class TddCalculator @Inject constructor( }) layout.addView(averageTdd.toTableRow(context, rh, tdds.size(), includeCarbs = true)) } + layout.addView(TextView(context).apply { + text = rh.gs(R.string.today) + setTypeface(typeface, Typeface.BOLD) + gravity = Gravity.CENTER_HORIZONTAL + setTextAppearance(android.R.style.TextAppearance_Material_Medium) + }) + layout.addView(todayTdd.toTableRow(context, rh, dateUtil, includeCarbs = true)) } } -} \ No newline at end of file +} From fb4276f461bc654683340b6474ec0f51f16cf879 Mon Sep 17 00:00:00 2001 From: Andries Smit Date: Mon, 4 Jul 2022 16:32:31 +0200 Subject: [PATCH 03/39] fix: remove tint light theme action icons --- app/src/main/res/drawable/ic_sort.xml | 1 - core/src/main/res/drawable/ic_close.xml | 3 +-- core/src/main/res/drawable/ic_sort.xml | 1 - 3 files changed, 1 insertion(+), 4 deletions(-) diff --git a/app/src/main/res/drawable/ic_sort.xml b/app/src/main/res/drawable/ic_sort.xml index 4b1317ac20..8ff707c8ca 100644 --- a/app/src/main/res/drawable/ic_sort.xml +++ b/app/src/main/res/drawable/ic_sort.xml @@ -2,7 +2,6 @@ android:width="24dp" android:height="24dp" android:autoMirrored="true" - android:tint="#FFFFFF" android:viewportWidth="24" android:viewportHeight="24"> diff --git a/core/src/main/res/drawable/ic_sort.xml b/core/src/main/res/drawable/ic_sort.xml index 4b1317ac20..8ff707c8ca 100644 --- a/core/src/main/res/drawable/ic_sort.xml +++ b/core/src/main/res/drawable/ic_sort.xml @@ -2,7 +2,6 @@ android:width="24dp" android:height="24dp" android:autoMirrored="true" - android:tint="#FFFFFF" android:viewportWidth="24" android:viewportHeight="24"> Date: Tue, 5 Jul 2022 11:49:53 +0200 Subject: [PATCH 04/39] chore: style fix light plugin icons --- .../userEntry/UserEntryPresentationHelper.kt | 6 +- core/src/main/res/drawable/ic_generic_cgm.xml | 32 +--- core/src/main/res/drawable/ic_glimp.xml | 163 +++++++++--------- core/src/main/res/drawable/ic_insulin.xml | 36 ++-- .../res/drawable/ic_patch_pump_outline.xml | 13 ++ core/src/main/res/drawable/ic_sensor.xml | 15 +- .../src/main/res/drawable/ic_virtual_pump.xml | 7 +- 7 files changed, 128 insertions(+), 144 deletions(-) create mode 100644 core/src/main/res/drawable/ic_patch_pump_outline.xml diff --git a/core/src/main/java/info/nightscout/androidaps/utils/userEntry/UserEntryPresentationHelper.kt b/core/src/main/java/info/nightscout/androidaps/utils/userEntry/UserEntryPresentationHelper.kt index 0bc1c3d8ca..faae359445 100644 --- a/core/src/main/java/info/nightscout/androidaps/utils/userEntry/UserEntryPresentationHelper.kt +++ b/core/src/main/java/info/nightscout/androidaps/utils/userEntry/UserEntryPresentationHelper.kt @@ -91,9 +91,9 @@ class UserEntryPresentationHelper @Inject constructor( Sources.Insight -> R.drawable.ic_insight_128 Sources.Combo -> R.drawable.ic_combo_128 Sources.Medtronic -> R.drawable.ic_veo_128 - Sources.Omnipod -> R.drawable.ic_pod_128 - Sources.OmnipodEros -> R.drawable.ic_pod_128 - Sources.OmnipodDash -> R.drawable.ic_pod_128 + Sources.Omnipod -> R.drawable.ic_patch_pump_outline + Sources.OmnipodEros -> R.drawable.ic_patch_pump_outline + Sources.OmnipodDash -> R.drawable.ic_patch_pump_outline Sources.MDI -> R.drawable.ic_ict Sources.VirtualPump -> R.drawable.ic_virtual_pump Sources.SMS -> R.drawable.ic_sms diff --git a/core/src/main/res/drawable/ic_generic_cgm.xml b/core/src/main/res/drawable/ic_generic_cgm.xml index 2758d5d8b8..2838fce45f 100644 --- a/core/src/main/res/drawable/ic_generic_cgm.xml +++ b/core/src/main/res/drawable/ic_generic_cgm.xml @@ -1,45 +1,21 @@ - - - - - - - - - - - + android:fillColor="?attr/colorControlNormal"/> diff --git a/core/src/main/res/drawable/ic_glimp.xml b/core/src/main/res/drawable/ic_glimp.xml index ed10736e93..d58294f27e 100644 --- a/core/src/main/res/drawable/ic_glimp.xml +++ b/core/src/main/res/drawable/ic_glimp.xml @@ -3,85 +3,86 @@ android:height="64dp" android:viewportWidth="64" android:viewportHeight="64"> - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + diff --git a/core/src/main/res/drawable/ic_insulin.xml b/core/src/main/res/drawable/ic_insulin.xml index a273562b2d..a4f653fe07 100644 --- a/core/src/main/res/drawable/ic_insulin.xml +++ b/core/src/main/res/drawable/ic_insulin.xml @@ -3,28 +3,16 @@ android:height="64dp" android:viewportWidth="64" android:viewportHeight="64"> - - - - - - - - + + + + diff --git a/core/src/main/res/drawable/ic_patch_pump_outline.xml b/core/src/main/res/drawable/ic_patch_pump_outline.xml new file mode 100644 index 0000000000..6a86ec1503 --- /dev/null +++ b/core/src/main/res/drawable/ic_patch_pump_outline.xml @@ -0,0 +1,13 @@ + + + + + diff --git a/core/src/main/res/drawable/ic_sensor.xml b/core/src/main/res/drawable/ic_sensor.xml index 39caee867c..4ce0d49c60 100644 --- a/core/src/main/res/drawable/ic_sensor.xml +++ b/core/src/main/res/drawable/ic_sensor.xml @@ -1,5 +1,12 @@ - - - + + + diff --git a/core/src/main/res/drawable/ic_virtual_pump.xml b/core/src/main/res/drawable/ic_virtual_pump.xml index 1f813674ff..e2360921d1 100644 --- a/core/src/main/res/drawable/ic_virtual_pump.xml +++ b/core/src/main/res/drawable/ic_virtual_pump.xml @@ -5,13 +5,12 @@ android:viewportHeight="64"> + android:fillColor="?attr/colorControlNormal"/> From d77c0fd8cb1da022939e303d3d7d3a34fb3ccaf0 Mon Sep 17 00:00:00 2001 From: Andries Smit Date: Tue, 5 Jul 2022 12:08:55 +0200 Subject: [PATCH 05/39] chore: fix alligment chart menu button --- app/src/main/res/layout/overview_graphs_layout.xml | 1 + 1 file changed, 1 insertion(+) diff --git a/app/src/main/res/layout/overview_graphs_layout.xml b/app/src/main/res/layout/overview_graphs_layout.xml index 70bcfa678e..d1e35bb237 100644 --- a/app/src/main/res/layout/overview_graphs_layout.xml +++ b/app/src/main/res/layout/overview_graphs_layout.xml @@ -22,6 +22,7 @@ android:layout_height="wrap_content" android:layout_alignParentTop="true" android:layout_alignParentEnd="true" + android:layout_marginEnd="3dp" android:contentDescription="@string/chart_menu" android:paddingTop="5dp" app:srcCompat="@drawable/ic_arrow_drop_down_white_24dp" /> From 401d009ce45b49de036f995ac0d8844de372931e Mon Sep 17 00:00:00 2001 From: Andries Smit Date: Tue, 5 Jul 2022 12:13:44 +0200 Subject: [PATCH 06/39] chore: fix light icon refresh --- core/src/main/res/drawable/ic_refresh.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/src/main/res/drawable/ic_refresh.xml b/core/src/main/res/drawable/ic_refresh.xml index 8229a9a64c..ceda60bb9a 100644 --- a/core/src/main/res/drawable/ic_refresh.xml +++ b/core/src/main/res/drawable/ic_refresh.xml @@ -4,6 +4,6 @@ android:viewportWidth="24.0" android:viewportHeight="24.0"> From 882400caa33422f07aacea90df3123967eb22310 Mon Sep 17 00:00:00 2001 From: Andries Smit Date: Tue, 5 Jul 2022 13:38:34 +0200 Subject: [PATCH 07/39] fix: wear ecarb input default --- .../java/info/nightscout/shared/SafeParse.kt | 8 +++--- .../interaction/actions/BolusActivity.kt | 2 +- .../interaction/actions/CarbActivity.kt | 9 ++---- .../interaction/actions/ECarbActivity.kt | 23 +++++---------- .../interaction/actions/FillActivity.kt | 7 ++--- .../actions/ProfileSwitchActivity.kt | 15 +++------- .../interaction/actions/TempTargetActivity.kt | 28 +++++++------------ .../interaction/actions/TreatmentActivity.kt | 13 ++++----- .../interaction/actions/WizardActivity.kt | 20 ++++--------- 9 files changed, 42 insertions(+), 83 deletions(-) diff --git a/shared/src/main/java/info/nightscout/shared/SafeParse.kt b/shared/src/main/java/info/nightscout/shared/SafeParse.kt index badcc231d6..f8d9aefa0b 100644 --- a/shared/src/main/java/info/nightscout/shared/SafeParse.kt +++ b/shared/src/main/java/info/nightscout/shared/SafeParse.kt @@ -3,12 +3,12 @@ package info.nightscout.shared object SafeParse { // private static Logger log = StacktraceLoggerWrapper.getLogger(SafeParse.class); - fun stringToDouble(inputString: String?): Double { - var input = inputString ?: return 0.0 - var result = 0.0 + fun stringToDouble(inputString: String?, defaultValue: Double = 0.0): Double { + var input = inputString ?: return defaultValue + var result = defaultValue input = input.replace(",", ".") input = input.replace("−", "-") - if (input == "") return 0.0 + if (input == "") return defaultValue try { result = input.toDouble() } catch (e: Exception) { diff --git a/wear/src/main/java/info/nightscout/androidaps/interaction/actions/BolusActivity.kt b/wear/src/main/java/info/nightscout/androidaps/interaction/actions/BolusActivity.kt index 012d5ec516..f67a34f690 100644 --- a/wear/src/main/java/info/nightscout/androidaps/interaction/actions/BolusActivity.kt +++ b/wear/src/main/java/info/nightscout/androidaps/interaction/actions/BolusActivity.kt @@ -42,7 +42,7 @@ class BolusActivity : ViewSelectorActivity() { override fun instantiateItem(container: ViewGroup, row: Int, col: Int): View = when (col) { 0 -> { val viewAdapter = EditPlusMinusViewAdapter.getViewAdapter(sp, applicationContext, container, true) - val initValue = if (editInsulin != null) SafeParse.stringToDouble(editInsulin?.editText?.text.toString()) else 0.0 + val initValue = SafeParse.stringToDouble(editInsulin?.editText?.text.toString(), 0.0) val maxBolus = sp.getDouble(getString(R.string.key_treatments_safety_max_bolus), 3.0) val title = getString(R.string.action_insulin) editInsulin = PlusMinusEditText(viewAdapter, initValue, 0.0, maxBolus, stepValues, DecimalFormat("#0.0"), false, title) diff --git a/wear/src/main/java/info/nightscout/androidaps/interaction/actions/CarbActivity.kt b/wear/src/main/java/info/nightscout/androidaps/interaction/actions/CarbActivity.kt index b941049002..6521ffd413 100644 --- a/wear/src/main/java/info/nightscout/androidaps/interaction/actions/CarbActivity.kt +++ b/wear/src/main/java/info/nightscout/androidaps/interaction/actions/CarbActivity.kt @@ -42,12 +42,9 @@ class CarbActivity : ViewSelectorActivity() { 0 -> { val viewAdapter = EditPlusMinusViewAdapter.getViewAdapter(sp, applicationContext, container, true) val view = viewAdapter.root - var def = 0.0 - if (editCarbs != null) { - def = SafeParse.stringToDouble(editCarbs?.editText?.text.toString()) - } - val maxCarbs = sp.getInt(getString(R.string.key_treatments_safety_max_carbs), 48) - editCarbs = PlusMinusEditText(viewAdapter, def, 0.0, maxCarbs.toDouble(), stepValues, DecimalFormat("0"), true, getString(R.string.action_carbs)) + var initValue = SafeParse.stringToDouble(editCarbs?.editText?.text.toString(), 0.0) + val maxCarbs = sp.getInt(getString(R.string.key_treatments_safety_max_carbs), 48).toDouble() + editCarbs = PlusMinusEditText(viewAdapter, initValue, 0.0, maxCarbs, stepValues, DecimalFormat("0"), true, getString(R.string.action_carbs)) container.addView(view) view.requestFocus() view diff --git a/wear/src/main/java/info/nightscout/androidaps/interaction/actions/ECarbActivity.kt b/wear/src/main/java/info/nightscout/androidaps/interaction/actions/ECarbActivity.kt index 919d92b1dd..bc2662066d 100644 --- a/wear/src/main/java/info/nightscout/androidaps/interaction/actions/ECarbActivity.kt +++ b/wear/src/main/java/info/nightscout/androidaps/interaction/actions/ECarbActivity.kt @@ -45,12 +45,9 @@ class ECarbActivity : ViewSelectorActivity() { 0 -> { val viewAdapter = EditPlusMinusViewAdapter.getViewAdapter(sp, applicationContext, container, true) val view = viewAdapter.root - var def = 0.0 - if (editCarbs != null) { - def = stringToDouble(editCarbs?.editText?.text.toString()) - } - val maxCarbs = sp.getInt(getString(R.string.key_treatments_safety_max_carbs), 48) - editCarbs = PlusMinusEditText(viewAdapter, def, 0.0, maxCarbs.toDouble(), stepValues, DecimalFormat("0"), true, getString(R.string.action_carbs)) + var initValue = stringToDouble(editCarbs?.editText?.text.toString(), 0.0) + val maxCarbs = sp.getInt(getString(R.string.key_treatments_safety_max_carbs), 48).toDouble() + editCarbs = PlusMinusEditText(viewAdapter, initValue, 0.0, maxCarbs, stepValues, DecimalFormat("0"), true, getString(R.string.action_carbs)) container.addView(view) view.requestFocus() view @@ -59,11 +56,8 @@ class ECarbActivity : ViewSelectorActivity() { 1 -> { val viewAdapter = EditPlusMinusViewAdapter.getViewAdapter(sp, applicationContext, container, false) val view = viewAdapter.root - var def = 0.0 - if (editStartTime != null) { - def = stringToDouble(editStartTime?.editText?.text.toString()) - } - editStartTime = PlusMinusEditText(viewAdapter, 15.0, def, -60.0, 300.0, DecimalFormat("0"), false, getString(R.string.action_start_min)) + var initValue = stringToDouble(editStartTime?.editText?.text.toString(), 0.0) + editStartTime = PlusMinusEditText(viewAdapter, initValue, -60.0, 300.0, 15.0, DecimalFormat("0"), false, getString(R.string.action_start_min)) container.addView(view) view } @@ -71,11 +65,8 @@ class ECarbActivity : ViewSelectorActivity() { 2 -> { val viewAdapter = EditPlusMinusViewAdapter.getViewAdapter(sp, applicationContext, container, false) val view = viewAdapter.root - var def = 0.0 - if (editDuration != null) { - def = stringToDouble(editDuration?.editText?.text.toString()) - } - editDuration = PlusMinusEditText(viewAdapter, 1.0, def, 0.0, 8.0, DecimalFormat("0"), false, getString(R.string.action_duration_h)) + var initValue = stringToDouble(editDuration?.editText?.text.toString(), 0.0) + editDuration = PlusMinusEditText(viewAdapter, initValue, 0.0, 8.0, 1.0, DecimalFormat("0"), false, getString(R.string.action_duration_h)) container.addView(view) view } diff --git a/wear/src/main/java/info/nightscout/androidaps/interaction/actions/FillActivity.kt b/wear/src/main/java/info/nightscout/androidaps/interaction/actions/FillActivity.kt index 9fdfa97d26..d2c3abc2a3 100644 --- a/wear/src/main/java/info/nightscout/androidaps/interaction/actions/FillActivity.kt +++ b/wear/src/main/java/info/nightscout/androidaps/interaction/actions/FillActivity.kt @@ -38,11 +38,8 @@ class FillActivity : ViewSelectorActivity() { 0 -> { val viewAdapter = EditPlusMinusViewAdapter.getViewAdapter(sp, applicationContext, container, false) val view = viewAdapter.root - var def = 0.0 - if (editInsulin != null) { - def = stringToDouble(editInsulin?.editText?.text.toString()) - } - editInsulin = PlusMinusEditText(viewAdapter, def, 0.0, 30.0, 0.1, DecimalFormat("#0.0"), false, getString(R.string.action_insulin)) + var initValue = stringToDouble(editInsulin?.editText?.text.toString(), 0.0) + editInsulin = PlusMinusEditText(viewAdapter, initValue, 0.0, 30.0, 0.1, DecimalFormat("#0.0"), false, getString(R.string.action_insulin)) container.addView(view) view.requestFocus() view diff --git a/wear/src/main/java/info/nightscout/androidaps/interaction/actions/ProfileSwitchActivity.kt b/wear/src/main/java/info/nightscout/androidaps/interaction/actions/ProfileSwitchActivity.kt index 8aa2a26437..75de43d82d 100644 --- a/wear/src/main/java/info/nightscout/androidaps/interaction/actions/ProfileSwitchActivity.kt +++ b/wear/src/main/java/info/nightscout/androidaps/interaction/actions/ProfileSwitchActivity.kt @@ -48,11 +48,8 @@ class ProfileSwitchActivity : ViewSelectorActivity() { 0 -> { val viewAdapter = EditPlusMinusViewAdapter.getViewAdapter(sp, applicationContext, container, false) val view = viewAdapter.root - var def = timeshift.toDouble() - if (editTimeshift != null) { - def = SafeParse.stringToDouble(editTimeshift?.editText?.text.toString()) - } - editTimeshift = PlusMinusEditText(viewAdapter, def, 0.0, 23.0, 1.0, DecimalFormat("0"), true, getString(R.string.action_timeshift), true) + var initValue = SafeParse.stringToDouble(editTimeshift?.editText?.text.toString(), timeshift.toDouble()) + editTimeshift = PlusMinusEditText(viewAdapter, initValue, 0.0, 23.0, 1.0, DecimalFormat("0"), true, getString(R.string.action_timeshift), true) container.addView(view) view.requestFocus() view @@ -61,12 +58,8 @@ class ProfileSwitchActivity : ViewSelectorActivity() { 1 -> { val viewAdapter = EditPlusMinusViewAdapter.getViewAdapter(sp, applicationContext, container, false) val view = viewAdapter.root - var def = percentage.toDouble() - if (editPercentage != null) { - def = SafeParse.stringToDouble(editPercentage?.editText?.text.toString()) - } - editPercentage = PlusMinusEditText(viewAdapter, def, 30.0, 250.0, 1.0, DecimalFormat("0"), false, getString(R.string.action_percentage)) - + var initValue = SafeParse.stringToDouble(editPercentage?.editText?.text.toString(), percentage.toDouble()) + editPercentage = PlusMinusEditText(viewAdapter, initValue, 30.0, 250.0, 1.0, DecimalFormat("0"), false, getString(R.string.action_percentage)) container.addView(view) view } diff --git a/wear/src/main/java/info/nightscout/androidaps/interaction/actions/TempTargetActivity.kt b/wear/src/main/java/info/nightscout/androidaps/interaction/actions/TempTargetActivity.kt index 77f1c256dc..dd18434b38 100644 --- a/wear/src/main/java/info/nightscout/androidaps/interaction/actions/TempTargetActivity.kt +++ b/wear/src/main/java/info/nightscout/androidaps/interaction/actions/TempTargetActivity.kt @@ -50,12 +50,8 @@ class TempTargetActivity : ViewSelectorActivity() { col == 0 -> { val viewAdapter = EditPlusMinusViewAdapter.getViewAdapter(sp, applicationContext, container, false) val view = viewAdapter.root - time = if (time == null) { - PlusMinusEditText(viewAdapter, 60.0, 0.0, 24 * 60.0, 5.0, DecimalFormat("0"), false, getString(R.string.action_duration)) - } else { - val def = SafeParse.stringToDouble(time?.editText?.text.toString()) - PlusMinusEditText(viewAdapter, def, 0.0, 24 * 60.0, 5.0, DecimalFormat("0"), false, getString(R.string.action_duration)) - } + val initValue = SafeParse.stringToDouble(time?.editText?.text.toString(), 60.0) + time = PlusMinusEditText(viewAdapter, initValue, 0.0, 24 * 60.0, 5.0, DecimalFormat("0"), false, getString(R.string.action_duration)) container.addView(view) view.requestFocus() view @@ -66,13 +62,11 @@ class TempTargetActivity : ViewSelectorActivity() { val view = viewAdapter.root val title = if (isSingleTarget) getString(R.string.action_target) else getString(R.string.action_low) if (isMGDL) { - var def = 100.0 - if (lowRange != null) def = SafeParse.stringToDouble(lowRange?.editText?.text.toString()) - lowRange = PlusMinusEditText(viewAdapter, def, 72.0, 180.0, 1.0, DecimalFormat("0"), false, title) + var initValue = SafeParse.stringToDouble(lowRange?.editText?.text.toString(), 100.0) + lowRange = PlusMinusEditText(viewAdapter, initValue, 72.0, 180.0, 1.0, DecimalFormat("0"), false, title) } else { - var def = 5.5 - if (lowRange != null) def = SafeParse.stringToDouble(lowRange?.editText?.text.toString()) - lowRange = PlusMinusEditText(viewAdapter, def, 4.0, 10.0, 0.1, DecimalFormat("#0.0"), false, title) + var initValue = SafeParse.stringToDouble(lowRange?.editText?.text.toString(), 5.5) + lowRange = PlusMinusEditText(viewAdapter, initValue, 4.0, 10.0, 0.1, DecimalFormat("#0.0"), false, title) } container.addView(view) view @@ -82,13 +76,11 @@ class TempTargetActivity : ViewSelectorActivity() { val viewAdapter = EditPlusMinusViewAdapter.getViewAdapter(sp, applicationContext, container, false) val view = viewAdapter.root if (isMGDL) { - var def = 100.0 - if (highRange != null) def = SafeParse.stringToDouble(highRange?.editText?.text.toString()) - highRange = PlusMinusEditText(viewAdapter, def, 72.0, 180.0, 1.0, DecimalFormat("0"), false, getString(R.string.action_high)) + var initValue = SafeParse.stringToDouble(highRange?.editText?.text.toString(), 100.0) + highRange = PlusMinusEditText(viewAdapter, initValue, 72.0, 180.0, 1.0, DecimalFormat("0"), false, getString(R.string.action_high)) } else { - var def = 5.5 - if (highRange != null) def = SafeParse.stringToDouble(highRange?.editText?.text.toString()) - highRange = PlusMinusEditText(viewAdapter, def, 4.0, 10.0, 0.1, DecimalFormat("#0.0"), false, getString(R.string.action_high)) + var initValue = SafeParse.stringToDouble(highRange?.editText?.text.toString(), 5.5) + highRange = PlusMinusEditText(viewAdapter, initValue, 4.0, 10.0, 0.1, DecimalFormat("#0.0"), false, getString(R.string.action_high)) } container.addView(view) view diff --git a/wear/src/main/java/info/nightscout/androidaps/interaction/actions/TreatmentActivity.kt b/wear/src/main/java/info/nightscout/androidaps/interaction/actions/TreatmentActivity.kt index 1cb7c36879..82e631de58 100644 --- a/wear/src/main/java/info/nightscout/androidaps/interaction/actions/TreatmentActivity.kt +++ b/wear/src/main/java/info/nightscout/androidaps/interaction/actions/TreatmentActivity.kt @@ -48,10 +48,9 @@ class TreatmentActivity : ViewSelectorActivity() { 0 -> { val viewAdapter = EditPlusMinusViewAdapter.getViewAdapter(sp, applicationContext, container, true) val view = viewAdapter.root - var def = 0.0 - if (editInsulin != null) def = stringToDouble(editInsulin?.editText?.text.toString()) + var initValue = stringToDouble(editInsulin?.editText?.text.toString(), 0.0) val maxBolus = sp.getDouble(getString(R.string.key_treatments_safety_max_bolus), 3.0) - editInsulin = PlusMinusEditText(viewAdapter, def, 0.0, maxBolus, stepValuesInsulin, DecimalFormat("#0.0"), false, getString(R.string.action_insulin)) + editInsulin = PlusMinusEditText(viewAdapter, initValue, 0.0, maxBolus, stepValuesInsulin, DecimalFormat("#0.0"), false, getString(R.string.action_insulin)) container.addView(view) view.requestFocus() view @@ -60,11 +59,9 @@ class TreatmentActivity : ViewSelectorActivity() { 1 -> { val viewAdapter = EditPlusMinusViewAdapter.getViewAdapter(sp, applicationContext, container, true) val view = viewAdapter.root - var def = 0.0 - val maxCarbs = sp.getInt(getString(R.string.key_treatments_safety_max_carbs), 48) - if (editCarbs != null) def = stringToDouble(editCarbs?.editText?.text.toString()) - - editCarbs = PlusMinusEditText(viewAdapter, def, 0.0, maxCarbs.toDouble(), stepValuesCarbs, DecimalFormat("0"), false, getString(R.string.action_carbs)) + val maxCarbs = sp.getInt(getString(R.string.key_treatments_safety_max_carbs), 48).toDouble() + var initValue = stringToDouble(editCarbs?.editText?.text.toString(), 0.0) + editCarbs = PlusMinusEditText(viewAdapter, initValue, 0.0, maxCarbs, stepValuesCarbs, DecimalFormat("0"), false, getString(R.string.action_carbs)) container.addView(view) view } diff --git a/wear/src/main/java/info/nightscout/androidaps/interaction/actions/WizardActivity.kt b/wear/src/main/java/info/nightscout/androidaps/interaction/actions/WizardActivity.kt index 9a9bd01967..58448f765f 100644 --- a/wear/src/main/java/info/nightscout/androidaps/interaction/actions/WizardActivity.kt +++ b/wear/src/main/java/info/nightscout/androidaps/interaction/actions/WizardActivity.kt @@ -44,13 +44,9 @@ class WizardActivity : ViewSelectorActivity() { col == 0 -> { val viewAdapter = EditPlusMinusViewAdapter.getViewAdapter(sp, applicationContext, container, true) val view = viewAdapter.root - val maxCarbs = sp.getInt(getString(R.string.key_treatments_safety_max_carbs), 48) - editCarbs = if (editCarbs == null) { - PlusMinusEditText(viewAdapter, 0.0, 0.0, maxCarbs.toDouble(), stepValues, DecimalFormat("0"), false, getString(R.string.action_carbs)) - } else { - val def = SafeParse.stringToDouble(editCarbs?.editText?.text.toString()) - PlusMinusEditText(viewAdapter, def, 0.0, maxCarbs.toDouble(), 1.0, DecimalFormat("0"), false, getString(R.string.action_carbs)) - } + val maxCarbs = sp.getInt(getString(R.string.key_treatments_safety_max_carbs), 48).toDouble() + val initValue = SafeParse.stringToDouble(editCarbs?.editText?.text.toString(), 0.0) + editCarbs = PlusMinusEditText(viewAdapter, initValue, 0.0, maxCarbs, stepValues, DecimalFormat("0"), false, getString(R.string.action_carbs)) container.addView(view) view.requestFocus() view @@ -59,13 +55,9 @@ class WizardActivity : ViewSelectorActivity() { col == 1 && hasPercentage -> { val viewAdapter = EditPlusMinusViewAdapter.getViewAdapter(sp, applicationContext, container, false) val view = viewAdapter.root - val percentage = sp.getInt(getString(R.string.key_bolus_wizard_percentage), 100) - editPercentage = if (editPercentage == null) { - PlusMinusEditText(viewAdapter, percentage.toDouble(), 50.0, 150.0, 1.0, DecimalFormat("0"), false, getString(R.string.action_percentage)) - } else { - val def = SafeParse.stringToDouble(editPercentage?.editText?.text.toString()) - PlusMinusEditText(viewAdapter, def, 50.0, 150.0, 1.0, DecimalFormat("0"), false, getString(R.string.action_percentage)) - } + val percentage = sp.getInt(getString(R.string.key_bolus_wizard_percentage), 100).toDouble() + val initValue = SafeParse.stringToDouble(editPercentage?.editText?.text.toString(), percentage) + editPercentage = PlusMinusEditText(viewAdapter, initValue, 50.0, 150.0, 1.0, DecimalFormat("0"), false, getString(R.string.action_percentage)) container.addView(view) view } From 9a409a5d123a5a90849278fc987b5adb7ad803a1 Mon Sep 17 00:00:00 2001 From: Andries Smit Date: Tue, 5 Jul 2022 22:07:11 +0200 Subject: [PATCH 08/39] chore: move to utils folder --- .../watchfaces/{ => utils}/BaseWatchFace.kt | 204 ++++++------------ .../watchfaces/{ => utils}/BgGraphBuilder.kt | 2 +- 2 files changed, 69 insertions(+), 137 deletions(-) rename wear/src/main/java/info/nightscout/androidaps/watchfaces/{ => utils}/BaseWatchFace.kt (71%) rename wear/src/main/java/info/nightscout/androidaps/watchfaces/{ => utils}/BgGraphBuilder.kt (99%) diff --git a/wear/src/main/java/info/nightscout/androidaps/watchfaces/BaseWatchFace.kt b/wear/src/main/java/info/nightscout/androidaps/watchfaces/utils/BaseWatchFace.kt similarity index 71% rename from wear/src/main/java/info/nightscout/androidaps/watchfaces/BaseWatchFace.kt rename to wear/src/main/java/info/nightscout/androidaps/watchfaces/utils/BaseWatchFace.kt index 23f304a8b5..68fa4fe519 100644 --- a/wear/src/main/java/info/nightscout/androidaps/watchfaces/BaseWatchFace.kt +++ b/wear/src/main/java/info/nightscout/androidaps/watchfaces/utils/BaseWatchFace.kt @@ -1,6 +1,5 @@ @file:Suppress("DEPRECATION") - -package info.nightscout.androidaps.watchfaces +package info.nightscout.androidaps.watchfaces.utils import android.annotation.SuppressLint import android.content.BroadcastReceiver @@ -13,14 +12,10 @@ import android.os.Vibrator import android.support.wearable.watchface.WatchFaceStyle import android.view.LayoutInflater import android.view.View -import android.view.ViewGroup import android.view.WindowInsets import android.view.WindowManager -import android.widget.ImageView -import android.widget.LinearLayout -import android.widget.TextView -import androidx.annotation.LayoutRes import androidx.core.content.ContextCompat +import androidx.viewbinding.ViewBinding import com.ustwo.clockwise.common.WatchFaceTime import com.ustwo.clockwise.common.WatchMode import com.ustwo.clockwise.common.WatchShape @@ -45,7 +40,6 @@ import info.nightscout.shared.weardata.EventData import info.nightscout.shared.weardata.EventData.ActionResendData import io.reactivex.rxjava3.disposables.CompositeDisposable import io.reactivex.rxjava3.kotlin.plusAssign -import lecho.lib.hellocharts.view.LineChartView import javax.inject.Inject import kotlin.math.floor @@ -55,6 +49,7 @@ import kotlin.math.floor * Refactored by dlvoy on 2019-11-2019 * Refactored by MilosKozak 24/04/2022 */ + abstract class BaseWatchFace : WatchFace() { @Inject lateinit var wearUtil: WearUtil @@ -74,45 +69,10 @@ abstract class BaseWatchFace : WatchFace() { private val graphData get() = rawData.graphData // Layout - @LayoutRes abstract fun layoutResource(): Int + // @LayoutRes abstract fun layoutResource(): Int + abstract fun inflateLayout(inflater: LayoutInflater): ViewBinding private val displaySize = Point() - var mTime: TextView? = null - var mHour: TextView? = null - var mMinute: TextView? = null - var mSgv: TextView? = null - var mDirection: TextView? = null - var mTimestamp: TextView? = null - var mUploaderBattery: TextView? = null - var mRigBattery: TextView? = null - var mDelta: TextView? = null - var mAvgDelta: TextView? = null - var mStatus: TextView? = null - var mBasalRate: TextView? = null - var mIOB1: TextView? = null - var mIOB2: TextView? = null - var mCOB1: TextView? = null - var mCOB2: TextView? = null - var mBgi: TextView? = null - var mLoop: TextView? = null - private var mTimePeriod: TextView? = null - var mDay: TextView? = null - private var mDayName: TextView? = null - var mMonth: TextView? = null - private var isAAPSv2: View? = null - var mHighLight: TextView? = null - var mLowLight: TextView? = null - var mGlucoseDial: ImageView? = null - var mDeltaGauge: ImageView? = null - var mHourHand: ImageView? = null - var mMinuteHand: ImageView? = null - var mRelativeLayout: ViewGroup? = null - var mLinearLayout: LinearLayout? = null - var mLinearLayout2: LinearLayout? = null - private var mDate: LinearLayout? = null - private var mChartTap: LinearLayout? = null // Steampunk only - private var mMainMenuTap: LinearLayout? = null // Steampunk,Digital only - var chart: LineChartView? = null var ageLevel = 1 var loopLevel = -1 @@ -148,10 +108,12 @@ abstract class BaseWatchFace : WatchFace() { private lateinit var mTimePaint: Paint private lateinit var mSvgPaint: Paint private lateinit var mDirectionPaint: Paint + private lateinit var binding: WatchfaceViewAdapter private var mLastSvg = "" private var mLastDirection = "" private var mYOffset = 0f + override fun onCreate() { // Not derived from DaggerService, do injection here AndroidInjection.inject(this) @@ -188,13 +150,17 @@ abstract class BaseWatchFace : WatchFace() { persistence.turnOff() setupBatteryReceiver() setupSimpleUi() - layoutView = (getSystemService(LAYOUT_INFLATER_SERVICE) as LayoutInflater).inflate(layoutResource(), null) + + val inflater = (getSystemService(LAYOUT_INFLATER_SERVICE) as LayoutInflater) + val bindLayout = inflateLayout(inflater) + binding = WatchfaceViewAdapter.getBinding(bindLayout) + layoutView = binding.root performViewSetup() rxBus.send(EventWearToMobile(ActionResendData("BaseWatchFace::onCreate"))) } override fun onTapCommand(tapType: Int, x: Int, y: Int, eventTime: Long) { - chart?.let { chart -> + binding.chart?.let { chart -> if (tapType == TAP_TYPE_TAP && x >= chart.left && x <= chart.right && y >= chart.top && y <= chart.bottom) { if (eventTime - chartTapTime < 800) { changeChartTimeframe() @@ -203,7 +169,7 @@ abstract class BaseWatchFace : WatchFace() { return } } - mSgv?.let { mSgv -> + binding.sgv?.let { mSgv -> val extra = (mSgv.right - mSgv.left) / 2 if (tapType == TAP_TYPE_TAP && x + extra >= mSgv.left && x - extra <= mSgv.right && y >= mSgv.top && y <= mSgv.bottom) { if (eventTime - sgvTapTime < 800) { @@ -212,7 +178,7 @@ abstract class BaseWatchFace : WatchFace() { sgvTapTime = eventTime } } - mChartTap?.let { mChartTap -> + binding.chartZoomTap?.let { mChartTap -> if (tapType == TAP_TYPE_TAP && x >= mChartTap.left && x <= mChartTap.right && y >= mChartTap.top && y <= mChartTap.bottom) { if (eventTime - chartTapTime < 800) { changeChartTimeframe() @@ -221,7 +187,7 @@ abstract class BaseWatchFace : WatchFace() { return } } - mMainMenuTap?.let { mMainMenuTap -> + binding.mainMenuTap?.let { mMainMenuTap -> if (tapType == TAP_TYPE_TAP && x >= mMainMenuTap.left && x <= mMainMenuTap.right && y >= mMainMenuTap.top && y <= mMainMenuTap.bottom) { if (eventTime - mainMenuTapTime < 800) { startActivity(Intent(this, MainMenuActivity::class.java).also { it.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK) }) @@ -288,42 +254,6 @@ abstract class BaseWatchFace : WatchFace() { } private fun performViewSetup() { - mTime = layoutView?.findViewById(R.id.watch_time) - mHour = layoutView?.findViewById(R.id.hour) - mMinute = layoutView?.findViewById(R.id.minute) - mDay = layoutView?.findViewById(R.id.day) - mDayName = layoutView?.findViewById(R.id.dayname) - mMonth = layoutView?.findViewById(R.id.month) - mTimePeriod = layoutView?.findViewById(R.id.timePeriod) - mDate = layoutView?.findViewById(R.id.date_time) - mLoop = layoutView?.findViewById(R.id.loop) - mSgv = layoutView?.findViewById(R.id.sgv) - mDirection = layoutView?.findViewById(R.id.direction) - mTimestamp = layoutView?.findViewById(R.id.timestamp) - mIOB1 = layoutView?.findViewById(R.id.iob_text) - mIOB2 = layoutView?.findViewById(R.id.iobView) - mCOB1 = layoutView?.findViewById(R.id.cob_text) - mCOB2 = layoutView?.findViewById(R.id.cobView) - mBgi = layoutView?.findViewById(R.id.bgiView) - mStatus = layoutView?.findViewById(R.id.externaltstatus) - mBasalRate = layoutView?.findViewById(R.id.tmpBasal) - mUploaderBattery = layoutView?.findViewById(R.id.uploader_battery) - mRigBattery = layoutView?.findViewById(R.id.rig_battery) - mDelta = layoutView?.findViewById(R.id.delta) - mAvgDelta = layoutView?.findViewById(R.id.avgdelta) - isAAPSv2 = layoutView?.findViewById(R.id.AAPSv2) - mHighLight = layoutView?.findViewById(R.id.highLight) - mLowLight = layoutView?.findViewById(R.id.lowLight) - mRelativeLayout = layoutView?.findViewById(R.id.main_layout) - mLinearLayout = layoutView?.findViewById(R.id.secondary_layout) - mLinearLayout2 = layoutView?.findViewById(R.id.tertiary_layout) - mGlucoseDial = layoutView?.findViewById(R.id.glucose_dial) - mDeltaGauge = layoutView?.findViewById(R.id.delta_pointer) - mHourHand = layoutView?.findViewById(R.id.hour_hand) - mMinuteHand = layoutView?.findViewById(R.id.minute_hand) - mChartTap = layoutView?.findViewById(R.id.chart_zoom_tap) - mMainMenuTap = layoutView?.findViewById(R.id.main_menu_tap) - chart = layoutView?.findViewById(R.id.chart) layoutSet = true setupCharts() setDataFields() @@ -364,10 +294,10 @@ abstract class BaseWatchFace : WatchFace() { onDrawSimpleUi(canvas) } else { if (layoutSet) { - mRelativeLayout?.measure(specW, specH) + binding.mainLayout.measure(specW, specH) val y = if (forceSquareCanvas) displaySize.x else displaySize.y // Square Steampunk - mRelativeLayout?.layout(0, 0, displaySize.x, y) - mRelativeLayout?.draw(canvas) + binding.mainLayout.layout(0, 0, displaySize.x, y) + binding.mainLayout.draw(canvas) } } } @@ -417,6 +347,7 @@ abstract class BaseWatchFace : WatchFace() { return status == BatteryManager.BATTERY_STATUS_CHARGING || status == BatteryManager.BATTERY_STATUS_FULL } + @SuppressLint("MissingPermission") @Suppress("DEPRECATION") private fun checkVibrateHourly(oldTime: WatchFaceTime, newTime: WatchFaceTime) { val hourlyVibratePref = sp.getBoolean(R.string.key_vibrate_hourly, false) @@ -431,54 +362,54 @@ abstract class BaseWatchFace : WatchFace() { @SuppressLint("SetTextI18n") open fun setDataFields() { setDateAndTime() - mSgv?.text = singleBg.sgvString - mSgv?.visibility = sp.getBoolean(R.string.key_show_bg, true).toVisibilityKeepSpace() + binding.sgv?.text = singleBg.sgvString + binding.sgv?.visibility = sp.getBoolean(R.string.key_show_bg, true).toVisibilityKeepSpace() strikeThroughSgvIfNeeded() - mDirection?.text = "${singleBg.slopeArrow}\uFE0E" - mDirection?.visibility = sp.getBoolean(R.string.key_show_direction, true).toVisibility() - mDelta?.text = singleBg.delta - mDelta?.visibility = sp.getBoolean(R.string.key_show_delta, true).toVisibility() - mAvgDelta?.text = singleBg.avgDelta - mAvgDelta?.visibility = sp.getBoolean(R.string.key_show_avg_delta, true).toVisibility() - mCOB1?.visibility = sp.getBoolean(R.string.key_show_cob, true).toVisibility() - mCOB2?.text = status.cob - mCOB2?.visibility = sp.getBoolean(R.string.key_show_cob, true).toVisibility() - mIOB1?.visibility = sp.getBoolean(R.string.key_show_iob, true).toVisibility() - mIOB2?.visibility = sp.getBoolean(R.string.key_show_iob, true).toVisibility() - mIOB1?.text = if (status.detailedIob) status.iobSum else getString(R.string.activity_IOB) - mIOB2?.text = if (status.detailedIob) status.iobDetail else status.iobSum - mTimestamp?.visibility = sp.getBoolean(R.string.key_show_ago, true).toVisibility() - mTimestamp?.text = readingAge(if (isAAPSv2 != null) true else sp.getBoolean(R.string.key_show_external_status, true)) - mUploaderBattery?.visibility = sp.getBoolean(R.string.key_show_uploader_battery, true).toVisibility() - mUploaderBattery?.text = + binding.direction?.text = "${singleBg.slopeArrow}\uFE0E" + binding.direction?.visibility = sp.getBoolean(R.string.key_show_direction, true).toVisibility() + binding.delta?.text = singleBg.delta + binding.delta?.visibility = sp.getBoolean(R.string.key_show_delta, true).toVisibility() + binding.avgDelta?.text = singleBg.avgDelta + binding.avgDelta?.visibility = sp.getBoolean(R.string.key_show_avg_delta, true).toVisibility() + binding.cob1?.visibility = sp.getBoolean(R.string.key_show_cob, true).toVisibility() + binding.cob2?.text = status.cob + binding.cob2?.visibility = sp.getBoolean(R.string.key_show_cob, true).toVisibility() + binding.iob1?.visibility = sp.getBoolean(R.string.key_show_iob, true).toVisibility() + binding.iob2?.visibility = sp.getBoolean(R.string.key_show_iob, true).toVisibility() + binding.iob1?.text = if (status.detailedIob) status.iobSum else getString(R.string.activity_IOB) + binding.iob2?.text = if (status.detailedIob) status.iobDetail else status.iobSum + binding.timestamp.visibility = sp.getBoolean(R.string.key_show_ago, true).toVisibility() + binding.timestamp.text = readingAge(if (binding.AAPSv2 != null) true else sp.getBoolean(R.string.key_show_external_status, true)) + binding.uploaderBattery?.visibility = sp.getBoolean(R.string.key_show_uploader_battery, true).toVisibility() + binding.uploaderBattery?.text = when { - isAAPSv2 != null -> status.battery + "%" + binding.AAPSv2 != null -> status.battery + "%" sp.getBoolean(R.string.key_show_external_status, true) -> "U: ${status.battery}%" else -> "Uploader: ${status.battery}%" } - mRigBattery?.visibility = sp.getBoolean(R.string.key_show_rig_battery, false).toVisibility() - mRigBattery?.text = status.rigBattery - mBasalRate?.text = status.currentBasal - mBasalRate?.visibility = sp.getBoolean(R.string.key_show_temp_basal, true).toVisibility() - mBgi?.text = status.bgi - mBgi?.visibility = status.showBgi.toVisibility() - mStatus?.text = status.externalStatus - mStatus?.visibility = sp.getBoolean(R.string.key_show_external_status, true).toVisibility() - mLoop?.visibility = sp.getBoolean(R.string.key_show_external_status, true).toVisibility() + binding.rigBattery?.visibility = sp.getBoolean(R.string.key_show_rig_battery, false).toVisibility() + binding.rigBattery?.text = status.rigBattery + binding.basalRate?.text = status.currentBasal + binding.basalRate?.visibility = sp.getBoolean(R.string.key_show_temp_basal, true).toVisibility() + binding.bgi?.text = status.bgi + binding.bgi?.visibility = status.showBgi.toVisibility() + binding.status?.text = status.externalStatus + binding.status?.visibility = sp.getBoolean(R.string.key_show_external_status, true).toVisibility() + binding.loop?.visibility = sp.getBoolean(R.string.key_show_external_status, true).toVisibility() if (status.openApsStatus != -1L) { val minutes = ((System.currentTimeMillis() - status.openApsStatus) / 1000 / 60).toInt() - mLoop?.text = "$minutes'" + binding.loop?.text = "$minutes'" if (minutes > 14) { loopLevel = 0 - mLoop?.setBackgroundResource(R.drawable.loop_red_25) + binding.loop?.setBackgroundResource(R.drawable.loop_red_25) } else { loopLevel = 1 - mLoop?.setBackgroundResource(R.drawable.loop_green_25) + binding.loop?.setBackgroundResource(R.drawable.loop_green_25) } } else { loopLevel = -1 - mLoop?.text = "-" - mLoop?.setBackgroundResource(R.drawable.loop_grey_25) + binding.loop?.text = "-" + binding.loop?.setBackgroundResource(R.drawable.loop_grey_25) } setColor() } @@ -491,15 +422,15 @@ abstract class BaseWatchFace : WatchFace() { } private fun setDateAndTime() { - mTime?.text = dateUtil.timeString() - mHour?.text = dateUtil.hourString() - mMinute?.text = dateUtil.minuteString() - mDate?.visibility = sp.getBoolean(R.string.key_show_date, false).toVisibility() - mDayName?.text = dateUtil.dayNameString() - mDay?.text = dateUtil.dayString() - mMonth?.text = dateUtil.monthString() - mTimePeriod?.visibility = android.text.format.DateFormat.is24HourFormat(this).not().toVisibility() - mTimePeriod?.text = dateUtil.amPm() + binding.time?.text = dateUtil.timeString() + binding.hour?.text = dateUtil.hourString() + binding.minute?.text = dateUtil.minuteString() + binding.dateTime?.visibility = sp.getBoolean(R.string.key_show_date, false).toVisibility() + binding.dayName?.text = dateUtil.dayNameString() + binding.day?.text = dateUtil.dayString() + binding.month?.text = dateUtil.monthString() + binding.timePeriod?.visibility = android.text.format.DateFormat.is24HourFormat(this).not().toVisibility() + binding.timePeriod?.text = dateUtil.amPm() } private fun setColor() { @@ -512,7 +443,8 @@ abstract class BaseWatchFace : WatchFace() { } private fun strikeThroughSgvIfNeeded() { - mSgv?.let { mSgv -> + @Suppress("DEPRECATION") + binding.sgv?.let { mSgv -> if (ageLevel() <= 0 && singleBg.timeStamp > 0) mSgv.paintFlags = mSgv.paintFlags or Paint.STRIKE_THRU_TEXT_FLAG else mSgv.paintFlags = mSgv.paintFlags and Paint.STRIKE_THRU_TEXT_FLAG.inv() } @@ -559,7 +491,7 @@ abstract class BaseWatchFace : WatchFace() { if (isSimpleUi) { return } - if (chart != null && graphData.entries.size > 0) { + if (binding.chart != null && graphData.entries.size > 0) { val timeframe = sp.getInt(R.string.key_chart_time_frame, 3) val bgGraphBuilder = if (lowResMode) @@ -572,8 +504,8 @@ abstract class BaseWatchFace : WatchFace() { sp, dateUtil, graphData.entries, treatmentData.predictions, treatmentData.temps, treatmentData.basals, treatmentData.boluses, pointSize, highColor, lowColor, midColor, gridColor, basalBackgroundColor, basalCenterColor, bolusColor, Color.GREEN, timeframe ) - chart?.lineChartData = bgGraphBuilder.lineData() - chart?.isViewportCalculationEnabled = true + binding.chart?.lineChartData = bgGraphBuilder.lineData() + binding.chart?.isViewportCalculationEnabled = true } } diff --git a/wear/src/main/java/info/nightscout/androidaps/watchfaces/BgGraphBuilder.kt b/wear/src/main/java/info/nightscout/androidaps/watchfaces/utils/BgGraphBuilder.kt similarity index 99% rename from wear/src/main/java/info/nightscout/androidaps/watchfaces/BgGraphBuilder.kt rename to wear/src/main/java/info/nightscout/androidaps/watchfaces/utils/BgGraphBuilder.kt index 48b7d340f4..5cce0bf6c0 100644 --- a/wear/src/main/java/info/nightscout/androidaps/watchfaces/BgGraphBuilder.kt +++ b/wear/src/main/java/info/nightscout/androidaps/watchfaces/utils/BgGraphBuilder.kt @@ -1,4 +1,4 @@ -package info.nightscout.androidaps.watchfaces +package info.nightscout.androidaps.watchfaces.utils import android.graphics.DashPathEffect import info.nightscout.androidaps.R From 5c923d4a07750e328869f70b5bc54c78c950dc56 Mon Sep 17 00:00:00 2001 From: Andries Smit Date: Tue, 5 Jul 2022 22:07:38 +0200 Subject: [PATCH 09/39] chore: wear watchface use databinding --- .../androidaps/di/WearServicesModule.kt | 1 + .../watchfaces/AapsLargeWatchface.kt | 157 +++++------ .../androidaps/watchfaces/AapsV2Watchface.kt | 259 +++++++++--------- .../androidaps/watchfaces/AapsWatchface.kt | 172 ++++++------ .../watchfaces/BigChartWatchface.kt | 171 ++++++------ .../androidaps/watchfaces/CockpitWatchface.kt | 74 ++--- .../watchfaces/DigitalStyleWatchface.kt | 84 +++--- .../androidaps/watchfaces/NoChartWatchface.kt | 119 ++++---- .../watchfaces/SteampunkWatchface.kt | 140 +++++----- .../watchfaces/utils/WatchfaceViewAdapter.kt | 102 +++++++ .../res/layout-notround/activity_bigchart.xml | 6 +- .../activity_bigchart_small.xml | 6 +- .../res/layout-notround/activity_cockpit.xml | 10 +- .../layout-notround/activity_digitalstyle.xml | 24 +- .../res/layout-notround/activity_home.xml | 4 +- .../res/layout-notround/activity_home_2.xml | 16 +- .../layout-notround/activity_home_large.xml | 4 +- .../res/layout-notround/activity_nochart.xml | 6 +- .../activity_nochart_small.xml | 6 +- .../layout-notround/activity_steampunk.xml | 6 +- .../res/layout-round/activity_bigchart.xml | 6 +- .../layout-round/activity_bigchart_small.xml | 6 +- .../res/layout-round/activity_cockpit.xml | 10 +- .../layout-round/activity_digitalstyle.xml | 18 +- .../main/res/layout-round/activity_home.xml | 4 +- .../main/res/layout-round/activity_home_2.xml | 16 +- .../res/layout-round/activity_home_large.xml | 4 +- .../res/layout-round/activity_nochart.xml | 6 +- .../layout-round/activity_nochart_small.xml | 6 +- .../res/layout-round/activity_steampunk.xml | 6 +- 30 files changed, 743 insertions(+), 706 deletions(-) create mode 100644 wear/src/main/java/info/nightscout/androidaps/watchfaces/utils/WatchfaceViewAdapter.kt diff --git a/wear/src/main/java/info/nightscout/androidaps/di/WearServicesModule.kt b/wear/src/main/java/info/nightscout/androidaps/di/WearServicesModule.kt index 6e318f0e45..93204ba917 100644 --- a/wear/src/main/java/info/nightscout/androidaps/di/WearServicesModule.kt +++ b/wear/src/main/java/info/nightscout/androidaps/di/WearServicesModule.kt @@ -6,6 +6,7 @@ import info.nightscout.androidaps.comm.DataLayerListenerServiceWear import info.nightscout.androidaps.complications.* import info.nightscout.androidaps.tile.* import info.nightscout.androidaps.watchfaces.* +import info.nightscout.androidaps.watchfaces.utils.BaseWatchFace @Module @Suppress("unused") diff --git a/wear/src/main/java/info/nightscout/androidaps/watchfaces/AapsLargeWatchface.kt b/wear/src/main/java/info/nightscout/androidaps/watchfaces/AapsLargeWatchface.kt index 39e7252498..b8f922f300 100644 --- a/wear/src/main/java/info/nightscout/androidaps/watchfaces/AapsLargeWatchface.kt +++ b/wear/src/main/java/info/nightscout/androidaps/watchfaces/AapsLargeWatchface.kt @@ -1,116 +1,93 @@ package info.nightscout.androidaps.watchfaces import android.graphics.Color -import androidx.annotation.LayoutRes +import android.view.LayoutInflater import androidx.core.content.ContextCompat +import androidx.viewbinding.ViewBinding import com.ustwo.clockwise.common.WatchMode import info.nightscout.androidaps.R +import info.nightscout.androidaps.databinding.ActivityHomeLargeBinding +import info.nightscout.androidaps.watchfaces.utils.BaseWatchFace class AapsLargeWatchface : BaseWatchFace() { - @LayoutRes override fun layoutResource(): Int = R.layout.activity_home_large + private lateinit var binding: ActivityHomeLargeBinding + + override fun inflateLayout(inflater: LayoutInflater): ViewBinding { + binding = ActivityHomeLargeBinding.inflate(inflater) + return binding + } override fun setColorDark() { - mLinearLayout?.setBackgroundColor(ContextCompat.getColor(this, if (dividerMatchesBg) R.color.dark_background else R.color.dark_mLinearLayout)) - mTime?.setTextColor(ContextCompat.getColor(this, R.color.dark_mTime)) - mRelativeLayout?.setBackgroundColor(ContextCompat.getColor(this, R.color.dark_background)) - when (singleBg.sgvLevel) { - 1L -> { - mSgv?.setTextColor(ContextCompat.getColor(this, R.color.dark_highColor)) - mDelta?.setTextColor(ContextCompat.getColor(this, R.color.dark_highColor)) - mDirection?.setTextColor(ContextCompat.getColor(this, R.color.dark_highColor)) - } - - 0L -> { - mSgv?.setTextColor(ContextCompat.getColor(this, R.color.dark_midColor)) - mDelta?.setTextColor(ContextCompat.getColor(this, R.color.dark_midColor)) - mDirection?.setTextColor(ContextCompat.getColor(this, R.color.dark_midColor)) - } - - -1L -> { - mSgv?.setTextColor(ContextCompat.getColor(this, R.color.dark_lowColor)) - mDelta?.setTextColor(ContextCompat.getColor(this, R.color.dark_lowColor)) - mDirection?.setTextColor(ContextCompat.getColor(this, R.color.dark_lowColor)) - } + binding.secondaryLayout.setBackgroundColor(ContextCompat.getColor(this, if (dividerMatchesBg) R.color.dark_background else R.color.dark_mLinearLayout)) + binding.time.setTextColor(ContextCompat.getColor(this, R.color.dark_mTime)) + binding.mainLayout.setBackgroundColor(ContextCompat.getColor(this, R.color.dark_background)) + val color = when (singleBg.sgvLevel) { + 1L -> R.color.dark_highColor + 0L -> R.color.dark_midColor + -1L -> R.color.dark_lowColor + else -> R.color.dark_midColor } - if (ageLevel == 1) mTimestamp?.setTextColor(ContextCompat.getColor(this, if (dividerMatchesBg) R.color.dark_midColor else R.color.dark_mTimestamp1_home)) - else mTimestamp?.setTextColor(ContextCompat.getColor(this, R.color.dark_TimestampOld)) - - if (status.batteryLevel == 1) mUploaderBattery?.setTextColor(ContextCompat.getColor(this, if (dividerMatchesBg) R.color.dark_midColor else R.color.dark_uploaderBattery)) - else mUploaderBattery?.setTextColor(ContextCompat.getColor(this, R.color.dark_uploaderBatteryEmpty)) - - mStatus?.setTextColor(ContextCompat.getColor(this, if (dividerMatchesBg) R.color.dark_midColor else R.color.dark_mStatus_home)) + binding.sgv.setTextColor(ContextCompat.getColor(this, color)) + binding.delta.setTextColor(ContextCompat.getColor(this, color)) + binding.direction.setTextColor(ContextCompat.getColor(this, color)) + val colorTime = if (ageLevel == 1) if (dividerMatchesBg) R.color.dark_midColor else R.color.dark_mTimestamp1_home else R.color.dark_TimestampOld + binding.timestamp.setTextColor(ContextCompat.getColor(this, colorTime)) + val colourBat = if (status.batteryLevel == 1) if (dividerMatchesBg) R.color.dark_midColor else R.color.dark_uploaderBattery else R.color.dark_uploaderBatteryEmpty + binding.uploaderBattery.setTextColor(ContextCompat.getColor(this, colourBat)) + binding.status.setTextColor(ContextCompat.getColor(this, if (dividerMatchesBg) R.color.dark_midColor else R.color.dark_mStatus_home)) } override fun setColorBright() { if (currentWatchMode == WatchMode.INTERACTIVE) { - mLinearLayout?.setBackgroundColor(ContextCompat.getColor(this, if (dividerMatchesBg) R.color.light_background else R.color.light_stripe_background)) - mRelativeLayout?.setBackgroundColor(ContextCompat.getColor(this, R.color.light_background)) - when (singleBg.sgvLevel) { - 1L -> { - mSgv?.setTextColor(ContextCompat.getColor(this, R.color.light_highColor)) - mDelta?.setTextColor(ContextCompat.getColor(this, R.color.light_highColor)) - mDirection?.setTextColor(ContextCompat.getColor(this, R.color.light_highColor)) - } - - 0L -> { - mSgv?.setTextColor(ContextCompat.getColor(this, R.color.light_midColor)) - mDelta?.setTextColor(ContextCompat.getColor(this, R.color.light_midColor)) - mDirection?.setTextColor(ContextCompat.getColor(this, R.color.light_midColor)) - } - - -1L -> { - mSgv?.setTextColor(ContextCompat.getColor(this, R.color.light_lowColor)) - mDelta?.setTextColor(ContextCompat.getColor(this, R.color.light_lowColor)) - mDirection?.setTextColor(ContextCompat.getColor(this, R.color.light_lowColor)) - } + binding.secondaryLayout.setBackgroundColor(ContextCompat.getColor(this, if (dividerMatchesBg) R.color.light_background else R.color.light_stripe_background)) + binding.mainLayout.setBackgroundColor(ContextCompat.getColor(this, R.color.light_background)) + val color = when (singleBg.sgvLevel) { + 1L -> R.color.light_highColor + 0L -> R.color.light_midColor + -1L -> R.color.light_lowColor + else -> R.color.light_midColor } - if (ageLevel == 1) mTimestamp?.setTextColor(if (dividerMatchesBg) Color.BLACK else Color.WHITE) - else mTimestamp?.setTextColor(Color.RED) + binding.sgv.setTextColor(ContextCompat.getColor(this, color)) + binding.delta.setTextColor(ContextCompat.getColor(this, color)) + binding.direction.setTextColor(ContextCompat.getColor(this, color)) - if (status.batteryLevel == 1) mUploaderBattery?.setTextColor(if (dividerMatchesBg) Color.BLACK else Color.WHITE) - else mUploaderBattery?.setTextColor(Color.RED) + val colorTime = if (ageLevel == 1) if (dividerMatchesBg) Color.BLACK else Color.WHITE else Color.RED + binding.timestamp.setTextColor(colorTime) + val colourBat = if (status.batteryLevel == 1) if (dividerMatchesBg) Color.BLACK else Color.WHITE else Color.RED + binding.uploaderBattery.setTextColor(colourBat) - mStatus?.setTextColor(if (dividerMatchesBg) Color.BLACK else Color.WHITE) - mTime?.setTextColor(Color.BLACK) + binding.status.setTextColor(if (dividerMatchesBg) Color.BLACK else Color.WHITE) + binding.time.setTextColor(Color.BLACK) } else { - mRelativeLayout?.setBackgroundColor(Color.BLACK) - mLinearLayout?.setBackgroundColor(if (dividerMatchesBg) Color.BLACK else Color.LTGRAY) - when (singleBg.sgvLevel) { - 1L -> { - mSgv?.setTextColor(Color.YELLOW) - mDirection?.setTextColor(Color.YELLOW) - mDelta?.setTextColor(Color.YELLOW) - } - - 0L -> { - mSgv?.setTextColor(Color.WHITE) - mDirection?.setTextColor(Color.WHITE) - mDelta?.setTextColor(Color.WHITE) - } - - -1L -> { - mSgv?.setTextColor(Color.RED) - mDirection?.setTextColor(Color.RED) - mDelta?.setTextColor(Color.RED) - } + binding.mainLayout.setBackgroundColor(Color.BLACK) + binding.secondaryLayout.setBackgroundColor(if (dividerMatchesBg) Color.BLACK else Color.LTGRAY) + val color = when (singleBg.sgvLevel) { + 1L -> Color.YELLOW + 0L -> Color.WHITE + -1L -> Color.RED + else -> Color.WHITE } - mUploaderBattery?.setTextColor(if (dividerMatchesBg) Color.WHITE else Color.BLACK) - mTimestamp?.setTextColor(if (dividerMatchesBg) Color.WHITE else Color.BLACK) - mStatus?.setTextColor(if (dividerMatchesBg) Color.WHITE else Color.BLACK) - mTime?.setTextColor(Color.WHITE) + binding.sgv.setTextColor(ContextCompat.getColor(this, color)) + binding.delta.setTextColor(ContextCompat.getColor(this, color)) + binding.direction.setTextColor(ContextCompat.getColor(this, color)) + + binding.uploaderBattery.setTextColor(if (dividerMatchesBg) Color.WHITE else Color.BLACK) + binding.timestamp.setTextColor(if (dividerMatchesBg) Color.WHITE else Color.BLACK) + binding.status.setTextColor(if (dividerMatchesBg) Color.WHITE else Color.BLACK) + binding.time.setTextColor(Color.WHITE) } } override fun setColorLowRes() { - mLinearLayout?.setBackgroundColor(ContextCompat.getColor(this, if (dividerMatchesBg) R.color.dark_background else R.color.dark_mLinearLayout)) - mTime?.setTextColor(ContextCompat.getColor(this, R.color.dark_mTime)) - mRelativeLayout?.setBackgroundColor(ContextCompat.getColor(this, R.color.dark_background)) - mSgv?.setTextColor(ContextCompat.getColor(this, R.color.dark_midColor)) - mDelta?.setTextColor(ContextCompat.getColor(this, R.color.dark_midColor)) - mDirection?.setTextColor(ContextCompat.getColor(this, R.color.dark_midColor)) - mTimestamp?.setTextColor(ContextCompat.getColor(this, if (dividerMatchesBg) R.color.dark_midColor else R.color.dark_mTimestamp1_home)) - mUploaderBattery?.setTextColor(ContextCompat.getColor(this, if (dividerMatchesBg) R.color.dark_midColor else R.color.dark_uploaderBattery)) - mStatus?.setTextColor(ContextCompat.getColor(this, if (dividerMatchesBg) R.color.dark_midColor else R.color.dark_mStatus_home)) + binding.secondaryLayout.setBackgroundColor(ContextCompat.getColor(this, if (dividerMatchesBg) R.color.dark_background else R.color.dark_mLinearLayout)) + binding.time.setTextColor(ContextCompat.getColor(this, R.color.dark_mTime)) + binding.mainLayout.setBackgroundColor(ContextCompat.getColor(this, R.color.dark_background)) + binding.sgv.setTextColor(ContextCompat.getColor(this, R.color.dark_midColor)) + binding.delta.setTextColor(ContextCompat.getColor(this, R.color.dark_midColor)) + binding.direction.setTextColor(ContextCompat.getColor(this, R.color.dark_midColor)) + binding.timestamp.setTextColor(ContextCompat.getColor(this, if (dividerMatchesBg) R.color.dark_midColor else R.color.dark_mTimestamp1_home)) + binding.uploaderBattery.setTextColor(ContextCompat.getColor(this, if (dividerMatchesBg) R.color.dark_midColor else R.color.dark_uploaderBattery)) + binding.status.setTextColor(ContextCompat.getColor(this, if (dividerMatchesBg) R.color.dark_midColor else R.color.dark_mStatus_home)) } -} \ No newline at end of file +} diff --git a/wear/src/main/java/info/nightscout/androidaps/watchfaces/AapsV2Watchface.kt b/wear/src/main/java/info/nightscout/androidaps/watchfaces/AapsV2Watchface.kt index 5665af5c09..887fe53072 100644 --- a/wear/src/main/java/info/nightscout/androidaps/watchfaces/AapsV2Watchface.kt +++ b/wear/src/main/java/info/nightscout/androidaps/watchfaces/AapsV2Watchface.kt @@ -1,110 +1,109 @@ package info.nightscout.androidaps.watchfaces import android.graphics.Color +import android.view.LayoutInflater import androidx.annotation.ColorInt -import androidx.annotation.LayoutRes import androidx.core.content.ContextCompat +import androidx.viewbinding.ViewBinding import com.ustwo.clockwise.common.WatchMode import info.nightscout.androidaps.R +import info.nightscout.androidaps.databinding.ActivityHome2Binding +import info.nightscout.androidaps.watchfaces.utils.BaseWatchFace class AapsV2Watchface : BaseWatchFace() { - @LayoutRes override fun layoutResource(): Int = R.layout.activity_home_2 + private lateinit var binding: ActivityHome2Binding + + override fun inflateLayout(inflater: LayoutInflater): ViewBinding { + binding = ActivityHome2Binding.inflate(inflater) + return binding + } override fun setColorDark() { @ColorInt val dividerTxtColor = if (dividerMatchesBg) ContextCompat.getColor(this, R.color.dark_midColor) else Color.BLACK @ColorInt val dividerBatteryOkColor = ContextCompat.getColor(this, if (dividerMatchesBg) R.color.dark_midColor else R.color.dark_uploaderBattery) @ColorInt val dividerBgColor = ContextCompat.getColor(this, if (dividerMatchesBg) R.color.dark_background else R.color.dark_statusView) - mLinearLayout?.setBackgroundColor(dividerBgColor) - mLinearLayout2?.setBackgroundColor(ContextCompat.getColor(this, R.color.dark_background)) - mRelativeLayout?.setBackgroundColor(ContextCompat.getColor(this, R.color.dark_background)) - mTime?.setTextColor(ContextCompat.getColor(this, R.color.dark_midColor)) - mIOB1?.setTextColor(ContextCompat.getColor(this, R.color.dark_midColor)) - mIOB2?.setTextColor(ContextCompat.getColor(this, R.color.dark_midColor)) - mCOB1?.setTextColor(ContextCompat.getColor(this, R.color.dark_midColor)) - mCOB2?.setTextColor(ContextCompat.getColor(this, R.color.dark_midColor)) - mDay?.setTextColor(ContextCompat.getColor(this, R.color.dark_midColor)) - mMonth?.setTextColor(ContextCompat.getColor(this, R.color.dark_midColor)) - mLoop?.setTextColor(ContextCompat.getColor(this, R.color.dark_midColor)) + binding.secondaryLayout.setBackgroundColor(dividerBgColor) + binding.tertiaryLayout.setBackgroundColor(ContextCompat.getColor(this, R.color.dark_background)) + binding.mainLayout.setBackgroundColor(ContextCompat.getColor(this, R.color.dark_background)) + binding.time.setTextColor(ContextCompat.getColor(this, R.color.dark_midColor)) + binding.iob1.setTextColor(ContextCompat.getColor(this, R.color.dark_midColor)) + binding.iob2.setTextColor(ContextCompat.getColor(this, R.color.dark_midColor)) + binding.cob1.setTextColor(ContextCompat.getColor(this, R.color.dark_midColor)) + binding.cob2.setTextColor(ContextCompat.getColor(this, R.color.dark_midColor)) + binding.day.setTextColor(ContextCompat.getColor(this, R.color.dark_midColor)) + binding.month.setTextColor(ContextCompat.getColor(this, R.color.dark_midColor)) + binding.loop.setTextColor(ContextCompat.getColor(this, R.color.dark_midColor)) setTextSizes() - when (singleBg.sgvLevel) { - 1L -> { - mSgv?.setTextColor(ContextCompat.getColor(this, R.color.dark_highColor)) - mDirection?.setTextColor(ContextCompat.getColor(this, R.color.dark_highColor)) - } - - 0L -> { - mSgv?.setTextColor(ContextCompat.getColor(this, R.color.dark_midColor)) - mDirection?.setTextColor(ContextCompat.getColor(this, R.color.dark_midColor)) - } - - -1L -> { - mSgv?.setTextColor(ContextCompat.getColor(this, R.color.dark_lowColor)) - mDirection?.setTextColor(ContextCompat.getColor(this, R.color.dark_lowColor)) - } + val color = when (singleBg.sgvLevel) { + 1L -> R.color.dark_highColor + 0L -> R.color.dark_midColor + -1L -> R.color.dark_lowColor + else -> R.color.dark_midColor } - if (ageLevel == 1) mTimestamp?.setTextColor(ContextCompat.getColor(this, R.color.dark_midColor)) - else mTimestamp?.setTextColor(ContextCompat.getColor(this, R.color.dark_TimestampOld)) + binding.sgv.setTextColor(ContextCompat.getColor(this, color)) + binding.direction.setTextColor(ContextCompat.getColor(this, color)) - if (status.batteryLevel == 1) mUploaderBattery?.setTextColor(dividerBatteryOkColor) - else mUploaderBattery?.setTextColor(ContextCompat.getColor(this, R.color.dark_uploaderBatteryEmpty)) + val colorTime = if (ageLevel == 1) R.color.dark_midColor else R.color.dark_TimestampOld + binding.timestamp.setTextColor(ContextCompat.getColor(this, colorTime)) + val colourBat = if (status.batteryLevel == 1) dividerBatteryOkColor else ContextCompat.getColor(this, R.color.dark_uploaderBatteryEmpty) + binding.uploaderBattery.setTextColor(colourBat) - mRigBattery?.setTextColor(dividerTxtColor) - mDelta?.setTextColor(dividerTxtColor) - mAvgDelta?.setTextColor(dividerTxtColor) - mBasalRate?.setTextColor(dividerTxtColor) - mBgi?.setTextColor(dividerTxtColor) + binding.rigBattery.setTextColor(dividerTxtColor) + binding.delta.setTextColor(dividerTxtColor) + binding.avgDelta.setTextColor(dividerTxtColor) + binding.basalRate?.setTextColor(dividerTxtColor) + binding.bgi.setTextColor(dividerTxtColor) when (loopLevel) { - -1 -> mLoop?.setBackgroundResource(R.drawable.loop_grey_25) - 1 -> mLoop?.setBackgroundResource(R.drawable.loop_green_25) - else -> mLoop?.setBackgroundResource(R.drawable.loop_red_25) - } - if (chart != null) { - highColor = ContextCompat.getColor(this, R.color.dark_highColor) - lowColor = ContextCompat.getColor(this, R.color.dark_lowColor) - midColor = ContextCompat.getColor(this, R.color.dark_midColor) - gridColor = ContextCompat.getColor(this, R.color.dark_gridColor) - basalBackgroundColor = ContextCompat.getColor(this, R.color.basal_dark) - basalCenterColor = ContextCompat.getColor(this, R.color.basal_light) - pointSize = 2 - setupCharts() + -1 -> binding.loop.setBackgroundResource(R.drawable.loop_grey_25) + 1 -> binding.loop.setBackgroundResource(R.drawable.loop_green_25) + else -> binding.loop.setBackgroundResource(R.drawable.loop_red_25) } + + highColor = ContextCompat.getColor(this, R.color.dark_highColor) + lowColor = ContextCompat.getColor(this, R.color.dark_lowColor) + midColor = ContextCompat.getColor(this, R.color.dark_midColor) + gridColor = ContextCompat.getColor(this, R.color.dark_gridColor) + basalBackgroundColor = ContextCompat.getColor(this, R.color.basal_dark) + basalCenterColor = ContextCompat.getColor(this, R.color.basal_light) + pointSize = 2 + setupCharts() } override fun setColorLowRes() { @ColorInt val dividerTxtColor = if (dividerMatchesBg) ContextCompat.getColor(this, R.color.dark_midColor) else Color.BLACK @ColorInt val dividerBgColor = ContextCompat.getColor(this, if (dividerMatchesBg) R.color.dark_background else R.color.dark_statusView) - mLinearLayout?.setBackgroundColor(dividerBgColor) - mLinearLayout2?.setBackgroundColor(ContextCompat.getColor(this, R.color.dark_background)) - mRelativeLayout?.setBackgroundColor(ContextCompat.getColor(this, R.color.dark_background)) - mLoop?.setBackgroundResource(R.drawable.loop_grey_25) - mLoop?.setTextColor(ContextCompat.getColor(this, R.color.dark_midColor)) - mSgv?.setTextColor(ContextCompat.getColor(this, R.color.dark_midColor)) - mDirection?.setTextColor(ContextCompat.getColor(this, R.color.dark_midColor)) - mTimestamp?.setTextColor(ContextCompat.getColor(this, R.color.dark_Timestamp)) - mDelta?.setTextColor(dividerTxtColor) - mAvgDelta?.setTextColor(dividerTxtColor) - mRigBattery?.setTextColor(dividerTxtColor) - mUploaderBattery?.setTextColor(dividerTxtColor) - mBasalRate?.setTextColor(dividerTxtColor) - mBgi?.setTextColor(dividerTxtColor) - mIOB1?.setTextColor(ContextCompat.getColor(this, R.color.dark_midColor)) - mIOB2?.setTextColor(ContextCompat.getColor(this, R.color.dark_midColor)) - mCOB1?.setTextColor(ContextCompat.getColor(this, R.color.dark_midColor)) - mCOB2?.setTextColor(ContextCompat.getColor(this, R.color.dark_midColor)) - mDay?.setTextColor(ContextCompat.getColor(this, R.color.dark_midColor)) - mMonth?.setTextColor(ContextCompat.getColor(this, R.color.dark_midColor)) - mTime?.setTextColor(ContextCompat.getColor(this, R.color.dark_mTime)) - if (chart != null) { - highColor = ContextCompat.getColor(this, R.color.dark_midColor) - lowColor = ContextCompat.getColor(this, R.color.dark_midColor) - midColor = ContextCompat.getColor(this, R.color.dark_midColor) - gridColor = ContextCompat.getColor(this, R.color.dark_gridColor) - basalBackgroundColor = ContextCompat.getColor(this, R.color.basal_dark_lowres) - basalCenterColor = ContextCompat.getColor(this, R.color.basal_light_lowres) - pointSize = 2 - setupCharts() - } + binding.secondaryLayout.setBackgroundColor(dividerBgColor) + binding.tertiaryLayout.setBackgroundColor(ContextCompat.getColor(this, R.color.dark_background)) + binding.mainLayout.setBackgroundColor(ContextCompat.getColor(this, R.color.dark_background)) + binding.loop.setBackgroundResource(R.drawable.loop_grey_25) + binding.loop.setTextColor(ContextCompat.getColor(this, R.color.dark_midColor)) + binding.sgv.setTextColor(ContextCompat.getColor(this, R.color.dark_midColor)) + binding.direction.setTextColor(ContextCompat.getColor(this, R.color.dark_midColor)) + binding.timestamp.setTextColor(ContextCompat.getColor(this, R.color.dark_Timestamp)) + binding.delta.setTextColor(dividerTxtColor) + binding.avgDelta.setTextColor(dividerTxtColor) + binding.rigBattery.setTextColor(dividerTxtColor) + binding.uploaderBattery.setTextColor(dividerTxtColor) + binding.basalRate?.setTextColor(dividerTxtColor) + binding.bgi.setTextColor(dividerTxtColor) + binding.iob1.setTextColor(ContextCompat.getColor(this, R.color.dark_midColor)) + binding.iob2.setTextColor(ContextCompat.getColor(this, R.color.dark_midColor)) + binding.cob1.setTextColor(ContextCompat.getColor(this, R.color.dark_midColor)) + binding.cob2.setTextColor(ContextCompat.getColor(this, R.color.dark_midColor)) + binding.day.setTextColor(ContextCompat.getColor(this, R.color.dark_midColor)) + binding.month.setTextColor(ContextCompat.getColor(this, R.color.dark_midColor)) + binding.time.setTextColor(ContextCompat.getColor(this, R.color.dark_mTime)) + + highColor = ContextCompat.getColor(this, R.color.dark_midColor) + lowColor = ContextCompat.getColor(this, R.color.dark_midColor) + midColor = ContextCompat.getColor(this, R.color.dark_midColor) + gridColor = ContextCompat.getColor(this, R.color.dark_gridColor) + basalBackgroundColor = ContextCompat.getColor(this, R.color.basal_dark_lowres) + basalCenterColor = ContextCompat.getColor(this, R.color.basal_light_lowres) + pointSize = 2 + setupCharts() + setTextSizes() } @@ -112,58 +111,50 @@ class AapsV2Watchface : BaseWatchFace() { if (currentWatchMode == WatchMode.INTERACTIVE) { @ColorInt val dividerTxtColor = if (dividerMatchesBg) Color.BLACK else ContextCompat.getColor(this, R.color.dark_midColor) @ColorInt val dividerBgColor = ContextCompat.getColor(this, if (dividerMatchesBg) R.color.light_background else R.color.light_stripe_background) - mLinearLayout?.setBackgroundColor(dividerBgColor) - mLinearLayout2?.setBackgroundColor(ContextCompat.getColor(this, R.color.light_background)) - mRelativeLayout?.setBackgroundColor(ContextCompat.getColor(this, R.color.light_background)) - mTime?.setTextColor(Color.BLACK) - mIOB1?.setTextColor(Color.BLACK) - mIOB2?.setTextColor(Color.BLACK) - mCOB1?.setTextColor(Color.BLACK) - mCOB2?.setTextColor(Color.BLACK) - mDay?.setTextColor(Color.BLACK) - mMonth?.setTextColor(Color.BLACK) - mLoop?.setTextColor(Color.BLACK) + binding.secondaryLayout.setBackgroundColor(dividerBgColor) + binding.tertiaryLayout.setBackgroundColor(ContextCompat.getColor(this, R.color.light_background)) + binding.mainLayout.setBackgroundColor(ContextCompat.getColor(this, R.color.light_background)) + binding.time.setTextColor(Color.BLACK) + binding.iob1.setTextColor(Color.BLACK) + binding.iob2.setTextColor(Color.BLACK) + binding.cob1.setTextColor(Color.BLACK) + binding.cob2.setTextColor(Color.BLACK) + binding.day.setTextColor(Color.BLACK) + binding.month.setTextColor(Color.BLACK) + binding.loop.setTextColor(Color.BLACK) setTextSizes() - when (singleBg.sgvLevel) { - 1L -> { - mSgv?.setTextColor(ContextCompat.getColor(this, R.color.light_highColor)) - mDirection?.setTextColor(ContextCompat.getColor(this, R.color.light_highColor)) - } - - 0L -> { - mSgv?.setTextColor(ContextCompat.getColor(this, R.color.light_midColor)) - mDirection?.setTextColor(ContextCompat.getColor(this, R.color.light_midColor)) - } - - -1L -> { - mSgv?.setTextColor(ContextCompat.getColor(this, R.color.light_lowColor)) - mDirection?.setTextColor(ContextCompat.getColor(this, R.color.light_lowColor)) - } + val color = when (singleBg.sgvLevel) { + 1L -> R.color.light_highColor + 0L -> R.color.light_midColor + -1L -> R.color.light_lowColor + else -> R.color.light_midColor } - if (ageLevel == 1) mTimestamp?.setTextColor(Color.BLACK) - else mTimestamp?.setTextColor(Color.RED) - if (status.batteryLevel == 1) mUploaderBattery?.setTextColor(dividerTxtColor) - else mUploaderBattery?.setTextColor(Color.RED) - mRigBattery?.setTextColor(dividerTxtColor) - mDelta?.setTextColor(dividerTxtColor) - mAvgDelta?.setTextColor(dividerTxtColor) - mBasalRate?.setTextColor(dividerTxtColor) - mBgi?.setTextColor(dividerTxtColor) + binding.sgv.setTextColor(ContextCompat.getColor(this, color)) + binding.direction.setTextColor(ContextCompat.getColor(this, color)) + val colorTime = if (ageLevel == 1) Color.BLACK else Color.RED + binding.timestamp.setTextColor(colorTime) + val colourBat = if (status.batteryLevel == 1) dividerTxtColor else Color.RED + binding.uploaderBattery.setTextColor(colourBat) + binding.rigBattery.setTextColor(dividerTxtColor) + binding.delta.setTextColor(dividerTxtColor) + binding.avgDelta.setTextColor(dividerTxtColor) + binding.basalRate?.setTextColor(dividerTxtColor) + binding.bgi.setTextColor(dividerTxtColor) when (loopLevel) { - -1 -> mLoop?.setBackgroundResource(R.drawable.loop_grey_25) - 1 -> mLoop?.setBackgroundResource(R.drawable.loop_green_25) - else -> mLoop?.setBackgroundResource(R.drawable.loop_red_25) - } - if (chart != null) { - highColor = ContextCompat.getColor(this, R.color.light_highColor) - lowColor = ContextCompat.getColor(this, R.color.light_lowColor) - midColor = ContextCompat.getColor(this, R.color.light_midColor) - gridColor = ContextCompat.getColor(this, R.color.light_gridColor) - basalBackgroundColor = ContextCompat.getColor(this, R.color.basal_light) - basalCenterColor = ContextCompat.getColor(this, R.color.basal_dark) - pointSize = 2 - setupCharts() + -1 -> binding.loop.setBackgroundResource(R.drawable.loop_grey_25) + 1 -> binding.loop.setBackgroundResource(R.drawable.loop_green_25) + else -> binding.loop.setBackgroundResource(R.drawable.loop_red_25) } + + highColor = ContextCompat.getColor(this, R.color.light_highColor) + lowColor = ContextCompat.getColor(this, R.color.light_lowColor) + midColor = ContextCompat.getColor(this, R.color.light_midColor) + gridColor = ContextCompat.getColor(this, R.color.light_gridColor) + basalBackgroundColor = ContextCompat.getColor(this, R.color.basal_light) + basalCenterColor = ContextCompat.getColor(this, R.color.basal_dark) + pointSize = 2 + setupCharts() + } else { setColorDark() } @@ -171,11 +162,11 @@ class AapsV2Watchface : BaseWatchFace() { private fun setTextSizes() { if (status.detailedIob) { - mIOB1?.textSize = 14f - mIOB2?.textSize = 10f + binding.iob1.textSize = 14f + binding.iob2.textSize = 10f } else { - mIOB1?.textSize = 10f - mIOB2?.textSize = 14f + binding.iob1.textSize = 10f + binding.iob2.textSize = 14f } } -} \ No newline at end of file +} diff --git a/wear/src/main/java/info/nightscout/androidaps/watchfaces/AapsWatchface.kt b/wear/src/main/java/info/nightscout/androidaps/watchfaces/AapsWatchface.kt index 48e457a3d1..4086d479ec 100644 --- a/wear/src/main/java/info/nightscout/androidaps/watchfaces/AapsWatchface.kt +++ b/wear/src/main/java/info/nightscout/androidaps/watchfaces/AapsWatchface.kt @@ -1,114 +1,106 @@ package info.nightscout.androidaps.watchfaces import android.graphics.Color -import androidx.annotation.LayoutRes +import android.view.LayoutInflater import androidx.core.content.ContextCompat +import androidx.viewbinding.ViewBinding import com.ustwo.clockwise.common.WatchMode import info.nightscout.androidaps.R +import info.nightscout.androidaps.watchfaces.utils.BaseWatchFace +import info.nightscout.androidaps.databinding.ActivityHomeBinding class AapsWatchface : BaseWatchFace() { - @LayoutRes override fun layoutResource(): Int = R.layout.activity_home + private lateinit var binding: ActivityHomeBinding + + override fun inflateLayout(inflater: LayoutInflater): ViewBinding { + binding = ActivityHomeBinding.inflate(inflater) + return binding + } override fun setColorDark() { - mLinearLayout?.setBackgroundColor(ContextCompat.getColor(this, if (dividerMatchesBg) R.color.dark_background else R.color.dark_statusView)) - mTime?.setTextColor(ContextCompat.getColor(this, R.color.dark_mTime)) - mRelativeLayout?.setBackgroundColor(ContextCompat.getColor(this, R.color.dark_background)) - when (singleBg.sgvLevel) { - 1L -> { - mSgv?.setTextColor(ContextCompat.getColor(this, R.color.dark_highColor)) - mDelta?.setTextColor(ContextCompat.getColor(this, R.color.dark_highColor)) - mDirection?.setTextColor(ContextCompat.getColor(this, R.color.dark_highColor)) - } - - 0L -> { - mSgv?.setTextColor(ContextCompat.getColor(this, R.color.dark_midColor)) - mDelta?.setTextColor(ContextCompat.getColor(this, R.color.dark_midColor)) - mDirection?.setTextColor(ContextCompat.getColor(this, R.color.dark_midColor)) - } - - -1L -> { - mSgv?.setTextColor(ContextCompat.getColor(this, R.color.dark_lowColor)) - mDelta?.setTextColor(ContextCompat.getColor(this, R.color.dark_lowColor)) - mDirection?.setTextColor(ContextCompat.getColor(this, R.color.dark_lowColor)) - } - } - if (ageLevel == 1) mTimestamp?.setTextColor(ContextCompat.getColor(this, if (dividerMatchesBg) R.color.dark_midColor else R.color.dark_mTimestamp1_home)) - else mTimestamp?.setTextColor(ContextCompat.getColor(this, R.color.dark_TimestampOld)) - if (status.batteryLevel == 1) mUploaderBattery?.setTextColor(ContextCompat.getColor(this, if (dividerMatchesBg) R.color.dark_midColor else R.color.dark_uploaderBattery)) - else mUploaderBattery?.setTextColor(ContextCompat.getColor(this, R.color.dark_uploaderBatteryEmpty)) - mStatus?.setTextColor(ContextCompat.getColor(this, if (dividerMatchesBg) R.color.dark_midColor else R.color.dark_mStatus_home)) - if (chart != null) { - highColor = ContextCompat.getColor(this, R.color.dark_highColor) - lowColor = ContextCompat.getColor(this, R.color.dark_lowColor) - midColor = ContextCompat.getColor(this, R.color.dark_midColor) - gridColor = ContextCompat.getColor(this, R.color.dark_gridColor) - basalBackgroundColor = ContextCompat.getColor(this, R.color.basal_dark) - basalCenterColor = ContextCompat.getColor(this, R.color.basal_light) - pointSize = 2 - setupCharts() + binding.secondaryLayout.setBackgroundColor(ContextCompat.getColor(this, if (dividerMatchesBg) R.color.dark_background else R.color.dark_statusView)) + binding.time.setTextColor(ContextCompat.getColor(this, R.color.dark_mTime)) + val color = when (singleBg.sgvLevel) { + 1L -> R.color.dark_highColor + 0L -> R.color.dark_midColor + -1L -> R.color.dark_lowColor + else -> R.color.dark_midColor } + binding.sgv.setTextColor(ContextCompat.getColor(this, color)) + binding.delta.setTextColor(ContextCompat.getColor(this, color)) + binding.direction.setTextColor(ContextCompat.getColor(this, color)) + + val colorTime = if (ageLevel == 1) if (dividerMatchesBg) R.color.dark_midColor else R.color.dark_mTimestamp1_home else R.color.dark_TimestampOld + binding.timestamp.setTextColor(ContextCompat.getColor(this, colorTime)) + + val colourBat = if (status.batteryLevel == 1) if (dividerMatchesBg) R.color.dark_midColor else R.color.dark_uploaderBattery else R.color.dark_uploaderBatteryEmpty + binding.uploaderBattery.setTextColor(ContextCompat.getColor(this, colourBat)) + + binding.status.setTextColor(ContextCompat.getColor(this, if (dividerMatchesBg) R.color.dark_midColor else R.color.dark_mStatus_home)) + + highColor = ContextCompat.getColor(this, R.color.dark_highColor) + lowColor = ContextCompat.getColor(this, R.color.dark_lowColor) + midColor = ContextCompat.getColor(this, R.color.dark_midColor) + gridColor = ContextCompat.getColor(this, R.color.dark_gridColor) + basalBackgroundColor = ContextCompat.getColor(this, R.color.basal_dark) + basalCenterColor = ContextCompat.getColor(this, R.color.basal_light) + pointSize = 2 + setupCharts() + } override fun setColorLowRes() { - mTime?.setTextColor(ContextCompat.getColor(this, R.color.dark_mTime)) - mRelativeLayout?.setBackgroundColor(ContextCompat.getColor(this, R.color.dark_background)) - mSgv?.setTextColor(ContextCompat.getColor(this, R.color.dark_midColor)) - mDelta?.setTextColor(ContextCompat.getColor(this, R.color.dark_midColor)) - mTimestamp?.setTextColor(ContextCompat.getColor(this, R.color.dark_Timestamp)) - if (chart != null) { - highColor = ContextCompat.getColor(this, R.color.dark_midColor) - lowColor = ContextCompat.getColor(this, R.color.dark_midColor) - midColor = ContextCompat.getColor(this, R.color.dark_midColor) - gridColor = ContextCompat.getColor(this, R.color.dark_gridColor) - basalBackgroundColor = ContextCompat.getColor(this, R.color.basal_dark_lowres) - basalCenterColor = ContextCompat.getColor(this, R.color.basal_light_lowres) - pointSize = 2 - setupCharts() - } + binding.time.setTextColor(ContextCompat.getColor(this, R.color.dark_mTime)) + binding.mainLayout.setBackgroundColor(ContextCompat.getColor(this, R.color.dark_background)) + binding.sgv.setTextColor(ContextCompat.getColor(this, R.color.dark_midColor)) + binding.delta.setTextColor(ContextCompat.getColor(this, R.color.dark_midColor)) + binding.timestamp.setTextColor(ContextCompat.getColor(this, R.color.dark_Timestamp)) + + highColor = ContextCompat.getColor(this, R.color.dark_midColor) + lowColor = ContextCompat.getColor(this, R.color.dark_midColor) + midColor = ContextCompat.getColor(this, R.color.dark_midColor) + gridColor = ContextCompat.getColor(this, R.color.dark_gridColor) + basalBackgroundColor = ContextCompat.getColor(this, R.color.basal_dark_lowres) + basalCenterColor = ContextCompat.getColor(this, R.color.basal_light_lowres) + pointSize = 2 + setupCharts() } override fun setColorBright() { if (currentWatchMode == WatchMode.INTERACTIVE) { - mLinearLayout?.setBackgroundColor(ContextCompat.getColor(this, if (dividerMatchesBg) R.color.light_background else R.color.light_stripe_background)) - mRelativeLayout?.setBackgroundColor(ContextCompat.getColor(this, R.color.light_background)) - when (singleBg.sgvLevel) { - 1L -> { - mSgv?.setTextColor(ContextCompat.getColor(this, R.color.light_highColor)) - mDelta?.setTextColor(ContextCompat.getColor(this, R.color.light_highColor)) - mDirection?.setTextColor(ContextCompat.getColor(this, R.color.light_highColor)) - } - - 0L -> { - mSgv?.setTextColor(ContextCompat.getColor(this, R.color.light_midColor)) - mDelta?.setTextColor(ContextCompat.getColor(this, R.color.light_midColor)) - mDirection?.setTextColor(ContextCompat.getColor(this, R.color.light_midColor)) - } - - -1L -> { - mSgv?.setTextColor(ContextCompat.getColor(this, R.color.light_lowColor)) - mDelta?.setTextColor(ContextCompat.getColor(this, R.color.light_lowColor)) - mDirection?.setTextColor(ContextCompat.getColor(this, R.color.light_lowColor)) - } - } - if (ageLevel == 1) mTimestamp?.setTextColor(if (dividerMatchesBg) Color.BLACK else Color.WHITE) - else mTimestamp?.setTextColor(Color.RED) - if (status.batteryLevel == 1) mUploaderBattery?.setTextColor(if (dividerMatchesBg) Color.BLACK else Color.WHITE) - else mUploaderBattery?.setTextColor(Color.RED) - mStatus?.setTextColor(if (dividerMatchesBg) Color.BLACK else Color.WHITE) - mTime?.setTextColor(Color.BLACK) - if (chart != null) { - highColor = ContextCompat.getColor(this, R.color.light_highColor) - lowColor = ContextCompat.getColor(this, R.color.light_lowColor) - midColor = ContextCompat.getColor(this, R.color.light_midColor) - gridColor = ContextCompat.getColor(this, R.color.light_gridColor) - basalBackgroundColor = ContextCompat.getColor(this, R.color.basal_light) - basalCenterColor = ContextCompat.getColor(this, R.color.basal_dark) - pointSize = 2 - setupCharts() + binding.secondaryLayout.setBackgroundColor(ContextCompat.getColor(this, if (dividerMatchesBg) R.color.light_background else R.color.light_stripe_background)) + binding.mainLayout.setBackgroundColor(ContextCompat.getColor(this, R.color.light_background)) + val color = when (singleBg.sgvLevel) { + 1L -> R.color.light_highColor + 0L -> R.color.light_midColor + -1L -> R.color.light_lowColor + else -> R.color.light_midColor } + binding.sgv.setTextColor(ContextCompat.getColor(this, color)) + binding.delta.setTextColor(ContextCompat.getColor(this, color)) + binding.direction.setTextColor(ContextCompat.getColor(this, color)) + + val colorTime = if (ageLevel == 1) if (dividerMatchesBg) Color.BLACK else Color.WHITE else Color.RED + binding.timestamp.setTextColor(colorTime) + + val colourBat = if (status.batteryLevel == 1) if (dividerMatchesBg) Color.BLACK else Color.WHITE else Color.RED + binding.uploaderBattery.setTextColor(colourBat) + + binding.status.setTextColor(if (dividerMatchesBg) Color.BLACK else Color.WHITE) + binding.time.setTextColor(Color.BLACK) + + highColor = ContextCompat.getColor(this, R.color.light_highColor) + lowColor = ContextCompat.getColor(this, R.color.light_lowColor) + midColor = ContextCompat.getColor(this, R.color.light_midColor) + gridColor = ContextCompat.getColor(this, R.color.light_gridColor) + basalBackgroundColor = ContextCompat.getColor(this, R.color.basal_light) + basalCenterColor = ContextCompat.getColor(this, R.color.basal_dark) + pointSize = 2 + setupCharts() + } else { setColorDark() } } -} \ No newline at end of file +} diff --git a/wear/src/main/java/info/nightscout/androidaps/watchfaces/BigChartWatchface.kt b/wear/src/main/java/info/nightscout/androidaps/watchfaces/BigChartWatchface.kt index 698ce41142..f6b472797b 100644 --- a/wear/src/main/java/info/nightscout/androidaps/watchfaces/BigChartWatchface.kt +++ b/wear/src/main/java/info/nightscout/androidaps/watchfaces/BigChartWatchface.kt @@ -3,119 +3,110 @@ package info.nightscout.androidaps.watchfaces import android.annotation.SuppressLint -import androidx.annotation.LayoutRes +import android.view.LayoutInflater import androidx.core.content.ContextCompat +import androidx.viewbinding.ViewBinding import com.ustwo.clockwise.common.WatchMode import info.nightscout.androidaps.R +import info.nightscout.androidaps.databinding.ActivityBigchartBinding +import info.nightscout.androidaps.databinding.ActivityBigchartSmallBinding +import info.nightscout.androidaps.watchfaces.utils.BaseWatchFace +import info.nightscout.androidaps.watchfaces.utils.WatchfaceViewAdapter class BigChartWatchface : BaseWatchFace() { - @LayoutRes override fun layoutResource(): Int = - if (resources.displayMetrics.widthPixels < SCREEN_SIZE_SMALL || resources.displayMetrics.heightPixels < SCREEN_SIZE_SMALL) R.layout.activity_bigchart_small - else R.layout.activity_bigchart + private lateinit var binding: WatchfaceViewAdapter + + override fun inflateLayout(inflater: LayoutInflater): ViewBinding { + if (resources.displayMetrics.widthPixels < SCREEN_SIZE_SMALL || resources.displayMetrics.heightPixels < SCREEN_SIZE_SMALL) { + val layoutBinding = ActivityBigchartSmallBinding.inflate(inflater) + binding = WatchfaceViewAdapter.getBinding(layoutBinding) + return layoutBinding + } + val layoutBinding = ActivityBigchartBinding.inflate(inflater) + binding = WatchfaceViewAdapter.getBinding(layoutBinding) + return layoutBinding + } @SuppressLint("SetTextI18n") override fun setDataFields() { super.setDataFields() - mStatus?.text = status.externalStatus + if (sp.getBoolean(R.string.key_show_cob, true)) (" " + this.status.cob) else "" + binding.status?.text = status.externalStatus + if (sp.getBoolean(R.string.key_show_cob, true)) (" " + this.status.cob) else "" } override fun setColorLowRes() { - mTime?.setTextColor(ContextCompat.getColor(this, R.color.dark_mTime)) - mStatus?.setTextColor(ContextCompat.getColor(this, R.color.dark_statusView)) - mRelativeLayout?.setBackgroundColor(ContextCompat.getColor(this, R.color.dark_background)) - mSgv?.setTextColor(ContextCompat.getColor(this, R.color.dark_midColor)) - mDelta?.setTextColor(ContextCompat.getColor(this, R.color.dark_midColor)) - mAvgDelta?.setTextColor(ContextCompat.getColor(this, R.color.dark_midColor)) - mTimestamp?.setTextColor(ContextCompat.getColor(this, R.color.dark_Timestamp)) - if (chart != null) { - highColor = ContextCompat.getColor(this, R.color.dark_midColor) - lowColor = ContextCompat.getColor(this, R.color.dark_midColor) - midColor = ContextCompat.getColor(this, R.color.dark_midColor) - gridColor = ContextCompat.getColor(this, R.color.dark_gridColor) - basalBackgroundColor = ContextCompat.getColor(this, R.color.basal_dark_lowres) - basalCenterColor = ContextCompat.getColor(this, R.color.basal_light_lowres) - pointSize = 2 - setupCharts() - } + binding.time?.setTextColor(ContextCompat.getColor(this, R.color.dark_mTime)) + binding.status?.setTextColor(ContextCompat.getColor(this, R.color.dark_statusView)) + binding.mainLayout.setBackgroundColor(ContextCompat.getColor(this, R.color.dark_background)) + binding.sgv?.setTextColor(ContextCompat.getColor(this, R.color.dark_midColor)) + binding.delta?.setTextColor(ContextCompat.getColor(this, R.color.dark_midColor)) + binding.avgDelta?.setTextColor(ContextCompat.getColor(this, R.color.dark_midColor)) + binding.timestamp.setTextColor(ContextCompat.getColor(this, R.color.dark_Timestamp)) + + highColor = ContextCompat.getColor(this, R.color.dark_midColor) + lowColor = ContextCompat.getColor(this, R.color.dark_midColor) + midColor = ContextCompat.getColor(this, R.color.dark_midColor) + gridColor = ContextCompat.getColor(this, R.color.dark_gridColor) + basalBackgroundColor = ContextCompat.getColor(this, R.color.basal_dark_lowres) + basalCenterColor = ContextCompat.getColor(this, R.color.basal_light_lowres) + pointSize = 2 + setupCharts() } override fun setColorDark() { - mTime?.setTextColor(ContextCompat.getColor(this, R.color.dark_mTime)) - mStatus?.setTextColor(ContextCompat.getColor(this, R.color.dark_statusView)) - mRelativeLayout?.setBackgroundColor(ContextCompat.getColor(this, R.color.dark_background)) - when (singleBg.sgvLevel) { - 1L -> { - mSgv?.setTextColor(ContextCompat.getColor(this, R.color.dark_highColor)) - mDelta?.setTextColor(ContextCompat.getColor(this, R.color.dark_highColor)) - mAvgDelta?.setTextColor(ContextCompat.getColor(this, R.color.dark_highColor)) - } + binding.time?.setTextColor(ContextCompat.getColor(this, R.color.dark_mTime)) + binding.status?.setTextColor(ContextCompat.getColor(this, R.color.dark_statusView)) + binding.mainLayout.setBackgroundColor(ContextCompat.getColor(this, R.color.dark_background)) + val color = when (singleBg.sgvLevel) { + 1L -> R.color.dark_highColor + 0L -> R.color.dark_midColor + -1L -> R.color.dark_lowColor + else -> R.color.dark_midColor + } + binding.sgv?.setTextColor(ContextCompat.getColor(this, color)) + binding.delta?.setTextColor(ContextCompat.getColor(this, color)) + binding.avgDelta?.setTextColor(ContextCompat.getColor(this, color)) - 0L -> { - mSgv?.setTextColor(ContextCompat.getColor(this, R.color.dark_midColor)) - mDelta?.setTextColor(ContextCompat.getColor(this, R.color.dark_midColor)) - mAvgDelta?.setTextColor(ContextCompat.getColor(this, R.color.dark_midColor)) - } + val colorTime = if (ageLevel == 1) R.color.dark_Timestamp else R.color.dark_TimestampOld + binding.timestamp.setTextColor(ContextCompat.getColor(this, colorTime)) - -1L -> { - mSgv?.setTextColor(ContextCompat.getColor(this, R.color.dark_lowColor)) - mDelta?.setTextColor(ContextCompat.getColor(this, R.color.dark_lowColor)) - mAvgDelta?.setTextColor(ContextCompat.getColor(this, R.color.dark_lowColor)) - } - } - if (ageLevel == 1) { - mTimestamp?.setTextColor(ContextCompat.getColor(this, R.color.dark_Timestamp)) - } else { - mTimestamp?.setTextColor(ContextCompat.getColor(this, R.color.dark_TimestampOld)) - } - if (chart != null) { - highColor = ContextCompat.getColor(this, R.color.dark_highColor) - lowColor = ContextCompat.getColor(this, R.color.dark_lowColor) - midColor = ContextCompat.getColor(this, R.color.dark_midColor) - gridColor = ContextCompat.getColor(this, R.color.dark_gridColor) - basalBackgroundColor = ContextCompat.getColor(this, R.color.basal_dark) - basalCenterColor = ContextCompat.getColor(this, R.color.basal_light) - pointSize = 2 - setupCharts() - } + highColor = ContextCompat.getColor(this, R.color.dark_highColor) + lowColor = ContextCompat.getColor(this, R.color.dark_lowColor) + midColor = ContextCompat.getColor(this, R.color.dark_midColor) + gridColor = ContextCompat.getColor(this, R.color.dark_gridColor) + basalBackgroundColor = ContextCompat.getColor(this, R.color.basal_dark) + basalCenterColor = ContextCompat.getColor(this, R.color.basal_light) + pointSize = 2 + setupCharts() } override fun setColorBright() { if (currentWatchMode == WatchMode.INTERACTIVE) { - mTime?.setTextColor(ContextCompat.getColor(this, R.color.light_bigchart_time)) - mStatus?.setTextColor(ContextCompat.getColor(this, R.color.light_bigchart_status)) - mRelativeLayout?.setBackgroundColor(ContextCompat.getColor(this, R.color.light_background)) - when (singleBg.sgvLevel) { - 1L -> { - mSgv?.setTextColor(ContextCompat.getColor(this, R.color.light_highColor)) - mDelta?.setTextColor(ContextCompat.getColor(this, R.color.light_highColor)) - mAvgDelta?.setTextColor(ContextCompat.getColor(this, R.color.light_highColor)) - } - - 0L -> { - mSgv?.setTextColor(ContextCompat.getColor(this, R.color.light_midColor)) - mDelta?.setTextColor(ContextCompat.getColor(this, R.color.light_midColor)) - mAvgDelta?.setTextColor(ContextCompat.getColor(this, R.color.light_midColor)) - } - - -1L -> { - mSgv?.setTextColor(ContextCompat.getColor(this, R.color.light_lowColor)) - mDelta?.setTextColor(ContextCompat.getColor(this, R.color.light_lowColor)) - mAvgDelta?.setTextColor(ContextCompat.getColor(this, R.color.light_lowColor)) - } - } - if (ageLevel == 1) mTimestamp?.setTextColor(ContextCompat.getColor(this, R.color.light_mTimestamp1)) - else mTimestamp?.setTextColor(ContextCompat.getColor(this, R.color.light_mTimestamp)) - if (chart != null) { - highColor = ContextCompat.getColor(this, R.color.light_highColor) - lowColor = ContextCompat.getColor(this, R.color.light_lowColor) - midColor = ContextCompat.getColor(this, R.color.light_midColor) - gridColor = ContextCompat.getColor(this, R.color.light_gridColor) - basalBackgroundColor = ContextCompat.getColor(this, R.color.basal_light) - basalCenterColor = ContextCompat.getColor(this, R.color.basal_dark) - pointSize = 2 - setupCharts() + binding.time?.setTextColor(ContextCompat.getColor(this, R.color.light_bigchart_time)) + binding.status?.setTextColor(ContextCompat.getColor(this, R.color.light_bigchart_status)) + binding.mainLayout.setBackgroundColor(ContextCompat.getColor(this, R.color.light_background)) + val color = when (singleBg.sgvLevel) { + 1L -> R.color.light_highColor + 0L -> R.color.light_midColor + -1L -> R.color.light_lowColor + else -> R.color.light_midColor } + binding.sgv?.setTextColor(ContextCompat.getColor(this, color)) + binding.delta?.setTextColor(ContextCompat.getColor(this, color)) + binding.avgDelta?.setTextColor(ContextCompat.getColor(this, color)) + + val colorTime = if (ageLevel == 1) R.color.light_mTimestamp1 else R.color.light_mTimestamp + binding.timestamp.setTextColor(ContextCompat.getColor(this, colorTime)) + + highColor = ContextCompat.getColor(this, R.color.light_highColor) + lowColor = ContextCompat.getColor(this, R.color.light_lowColor) + midColor = ContextCompat.getColor(this, R.color.light_midColor) + gridColor = ContextCompat.getColor(this, R.color.light_gridColor) + basalBackgroundColor = ContextCompat.getColor(this, R.color.basal_light) + basalCenterColor = ContextCompat.getColor(this, R.color.basal_dark) + pointSize = 2 + setupCharts() + } else { setColorDark() } diff --git a/wear/src/main/java/info/nightscout/androidaps/watchfaces/CockpitWatchface.kt b/wear/src/main/java/info/nightscout/androidaps/watchfaces/CockpitWatchface.kt index cb15fbc7f9..2736b49e1b 100644 --- a/wear/src/main/java/info/nightscout/androidaps/watchfaces/CockpitWatchface.kt +++ b/wear/src/main/java/info/nightscout/androidaps/watchfaces/CockpitWatchface.kt @@ -1,8 +1,11 @@ package info.nightscout.androidaps.watchfaces +import android.view.LayoutInflater import android.view.View -import androidx.annotation.LayoutRes +import androidx.viewbinding.ViewBinding import info.nightscout.androidaps.R +import info.nightscout.androidaps.databinding.ActivityCockpitBinding +import info.nightscout.androidaps.watchfaces.utils.BaseWatchFace /** * Created by andrew-warrington on 18/11/2017. @@ -10,37 +13,36 @@ import info.nightscout.androidaps.R */ class CockpitWatchface : BaseWatchFace() { - @LayoutRes override fun layoutResource(): Int = R.layout.activity_cockpit + private lateinit var binding: ActivityCockpitBinding + + override fun inflateLayout(inflater: LayoutInflater): ViewBinding { + binding = ActivityCockpitBinding.inflate(inflater) + return binding + } override fun setColorDark() { - mRelativeLayout?.setBackgroundResource(R.drawable.airplane_cockpit_outside_clouds) + binding.mainLayout.setBackgroundResource(R.drawable.airplane_cockpit_outside_clouds) setTextSizes() - when (singleBg.sgvLevel) { - 1L -> { - mHighLight?.setBackgroundResource(R.drawable.airplane_led_yellow_lit) - mLowLight?.setBackgroundResource(R.drawable.airplane_led_grey_unlit) - } - - 0L -> { - mHighLight?.setBackgroundResource(R.drawable.airplane_led_grey_unlit) - mLowLight?.setBackgroundResource(R.drawable.airplane_led_grey_unlit) - } - - -1L -> { - mHighLight?.setBackgroundResource(R.drawable.airplane_led_grey_unlit) - mLowLight?.setBackgroundResource(R.drawable.airplane_led_red_lit) - } + val led = when (singleBg.sgvLevel) { + 1L -> R.drawable.airplane_led_yellow_lit + 0L -> R.drawable.airplane_led_grey_unlit + -1L -> R.drawable.airplane_led_red_lit + else -> R.drawable.airplane_led_grey_unlit } + + binding.highLight.setBackgroundResource(led) + binding.lowLight.setBackgroundResource(led) + when (loopLevel) { - -1 -> mLoop?.setBackgroundResource(R.drawable.loop_grey_25) - 1 -> mLoop?.setBackgroundResource(R.drawable.loop_green_25) - else -> mLoop?.setBackgroundResource(R.drawable.loop_red_25) + -1 -> binding.loop.setBackgroundResource(R.drawable.loop_grey_25) + 1 -> binding.loop.setBackgroundResource(R.drawable.loop_green_25) + else -> binding.loop.setBackgroundResource(R.drawable.loop_red_25) } invalidate() } override fun setColorLowRes() { - mRelativeLayout?.setBackgroundResource(R.drawable.airplane_cockpit_outside_clouds_lowres) + binding.mainLayout.setBackgroundResource(R.drawable.airplane_cockpit_outside_clouds_lowres) } override fun setColorBright() { @@ -49,28 +51,28 @@ class CockpitWatchface : BaseWatchFace() { private fun setTextSizes() { if (status.detailedIob) { - if (bIsRound) mIOB2?.textSize = 10f - else mIOB2?.textSize = 9f + if (bIsRound) binding.iob2.textSize = 10f + else binding.iob2.textSize = 9f } else { - if (bIsRound) mIOB2?.textSize = 13f - else mIOB2?.textSize = 12f + if (bIsRound) binding.iob2.textSize = 13f + else binding.iob2.textSize = 12f } - if (mUploaderBattery?.visibility != View.GONE && mRigBattery?.visibility != View.GONE) { + if (binding.uploaderBattery.visibility != View.GONE && binding.rigBattery.visibility != View.GONE) { if (bIsRound) { - mUploaderBattery?.textSize = 12f - mRigBattery?.textSize = 12f + binding.uploaderBattery.textSize = 12f + binding.rigBattery.textSize = 12f } else { - mUploaderBattery?.textSize = 10f - mRigBattery?.textSize = 10f + binding.uploaderBattery.textSize = 10f + binding.rigBattery.textSize = 10f } } else { if (bIsRound) { - mUploaderBattery?.textSize = 13f - mRigBattery?.textSize = 13f + binding.uploaderBattery.textSize = 13f + binding.rigBattery.textSize = 13f } else { - mUploaderBattery?.textSize = 12f - mRigBattery?.textSize = 12f + binding.uploaderBattery.textSize = 12f + binding.rigBattery.textSize = 12f } } } -} \ No newline at end of file +} diff --git a/wear/src/main/java/info/nightscout/androidaps/watchfaces/DigitalStyleWatchface.kt b/wear/src/main/java/info/nightscout/androidaps/watchfaces/DigitalStyleWatchface.kt index de808a21be..d2aa2257fa 100644 --- a/wear/src/main/java/info/nightscout/androidaps/watchfaces/DigitalStyleWatchface.kt +++ b/wear/src/main/java/info/nightscout/androidaps/watchfaces/DigitalStyleWatchface.kt @@ -4,18 +4,26 @@ package info.nightscout.androidaps.watchfaces import android.annotation.SuppressLint import android.support.wearable.watchface.WatchFaceStyle +import android.view.LayoutInflater import android.view.View import android.widget.LinearLayout import android.widget.TextView -import androidx.annotation.LayoutRes import androidx.core.content.ContextCompat +import androidx.viewbinding.ViewBinding import info.nightscout.androidaps.R +import info.nightscout.androidaps.databinding.ActivityDigitalstyleBinding import info.nightscout.androidaps.extensions.toVisibility +import info.nightscout.androidaps.watchfaces.utils.BaseWatchFace import info.nightscout.shared.logging.LTag class DigitalStyleWatchface : BaseWatchFace() { - @LayoutRes override fun layoutResource(): Int = R.layout.activity_digitalstyle + private lateinit var binding: ActivityDigitalstyleBinding + + override fun inflateLayout(inflater: LayoutInflater): ViewBinding { + binding = ActivityDigitalstyleBinding.inflate(inflater) + return binding + } override fun getWatchFaceStyle(): WatchFaceStyle { return WatchFaceStyle.Builder(this) @@ -26,39 +34,31 @@ class DigitalStyleWatchface : BaseWatchFace() { } override fun setColorDark() { - when (singleBg.sgvLevel) { - 1L -> { - mSgv?.setTextColor(ContextCompat.getColor(this, R.color.dark_highColor)) - mDirection?.setTextColor(ContextCompat.getColor(this, R.color.dark_highColor)) - } - - 0L -> { - mSgv?.setTextColor(ContextCompat.getColor(this, R.color.dark_midColor)) - mDirection?.setTextColor(ContextCompat.getColor(this, R.color.dark_midColor)) - } - - -1L -> { - mSgv?.setTextColor(ContextCompat.getColor(this, R.color.dark_lowColor)) - mDirection?.setTextColor(ContextCompat.getColor(this, R.color.dark_lowColor)) - } + val color = when (singleBg.sgvLevel) { + 1L -> R.color.dark_highColor + 0L -> R.color.dark_midColor + -1L -> R.color.dark_lowColor + else -> R.color.dark_midColor } - if (ageLevel == 1) mTimestamp?.setTextColor(ContextCompat.getColor(this, R.color.dark_midColor)) - else mTimestamp?.setTextColor(ContextCompat.getColor(this, R.color.dark_TimestampOld)) + binding.sgv.setTextColor(ContextCompat.getColor(this, color)) + binding.direction.setTextColor(ContextCompat.getColor(this, color)) - if (status.batteryLevel == 1) mUploaderBattery?.setTextColor(ContextCompat.getColor(this, R.color.dark_midColor)) - else mUploaderBattery?.setTextColor(ContextCompat.getColor(this, R.color.dark_uploaderBatteryEmpty)) + val colorTime = if (ageLevel == 1) R.color.dark_midColor else R.color.dark_TimestampOld + binding.timestamp.setTextColor(ContextCompat.getColor(this, colorTime)) + + val colorBat = if (status.batteryLevel == 1) R.color.dark_midColor else R.color.dark_uploaderBatteryEmpty + binding.uploaderBattery.setTextColor(ContextCompat.getColor(this, colorBat)) + + highColor = ContextCompat.getColor(this, R.color.dark_highColor) + lowColor = ContextCompat.getColor(this, R.color.dark_lowColor) + midColor = ContextCompat.getColor(this, R.color.dark_midColor) + gridColor = ContextCompat.getColor(this, R.color.dark_gridColor) + basalBackgroundColor = ContextCompat.getColor(this, R.color.basal_dark) + basalCenterColor = ContextCompat.getColor(this, R.color.basal_light) + pointSize = 1 + setupCharts() + setWatchfaceStyle() - if (chart != null) { - highColor = ContextCompat.getColor(this, R.color.dark_highColor) - lowColor = ContextCompat.getColor(this, R.color.dark_lowColor) - midColor = ContextCompat.getColor(this, R.color.dark_midColor) - gridColor = ContextCompat.getColor(this, R.color.dark_gridColor) - basalBackgroundColor = ContextCompat.getColor(this, R.color.basal_dark) - basalCenterColor = ContextCompat.getColor(this, R.color.basal_light) - pointSize = 1 - setupCharts() - setWatchfaceStyle() - } } @SuppressLint("SetTextI18n") @@ -103,19 +103,19 @@ class DigitalStyleWatchface : BaseWatchFace() { val isShowDate = sp.getBoolean(R.string.key_show_date, false) if (!isShowDate) { layoutView?.findViewById(R.id.date_time)?.visibility = View.GONE - mHour?.textSize = 62f - mMinute?.textSize = 40f - mHour?.letterSpacing = (-0.066).toFloat() - mMinute?.letterSpacing = (-0.066).toFloat() + binding.hour.textSize = 62f + binding.minute.textSize = 40f + binding.hour.letterSpacing = (-0.066).toFloat() + binding.minute.letterSpacing = (-0.066).toFloat() } else { layoutView?.findViewById(R.id.date_time)?.visibility = View.VISIBLE - mHour?.textSize = 40f - mMinute?.textSize = 26f - mHour?.letterSpacing = 0.toFloat() - mMinute?.letterSpacing = 0.toFloat() + binding.hour.textSize = 40f + binding.minute.textSize = 26f + binding.hour.letterSpacing = 0.toFloat() + binding.minute.letterSpacing = 0.toFloat() /* display week number */ - val mWeekNumber = layoutView?.findViewById(R.id.weeknumber) + val mWeekNumber = layoutView?.findViewById(R.id.week_number) mWeekNumber?.visibility = sp.getBoolean(R.string.key_show_week_number, false).toVisibility() mWeekNumber?.text = "(" + dateUtil.weekString() + ")" } @@ -128,4 +128,4 @@ class DigitalStyleWatchface : BaseWatchFace() { override fun setColorBright() { setColorDark() /* getCurrentWatchMode() == WatchMode.AMBIENT or WatchMode.INTERACTIVE */ } -} \ No newline at end of file +} diff --git a/wear/src/main/java/info/nightscout/androidaps/watchfaces/NoChartWatchface.kt b/wear/src/main/java/info/nightscout/androidaps/watchfaces/NoChartWatchface.kt index bcbb388684..e277945540 100644 --- a/wear/src/main/java/info/nightscout/androidaps/watchfaces/NoChartWatchface.kt +++ b/wear/src/main/java/info/nightscout/androidaps/watchfaces/NoChartWatchface.kt @@ -1,87 +1,78 @@ package info.nightscout.androidaps.watchfaces -import androidx.annotation.LayoutRes +import android.view.LayoutInflater import androidx.core.content.ContextCompat +import androidx.viewbinding.ViewBinding import com.ustwo.clockwise.common.WatchMode import info.nightscout.androidaps.R +import info.nightscout.androidaps.databinding.ActivityBigchartBinding +import info.nightscout.androidaps.databinding.ActivityBigchartSmallBinding +import info.nightscout.androidaps.databinding.ActivityNochartBinding +import info.nightscout.androidaps.databinding.ActivityNochartSmallBinding +import info.nightscout.androidaps.watchfaces.utils.BaseWatchFace +import info.nightscout.androidaps.watchfaces.utils.WatchfaceViewAdapter class NoChartWatchface : BaseWatchFace() { - @LayoutRes override fun layoutResource(): Int = - if (resources.displayMetrics.widthPixels < SCREEN_SIZE_SMALL || resources.displayMetrics.heightPixels < SCREEN_SIZE_SMALL) R.layout.activity_nochart_small - else R.layout.activity_nochart + private lateinit var binding: WatchfaceViewAdapter + + override fun inflateLayout(inflater: LayoutInflater): ViewBinding { + if (resources.displayMetrics.widthPixels < SCREEN_SIZE_SMALL || resources.displayMetrics.heightPixels < SCREEN_SIZE_SMALL) { + val layoutBinding = ActivityNochartSmallBinding.inflate(inflater) + binding = WatchfaceViewAdapter.getBinding(layoutBinding) + return layoutBinding + } + val layoutBinding = ActivityNochartBinding.inflate(inflater) + binding = WatchfaceViewAdapter.getBinding(layoutBinding) + return layoutBinding + } override fun setColorLowRes() { - mTime?.setTextColor(ContextCompat.getColor(this, R.color.dark_mTime)) - mStatus?.setTextColor(ContextCompat.getColor(this, R.color.dark_statusView)) - mRelativeLayout?.setBackgroundColor(ContextCompat.getColor(this, R.color.dark_background)) - mSgv?.setTextColor(ContextCompat.getColor(this, R.color.dark_midColor)) - mDelta?.setTextColor(ContextCompat.getColor(this, R.color.dark_midColor)) - mAvgDelta?.setTextColor(ContextCompat.getColor(this, R.color.dark_midColor)) - mTimestamp?.setTextColor(ContextCompat.getColor(this, R.color.dark_Timestamp)) + binding.time?.setTextColor(ContextCompat.getColor(this, R.color.dark_mTime)) + binding.status?.setTextColor(ContextCompat.getColor(this, R.color.dark_statusView)) + binding.mainLayout.setBackgroundColor(ContextCompat.getColor(this, R.color.dark_background)) + binding.sgv?.setTextColor(ContextCompat.getColor(this, R.color.dark_midColor)) + binding.delta?.setTextColor(ContextCompat.getColor(this, R.color.dark_midColor)) + binding.avgDelta?.setTextColor(ContextCompat.getColor(this, R.color.dark_midColor)) + binding.timestamp.setTextColor(ContextCompat.getColor(this, R.color.dark_Timestamp)) } override fun setColorDark() { - mTime?.setTextColor(ContextCompat.getColor(this, R.color.dark_mTime)) - mStatus?.setTextColor(ContextCompat.getColor(this, R.color.dark_statusView)) - mRelativeLayout?.setBackgroundColor(ContextCompat.getColor(this, R.color.dark_background)) - when (singleBg.sgvLevel) { - 1L -> { - mSgv?.setTextColor(ContextCompat.getColor(this, R.color.dark_highColor)) - mDelta?.setTextColor(ContextCompat.getColor(this, R.color.dark_highColor)) - mAvgDelta?.setTextColor(ContextCompat.getColor(this, R.color.dark_highColor)) - } - - 0L -> { - mSgv?.setTextColor(ContextCompat.getColor(this, R.color.dark_midColor)) - mDelta?.setTextColor(ContextCompat.getColor(this, R.color.dark_midColor)) - mAvgDelta?.setTextColor(ContextCompat.getColor(this, R.color.dark_midColor)) - } - - -1L -> { - mSgv?.setTextColor(ContextCompat.getColor(this, R.color.dark_lowColor)) - mDelta?.setTextColor(ContextCompat.getColor(this, R.color.dark_lowColor)) - mAvgDelta?.setTextColor(ContextCompat.getColor(this, R.color.dark_lowColor)) - } - } - if (ageLevel == 1) { - mTimestamp?.setTextColor(ContextCompat.getColor(this, R.color.dark_Timestamp)) - } else { - mTimestamp?.setTextColor(ContextCompat.getColor(this, R.color.dark_TimestampOld)) + binding.time?.setTextColor(ContextCompat.getColor(this, R.color.dark_mTime)) + binding.status?.setTextColor(ContextCompat.getColor(this, R.color.dark_statusView)) + binding.mainLayout.setBackgroundColor(ContextCompat.getColor(this, R.color.dark_background)) + val color = when (singleBg.sgvLevel) { + 1L -> R.color.dark_highColor + 0L -> R.color.dark_midColor + -1L -> R.color.dark_lowColor + else -> R.color.dark_midColor } + binding.sgv?.setTextColor(ContextCompat.getColor(this, color)) + binding.delta?.setTextColor(ContextCompat.getColor(this, color)) + binding.avgDelta?.setTextColor(ContextCompat.getColor(this, color)) + val colorTime = if (ageLevel == 1) R.color.dark_Timestamp else R.color.dark_TimestampOld + binding.timestamp.setTextColor(ContextCompat.getColor(this, colorTime)) } override fun setColorBright() { if (currentWatchMode == WatchMode.INTERACTIVE) { - mTime?.setTextColor(ContextCompat.getColor(this, R.color.light_bigchart_time)) - mStatus?.setTextColor(ContextCompat.getColor(this, R.color.light_bigchart_status)) - mRelativeLayout?.setBackgroundColor(ContextCompat.getColor(this, R.color.light_background)) - when (singleBg.sgvLevel) { - 1L -> { - mSgv?.setTextColor(ContextCompat.getColor(this, R.color.light_highColor)) - mDelta?.setTextColor(ContextCompat.getColor(this, R.color.light_highColor)) - mAvgDelta?.setTextColor(ContextCompat.getColor(this, R.color.light_highColor)) - } - - 0L -> { - mSgv?.setTextColor(ContextCompat.getColor(this, R.color.light_midColor)) - mDelta?.setTextColor(ContextCompat.getColor(this, R.color.light_midColor)) - mAvgDelta?.setTextColor(ContextCompat.getColor(this, R.color.light_midColor)) - } - - -1L -> { - mSgv?.setTextColor(ContextCompat.getColor(this, R.color.light_lowColor)) - mDelta?.setTextColor(ContextCompat.getColor(this, R.color.light_lowColor)) - mAvgDelta?.setTextColor(ContextCompat.getColor(this, R.color.light_lowColor)) - } - } - if (ageLevel == 1) { - mTimestamp?.setTextColor(ContextCompat.getColor(this, R.color.light_mTimestamp1)) - } else { - mTimestamp?.setTextColor(ContextCompat.getColor(this, R.color.light_mTimestamp)) + binding.time?.setTextColor(ContextCompat.getColor(this, R.color.light_bigchart_time)) + binding.status?.setTextColor(ContextCompat.getColor(this, R.color.light_bigchart_status)) + binding.mainLayout.setBackgroundColor(ContextCompat.getColor(this, R.color.light_background)) + val color = when (singleBg.sgvLevel) { + 1L -> R.color.light_highColor + 0L -> R.color.light_midColor + -1L -> R.color.light_lowColor + else -> R.color.light_midColor } + binding.sgv?.setTextColor(ContextCompat.getColor(this, color)) + binding.delta?.setTextColor(ContextCompat.getColor(this, color)) + binding.avgDelta?.setTextColor(ContextCompat.getColor(this, color)) + val colorTime = if (ageLevel == 1) R.color.light_mTimestamp1 else R.color.light_mTimestamp + binding.timestamp.setTextColor(ContextCompat.getColor(this, colorTime)) + } else { setColorDark() } } -} \ No newline at end of file +} diff --git a/wear/src/main/java/info/nightscout/androidaps/watchfaces/SteampunkWatchface.kt b/wear/src/main/java/info/nightscout/androidaps/watchfaces/SteampunkWatchface.kt index eba08790d6..e387062017 100644 --- a/wear/src/main/java/info/nightscout/androidaps/watchfaces/SteampunkWatchface.kt +++ b/wear/src/main/java/info/nightscout/androidaps/watchfaces/SteampunkWatchface.kt @@ -2,12 +2,15 @@ package info.nightscout.androidaps.watchfaces +import android.view.LayoutInflater import android.view.animation.Animation import android.view.animation.LinearInterpolator import android.view.animation.RotateAnimation -import androidx.annotation.LayoutRes import androidx.core.content.ContextCompat +import androidx.viewbinding.ViewBinding import info.nightscout.androidaps.R +import info.nightscout.androidaps.databinding.ActivitySteampunkBinding +import info.nightscout.androidaps.watchfaces.utils.BaseWatchFace import info.nightscout.shared.SafeParse.stringToFloat import org.joda.time.TimeOfDay @@ -19,8 +22,12 @@ class SteampunkWatchface : BaseWatchFace() { private var lastEndDegrees = 0f private var deltaRotationAngle = 0f + private lateinit var binding: ActivitySteampunkBinding - @LayoutRes override fun layoutResource(): Int = R.layout.activity_steampunk + override fun inflateLayout(inflater: LayoutInflater): ViewBinding { + binding = ActivitySteampunkBinding.inflate(inflater) + return binding + } override fun onCreate() { forceSquareCanvas = true @@ -29,48 +36,48 @@ class SteampunkWatchface : BaseWatchFace() { override fun setColorDark() { if (ageLevel() <= 0 && singleBg.timeStamp != 0L) { - mLinearLayout2?.setBackgroundResource(R.drawable.redline) - mTimestamp?.setTextColor(ContextCompat.getColor(this, R.color.red_600)) + binding.tertiaryLayout.setBackgroundResource(R.drawable.redline) + binding.timestamp.setTextColor(ContextCompat.getColor(this, R.color.red_600)) } else { - mLinearLayout2?.setBackgroundResource(0) - mTimestamp?.setTextColor(ContextCompat.getColor(this, R.color.black_86p)) + binding.tertiaryLayout.setBackgroundResource(0) + binding.timestamp.setTextColor(ContextCompat.getColor(this, R.color.black_86p)) } - mLoop?.setTextColor(ContextCompat.getColor(this, if (loopLevel == 0) R.color.red_600 else R.color.black_86p)) + binding.loop.setTextColor(ContextCompat.getColor(this, if (loopLevel == 0) R.color.red_600 else R.color.black_86p)) if (singleBg.sgvString != "---") { - var rotationAngle = 0f //by default, show ? on the dial (? is at 0 degrees on the dial) + var rotationAngle = 0f // by default, show ? on the dial (? is at 0 degrees on the dial) if (singleBg.glucoseUnits != "-") { - //ensure the glucose dial is the correct units - mGlucoseDial?.setImageResource(if (singleBg.glucoseUnits == "mmol") R.drawable.steampunk_dial_mmol else R.drawable.steampunk_dial_mgdl) + // ensure the glucose dial is the correct units + binding.glucoseDial.setImageResource(if (singleBg.glucoseUnits == "mmol") R.drawable.steampunk_dial_mmol else R.drawable.steampunk_dial_mgdl) - //convert the Sgv to degrees of rotation + // convert the Sgv to degrees of rotation rotationAngle = if (singleBg.glucoseUnits == "mmol") stringToFloat(singleBg.sgvString) * 18f //convert to mg/dL, which is equivalent to degrees - else stringToFloat(singleBg.sgvString) //if glucose a value is received, use it to determine the amount of rotation of the dial. + else stringToFloat(singleBg.sgvString) // if glucose a value is received, use it to determine the amount of rotation of the dial. } - if (rotationAngle > 330) rotationAngle = 330f //if the glucose value is higher than 330 then show "HIGH" on the dial. ("HIGH" is at 330 degrees on the dial) - if (rotationAngle != 0f && rotationAngle < 30) rotationAngle = 30f //if the glucose value is lower than 30 show "LOW" on the dial. ("LOW" is at 30 degrees on the dial) + if (rotationAngle > 330) rotationAngle = 330f // if the glucose value is higher than 330 then show "HIGH" on the dial. ("HIGH" is at 330 degrees on the dial) + if (rotationAngle != 0f && rotationAngle < 30) rotationAngle = 30f // if the glucose value is lower than 30 show "LOW" on the dial. ("LOW" is at 30 degrees on the dial) if (lastEndDegrees == 0f) lastEndDegrees = rotationAngle - //rotate glucose dial + // rotate glucose dial val rotate = RotateAnimation(lastEndDegrees, rotationAngle - lastEndDegrees, Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.5f).apply { fillAfter = true interpolator = LinearInterpolator() duration = 1 } - mGlucoseDial?.startAnimation(rotate) + binding.glucoseDial.startAnimation(rotate) lastEndDegrees = rotationAngle //store the final angle as a starting point for the next rotation. } - //set the delta gauge and rotate the delta pointer - var deltaIsNegative = 1f //by default go clockwise - if (singleBg.avgDelta != "--") { //if a legitimate delta value is + // set the delta gauge and rotate the delta pointer + var deltaIsNegative = 1f // by default go clockwise + if (singleBg.avgDelta != "--") { // if a legitimate delta value is // received, // then... if (singleBg.avgDelta[0] == '-') deltaIsNegative = -1f //if the delta is negative, go counter-clockwise val absAvgDelta = stringToFloat(singleBg.avgDelta.substring(1)) //get rid of the sign so it can be converted to float. var autoGranularity = "0" //auto-granularity off - //ensure the delta gauge is the right units and granularity + // ensure the delta gauge is the right units and granularity if (singleBg.glucoseUnits != "-") { if (singleBg.glucoseUnits == "mmol") { if (sp.getString("delta_granularity", "2") == "4") { //Auto granularity @@ -82,15 +89,15 @@ class SteampunkWatchface : BaseWatchFace() { } } if (sp.getString("delta_granularity", "2") == "1" || autoGranularity == "1") { //low - mLinearLayout?.setBackgroundResource(R.drawable.steampunk_gauge_mmol_10) + binding.secondaryLayout.setBackgroundResource(R.drawable.steampunk_gauge_mmol_10) deltaRotationAngle = absAvgDelta * 30f } if (sp.getString("delta_granularity", "2") == "2" || autoGranularity == "2") { //medium - mLinearLayout?.setBackgroundResource(R.drawable.steampunk_gauge_mmol_05) + binding.secondaryLayout.setBackgroundResource(R.drawable.steampunk_gauge_mmol_05) deltaRotationAngle = absAvgDelta * 60f } if (sp.getString("delta_granularity", "2") == "3" || autoGranularity == "3") { //high - mLinearLayout?.setBackgroundResource(R.drawable.steampunk_gauge_mmol_03) + binding.secondaryLayout.setBackgroundResource(R.drawable.steampunk_gauge_mmol_03) deltaRotationAngle = absAvgDelta * 100f } } else { @@ -103,44 +110,40 @@ class SteampunkWatchface : BaseWatchFace() { } } if (sp.getString("delta_granularity", "2") == "1" || autoGranularity == "1") { //low - mLinearLayout?.setBackgroundResource(R.drawable.steampunk_gauge_mgdl_20) + binding.secondaryLayout.setBackgroundResource(R.drawable.steampunk_gauge_mgdl_20) deltaRotationAngle = absAvgDelta * 1.5f } if (sp.getString("delta_granularity", "2") == "2" || autoGranularity == "2") { //medium - mLinearLayout?.setBackgroundResource(R.drawable.steampunk_gauge_mgdl_10) + binding.secondaryLayout.setBackgroundResource(R.drawable.steampunk_gauge_mgdl_10) deltaRotationAngle = absAvgDelta * 3f } if (sp.getString("delta_granularity", "2") == "3" || autoGranularity == "3") { //high - mLinearLayout?.setBackgroundResource(R.drawable.steampunk_gauge_mgdl_5) + binding.secondaryLayout.setBackgroundResource(R.drawable.steampunk_gauge_mgdl_5) deltaRotationAngle = absAvgDelta * 6f } } } if (deltaRotationAngle > 40) deltaRotationAngle = 40f - mDeltaGauge?.rotation = deltaRotationAngle * deltaIsNegative + binding.deltaPointer.rotation = deltaRotationAngle * deltaIsNegative } - //rotate the minute hand. - mMinuteHand?.rotation = TimeOfDay().minuteOfHour * 6f + // rotate the minute hand. + binding.minuteHand.rotation = TimeOfDay().minuteOfHour * 6f - //rotate the hour hand. - mHourHand?.rotation = TimeOfDay().hourOfDay * 30f + TimeOfDay().minuteOfHour * 0.5f + // rotate the hour hand. + binding.hourHand.rotation = TimeOfDay().hourOfDay * 30f + TimeOfDay().minuteOfHour * 0.5f setTextSizes() - mLoop?.setBackgroundResource(0) - if (chart != null) { - highColor = ContextCompat.getColor(this, R.color.black) - lowColor = ContextCompat.getColor(this, R.color.black) - midColor = ContextCompat.getColor(this, R.color.black) - gridColor = ContextCompat.getColor(this, R.color.grey_steampunk) - basalBackgroundColor = ContextCompat.getColor(this, R.color.basal_dark) - basalCenterColor = ContextCompat.getColor(this, R.color.basal_dark) - pointSize = if (sp.getInt(R.string.key_chart_time_frame, 3) < 3) { - 2 - } else { - 1 - } - setupCharts() - } + binding.loop.setBackgroundResource(0) + + highColor = ContextCompat.getColor(this, R.color.black) + lowColor = ContextCompat.getColor(this, R.color.black) + midColor = ContextCompat.getColor(this, R.color.black) + gridColor = ContextCompat.getColor(this, R.color.grey_steampunk) + basalBackgroundColor = ContextCompat.getColor(this, R.color.basal_dark) + basalCenterColor = ContextCompat.getColor(this, R.color.basal_dark) + pointSize = if (sp.getInt(R.string.key_chart_time_frame, 3) < 3) 2 else 1 + setupCharts() + invalidate() } @@ -162,36 +165,23 @@ class SteampunkWatchface : BaseWatchFace() { fontLarge = 13f } - //top row. large font unless text too big (i.e. detailedIOB) - mCOB2?.textSize = fontLarge - mBasalRate?.textSize = fontLarge - if (status.iobDetail.length < 7) { - mIOB2?.textSize = fontLarge - } else { - mIOB2?.textSize = fontSmall - } + // top row. large font unless text too big (i.e. detailedIOB) + binding.cob2.textSize = fontLarge + binding.basalRate.textSize = fontLarge + val fontIob = if (status.iobDetail.length < 7) fontLarge else fontSmall + binding.iob2.textSize = fontIob - //bottom row. font medium unless text too long (i.e. longer than 9' timestamp) - mLoop?.let { mLoop -> - mTimestamp?.let { mTimestamp -> - if (mTimestamp.text.length < 3 || mLoop.text.length < 3) { //always resize these fields together, for symmetry. - mTimestamp.textSize = fontMedium - mLoop.textSize = fontMedium - } else { - mTimestamp.textSize = fontSmall - mLoop.textSize = fontSmall - } - } - } + // bottom row. font medium unless text too long (i.e. longer than 9' timestamp) + // always resize these fields together, for symmetry. + val font = if (binding.timestamp.text.length < 3 || binding.loop.text.length < 3) fontMedium else fontSmall + binding.loop.textSize = font + binding.timestamp.textSize = font + + // if both batteries are shown, make them smaller. + val fontBat = if (sp.getBoolean(R.string.key_show_uploader_battery, true) && sp.getBoolean(R.string.key_show_rig_battery, false)) fontSmall else fontMedium + binding.uploaderBattery.textSize = fontBat + binding.rigBattery.textSize = fontBat - //if both batteries are shown, make them smaller. - if (sp.getBoolean(R.string.key_show_uploader_battery, true) && sp.getBoolean(R.string.key_show_rig_battery, false)) { - mUploaderBattery?.textSize = fontSmall - mRigBattery?.textSize = fontSmall - } else { - mUploaderBattery?.textSize = fontMedium - mRigBattery?.textSize = fontMedium - } } override fun changeChartTimeframe() { @@ -200,4 +190,4 @@ class SteampunkWatchface : BaseWatchFace() { pointSize = if (timeframe < 3) 2 else 1 sp.putString(R.string.key_chart_time_frame, timeframe.toString()) } -} \ No newline at end of file +} diff --git a/wear/src/main/java/info/nightscout/androidaps/watchfaces/utils/WatchfaceViewAdapter.kt b/wear/src/main/java/info/nightscout/androidaps/watchfaces/utils/WatchfaceViewAdapter.kt new file mode 100644 index 0000000000..3b1b8113b8 --- /dev/null +++ b/wear/src/main/java/info/nightscout/androidaps/watchfaces/utils/WatchfaceViewAdapter.kt @@ -0,0 +1,102 @@ +package info.nightscout.androidaps.watchfaces.utils + +import androidx.viewbinding.ViewBinding +import info.nightscout.androidaps.databinding.ActivityHomeLargeBinding +import info.nightscout.androidaps.databinding.ActivityHome2Binding +import info.nightscout.androidaps.databinding.ActivityHomeBinding +import info.nightscout.androidaps.databinding.ActivityBigchartBinding +import info.nightscout.androidaps.databinding.ActivityBigchartSmallBinding +import info.nightscout.androidaps.databinding.ActivityCockpitBinding +import info.nightscout.androidaps.databinding.ActivityDigitalstyleBinding +import info.nightscout.androidaps.databinding.ActivityNochartBinding +import info.nightscout.androidaps.databinding.ActivitySteampunkBinding + +/** + * WatchfaceViewAdapter binds all WatchFace variants shared attributes to one common view adapter. + * Requires at least one of the ViewBinding as a parameter. Recommended to use the factory object to create the binding. + */ +class WatchfaceViewAdapter( + aL: ActivityHomeLargeBinding? = null, + a2: ActivityHome2Binding? = null, + aa: ActivityHomeBinding? = null, + bC: ActivityBigchartBinding? = null, + bCs: ActivityBigchartSmallBinding? = null, + cp: ActivityCockpitBinding? = null, + ds: ActivityDigitalstyleBinding? = null, + nC: ActivityNochartBinding? = null, + sP: ActivitySteampunkBinding? = null +) { + + init { + if (aL == null && a2 == null && aa == null && bC == null && bCs == null && cp == null && ds == null && nC == null && sP == null) { + throw IllegalArgumentException("Require at least on Binding parameter") + } + } + + private val errorMessage = "Missing require View Binding parameter" + // Required attributes + val mainLayout = + aL?.mainLayout ?: a2?.mainLayout ?: aa?.mainLayout ?: bC?.mainLayout ?: bC?.mainLayout ?: cp?.mainLayout ?: ds?.mainLayout ?: nC?.mainLayout ?: sP?.mainLayout + ?: throw IllegalArgumentException(errorMessage) + val timestamp = + aL?.timestamp ?: a2?.timestamp ?: aa?.timestamp ?: bC?.timestamp ?: bC?.timestamp ?: cp?.timestamp ?: ds?.timestamp ?: nC?.timestamp ?: sP?.timestamp + ?: throw IllegalArgumentException(errorMessage) + val root = + aL?.root ?: a2?.root ?: aa?.root ?: bC?.root ?: bC?.root ?: cp?.root ?: ds?.root ?: nC?.root ?: sP?.root + ?: throw IllegalArgumentException(errorMessage) + + // Optional attributes + val sgv = aL?.sgv ?: a2?.sgv ?: aa?.sgv ?: bC?.sgv ?: bC?.sgv ?: cp?.sgv ?: ds?.sgv ?: nC?.sgv + val direction = aL?.direction ?: a2?.direction ?: aa?.direction ?: cp?.direction ?: ds?.direction + val loop = a2?.loop ?: cp?.loop ?: sP?.loop + val delta = aL?.delta ?: a2?.delta ?: aa?.delta ?: bC?.delta ?: bC?.delta ?: cp?.delta ?: ds?.delta ?: nC?.delta + val avgDelta = a2?.avgDelta ?: bC?.avgDelta ?: bC?.avgDelta ?: cp?.avgDelta ?: ds?.avgDelta ?: nC?.avgDelta + val uploaderBattery = aL?.uploaderBattery ?: a2?.uploaderBattery ?: aa?.uploaderBattery ?: cp?.uploaderBattery ?: ds?.uploaderBattery ?: sP?.uploaderBattery + val rigBattery = a2?.rigBattery ?: cp?.rigBattery ?: ds?.rigBattery ?: sP?.rigBattery + val basalRate = a2?.basalRate ?: cp?.basalRate ?: ds?.basalRate ?: sP?.basalRate + val bgi = a2?.bgi ?: ds?.bgi + val AAPSv2 = a2?.AAPSv2 ?: cp?.AAPSv2 ?: ds?.AAPSv2 ?: sP?.AAPSv2 + val cob1 = a2?.cob1 ?: ds?.cob1 + val cob2 = a2?.cob2 ?: cp?.cob2 ?: ds?.cob2 ?: sP?.cob2 + val time = aL?.time ?: a2?.time ?: aa?.time ?: bC?.time ?: bC?.time ?: cp?.time ?: nC?.time + val minute = ds?.minute + val hour = ds?.hour + val day = a2?.day ?: ds?.day + val month = a2?.month ?: ds?.month + val iob1 = a2?.iob1 ?: ds?.iob1 + val iob2 = a2?.iob2 ?: cp?.iob2 ?: ds?.iob2 ?: sP?.iob2 + val chart = a2?.chart ?: aa?.chart ?: bC?.chart ?: bC?.chart ?: ds?.chart ?: sP?.chart + val status = aL?.status ?: aa?.status ?: bC?.status ?: bC?.status ?: nC?.status + val timePeriod = ds?.timePeriod + val dayName = ds?.dayName + val mainMenuTap = ds?.mainMenuTap ?: sP?.mainMenuTap + val chartZoomTap = sP?.chartZoomTap + val dateTime = ds?.dateTime ?: a2?.dateTime + // val minuteHand = sP?.minuteHand + // val secondaryLayout = aL?.secondaryLayout ?: a2?.secondaryLayout ?: aa?.secondaryLayout ?: ds?.secondaryLayout ?: sP?.secondaryLayout + // val tertiaryLayout = a2?.tertiaryLayout ?: sP?.tertiaryLayout + // val highLight = cp?.highLight + // val lowLight = cp?.lowLight + // val deltaGauge = sP?.deltaPointer + // val hourHand = sP?.hourHand + // val glucoseDial = sP?.glucoseDial + + companion object { + + fun getBinding(bindLayout: ViewBinding): WatchfaceViewAdapter { + return when (bindLayout) { + is ActivityHomeLargeBinding -> WatchfaceViewAdapter(bindLayout) + is ActivityHome2Binding -> WatchfaceViewAdapter(null, bindLayout) + is ActivityHomeBinding -> WatchfaceViewAdapter(null, null, bindLayout) + is ActivityBigchartBinding -> WatchfaceViewAdapter(null, null, null, bindLayout) + is ActivityBigchartSmallBinding -> WatchfaceViewAdapter(null, null, null, null, bindLayout) + is ActivityCockpitBinding -> WatchfaceViewAdapter(null, null, null, null, null, bindLayout) + is ActivityDigitalstyleBinding -> WatchfaceViewAdapter(null, null, null, null, null, null, bindLayout) + is ActivityNochartBinding -> WatchfaceViewAdapter(null, null, null, null, null, null, null, bindLayout) + is ActivitySteampunkBinding -> WatchfaceViewAdapter(null, null, null, null, null, null, null, null, bindLayout) + else -> throw IllegalArgumentException("ViewBinding is not implement in WatchfaceViewAdapter") + } + } + } + +} diff --git a/wear/src/main/res/layout-notround/activity_bigchart.xml b/wear/src/main/res/layout-notround/activity_bigchart.xml index 8c3a136e6a..28be3ae4bb 100644 --- a/wear/src/main/res/layout-notround/activity_bigchart.xml +++ b/wear/src/main/res/layout-notround/activity_bigchart.xml @@ -46,7 +46,7 @@ tools:ignore="HardcodedText" /> - + - + - + Date: Tue, 5 Jul 2022 23:22:11 +0200 Subject: [PATCH 10/39] Fix Double Time in Popup for profile name --- .../androidaps/plugins/general/autotune/AutotuneFragment.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/general/autotune/AutotuneFragment.kt b/app/src/main/java/info/nightscout/androidaps/plugins/general/autotune/AutotuneFragment.kt index b0f3303c4e..9fcc4b8db2 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/general/autotune/AutotuneFragment.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/general/autotune/AutotuneFragment.kt @@ -126,7 +126,7 @@ class AutotuneFragment : DaggerFragment() { autotunePlugin.tunedProfile?.let { tunedProfile -> showConfirmation(requireContext(), rh.gs(R.string.autotune_copy_localprofile_button), - rh.gs(R.string.autotune_copy_local_profile_message) + "\n" + localName + " " + dateUtil.dateAndTimeString(autotunePlugin.lastRun), + rh.gs(R.string.autotune_copy_local_profile_message) + "\n" + localName, Runnable { localProfilePlugin.addProfile(localProfilePlugin.copyFrom(tunedProfile.getProfile(circadian), localName)) rxBus.send(EventLocalProfileChanged()) From a4be4bb0a79bc9f77f8ce00a547a057df40f674c Mon Sep 17 00:00:00 2001 From: Andries Smit Date: Tue, 5 Jul 2022 12:52:30 +0200 Subject: [PATCH 11/39] chore: add no watch connected messgae --- .../wear/wearintegration/DataLayerListenerServiceMobile.kt | 2 +- app/src/main/res/layout/wear_fragment.xml | 2 +- app/src/main/res/values/strings.xml | 1 + 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/general/wear/wearintegration/DataLayerListenerServiceMobile.kt b/app/src/main/java/info/nightscout/androidaps/plugins/general/wear/wearintegration/DataLayerListenerServiceMobile.kt index ed1ac23bdb..4535cda62f 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/general/wear/wearintegration/DataLayerListenerServiceMobile.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/general/wear/wearintegration/DataLayerListenerServiceMobile.kt @@ -134,7 +134,7 @@ class DataLayerListenerServiceMobile : WearableListenerService() { aapsLogger.debug(LTag.WEAR, "Nodes: ${capabilityInfo.nodes.joinToString(", ") { it.displayName + "(" + it.id + ")" }}") val bestNode = pickBestNodeId(capabilityInfo.nodes) transcriptionNodeId = bestNode?.id - wearPlugin.connectedDevice = bestNode?.displayName ?: "---" + wearPlugin.connectedDevice = bestNode?.displayName ?: rh.gs(R.string.no_watch_connected) rxBus.send(EventWearUpdateGui()) aapsLogger.debug(LTag.WEAR, "Selected node: ${bestNode?.displayName} $transcriptionNodeId") rxBus.send(EventMobileToWear(EventData.ActionPing(System.currentTimeMillis()))) diff --git a/app/src/main/res/layout/wear_fragment.xml b/app/src/main/res/layout/wear_fragment.xml index 2bcbb389ac..5c6dd20d9a 100644 --- a/app/src/main/res/layout/wear_fragment.xml +++ b/app/src/main/res/layout/wear_fragment.xml @@ -13,7 +13,7 @@ android:gravity="center_vertical|center_horizontal" android:paddingTop="10dp" android:paddingBottom="10dp" - android:text="---" + android:text="@string/no_watch_connected" android:textAppearance="@style/TextAppearance.AppCompat.Medium" tools:ignore="HardcodedText" /> diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index d33d543dd9..b4bb05b480 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -1249,6 +1249,7 @@ Receive BG values from GlucoRx Aidex CGMS. Blocked by charging options Blocked by connectivity options + (No Watch Connected) From ad71a38cfbb0ae6003c76715b86112b23a659eaa Mon Sep 17 00:00:00 2001 From: Milos Kozak Date: Wed, 6 Jul 2022 23:00:07 +0200 Subject: [PATCH 12/39] Objectives: new questions --- .../objectives/objectives/Objective2.kt | 15 +++++++++++++++ app/src/main/res/values/exam.xml | 14 +++++++++++++- 2 files changed, 28 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/constraints/objectives/objectives/Objective2.kt b/app/src/main/java/info/nightscout/androidaps/plugins/constraints/objectives/objectives/Objective2.kt index b32fab8e96..4c79036f9b 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/constraints/objectives/objectives/Objective2.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/constraints/objectives/objectives/Objective2.kt @@ -178,6 +178,21 @@ class Objective2(injector: HasAndroidInjector) : Objective(injector, "exam", R.s .option(Option(R.string.iob_negiob, true)) .option(Option(R.string.iob_posiob, true)) ) + tasks.add(ExamTask(this, R.string.cob_label, R.string.cob_question, "cob1") + .option(Option(R.string.cob_longer, true)) + .option(Option(R.string.cob_shorter, false)) + .option(Option(R.string.cob_no_effect, false)) + ) + tasks.add(ExamTask(this, R.string.cob_label, R.string.cob2_question, "cob2") + .option(Option(R.string.cob2_longer, false)) + .option(Option(R.string.cob2_shorter, true)) + .option(Option(R.string.cob2_no_effect, false)) + ) + tasks.add(ExamTask(this, R.string.cob_label, R.string.cob3_question, "cob3") + .option(Option(R.string.cob3_longer, false)) + .option(Option(R.string.cob3_shorter, false)) + .option(Option(R.string.cob3_no_effect, true)) + ) tasks.add(ExamTask(this, R.string.breadgrams_label, R.string.blank, "breadgrams") .option(Option(R.string.breadgrams_grams, true)) .option(Option(R.string.breadgrams_exchange, false)) diff --git a/app/src/main/res/values/exam.xml b/app/src/main/res/values/exam.xml index d61962065a..2ca128b413 100644 --- a/app/src/main/res/values/exam.xml +++ b/app/src/main/res/values/exam.xml @@ -136,8 +136,20 @@ Compare values in AndroidAPS and pump history (if pump supports this). Bolus a proportion of your calculated ‘missed’ insulin by either syringe/pen or using a prime. Do nothing and allow AndroidAPS to correct any resulting high blood glucose level. + Carbs on Board (COB) + How changing ISF value affects COB calculation? + Increasing ISF will make absorbing carbs longer time + Increasing ISF will make absorbing carbs shorter time + Increasing ISF will not affect calculated carbs absorption + How changing IC value affects COB calculation? + Increasing IC will make absorbing carbs longer time + Increasing IC will make absorbing carbs shorter time + Increasing IC will not affect calculated carbs absorption + How changing profile percentage affects COB calculation? + Setting profile to 150% will make absorbing carbs longer time + Setting profile to 150% will make absorbing carbs shorter time + Setting profile to 150% will not affect calculated carbs absorption Insulin on Board (IOB) - Check all the correct answers. IOB value is affected by issued temporary basals. High temp basal will not be given when your blood sugar is below target. Negative IOB for a substantial period in the absence of exercise suggests your profile is too strong and less insulin is needed in your settings. From 8b496c45c28dd852dcc887275bb8a318105b8293 Mon Sep 17 00:00:00 2001 From: Milos Kozak Date: Wed, 6 Jul 2022 23:11:45 +0200 Subject: [PATCH 13/39] prevent NPE --- .../androidaps/plugins/profile/local/LocalProfileFragment.kt | 1 + 1 file changed, 1 insertion(+) diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/profile/local/LocalProfileFragment.kt b/app/src/main/java/info/nightscout/androidaps/plugins/profile/local/LocalProfileFragment.kt index 7e0e29fc8f..77f0139d4b 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/profile/local/LocalProfileFragment.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/profile/local/LocalProfileFragment.kt @@ -394,6 +394,7 @@ class LocalProfileFragment : DaggerFragment() { } private fun updateProtectedUi() { + _binding ?: return val isLocked = protectionCheck.isLocked(ProtectionCheck.Protection.PREFERENCES) binding.mainLayout.visibility = isLocked.not().toVisibility() binding.unlock.visibility = isLocked.toVisibility() From 5c26c1ddb6a84291a46caaa93bfdea9faef13b2e Mon Sep 17 00:00:00 2001 From: Milos Kozak Date: Wed, 6 Jul 2022 23:14:55 +0200 Subject: [PATCH 14/39] prevent NPE --- .../main/java/info/nightscout/androidaps/dialogs/WizardDialog.kt | 1 + 1 file changed, 1 insertion(+) diff --git a/app/src/main/java/info/nightscout/androidaps/dialogs/WizardDialog.kt b/app/src/main/java/info/nightscout/androidaps/dialogs/WizardDialog.kt index 8af683bcdb..9c8fe4ba91 100644 --- a/app/src/main/java/info/nightscout/androidaps/dialogs/WizardDialog.kt +++ b/app/src/main/java/info/nightscout/androidaps/dialogs/WizardDialog.kt @@ -345,6 +345,7 @@ class WizardDialog : DaggerDialogFragment() { val basalIob = iobCobCalculator.calculateIobFromTempBasalsIncludingConvertedExtended().round() runOnUiThread { + _binding ?: return@runOnUiThread if (carbsPassedIntoWizard != 0.0) { binding.carbsInput.value = carbsPassedIntoWizard } From cf1f31ab78ac629e465165108f242d11aca0a11a Mon Sep 17 00:00:00 2001 From: Milos Kozak Date: Thu, 7 Jul 2022 10:09:36 +0200 Subject: [PATCH 15/39] fix build --- .../info/nightscout/androidaps/utils/ui/TimeListEdit.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/info/nightscout/androidaps/utils/ui/TimeListEdit.java b/app/src/main/java/info/nightscout/androidaps/utils/ui/TimeListEdit.java index 437bb3cbd2..e1645c907f 100644 --- a/app/src/main/java/info/nightscout/androidaps/utils/ui/TimeListEdit.java +++ b/app/src/main/java/info/nightscout/androidaps/utils/ui/TimeListEdit.java @@ -182,7 +182,7 @@ public class TimeListEdit { numberPickers1[position].setTextWatcher(new TextWatcher() { @Override public void afterTextChanged(Editable s) { - Double value1 = SafeParse.INSTANCE.stringToDouble(numberPickers1[position].getText()); + Double value1 = SafeParse.INSTANCE.stringToDouble(numberPickers1[position].getText(), 0.0); Double value2 = value2(position); if (data2 != null && value1 > value2) { value2 = value1; @@ -209,7 +209,7 @@ public class TimeListEdit { @Override public void afterTextChanged(Editable s) { Double value1 = value1(position); - Double value2 = SafeParse.INSTANCE.stringToDouble(numberPickers2[position].getText()); + Double value2 = SafeParse.INSTANCE.stringToDouble(numberPickers2[position].getText(), 0.0); if (data2 != null && value2 < value1) { value1 = value2; numberPickers1[position].setValue(value1); From 396bfc8304b4a07ecdbf97d5982adf2821683259 Mon Sep 17 00:00:00 2001 From: Andries Smit Date: Thu, 7 Jul 2022 11:38:06 +0200 Subject: [PATCH 16/39] fix: option parameter java --- .../info/nightscout/androidaps/utils/ui/TimeListEdit.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/info/nightscout/androidaps/utils/ui/TimeListEdit.java b/app/src/main/java/info/nightscout/androidaps/utils/ui/TimeListEdit.java index 437bb3cbd2..e1645c907f 100644 --- a/app/src/main/java/info/nightscout/androidaps/utils/ui/TimeListEdit.java +++ b/app/src/main/java/info/nightscout/androidaps/utils/ui/TimeListEdit.java @@ -182,7 +182,7 @@ public class TimeListEdit { numberPickers1[position].setTextWatcher(new TextWatcher() { @Override public void afterTextChanged(Editable s) { - Double value1 = SafeParse.INSTANCE.stringToDouble(numberPickers1[position].getText()); + Double value1 = SafeParse.INSTANCE.stringToDouble(numberPickers1[position].getText(), 0.0); Double value2 = value2(position); if (data2 != null && value1 > value2) { value2 = value1; @@ -209,7 +209,7 @@ public class TimeListEdit { @Override public void afterTextChanged(Editable s) { Double value1 = value1(position); - Double value2 = SafeParse.INSTANCE.stringToDouble(numberPickers2[position].getText()); + Double value2 = SafeParse.INSTANCE.stringToDouble(numberPickers2[position].getText(), 0.0); if (data2 != null && value2 < value1) { value1 = value2; numberPickers1[position].setValue(value1); From e7bd9ad81ea2669cba7cbe017ebaa35575fa9cb7 Mon Sep 17 00:00:00 2001 From: Andries Smit Date: Thu, 7 Jul 2022 11:38:36 +0200 Subject: [PATCH 17/39] feat: preference search in actionbar --- .../activities/PreferencesActivity.kt | 37 +++++++++++-------- .../main/res/layout/activity_preferences.xml | 22 ----------- app/src/main/res/menu/menu_preferences.xml | 11 ++++++ app/src/main/res/values/strings.xml | 3 +- 4 files changed, 34 insertions(+), 39 deletions(-) create mode 100644 app/src/main/res/menu/menu_preferences.xml diff --git a/app/src/main/java/info/nightscout/androidaps/activities/PreferencesActivity.kt b/app/src/main/java/info/nightscout/androidaps/activities/PreferencesActivity.kt index 60f0f5006a..7725617e88 100644 --- a/app/src/main/java/info/nightscout/androidaps/activities/PreferencesActivity.kt +++ b/app/src/main/java/info/nightscout/androidaps/activities/PreferencesActivity.kt @@ -2,9 +2,9 @@ package info.nightscout.androidaps.activities import android.content.Context import android.os.Bundle -import android.text.Editable -import android.text.TextWatcher +import android.view.Menu import android.view.MenuItem +import androidx.appcompat.widget.SearchView import androidx.preference.PreferenceFragmentCompat import androidx.preference.PreferenceScreen import info.nightscout.androidaps.R @@ -15,6 +15,7 @@ class PreferencesActivity : NoSplashAppCompatActivity(), PreferenceFragmentCompa private var preferenceId = 0 private var myPreferenceFragment: MyPreferenceFragment? = null + private var searchView: SearchView? = null private lateinit var binding: ActivityPreferencesBinding @@ -24,15 +25,6 @@ class PreferencesActivity : NoSplashAppCompatActivity(), PreferenceFragmentCompa binding = ActivityPreferencesBinding.inflate(layoutInflater) setContentView(binding.root) - binding.prefFilter.addTextChangedListener(object : TextWatcher { - override fun beforeTextChanged(s: CharSequence, start: Int, count: Int, after: Int) {} - override fun onTextChanged(s: CharSequence, start: Int, before: Int, count: Int) { - filterPreferences() - } - - override fun afterTextChanged(s: Editable) {} - }) - title = rh.gs(R.string.nav_preferences) supportActionBar?.setDisplayHomeAsUpEnabled(true) supportActionBar?.setDisplayShowHomeEnabled(true) @@ -40,12 +32,29 @@ class PreferencesActivity : NoSplashAppCompatActivity(), PreferenceFragmentCompa preferenceId = intent.getIntExtra("id", -1) myPreferenceFragment?.arguments = Bundle().also { it.putInt("id", preferenceId) - it.putString("filter", binding.prefFilter.text.toString()) } if (savedInstanceState == null) supportFragmentManager.beginTransaction().replace(R.id.frame_layout, myPreferenceFragment!!).commit() } + override fun onCreateOptionsMenu(menu: Menu): Boolean { + menuInflater.inflate(R.menu.menu_preferences, menu) + val searchItem = menu.findItem(R.id.menu_search) + searchView = searchItem.actionView as SearchView + searchView?.setOnQueryTextListener(object : SearchView.OnQueryTextListener { + + override fun onQueryTextChange(newText: String): Boolean { + myPreferenceFragment?.setFilter(newText) + return false + } + + override fun onQueryTextSubmit(query: String): Boolean { + return false + } + }) + return super.onCreateOptionsMenu(menu) + } + override fun onPreferenceStartScreen(caller: PreferenceFragmentCompat, pref: PreferenceScreen): Boolean { val fragment = MyPreferenceFragment() fragment.arguments = Bundle().also { @@ -60,10 +69,6 @@ class PreferencesActivity : NoSplashAppCompatActivity(), PreferenceFragmentCompa super.attachBaseContext(LocaleHelper.wrap(newBase)) } - private fun filterPreferences() { - myPreferenceFragment?.setFilter(binding.prefFilter.text.toString()) - } - override fun onOptionsItemSelected(item: MenuItem): Boolean { when (item.itemId) { android.R.id.home -> { diff --git a/app/src/main/res/layout/activity_preferences.xml b/app/src/main/res/layout/activity_preferences.xml index 2ff946628a..ae72eaf113 100644 --- a/app/src/main/res/layout/activity_preferences.xml +++ b/app/src/main/res/layout/activity_preferences.xml @@ -5,28 +5,6 @@ android:layout_height="match_parent" android:orientation="vertical"> - - - - - - + + + + + diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index b4bb05b480..7bc428a968 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -1242,8 +1242,9 @@ only on watch only on phone drag and drop handle + Search - + GlucoRx Aidex Aidex Receive BG values from GlucoRx Aidex CGMS. From 943e68d1be4e860b3315c784bb69301fd8cee17e Mon Sep 17 00:00:00 2001 From: Andries Smit Date: Fri, 8 Jul 2022 08:58:53 +0200 Subject: [PATCH 18/39] fix: nightscout icons --- .../res/drawable/ic_nightscout_profile.xml | 29 +++++++++++----- .../main/res/drawable/ic_nightscout_syncs.xml | 34 ++++++++++++++----- core/src/main/res/drawable/ic_nsclient_bg.xml | 27 +++++++++------ 3 files changed, 62 insertions(+), 28 deletions(-) diff --git a/core/src/main/res/drawable/ic_nightscout_profile.xml b/core/src/main/res/drawable/ic_nightscout_profile.xml index 7fb7c6f4a5..9b9b07d3f9 100644 --- a/core/src/main/res/drawable/ic_nightscout_profile.xml +++ b/core/src/main/res/drawable/ic_nightscout_profile.xml @@ -1,10 +1,23 @@ - - - + + - - - + android:strokeWidth="3.09" + android:strokeColor="?attr/colorControlNormal" /> + + + diff --git a/core/src/main/res/drawable/ic_nightscout_syncs.xml b/core/src/main/res/drawable/ic_nightscout_syncs.xml index d90bc99dd3..381de5de2c 100644 --- a/core/src/main/res/drawable/ic_nightscout_syncs.xml +++ b/core/src/main/res/drawable/ic_nightscout_syncs.xml @@ -1,11 +1,27 @@ - - - - - + - - + android:strokeWidth="3.09" + android:strokeColor="?attr/colorControlNormal" /> + + + + + diff --git a/core/src/main/res/drawable/ic_nsclient_bg.xml b/core/src/main/res/drawable/ic_nsclient_bg.xml index 00e95c65cb..fff0a558f6 100644 --- a/core/src/main/res/drawable/ic_nsclient_bg.xml +++ b/core/src/main/res/drawable/ic_nsclient_bg.xml @@ -3,15 +3,20 @@ android:height="64dp" android:viewportWidth="64" android:viewportHeight="64"> - - - + + + + + From 6b1f495c283d3b66b2620582efb123054dff4029 Mon Sep 17 00:00:00 2001 From: Philoul Date: Fri, 8 Jul 2022 23:13:12 +0200 Subject: [PATCH 19/39] Synchronized aapsAutotune call to avoid multi-thread conflicts --- .../general/autotune/AutotunePlugin.kt | 33 +++++++++++++------ .../androidaps/interfaces/Autotune.kt | 2 +- 2 files changed, 24 insertions(+), 11 deletions(-) diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/general/autotune/AutotunePlugin.kt b/app/src/main/java/info/nightscout/androidaps/plugins/general/autotune/AutotunePlugin.kt index 5f926c28c5..e379f22026 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/general/autotune/AutotunePlugin.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/general/autotune/AutotunePlugin.kt @@ -76,21 +76,31 @@ class AutotunePlugin @Inject constructor( private lateinit var profile: Profile val autotuneStartHour: Int = 4 - override fun aapsAutotune(daysBack: Int, autoSwitch: Boolean, profileToTune: String): String { + @Synchronized + override fun aapsAutotune(daysBack: Int, autoSwitch: Boolean, profileToTune: String) { + lastRunSuccess = false + calculationRunning = true tunedProfile = null updateButtonVisibility = View.GONE - lastRunSuccess = false var logResult = "" result = "" if (profileFunction.getProfile() == null) { result = rh.gs(R.string.profileswitch_ismissing) - return result + rxBus.send(EventAutotuneUpdateGui()) + calculationRunning = false + return } val detailedLog = sp.getBoolean(R.string.key_autotune_additional_log, false) calculationRunning = true lastNbDays = "" + daysBack lastRun = dateUtil.now() - val profileStore = activePlugin.activeProfileSource.profile ?: return rh.gs(R.string.profileswitch_ismissing) + val profileStore = activePlugin.activeProfileSource.profile + if (profileStore == null) { + result = rh.gs(R.string.profileswitch_ismissing) + rxBus.send(EventAutotuneUpdateGui()) + calculationRunning = false + return + } selectedProfile = if (profileToTune.isEmpty()) profileFunction.getProfileName() else profileToTune profileFunction.getProfile()?.let { currentProfile -> profile = profileStore.getSpecificProfile(profileToTune)?.let { ProfileSealed.Pure(it) } ?: currentProfile @@ -144,11 +154,11 @@ class AutotunePlugin @Inject constructor( if (tunedProfile == null) { result = rh.gs(R.string.autotune_error) log("TunedProfile is null on day ${i + 1}") - calculationRunning = false - rxBus.send(EventAutotuneUpdateGui()) autotuneFS.exportResult(result) autotuneFS.exportLogAndZip(lastRun) - return result + rxBus.send(EventAutotuneUpdateGui()) + calculationRunning = false + return } } result = rh.gs(R.string.autotune_result, dateUtil.dateAndTimeString(lastRun)) @@ -193,13 +203,16 @@ class AutotunePlugin @Inject constructor( } tunedProfile?.let { - lastRunSuccess = true saveLastRun() + lastRunSuccess = true rxBus.send(EventAutotuneUpdateGui()) calculationRunning = false - return result + return } - return rh.gs(R.string.autotune_error) + result = rh.gs(R.string.autotune_error) + rxBus.send(EventAutotuneUpdateGui()) + calculationRunning = false + return } private fun showResults(tunedProfile: ATProfile?, pumpProfile: ATProfile): String { diff --git a/core/src/main/java/info/nightscout/androidaps/interfaces/Autotune.kt b/core/src/main/java/info/nightscout/androidaps/interfaces/Autotune.kt index b90934475e..83ebcd2530 100644 --- a/core/src/main/java/info/nightscout/androidaps/interfaces/Autotune.kt +++ b/core/src/main/java/info/nightscout/androidaps/interfaces/Autotune.kt @@ -2,7 +2,7 @@ package info.nightscout.androidaps.interfaces interface Autotune { - fun aapsAutotune(daysBack: Int, autoSwitch: Boolean, profileToTune: String = ""): String + fun aapsAutotune(daysBack: Int, autoSwitch: Boolean, profileToTune: String = "") fun atLog(message: String) var lastRunSuccess: Boolean From 4c52081a8fecce7420600fd95be71f74dc977025 Mon Sep 17 00:00:00 2001 From: Philoul Date: Sat, 9 Jul 2022 00:57:23 +0200 Subject: [PATCH 20/39] Prevent NPE (Trial) convert ArrayList to List to execute Sort --- .../androidaps/plugins/general/autotune/AutotuneIob.kt | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/general/autotune/AutotuneIob.kt b/app/src/main/java/info/nightscout/androidaps/plugins/general/autotune/AutotuneIob.kt index bac89d9f9e..925d290ee4 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/general/autotune/AutotuneIob.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/general/autotune/AutotuneIob.kt @@ -39,7 +39,7 @@ open class AutotuneIob @Inject constructor( private val autotuneFS: AutotuneFS ) { - private val nsTreatments = ArrayList() + private var nsTreatments = ArrayList() private var dia: Double = Constants.defaultDIA var boluses: ArrayList = ArrayList() var meals = ArrayList() @@ -59,11 +59,11 @@ open class AutotuneIob @Inject constructor( initializeTreatmentData(from - range(), to) initializeTempBasalData(from - range(), to, tunedProfile) initializeExtendedBolusData(from - range(), to, tunedProfile) - tempBasals.sortWith { o1: TemporaryBasal, o2: TemporaryBasal -> (o2.timestamp - o1.timestamp).toInt() } + tempBasals = ArrayList(tempBasals.toList().sortedWith { o1: TemporaryBasal, o2: TemporaryBasal -> (o2.timestamp - o1.timestamp).toInt() }) // Without Neutral TBR, Autotune Web will ignore iob for periods without TBR running addNeutralTempBasal(from - range(), to, tunedProfile) - nsTreatments.sortWith { o1: NsTreatment, o2: NsTreatment -> (o2.date - o1.date).toInt() } - this.boluses.sortWith { o1: Bolus, o2: Bolus -> (o2.timestamp - o1.timestamp).toInt() } + nsTreatments = ArrayList(nsTreatments.toList().sortedWith { o1: NsTreatment, o2: NsTreatment -> (o2.date - o1.date).toInt() }) + boluses = ArrayList(boluses.toList().sortedWith { o1: Bolus, o2: Bolus -> (o2.timestamp - o1.timestamp).toInt() }) aapsLogger.debug(LTag.AUTOTUNE, "Nb Treatments: " + nsTreatments.size + " Nb meals: " + meals.size) } From a9c7b5c15b1185e73b3c1c635de6b357b465a25f Mon Sep 17 00:00:00 2001 From: Milos Kozak Date: Sat, 9 Jul 2022 18:18:14 +0200 Subject: [PATCH 21/39] fix tests --- .../omnipod/eros/manager/AapsErosPodStateManagerTest.kt | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/omnipod-eros/src/test/java/info/nightscout/androidaps/plugins/pump/omnipod/eros/manager/AapsErosPodStateManagerTest.kt b/omnipod-eros/src/test/java/info/nightscout/androidaps/plugins/pump/omnipod/eros/manager/AapsErosPodStateManagerTest.kt index 7d0748726d..8c15bc9fa8 100644 --- a/omnipod-eros/src/test/java/info/nightscout/androidaps/plugins/pump/omnipod/eros/manager/AapsErosPodStateManagerTest.kt +++ b/omnipod-eros/src/test/java/info/nightscout/androidaps/plugins/pump/omnipod/eros/manager/AapsErosPodStateManagerTest.kt @@ -27,7 +27,7 @@ class AapsErosPodStateManagerTest : TestBase() { val now = DateTime(2020, 1, 1, 1, 2, 3, timeZone) DateTimeUtils.setCurrentMillisFixed(now.millis) val podStateManager = AapsErosPodStateManager(aapsLogger, sp, rxBus) - podStateManager.initState(0x0) + podStateManager.initState(0x01) podStateManager.setInitializationParameters( 0, 0, FirmwareVersion(1, 1, 1), FirmwareVersion(2, 2, 2), timeZone, PodProgressStatus.ABOVE_FIFTY_UNITS @@ -46,7 +46,7 @@ class AapsErosPodStateManagerTest : TestBase() { val now = DateTime(2020, 1, 1, 1, 2, 3, timeZone) DateTimeUtils.setCurrentMillisFixed(now.millis) val podStateManager = AapsErosPodStateManager(aapsLogger, sp, rxBus) - podStateManager.initState(0x0) + podStateManager.initState(0x01) podStateManager.setInitializationParameters( 0, 0, FirmwareVersion(1, 1, 1), FirmwareVersion(2, 2, 2), timeZone, PodProgressStatus.ABOVE_FIFTY_UNITS @@ -70,7 +70,7 @@ class AapsErosPodStateManagerTest : TestBase() { val now = DateTime(2020, 1, 1, 1, 2, 3, timeZone) DateTimeUtils.setCurrentMillisFixed(now.millis) val podStateManager = AapsErosPodStateManager(aapsLogger, sp, rxBus) - podStateManager.initState(0x0) + podStateManager.initState(0x01) podStateManager.setInitializationParameters( 0, 0, FirmwareVersion(1, 1, 1), FirmwareVersion(2, 2, 2), timeZone, PodProgressStatus.ABOVE_FIFTY_UNITS From cf87185976a0e157d0520adce193f0c46c1fca63 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Sat, 9 Jul 2022 16:40:44 +0000 Subject: [PATCH 22/39] Bump org.jetbrains.kotlin.android from 1.7.0 to 1.7.10 Bumps org.jetbrains.kotlin.android from 1.7.0 to 1.7.10. --- updated-dependencies: - dependency-name: org.jetbrains.kotlin.android dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.gradle b/build.gradle index 0f1228a852..f287edcd30 100644 --- a/build.gradle +++ b/build.gradle @@ -66,7 +66,7 @@ plugins { id "io.gitlab.arturbosch.detekt" version "1.20.0" id "org.jlleitschuh.gradle.ktlint" version "10.3.0" id 'org.barfuin.gradle.jacocolog' version '2.0.0' - id 'org.jetbrains.kotlin.android' version '1.7.0' apply false + id 'org.jetbrains.kotlin.android' version '1.7.10' apply false } allprojects { From 28972e2923ab053ac360ecbf220a0be103b440f2 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Sat, 9 Jul 2022 16:41:05 +0000 Subject: [PATCH 23/39] Bump kotlin_version from 1.7.0 to 1.7.10 Bumps `kotlin_version` from 1.7.0 to 1.7.10. Updates `kotlin-gradle-plugin` from 1.7.0 to 1.7.10 - [Release notes](https://github.com/JetBrains/kotlin/releases) - [Changelog](https://github.com/JetBrains/kotlin/blob/v1.7.10/ChangeLog.md) - [Commits](https://github.com/JetBrains/kotlin/compare/v1.7.0...v1.7.10) Updates `kotlin-allopen` from 1.7.0 to 1.7.10 - [Release notes](https://github.com/JetBrains/kotlin/releases) - [Changelog](https://github.com/JetBrains/kotlin/blob/v1.7.10/ChangeLog.md) - [Commits](https://github.com/JetBrains/kotlin/compare/v1.7.0...v1.7.10) Updates `kotlin-serialization` from 1.7.0 to 1.7.10 - [Release notes](https://github.com/JetBrains/kotlin/releases) - [Changelog](https://github.com/JetBrains/kotlin/blob/v1.7.10/ChangeLog.md) - [Commits](https://github.com/JetBrains/kotlin/compare/v1.7.0...v1.7.10) Updates `kotlin-stdlib-jdk8` from 1.7.0 to 1.7.10 - [Release notes](https://github.com/JetBrains/kotlin/releases) - [Changelog](https://github.com/JetBrains/kotlin/blob/v1.7.10/ChangeLog.md) - [Commits](https://github.com/JetBrains/kotlin/compare/v1.7.0...v1.7.10) Updates `kotlin-reflect` from 1.7.0 to 1.7.10 - [Release notes](https://github.com/JetBrains/kotlin/releases) - [Changelog](https://github.com/JetBrains/kotlin/blob/v1.7.10/ChangeLog.md) - [Commits](https://github.com/JetBrains/kotlin/compare/v1.7.0...v1.7.10) --- updated-dependencies: - dependency-name: org.jetbrains.kotlin:kotlin-gradle-plugin dependency-type: direct:production update-type: version-update:semver-patch - dependency-name: org.jetbrains.kotlin:kotlin-allopen dependency-type: direct:production update-type: version-update:semver-patch - dependency-name: org.jetbrains.kotlin:kotlin-serialization dependency-type: direct:production update-type: version-update:semver-patch - dependency-name: org.jetbrains.kotlin:kotlin-stdlib-jdk8 dependency-type: direct:production update-type: version-update:semver-patch - dependency-name: org.jetbrains.kotlin:kotlin-reflect dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.gradle b/build.gradle index 0f1228a852..57c1a25da2 100644 --- a/build.gradle +++ b/build.gradle @@ -2,7 +2,7 @@ buildscript { ext { - kotlin_version = '1.7.0' + kotlin_version = '1.7.10' core_version = '1.8.0' rxjava_version = '3.1.5' rxandroid_version = '3.0.0' From 5de98fab938cc7ee3ec94342fbeaa38e56a3fe8c Mon Sep 17 00:00:00 2001 From: Milos Kozak Date: Sat, 9 Jul 2022 23:03:42 +0200 Subject: [PATCH 24/39] language style --- app/src/main/res/values/exam.xml | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/app/src/main/res/values/exam.xml b/app/src/main/res/values/exam.xml index 2ca128b413..ff2a4f9d5d 100644 --- a/app/src/main/res/values/exam.xml +++ b/app/src/main/res/values/exam.xml @@ -138,16 +138,16 @@ Do nothing and allow AndroidAPS to correct any resulting high blood glucose level. Carbs on Board (COB) How changing ISF value affects COB calculation? - Increasing ISF will make absorbing carbs longer time - Increasing ISF will make absorbing carbs shorter time + Increasing ISF will take absorbing carbs a longer time + Increasing ISF will take absorbing carbs a shorter time Increasing ISF will not affect calculated carbs absorption How changing IC value affects COB calculation? - Increasing IC will make absorbing carbs longer time - Increasing IC will make absorbing carbs shorter time + Increasing IC will take absorbing carbs a longer time + Increasing IC will take absorbing carbs a shorter time Increasing IC will not affect calculated carbs absorption How changing profile percentage affects COB calculation? - Setting profile to 150% will make absorbing carbs longer time - Setting profile to 150% will make absorbing carbs shorter time + Setting profile to 150% will take absorbing carbs a longer time + Setting profile to 150% will take absorbing carbs a shorter time Setting profile to 150% will not affect calculated carbs absorption Insulin on Board (IOB) IOB value is affected by issued temporary basals. From 10d92b89fda5a0b9b40ae61272af0c59d9d71597 Mon Sep 17 00:00:00 2001 From: Philoul Date: Sun, 10 Jul 2022 00:35:54 +0200 Subject: [PATCH 25/39] Avoid AutotuneRun from automation if Run detected --- app/build.gradle | 2 +- .../general/autotune/AutotuneFragment.kt | 1 - .../plugins/general/autotune/AutotunePlugin.kt | 8 ++++++-- .../automation/actions/ActionRunAutotune.kt | 18 ++++++++++++------ .../androidaps/interfaces/Autotune.kt | 1 + core/src/main/res/values/strings.xml | 1 + 6 files changed, 21 insertions(+), 10 deletions(-) diff --git a/app/build.gradle b/app/build.gradle index ffa92cddd2..da06e17acd 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -105,7 +105,7 @@ android { defaultConfig { multiDexEnabled true versionCode 1500 - version "3.0.0.2-dev-n" + version "3.0.0.2-autotune-dev-n0" buildConfigField "String", "VERSION", '"' + version + '"' buildConfigField "String", "BUILDVERSION", '"' + generateGitBuild() + '-' + generateDate() + '"' buildConfigField "String", "REMOTE", '"' + generateGitRemote() + '"' diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/general/autotune/AutotuneFragment.kt b/app/src/main/java/info/nightscout/androidaps/plugins/general/autotune/AutotuneFragment.kt index 9fcc4b8db2..0f2834c90e 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/general/autotune/AutotuneFragment.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/general/autotune/AutotuneFragment.kt @@ -100,7 +100,6 @@ class AutotuneFragment : DaggerFragment() { ) binding.autotuneRun.setOnClickListener { val daysBack = SafeParse.stringToInt(binding.tuneDays.text) - autotunePlugin.calculationRunning = true autotunePlugin.lastNbDays = daysBack.toString() log("Run Autotune $profileName, $daysBack days") Thread { diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/general/autotune/AutotunePlugin.kt b/app/src/main/java/info/nightscout/androidaps/plugins/general/autotune/AutotunePlugin.kt index e379f22026..6a4f3d6a94 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/general/autotune/AutotunePlugin.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/general/autotune/AutotunePlugin.kt @@ -22,6 +22,7 @@ import info.nightscout.androidaps.utils.MidnightTime import info.nightscout.androidaps.utils.T import info.nightscout.androidaps.interfaces.BuildHelper import info.nightscout.shared.logging.AAPSLogger +import info.nightscout.shared.logging.LTag import info.nightscout.shared.sharedPreferences.SP import org.json.JSONException import org.json.JSONObject @@ -65,7 +66,7 @@ class AutotunePlugin @Inject constructor( ), Autotune { @Volatile override var lastRunSuccess: Boolean = false @Volatile var result: String = "" - @Volatile var calculationRunning: Boolean = false + @Volatile override var calculationRunning: Boolean = false @Volatile var lastRun: Long = 0 @Volatile var selectedProfile = "" @Volatile var lastNbDays: String = "" @@ -76,9 +77,12 @@ class AutotunePlugin @Inject constructor( private lateinit var profile: Profile val autotuneStartHour: Int = 4 - @Synchronized override fun aapsAutotune(daysBack: Int, autoSwitch: Boolean, profileToTune: String) { lastRunSuccess = false + if (calculationRunning) { + aapsLogger.debug(LTag.AUTOMATION, "Autotune run detected, Autotune Run Cancelled") + return + } calculationRunning = true tunedProfile = null updateButtonVisibility = View.GONE diff --git a/automation/src/main/java/info/nightscout/androidaps/plugins/general/automation/actions/ActionRunAutotune.kt b/automation/src/main/java/info/nightscout/androidaps/plugins/general/automation/actions/ActionRunAutotune.kt index c2687fffed..b1da120478 100644 --- a/automation/src/main/java/info/nightscout/androidaps/plugins/general/automation/actions/ActionRunAutotune.kt +++ b/automation/src/main/java/info/nightscout/androidaps/plugins/general/automation/actions/ActionRunAutotune.kt @@ -42,13 +42,19 @@ class ActionRunAutotune(injector: HasAndroidInjector) : Action(injector) { val profileName = if (inputProfileName.value == rh.gs(R.string.active)) "" else inputProfileName.value var message = if (autoSwitch) R.string.autotune_run_with_autoswitch else R.string.autotune_run_without_autoswitch Thread { - autotunePlugin.atLog("[Automation] Run Autotune $profileName, ${daysBack.value} days, Autoswitch $autoSwitch") - autotunePlugin.aapsAutotune(daysBack.value, autoSwitch, profileName) - if (!autotunePlugin.lastRunSuccess) { - message = R.string.autotune_run_with_error - aapsLogger.error(LTag.AUTOMATION, "Error during Autotune Run") + if (!autotunePlugin.calculationRunning) { + autotunePlugin.atLog("[Automation] Run Autotune $profileName, ${daysBack.value} days, Autoswitch $autoSwitch") + autotunePlugin.aapsAutotune(daysBack.value, autoSwitch, profileName) + if (!autotunePlugin.lastRunSuccess) { + message = R.string.autotune_run_with_error + aapsLogger.error(LTag.AUTOMATION, "Error during Autotune Run") + } + callback.result(PumpEnactResult(injector).success(autotunePlugin.lastRunSuccess).comment(message)).run() + } else { + message = R.string.autotune_run_cancelled + aapsLogger.debug(LTag.AUTOMATION, "Autotune run detected, Autotune Run Cancelled") + callback.result(PumpEnactResult(injector).success(false).comment(message)).run() } - callback.result(PumpEnactResult(injector).success(autotunePlugin.lastRunSuccess).comment(message)).run() }.start() return } diff --git a/core/src/main/java/info/nightscout/androidaps/interfaces/Autotune.kt b/core/src/main/java/info/nightscout/androidaps/interfaces/Autotune.kt index 83ebcd2530..93c20f71d5 100644 --- a/core/src/main/java/info/nightscout/androidaps/interfaces/Autotune.kt +++ b/core/src/main/java/info/nightscout/androidaps/interfaces/Autotune.kt @@ -6,4 +6,5 @@ interface Autotune { fun atLog(message: String) var lastRunSuccess: Boolean + var calculationRunning: Boolean } \ No newline at end of file diff --git a/core/src/main/res/values/strings.xml b/core/src/main/res/values/strings.xml index 30974f7512..3f5832b0cd 100644 --- a/core/src/main/res/values/strings.xml +++ b/core/src/main/res/values/strings.xml @@ -600,6 +600,7 @@ Autotune runned without profile switch Autotune runned and profile automatically switched Error during last Autotune run + Another run of Autotune is detected, run cancelled %1$d day From c37bbeedc1278908cc81d7d00d309f90cc331f6b Mon Sep 17 00:00:00 2001 From: Philoul Date: Sun, 10 Jul 2022 00:56:08 +0200 Subject: [PATCH 26/39] @Synchronized functions with Array --- .../plugins/general/autotune/AutotuneIob.kt | 30 +++++++++++++++---- 1 file changed, 24 insertions(+), 6 deletions(-) diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/general/autotune/AutotuneIob.kt b/app/src/main/java/info/nightscout/androidaps/plugins/general/autotune/AutotuneIob.kt index 925d290ee4..a634ee876c 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/general/autotune/AutotuneIob.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/general/autotune/AutotuneIob.kt @@ -59,14 +59,28 @@ open class AutotuneIob @Inject constructor( initializeTreatmentData(from - range(), to) initializeTempBasalData(from - range(), to, tunedProfile) initializeExtendedBolusData(from - range(), to, tunedProfile) - tempBasals = ArrayList(tempBasals.toList().sortedWith { o1: TemporaryBasal, o2: TemporaryBasal -> (o2.timestamp - o1.timestamp).toInt() }) - // Without Neutral TBR, Autotune Web will ignore iob for periods without TBR running - addNeutralTempBasal(from - range(), to, tunedProfile) - nsTreatments = ArrayList(nsTreatments.toList().sortedWith { o1: NsTreatment, o2: NsTreatment -> (o2.date - o1.date).toInt() }) - boluses = ArrayList(boluses.toList().sortedWith { o1: Bolus, o2: Bolus -> (o2.timestamp - o1.timestamp).toInt() }) + sortTempBasal() + addNeutralTempBasal(from - range(), to, tunedProfile) // Without Neutral TBR, Autotune Web will ignore iob for periods without TBR running + sortNsTreatments() + sortBoluses() aapsLogger.debug(LTag.AUTOTUNE, "Nb Treatments: " + nsTreatments.size + " Nb meals: " + meals.size) } + @Synchronized + private fun sortTempBasal() { + tempBasals = ArrayList(tempBasals.toList().sortedWith { o1: TemporaryBasal, o2: TemporaryBasal -> (o2.timestamp - o1.timestamp).toInt() }) + } + + @Synchronized + private fun sortNsTreatments() { + nsTreatments = ArrayList(nsTreatments.toList().sortedWith { o1: NsTreatment, o2: NsTreatment -> (o2.date - o1.date).toInt() }) + } + + @Synchronized + private fun sortBoluses() { + boluses = ArrayList(boluses.toList().sortedWith { o1: Bolus, o2: Bolus -> (o2.timestamp - o1.timestamp).toInt() }) + } + private fun initializeBgreadings(from: Long, to: Long) { glucose = repository.compatGetBgReadingsDataFromTime(from, to, false).blockingGet() } @@ -146,6 +160,7 @@ open class AutotuneIob @Inject constructor( // addNeutralTempBasal will add a fake neutral TBR (100%) to have correct basal rate in exported file for periods without TBR running // to be able to compare results between oref0 algo and aaps + @Synchronized private fun addNeutralTempBasal(from: Long, to: Long, tunedProfile: ATProfile) { var previousStart = to for (i in tempBasals.indices) { @@ -180,6 +195,7 @@ open class AutotuneIob @Inject constructor( // toSplittedTimestampTB will split all TBR across hours in different TBR with correct absolute value to be sure to have correct basal rate // even if profile rate is not the same + @Synchronized private fun toSplittedTimestampTB(tb: TemporaryBasal, tunedProfile: ATProfile) { var splittedTimestamp = tb.timestamp val cutInMilliSec = T.mins(60).msecs() //30 min to compare with oref0, 60 min to improve accuracy @@ -295,7 +311,7 @@ open class AutotuneIob @Inject constructor( return result } - + @Synchronized fun glucoseToJSON(): String { val glucoseJson = JSONArray() for (bgreading in glucose) @@ -303,6 +319,7 @@ open class AutotuneIob @Inject constructor( return glucoseJson.toString(2) } + @Synchronized fun bolusesToJSON(): String { val bolusesJson = JSONArray() for (bolus in boluses) @@ -310,6 +327,7 @@ open class AutotuneIob @Inject constructor( return bolusesJson.toString(2) } + @Synchronized fun nsHistoryToJSON(): String { val json = JSONArray() for (t in nsTreatments) { From 09bcad5b2659fd06990a7bed80346104eb98a02b Mon Sep 17 00:00:00 2001 From: Milos Kozak Date: Sun, 10 Jul 2022 10:25:03 +0200 Subject: [PATCH 27/39] New Crowdin updates (#1870) * New translations strings.xml (Italian) * Update source file strings.xml * New translations strings.xml (French) * New translations strings.xml (French) * New translations strings.xml (Russian) * New translations objectives.xml (Russian) * New translations strings.xml (Russian) * New translations strings.xml (Turkish) * Update source file strings.xml * New translations exam.xml (Portuguese, Brazilian) * New translations exam.xml (Chinese Simplified) * New translations exam.xml (Turkish) * New translations exam.xml (Swedish) * New translations exam.xml (Slovak) * New translations exam.xml (Portuguese) * New translations exam.xml (Polish) * New translations exam.xml (Norwegian) * New translations exam.xml (Lithuanian) * New translations exam.xml (Korean) * New translations exam.xml (German) * New translations strings.xml (Spanish) * New translations exam.xml (Czech) * New translations exam.xml (Catalan) * New translations exam.xml (Spanish) * New translations exam.xml (French) * New translations exam.xml (Romanian) * New translations exam.xml (Russian) * New translations exam.xml (Dutch) * New translations exam.xml (Italian) * New translations exam.xml (Hebrew) * New translations exam.xml (Danish) * Update source file exam.xml * New translations strings.xml (Norwegian) * New translations exam.xml (Spanish) * New translations exam.xml (Norwegian) * New translations exam.xml (Turkish) * New translations strings.xml (Czech) * New translations strings.xml (Turkish) * New translations strings.xml (Turkish) * New translations exam.xml (Czech) * New translations exam.xml (Turkish) * New translations strings.xml (Turkish) * New translations strings.xml (Turkish) * New translations strings.xml (Turkish) * New translations strings.xml (Turkish) * New translations exam.xml (Turkish) * New translations strings.xml (Turkish) * New translations strings.xml (Turkish) * New translations strings.xml (Turkish) * New translations exam.xml (Spanish) * New translations exam.xml (Spanish) * New translations exam.xml (Turkish) * New translations exam.xml (Norwegian) * New translations exam.xml (Czech) * New translations exam.xml (Spanish) * Update source file strings.xml * Update source file exam.xml * New translations exam.xml (Czech) * New translations exam.xml (Hebrew) * New translations strings.xml (Hebrew) * New translations strings.xml (Hebrew) --- app/src/main/res/values-ca-rES/exam.xml | 1 - app/src/main/res/values-cs-rCZ/exam.xml | 14 +++- app/src/main/res/values-cs-rCZ/strings.xml | 1 + app/src/main/res/values-da-rDK/exam.xml | 1 - app/src/main/res/values-de-rDE/exam.xml | 1 - app/src/main/res/values-es-rES/exam.xml | 8 ++- app/src/main/res/values-es-rES/strings.xml | 1 + app/src/main/res/values-fr-rFR/exam.xml | 1 - app/src/main/res/values-fr-rFR/strings.xml | 3 + app/src/main/res/values-it-rIT/exam.xml | 1 - app/src/main/res/values-iw-rIL/exam.xml | 14 +++- app/src/main/res/values-iw-rIL/strings.xml | 1 + app/src/main/res/values-ko-rKR/exam.xml | 1 - app/src/main/res/values-lt-rLT/exam.xml | 1 - app/src/main/res/values-nl-rNL/exam.xml | 1 - app/src/main/res/values-no-rNO/exam.xml | 8 ++- app/src/main/res/values-no-rNO/strings.xml | 1 + app/src/main/res/values-pl-rPL/exam.xml | 1 - app/src/main/res/values-pt-rBR/exam.xml | 1 - app/src/main/res/values-pt-rPT/exam.xml | 1 - app/src/main/res/values-ro-rRO/exam.xml | 1 - app/src/main/res/values-ru-rRU/exam.xml | 1 - app/src/main/res/values-ru-rRU/objectives.xml | 2 +- app/src/main/res/values-ru-rRU/strings.xml | 5 ++ app/src/main/res/values-sk-rSK/exam.xml | 1 - app/src/main/res/values-sv-rSE/exam.xml | 1 - app/src/main/res/values-tr-rTR/exam.xml | 22 +++--- app/src/main/res/values-tr-rTR/strings.xml | 68 ++++++++++--------- app/src/main/res/values-zh-rCN/exam.xml | 1 - .../src/main/res/values-tr-rTR/strings.xml | 4 +- core/src/main/res/values-tr-rTR/strings.xml | 2 +- .../src/main/res/values-iw-rIL/strings.xml | 1 + wear/src/main/res/values-fr-rFR/strings.xml | 2 + wear/src/main/res/values-it-rIT/strings.xml | 2 + wear/src/main/res/values-ru-rRU/strings.xml | 2 + wear/src/main/res/values-tr-rTR/strings.xml | 2 +- 36 files changed, 113 insertions(+), 66 deletions(-) diff --git a/app/src/main/res/values-ca-rES/exam.xml b/app/src/main/res/values-ca-rES/exam.xml index e954253896..1d7fce44c7 100644 --- a/app/src/main/res/values-ca-rES/exam.xml +++ b/app/src/main/res/values-ca-rES/exam.xml @@ -134,7 +134,6 @@ Lliurar un bolus amb part de la insulina que falta utilitzant una jeringa/ploma o el menú d\'encebat. No fer res i permetre que AndroidAPS corregeixi els possibles valors alts de glucèmia que es produeixin. Insulina \"a bord\" (IOB) - Marqueu totes les respostes correctes. El valor d\'IOB es veu afectat per les basals temporals lliurades. Una basal temporal alta no serà lliurada si la glucèmia està per sota de l\'objectiu. Un valor d\'IOB positiu durant un període de temps important suggereix resistència a la insulina o àpats no anunciats. diff --git a/app/src/main/res/values-cs-rCZ/exam.xml b/app/src/main/res/values-cs-rCZ/exam.xml index 674f46bec9..6b78dc52c1 100644 --- a/app/src/main/res/values-cs-rCZ/exam.xml +++ b/app/src/main/res/values-cs-rCZ/exam.xml @@ -136,8 +136,20 @@ Porovnat hodnoty v AndroidAPS s hodnotami v historii pumpy (pokud to pumpa podporuje). Pošlete bolus na vypočtený „chybějící“ inzulín buď injekční stříkačkou nebo perem nebo pomocí plnění na pumpě. Neudělejte nic a dovolte AndroidAPS opravit jakoukoliv výslednou vysokou hladinu glukózy v krvi. + Zbývající sacharidy (COB) + Jak změna hodnoty citlivosti ovlivňuje výpočet COB? + Zvýšení hodnoty citlivosti prodlouží dobu pohlcování sacharidů + Zvýšení hodnoty citlivosti zkrátí dobu pohlcování sacharidů + Zvýšení citlivosti neovlivní vypočtenou absorpci sacharidů + Jak změna inzulíno-sacharidového poměru ovlivňuje výpočet COB? + Zvýšení hodnoty inzulíno-sacharidového poměru prodlouží dobu pohlcování sacharidů + Zvýšení hodnoty inzulíno-sacharidového poměru zkrátí dobu pohlcování sacharidů + Zvýšení inzulíno-sacharidového poměru neovlivní vypočtenou absorpci sacharidů + Jak procentuální změna profilu ovlivňuje výpočet COB? + Nastavením profilu na 150% dojde k prodloužení doby pohlcování sacharidů + Nastavením profilu na 150% dojde ke zkrácení doby pohlcování sacharidů + Nastavení profilu na 150% neovlivní vypočtenou absorpci sacharidů Aktivní inzulín (IOB) - Zatrhněte všechny správné odpovědi. Hodnota IOB je ovlivněna vydanými dočasnými bazály. Vysoký dočasný bazál nebude spuštěn, pokud je Vaše glykémie nižší než cíl. Negativní IOB po značnou dobu bez cvičení naznačuje, že váš profil je příliš \"silný\" a ve vašem profilu je potřeba méně inzulínu. diff --git a/app/src/main/res/values-cs-rCZ/strings.xml b/app/src/main/res/values-cs-rCZ/strings.xml index c577d77db7..3805308216 100644 --- a/app/src/main/res/values-cs-rCZ/strings.xml +++ b/app/src/main/res/values-cs-rCZ/strings.xml @@ -1043,4 +1043,5 @@ Přijímat hodnoty glykémie ze senzoru GlucoRx Aidex. Zablokováno možností nabíjení Zablokováno možností připojení + (Žádné hodinky nejsou připojeny) diff --git a/app/src/main/res/values-da-rDK/exam.xml b/app/src/main/res/values-da-rDK/exam.xml index 31dc1e91d2..2a4276dfe3 100644 --- a/app/src/main/res/values-da-rDK/exam.xml +++ b/app/src/main/res/values-da-rDK/exam.xml @@ -136,7 +136,6 @@ Bolus en del af din beregnede \"glemte\" insulin med enten sprøjter / pen eller brug af en kanylefyldning. Gør ingenting og tillad AndroidAPS at rette op på højt blodsukker. Insulin om bord (IOB) - Tjek alle de korrekte svar. IOB-værdi påvirkes af midlertidige basaler. Høj midlertidlig basal vil ikke blive givet, når dit blodsukker er under målet. Negative IOB i en længere periode uden motion tyder på, at din profil er for stærk, og at der er behov for mindre insulin i dine indstillinger. diff --git a/app/src/main/res/values-de-rDE/exam.xml b/app/src/main/res/values-de-rDE/exam.xml index 2037d190da..6b25674a29 100644 --- a/app/src/main/res/values-de-rDE/exam.xml +++ b/app/src/main/res/values-de-rDE/exam.xml @@ -134,7 +134,6 @@ Gib einen Teil-Bolus des \'nicht erhaltenen\' Insulins mit Spritze / Pen oder durch Befüllen der Kanüle. Unternimm nichts und lass AndroidAPS die entstehenden hohen Glukosewerte korrigieren. Aktives Insulin (IOB) - Kreuze alle richtigen Antworten an. IOB wird von den abgegebenen temporären Basalraten beeinflusst. Eine hohe temporäre Basalrate wird nicht abgegeben, wenn der BZ unterhalb des Zielwerts liegt. Ein negativer IOB über einen längeren Zeitraum bei fehlender Bewegung deutet darauf hin, dass Dein Profil zu stark ist und weniger Insulin in Deinen Einstellungen benötigt wird. diff --git a/app/src/main/res/values-es-rES/exam.xml b/app/src/main/res/values-es-rES/exam.xml index d4ca2b6d4a..b7fb70e16d 100644 --- a/app/src/main/res/values-es-rES/exam.xml +++ b/app/src/main/res/values-es-rES/exam.xml @@ -136,8 +136,14 @@ Comparar valores en AndroidAPS con el historial de la bomba (si la bomba lo soporta). Bolo una proporción de la insulina calculada “perdida” por jeringa/pluma o usando menú de llenado. No haga nada y permite que AndroidAPS corrija cualquier nivel alto de glucosa en la sangre resultante. + Carbohidratos activos (COB) + ¿Cómo afecta el cambio del valor ISF al cálculo de COB? + Incrementar el ISF no afectará la absorción calculada de carbohidratos + ¿Cómo afecta cambiar los valores de IC a los cálculos de COB? + Incrementar el IC no afectará la absorción calculada de carbohidratos + ¿Cómo afecta el cambio de porcentaje del perfil al cálculo de los COB? + Establecer el perfil a 150% no afectará la absorción calculada de carbohidratos Insulina a bordo (IOB) - Marca todas las respuestas correctas. El valor del IOB se ve afectado por las bases temporales ejecutadas. No se dará alta tasa basal temporal cuando su nivel de azúcar en sangre esté por debajo del objetivo. El IOB negativo durante un período sustancial en ausencia de ejercicio sugiere que tu perfil es demasiado fuerte y que se necesita menos insulina en tus ajustes. diff --git a/app/src/main/res/values-es-rES/strings.xml b/app/src/main/res/values-es-rES/strings.xml index d80010a14a..4ea56784c9 100644 --- a/app/src/main/res/values-es-rES/strings.xml +++ b/app/src/main/res/values-es-rES/strings.xml @@ -1043,4 +1043,5 @@ Recibir los valores de glucosa de GlucoRx Aidex CGMS Bloqueado por opciones de carga Bloqueado por opciones de conectividad + (Ningún reloj conectado) diff --git a/app/src/main/res/values-fr-rFR/exam.xml b/app/src/main/res/values-fr-rFR/exam.xml index bab13d862d..5eb4d70a4c 100644 --- a/app/src/main/res/values-fr-rFR/exam.xml +++ b/app/src/main/res/values-fr-rFR/exam.xml @@ -137,7 +137,6 @@ Faites un bolus du montant de votre insuline calculée « manquante » soit par seringue / stylo ou en utilisant un amorçage. Ne faites rien et laissez AndroidAPS corriger tout taux élevé de glycémie qui en résulte. Insuline Active (IA) - Sélectionnez toutes les bonnes réponses. La valeur de l\'IA est impactée par les débits de basal temporaires émis. Une basale temp haute ne sera pas donnée quand votre glycémie est en dessous de la cible. Une IA négative pendant une période significative en l\'absence d\'exercice indique que votre profil est trop fort et qu\'il faut moins d\'insuline dans vos paramètres. diff --git a/app/src/main/res/values-fr-rFR/strings.xml b/app/src/main/res/values-fr-rFR/strings.xml index a278365845..f6f45e5c90 100644 --- a/app/src/main/res/values-fr-rFR/strings.xml +++ b/app/src/main/res/values-fr-rFR/strings.xml @@ -434,6 +434,8 @@ L\'ENSEMBLE DES RISQUES LIÉS À LA QUALITÉ ET À LA PERFORMANCE DU PROGRAMME S Activer les transmissions locales OpenAPS SMB SI dynamique + Facteur d\'ajustement Si dynamique % + Facteur d\'ajustement pour Si dynamique. Définissez plus de 100 % pour des corrections plus agressives et moins de 100 % pour des corrections moins agressives. Activer RNS Activer SMB Utiliser les Super Micro Bolus au lieu des débits de base temporaires pour une action rapide @@ -968,6 +970,7 @@ L\'ENSEMBLE DES RISQUES LIÉS À LA QUALITÉ ET À LA PERFORMANCE DU PROGRAMME S Gly maxi hors limite! Cible temporaire:\nMin: %1$s\nMax : %2$s\nDurée : %3$s Cible temporaire:\nCible: %1$s\nDurée: %2$s + Cible temp:\nRaison: %1$s\nCible : %2$s\nDurée : %3$s Assistant: %1$s\nInsuline : %2$.2fU\nGlucides : %3$dg Assistant Calc :\nInsuline : %1$.2fU\nGlucides : %2$dg Afficher l\'entrée sur l\'appareil : diff --git a/app/src/main/res/values-it-rIT/exam.xml b/app/src/main/res/values-it-rIT/exam.xml index c91b576f44..1841752c18 100644 --- a/app/src/main/res/values-it-rIT/exam.xml +++ b/app/src/main/res/values-it-rIT/exam.xml @@ -137,7 +137,6 @@ Erogare un bolo con parte della tua insulina calcolata \"mancante\" usando una siringa/penna o la funzione caricamento. Non fare nulla e permettere ad AndroidAPS di correggere eventuali glicemie alte. Insulina attiva (IOB) - Seleziona tutte le risposte corrette. Il valore IOB è influenzato dalle basali temporanee emesse. Non verrà emessa una basale temporanea alta quando la tua glicemia è al di sotto del target. IOB negativo per un periodo considerevole in assenza di esercizio fisico suggerisce che il tuo profilo è troppo incisivo e che è necessaria meno insulina nelle tue impostazioni. diff --git a/app/src/main/res/values-iw-rIL/exam.xml b/app/src/main/res/values-iw-rIL/exam.xml index e4f2d5dd9e..3e03a6e498 100644 --- a/app/src/main/res/values-iw-rIL/exam.xml +++ b/app/src/main/res/values-iw-rIL/exam.xml @@ -136,8 +136,20 @@ השוו את הרשומות שב-AndroidAPS עם היסטוריית המשאבה (אם המשאבה תומכת בכך). מזריקים בולוס על חלק מהאינסולין המחושב \"שחסר\" עם מזרק\\עט או באמצעות תיחול (Prime). לא לעשות דבר ולאפשר ל-AndroidAPS לתקן כל רמת סוכר גבוהה. + פחמ\' פעילות + איך שינויים ביחס התיקון משפיעים על חישוב הפחמימות הפעילות? + הגדלת ערך יחס התיקון תגרום להארכת משך ספיגת הפחמימות + הגדלת ערך יחס התיקון תגרום לקיצור משך ספיגת הפחמימות + הגדלת ערך יחס התיקון לא תשפיע על חישוב ספיגת הפחמימות + איך שינויים ביחס הפחמימות משפיעים על חישוב הפחמימות הפעילות? + הגדלת ערך יחס הפחמימות תגרום להארכת משך ספיגת הפחמימות + הגדלת ערך יחס הפחמימות תגרום לקיצור משך ספיגת הפחמימות + הגדלת ערך יחס הפחמימות לא תשפיע על חישוב ספיגת הפחמימות + איך שינויים באחוזי הפרופיל משפיעים על חישוב הפחמימות הפעילות? + הגדרת 150% פרופיל תגרום להארכת משך ספיגת הפחמימות + הגדרת 150% פרופיל תגרום לקיצור משך ספיגת הפחמימות + הגדרת 150% פרופיל לא תשפיע על חישוב משך ספיגת הפחמימות אינסולין פעיל בגוף (IOB) - סמנו את כל התשובות הנכונות. ערך האינסולין הפעיל (IOB) מושפע ממינונים בזאליים זמניים שסופקו. מינון בזאלי גבוה לא יינתן כאשר רמת הסוכר נמוכה מערך המטרה. אינסולין פעיל שלילי לאורך זמן בו לא נעשית פעילות מצביע על כך שהפרופיל חזק מדי, נדרש פחות אינסולין ויש להגדיר זאת בפרופיל. diff --git a/app/src/main/res/values-iw-rIL/strings.xml b/app/src/main/res/values-iw-rIL/strings.xml index 0be19f2f23..1fe66ba7f5 100644 --- a/app/src/main/res/values-iw-rIL/strings.xml +++ b/app/src/main/res/values-iw-rIL/strings.xml @@ -1039,4 +1039,5 @@ קבלת נתוני סוכר מחיישני GlucoRx Aidex. חסום ע\"י הגדרות טעינה חסום ע\"י הגדרות חיבור + (השעון לא מחובר) diff --git a/app/src/main/res/values-ko-rKR/exam.xml b/app/src/main/res/values-ko-rKR/exam.xml index 8aaf183241..89ae40d8dc 100644 --- a/app/src/main/res/values-ko-rKR/exam.xml +++ b/app/src/main/res/values-ko-rKR/exam.xml @@ -134,7 +134,6 @@ \"주입되지 않은\" 인슐린양을 계산하여 시린지/펜 또는 prime 기능을 사용하여 인슐린을 주입합니다. 특별한 조치를 취하지 않고, AndroidAPS가 결과적으로 높은 혈당 정도를 조정할 수 있도록 합니다. 활성 인슐린 (IOB) - 올바른 답변을 모두 체크하세요. IOB 값은 실행된 임시 basal의 영향을 받습니다. 혈당이 목표보다 낮을 경우 높은 임시 basal은 실행되지 않습니다. 운동 없이도 음수의 IOB (마이너스 IOB) 구간이 많을 경우, 프로파일이 너무 강한 것이며 인슐린 양을 적게 설정해야 합니다. diff --git a/app/src/main/res/values-lt-rLT/exam.xml b/app/src/main/res/values-lt-rLT/exam.xml index 9e5bb2cb09..dc3d8612f4 100644 --- a/app/src/main/res/values-lt-rLT/exam.xml +++ b/app/src/main/res/values-lt-rLT/exam.xml @@ -134,7 +134,6 @@ Susileisti trūkstamą insulino kiekį švirkštu ar naudojantis infuzinės sistemos užpildymo funkcija. Nieko nedaryti ir leisti AndroidAPS koreguoti padidėjusį gliukozės kiekį kraujyje. Aktyvus insulinas organizme (AIO) - Pasirinkite visus teisingus atsakymus. AIO reikšmei įtakos turi nustatyta laikina valandinė bazė. Padidinta laikina bazė nebus nustatyta, jei kraujo glikemija yra žemiau nustatyto tikslo. Jei ilgą laiką stebima neigiama AIO reikšmė ir nėra fizinio aktyvumo, tai rodo, kad jūsų nustatymai yra per „agresyvūs“ ir kad jums reikia mažiau insulino nei nustatyta. diff --git a/app/src/main/res/values-nl-rNL/exam.xml b/app/src/main/res/values-nl-rNL/exam.xml index 5a64cd78c6..e871ace199 100644 --- a/app/src/main/res/values-nl-rNL/exam.xml +++ b/app/src/main/res/values-nl-rNL/exam.xml @@ -137,7 +137,6 @@ Bolus een deel van je berekende \'gemiste\' insuline door een injectiespuit/pen of door de uitvulfunctie te gebruiken. Doe niets en laat AndroidAPS de resulterende hoge bloedglucosespiegel corrigeren. Insuline aan boord (IOB) - Selecteer alle juiste antwoorden. De IOB-waarde wordt beïnvloed door eerdere tijdelijke basaalstanden. Een hoge tijdelijke basaal zal niet worden ingesteld wanneer je bloedsuiker onder het streefdoel ligt. Negatieve IOB voor een aanzienlijke periode vrij van inspanning, suggereert dat je profiel te hoog is ingesteld, dus dat er minder insuline nodig is. diff --git a/app/src/main/res/values-no-rNO/exam.xml b/app/src/main/res/values-no-rNO/exam.xml index 087dc7d9be..2565916e50 100644 --- a/app/src/main/res/values-no-rNO/exam.xml +++ b/app/src/main/res/values-no-rNO/exam.xml @@ -136,8 +136,14 @@ Sammenlign verdiene i AndroidAPS og pumpehistorikken (hvis pumpen støtter dette). Gi en bolus med en del av det insulinet du mangler enten med penn eller ved å bruke prime funksjonen. Ikke gjør noe og la AndroidAPS korrigere eventuelle høye blodsukkerverdier. + Karbohydrater ombord (COB) + Hvordan vil endring av ISF-verdi påvirke COB-beregning? + Økning av ISF påvirker ikke beregningen av absorbering av karbohydrater + Hvordan vil endring av IC-verdi påvirke COB-beregning? + Økning av IC påvirker ikke beregningen av absorbering av karbohydrater + Hvordan vil endring av profil-prosent påvirke COB-beregning? + Ved å sette profilen til 150% påvirkes ikke beregningen av absorbering av karbohydrater Aktivt insulin (IOB) - Marker alle riktige svar. IOB verdi påvirkes av midlertidige temp basaler. Høy temp basal vil ikke bli gitt når ditt blodsukker er under målverdi. Negativ IOB i en lengre periode selv om du ikke trener tyder på at profilen din gir for mye insulin og kanskje bør reduseres i innstillingene. diff --git a/app/src/main/res/values-no-rNO/strings.xml b/app/src/main/res/values-no-rNO/strings.xml index 5967430250..73b4a8a093 100644 --- a/app/src/main/res/values-no-rNO/strings.xml +++ b/app/src/main/res/values-no-rNO/strings.xml @@ -1043,4 +1043,5 @@ Motta BS verdier fra GlucoRx Aidex CGM. Blokkert på grunn av ladealternativer Blokkert på grunn av tilkoblingsalternativer + (Ingen klokke tilkoblet) diff --git a/app/src/main/res/values-pl-rPL/exam.xml b/app/src/main/res/values-pl-rPL/exam.xml index dfa9014d5e..b9ce8332d5 100644 --- a/app/src/main/res/values-pl-rPL/exam.xml +++ b/app/src/main/res/values-pl-rPL/exam.xml @@ -134,7 +134,6 @@ Podaj obliczoną dawkę „pominiętej” insuliny za pomocą strzykawki / wstrzykiwacza lub za pomocą pompy funkcji wypełnienia. Nie rób nic i pozwól AndroidAPS na skorygowanie każdego uzyskanego wysokiego stężenia glukozy we krwi. Aktywna insulina (IOB) - Sprawdź/Zaznacz wszystkie prawidłowe odpowiedzi. Na wartość IOB mają wpływ wykonane tymczasowe dawki bazowe. Wysoka tymczasowa dawka bazowa nie zostanie podana, gdy twóje poziom cukru we krwi jest poniżej poziomu docelowego. Negatywne IOB utrzymujące się przez znaczny okres czasu bez wysiłku fizycznego sugeruje, że Twój profil jest zbyt silny i mniej insuliny jest wymagane w Twoich ustawieniach. diff --git a/app/src/main/res/values-pt-rBR/exam.xml b/app/src/main/res/values-pt-rBR/exam.xml index 0a6e10f3a3..c2bf8ae20a 100644 --- a/app/src/main/res/values-pt-rBR/exam.xml +++ b/app/src/main/res/values-pt-rBR/exam.xml @@ -136,7 +136,6 @@ Dê uma porção do bolus calculado não administrado por meio de seringa/caneta ou usando o menu ações -> purgar/preencher. Não faça nada e permita que o AndroidAPS corrija qualquer nível de glicose elevado resultante. Insulina ativa (IA) - Marque todas as respostas corretas. O valor de IA é afetado por basais temporárias efetuadas. Um basal alto temporário não será efetuado quando sua glicose estiver abaixo do alvo. Insulina Ativa (IA) negativa por um período substancial na ausência de exercícios, sugere que seu perfil é muito agressivo e menos insulina deve ser considerada nas suas configurações. diff --git a/app/src/main/res/values-pt-rPT/exam.xml b/app/src/main/res/values-pt-rPT/exam.xml index 3b66353316..5d3cd2fca4 100644 --- a/app/src/main/res/values-pt-rPT/exam.xml +++ b/app/src/main/res/values-pt-rPT/exam.xml @@ -134,7 +134,6 @@ Bólus uma proporção de insulina calculada \'não administrada\' ou com seringa/caneta ou purgando. Faça nada e permita que o AndroidAPS corrija qualquer nível de glicose elevado que daí resulte. Insulina ativa (IA ) - Marque todas as respostas corretas. O valor do IA é afectado por basais temporárias emitidas. Basal temporária alta não será dada quando a sua glicose estiver abaixo do alvo. IA negativa por um período substancial na ausência de exercício, sugere que o seu perfil é muito alto e é necessária menos insulina nas suas configurações. diff --git a/app/src/main/res/values-ro-rRO/exam.xml b/app/src/main/res/values-ro-rRO/exam.xml index e71e92bee4..4b5f2acaf1 100644 --- a/app/src/main/res/values-ro-rRO/exam.xml +++ b/app/src/main/res/values-ro-rRO/exam.xml @@ -134,7 +134,6 @@ Bolusati o cantitate parțiala de insulina din insulina calculata ca fiind lipsa utilizând seringa/penul sau amorsarea. Nu faceți nimic și permiteți AndroidAPS să corecteze valorile mari ale glicemiei. Insulină activă (IOB) - Bifați toate răspunsurile corecte. Valoarea IOB este afectată de bazalele temporare emise. Rata bazala ridicata temporara nu va fi livrata atunci când glicemia este sub nivelul țintă. Un IOB negativ pentru o perioadă substanțială în absența exercițiilor fizice sugerează că profilul tău este prea puternic și este nevoie de mai puţină insulină în setările inițiale. diff --git a/app/src/main/res/values-ru-rRU/exam.xml b/app/src/main/res/values-ru-rRU/exam.xml index d5edb09ce2..bef3de9917 100644 --- a/app/src/main/res/values-ru-rRU/exam.xml +++ b/app/src/main/res/values-ru-rRU/exam.xml @@ -137,7 +137,6 @@ Рассчитать и ввести «пропущенный» вами инсулин шприцем/ручкой или через кнопку заполнения канюли. Ничего не делать и позволить AndroidAPS исправить возможный высокий уровень ГК. Активный инсулин (IOB) - Отметьте все правильные ответы. На величину IOB влияют устанавливаемые ВБС. Высокая ВБС не будет применяться, если уровень сахара в крови ниже целевого. Отрицательный IOB в течение длительного периода при отсутствии физнагрузки указывает на то, что ваш профиль завышен и требуется снизить кол-во инсулина в настройках. diff --git a/app/src/main/res/values-ru-rRU/objectives.xml b/app/src/main/res/values-ru-rRU/objectives.xml index 65f4dd716f..499fa398bf 100644 --- a/app/src/main/res/values-ru-rRU/objectives.xml +++ b/app/src/main/res/values-ru-rRU/objectives.xml @@ -6,7 +6,7 @@ Цель %1$d не начата Цель %1$d не завершена Настройка визуализации и мониторинга, анализ базала и коэффициентов - Убедитесь, что BG доступен в Nightscut, и данные инсулина помпы загружаются + Убедитесь, что значения ГК и данные по инсулину помпы передаются в Nightscout Старт незамкнутого цикла Начинайте работу в режиме незамкнутого цикла и ручной подстройки величины временного базала. Установите и применяйте временные цели и временные цели по умолчанию (напр. углеводы при нагрузке или купировании гипо) Глубже понимаем незакольцованную систему Open Loop, включая ее рекомендации по временным базалам diff --git a/app/src/main/res/values-ru-rRU/strings.xml b/app/src/main/res/values-ru-rRU/strings.xml index 9baf342a88..81ad3a36a1 100644 --- a/app/src/main/res/values-ru-rRU/strings.xml +++ b/app/src/main/res/values-ru-rRU/strings.xml @@ -6,6 +6,7 @@ Безопасность терапии Макс разрешенный болюс [U] ед. Макс разрешенные углеводы (г) + Уровень ГК, ниже которого происходит остановка подачи инсулина Настройки %1$s Настройки Синхронизировать назначения с NS @@ -432,6 +433,8 @@ Активировать локальную передачу Супер микро болюс OpenAPS Динамический ISF + Коэффициент регулировки динамического диапазона чувствительности ISF % + Коэффициент корректировки динамического диапазона чувствительности ISF. Установите более 100% для агрессивных доз коррекции и менее 100% для менее агрессивной коррекции. Включить непредвиденный прием пищи UAM Включить супер микро болюс SMB Для ускорения действия используйте супер микро болюсы SMB вместо временного базала @@ -590,6 +593,7 @@ Эта величина называется Max IOB в OpenAPS context\nOpenAPS не будет добавлять инсулин если текущий активный инсулин ее превысит Максимальное время усваимости пищи [h] Время, за которое любая еда считается усвоившейся. Оставшиеся углеводы не будут учтены. + Значение уровня ГК, на котором происходит приостановка подачи инсулина. Значения по умолчанию являются стандартными для целевого диапазона. Пользователь может установить значения между 60 мг/дл (3.3 ммоль/л) и 100 мг/дл (5.5 ммоль/л) Параметры, заданные ниже 65/3.6 приводят к использованию значений по умолчанию Показать поле примечаний в диалогах назначений Далее Назад @@ -965,6 +969,7 @@ Макс ГК вне диапазона! ВремЦель:\nМин: %1$s\nМакс.: %2$s\nДлительность: %3$s ВремЦель:\nЦель: %1$s\nДлительность: %2$s + ВремЦель:\nПричина: %1$s\nЦель.: %2$s\nДлительность: %3$s Мастер: %1$s\nИнсулин: %2$.2fЕд\nУгл: %3$dg Мастер:\nИнсулин: %1$.2fЕд\nУгл: %2$dg Показать запись на устройстве: diff --git a/app/src/main/res/values-sk-rSK/exam.xml b/app/src/main/res/values-sk-rSK/exam.xml index 54aaa5002d..00592c1bdb 100644 --- a/app/src/main/res/values-sk-rSK/exam.xml +++ b/app/src/main/res/values-sk-rSK/exam.xml @@ -137,7 +137,6 @@ Pošlite bolus na vypočítaný „chýbajúci“ inzulín buď injekčnou striekačkou, alebo perom, alebo pomocou plnenia na pumpe. Nerobte nič a dovoľte AndroidAPS upraviť akúkoľvek výslednú vysokú hladinu glukózy v krvi. Aktívny inzulín (IOB) - Zaškrtnite všetky správne odpovede. Hodnota IOB je ovplyvnená vydanými dočasnými bazálmi. Vysoký dočasný bazál nebude spustený, pokiaľ je Vaša glykémia nižšia, ako cieľ. Negatívne IOB po značnú dobu bez cvičenia naznačuje, že váš profil je príliš \"silný\" a vo vašom profile je potrebného menej inzulínu. diff --git a/app/src/main/res/values-sv-rSE/exam.xml b/app/src/main/res/values-sv-rSE/exam.xml index 9657e08fdd..cf588d6136 100644 --- a/app/src/main/res/values-sv-rSE/exam.xml +++ b/app/src/main/res/values-sv-rSE/exam.xml @@ -134,7 +134,6 @@ Ge en bolus med en del av det insulin du saknar antingen med penna eller genom att använda förfyllningsfunktionen. Gör ingenting och låt AndroidAPS korrigera eventuella höga blodglukosnivåer. Aktivt Insulin (IOB) - Markera ett eller flera alternativ. IOB-värdet påverkas av temp basaler. Hög temp basal kommer inte att ges när ditt BG-värde är under målet. Negativ IOB under en längre period även om du inte motionerat, tyder på att din profil ger för mycket insulin. diff --git a/app/src/main/res/values-tr-rTR/exam.xml b/app/src/main/res/values-tr-rTR/exam.xml index 979bfb5b2e..99937663ce 100644 --- a/app/src/main/res/values-tr-rTR/exam.xml +++ b/app/src/main/res/values-tr-rTR/exam.xml @@ -136,16 +136,22 @@ AndroidAPS ve pompa geçmişindeki değerleri karşılaştırın (pompa bunu destekliyorsa). Şırınga/kalem veya başlatma kullanarak hesaplanan \"eksik\" insülininizi bolus olarak karşılayın. Hiçbir şey yapmayın ve AndroidAPS\'in ortaya çıkabilecek yüksek kan şekeri seviyesini düzeltmesine müsade edin. - Aktif İnsülin (IOB) - Tüm doğru cevapları kontrol edin. - IOB değeri, verilen geçici bazallardan etkilenir. + Aktif Karbonhidrat (AKRB) + İDF değerinin değiştirilmesi AKRB (Aktif karbonhidrat) hesaplamasını nasıl etkiler? + Artan İDF, hesaplanan karbonhidrat emilimini etkilemez + Değişen Kİ değeri AKRB hesaplamasını nasıl etkiler? + Artan Kİ oranı, hesaplanan karbonhidrat emilimini etkilemez + Değişen profil yüzdesi AKRB hesaplamasını nasıl etkiler? + Profili %150\'ye ayarlamak hesaplanan karbonhidrat emilimini etkilemez + Aktif İnsülin (AİNS) + AİNS değeri, verilen geçici bazallardan etkilenir. Kan şekeriniz hedefin altına düştüğünde yüksek geçici bazal verilmeyecektir. - Egzersiz yapmadığınız halde uzun bir dönem için negatif IOB, profilinizin çok güçlü olduğunu ve ayarlarınızda daha az insüline ihtiyaç duyulduğunu gösterir. + Egzersiz yapmadığınız halde uzun bir dönem için negatif AİNS, profilinizin çok güçlü olduğunu ve ayarlarınızda daha az insüline ihtiyaç duyulduğunu gösterir. Önemli bir süre için pozitif IOB, insülin direncini veya habersiz öğünleri gösterir. Karbonhidrat girişi ve boluslar Tüketilen karbonhidratları tahmin etmek ve kaydetmek için sadece gram kullanılmalıdır. Tüketilen karbonhidratlar uygun bir değişim sistemi kullanılarak kaydedilebilir (örn. DAFNE \"CHO\" değişimleri veya Avrupa \"Ekmek Birimleri\"). - AndroidAPS, karbonhidrat \"çözünmesini\" tahmin etmek ve COB\'ı hesaplamak için dinamik bir model kullanır. + AndroidAPS, karbonhidrat \"çözünmesini\" tahmin etmek ve AKRB\'ı hesaplamak için dinamik bir model kullanır. Kan şekeri seviyeleri kabul edilebilir değerlerin dışındaysa (çok düşük veya çok yüksek), karbonhidrat veya insülin düzeltmeleri için öneriler sağlamak için bolus hesaplayıcı kullanılabilir. https://androidaps.readthedocs.io/en/latest/EN/Getting-Started/FAQ.html#insulin-to-carb-ratio-ic-g-u yayma-karbonhidratlar @@ -158,11 +164,11 @@ Uzaktan İzleme AndroidAPS\'i (örneğin çocuğunuz için) uzaktan nasıl izleyebilirsiniz? NS Client uygulaması, Nightscout uygulaması ve Nightscout web sayfasının tümü, AndroidAPS\'i uzaktan takip etmenize olanak tanır. - Diğer uygulamalar (ör. Dexcom takip, xDrip) bazı parametreleri (ör. kan şekeri/sensör değerleri) uzaktan takip etmenize izin verir, ancak farklı algoritma kullanımı, hatalı IOB veya COB değerlerine sebep olabilir. + Diğer uygulamalar (ör. Dexcom takip, xDrip) bazı parametreleri (ör. kan şekeri/sensör değerleri) uzaktan takip etmenize izin verir, ancak farklı algoritma kullanımı, hatalı AİNS veya AKRB değerlerine sebep olabilir. AndroidAPS\'yi uzaktan takip etmek için her iki cihazın da internet erişimine sahip olması gerekir (ör. Wi-Fi veya mobil/hücresel ağ verileri aracılığıyla). Uzak takipçi olarak kullanılan NS İstemcisi, AndroidAPS\'i hem izleyecek hem de tam kontrol sağlayacaktır. https://androidaps.readthedocs.io/en/latest/EN/Children/Children.html - İnsülin Duyarlılık Faktörü (ISF) + İnsülin Duyarlılık Faktörü (İDF) ISF değerlerini yükseltmek, belirli bir karbonhidrat miktarını karşılamak için daha fazla insülin verilmesine yol açacaktır. ISF değerinin düşürülmesi, hedeflenen kan şekerinin üzerinde bir düzeltme için daha fazla insülin verilmesine yol açar. Kan şekeri seviyeleri hedefin altında olduğunda ISF\'yi yükseltmenin veya düşürmenin insülin iletimi üzerinde hiçbir etkisi yoktur. @@ -175,7 +181,7 @@ Karbonhidrat insülin Oranı (I:C oranı) Daha yüksek I:C oranları, belirli bir miktarda karbonhidrat için daha az insülin verilmesine yol açar. Daha düşük I:C oranları, belirli bir miktarda karbonhidrat için daha az insülin verilmesine yol açar. - 0 COB\'niz varsa, IC oranını değiştirmek, belirli bir KŞ değerini düzeltmek için farklı insülin miktarına sebep olur. + 0 AKRB varsa, Kİ oranını değiştirmek, belirli bir KŞ değerini düzeltmek için farklı insülin miktarına sebep olur. Ekmek (değişim) birimini 10g veya 12g olarak sayarsanız IC farklı olacaktır. IC anlamı şudur: 1Ü insülin kaç ekmek birimi (değişim) kapsar. https://androidaps.readthedocs.io/en/latest/EN/Getting-Started/FAQ.html#carbohydrate-to-insulin-ratio-cr-g-u diff --git a/app/src/main/res/values-tr-rTR/strings.xml b/app/src/main/res/values-tr-rTR/strings.xml index 7e728fcaef..778403faab 100644 --- a/app/src/main/res/values-tr-rTR/strings.xml +++ b/app/src/main/res/values-tr-rTR/strings.xml @@ -6,6 +6,7 @@ Tedavi güvenliği Maks izin verilen bolus [U] Maks izin verilen karbonhidrat [g] + KŞ seviyesi altında düşük glikoz duraklatma meydana gelir %1$s Tercihler Tercihler NS\'tan tedavileri güncelle @@ -44,27 +45,27 @@ SMS komutlarını kullanarak uzaktan AndroidAPS kontrolü. İnsülin: Karbonhidrat: - IOB: - IOB: - Toplam IOB: - Toplam IOB etkinliği: + AİNS: + AİNS: + Toplam AİNS: + Toplam AİNS etkinliği: Süre: Oran: İns: - IOB: - Toplam IOB: + AİNS: + Toplam AİNS: GH Karbonhidrat Düzeltme - Bolus IOB + Bolus AİNS Şimdi Çalıştır SANAL POMPA Son Çalıştırma Girdi Parametreleri Glikoz durumu Mevcut Geçici Bazal - IOB Verisi + AİNS Verisi Profil Yemek Verisi Sonuç @@ -115,7 +116,7 @@ Yeni öneri mevcut Karbonhidrat Önerisi Nightscout\'un desteklenmeyen sürümü - Bazal IOB + Bazal AİNS Bolus kısıtlaması uygulandı Karbonhidrat kısıtlaması uygulandı Diğer @@ -139,8 +140,8 @@ İçe aktarma ayarları Maks Ü/s geçici Bazal ayarlanabilir Bu değer OpenAPS\'te \"maksimum bazal\" olarak adlandırılır - OpenAPS\'nin vermesine izin verilen maksimum bazal IOB (Aktif insülin) [U] - Bu değere OpenAPS bağlamında Maks IOB denir.\nAPS\'de bir kerede verilebilen maksimum insülin [U] ü. + OpenAPS\'in gönderebileceği maksimum bazal AİNS (Aktif insülin) [U] + Bu değere OpenAPS bağlamında Maks AİNS denir.\nAPS\'de bir kerede verilebilen maksimum insülin [U] ü. Dışa aktarılan tercihleri şifrelemek için kullanılacak ana parola sorulacaktır. İçe aktarılan tercihlerin şifresini çözmek için gerekli olan ana parola sorulacaktır. Aktarım iptal edildi! Tercihler dışa aktarılmadı! @@ -316,8 +317,8 @@ Aktif Karbonhidratın ne kadar hızlı sindirildiğine ve KŞ\'nin beklenenden d Günlüğü temizle NSCLIENT yazma izni yok. Yanlış API Anahtarı? Wear ayarları - Ayrıntılı IOB göster - Saat arayüzü üzerinde IOB\'yi bolus ve bazal olarak ayırın + Ayrıntılı AİNS göster + Saat arayüzü üzerinde AİNS\'i bolus ve bazal olarak ayırın başarısız - lütfen telefonu kontrol edin n/a Hasta tipi @@ -356,7 +357,7 @@ Aktif Karbonhidratın ne kadar hızlı sindirildiğine ve KŞ\'nin beklenenden d Döngü duraklatıldı Döngü devam ettirildi 15 dk eğilim - COB + AKRB Süperbolus NS\'a uygulama başlangıcını kaydet Ayarları uygulamak için uygulamadan çıkılıyor. @@ -439,7 +440,7 @@ Aktif Karbonhidratın ne kadar hızlı sindirildiğine ve KŞ\'nin beklenenden d SMB (Super Micro Bolus) etkinleştir Daha hızlı bir etki için geçici bazal yerine Super Micro Bolus kullanın (Uam) Bildirilmemiş öğünlerin tespiti - IOB Eğrisi Tepe Zamanı + AİNS Eğrisi Tepe Zamanı Tepe zamanı [min] Tepe Serbest tepe Oref @@ -495,28 +496,28 @@ Aktif Karbonhidratın ne kadar hızlı sindirildiğine ve KŞ\'nin beklenenden d Nightscout Client KŞ NS KŞ KŞ Hesaplaması - Bolus IOB (Aktif İnsülin) hesaplaması - Bazal IOB (Aktif İnsülin) hesaplaması + Bolus AİNS hesaplaması + Bazal AİNS hesaplaması Trend hesapla Süperbolus hesapla Sadece pozitif Sadece negatif - COB (Aktif Karbonhidrat) hesaplaması + AKRB (Aktif Karbonhidrat) hesaplaması Geçici hedef hesaplaması Yüzde Hesaplaması Döngü etkin APS Seçildi NSClient\'in yazma izni var Kapalı mod etkin - Maksimal IOB doğru şekilde ayarlandı + Maksimal AİNS doğru şekilde ayarlandı Seçili kaynaktan KŞ kullanılabilir Yayma bolus iletim hatası SMB\'yi her zaman etkinleştir SMB\'yi her zaman bağımsız olarak boluslarla etkinleştirin. G5 gibi verilerin yalnızca filtrelenmesiyle yalnızca KŞ kaynağıyla mümkündür Yemeklerden sonra SMB\'yi etkinleştir - Karbonhidrat alındıktan sonra 6 saat süreyle SMB\'yi (Super Micro Bolus) etkinleştirin.0 COB (Aktif Karbonhidrat) ile de çalışır, Şayet KŞ kaynağıyla kullanılacaksa verilerin iyice filtrelenmesiyle mümkündür.örn. Dexcom G5 gibi - SMB\'yi COB ile etkinleştir - COB (Aktif Karbonhidrat) aktif olduğunda SMB\'yi (Super Micro Bolus) etkinleştirin. + 0 AKRB (Aktif Karbonhidrat) olsa dahi, karbonhidrat alındıktan sonra 6 saat süreyle SMB\'yi (Süper Mikro Bolus) etkinleştirir. Şayet KŞ kaynağıyla kullanılacaksa verilerin iyice filtrelenmesiyle (Dexcom G5-G6 gibi) mümkündür. + SMB\'yi AKRB ile etkinleştir + AKRB (Aktif Karbonhidrat) aktif olduğunda SMB\'yi (Süper Mikro Bolus) etkinleştirin. Geçici hedeflerle SMB\'yi etkinleştir Geçici hedef aktif olduğunda SMB\'yi etkinleştir (yakında yeme, egzersiz) Yüksek geçici hedeflerle SMB\'yi etkinleştir @@ -579,7 +580,7 @@ Aktif Karbonhidratın ne kadar hızlı sindirildiğine ve KŞ\'nin beklenenden d Bazal doğru ayarlanmış %2$s\'den dolayı yayma bolus %1$.1f Ü ile sınırlandırılıyor %2$s\'den dolayı karbonhidratlar %1$d g ile sınırlandırılıyor - %2$s\'den dolayı IOB (Aktif İnsülin)%1$.1f Ü ile sınırlandırılıyor + %2$s\'den dolayı AİNS %1$.1f Ü ile sınırlandırılıyor tercihlerde maksimum değer sert sınır Durumu okumak başarısız oldu @@ -589,8 +590,8 @@ Aktif Karbonhidratın ne kadar hızlı sindirildiğine ve KŞ\'nin beklenenden d Açık Döngü modunda SMB\'ye (Super Micro Bolus) izin verilmiyor Yiyecek sıfırla - OpenAPS tarafından aşılmayacak, maksimum toplam IOB(Aktif İnsülin)[U] - Bu değer OpenAPS bağlamında Max IOB (Aktif İnsülin) olarak adlandırılır\nOpenAPS, mevcut IOB bu değerden daha büyükse daha fazla insülin eklemez + OpenAPS tarafından aşılamayacak maksimum toplam AİNS (Aktif İnsülin)[U] + Bu değer OpenAPS bağlamında Max AİNS (Aktif İnsülin) olarak adlandırılır\nOpenAPS, mevcut AİNS bu değerden daha büyükse daha fazla insülin vermez Besinin maksimum emilim süresi [h] Herhangi bir öğünün emildiği kabul edilen zaman. Kalan karbonhidratlar kesilecek. Altına düştüğünde insülinin askıya alındığı KŞ değeri. Varsayılan değer, standart hedef modeli kullanır. Kullanıcı değeri 60mg/dl (3,3mmol/l) ile 100mg/dl(5.5mmol/l) arasında ayarlayabilir. 65/3,6\'nın altındaki değerler varsayılan modelin kullanılmasına neden olur @@ -632,7 +633,7 @@ Aktif Karbonhidratın ne kadar hızlı sindirildiğine ve KŞ\'nin beklenenden d Durum oku Kurulum sihirbazını atla AndroidAPS\'ın bazal değişiklikleri önerme/yapmasını sağlamak için aşağıdaki düğmeye basın - Duyarlılık eklentisi, duyarlılık tespiti ve COB hesaplaması için kullanılır. Daha fazla bilgi için ziyaret edin: + Duyarlılık eklentisi, duyarlılık tespiti ve AKRB hesaplaması için kullanılır. Daha fazla bilgi için ziyaret edin: https://androidaps.readthedocs.io/en/latest/Configuration/Sensitivity-detection-and-COB.html NSClient, Nightscout\'a bağlantıyı sağlar. Şimdi bu kısmı atlayabilirsiniz, ancak ayarlamadan görevleri geçemezsiniz. Lütfen unutmayın: yeni insülin profilleri en az 5 saat DIA gerektirir. Yeni profildeki DIA 5–6 saat, eski insülin profillerinde DIA 3saat\'e eşittir. @@ -736,9 +737,9 @@ Aktif Karbonhidratın ne kadar hızlı sindirildiğine ve KŞ\'nin beklenenden d BYODA BYODA \'Kendi Dexcom Uygulamanızı Oluşturun\' uygulamasından KŞ değerlerini alın. - COB vs IOB + AKRB vs AİNS Bolus kısıtlaması uygulandı: %1$.2f Ü ile %2$.2f Ü - !!!!! Yavaş karbonhidrat emilimi tespit edildi: zamanın %2$d%% si. Hesaplamanızı iki kez kontrol edin. Aktif Karbonhidrat (COB) olduğundan fazla tahmin edilebilir, bu nedenle daha fazla insülin verilebilir !!!!!]]> + !!!!! Yavaş karbonhidrat emilimi tespit edildi: zamanın %2$d%% si. Hesaplamanızı iki kez kontrol edin. Aktif Karbonhidrat (AKRB) olduğundan fazla tahmin edilebilir, bu nedenle daha fazla insülin verilebilir !!!!!]]> Bolus sihirbazı sonucunun bu kadarını ilet [%] Bolus sihirbazı hesaplamayı gerçekleştirir ancak hesaplanan insülinin yalnızca bu kısmı iletilir. SMB algoritması ile kullanışlıdır. Ertele @@ -746,7 +747,7 @@ Aktif Karbonhidratın ne kadar hızlı sindirildiğine ve KŞ\'nin beklenenden d Geçersiz mesaj %1$s ISF: %2$.1f %1$.0fg IC: %2$.1f - %1$.1fg IC: %2$.1f + %1$.1fg Kİ: %2$.1f %1$d%% dk. Profil adı: @@ -897,7 +898,7 @@ Aktif Karbonhidratın ne kadar hızlı sindirildiğine ve KŞ\'nin beklenenden d GBO ve EB (Yayma Bolus) alın Başka bir örnek üzerinden girilen GBO ve EB (Yayma Bolusu) kabul edin İnsülinleri alın - NS veya NSClient aracılığıyla girilen insülini kabul edin (iletilmez, yalnızca aktif insüline göre (IOB) hesaplanır) + NS veya NSClient aracılığıyla girilen insülini kabul edin (iletilmez, yalnızca AİNS\'e göre hesaplanır) Karbonhidratları alın NS veya NSClient aracılığıyla girilen karbonhidratları kabul edin Terapi etkinlikleri alın @@ -977,13 +978,13 @@ Aktif Karbonhidratın ne kadar hızlı sindirildiğine ve KŞ\'nin beklenenden d Seçili hızlı asistan artık mevcut değil, lütfen kutucuğu yenileyin Hesaplamayı temel alacak yeni bir KŞ yok! Etkin profil ayarlanmadı! - Aktif karbonhidrat bilinmiyor! KŞ okuması eksik veya son uygulama yeniden başlatılsın mı? + Aktif karbonhidrat (AKRB) bilinmiyor! KŞ okuması eksik veya son uygulama yeniden başlatılsın mı? Karbonhidrat kısıtlaması ihlali! Hesap (KİO: %1$.1f, İDF: %2$.1f) Karb: %1$.2fÜ - COB: %1$.0fg %2$.2fÜ + AKRB: %1$.0fg %2$.2fÜ KŞ: %1$.2fÜ - Aktif İnsülin: %1$.2fÜ + AİNS: %1$.2fÜ Süperbolus: %1$.2fÜ 15\' trend: %1$.2fÜ Yüzde: %1$.2fÜ x %2$d%% ≈ %3$.2fÜ @@ -1043,4 +1044,5 @@ Aktif Karbonhidratın ne kadar hızlı sindirildiğine ve KŞ\'nin beklenenden d GlucoRx Aidex CGMS\'den KŞ değerleri alır. Şarj seçenekleri tarafından engellendi Bağlantı seçenekleri tarafından engellendi + (Saat Bağlı Değil) diff --git a/app/src/main/res/values-zh-rCN/exam.xml b/app/src/main/res/values-zh-rCN/exam.xml index ae7b8c0ad4..bb37fdc4ef 100644 --- a/app/src/main/res/values-zh-rCN/exam.xml +++ b/app/src/main/res/values-zh-rCN/exam.xml @@ -137,7 +137,6 @@ 通过注射器或胰岛素笔输注你计算出的“遗漏”胰岛素的一部分。 不做任何事情,允许AndroidAPS纠正高血糖导致的任何结果。 活性胰岛素(IOB) - 选择所有正确的答案。 活性胰岛素IOB数值受发布的临时基础率影响。 当您的血糖低于目标值时,不会被给予高临时基础率。 在没有运动的情况下,活性胰岛素IOB长时间负数表明你的个人配置太强,你需要在配置中减少的胰岛素用量。 diff --git a/automation/src/main/res/values-tr-rTR/strings.xml b/automation/src/main/res/values-tr-rTR/strings.xml index 2873b09421..5c34548fc0 100644 --- a/automation/src/main/res/values-tr-rTR/strings.xml +++ b/automation/src/main/res/values-tr-rTR/strings.xml @@ -93,8 +93,8 @@ Hedef [%1$s]: Son bolus önce Son bolus zamanı %1$s %2$s dakika önce - COB - AK (COB) %1$s %2$.0f + AKRB + AKRB %1$s %2$.0f IOB [U]: Mesafe [m]: Yinelenen zaman diff --git a/core/src/main/res/values-tr-rTR/strings.xml b/core/src/main/res/values-tr-rTR/strings.xml index 07bb349882..3452cc4f66 100644 --- a/core/src/main/res/values-tr-rTR/strings.xml +++ b/core/src/main/res/values-tr-rTR/strings.xml @@ -103,7 +103,7 @@ yok Glikoz IOB - COB + AKRB İsim: Zaman WiFi SSID diff --git a/diaconn/src/main/res/values-iw-rIL/strings.xml b/diaconn/src/main/res/values-iw-rIL/strings.xml index 793e713ae8..18a3277051 100644 --- a/diaconn/src/main/res/values-iw-rIL/strings.xml +++ b/diaconn/src/main/res/values-iw-rIL/strings.xml @@ -135,4 +135,5 @@ בעת השהייה עקב סוכר נמוך, ההזרקה מוגבלת מצב השהייה עקב סוכר נמוך מופעל, פקודת ON נדחתה. מצב השהייה עקב סוכר נמוך כבוי, פקודת OFF נדחתה. + שלח יומני משאבה לענן Diaconn. diff --git a/wear/src/main/res/values-fr-rFR/strings.xml b/wear/src/main/res/values-fr-rFR/strings.xml index e4bd273b2d..586ae78b10 100644 --- a/wear/src/main/res/values-fr-rFR/strings.xml +++ b/wear/src/main/res/values-fr-rFR/strings.xml @@ -184,4 +184,6 @@ 000 g 00,0 0,00 U + AAPS Mise en veille Alerte + Envoi Mise en veille à AAPS diff --git a/wear/src/main/res/values-it-rIT/strings.xml b/wear/src/main/res/values-it-rIT/strings.xml index ccf8bfec97..3e3d1105ac 100644 --- a/wear/src/main/res/values-it-rIT/strings.xml +++ b/wear/src/main/res/values-it-rIT/strings.xml @@ -184,4 +184,6 @@ 000g 00,0 0,00U + Avviso snooze AAPS + Invio snooze ad AAPS diff --git a/wear/src/main/res/values-ru-rRU/strings.xml b/wear/src/main/res/values-ru-rRU/strings.xml index 034531f610..6dd54951ae 100644 --- a/wear/src/main/res/values-ru-rRU/strings.xml +++ b/wear/src/main/res/values-ru-rRU/strings.xml @@ -184,4 +184,6 @@ 000г 00,0 0,00 ед + Отложить оповещения AAPS + Отправка команды отложить оповещения AAPS diff --git a/wear/src/main/res/values-tr-rTR/strings.xml b/wear/src/main/res/values-tr-rTR/strings.xml index f9db54975d..ed3f2c0666 100644 --- a/wear/src/main/res/values-tr-rTR/strings.xml +++ b/wear/src/main/res/values-tr-rTR/strings.xml @@ -24,7 +24,7 @@ Eylemler için Birimler Tarihi Göster IOB\'yi göster - COB\'u göster + AKRB göster Deltayı göster OrtDelta\'yı Göster Telefon Pilini Göster From 12b21eee72de2b5b2fec4e7d1424cf1e7d53db6f Mon Sep 17 00:00:00 2001 From: Milos Kozak Date: Sun, 10 Jul 2022 10:25:27 +0200 Subject: [PATCH 28/39] 3.0.0.2-dev-o --- app/build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/build.gradle b/app/build.gradle index da06e17acd..65236b15cf 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -105,7 +105,7 @@ android { defaultConfig { multiDexEnabled true versionCode 1500 - version "3.0.0.2-autotune-dev-n0" + version "3.0.0.2-dev-o" buildConfigField "String", "VERSION", '"' + version + '"' buildConfigField "String", "BUILDVERSION", '"' + generateGitBuild() + '-' + generateDate() + '"' buildConfigField "String", "REMOTE", '"' + generateGitRemote() + '"' From e1423c0f82a2c56a7d7e1ac734c413ab80b24285 Mon Sep 17 00:00:00 2001 From: Milos Kozak Date: Sun, 10 Jul 2022 20:48:19 +0200 Subject: [PATCH 29/39] catch serialization --- .../java/info/nightscout/shared/weardata/EventData.kt | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/shared/src/main/java/info/nightscout/shared/weardata/EventData.kt b/shared/src/main/java/info/nightscout/shared/weardata/EventData.kt index aca2303c89..fd30835155 100644 --- a/shared/src/main/java/info/nightscout/shared/weardata/EventData.kt +++ b/shared/src/main/java/info/nightscout/shared/weardata/EventData.kt @@ -14,7 +14,11 @@ sealed class EventData : Event() { companion object { - fun deserialize(json: String) = Json.decodeFromString(serializer(), json) + fun deserialize(json: String) = try { + Json.decodeFromString(serializer(), json) + } catch (ignored: Exception) { + Error(System.currentTimeMillis()) + } } // Mobile <- Wear @@ -234,7 +238,7 @@ sealed class EventData : Event() { @Serializable // returnCommand is sent back to Mobile after confirmation data class ConfirmAction(val title: String, val message: String, val returnCommand: EventData?) : EventData() - + @Serializable data class SnoozeAlert(val timeStamp: Long) : EventData() } From 89d2290ed971d91c8ebebb76fa53022a3d62c82a Mon Sep 17 00:00:00 2001 From: Milos Kozak Date: Sun, 10 Jul 2022 23:05:34 +0200 Subject: [PATCH 30/39] cleanup --- .../pump/medtronic/MedtronicPumpPlugin.kt | 3 ++- .../medtronic/data/MedtronicHistoryData.kt | 3 ++- .../plugins/pump/common/PumpPluginAbstract.kt | 24 +++++++++---------- 3 files changed, 15 insertions(+), 15 deletions(-) diff --git a/medtronic/src/main/java/info/nightscout/androidaps/plugins/pump/medtronic/MedtronicPumpPlugin.kt b/medtronic/src/main/java/info/nightscout/androidaps/plugins/pump/medtronic/MedtronicPumpPlugin.kt index a3849304e5..05478bb4a0 100644 --- a/medtronic/src/main/java/info/nightscout/androidaps/plugins/pump/medtronic/MedtronicPumpPlugin.kt +++ b/medtronic/src/main/java/info/nightscout/androidaps/plugins/pump/medtronic/MedtronicPumpPlugin.kt @@ -34,6 +34,7 @@ import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.service.tasks import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.service.tasks.WakeAndTuneTask import info.nightscout.androidaps.plugins.pump.common.sync.PumpDbEntryTBR import info.nightscout.androidaps.plugins.pump.common.sync.PumpSyncEntriesCreator +import info.nightscout.androidaps.plugins.pump.common.sync.PumpSyncStorage import info.nightscout.androidaps.plugins.pump.common.utils.DateTimeUtil import info.nightscout.androidaps.plugins.pump.common.utils.ProfileUtil import info.nightscout.androidaps.plugins.pump.medtronic.comm.history.pump.PumpHistoryEntry @@ -90,7 +91,7 @@ class MedtronicPumpPlugin @Inject constructor( dateUtil: DateUtil, aapsSchedulers: AapsSchedulers, pumpSync: PumpSync, - pumpSyncStorage: info.nightscout.androidaps.plugins.pump.common.sync.PumpSyncStorage + pumpSyncStorage: PumpSyncStorage ) : PumpPluginAbstract( PluginDescription() // .mainType(PluginType.PUMP) // diff --git a/medtronic/src/main/java/info/nightscout/androidaps/plugins/pump/medtronic/data/MedtronicHistoryData.kt b/medtronic/src/main/java/info/nightscout/androidaps/plugins/pump/medtronic/data/MedtronicHistoryData.kt index 752d7e187b..2151ac018a 100644 --- a/medtronic/src/main/java/info/nightscout/androidaps/plugins/pump/medtronic/data/MedtronicHistoryData.kt +++ b/medtronic/src/main/java/info/nightscout/androidaps/plugins/pump/medtronic/data/MedtronicHistoryData.kt @@ -29,6 +29,7 @@ import info.nightscout.androidaps.plugins.pump.medtronic.driver.MedtronicPumpSta import info.nightscout.androidaps.plugins.pump.medtronic.util.MedtronicConst import info.nightscout.androidaps.plugins.pump.medtronic.util.MedtronicUtil import info.nightscout.androidaps.interfaces.ResourceHelper +import info.nightscout.androidaps.plugins.pump.common.sync.PumpSyncStorage import info.nightscout.shared.sharedPreferences.SP import org.apache.commons.lang3.StringUtils import org.joda.time.LocalDateTime @@ -57,7 +58,7 @@ class MedtronicHistoryData @Inject constructor( val medtronicPumpHistoryDecoder: MedtronicPumpHistoryDecoder, val medtronicPumpStatus: MedtronicPumpStatus, val pumpSync: PumpSync, - val pumpSyncStorage: info.nightscout.androidaps.plugins.pump.common.sync.PumpSyncStorage + val pumpSyncStorage: PumpSyncStorage ) { val allHistory: MutableList = mutableListOf() diff --git a/pump-common/src/main/java/info/nightscout/androidaps/plugins/pump/common/PumpPluginAbstract.kt b/pump-common/src/main/java/info/nightscout/androidaps/plugins/pump/common/PumpPluginAbstract.kt index 00ee367a8c..93825facce 100644 --- a/pump-common/src/main/java/info/nightscout/androidaps/plugins/pump/common/PumpPluginAbstract.kt +++ b/pump-common/src/main/java/info/nightscout/androidaps/plugins/pump/common/PumpPluginAbstract.kt @@ -26,6 +26,7 @@ import info.nightscout.androidaps.utils.DecimalFormatter.to0Decimal import info.nightscout.androidaps.utils.DecimalFormatter.to2Decimal import info.nightscout.androidaps.utils.FabricPrivacy import info.nightscout.androidaps.interfaces.ResourceHelper +import info.nightscout.androidaps.plugins.pump.common.sync.PumpSyncStorage import info.nightscout.androidaps.utils.rx.AapsSchedulers import info.nightscout.shared.logging.AAPSLogger import info.nightscout.shared.logging.LTag @@ -39,9 +40,9 @@ import org.json.JSONObject */ // When using this class, make sure that your first step is to create mConnection (see MedtronicPumpPlugin) abstract class PumpPluginAbstract protected constructor( - pluginDescription: PluginDescription?, + pluginDescription: PluginDescription, pumpType: PumpType, - injector: HasAndroidInjector?, + injector: HasAndroidInjector, rh: ResourceHelper, aapsLogger: AAPSLogger, commandQueue: CommandQueue, @@ -53,8 +54,8 @@ abstract class PumpPluginAbstract protected constructor( var dateUtil: DateUtil, var aapsSchedulers: AapsSchedulers, var pumpSync: PumpSync, - var pumpSyncStorage: info.nightscout.androidaps.plugins.pump.common.sync.PumpSyncStorage -) : PumpPluginBase(pluginDescription!!, injector!!, aapsLogger, rh, commandQueue), Pump, Constraints, info.nightscout.androidaps.plugins.pump.common.sync.PumpSyncEntriesCreator { + var pumpSyncStorage: PumpSyncStorage +) : PumpPluginBase(pluginDescription, injector, aapsLogger, rh, commandQueue), Pump, Constraints, info.nightscout.androidaps.plugins.pump.common.sync.PumpSyncEntriesCreator { private val disposable = CompositeDisposable() @@ -84,7 +85,7 @@ abstract class PumpPluginAbstract protected constructor( disposable.add(rxBus .toObservable(EventAppExit::class.java) .observeOn(aapsSchedulers.io) - .subscribe({ _ -> context.unbindService(serviceConnection!!) }) { throwable: Throwable? -> fabricPrivacy.logException(throwable!!) } + .subscribe({ context.unbindService(serviceConnection!!) }) { throwable: Throwable? -> fabricPrivacy.logException(throwable!!) } ) onStartCustomActions() } @@ -265,19 +266,16 @@ abstract class PumpPluginAbstract protected constructor( override fun shortStatus(veryShort: Boolean): String { var ret = "" - if (pumpStatusData.lastConnection == 0L) { - ret += "LastConn: never\n" + ret += if (pumpStatusData.lastConnection == 0L) { + "LastConn: never\n" } else { val agoMsec = System.currentTimeMillis() - pumpStatusData.lastConnection val agoMin = (agoMsec / 60.0 / 1000.0).toInt() - ret += "LastConn: $agoMin min ago\n" + "LastConn: $agoMin min ago\n" } - if (pumpStatusData.lastBolusTime != null && pumpStatusData.lastBolusTime!!.time != 0L) { - ret += """ - LastBolus: ${to2Decimal(pumpStatusData.lastBolusAmount!!)}U @${DateFormat.format("HH:mm", pumpStatusData.lastBolusTime)} - - """.trimIndent() + if (pumpStatusData.lastBolusTime?.time != 0L) { + ret += "LastBolus: ${to2Decimal(pumpStatusData.lastBolusAmount!!)}U @${DateFormat.format("HH:mm", pumpStatusData.lastBolusTime)}" } val activeTemp = pumpSync.expectedPumpState().temporaryBasal if (activeTemp != null) { From b025fea343cd0a3f9ac5320dd1fdc3717b9f4af4 Mon Sep 17 00:00:00 2001 From: Milos Kozak Date: Sun, 10 Jul 2022 23:13:14 +0200 Subject: [PATCH 31/39] cleanup --- .../plugins/pump/common/PumpPluginAbstract.kt | 44 +++++-------------- 1 file changed, 10 insertions(+), 34 deletions(-) diff --git a/pump-common/src/main/java/info/nightscout/androidaps/plugins/pump/common/PumpPluginAbstract.kt b/pump-common/src/main/java/info/nightscout/androidaps/plugins/pump/common/PumpPluginAbstract.kt index 93825facce..8ae4202a56 100644 --- a/pump-common/src/main/java/info/nightscout/androidaps/plugins/pump/common/PumpPluginAbstract.kt +++ b/pump-common/src/main/java/info/nightscout/androidaps/plugins/pump/common/PumpPluginAbstract.kt @@ -269,44 +269,20 @@ abstract class PumpPluginAbstract protected constructor( ret += if (pumpStatusData.lastConnection == 0L) { "LastConn: never\n" } else { - val agoMsec = System.currentTimeMillis() - pumpStatusData.lastConnection - val agoMin = (agoMsec / 60.0 / 1000.0).toInt() + val agoMin = ((System.currentTimeMillis() - pumpStatusData.lastConnection) / 60.0 / 1000.0).toInt() "LastConn: $agoMin min ago\n" } - if (pumpStatusData.lastBolusTime?.time != 0L) { - ret += "LastBolus: ${to2Decimal(pumpStatusData.lastBolusAmount!!)}U @${DateFormat.format("HH:mm", pumpStatusData.lastBolusTime)}" + pumpStatusData.lastBolusTime?.let { + if (it.time != 0L) { + ret += "LastBolus: ${to2Decimal(pumpStatusData.lastBolusAmount!!)}U @${DateFormat.format("HH:mm", it)}\n" + } } - val activeTemp = pumpSync.expectedPumpState().temporaryBasal - if (activeTemp != null) { - ret += """ - Temp: ${activeTemp.toStringFull(dateUtil)} - - """.trimIndent() - } - val activeExtendedBolus = pumpSync.expectedPumpState().extendedBolus - if (activeExtendedBolus != null) { - ret += """ - Extended: ${activeExtendedBolus.toStringFull(dateUtil)} - - """.trimIndent() - } - // if (!veryShort) { - // ret += "TDD: " + DecimalFormatter.to0Decimal(pumpStatus.dailyTotalUnits) + " / " - // + pumpStatus.maxDailyTotalUnits + " U\n"; - // } - ret += """ - IOB: ${pumpStatusData.iob}U - - """.trimIndent() - ret += """ - Reserv: ${to0Decimal(pumpStatusData.reservoirRemainingUnits)}U - - """.trimIndent() - ret += """ - Batt: ${pumpStatusData.batteryRemaining} - - """.trimIndent() + pumpSync.expectedPumpState().temporaryBasal?.let { ret += "Temp: ${it.toStringFull(dateUtil)}\n" } + pumpSync.expectedPumpState().extendedBolus?.let { ret += "Extended: ${it.toStringFull(dateUtil)}\n" } + ret += "IOB: ${pumpStatusData.iob}U\n" + ret += "Reserv: ${to0Decimal(pumpStatusData.reservoirRemainingUnits)}U\n" + ret += "Batt: ${pumpStatusData.batteryRemaining}\n" return ret } From d78f685f1ff872a92bbb2d997f09469276075773 Mon Sep 17 00:00:00 2001 From: Andries Smit Date: Tue, 12 Jul 2022 15:37:56 +0200 Subject: [PATCH 32/39] fix: eros time color --- .../pump/omnipod/eros/ui/OmnipodErosOverviewFragment.kt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/omnipod-eros/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/eros/ui/OmnipodErosOverviewFragment.kt b/omnipod-eros/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/eros/ui/OmnipodErosOverviewFragment.kt index 429301d62c..e26bb0dfb0 100644 --- a/omnipod-eros/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/eros/ui/OmnipodErosOverviewFragment.kt +++ b/omnipod-eros/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/eros/ui/OmnipodErosOverviewFragment.kt @@ -287,9 +287,9 @@ class OmnipodErosOverviewFragment : DaggerFragment() { podInfoBinding.timeOnPod.setTextColor( rh.gac(context, if (podStateManager.timeDeviatesMoreThan(OmnipodConstants.TIME_DEVIATION_THRESHOLD)) { - R.attr.defaultTextColor - } else { R.attr.warningColor + } else { + R.attr.defaultTextColor }) ) val expiresAt = podStateManager.expiresAt From ff35b07304999116b7f45c75257eda25e8f4af59 Mon Sep 17 00:00:00 2001 From: Andries Smit Date: Tue, 12 Jul 2022 16:01:10 +0200 Subject: [PATCH 33/39] chore: add tool hint for merge layout --- .../omnipod_common_overview_buttons.xml | 7 +- .../omnipod_common_overview_pod_info.xml | 127 +++++++++--------- ...ommon_pod_deactivation_wizard_activity.xml | 4 +- ...omnipod_dash_overview_bluetooth_status.xml | 39 +++--- ...mnipod_eros_overview_riley_link_status.xml | 12 +- 5 files changed, 101 insertions(+), 88 deletions(-) diff --git a/omnipod-common/src/main/res/layout/omnipod_common_overview_buttons.xml b/omnipod-common/src/main/res/layout/omnipod_common_overview_buttons.xml index 50c2861bf3..14844d8efc 100644 --- a/omnipod-common/src/main/res/layout/omnipod_common_overview_buttons.xml +++ b/omnipod-common/src/main/res/layout/omnipod_common_overview_buttons.xml @@ -1,6 +1,9 @@ + android:layout_height="wrap_content" + android:orientation="horizontal" + tools:parentTag="android.widget.LinearLayout"> - \ No newline at end of file + diff --git a/omnipod-common/src/main/res/layout/omnipod_common_overview_pod_info.xml b/omnipod-common/src/main/res/layout/omnipod_common_overview_pod_info.xml index ff9e401287..9813bcd36b 100644 --- a/omnipod-common/src/main/res/layout/omnipod_common_overview_pod_info.xml +++ b/omnipod-common/src/main/res/layout/omnipod_common_overview_pod_info.xml @@ -2,24 +2,26 @@ xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" - android:layout_height="match_parent"> + android:layout_height="match_parent" + android:orientation="vertical" + tools:parentTag="android.widget.LinearLayout"> + android:focusable="true" + android:orientation="horizontal"> @@ -49,17 +51,17 @@ android:id="@+id/omnipod_common_overview_lot_number_layout" android:layout_width="match_parent" android:layout_height="wrap_content" - android:orientation="horizontal" - android:focusable="true"> + android:focusable="true" + android:orientation="horizontal"> @@ -88,17 +90,17 @@ + android:focusable="true" + android:orientation="horizontal"> @@ -127,17 +129,17 @@ + android:focusable="true" + android:orientation="horizontal"> @@ -166,17 +168,17 @@ + android:focusable="true" + android:orientation="horizontal"> @@ -206,17 +208,17 @@ + android:focusable="true" + android:orientation="horizontal"> @@ -246,17 +248,17 @@ + android:focusable="true" + android:orientation="horizontal"> @@ -302,17 +304,17 @@ + android:focusable="true" + android:orientation="horizontal"> @@ -350,17 +352,17 @@ + android:focusable="true" + android:orientation="horizontal"> @@ -398,17 +400,17 @@ + android:focusable="true" + android:orientation="horizontal"> @@ -446,17 +448,17 @@ + android:focusable="true" + android:orientation="horizontal"> @@ -494,17 +496,17 @@ + android:focusable="true" + android:orientation="horizontal"> @@ -542,17 +544,17 @@ + android:focusable="true" + android:orientation="horizontal"> @@ -590,17 +592,17 @@ + android:focusable="true" + android:orientation="horizontal"> @@ -638,17 +640,17 @@ + android:focusable="true" + android:orientation="horizontal"> @@ -691,4 +693,5 @@ android:rotationX="180" android:rotationY="180" app:drawableTopCompat="@drawable/ic_pod" /> - \ No newline at end of file + + diff --git a/omnipod-common/src/main/res/layout/omnipod_common_pod_deactivation_wizard_activity.xml b/omnipod-common/src/main/res/layout/omnipod_common_pod_deactivation_wizard_activity.xml index f6143346a7..334bb28408 100644 --- a/omnipod-common/src/main/res/layout/omnipod_common_pod_deactivation_wizard_activity.xml +++ b/omnipod-common/src/main/res/layout/omnipod_common_pod_deactivation_wizard_activity.xml @@ -10,6 +10,6 @@ android:name="androidx.navigation.fragment.NavHostFragment" android:layout_width="match_parent" android:layout_height="match_parent" - app:navGraph="@navigation/omnipod_common_pod_deactivation_wizard_navigation_graph" /> - \ No newline at end of file + + diff --git a/omnipod-dash/src/main/res/layout/omnipod_dash_overview_bluetooth_status.xml b/omnipod-dash/src/main/res/layout/omnipod_dash_overview_bluetooth_status.xml index c4d2b73130..a117c1ce23 100644 --- a/omnipod-dash/src/main/res/layout/omnipod_dash_overview_bluetooth_status.xml +++ b/omnipod-dash/src/main/res/layout/omnipod_dash_overview_bluetooth_status.xml @@ -1,20 +1,22 @@ + xmlns:tools="http://schemas.android.com/tools" + android:orientation="vertical" + tools:parentTag="android.widget.LinearLayout"> + android:focusable="true" + android:orientation="horizontal"> + + android:focusable="true" + android:orientation="horizontal"> @@ -82,18 +85,18 @@ android:id="@+id/connectionQuality" android:layout_width="match_parent" android:layout_height="wrap_content" + android:focusable="true" android:orientation="horizontal" - android:visibility="gone" - android:focusable="true"> + android:visibility="gone"> + + android:visibility="gone"> + + xmlns:tools="http://schemas.android.com/tools" + android:orientation="vertical" + tools:parentTag="android.widget.LinearLayout"> + android:focusable="true" + android:orientation="horizontal"> From 89694e22011bb126d7781f32582398b4c1864ef2 Mon Sep 17 00:00:00 2001 From: Andries Smit Date: Tue, 12 Jul 2022 16:32:54 +0200 Subject: [PATCH 34/39] feat: default select active profile --- .../plugins/profile/local/LocalProfileFragment.kt | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/profile/local/LocalProfileFragment.kt b/app/src/main/java/info/nightscout/androidaps/plugins/profile/local/LocalProfileFragment.kt index 77f0139d4b..a68d6ee25a 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/profile/local/LocalProfileFragment.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/profile/local/LocalProfileFragment.kt @@ -23,6 +23,7 @@ import info.nightscout.androidaps.extensions.toVisibility import info.nightscout.androidaps.interfaces.ActivePlugin import info.nightscout.androidaps.interfaces.GlucoseUnit import info.nightscout.androidaps.interfaces.Profile +import info.nightscout.androidaps.interfaces.ProfileFunction import info.nightscout.androidaps.logging.UserEntryLogger import info.nightscout.androidaps.plugins.bus.RxBus import info.nightscout.androidaps.plugins.profile.local.events.EventLocalProfileChanged @@ -52,6 +53,7 @@ class LocalProfileFragment : DaggerFragment() { @Inject lateinit var activePlugin: ActivePlugin @Inject lateinit var fabricPrivacy: FabricPrivacy @Inject lateinit var localProfilePlugin: LocalProfilePlugin + @Inject lateinit var profileFunction: ProfileFunction @Inject lateinit var hardLimits: HardLimits @Inject lateinit var protectionCheck: ProtectionCheck @Inject lateinit var dateUtil: DateUtil @@ -117,6 +119,11 @@ class LocalProfileFragment : DaggerFragment() { }) binding.diaLabel.labelFor = binding.dia.editTextId binding.unlock.setOnClickListener { queryProtection() } + + val profiles = localProfilePlugin.profile?.getProfileList() ?: ArrayList() + val activeProfile = profileFunction.getProfileName() + val profileIndex = profiles.indexOf(activeProfile) + localProfilePlugin.currentProfileIndex = if (profileIndex >= 0) profileIndex else 0 } fun build() { @@ -387,10 +394,10 @@ class LocalProfileFragment : DaggerFragment() { private fun processVisibility(position: Int) { binding.diaPlaceholder.visibility = (position == 0).toVisibility() - binding.ic.visibility = (position == 1).toVisibility() - binding.isf.visibility = (position == 2).toVisibility() - binding.basal.visibility = (position == 3).toVisibility() - binding.target.visibility = (position == 4).toVisibility() + binding.ic.visibility = (position == 1).toVisibility() + binding.isf.visibility = (position == 2).toVisibility() + binding.basal.visibility = (position == 3).toVisibility() + binding.target.visibility = (position == 4).toVisibility() } private fun updateProtectedUi() { From 71a64e0b23b6373900e458adcf331108acd00dc7 Mon Sep 17 00:00:00 2001 From: Milos Kozak Date: Tue, 12 Jul 2022 18:41:57 +0200 Subject: [PATCH 35/39] autotune prefs colapsed --- app/src/main/res/xml/pref_autotune.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/src/main/res/xml/pref_autotune.xml b/app/src/main/res/xml/pref_autotune.xml index fc5f6dbc72..aef72365a0 100644 --- a/app/src/main/res/xml/pref_autotune.xml +++ b/app/src/main/res/xml/pref_autotune.xml @@ -4,7 +4,7 @@ + app:initialExpandedChildrenCount="0"> Date: Tue, 12 Jul 2022 18:44:02 +0200 Subject: [PATCH 36/39] add dynISF plugin to preferences --- .../nightscout/androidaps/activities/MyPreferenceFragment.kt | 3 +++ 1 file changed, 3 insertions(+) diff --git a/app/src/main/java/info/nightscout/androidaps/activities/MyPreferenceFragment.kt b/app/src/main/java/info/nightscout/androidaps/activities/MyPreferenceFragment.kt index c0f577d427..8da9192724 100644 --- a/app/src/main/java/info/nightscout/androidaps/activities/MyPreferenceFragment.kt +++ b/app/src/main/java/info/nightscout/androidaps/activities/MyPreferenceFragment.kt @@ -49,6 +49,7 @@ import info.nightscout.androidaps.utils.alertDialogs.OKDialog.show import info.nightscout.androidaps.utils.protection.PasswordCheck import info.nightscout.androidaps.utils.protection.ProtectionCheck.ProtectionType.* import info.nightscout.androidaps.interfaces.ResourceHelper +import info.nightscout.androidaps.plugins.aps.openAPSSMBDynamicISF.OpenAPSSMBDynamicISFPlugin import info.nightscout.shared.SafeParse import info.nightscout.shared.sharedPreferences.SP import javax.inject.Inject @@ -79,6 +80,7 @@ class MyPreferenceFragment : PreferenceFragmentCompat(), OnSharedPreferenceChang @Inject lateinit var nsClientPlugin: NSClientPlugin @Inject lateinit var openAPSAMAPlugin: OpenAPSAMAPlugin @Inject lateinit var openAPSSMBPlugin: OpenAPSSMBPlugin + @Inject lateinit var openAPSSMBDynamicISFPlugin: OpenAPSSMBDynamicISFPlugin @Inject lateinit var safetyPlugin: SafetyPlugin @Inject lateinit var sensitivityAAPSPlugin: SensitivityAAPSPlugin @Inject lateinit var sensitivityOref1Plugin: SensitivityOref1Plugin @@ -171,6 +173,7 @@ class MyPreferenceFragment : PreferenceFragmentCompat(), OnSharedPreferenceChang addPreferencesFromResourceIfEnabled(loopPlugin, rootKey, config.APS) addPreferencesFromResourceIfEnabled(openAPSAMAPlugin, rootKey, config.APS) addPreferencesFromResourceIfEnabled(openAPSSMBPlugin, rootKey, config.APS) + addPreferencesFromResourceIfEnabled(openAPSSMBDynamicISFPlugin, rootKey, config.APS) addPreferencesFromResourceIfEnabled(sensitivityAAPSPlugin, rootKey) addPreferencesFromResourceIfEnabled(sensitivityWeightedAveragePlugin, rootKey) addPreferencesFromResourceIfEnabled(sensitivityOref1Plugin, rootKey) From 2b0670921e2c15e82a67e0c7b3f93fb6874d611f Mon Sep 17 00:00:00 2001 From: Milos Kozak Date: Tue, 12 Jul 2022 19:51:06 +0200 Subject: [PATCH 37/39] ActionStopProcessing --- .../automation/di/AutomationModule.kt | 1 + .../general/automation/AutomationEvent.kt | 6 +++ .../general/automation/AutomationPlugin.kt | 7 ++- .../actions/ActionStopProcessing.kt | 33 ++++++++++++++ automation/src/main/res/values/strings.xml | 1 + .../general/automation/AutomationEventTest.kt | 13 +++++- .../actions/ActionStopProcessingTest.kt | 44 +++++++++++++++++++ .../automation/actions/ActionsTestBase.kt | 3 ++ 8 files changed, 106 insertions(+), 2 deletions(-) create mode 100644 automation/src/main/java/info/nightscout/androidaps/plugins/general/automation/actions/ActionStopProcessing.kt create mode 100644 automation/src/test/java/info/nightscout/androidaps/plugins/general/automation/actions/ActionStopProcessingTest.kt diff --git a/automation/src/main/java/info/nightscout/androidaps/automation/di/AutomationModule.kt b/automation/src/main/java/info/nightscout/androidaps/automation/di/AutomationModule.kt index 0d40a894fa..b889b40692 100644 --- a/automation/src/main/java/info/nightscout/androidaps/automation/di/AutomationModule.kt +++ b/automation/src/main/java/info/nightscout/androidaps/automation/di/AutomationModule.kt @@ -33,6 +33,7 @@ abstract class AutomationModule { @ContributesAndroidInjector abstract fun triggerWifiSsidInjector(): TriggerWifiSsid @ContributesAndroidInjector abstract fun actionInjector(): Action + @ContributesAndroidInjector abstract fun actionStopProcessingInjector(): ActionStopProcessing @ContributesAndroidInjector abstract fun actionLoopDisableInjector(): ActionLoopDisable @ContributesAndroidInjector abstract fun actionLoopEnableInjector(): ActionLoopEnable @ContributesAndroidInjector abstract fun actionLoopResumeInjector(): ActionLoopResume diff --git a/automation/src/main/java/info/nightscout/androidaps/plugins/general/automation/AutomationEvent.kt b/automation/src/main/java/info/nightscout/androidaps/plugins/general/automation/AutomationEvent.kt index 13842ec74a..6657204f97 100644 --- a/automation/src/main/java/info/nightscout/androidaps/plugins/general/automation/AutomationEvent.kt +++ b/automation/src/main/java/info/nightscout/androidaps/plugins/general/automation/AutomationEvent.kt @@ -4,6 +4,7 @@ import dagger.android.HasAndroidInjector import info.nightscout.shared.logging.AAPSLogger import info.nightscout.androidaps.plugins.general.automation.actions.Action import info.nightscout.androidaps.plugins.general.automation.actions.ActionDummy +import info.nightscout.androidaps.plugins.general.automation.actions.ActionStopProcessing import info.nightscout.androidaps.plugins.general.automation.triggers.TriggerConnector import info.nightscout.androidaps.plugins.general.automation.triggers.TriggerDummy import info.nightscout.androidaps.utils.DateUtil @@ -52,6 +53,11 @@ class AutomationEvent(private val injector: HasAndroidInjector) { return result } + fun hasStopProcessing(): Boolean { + for (action in actions) if (action is ActionStopProcessing) return true + return false + } + fun toJSON(): String { val array = JSONArray() for (a in actions) array.put(a.toJSON()) diff --git a/automation/src/main/java/info/nightscout/androidaps/plugins/general/automation/AutomationPlugin.kt b/automation/src/main/java/info/nightscout/androidaps/plugins/general/automation/AutomationPlugin.kt index fd941dd6ca..c7710432f7 100644 --- a/automation/src/main/java/info/nightscout/androidaps/plugins/general/automation/AutomationPlugin.kt +++ b/automation/src/main/java/info/nightscout/androidaps/plugins/general/automation/AutomationPlugin.kt @@ -212,8 +212,12 @@ class AutomationPlugin @Inject constructor( while (iterator.hasNext()) { val event = iterator.next() if (event.isEnabled && !event.userAction && event.shouldRun()) - if (event.systemAction || commonEventsEnabled) processEvent(event) + if (event.systemAction || commonEventsEnabled) { + processEvent(event) + if (event.hasStopProcessing()) break + } } + // we cannot detect connected BT devices // so let's collect all connection/disconnections between 2 runs of processActions() // TriggerBTDevice can pick up and process these events @@ -329,6 +333,7 @@ class AutomationPlugin @Inject constructor( //ActionLoopEnable(injector), //ActionLoopResume(injector), //ActionLoopSuspend(injector), + ActionStopProcessing(injector), ActionStartTempTarget(injector), ActionStopTempTarget(injector), ActionNotification(injector), diff --git a/automation/src/main/java/info/nightscout/androidaps/plugins/general/automation/actions/ActionStopProcessing.kt b/automation/src/main/java/info/nightscout/androidaps/plugins/general/automation/actions/ActionStopProcessing.kt new file mode 100644 index 0000000000..eb437bb91c --- /dev/null +++ b/automation/src/main/java/info/nightscout/androidaps/plugins/general/automation/actions/ActionStopProcessing.kt @@ -0,0 +1,33 @@ +package info.nightscout.androidaps.plugins.general.automation.actions + +import androidx.annotation.DrawableRes +import com.google.gson.JsonObject +import dagger.android.HasAndroidInjector +import info.nightscout.androidaps.automation.R +import info.nightscout.androidaps.data.PumpEnactResult +import info.nightscout.androidaps.queue.Callback +import org.json.JSONObject + +class ActionStopProcessing(injector: HasAndroidInjector) : Action(injector) { + + override fun friendlyName(): Int = R.string.stop_processing + override fun shortDescription(): String = rh.gs(R.string.stop_processing) + @DrawableRes override fun icon(): Int = R.drawable.ic_stop_24dp + + override fun isValid(): Boolean = true + + override fun doAction(callback: Callback) { + callback.result(PumpEnactResult(injector).success(true).comment(R.string.ok)).run() + } + + override fun toJSON(): String { + return JSONObject() + .put("type", this.javaClass.name) + .put("data", JsonObject()) + .toString() + } + + override fun fromJSON(data: String): Action = this + + override fun hasDialog(): Boolean = false +} \ No newline at end of file diff --git a/automation/src/main/res/values/strings.xml b/automation/src/main/res/values/strings.xml index 30ca8cf431..3e7d2daf50 100644 --- a/automation/src/main/res/values/strings.xml +++ b/automation/src/main/res/values/strings.xml @@ -126,5 +126,6 @@ Run automations Add rule Remove/sort + Stop processing \ No newline at end of file diff --git a/automation/src/test/java/info/nightscout/androidaps/plugins/general/automation/AutomationEventTest.kt b/automation/src/test/java/info/nightscout/androidaps/plugins/general/automation/AutomationEventTest.kt index 874077109b..68066c6e7b 100644 --- a/automation/src/test/java/info/nightscout/androidaps/plugins/general/automation/AutomationEventTest.kt +++ b/automation/src/test/java/info/nightscout/androidaps/plugins/general/automation/AutomationEventTest.kt @@ -5,13 +5,14 @@ import dagger.android.HasAndroidInjector import info.nightscout.androidaps.TestBase import info.nightscout.androidaps.interfaces.ConfigBuilder import info.nightscout.androidaps.interfaces.Loop +import info.nightscout.androidaps.interfaces.ResourceHelper import info.nightscout.androidaps.plugins.bus.RxBus import info.nightscout.androidaps.plugins.general.automation.actions.Action import info.nightscout.androidaps.plugins.general.automation.actions.ActionLoopEnable +import info.nightscout.androidaps.plugins.general.automation.actions.ActionStopProcessing import info.nightscout.androidaps.plugins.general.automation.triggers.TriggerConnector import info.nightscout.androidaps.plugins.general.automation.triggers.TriggerConnectorTest import info.nightscout.androidaps.plugins.general.automation.triggers.TriggerDummy -import info.nightscout.androidaps.interfaces.ResourceHelper import org.json.JSONObject import org.junit.Assert import org.junit.Test @@ -70,4 +71,14 @@ class AutomationEventTest : TestBase() { Assert.assertFalse(event.actions === clone.actions) // not the same object reference Assert.assertEquals(clone.toJSON(), clone.toJSON()) } + + @Test + fun hasStopProcessing() { + val event = AutomationEvent(injector) + event.title = "Test" + event.trigger = TriggerDummy(injector).instantiate(JSONObject(TriggerConnectorTest.oneItem)) as TriggerConnector + Assert.assertFalse(event.hasStopProcessing()) + event.addAction(ActionStopProcessing(injector)) + Assert.assertTrue(event.hasStopProcessing()) + } } diff --git a/automation/src/test/java/info/nightscout/androidaps/plugins/general/automation/actions/ActionStopProcessingTest.kt b/automation/src/test/java/info/nightscout/androidaps/plugins/general/automation/actions/ActionStopProcessingTest.kt new file mode 100644 index 0000000000..c16de7bdac --- /dev/null +++ b/automation/src/test/java/info/nightscout/androidaps/plugins/general/automation/actions/ActionStopProcessingTest.kt @@ -0,0 +1,44 @@ +package info.nightscout.androidaps.plugins.general.automation.actions + +import info.nightscout.androidaps.automation.R +import info.nightscout.androidaps.queue.Callback +import org.junit.Assert +import org.junit.Before +import org.junit.Test +import org.mockito.Mockito.`when` + +class ActionStopProcessingTest : ActionsTestBase() { + + lateinit var sut: ActionStopProcessing + + @Before + fun setup() { + + `when`(rh.gs(R.string.stop_processing)).thenReturn("Stop processing") + sut = ActionStopProcessing(injector) + } + + @Test + fun friendlyNameTest() { + Assert.assertEquals(R.string.stop_processing, sut.friendlyName()) + } + + @Test + fun shortDescriptionTest() { + Assert.assertEquals("Stop processing", sut.shortDescription()) + } + + @Test + fun iconTest() { + Assert.assertEquals(R.drawable.ic_stop_24dp, sut.icon()) + } + + @Test + fun doActionTest() { + sut.doAction(object : Callback() { + override fun run() { + Assert.assertTrue(result.success) + } + }) + } +} \ No newline at end of file diff --git a/automation/src/test/java/info/nightscout/androidaps/plugins/general/automation/actions/ActionsTestBase.kt b/automation/src/test/java/info/nightscout/androidaps/plugins/general/automation/actions/ActionsTestBase.kt index 783fcbb2e6..0461810d0d 100644 --- a/automation/src/test/java/info/nightscout/androidaps/plugins/general/automation/actions/ActionsTestBase.kt +++ b/automation/src/test/java/info/nightscout/androidaps/plugins/general/automation/actions/ActionsTestBase.kt @@ -144,6 +144,9 @@ ActionsTestBase : TestBaseWithProfile() { it.profileFunction = profileFunction it.uel = uel } + if (it is ActionStopProcessing) { + it.rh = rh + } if (it is PumpEnactResult) { it.rh = rh } From 875c4144fddaf6f2bc976424ce31a140856b3f4b Mon Sep 17 00:00:00 2001 From: Andries Smit Date: Wed, 13 Jul 2022 08:54:18 +0200 Subject: [PATCH 38/39] style: profile helper use dropdowns --- .../activities/ProfileHelperActivity.kt | 82 ++++++++----------- .../res/layout/activity_profilehelper.xml | 40 ++++----- app/src/main/res/menu/menu_profilehelper.xml | 20 ----- 3 files changed, 51 insertions(+), 91 deletions(-) delete mode 100644 app/src/main/res/menu/menu_profilehelper.xml diff --git a/app/src/main/java/info/nightscout/androidaps/activities/ProfileHelperActivity.kt b/app/src/main/java/info/nightscout/androidaps/activities/ProfileHelperActivity.kt index 81563f0944..d0bf2c968f 100644 --- a/app/src/main/java/info/nightscout/androidaps/activities/ProfileHelperActivity.kt +++ b/app/src/main/java/info/nightscout/androidaps/activities/ProfileHelperActivity.kt @@ -5,9 +5,9 @@ import android.content.res.ColorStateList import android.os.Bundle import android.text.Editable import android.text.TextWatcher -import android.view.Menu -import android.widget.PopupMenu +import android.widget.ArrayAdapter import android.widget.TextView +import com.google.common.collect.Lists import info.nightscout.androidaps.R import info.nightscout.androidaps.data.ProfileSealed import info.nightscout.androidaps.data.PureProfile @@ -18,7 +18,6 @@ import info.nightscout.androidaps.dialogs.ProfileViewerDialog import info.nightscout.androidaps.extensions.toVisibility import info.nightscout.androidaps.interfaces.ActivePlugin import info.nightscout.androidaps.interfaces.ProfileFunction -import info.nightscout.androidaps.plugins.bus.RxBus import info.nightscout.androidaps.plugins.profile.local.LocalProfilePlugin import info.nightscout.androidaps.plugins.profile.local.events.EventLocalProfileChanged import info.nightscout.androidaps.utils.DateUtil @@ -79,54 +78,40 @@ class ProfileHelperActivity : NoSplashAppCompatActivity() { switchTab(1, typeSelected[1]) } - binding.profileType.setOnClickListener { - PopupMenu(this, binding.profileType).apply { - menuInflater.inflate(R.menu.menu_profilehelper, menu) - setOnMenuItemClickListener { item -> - binding.profileType.setText(item.title) - when (item.itemId) { - R.id.menu_default -> switchTab(tabSelected, ProfileType.MOTOL_DEFAULT) - R.id.menu_default_dpv -> switchTab(tabSelected, ProfileType.DPV_DEFAULT) - R.id.menu_current -> switchTab(tabSelected, ProfileType.CURRENT) - R.id.menu_available -> switchTab(tabSelected, ProfileType.AVAILABLE_PROFILE) - R.id.menu_profileswitch -> switchTab(tabSelected, ProfileType.PROFILE_SWITCH) - } - true - } - show() + val profileTypeList = Lists.newArrayList( + rh.gs(R.string.motoldefaultprofile), + rh.gs(R.string.dpvdefaultprofile), + rh.gs(R.string.currentprofile), + rh.gs(R.string.availableprofile), + rh.gs(R.string.careportal_profileswitch) + ) + binding.profileType.setAdapter(ArrayAdapter(this, R.layout.spinner_centered, profileTypeList)) + + binding.profileType.setOnItemClickListener { _, _, _, _ -> + when (binding.profileType.text.toString()) { + rh.gs(R.string.motoldefaultprofile) -> switchTab(tabSelected, ProfileType.MOTOL_DEFAULT) + rh.gs(R.string.dpvdefaultprofile) -> switchTab(tabSelected, ProfileType.DPV_DEFAULT) + rh.gs(R.string.currentprofile) -> switchTab(tabSelected, ProfileType.CURRENT) + rh.gs(R.string.availableprofile) -> switchTab(tabSelected, ProfileType.AVAILABLE_PROFILE) + rh.gs(R.string.careportal_profileswitch) -> switchTab(tabSelected, ProfileType.PROFILE_SWITCH) } } // Active profile profileList = activePlugin.activeProfileSource.profile?.getProfileList() ?: ArrayList() - binding.availableProfileList.setOnClickListener { - PopupMenu(this, binding.availableProfileList).apply { - var order = 0 - for (name in profileList) menu.add(Menu.NONE, order, order++, name) - setOnMenuItemClickListener { item -> - binding.availableProfileList.setText(item.title) - profileUsed[tabSelected] = item.itemId - true - } - show() - } + binding.availableProfileList.setAdapter(ArrayAdapter(this, R.layout.spinner_centered, profileList)) + binding.availableProfileList.setOnItemClickListener { _, _, index, _ -> + profileUsed[tabSelected] = index } // Profile switch profileSwitch = repository.getEffectiveProfileSwitchDataFromTime(dateUtil.now() - T.months(2).msecs(), true).blockingGet() - - binding.profileswitchList.setOnClickListener { - PopupMenu(this, binding.profileswitchList).apply { - var order = 0 - for (name in profileSwitch) menu.add(Menu.NONE, order, order++, name.originalCustomizedName) - setOnMenuItemClickListener { item -> - binding.profileswitchList.setText(item.title) - profileSwitchUsed[tabSelected] = item.itemId - true - } - show() - } + + val profileswitchListNames = profileSwitch.map { it.originalCustomizedName } + binding.profileswitchList.setAdapter(ArrayAdapter(this, R.layout.spinner_centered, profileswitchListNames)) + binding.profileswitchList.setOnItemClickListener { _, _, index, _ -> + profileSwitchUsed[tabSelected] = index } // Default profile @@ -285,7 +270,7 @@ class ProfileHelperActivity : NoSplashAppCompatActivity() { tabSelected = tab typeSelected[tabSelected] = newContent - binding.profileTypeTitle.defaultHintTextColor = ColorStateList.valueOf(rh.gac( this, if (tab == 0) R.attr.helperProfileColor else R.attr.examinedProfileColor)) + binding.profileTypeTitle.defaultHintTextColor = ColorStateList.valueOf(rh.gac(this, if (tab == 0) R.attr.helperProfileColor else R.attr.examinedProfileColor)) // show new content binding.profileType.setText( @@ -295,7 +280,8 @@ class ProfileHelperActivity : NoSplashAppCompatActivity() { ProfileType.CURRENT -> rh.gs(R.string.currentprofile) ProfileType.AVAILABLE_PROFILE -> rh.gs(R.string.availableprofile) ProfileType.PROFILE_SWITCH -> rh.gs(R.string.careportal_profileswitch) - } + }, + false ) binding.defaultProfile.visibility = (newContent == ProfileType.MOTOL_DEFAULT || newContent == ProfileType.DPV_DEFAULT).toVisibility() binding.currentProfile.visibility = (newContent == ProfileType.CURRENT).toVisibility() @@ -309,10 +295,12 @@ class ProfileHelperActivity : NoSplashAppCompatActivity() { binding.basalPctFromTdd.value = pctUsed[tabSelected] binding.basalPctFromTddRow.visibility = (newContent == ProfileType.DPV_DEFAULT).toVisibility() - if (profileList.isNotEmpty()) - binding.availableProfileList.setText(profileList[profileUsed[tabSelected]].toString()) - if (profileSwitch.isNotEmpty()) - binding.profileswitchList.setText(profileSwitch[profileSwitchUsed[tabSelected]].originalCustomizedName) + if (profileList.isNotEmpty()) { + binding.availableProfileList.setText(profileList[profileUsed[tabSelected]].toString(), false) + } + if (profileSwitch.isNotEmpty()) { + binding.profileswitchList.setText(profileSwitch[profileSwitchUsed[tabSelected]].originalCustomizedName, false) + } } private fun setBackgroundColorOnSelected(tab: Int) { diff --git a/app/src/main/res/layout/activity_profilehelper.xml b/app/src/main/res/layout/activity_profilehelper.xml index 5895f77094..fc9df1a3eb 100644 --- a/app/src/main/res/layout/activity_profilehelper.xml +++ b/app/src/main/res/layout/activity_profilehelper.xml @@ -43,21 +43,18 @@ + android:hint="@string/profiletype" + android:paddingHorizontal="5dp"> - + android:inputType="none" /> @@ -206,21 +203,18 @@ android:orientation="vertical"> + android:hint="@string/selected_profile" + android:paddingHorizontal="5dp"> - + android:inputType="none" /> @@ -233,21 +227,19 @@ android:orientation="vertical"> + android:hint="@string/careportal_profileswitch" + android:paddingHorizontal="5dp"> - + + android:inputType="none" /> diff --git a/app/src/main/res/menu/menu_profilehelper.xml b/app/src/main/res/menu/menu_profilehelper.xml deleted file mode 100644 index ca6e6cb9fc..0000000000 --- a/app/src/main/res/menu/menu_profilehelper.xml +++ /dev/null @@ -1,20 +0,0 @@ - - - - - - - - - - \ No newline at end of file From 7ec4b855e508b031be2d3d1141c4fb9217a9eecd Mon Sep 17 00:00:00 2001 From: Andries Smit Date: Wed, 13 Jul 2022 08:54:34 +0200 Subject: [PATCH 39/39] style: profile helper use material tabs --- .../activities/ProfileHelperActivity.kt | 30 ++++++++---------- .../res/layout/activity_profilehelper.xml | 31 ++++++------------- 2 files changed, 23 insertions(+), 38 deletions(-) diff --git a/app/src/main/java/info/nightscout/androidaps/activities/ProfileHelperActivity.kt b/app/src/main/java/info/nightscout/androidaps/activities/ProfileHelperActivity.kt index d0bf2c968f..dcba11d059 100644 --- a/app/src/main/java/info/nightscout/androidaps/activities/ProfileHelperActivity.kt +++ b/app/src/main/java/info/nightscout/androidaps/activities/ProfileHelperActivity.kt @@ -1,12 +1,12 @@ package info.nightscout.androidaps.activities import android.annotation.SuppressLint -import android.content.res.ColorStateList import android.os.Bundle import android.text.Editable import android.text.TextWatcher import android.widget.ArrayAdapter import android.widget.TextView +import com.google.android.material.tabs.TabLayout import com.google.common.collect.Lists import info.nightscout.androidaps.R import info.nightscout.androidaps.data.ProfileSealed @@ -71,12 +71,14 @@ class ProfileHelperActivity : NoSplashAppCompatActivity() { binding = ActivityProfilehelperBinding.inflate(layoutInflater) setContentView(binding.root) - binding.menu1.setOnClickListener { - switchTab(0, typeSelected[0]) - } - binding.menu2.setOnClickListener { - switchTab(1, typeSelected[1]) - } + binding.tabLayout.addOnTabSelectedListener(object : TabLayout.OnTabSelectedListener { + override fun onTabSelected(tab: TabLayout.Tab) { + switchTab(tab.position, typeSelected[tab.position]) + } + + override fun onTabUnselected(tab: TabLayout.Tab) {} + override fun onTabReselected(tab: TabLayout.Tab) {} + }) val profileTypeList = Lists.newArrayList( rh.gs(R.string.motoldefaultprofile), @@ -107,7 +109,7 @@ class ProfileHelperActivity : NoSplashAppCompatActivity() { // Profile switch profileSwitch = repository.getEffectiveProfileSwitchDataFromTime(dateUtil.now() - T.months(2).msecs(), true).blockingGet() - + val profileswitchListNames = profileSwitch.map { it.originalCustomizedName } binding.profileswitchList.setAdapter(ArrayAdapter(this, R.layout.spinner_centered, profileswitchListNames)) binding.profileswitchList.setOnItemClickListener { _, _, index, _ -> @@ -235,7 +237,7 @@ class ProfileHelperActivity : NoSplashAppCompatActivity() { } private fun getProfile(age: Double, tdd: Double, weight: Double, basalPct: Double, tab: Int): PureProfile? = - try { // profile must not exist + try { // Profile must not exist when (typeSelected[tab]) { ProfileType.MOTOL_DEFAULT -> defaultProfile.profile(age, tdd, weight, profileFunction.getUnits()) ProfileType.DPV_DEFAULT -> defaultProfileDPV.profile(age, tdd, basalPct, profileFunction.getUnits()) @@ -264,15 +266,13 @@ class ProfileHelperActivity : NoSplashAppCompatActivity() { } private fun switchTab(tab: Int, newContent: ProfileType, storeOld: Boolean = true) { - setBackgroundColorOnSelected(tab) // Store values for selected tab. listBox values are stored on selection change if (storeOld) storeValues() tabSelected = tab typeSelected[tabSelected] = newContent - binding.profileTypeTitle.defaultHintTextColor = ColorStateList.valueOf(rh.gac(this, if (tab == 0) R.attr.helperProfileColor else R.attr.examinedProfileColor)) - // show new content + // Show new content binding.profileType.setText( when (typeSelected[tabSelected]) { ProfileType.MOTOL_DEFAULT -> rh.gs(R.string.motoldefaultprofile) @@ -288,7 +288,7 @@ class ProfileHelperActivity : NoSplashAppCompatActivity() { binding.availableProfile.visibility = (newContent == ProfileType.AVAILABLE_PROFILE).toVisibility() binding.profileSwitch.visibility = (newContent == ProfileType.PROFILE_SWITCH).toVisibility() - // restore selected values + // Restore selected values binding.age.value = ageUsed[tabSelected] binding.weight.value = weightUsed[tabSelected] binding.tdd.value = tddUsed[tabSelected] @@ -303,8 +303,4 @@ class ProfileHelperActivity : NoSplashAppCompatActivity() { } } - private fun setBackgroundColorOnSelected(tab: Int) { - binding.menu1.setBackgroundColor(rh.gac(this, if (tab == 1) R.attr.defaultBackground else R.attr.helperProfileColor)) - binding.menu2.setBackgroundColor(rh.gac(this, if (tab == 0) R.attr.defaultBackground else R.attr.examinedProfileColor)) - } } diff --git a/app/src/main/res/layout/activity_profilehelper.xml b/app/src/main/res/layout/activity_profilehelper.xml index fc9df1a3eb..c5749de48f 100644 --- a/app/src/main/res/layout/activity_profilehelper.xml +++ b/app/src/main/res/layout/activity_profilehelper.xml @@ -12,34 +12,23 @@ android:layout_height="wrap_content" android:orientation="vertical"> - + android:layout_marginBottom="10dp"> - - - +