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

Commit 481a7470 authored by Cosmin Băieș's avatar Cosmin Băieș Committed by Android (Google) Code Review
Browse files

Merge "Add accessibility labels for IME switcher button" into main

parents 7690c4f1 4a542161
Loading
Loading
Loading
Loading
+17 −2
Original line number Diff line number Diff line
@@ -22,6 +22,7 @@ import static android.view.KeyEvent.KEYCODE_UNKNOWN;
import static android.view.accessibility.AccessibilityNodeInfo.ACTION_CLICK;
import static android.view.accessibility.AccessibilityNodeInfo.ACTION_LONG_CLICK;

import android.annotation.Nullable;
import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Paint;
@@ -126,13 +127,27 @@ public class KeyButtonView extends ImageView implements ButtonInterface {
    @Override
    public void onInitializeAccessibilityNodeInfo(AccessibilityNodeInfo info) {
        super.onInitializeAccessibilityNodeInfo(info);
        if (mCode != KEYCODE_UNKNOWN) {
        if (isClickable()) {
            info.addAction(new AccessibilityNodeInfo.AccessibilityAction(ACTION_CLICK, null));
            if (isLongClickable()) {
                info.addAction(
                        new AccessibilityNodeInfo.AccessibilityAction(ACTION_LONG_CLICK, null));
                        new AccessibilityNodeInfo.AccessibilityAction(ACTION_LONG_CLICK,
                                getAccessibilityLongClickActionLabel()));
            }
        }
    }

    /**
     * Gets the accessibility long click action label for the button, or {@code null} for no label.
     */
    @Nullable
    private CharSequence getAccessibilityLongClickActionLabel() {
        if (Flags.imeSwitcherRevamp()
                && getId() == com.android.internal.R.id.input_method_nav_ime_switcher) {
            return getContext().getText(
                    com.android.internal.R.string.input_method_ime_switch_long_click_action_desc);
        }
        return null;
    }

    @Override
+2 −1
Original line number Diff line number Diff line
@@ -51,7 +51,8 @@
        <Space
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            android:layout_weight="1"/>
            android:layout_weight="1"
            android:importantForAccessibility="no"/>

        <Button
            style="?attr/buttonBarButtonStyle"
+4 −2
Original line number Diff line number Diff line
@@ -31,7 +31,8 @@
        android:layout_marginTop="8dp"
        android:layout_marginEnd="24dp"
        android:layout_marginBottom="12dp"
        android:visibility="gone"/>
        android:visibility="gone"
        android:importantForAccessibility="no"/>

    <TextView
        android:id="@+id/header_text"
@@ -81,7 +82,8 @@
            android:layout_marginStart="12dp"
            android:src="@drawable/ic_check_24dp"
            android:tint="?attr/materialColorOnSurface"
            android:visibility="gone"/>
            android:visibility="gone"
            android:importantForAccessibility="no"/>

    </LinearLayout>

+3 −0
Original line number Diff line number Diff line
@@ -3277,6 +3277,9 @@
    <string name="input_method_nav_back_button_desc">Back</string>
    <!-- Content description of the switch input method button for accessibility (not shown on the screen). [CHAR LIMIT=NONE] -->
    <string name="input_method_ime_switch_button_desc">Switch input method</string>
    <!-- Accessibility text for the long click action on the switch input method button. This will
         be used following "Double-tap and hold to..." [CHAR LIMIT=NONE] -->
    <string name="input_method_ime_switch_long_click_action_desc">Open input method picker</string>

    <!-- If the device is getting low on internal storage, a notification is shown to the user.  This is the title of that notification. -->
    <string name="low_internal_storage_view_title">Storage space running out</string>
+1 −0
Original line number Diff line number Diff line
@@ -2245,6 +2245,7 @@
  <java-symbol type="string" name="heavy_weight_notification_detail" />
  <java-symbol type="string" name="image_wallpaper_component" />
  <java-symbol type="string" name="input_method_binding_label" />
  <java-symbol type="string" name="input_method_ime_switch_long_click_action_desc" />
  <java-symbol type="string" name="launch_warning_original" />
  <java-symbol type="string" name="launch_warning_replace" />
  <java-symbol type="string" name="launch_warning_title" />
Loading