Add accessibility label for base URL dropdown

This commit is contained in:
Philipp Heckel 2022-06-18 20:10:01 -04:00
parent 7f88d8f3ff
commit eabb163fde
3 changed files with 17 additions and 2 deletions

View file

@ -9,13 +9,17 @@ import io.heckel.ntfy.R
fun initBaseUrlDropdown(baseUrls: List<String>, textView: AutoCompleteTextView, layout: TextInputLayout) {
// Base URL dropdown behavior; Oh my, why is this so complicated?!
val context = layout.context
val toggleEndIcon = {
if (textView.text.isNotEmpty()) {
layout.setEndIconDrawable(R.drawable.ic_cancel_gray_24dp)
layout.endIconContentDescription = context.getString(R.string.add_dialog_base_urls_dropdown_clear)
} else if (baseUrls.isEmpty()) {
layout.setEndIconDrawable(0)
layout.endIconContentDescription = ""
} else {
layout.setEndIconDrawable(R.drawable.ic_drop_down_gray_24dp)
layout.endIconContentDescription = context.getString(R.string.add_dialog_base_urls_dropdown_choose)
}
}
layout.setEndIconOnClickListener {
@ -23,11 +27,14 @@ fun initBaseUrlDropdown(baseUrls: List<String>, textView: AutoCompleteTextView,
textView.text.clear()
if (baseUrls.isEmpty()) {
layout.setEndIconDrawable(0)
layout.endIconContentDescription = ""
} else {
layout.setEndIconDrawable(R.drawable.ic_drop_down_gray_24dp)
layout.endIconContentDescription = context.getString(R.string.add_dialog_base_urls_dropdown_choose)
}
} else if (textView.text.isEmpty() && baseUrls.isNotEmpty()) {
layout.setEndIconDrawable(R.drawable.ic_drop_up_gray_24dp)
layout.endIconContentDescription = context.getString(R.string.add_dialog_base_urls_dropdown_choose)
textView.showDropDown()
}
}
@ -49,10 +56,13 @@ fun initBaseUrlDropdown(baseUrls: List<String>, textView: AutoCompleteTextView,
textView.setAdapter(adapter)
if (baseUrls.count() == 1) {
layout.setEndIconDrawable(R.drawable.ic_cancel_gray_24dp)
layout.endIconContentDescription = context.getString(R.string.add_dialog_base_urls_dropdown_clear)
textView.setText(baseUrls.first())
} else if (baseUrls.count() > 1) {
layout.setEndIconDrawable(R.drawable.ic_drop_down_gray_24dp)
layout.endIconContentDescription = context.getString(R.string.add_dialog_base_urls_dropdown_choose)
} else {
layout.setEndIconDrawable(0)
layout.endIconContentDescription = ""
}
}

View file

@ -1,4 +1,6 @@
<resources>
<resources xmlns:tools="http://schemas.android.com/tools"
tools:ignore="MissingTranslation">
<!-- Notification channels -->
<string name="channel_notifications_min_name">Notifications (min priority)</string>
<string name="channel_notifications_low_name">Notifications (low priority)</string>
@ -101,6 +103,8 @@
<string name="add_dialog_login_password_hint">Password</string>
<string name="add_dialog_login_error_not_authorized">Login failed. User %1$s not authorized.</string>
<string name="add_dialog_login_new_user">New user</string>
<string name="add_dialog_base_urls_dropdown_choose">Choose service URL</string>
<string name="add_dialog_base_urls_dropdown_clear">Clear service URL</string>
<!-- Detail activity -->
<string name="detail_no_notifications_text">You haven\'t received any notifications for this topic yet.</string>

View file

@ -1,6 +1,7 @@
Bugs:
* Fixed: Long-click selecting of notifications scrolls to the top (#235, thanks to @wunter8)
* Long-click selecting of notifications doesn't scoll to the top anymore (#235, thanks to @wunter8)
* Add attachment and click URL extras to MESSAGE_RECEIVED broadcast (#329, thanks to @wunter8)
* Accessibility: Clear/choose service URL button in base URL dropdown now has a label (#292, thanks to @mhameed for reporting)
Additional translations:
* Italian (thanks to @Genio2003)