From c38b2634582d74fe3a7c7a4273cac8750dbc7e7d Mon Sep 17 00:00:00 2001 From: ByteHamster Date: Fri, 6 Oct 2023 18:24:13 +0200 Subject: Better content descriptions for TalkBack (#6684) --- .../antennapod/dialog/VariableSpeedDialog.java | 8 +- .../view/viewholder/HorizontalItemViewHolder.java | 1 + app/src/main/res/layout/addfeed.xml | 1 + app/src/main/res/layout/episodes_list_fragment.xml | 1 + .../main/res/layout/feed_item_list_fragment.xml | 1 + app/src/main/res/layout/feeditemlist_header.xml | 98 +++++++++++----------- app/src/main/res/layout/fragment_itunes_search.xml | 1 + app/src/main/res/layout/fragment_subscriptions.xml | 1 + app/src/main/res/layout/home_section.xml | 1 + app/src/main/res/layout/queue_fragment.xml | 1 + app/src/main/res/layout/search_fragment.xml | 1 + app/src/main/res/layout/simple_list_fragment.xml | 1 + app/src/main/res/layout/subscription_item.xml | 1 + ui/common/build.gradle | 2 + ui/common/src/main/res/layout/pager_fragment.xml | 1 + ui/i18n/src/main/res/values/strings.xml | 2 + 16 files changed, 68 insertions(+), 54 deletions(-) diff --git a/app/src/main/java/de/danoeh/antennapod/dialog/VariableSpeedDialog.java b/app/src/main/java/de/danoeh/antennapod/dialog/VariableSpeedDialog.java index acb1f1694..987206743 100644 --- a/app/src/main/java/de/danoeh/antennapod/dialog/VariableSpeedDialog.java +++ b/app/src/main/java/de/danoeh/antennapod/dialog/VariableSpeedDialog.java @@ -23,7 +23,6 @@ import org.greenrobot.eventbus.EventBus; import org.greenrobot.eventbus.Subscribe; import org.greenrobot.eventbus.ThreadMode; -import java.text.DecimalFormat; import java.text.DecimalFormatSymbols; import java.util.ArrayList; import java.util.Collections; @@ -32,7 +31,6 @@ import java.util.Locale; public class VariableSpeedDialog extends BottomSheetDialogFragment { private SpeedSelectionAdapter adapter; - private final DecimalFormat speedFormat; private PlaybackController controller; private final List selectedSpeeds; private PlaybackSpeedSeekBar speedSeekBar; @@ -41,7 +39,6 @@ public class VariableSpeedDialog extends BottomSheetDialogFragment { public VariableSpeedDialog() { DecimalFormatSymbols format = new DecimalFormatSymbols(Locale.US); format.setDecimalSeparator('.'); - speedFormat = new DecimalFormat("0.00", format); selectedSpeeds = new ArrayList<>(UserPreferences.getPlaybackSpeedArray()); } @@ -70,7 +67,7 @@ public class VariableSpeedDialog extends BottomSheetDialogFragment { @Subscribe(threadMode = ThreadMode.MAIN) public void updateSpeed(SpeedChangedEvent event) { speedSeekBar.updateSpeed(event.getNewSpeed()); - addCurrentSpeedChip.setText(speedFormat.format(event.getNewSpeed())); + addCurrentSpeedChip.setText(String.format(Locale.getDefault(), "%1$.2f", event.getNewSpeed())); } @Nullable @@ -95,6 +92,7 @@ public class VariableSpeedDialog extends BottomSheetDialogFragment { addCurrentSpeedChip.setCloseIconVisible(true); addCurrentSpeedChip.setCloseIconResource(R.drawable.ic_add); addCurrentSpeedChip.setOnCloseIconClickListener(v -> addCurrentSpeed()); + addCurrentSpeedChip.setCloseIconContentDescription(getString(R.string.add_preset)); addCurrentSpeedChip.setOnClickListener(v -> addCurrentSpeed()); return root; } @@ -126,7 +124,7 @@ public class VariableSpeedDialog extends BottomSheetDialogFragment { public void onBindViewHolder(@NonNull ViewHolder holder, int position) { float speed = selectedSpeeds.get(position); - holder.chip.setText(speedFormat.format(speed)); + holder.chip.setText(String.format(Locale.getDefault(), "%1$.2f", speed)); holder.chip.setOnLongClickListener(v -> { selectedSpeeds.remove(speed); UserPreferences.setPlaybackSpeedArray(selectedSpeeds); diff --git a/app/src/main/java/de/danoeh/antennapod/view/viewholder/HorizontalItemViewHolder.java b/app/src/main/java/de/danoeh/antennapod/view/viewholder/HorizontalItemViewHolder.java index f809de175..21a29a920 100644 --- a/app/src/main/java/de/danoeh/antennapod/view/viewholder/HorizontalItemViewHolder.java +++ b/app/src/main/java/de/danoeh/antennapod/view/viewholder/HorizontalItemViewHolder.java @@ -65,6 +65,7 @@ public class HorizontalItemViewHolder extends RecyclerView.ViewHolder { .load(); title.setText(item.getTitle()); date.setText(DateFormatter.formatAbbrev(activity, item.getPubDate())); + date.setContentDescription(DateFormatter.formatForAccessibility(item.getPubDate())); ItemActionButton actionButton = ItemActionButton.forItem(item); actionButton.configure(secondaryActionIcon, secondaryActionIcon, activity); secondaryActionIcon.setFocusable(false); diff --git a/app/src/main/res/layout/addfeed.xml b/app/src/main/res/layout/addfeed.xml index 8082b9c8a..f2b7bed63 100644 --- a/app/src/main/res/layout/addfeed.xml +++ b/app/src/main/res/layout/addfeed.xml @@ -20,6 +20,7 @@ android:minHeight="?attr/actionBarSize" android:theme="?attr/actionBarTheme" app:title="@string/add_feed_label" + app:navigationContentDescription="@string/toolbar_back_button_content_description" app:navigationIcon="?homeAsUpIndicator" /> diff --git a/app/src/main/res/layout/episodes_list_fragment.xml b/app/src/main/res/layout/episodes_list_fragment.xml index 3d59bcddc..19b21f4f6 100644 --- a/app/src/main/res/layout/episodes_list_fragment.xml +++ b/app/src/main/res/layout/episodes_list_fragment.xml @@ -16,6 +16,7 @@ android:id="@+id/toolbar" android:layout_width="match_parent" android:layout_height="?attr/actionBarSize" + app:navigationContentDescription="@string/toolbar_back_button_content_description" app:navigationIcon="?homeAsUpIndicator" /> diff --git a/app/src/main/res/layout/feeditemlist_header.xml b/app/src/main/res/layout/feeditemlist_header.xml index 45f8e8ff8..0b7181cf2 100644 --- a/app/src/main/res/layout/feeditemlist_header.xml +++ b/app/src/main/res/layout/feeditemlist_header.xml @@ -16,55 +16,6 @@ android:orientation="horizontal" android:gravity="bottom"> - - - - - - - - - - - - + + + + + + + + + + + + diff --git a/app/src/main/res/layout/fragment_subscriptions.xml b/app/src/main/res/layout/fragment_subscriptions.xml index f60f925ab..ac40bf5a4 100644 --- a/app/src/main/res/layout/fragment_subscriptions.xml +++ b/app/src/main/res/layout/fragment_subscriptions.xml @@ -17,6 +17,7 @@ android:layout_width="match_parent" android:layout_height="?attr/actionBarSize" app:title="@string/subscriptions_label" + app:navigationContentDescription="@string/toolbar_back_button_content_description" app:navigationIcon="?homeAsUpIndicator" /> diff --git a/app/src/main/res/layout/search_fragment.xml b/app/src/main/res/layout/search_fragment.xml index 0d4ea6556..ff5de0f9f 100644 --- a/app/src/main/res/layout/search_fragment.xml +++ b/app/src/main/res/layout/search_fragment.xml @@ -19,6 +19,7 @@ android:minHeight="?attr/actionBarSize" android:theme="?attr/actionBarTheme" app:title="@string/search_label" + app:navigationContentDescription="@string/toolbar_back_button_content_description" app:navigationIcon="?homeAsUpIndicator" /> diff --git a/app/src/main/res/layout/simple_list_fragment.xml b/app/src/main/res/layout/simple_list_fragment.xml index fc08dccf2..bcc43cfcc 100644 --- a/app/src/main/res/layout/simple_list_fragment.xml +++ b/app/src/main/res/layout/simple_list_fragment.xml @@ -15,6 +15,7 @@ android:id="@+id/toolbar" android:layout_width="match_parent" android:layout_height="?attr/actionBarSize" + app:navigationContentDescription="@string/toolbar_back_button_content_description" app:navigationIcon="?homeAsUpIndicator" /> diff --git a/app/src/main/res/layout/subscription_item.xml b/app/src/main/res/layout/subscription_item.xml index 0b689fa28..d9a2800c1 100644 --- a/app/src/main/res/layout/subscription_item.xml +++ b/app/src/main/res/layout/subscription_item.xml @@ -82,6 +82,7 @@ android:gravity="start" android:textColor="?android:attr/textColorPrimary" android:lines="2" + android:importantForAccessibility="no" tools:text="@sample/episodes.json/data/title" /> diff --git a/ui/common/build.gradle b/ui/common/build.gradle index ff4bf83cf..0603eb711 100644 --- a/ui/common/build.gradle +++ b/ui/common/build.gradle @@ -4,6 +4,8 @@ plugins { apply from: "../../common.gradle" dependencies { + implementation project(":ui:i18n") + annotationProcessor "androidx.annotation:annotation:$annotationVersion" implementation "androidx.appcompat:appcompat:$appcompatVersion" implementation "androidx.viewpager2:viewpager2:$viewPager2Version" diff --git a/ui/common/src/main/res/layout/pager_fragment.xml b/ui/common/src/main/res/layout/pager_fragment.xml index a5bf6c76e..00525d57c 100644 --- a/ui/common/src/main/res/layout/pager_fragment.xml +++ b/ui/common/src/main/res/layout/pager_fragment.xml @@ -16,6 +16,7 @@ android:id="@+id/toolbar" android:layout_width="match_parent" android:layout_height="?attr/actionBarSize" + app:navigationContentDescription="@string/toolbar_back_button_content_description" app:navigationIcon="?homeAsUpIndicator" /> diff --git a/ui/i18n/src/main/res/values/strings.xml b/ui/i18n/src/main/res/values/strings.xml index 73423f4b5..a83ada10a 100644 --- a/ui/i18n/src/main/res/values/strings.xml +++ b/ui/i18n/src/main/res/values/strings.xml @@ -685,6 +685,8 @@ Play chapter Previous chapter Next chapter + Shuffle suggestions + Add preset Authentication -- cgit v1.2.3