mirror of
https://github.com/sudoxnym/habitica-android.git
synced 2026-05-20 04:39:04 +00:00
Further Talkback improvements for main activity (#1309)
* Add content description for Avatar icon * Add content descriptions for plus and minus buttons * Make bottom_navigation_background no longer clickable/focusable - Previously it was set as clickable, even though clicking on it did nothing. This had the side effect of making it focusable, adding an unnecessary item to scroll through when using Talkback. - Now it is no longer set as clickable, this is enough to make it no longer focusable either. * Add currency units to content descriptions of currency values
This commit is contained in:
parent
cd9361e5c8
commit
348b7fd19b
4 changed files with 21 additions and 5 deletions
|
|
@ -26,6 +26,7 @@
|
|||
android:layout_gravity="center_vertical"
|
||||
android:layout_marginEnd="16dp"
|
||||
android:layout_marginRight="16dp"
|
||||
android:contentDescription="@string/sidebar_avatar"
|
||||
app:showBackground="true"
|
||||
app:showMount="true"
|
||||
app:showPet="true"/>
|
||||
|
|
|
|||
|
|
@ -38,7 +38,8 @@
|
|||
style="@style/HabitButton"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:background="@drawable/selection_highlight" />
|
||||
android:background="@drawable/selection_highlight"
|
||||
android:contentDescription="@string/positive_habit_form" />
|
||||
</FrameLayout>
|
||||
|
||||
<LinearLayout
|
||||
|
|
@ -184,7 +185,8 @@
|
|||
style="@style/HabitButton"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:background="@drawable/selection_highlight" />
|
||||
android:background="@drawable/selection_highlight"
|
||||
android:contentDescription="@string/negative_habit_form" />
|
||||
</FrameLayout>
|
||||
</LinearLayout>
|
||||
|
||||
|
|
|
|||
|
|
@ -12,8 +12,7 @@
|
|||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignParentBottom="true"
|
||||
android:layout_alignTop="@id/item_wrapper"
|
||||
android:clickable="true">
|
||||
android:layout_alignTop="@id/item_wrapper">
|
||||
<View
|
||||
android:layout_width="0dp"
|
||||
android:layout_weight="1"
|
||||
|
|
|
|||
|
|
@ -20,9 +20,11 @@ class CurrencyView : androidx.appcompat.widget.AppCompatTextView {
|
|||
var currency: String? = null
|
||||
set(currency) {
|
||||
field = currency
|
||||
setCurrencyContentDescriptionFromCurrency(currency)
|
||||
configureCurrency()
|
||||
updateVisibility()
|
||||
}
|
||||
private var currencyContentDescription: String? = null
|
||||
|
||||
constructor(context: Context, attrs: AttributeSet?) : super(context, attrs) {
|
||||
val attributes = context.theme?.obtainStyledAttributes(
|
||||
|
|
@ -40,9 +42,19 @@ class CurrencyView : androidx.appcompat.widget.AppCompatTextView {
|
|||
constructor(context: Context, currency: String, lightbackground: Boolean) : super(context) {
|
||||
this.lightBackground = lightbackground
|
||||
this.currency = currency
|
||||
setCurrencyContentDescriptionFromCurrency(currency)
|
||||
visibility = GONE
|
||||
}
|
||||
|
||||
private fun setCurrencyContentDescriptionFromCurrency(currency: String?) {
|
||||
when (currency) {
|
||||
"gold" -> this.currencyContentDescription = context.getString(R.string.gold_plural)
|
||||
"gems" -> this.currencyContentDescription = context.getString(R.string.gems)
|
||||
"hourglasses" -> this.currencyContentDescription = context.getString(R.string.mystic_hourglasses)
|
||||
else -> this.currencyContentDescription = ""
|
||||
}
|
||||
}
|
||||
|
||||
private fun configureCurrency() {
|
||||
if ("gold" == currency) {
|
||||
icon = HabiticaIconsHelper.imageOfGold()
|
||||
|
|
@ -87,7 +99,9 @@ class CurrencyView : androidx.appcompat.widget.AppCompatTextView {
|
|||
var value = 0.0
|
||||
set(value) {
|
||||
field = value
|
||||
text = NumberAbbreviator.abbreviate(context, value)
|
||||
val abbreviatedValue = NumberAbbreviator.abbreviate(context, value)
|
||||
text = abbreviatedValue
|
||||
contentDescription = "$abbreviatedValue $currencyContentDescription"
|
||||
updateVisibility()
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue