Skip to content

Commit 4263828

Browse files
committed
UI Changes As per PRD
1 parent 3f49541 commit 4263828

53 files changed

Lines changed: 3930 additions & 3114 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

app/src/main/java/org/piramalswasthya/stoptb/adapters/FormInputAdapter.kt

Lines changed: 25 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -98,8 +98,12 @@ class FormInputAdapter(
9898
oldItem.id == newItem.id
9999

100100
override fun areContentsTheSame(oldItem: FormElement, newItem: FormElement): Boolean {
101-
Timber.d("${oldItem.id} ${oldItem.errorText} ${newItem.errorText}")
102-
return oldItem.errorText == newItem.errorText
101+
Timber.d("${oldItem.id} error:${oldItem.errorText} value:${oldItem.value}")
102+
return oldItem.errorText == newItem.errorText &&
103+
oldItem.value == newItem.value &&
104+
oldItem.isEnabled == newItem.isEnabled &&
105+
oldItem.required == newItem.required &&
106+
oldItem.title == newItem.title
103107
}
104108
}
105109

@@ -426,7 +430,8 @@ class FormInputAdapter(
426430
fun bind(
427431
item: FormElement, isEnabled: Boolean, formValueListener: FormValueListener?
428432
) {
429-
if (!isEnabled) {
433+
val effectiveEnabled = isEnabled && item.isEnabled
434+
if (!effectiveEnabled) {
430435
binding.rg.isClickable = false
431436
binding.rg.isFocusable = false
432437
}
@@ -482,7 +487,7 @@ class FormInputAdapter(
482487
)
483488
}
484489

485-
if (!isEnabled) rdBtn.buttonTintList = colorStateList
490+
if (!effectiveEnabled) rdBtn.buttonTintList = colorStateList
486491
rdBtn.text = it
487492
addView(rdBtn)
488493
if (item.value == it) rdBtn.isChecked = true
@@ -520,7 +525,7 @@ class FormInputAdapter(
520525
}
521526
}
522527

523-
if (!isEnabled) {
528+
if (!effectiveEnabled) {
524529
binding.rg.children.forEach {
525530
it.isClickable = false
526531
}
@@ -579,6 +584,7 @@ class FormInputAdapter(
579584
) {
580585
binding.form = item
581586
binding.llChecks.removeAllViews()
587+
val effectiveEnabled = isEnabled && item.isEnabled
582588

583589
val selectedIndexes = item.value
584590
?.split("|")
@@ -590,7 +596,7 @@ class FormInputAdapter(
590596

591597
val cbx = CheckBox(binding.root.context)
592598
cbx.text = text
593-
cbx.isEnabled = isEnabled
599+
cbx.isEnabled = effectiveEnabled
594600
cbx.isChecked = selectedIndexes.contains(index)
595601
cbx.setOnCheckedChangeListener { _, isChecked ->
596602

@@ -940,8 +946,18 @@ class FormInputAdapter(
940946
)
941947
item.errorText = null
942948
binding.tilEditTextDate.error = null
943-
item.min?.let { datePickerDialog.datePicker.minDate = it }
944-
item.max?.let { datePickerDialog.datePicker.maxDate = it }
949+
val effectiveMin = item.min
950+
val effectiveMax = item.max
951+
when {
952+
effectiveMin != null && effectiveMax != null && effectiveMin > effectiveMax -> {
953+
datePickerDialog.datePicker.minDate = effectiveMax
954+
datePickerDialog.datePicker.maxDate = effectiveMax
955+
}
956+
else -> {
957+
effectiveMin?.let { datePickerDialog.datePicker.minDate = it }
958+
effectiveMax?.let { datePickerDialog.datePicker.maxDate = it }
959+
}
960+
}
945961
if (item.showYearFirstInDatePicker)
946962
datePickerDialog.datePicker.touchables[0].performClick()
947963
datePickerDialog.show()
@@ -1372,4 +1388,4 @@ class FormInputAdapter(
13721388

13731389

13741390

1375-
}
1391+
}

app/src/main/java/org/piramalswasthya/stoptb/adapters/TbConfirmedListAdapter.kt

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -45,12 +45,7 @@ ListAdapter<BenWithTbSuspectedDomain, TbConfirmedListAdapter.BenViewHolder>
4545
clickListener: ClickListener?,
4646
pref: PreferenceDao?
4747
) {
48-
49-
if (pref?.getLoggedInUser()?.role.equals("asha", true)) {
50-
binding.btnFormTb.visibility = View.VISIBLE
51-
} else {
52-
binding.btnFormTb.visibility = View.INVISIBLE
53-
}
48+
binding.btnFormTb.visibility = View.VISIBLE
5449

5550
binding.benWithTb = item
5651

@@ -124,4 +119,4 @@ ListAdapter<BenWithTbSuspectedDomain, TbConfirmedListAdapter.BenViewHolder>
124119
clickedForm?.let { it(item.ben.hhId, item.ben.benId) }
125120
}
126121

127-
}
122+
}

0 commit comments

Comments
 (0)