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)
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

View file

@ -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() {

View file

@ -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">
<com.google.android.material.textfield.TextInputEditText

View file

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

View file

@ -211,34 +211,9 @@
</LinearLayout>
<LinearLayout
<include
android:id="@+id/notes_layout"
android:layout_width="match_parent"
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>
layout="@layout/notes" />
<LinearLayout
android:id="@+id/checkbox_row"

View file

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

View file

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

View file

@ -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" />

View file

@ -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">

View file

@ -29,15 +29,19 @@ fun List<ProfileSwitch>.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)

View file

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

View file

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

View file

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

View file

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

View file

@ -2,7 +2,7 @@
<resources xmlns:tools="http://schemas.android.com/tools">
<!-- Default theme color -->
<!-- This section describes the main theme colors -->
<color name="colorPrimary">#FBF9FF</color>
<color name="colorPrimary">#3378C5</color>
<color name="colorPrimaryDark">#676767</color>
<color name="colorAccent">#40bbaa</color>
<color name="mdtp_white">#ffffff</color>
@ -226,7 +226,7 @@
<!-- Gray colors -->
<color name="darkgray">#323232</color>
<color name="darkgrayVariant">#424242</color>
<color name="objectivesBackground">#3C3C3C</color>
<color name="objectivesBackground">#8C8C8C</color>
<color name="plastic_grey">#666666</color>
<color name="byodagray">#777777</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_surface">#FAF9F8</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>

View file

@ -11,7 +11,7 @@
<item name="colorOnError">@color/aaps_theme_light_onError</item>
<item name="android:colorBackground">@color/aaps_theme_light_background</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="colorPrimaryDark">@color/colorPrimaryDark</item>
<item name="colorAccent">@color/aaps_theme_light_secondary</item>
@ -79,6 +79,7 @@
<!-- Pump -->
<item name="pumpStatusBackground">@color/pumpStatusBackground</item>
<!-- Objectives -->
<item name="objectivescardItemBackgroundColor">@color/midgray</item>
<item name="objectivesBackgroundColor">@color/objectivesBackground</item>
<item name="objectivesDisabledTextColor">@color/colorObjectivesDisabledText</item>
<!---Import List -->