TempTargetDialog spinner replacement

This commit is contained in:
Milos Kozak 2022-03-19 16:17:36 +01:00
parent 2441ee1592
commit cb1e40bd90
2 changed files with 18 additions and 26 deletions

View file

@ -105,8 +105,7 @@ class TempTargetDialog : DialogFragmentWithDate() {
rh.gs(R.string.activity),
rh.gs(R.string.hypo)
)
val adapterReason = ArrayAdapter(context, R.layout.spinner_centered, reasonList)
binding.reason.adapter = adapterReason
binding.reasonList.setAdapter(ArrayAdapter(context, R.layout.spinner_centered, reasonList))
binding.targetCancel.setOnClickListener { binding.duration.value = 0.0; shortClick(it) }
binding.eatingSoon.setOnClickListener { shortClick(it) }
@ -140,19 +139,19 @@ class TempTargetDialog : DialogFragmentWithDate() {
R.id.eating_soon -> {
binding.temptarget.value = defaultValueHelper.determineEatingSoonTT()
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 -> {
binding.temptarget.value = defaultValueHelper.determineActivityTT()
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 -> {
binding.temptarget.value = defaultValueHelper.determineHypoTT()
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 {
if (_binding == null) return false
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 target = binding.temptarget.value
val duration = binding.duration.value.toInt()

View file

@ -120,31 +120,24 @@
</LinearLayout>
<LinearLayout
<com.google.android.material.textfield.TextInputLayout
style="@style/Widget.MaterialComponents.TextInputLayout.OutlinedBox.ExposedDropdownMenu"
android:layout_width="match_parent"
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
android:layout_width="wrap_content"
<androidx.appcompat.widget.AppCompatAutoCompleteTextView
android:id="@+id/reasonList"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:width="120dp"
android:padding="10dp"
android:labelFor="@+id/reason"
android:text="@string/reason"
android:textAppearance="@style/TextAppearance.AppCompat.Small"
android:textStyle="bold" />
android:clickable="true"
android:enabled="false"
tools:ignore="KeyboardInaccessibleWidget" />
<Spinner
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>
</com.google.android.material.textfield.TextInputLayout>
<LinearLayout
android:layout_width="match_parent"