@@ -26849,19 +26849,37 @@ private void updateSearchButtons(int mask, int num, int count) {
2684926849 }
2685026850 }
2685126851
26852+ private int accessibilityAnnouncedSearchIndex = -1;
26853+
2685226854 private void updateSearchCountText() {
2685326855 if (searchCountText != null) {
2685426856 boolean animated = !LocaleController.isRTL;
26857+ final CharSequence text;
2685526858 if (searchLastCount < 0) {
26856- searchCountText.setText("", animated) ;
26859+ text = "" ;
2685726860 } else if (searchLastCount == 0) {
26858- searchCountText.setText( LocaleController.getString(R.string.NoResult), animated );
26861+ text = LocaleController.getString(R.string.NoResult);
2685926862 } else if (searchingFiltered) {
26860- searchCountText.setText( LocaleController.formatPluralString("TaggedMessages", searchLastCount), animated );
26863+ text = LocaleController.formatPluralString("TaggedMessages", searchLastCount);
2686126864 } else if (chatMode == MODE_SEARCH || isMessagesSearchListVisible()) {
26862- searchCountText.setText( LocaleController.formatPluralString("SearchMessagesResultCount", searchLastCount, LocaleController.formatNumber(searchLastCount, ' ')), animated );
26865+ text = LocaleController.formatPluralString("SearchMessagesResultCount", searchLastCount, LocaleController.formatNumber(searchLastCount, ' '));
2686326866 } else {
26864- searchCountText.setText(LocaleController.formatString(R.string.Of, searchLastIndex + 1, searchLastCount), animated);
26867+ text = LocaleController.formatString(R.string.Of, searchLastIndex + 1, searchLastCount);
26868+ }
26869+ searchCountText.setText(text, animated);
26870+ // the count is drawn, so nothing reads it: give it what it shows, since the text it
26871+ // is set to only reaches it once the animation carrying it is over, and let it be
26872+ // reached by touch as well as by swiping
26873+ searchCountText.setContentDescription(text);
26874+ searchCountText.setImportantForAccessibility(TextUtils.isEmpty(text) ? View.IMPORTANT_FOR_ACCESSIBILITY_NO : View.IMPORTANT_FOR_ACCESSIBILITY_YES);
26875+ searchCountText.setFocusable(!TextUtils.isEmpty(text));
26876+ if (searchLastCount > 0 && searchLastIndex != accessibilityAnnouncedSearchIndex && AndroidUtilities.isAccessibilityScreenReaderEnabled()) {
26877+ if (accessibilityAnnouncedSearchIndex != -1) {
26878+ searchCountText.announceForAccessibility(text);
26879+ }
26880+ accessibilityAnnouncedSearchIndex = searchLastIndex;
26881+ } else if (searchLastCount <= 0) {
26882+ accessibilityAnnouncedSearchIndex = -1;
2686526883 }
2686626884 }
2686726885 }
0 commit comments