mirror of
https://github.com/ArcaneChat/android.git
synced 2026-07-03 14:05:24 +02:00
Use internationalized string for accessibility link label
- Added accessibility_link_action string resource - Updated LinkAccessibilityDelegate to accept Context and use resource - Updated ConversationItem to pass context to delegate Co-authored-by: adbenitez <24558636+adbenitez@users.noreply.github.com>
This commit is contained in:
@@ -432,7 +432,7 @@ public class ConversationItem extends BaseConversationItem
|
||||
|
||||
// Set accessibility delegate for TalkBack to expose links as custom actions
|
||||
if (Util.isTouchExplorationEnabled(context) && batchSelected.isEmpty()) {
|
||||
bodyText.setAccessibilityDelegate(new LinkAccessibilityDelegate());
|
||||
bodyText.setAccessibilityDelegate(new LinkAccessibilityDelegate(context));
|
||||
} else {
|
||||
bodyText.setAccessibilityDelegate(null);
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package org.thoughtcrime.securesms.util;
|
||||
|
||||
import android.content.Context;
|
||||
import android.os.Bundle;
|
||||
import android.text.Spanned;
|
||||
import android.view.View;
|
||||
@@ -8,6 +9,8 @@ import android.widget.TextView;
|
||||
|
||||
import androidx.core.view.accessibility.AccessibilityNodeInfoCompat;
|
||||
|
||||
import org.thoughtcrime.securesms.R;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
@@ -22,6 +25,12 @@ public class LinkAccessibilityDelegate extends View.AccessibilityDelegate {
|
||||
|
||||
// Map to store span references for each action ID
|
||||
private final Map<Integer, LongClickCopySpan> actionSpanMap = new HashMap<>();
|
||||
|
||||
private final Context context;
|
||||
|
||||
public LinkAccessibilityDelegate(Context context) {
|
||||
this.context = context;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onInitializeAccessibilityNodeInfo(View host, AccessibilityNodeInfo info) {
|
||||
@@ -52,7 +61,7 @@ public class LinkAccessibilityDelegate extends View.AccessibilityDelegate {
|
||||
|
||||
if (start >= 0 && end > start && end <= spanned.length()) {
|
||||
String linkText = spanned.subSequence(start, end).toString();
|
||||
String label = "Open link: " + linkText;
|
||||
String label = context.getString(R.string.accessibility_link_action, linkText);
|
||||
|
||||
// Create a unique action ID for each link
|
||||
final int actionId = LINK_ACTION_BASE_ID + i;
|
||||
|
||||
Reference in New Issue
Block a user