This commit is contained in:
Milos Kozak 2022-04-07 11:15:19 +02:00
commit 55072ea3b5
16 changed files with 80 additions and 155 deletions

View file

@ -130,7 +130,7 @@ class WizardDialog : DaggerDialogFragment() {
val useSuperBolus = sp.getBoolean(R.string.key_usesuperbolus, false) val useSuperBolus = sp.getBoolean(R.string.key_usesuperbolus, false)
binding.sbCheckbox.visibility = useSuperBolus.toVisibility() binding.sbCheckbox.visibility = useSuperBolus.toVisibility()
binding.superBolusRow.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 maxCarbs = constraintChecker.getMaxCarbsAllowed().value()
val maxCorrection = constraintChecker.getMaxBolusAllowed().value() val maxCorrection = constraintChecker.getMaxBolusAllowed().value()
@ -327,7 +327,7 @@ class WizardDialog : DaggerDialogFragment() {
binding.carbsInput.value = carbsPassedIntoWizard binding.carbsInput.value = carbsPassedIntoWizard
} }
if (notesPassedIntoWizard.isNotBlank()) { if (notesPassedIntoWizard.isNotBlank()) {
binding.notes.setText(notesPassedIntoWizard) binding.notesLayout.notes.setText(notesPassedIntoWizard)
} }
val profile = profileFunction.getProfile() val profile = profileFunction.getProfile()
val profileStore = activePlugin.activeProfileSource.profile val profileStore = activePlugin.activeProfileSource.profile
@ -427,7 +427,7 @@ class WizardDialog : DaggerDialogFragment() {
binding.ttCheckbox.isChecked, binding.ttCheckbox.isChecked,
binding.bgTrendCheckbox.isChecked, binding.bgTrendCheckbox.isChecked,
binding.alarm.isChecked, binding.alarm.isChecked,
binding.notes.text.toString(), binding.notesLayout.notes.text.toString(),
carbTime, carbTime,
usePercentage = usePercentage, usePercentage = usePercentage,
totalPercentage = percentageCorrection totalPercentage = percentageCorrection

View file

@ -9,6 +9,7 @@ import android.view.View
import android.view.ViewGroup import android.view.ViewGroup
import android.widget.AdapterView import android.widget.AdapterView
import android.widget.ArrayAdapter import android.widget.ArrayAdapter
import com.google.android.material.tabs.TabLayout
import dagger.android.support.DaggerFragment import dagger.android.support.DaggerFragment
import info.nightscout.androidaps.Constants import info.nightscout.androidaps.Constants
import info.nightscout.androidaps.R import info.nightscout.androidaps.R
@ -105,30 +106,16 @@ class LocalProfileFragment : DaggerFragment() {
val parentClass = this.activity?.let { it::class.java } val parentClass = this.activity?.let { it::class.java }
inMenu = parentClass == SingleFragmentActivity::class.java inMenu = parentClass == SingleFragmentActivity::class.java
updateProtectedUi() updateProtectedUi()
// activate DIA tab processVisibility(0)
processVisibilityOnClick(binding.diaTab) binding.tabLayout.addOnTabSelectedListener(object : TabLayout.OnTabSelectedListener {
binding.diaPlaceholder.visibility = View.VISIBLE override fun onTabSelected(tab: TabLayout.Tab) {
// setup listeners processVisibility(tab.position)
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
} }
override fun onTabUnselected(tab: TabLayout.Tab) {}
override fun onTabReselected(tab: TabLayout.Tab) {}
})
binding.dia.editText?.id?.let { binding.diaLabel.labelFor = it } binding.dia.editText?.id?.let { binding.diaLabel.labelFor = it }
binding.unlock.setOnClickListener { queryProtection() } binding.unlock.setOnClickListener { queryProtection() }
@ -400,18 +387,12 @@ class LocalProfileFragment : DaggerFragment() {
} }
} }
private fun processVisibilityOnClick(selected: View) { private fun processVisibility(position: Int) {
binding.diaTab.setBackgroundColor(rh.gac(context, R.attr.defaultbackground)) binding.diaPlaceholder.visibility = (position == 0).toVisibility()
binding.icTab.setBackgroundColor(rh.gac(context, R.attr.defaultbackground)) binding.ic.visibility = (position == 1).toVisibility()
binding.isfTab.setBackgroundColor(rh.gac(context, R.attr.defaultbackground)) binding.isf.visibility = (position == 2).toVisibility()
binding.basalTab.setBackgroundColor(rh.gac(context, R.attr.defaultbackground)) binding.basal.visibility = (position == 3).toVisibility()
binding.targetTab.setBackgroundColor(rh.gac(context, R.attr.defaultbackground)) binding.target.visibility = (position == 4).toVisibility()
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 updateProtectedUi() { private fun updateProtectedUi() {

View file

@ -9,7 +9,6 @@
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:hint="@string/filter" android:hint="@string/filter"
android:textColorHint="?attr/colorOnPrimary"
app:endIconMode="clear_text"> app:endIconMode="clear_text">
<com.google.android.material.textfield.TextInputEditText <com.google.android.material.textfield.TextInputEditText

View file

@ -49,9 +49,7 @@
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginBottom="10dp" android:layout_marginBottom="10dp"
android:hint="@string/profiletype" android:hint="@string/profiletype">
android:textColorHint="?attr/tabBgColorSelected"
app:boxStrokeColor="?attr/tabBgColorSelected">
<com.google.android.material.textfield.TextInputEditText <com.google.android.material.textfield.TextInputEditText
android:id="@+id/profile_type" android:id="@+id/profile_type"
@ -213,8 +211,7 @@
style="@style/Widget.MaterialComponents.TextInputLayout.OutlinedBox" style="@style/Widget.MaterialComponents.TextInputLayout.OutlinedBox"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:hint="@string/selected_profile" android:hint="@string/selected_profile">
app:boxStrokeColor="?attr/boxStrokeColor">
<com.google.android.material.textfield.TextInputEditText <com.google.android.material.textfield.TextInputEditText
android:id="@+id/available_profile_list" android:id="@+id/available_profile_list"
@ -241,8 +238,7 @@
style="@style/Widget.MaterialComponents.TextInputLayout.OutlinedBox" style="@style/Widget.MaterialComponents.TextInputLayout.OutlinedBox"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:hint="@string/careportal_profileswitch" android:hint="@string/careportal_profileswitch">
app:boxStrokeColor="?attr/boxStrokeColor">
<com.google.android.material.textfield.TextInputEditText <com.google.android.material.textfield.TextInputEditText
android:id="@+id/profileswitch_list" android:id="@+id/profileswitch_list"

View file

@ -211,34 +211,9 @@
</LinearLayout> </LinearLayout>
<LinearLayout <include
android:id="@+id/notes_layout" android:id="@+id/notes_layout"
android:layout_width="match_parent" layout="@layout/notes" />
android:layout_height="wrap_content"
android:orientation="horizontal">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:labelFor="@+id/notes"
android:padding="10dp"
android:text="@string/notes_label"
android:textAppearance="@style/TextAppearance.AppCompat.Small"
android:textStyle="bold" />
<EditText
android:id="@+id/notes"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_weight="1"
android:autofillHints="@string/notes_label"
android:gravity="start"
android:inputType="text|textCapSentences"
android:textAppearance="?android:attr/textAppearanceSmall" />
</LinearLayout>
<LinearLayout <LinearLayout
android:id="@+id/checkbox_row" android:id="@+id/checkbox_row"

View file

@ -21,10 +21,7 @@
style="@style/Widget.MaterialComponents.TextInputLayout.OutlinedBox" style="@style/Widget.MaterialComponents.TextInputLayout.OutlinedBox"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
app:boxStrokeColor="@color/mtrl_textinput_default_box_stroke_color"
android:hint="@string/filter" android:hint="@string/filter"
android:textColorHint="?attr/colorOnPrimary"
app:hintTextColor="?attr/colorOnPrimary"
app:startIconDrawable="@android:drawable/ic_menu_search" app:startIconDrawable="@android:drawable/ic_menu_search"
app:endIconMode="clear_text"> app:endIconMode="clear_text">

View file

@ -120,63 +120,37 @@
</LinearLayout> </LinearLayout>
<LinearLayout <com.google.android.material.tabs.TabLayout
android:id="@+id/tab_layout"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="wrap_content">
android:orientation="horizontal"
android:paddingBottom="10dp"
android:weightSum="5">
<TextView <com.google.android.material.tabs.TabItem
android:id="@+id/dia_tab" android:layout_width="wrap_content"
android:layout_width="0dp"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_weight="1" android:text="@string/dia_short" />
android:text="@string/dia_short"
android:textAlignment="center"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textStyle="bold" />
<TextView <com.google.android.material.tabs.TabItem
android:id="@+id/ic_tab" android:layout_width="wrap_content"
android:layout_width="0dp"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_weight="1" android:text="@string/ic_short" />
android:text="@string/ic_short"
android:textAlignment="center"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textStyle="bold" />
<TextView <com.google.android.material.tabs.TabItem
android:id="@+id/isf_tab" android:layout_width="wrap_content"
android:layout_width="0dp"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_weight="1" android:text="@string/isf_short" />
android:text="@string/isf_short"
android:textAlignment="center"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textStyle="bold" />
<TextView <com.google.android.material.tabs.TabItem
android:id="@+id/basal_tab" android:layout_width="wrap_content"
android:layout_width="0dp"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_weight="1" android:text="@string/basal_short" />
android:text="@string/basal_short"
android:textAlignment="center"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textStyle="bold" />
<TextView <com.google.android.material.tabs.TabItem
android:id="@+id/target_tab" android:layout_width="wrap_content"
android:layout_width="0dp"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_weight="1" android:text="@string/target_short" />
android:text="@string/target_short"
android:textAlignment="center" </com.google.android.material.tabs.TabLayout>
android:textAppearance="?android:attr/textAppearanceMedium"
android:textStyle="bold" />
</LinearLayout>
<LinearLayout <LinearLayout
android:id="@+id/dia_placeholder" android:id="@+id/dia_placeholder"

View file

@ -28,6 +28,7 @@
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginTop="16dp" android:layout_marginTop="16dp"
android:layout_marginBottom="10dp" android:layout_marginBottom="10dp"
android:background="?attr/objectivesBackgroundColor"
android:orientation="vertical" android:orientation="vertical"
app:layout_constraintTop_toBottomOf="@+id/exam_options" app:layout_constraintTop_toBottomOf="@+id/exam_options"
tools:layout_editor_absoluteX="3dp" /> tools:layout_editor_absoluteX="3dp" />

View file

@ -8,8 +8,9 @@
android:layout_marginLeft="16dp" android:layout_marginLeft="16dp"
android:layout_marginTop="16dp" android:layout_marginTop="16dp"
android:layout_marginRight="16dp" android:layout_marginRight="16dp"
app:cardBackgroundColor="?attr/cardItemBackgroundColor" app:cardBackgroundColor="?attr/objectivescardItemBackgroundColor"
app:cardCornerRadius="2dp" app:cardCornerRadius="2dp"
app:cardElevation="8dp"
app:cardUseCompatPadding="true" app:cardUseCompatPadding="true"
app:contentPadding="16dp"> app:contentPadding="16dp">

View file

@ -29,15 +29,19 @@ fun List<ProfileSwitch>.isPSEvent5minBack(time: Long): Boolean {
fun ProfileSwitch.toJson(isAdd: Boolean, dateUtil: DateUtil): JSONObject = fun ProfileSwitch.toJson(isAdd: Boolean, dateUtil: DateUtil): JSONObject =
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("created_at", dateUtil.toISOString(timestamp))
.put("enteredBy", "openaps://" + "AndroidAPS") .put("enteredBy", "openaps://" + "AndroidAPS")
.put("isValid", isValid) .put("isValid", isValid)
.put("eventType", TherapyEvent.Type.PROFILE_SWITCH.text) .put("eventType", TherapyEvent.Type.PROFILE_SWITCH.text)
.put("duration", T.msecs(duration).mins()) .put("duration", T.msecs(duration).mins())
.put("profile", getCustomizedName()) .put("profile", profileName)
.put("profileJson", ProfileSealed.PS(this).toPureNsJson(dateUtil).toString()) .put("profileJson", ProfileSealed.PS(this).toPureNsJson(dateUtil).toString())
.put("timeshift", 0)
.put("percentage", 100) // customization already applied to json
.also { .also {
if (interfaceIDs.pumpId != null) it.put("pumpId", interfaceIDs.pumpId) if (interfaceIDs.pumpId != null) it.put("pumpId", interfaceIDs.pumpId)
if (interfaceIDs.pumpType != null) it.put("pumpType", interfaceIDs.pumpType!!.name) if (interfaceIDs.pumpType != null) it.put("pumpType", interfaceIDs.pumpType!!.name)

View file

@ -1,35 +1,28 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/notes_layout" android:id="@+id/notes_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<com.google.android.material.textfield.TextInputLayout
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:orientation="horizontal">
<com.google.android.material.textfield.TextInputLayout
style="@style/Widget.MaterialComponents.TextInputLayout.OutlinedBox" 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" android:hint="@string/notes_label"
app:boxStrokeColor="@color/mtrl_textinput_default_box_stroke_color"
android:textColorHint="?attr/colorOnPrimary"
app:hintTextColor="?attr/colorOnPrimary"
app:endIconMode="clear_text"> app:endIconMode="clear_text">
<com.google.android.material.textfield.TextInputEditText <com.google.android.material.textfield.TextInputEditText
android:id="@+id/notes" android:id="@+id/notes"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginStart="10dp"
android:layout_marginEnd="10dp"
android:layout_gravity="center_vertical"
android:layout_weight="1"
android:autofillHints="@string/notes_label" android:autofillHints="@string/notes_label"
android:gravity="start" android:inputType="text|textCapSentences"
android:textStyle="bold" android:textStyle="bold" />
android:width="180dp"
android:inputType="text|textCapSentences" />
</com.google.android.material.textfield.TextInputLayout> </com.google.android.material.textfield.TextInputLayout>
</LinearLayout> </LinearLayout>

View file

@ -2,7 +2,7 @@
<resources xmlns:tools="http://schemas.android.com/tools"> <resources xmlns:tools="http://schemas.android.com/tools">
<!-- Default theme color --> <!-- Default theme color -->
<!-- This section describes the main theme colors --> <!-- This section describes the main theme colors -->
<color name="colorPrimary">#3378c5</color> <color name="colorPrimary">#96CAF2</color>
<color name="colorPrimaryDark">#000000</color> <color name="colorPrimaryDark">#000000</color>
<color name="colorAccent">#40bbaa</color> <color name="colorAccent">#40bbaa</color>
<color name="mdtp_white">#ffffff</color> <color name="mdtp_white">#ffffff</color>

View file

@ -71,6 +71,7 @@
<!-- Pump --> <!-- Pump -->
<item name="pumpStatusBackground">@color/pumpStatusBackground</item> <item name="pumpStatusBackground">@color/pumpStatusBackground</item>
<!-- Objectives --> <!-- Objectives -->
<item name="objectivescardItemBackgroundColor">?attr/cardItemBackgroundColor</item>
<item name="objectivesBackgroundColor">@color/objectivesBackground</item> <item name="objectivesBackgroundColor">@color/objectivesBackground</item>
<item name="objectivesDisabledTextColor">@color/colorObjectivesDisabledText</item> <item name="objectivesDisabledTextColor">@color/colorObjectivesDisabledText</item>
<!---Import List --> <!---Import List -->

View file

@ -44,6 +44,7 @@
<!-- Pump --> <!-- Pump -->
<attr name="pumpStatusBackground" format="reference|color" /> <attr name="pumpStatusBackground" format="reference|color" />
<!-- Objectives --> <!-- Objectives -->
<attr name="objectivescardItemBackgroundColor" format="reference|color" />
<attr name="objectivesBackgroundColor" format="reference|color" /> <attr name="objectivesBackgroundColor" format="reference|color" />
<attr name="objectivesDisabledTextColor" format="reference|color" /> <attr name="objectivesDisabledTextColor" format="reference|color" />
<!---Import List --> <!---Import List -->

View file

@ -2,7 +2,7 @@
<resources xmlns:tools="http://schemas.android.com/tools"> <resources xmlns:tools="http://schemas.android.com/tools">
<!-- Default theme color --> <!-- Default theme color -->
<!-- This section describes the main theme colors --> <!-- This section describes the main theme colors -->
<color name="colorPrimary">#FBF9FF</color> <color name="colorPrimary">#3378C5</color>
<color name="colorPrimaryDark">#676767</color> <color name="colorPrimaryDark">#676767</color>
<color name="colorAccent">#40bbaa</color> <color name="colorAccent">#40bbaa</color>
<color name="mdtp_white">#ffffff</color> <color name="mdtp_white">#ffffff</color>
@ -226,7 +226,7 @@
<!-- Gray colors --> <!-- Gray colors -->
<color name="darkgray">#323232</color> <color name="darkgray">#323232</color>
<color name="darkgrayVariant">#424242</color> <color name="darkgrayVariant">#424242</color>
<color name="objectivesBackground">#3C3C3C</color> <color name="objectivesBackground">#8C8C8C</color>
<color name="plastic_grey">#666666</color> <color name="plastic_grey">#666666</color>
<color name="byodagray">#777777</color> <color name="byodagray">#777777</color>
<color name="sphere_plastic_grey">#8c8c8c</color> <color name="sphere_plastic_grey">#8c8c8c</color>
@ -309,6 +309,7 @@
<color name="aaps_theme_light_onBackground">#1C1B1F</color> <color name="aaps_theme_light_onBackground">#1C1B1F</color>
<color name="aaps_theme_light_surface">#FAF9F8</color> <color name="aaps_theme_light_surface">#FAF9F8</color>
<color name="aaps_theme_light_onSurface">#1C1B1F</color> <color name="aaps_theme_light_onSurface">#1C1B1F</color>
<color name="aaps_theme_light_surfaceVariant">#E7E0EC</color> <color name="aaps_theme_light_surfaceVariant">#E2E0DF</color>
</resources> </resources>

View file

@ -11,7 +11,7 @@
<item name="colorOnError">@color/aaps_theme_light_onError</item> <item name="colorOnError">@color/aaps_theme_light_onError</item>
<item name="android:colorBackground">@color/aaps_theme_light_background</item> <item name="android:colorBackground">@color/aaps_theme_light_background</item>
<item name="colorOnBackground">@color/aaps_theme_light_onBackground</item> <item name="colorOnBackground">@color/aaps_theme_light_onBackground</item>
<item name="colorSurface">@color/aaps_theme_light_surface</item> <item name="colorSurface">@color/aaps_theme_light_surfaceVariant</item>
<item name="colorOnSurface">@color/aaps_theme_light_onSurface</item> <item name="colorOnSurface">@color/aaps_theme_light_onSurface</item>
<item name="colorPrimaryDark">@color/colorPrimaryDark</item> <item name="colorPrimaryDark">@color/colorPrimaryDark</item>
<item name="colorAccent">@color/aaps_theme_light_secondary</item> <item name="colorAccent">@color/aaps_theme_light_secondary</item>
@ -79,6 +79,7 @@
<!-- Pump --> <!-- Pump -->
<item name="pumpStatusBackground">@color/pumpStatusBackground</item> <item name="pumpStatusBackground">@color/pumpStatusBackground</item>
<!-- Objectives --> <!-- Objectives -->
<item name="objectivescardItemBackgroundColor">@color/midgray</item>
<item name="objectivesBackgroundColor">@color/objectivesBackground</item> <item name="objectivesBackgroundColor">@color/objectivesBackground</item>
<item name="objectivesDisabledTextColor">@color/colorObjectivesDisabledText</item> <item name="objectivesDisabledTextColor">@color/colorObjectivesDisabledText</item>
<!---Import List --> <!---Import List -->