Set accessibility action label for smart replies.

Currently the TalkBack reads something like "I am here, button,
double-tap to activate". Set an accessiblity delegate that changes
the click action label to "send", so the TalkBack message becomes
"I am here, button, double-tap to send".

Bug: 72216277
Test: In Notify post a notification with choices. Read it via TalkBack.
Change-Id: Ib50f6ff6f698196d905aea2e303b6bd2e5531587
This commit is contained in:
Milo Sredkov
2018-04-17 14:04:54 +01:00
parent 73abd2717e
commit 66da07bf81
2 changed files with 13 additions and 0 deletions

View File

@@ -240,6 +240,8 @@
<string name="accessibility_waiting_for_fingerprint">Waiting for fingerprint</string>
<!-- Accessibility action of the unlock button when fingerpint is on (not shown on the screen). [CHAR LIMIT=NONE] -->
<string name="accessibility_unlock_without_fingerprint">Unlock without using your fingerprint</string>
<!-- Click action label for accessibility for the smart reply buttons (not shown on-screen).". [CHAR LIMIT=NONE] -->
<string name="accessibility_send_smart_reply">Send</string>
<!-- Click action label for accessibility for the unlock button. [CHAR LIMIT=NONE] -->
<string name="unlock_label">unlock</string>
<!-- Click action label for accessibility for the phone button. [CHAR LIMIT=NONE] -->

View File

@@ -17,6 +17,8 @@ import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.accessibility.AccessibilityNodeInfo;
import android.view.accessibility.AccessibilityNodeInfo.AccessibilityAction;
import android.widget.Button;
import com.android.internal.annotations.VisibleForTesting;
@@ -179,6 +181,15 @@ public class SmartReplyView extends ViewGroup {
mKeyguardDismissUtil.dismissKeyguardThenExecute(
action, null /* cancelAction */, false /* afterKeyguardGone */);
});
b.setAccessibilityDelegate(new AccessibilityDelegate() {
public void onInitializeAccessibilityNodeInfo(View host, AccessibilityNodeInfo info) {
super.onInitializeAccessibilityNodeInfo(host, info);
String label = getResources().getString(R.string.accessibility_send_smart_reply);
info.addAction(new AccessibilityAction(AccessibilityNodeInfo.ACTION_CLICK, label));
}
});
return b;
}