From 7f29093bd66ac1267fe183d7eaf4348c892494da Mon Sep 17 00:00:00 2001 From: osodebailar Date: Wed, 6 Apr 2022 16:31:59 +0200 Subject: [PATCH 1/7] card items and objectives now readable in light mode --- app/src/main/res/layout/objectives_exam_fragment.xml | 1 + app/src/main/res/layout/objectives_item.xml | 3 ++- core/src/main/res/values-night/styles.xml | 1 + core/src/main/res/values/attrs.xml | 1 + core/src/main/res/values/colors.xml | 5 +++-- core/src/main/res/values/styles.xml | 3 ++- 6 files changed, 10 insertions(+), 4 deletions(-) diff --git a/app/src/main/res/layout/objectives_exam_fragment.xml b/app/src/main/res/layout/objectives_exam_fragment.xml index b5fd8b70b9..77ef669e3f 100644 --- a/app/src/main/res/layout/objectives_exam_fragment.xml +++ b/app/src/main/res/layout/objectives_exam_fragment.xml @@ -28,6 +28,7 @@ android:layout_height="wrap_content" android:layout_marginTop="16dp" android:layout_marginBottom="10dp" + android:background="?attr/objectivesBackgroundColor" android:orientation="vertical" app:layout_constraintTop_toBottomOf="@+id/exam_options" tools:layout_editor_absoluteX="3dp" /> diff --git a/app/src/main/res/layout/objectives_item.xml b/app/src/main/res/layout/objectives_item.xml index 7ea4fea232..b0906b8f02 100644 --- a/app/src/main/res/layout/objectives_item.xml +++ b/app/src/main/res/layout/objectives_item.xml @@ -8,8 +8,9 @@ android:layout_marginLeft="16dp" android:layout_marginTop="16dp" android:layout_marginRight="16dp" - app:cardBackgroundColor="?attr/cardItemBackgroundColor" + app:cardBackgroundColor="?attr/objectivescardItemBackgroundColor" app:cardCornerRadius="2dp" + app:cardElevation="8dp" app:cardUseCompatPadding="true" app:contentPadding="16dp"> diff --git a/core/src/main/res/values-night/styles.xml b/core/src/main/res/values-night/styles.xml index 6af4a3018b..bd4e0d8a15 100644 --- a/core/src/main/res/values-night/styles.xml +++ b/core/src/main/res/values-night/styles.xml @@ -71,6 +71,7 @@ @color/pumpStatusBackground + ?attr/cardItemBackgroundColor @color/objectivesBackground @color/colorObjectivesDisabledText diff --git a/core/src/main/res/values/attrs.xml b/core/src/main/res/values/attrs.xml index ce4561af52..1078e1607c 100644 --- a/core/src/main/res/values/attrs.xml +++ b/core/src/main/res/values/attrs.xml @@ -44,6 +44,7 @@ + diff --git a/core/src/main/res/values/colors.xml b/core/src/main/res/values/colors.xml index f6fa73a66e..ddf424d750 100644 --- a/core/src/main/res/values/colors.xml +++ b/core/src/main/res/values/colors.xml @@ -226,7 +226,7 @@ #323232 #424242 - #3C3C3C + #8C8C8C #666666 #777777 #8c8c8c @@ -309,6 +309,7 @@ #1C1B1F #FAF9F8 #1C1B1F - #E7E0EC + #E2E0DF + diff --git a/core/src/main/res/values/styles.xml b/core/src/main/res/values/styles.xml index ab6967991c..43a98803bd 100644 --- a/core/src/main/res/values/styles.xml +++ b/core/src/main/res/values/styles.xml @@ -11,7 +11,7 @@ @color/aaps_theme_light_onError @color/aaps_theme_light_background @color/aaps_theme_light_onBackground - @color/aaps_theme_light_surface + @color/aaps_theme_light_surfaceVariant @color/aaps_theme_light_onSurface @color/colorPrimaryDark @color/aaps_theme_light_secondary @@ -79,6 +79,7 @@ @color/pumpStatusBackground + @color/midgray @color/objectivesBackground @color/colorObjectivesDisabledText From bbc16f80b4e462cb589b1ca73731ed3bec01b137 Mon Sep 17 00:00:00 2001 From: Andries Smit Date: Wed, 6 Apr 2022 17:54:33 +0200 Subject: [PATCH 2/7] chore: convert buttons to tabs --- .../profile/local/LocalProfileFragment.kt | 53 +++++---------- .../main/res/layout/localprofile_fragment.xml | 66 ++++++------------- 2 files changed, 37 insertions(+), 82 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 6621b784dc..21cef09f87 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 @@ -9,6 +9,7 @@ import android.view.View import android.view.ViewGroup import android.widget.AdapterView import android.widget.ArrayAdapter +import com.google.android.material.tabs.TabLayout import dagger.android.support.DaggerFragment import info.nightscout.androidaps.Constants import info.nightscout.androidaps.R @@ -105,30 +106,16 @@ class LocalProfileFragment : DaggerFragment() { val parentClass = this.activity?.let { it::class.java } inMenu = parentClass == SingleFragmentActivity::class.java updateProtectedUi() - // activate DIA tab - processVisibilityOnClick(binding.diaTab) - binding.diaPlaceholder.visibility = View.VISIBLE - // setup listeners - binding.diaTab.setOnClickListener { - processVisibilityOnClick(it) - binding.diaPlaceholder.visibility = View.VISIBLE - } - binding.icTab.setOnClickListener { - processVisibilityOnClick(it) - binding.ic.visibility = View.VISIBLE - } - binding.isfTab.setOnClickListener { - processVisibilityOnClick(it) - binding.isf.visibility = View.VISIBLE - } - binding.basalTab.setOnClickListener { - processVisibilityOnClick(it) - binding.basal.visibility = View.VISIBLE - } - binding.targetTab.setOnClickListener { - processVisibilityOnClick(it) - binding.target.visibility = View.VISIBLE - } + processVisibility(0) + binding.tabLayout.addOnTabSelectedListener(object : TabLayout.OnTabSelectedListener { + override fun onTabSelected(tab: TabLayout.Tab) { + processVisibility(tab.position) + } + + override fun onTabUnselected(tab: TabLayout.Tab) {} + override fun onTabReselected(tab: TabLayout.Tab) {} + }) + binding.dia.editText?.id?.let { binding.diaLabel.labelFor = it } binding.unlock.setOnClickListener { queryProtection() } @@ -400,18 +387,12 @@ class LocalProfileFragment : DaggerFragment() { } } - private fun processVisibilityOnClick(selected: View) { - binding.diaTab.setBackgroundColor(rh.gac(context, R.attr.defaultbackground)) - binding.icTab.setBackgroundColor(rh.gac(context, R.attr.defaultbackground)) - binding.isfTab.setBackgroundColor(rh.gac(context, R.attr.defaultbackground)) - binding.basalTab.setBackgroundColor(rh.gac(context, R.attr.defaultbackground)) - binding.targetTab.setBackgroundColor(rh.gac(context, R.attr.defaultbackground)) - selected.setBackgroundColor(rh.gac(context, R.attr.tabBgColorSelected)) - binding.diaPlaceholder.visibility = View.GONE - binding.ic.visibility = View.GONE - binding.isf.visibility = View.GONE - binding.basal.visibility = View.GONE - binding.target.visibility = View.GONE + 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() } private fun updateProtectedUi() { diff --git a/app/src/main/res/layout/localprofile_fragment.xml b/app/src/main/res/layout/localprofile_fragment.xml index b1ae2ca816..ec8234f334 100644 --- a/app/src/main/res/layout/localprofile_fragment.xml +++ b/app/src/main/res/layout/localprofile_fragment.xml @@ -120,63 +120,37 @@ - + android:layout_height="wrap_content"> - + android:text="@string/dia_short" /> - + android:text="@string/ic_short" /> - + android:text="@string/isf_short" /> - + android:text="@string/basal_short" /> - - + android:text="@string/target_short" /> + + Date: Wed, 6 Apr 2022 20:06:59 +0200 Subject: [PATCH 3/7] chore: reuse note layout --- .../androidaps/dialogs/WizardDialog.kt | 6 ++-- app/src/main/res/layout/dialog_wizard.xml | 29 ++----------------- 2 files changed, 5 insertions(+), 30 deletions(-) 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 e5ff65ffda..13fc6cc0b8 100644 --- a/app/src/main/java/info/nightscout/androidaps/dialogs/WizardDialog.kt +++ b/app/src/main/java/info/nightscout/androidaps/dialogs/WizardDialog.kt @@ -130,7 +130,7 @@ class WizardDialog : DaggerDialogFragment() { val useSuperBolus = sp.getBoolean(R.string.key_usesuperbolus, false) binding.sbCheckbox.visibility = useSuperBolus.toVisibility() binding.superBolusRow.visibility = useSuperBolus.toVisibility() - binding.notesLayout.visibility = sp.getBoolean(R.string.key_show_notes_entry_dialogs, false).toVisibility() + binding.notesLayout.root.visibility = sp.getBoolean(R.string.key_show_notes_entry_dialogs, false).toVisibility() val maxCarbs = constraintChecker.getMaxCarbsAllowed().value() val maxCorrection = constraintChecker.getMaxBolusAllowed().value() @@ -327,7 +327,7 @@ class WizardDialog : DaggerDialogFragment() { binding.carbsInput.value = carbsPassedIntoWizard } if (notesPassedIntoWizard.isNotBlank()) { - binding.notes.setText(notesPassedIntoWizard) + binding.notesLayout.notes.setText(notesPassedIntoWizard) } val profile = profileFunction.getProfile() val profileStore = activePlugin.activeProfileSource.profile @@ -427,7 +427,7 @@ class WizardDialog : DaggerDialogFragment() { binding.ttCheckbox.isChecked, binding.bgTrendCheckbox.isChecked, binding.alarm.isChecked, - binding.notes.text.toString(), + binding.notesLayout.notes.text.toString(), carbTime, usePercentage = usePercentage, totalPercentage = percentageCorrection diff --git a/app/src/main/res/layout/dialog_wizard.xml b/app/src/main/res/layout/dialog_wizard.xml index 91b2bd2a4d..69f9ae3459 100644 --- a/app/src/main/res/layout/dialog_wizard.xml +++ b/app/src/main/res/layout/dialog_wizard.xml @@ -211,34 +211,9 @@ - - - - - - - + layout="@layout/notes" /> Date: Wed, 6 Apr 2022 20:07:11 +0200 Subject: [PATCH 4/7] chore: remove redundant style --- .../main/res/layout/activity_preferences.xml | 1 - .../res/layout/activity_profilehelper.xml | 10 ++-- app/src/main/res/layout/food_fragment.xml | 3 -- core/src/main/res/layout/notes.xml | 47 +++++++++---------- 4 files changed, 25 insertions(+), 36 deletions(-) diff --git a/app/src/main/res/layout/activity_preferences.xml b/app/src/main/res/layout/activity_preferences.xml index d4a7c61fc7..2ff946628a 100644 --- a/app/src/main/res/layout/activity_preferences.xml +++ b/app/src/main/res/layout/activity_preferences.xml @@ -9,7 +9,6 @@ android:layout_width="match_parent" android:layout_height="wrap_content" android:hint="@string/filter" - android:textColorHint="?attr/colorOnPrimary" app:endIconMode="clear_text"> + android:hint="@string/profiletype"> + android:hint="@string/selected_profile"> + android:hint="@string/careportal_profileswitch"> diff --git a/core/src/main/res/layout/notes.xml b/core/src/main/res/layout/notes.xml index 9ee27909a4..96adb89ff0 100644 --- a/core/src/main/res/layout/notes.xml +++ b/core/src/main/res/layout/notes.xml @@ -1,35 +1,32 @@ - - + android:orientation="horizontal"> - + android:hint="@string/notes_label" + app:endIconMode="clear_text"> - + + + From 14b097fa693334412897d558dfbcbbfc13fa7d44 Mon Sep 17 00:00:00 2001 From: Andries Smit Date: Wed, 6 Apr 2022 21:40:32 +0200 Subject: [PATCH 5/7] fix: notes padding --- core/src/main/res/layout/notes.xml | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/core/src/main/res/layout/notes.xml b/core/src/main/res/layout/notes.xml index 96adb89ff0..be8e098aa1 100644 --- a/core/src/main/res/layout/notes.xml +++ b/core/src/main/res/layout/notes.xml @@ -10,6 +10,8 @@ style="@style/Widget.MaterialComponents.TextInputLayout.OutlinedBox" android:layout_width="match_parent" android:layout_height="wrap_content" + android:layout_marginStart="10dp" + android:layout_marginEnd="10dp" android:hint="@string/notes_label" app:endIconMode="clear_text"> @@ -17,13 +19,7 @@ android:id="@+id/notes" android:layout_width="match_parent" android:layout_height="wrap_content" - android:layout_gravity="center_vertical" - android:layout_marginStart="10dp" - android:layout_marginEnd="10dp" - android:layout_weight="1" - android:width="180dp" android:autofillHints="@string/notes_label" - android:gravity="start" android:inputType="text|textCapSentences" android:textStyle="bold" /> From e2ad248195603a76bc0fffa4d48ce200a053724e Mon Sep 17 00:00:00 2001 From: Andries Smit Date: Wed, 6 Apr 2022 21:40:52 +0200 Subject: [PATCH 6/7] Set primairy color also matching for day mode --- core/src/main/res/values-night/colors.xml | 2 +- core/src/main/res/values/colors.xml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/core/src/main/res/values-night/colors.xml b/core/src/main/res/values-night/colors.xml index ddd9ab6985..dabe05793a 100644 --- a/core/src/main/res/values-night/colors.xml +++ b/core/src/main/res/values-night/colors.xml @@ -2,7 +2,7 @@ - #3378c5 + #96CAF2 #000000 #40bbaa #ffffff diff --git a/core/src/main/res/values/colors.xml b/core/src/main/res/values/colors.xml index ddf424d750..f752fc8fe5 100644 --- a/core/src/main/res/values/colors.xml +++ b/core/src/main/res/values/colors.xml @@ -2,7 +2,7 @@ - #FBF9FF + #3378C5 #676767 #40bbaa #ffffff From 2a54452e95c02d5d6c18861f2eb4d7a80634354d Mon Sep 17 00:00:00 2001 From: Milos Kozak Date: Wed, 6 Apr 2022 23:12:53 +0200 Subject: [PATCH 7/7] Nsclient: improve ProfileSwitch sync --- .../androidaps/extensions/ProfileSwitchExtension.kt | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/core/src/main/java/info/nightscout/androidaps/extensions/ProfileSwitchExtension.kt b/core/src/main/java/info/nightscout/androidaps/extensions/ProfileSwitchExtension.kt index 08664282ff..c612748869 100644 --- a/core/src/main/java/info/nightscout/androidaps/extensions/ProfileSwitchExtension.kt +++ b/core/src/main/java/info/nightscout/androidaps/extensions/ProfileSwitchExtension.kt @@ -29,15 +29,19 @@ fun List.isPSEvent5minBack(time: Long): Boolean { fun ProfileSwitch.toJson(isAdd: Boolean, dateUtil: DateUtil): JSONObject = JSONObject() + .put("timeshift", timeshift) + .put("percentage", percentage) + .also { // remove customization to store original profileJson in toPureNsJson call + timeshift = 0 + percentage = 100 + } .put("created_at", dateUtil.toISOString(timestamp)) .put("enteredBy", "openaps://" + "AndroidAPS") .put("isValid", isValid) .put("eventType", TherapyEvent.Type.PROFILE_SWITCH.text) .put("duration", T.msecs(duration).mins()) - .put("profile", getCustomizedName()) + .put("profile", profileName) .put("profileJson", ProfileSealed.PS(this).toPureNsJson(dateUtil).toString()) - .put("timeshift", 0) - .put("percentage", 100) // customization already applied to json .also { if (interfaceIDs.pumpId != null) it.put("pumpId", interfaceIDs.pumpId) if (interfaceIDs.pumpType != null) it.put("pumpType", interfaceIDs.pumpType!!.name)