@@ -6,6 +6,7 @@ import android.os.Bundle
6
6
import android.view.Menu
7
7
import android.view.MenuItem
8
8
import android.view.View
9
+ import android.view.accessibility.AccessibilityNodeInfo
9
10
import androidx.activity.result.contract.ActivityResultContracts.*
10
11
import androidx.activity.result.contract.ActivityResultContracts.StartActivityForResult.*
11
12
import androidx.activity.viewModels
@@ -73,7 +74,31 @@ class ReplaceManagerActivity : AppCompatActivity() {
73
74
getBindingOrNull<SysttsListCustomGroupItemBinding >()?.apply {
74
75
itemView.clickWithThrottle {
75
76
val data = getModel<ReplaceRuleGroupModel >().data
76
- appDb.replaceRuleDao.insertGroup(data.copy(isExpanded = ! data.isExpanded))
77
+ val isExpanded = ! data.isExpanded
78
+ appDb.replaceRuleDao.insertGroup(data.copy(isExpanded = isExpanded))
79
+ getModel<ReplaceRuleGroupModel >().let { model ->
80
+ val enabledCount =
81
+ model.itemSublist?.filter { (it as ReplaceRuleModel ).data.isEnabled }?.size
82
+ val speakText =
83
+ if (isExpanded) R .string.group_expanded else R .string.group_collapsed
84
+ itemView.announceForAccessibility(
85
+ getString(speakText) + " , ${
86
+ getString(
87
+ R .string.systts_desc_list_count_info,
88
+ model.itemSublist?.size,
89
+ enabledCount
90
+ )
91
+ } "
92
+ )
93
+
94
+ if (model.itemExpand && model.itemSublist.isNullOrEmpty()) {
95
+ collapse(modelPosition)
96
+ MaterialAlertDialogBuilder (this @ReplaceManagerActivity)
97
+ .setTitle(R .string.msg_group_is_empty)
98
+ .setMessage(getString(R .string.systts_group_empty_msg))
99
+ .show()
100
+ }
101
+ }
77
102
}
78
103
btnMore.clickWithThrottle {
79
104
displayGroupMenu(
@@ -88,6 +113,22 @@ class ReplaceManagerActivity : AppCompatActivity() {
88
113
}
89
114
}
90
115
}
116
+
117
+ checkBox.accessibilityDelegate = object : View .AccessibilityDelegate () {
118
+ override fun onInitializeAccessibilityNodeInfo (
119
+ host : View ,
120
+ info : AccessibilityNodeInfo
121
+ ) {
122
+ super .onInitializeAccessibilityNodeInfo(host, info)
123
+ val str = when (checkBox.checkedState) {
124
+ MaterialCheckBox .STATE_CHECKED -> getString(R .string.md_checkbox_checked)
125
+ MaterialCheckBox .STATE_UNCHECKED -> getString(R .string.md_checkbox_unchecked)
126
+ MaterialCheckBox .STATE_INDETERMINATE -> getString(R .string.md_checkbox_indeterminate)
127
+ else -> " "
128
+ }
129
+ info.text = " , $str , "
130
+ }
131
+ }
91
132
}
92
133
93
134
getBindingOrNull<SysttsReplaceRuleItemBinding >()?.apply {
@@ -345,7 +386,9 @@ class ReplaceManagerActivity : AppCompatActivity() {
345
386
getString(R .string.edit_group_name),
346
387
getString(R .string.name)
347
388
) { text ->
348
- appDb.replaceRuleDao.insertGroup(ReplaceRuleGroup (name = text))
389
+ appDb.replaceRuleDao.insertGroup(ReplaceRuleGroup (name = text.ifEmpty {
390
+ getString(R .string.unnamed)
391
+ }))
349
392
}
350
393
}
351
394
0 commit comments