ProfileSwitchDialog spinner replacement
This commit is contained in:
parent
c24d2798ff
commit
6d27f5fad0
4 changed files with 23 additions and 29 deletions
|
@ -117,8 +117,7 @@ class ProfileSwitchDialog : DialogFragmentWithDate() {
|
||||||
|
|
||||||
// profile
|
// profile
|
||||||
context?.let { context ->
|
context?.let { context ->
|
||||||
val profileStore = activePlugin.activeProfileSource.profile
|
val profileStore = activePlugin.activeProfileSource.profile ?: return
|
||||||
?: return
|
|
||||||
val profileListToCheck = profileStore.getProfileList()
|
val profileListToCheck = profileStore.getProfileList()
|
||||||
val profileList = ArrayList<CharSequence>()
|
val profileList = ArrayList<CharSequence>()
|
||||||
for (profileName in profileListToCheck) {
|
for (profileName in profileListToCheck) {
|
||||||
|
@ -130,15 +129,16 @@ class ProfileSwitchDialog : DialogFragmentWithDate() {
|
||||||
dismiss()
|
dismiss()
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
val adapter = ArrayAdapter(context, R.layout.spinner_centered, profileList)
|
binding.profileList.setAdapter(ArrayAdapter(context, R.layout.spinner_centered, profileList))
|
||||||
binding.profile.adapter = adapter
|
|
||||||
// set selected to actual profile
|
// set selected to actual profile
|
||||||
if (profileIndex != null)
|
if (profileIndex != null)
|
||||||
binding.profile.setSelection(profileIndex as Int)
|
binding.profileList.setText(profileList[profileIndex as Int], false)
|
||||||
else
|
else {
|
||||||
|
binding.profileList.setText(profileList[0], false)
|
||||||
for (p in profileList.indices)
|
for (p in profileList.indices)
|
||||||
if (profileList[p] == profileFunction.getOriginalProfileName())
|
if (profileList[p] == profileFunction.getOriginalProfileName())
|
||||||
binding.profile.setSelection(p)
|
binding.profileList.setText(profileList[p], false)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
profileFunction.getProfile()?.let { profile ->
|
profileFunction.getProfile()?.let { profile ->
|
||||||
|
@ -173,7 +173,7 @@ class ProfileSwitchDialog : DialogFragmentWithDate() {
|
||||||
val duration = binding.duration.value.toInt()
|
val duration = binding.duration.value.toInt()
|
||||||
if (duration > 0L)
|
if (duration > 0L)
|
||||||
actions.add(rh.gs(R.string.duration) + ": " + rh.gs(R.string.format_mins, duration))
|
actions.add(rh.gs(R.string.duration) + ": " + rh.gs(R.string.format_mins, duration))
|
||||||
val profileName = binding.profile.selectedItem.toString()
|
val profileName = binding.profileList.text.toString()
|
||||||
actions.add(rh.gs(R.string.profile) + ": " + profileName)
|
actions.add(rh.gs(R.string.profile) + ": " + profileName)
|
||||||
val percent = binding.percentage.value.toInt()
|
val percent = binding.percentage.value.toInt()
|
||||||
if (percent != 100)
|
if (percent != 100)
|
||||||
|
|
|
@ -128,12 +128,12 @@ class OverviewData @Inject constructor(
|
||||||
|
|
||||||
var lastBg: GlucoseValue? = null
|
var lastBg: GlucoseValue? = null
|
||||||
|
|
||||||
val isLow: Boolean
|
private val isLow: Boolean
|
||||||
get() = lastBg?.let { lastBg ->
|
get() = lastBg?.let { lastBg ->
|
||||||
lastBg.valueToUnits(profileFunction.getUnits()) < defaultValueHelper.determineLowLine()
|
lastBg.valueToUnits(profileFunction.getUnits()) < defaultValueHelper.determineLowLine()
|
||||||
} ?: false
|
} ?: false
|
||||||
|
|
||||||
val isHigh: Boolean
|
private val isHigh: Boolean
|
||||||
get() = lastBg?.let { lastBg ->
|
get() = lastBg?.let { lastBg ->
|
||||||
lastBg.valueToUnits(profileFunction.getUnits()) > defaultValueHelper.determineHighLine()
|
lastBg.valueToUnits(profileFunction.getUnits()) > defaultValueHelper.determineHighLine()
|
||||||
} ?: false
|
} ?: false
|
||||||
|
|
|
@ -58,7 +58,6 @@ class LocalProfileFragment : DaggerFragment() {
|
||||||
private var disposable: CompositeDisposable = CompositeDisposable()
|
private var disposable: CompositeDisposable = CompositeDisposable()
|
||||||
|
|
||||||
private var basalView: TimeListEdit? = null
|
private var basalView: TimeListEdit? = null
|
||||||
// private var spinner: SpinnerHelper? = null
|
|
||||||
|
|
||||||
private val save = Runnable {
|
private val save = Runnable {
|
||||||
doEdit()
|
doEdit()
|
||||||
|
@ -240,7 +239,6 @@ class LocalProfileFragment : DaggerFragment() {
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Spinner
|
|
||||||
context?.let { context ->
|
context?.let { context ->
|
||||||
val profileList: ArrayList<CharSequence> = localProfilePlugin.profile?.getProfileList() ?: ArrayList()
|
val profileList: ArrayList<CharSequence> = localProfilePlugin.profile?.getProfileList() ?: ArrayList()
|
||||||
binding.profileList.setAdapter(ArrayAdapter(context, R.layout.spinner_centered, profileList))
|
binding.profileList.setAdapter(ArrayAdapter(context, R.layout.spinner_centered, profileList))
|
||||||
|
|
|
@ -48,29 +48,25 @@
|
||||||
android:orientation="horizontal"
|
android:orientation="horizontal"
|
||||||
android:padding="5dp" />
|
android:padding="5dp" />
|
||||||
|
|
||||||
<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/profile"
|
||||||
|
app:boxStrokeColor="@color/list_delimiter">
|
||||||
|
|
||||||
<TextView
|
<androidx.appcompat.widget.AppCompatAutoCompleteTextView
|
||||||
android:layout_width="wrap_content"
|
android:id="@+id/profileList"
|
||||||
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_gravity="center_horizontal"
|
android:clickable="true"
|
||||||
android:width="120dp"
|
android:enabled="false"
|
||||||
android:labelFor="@+id/profile"
|
tools:ignore="KeyboardInaccessibleWidget" />
|
||||||
android:padding="10dp"
|
|
||||||
android:text="@string/profile_label"
|
|
||||||
android:textAppearance="@style/TextAppearance.AppCompat.Small"
|
|
||||||
android:textStyle="bold" />
|
|
||||||
|
|
||||||
<Spinner
|
</com.google.android.material.textfield.TextInputLayout>
|
||||||
android:id="@+id/profile"
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_gravity="center_vertical" />
|
|
||||||
|
|
||||||
</LinearLayout>
|
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:id="@+id/reuselayout"
|
android:id="@+id/reuselayout"
|
||||||
|
|
Loading…
Reference in a new issue