mirror of
https://codeberg.org/tom79/Fedilab.git
synced 2025-09-15 08:20:18 +03:00
Improve accessibility of translated content
- Focus translated content after original content - Make the whole translation container focusable - Set a minimum height limit to translated text - Improve content description of translated text
This commit is contained in:
parent
54dd37bd22
commit
2477f5b75a
3 changed files with 16 additions and 8 deletions
|
@ -57,6 +57,7 @@ import android.os.CountDownTimer;
|
|||
import android.os.Handler;
|
||||
import android.os.Looper;
|
||||
import android.text.Html;
|
||||
import android.text.Spannable;
|
||||
import android.text.SpannableString;
|
||||
import android.text.TextUtils;
|
||||
import android.util.TypedValue;
|
||||
|
@ -1602,12 +1603,12 @@ public class StatusAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder>
|
|||
}
|
||||
if (statusToDeal.translationContent != null) {
|
||||
holder.binding.containerTrans.setVisibility(View.VISIBLE);
|
||||
holder.binding.statusContentTranslated.setText(
|
||||
statusToDeal.getSpanTranslate(context,
|
||||
new WeakReference<>(holder.binding.statusContentTranslated), () -> {
|
||||
recyclerView.post(() -> adapter.notifyItemChanged(holder.getBindingAdapterPosition()));
|
||||
}),
|
||||
TextView.BufferType.SPANNABLE);
|
||||
Spannable translatedText = statusToDeal.getSpanTranslate(context,
|
||||
new WeakReference<>(holder.binding.statusContentTranslated), () -> {
|
||||
recyclerView.post(() -> adapter.notifyItemChanged(holder.getBindingAdapterPosition()));
|
||||
});
|
||||
holder.binding.statusContentTranslated.setText(translatedText, TextView.BufferType.SPANNABLE);
|
||||
holder.binding.containerTrans.setContentDescription(context.getString(R.string.cd_translated_content, translatedText));
|
||||
} else {
|
||||
holder.binding.containerTrans.setVisibility(View.GONE);
|
||||
}
|
||||
|
|
|
@ -310,6 +310,8 @@
|
|||
android:layout_marginStart="48dp"
|
||||
android:layout_marginTop="6dp"
|
||||
android:layout_marginEnd="6dp"
|
||||
android:focusable="true"
|
||||
android:importantForAccessibility="yes"
|
||||
android:orientation="vertical"
|
||||
android:visibility="gone"
|
||||
tools:visibility="visible">
|
||||
|
@ -332,12 +334,12 @@
|
|||
|
||||
<TextView
|
||||
android:id="@+id/translation_label"
|
||||
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="10dp"
|
||||
android:background="?colorSurface"
|
||||
android:elevation="2dp"
|
||||
android:importantForAccessibility="no"
|
||||
android:paddingStart="2dp"
|
||||
android:paddingEnd="2dp"
|
||||
android:text="@string/translation"
|
||||
|
@ -352,9 +354,13 @@
|
|||
android:layout_marginTop="4dp"
|
||||
android:layout_marginEnd="8dp"
|
||||
android:layout_marginBottom="4dp"
|
||||
android:importantForAccessibility="no"
|
||||
android:minHeight="48dp"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/translation_label"
|
||||
app:layout_goneMarginBottom="8dp" />
|
||||
app:layout_goneMarginBottom="8dp"
|
||||
tools:maxLines="4"
|
||||
tools:text="@tools:sample/lorem/random" />
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
|
||||
|
|
|
@ -82,6 +82,7 @@
|
|||
<string name="tab_local_timeline">@string/local_menu</string>
|
||||
<string name="tab_public_timeline">Public timeline</string>
|
||||
<string name="tab_private_mentions">Private mentions</string>
|
||||
<string name="cd_translated_content">Translated content: %s</string>
|
||||
|
||||
<!-- Status -->
|
||||
<string name="no_status">No message to display</string>
|
||||
|
|
Loading…
Reference in a new issue