Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 66da07bf authored by Milo Sredkov's avatar Milo Sredkov
Browse files

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
parent 73abd271
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -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] -->
+11 −0
Original line number Diff line number Diff line
@@ -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;
    }