TempTargetDialog spinner replacement
This commit is contained in:
parent
2441ee1592
commit
cb1e40bd90
2 changed files with 18 additions and 26 deletions
|
@ -105,8 +105,7 @@ class TempTargetDialog : DialogFragmentWithDate() {
|
||||||
rh.gs(R.string.activity),
|
rh.gs(R.string.activity),
|
||||||
rh.gs(R.string.hypo)
|
rh.gs(R.string.hypo)
|
||||||
)
|
)
|
||||||
val adapterReason = ArrayAdapter(context, R.layout.spinner_centered, reasonList)
|
binding.reasonList.setAdapter(ArrayAdapter(context, R.layout.spinner_centered, reasonList))
|
||||||
binding.reason.adapter = adapterReason
|
|
||||||
|
|
||||||
binding.targetCancel.setOnClickListener { binding.duration.value = 0.0; shortClick(it) }
|
binding.targetCancel.setOnClickListener { binding.duration.value = 0.0; shortClick(it) }
|
||||||
binding.eatingSoon.setOnClickListener { shortClick(it) }
|
binding.eatingSoon.setOnClickListener { shortClick(it) }
|
||||||
|
@ -140,19 +139,19 @@ class TempTargetDialog : DialogFragmentWithDate() {
|
||||||
R.id.eating_soon -> {
|
R.id.eating_soon -> {
|
||||||
binding.temptarget.value = defaultValueHelper.determineEatingSoonTT()
|
binding.temptarget.value = defaultValueHelper.determineEatingSoonTT()
|
||||||
binding.duration.value = defaultValueHelper.determineEatingSoonTTDuration().toDouble()
|
binding.duration.value = defaultValueHelper.determineEatingSoonTTDuration().toDouble()
|
||||||
binding.reason.setSelection(reasonList.indexOf(rh.gs(R.string.eatingsoon)))
|
binding.reasonList.setText(rh.gs(R.string.eatingsoon), false)
|
||||||
}
|
}
|
||||||
|
|
||||||
R.id.activity -> {
|
R.id.activity -> {
|
||||||
binding.temptarget.value = defaultValueHelper.determineActivityTT()
|
binding.temptarget.value = defaultValueHelper.determineActivityTT()
|
||||||
binding.duration.value = defaultValueHelper.determineActivityTTDuration().toDouble()
|
binding.duration.value = defaultValueHelper.determineActivityTTDuration().toDouble()
|
||||||
binding.reason.setSelection(reasonList.indexOf(rh.gs(R.string.activity)))
|
binding.reasonList.setText(rh.gs(R.string.activity), false)
|
||||||
}
|
}
|
||||||
|
|
||||||
R.id.hypo -> {
|
R.id.hypo -> {
|
||||||
binding.temptarget.value = defaultValueHelper.determineHypoTT()
|
binding.temptarget.value = defaultValueHelper.determineHypoTT()
|
||||||
binding.duration.value = defaultValueHelper.determineHypoTTDuration().toDouble()
|
binding.duration.value = defaultValueHelper.determineHypoTTDuration().toDouble()
|
||||||
binding.reason.setSelection(reasonList.indexOf(rh.gs(R.string.hypo)))
|
binding.reasonList.setText(rh.gs(R.string.hypo), false)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -166,7 +165,7 @@ class TempTargetDialog : DialogFragmentWithDate() {
|
||||||
override fun submit(): Boolean {
|
override fun submit(): Boolean {
|
||||||
if (_binding == null) return false
|
if (_binding == null) return false
|
||||||
val actions: LinkedList<String> = LinkedList()
|
val actions: LinkedList<String> = LinkedList()
|
||||||
var reason = binding.reason.selectedItem?.toString() ?: return false
|
var reason = binding.reasonList.text.toString()
|
||||||
val unitResId = if (profileFunction.getUnits() == GlucoseUnit.MGDL) R.string.mgdl else R.string.mmol
|
val unitResId = if (profileFunction.getUnits() == GlucoseUnit.MGDL) R.string.mgdl else R.string.mmol
|
||||||
val target = binding.temptarget.value
|
val target = binding.temptarget.value
|
||||||
val duration = binding.duration.value.toInt()
|
val duration = binding.duration.value.toInt()
|
||||||
|
|
|
@ -120,31 +120,24 @@
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
<LinearLayout
|
<com.google.android.material.textfield.TextInputLayout
|
||||||
|
style="@style/Widget.MaterialComponents.TextInputLayout.OutlinedBox.ExposedDropdownMenu"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:orientation="horizontal">
|
android:layout_marginStart="5dp"
|
||||||
|
android:layout_marginEnd="5dp"
|
||||||
|
android:hint="@string/reason"
|
||||||
|
app:boxStrokeColor="@color/list_delimiter">
|
||||||
|
|
||||||
<TextView
|
<androidx.appcompat.widget.AppCompatAutoCompleteTextView
|
||||||
android:layout_width="wrap_content"
|
android:id="@+id/reasonList"
|
||||||
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_gravity="center_vertical"
|
android:clickable="true"
|
||||||
android:width="120dp"
|
android:enabled="false"
|
||||||
android:padding="10dp"
|
tools:ignore="KeyboardInaccessibleWidget" />
|
||||||
android:labelFor="@+id/reason"
|
|
||||||
android:text="@string/reason"
|
|
||||||
android:textAppearance="@style/TextAppearance.AppCompat.Small"
|
|
||||||
android:textStyle="bold" />
|
|
||||||
|
|
||||||
<Spinner
|
</com.google.android.material.textfield.TextInputLayout>
|
||||||
android:id="@+id/reason"
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_gravity="center_vertical"
|
|
||||||
android:paddingLeft="5dp"
|
|
||||||
android:paddingRight="5dp" />
|
|
||||||
|
|
||||||
</LinearLayout>
|
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
|
|
Loading…
Reference in a new issue