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

Commit 0e668e1b authored by Shamali P's avatar Shamali P
Browse files

Update accessibility hint for widget cell that shows add button.

With tap to add feature, tapping widget cell reveals add button.

So, clarify the intent with ACTION_CLICK

Bug: 374033389
Test: Talkback
Flag: EXEMPT BUGFIX
Change-Id: I03e47241fbc16f1354394e3a6fd412998642e6cf
parent 9fdf9efd
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
@@ -154,6 +154,10 @@
    <!-- A widget category label for grouping widgets related to note taking. [CHAR_LIMIT=30] -->
    <string name="widget_category_note_taking">Note-taking</string>

    <!-- Accessibility label on the widget preview that on click (if add button is hidden) shows the button to add widget to the home screen. [CHAR_LIMIT=none] -->
    <string name="widget_cell_tap_to_show_add_button_label">Show add button</string>
    <!-- Accessibility label on the widget preview that on click (if add button is showing) hides the button to add widget to the home screen. [CHAR_LIMIT=none] -->
    <string name="widget_cell_tap_to_hide_add_button_label">Hide add button</string>
    <!-- Text on the button that adds a widget to the home screen. [CHAR_LIMIT=15] -->
    <string name="widget_add_button_label">Add</string>
    <!-- Accessibility content description for the button that adds a widget to the home screen. The
+16 −0
Original line number Diff line number Diff line
@@ -17,6 +17,7 @@
package com.android.launcher3.widget;

import static android.appwidget.AppWidgetProviderInfo.WIDGET_CATEGORY_HOME_SCREEN;
import static android.view.accessibility.AccessibilityNodeInfo.ACTION_CLICK;

import static com.android.launcher3.Flags.enableWidgetTapToAdd;
import static com.android.launcher3.LauncherSettings.Favorites.CONTAINER_WIDGETS_TRAY;
@@ -40,6 +41,7 @@ import android.view.MotionEvent;
import android.view.View;
import android.view.ViewGroup;
import android.view.ViewPropertyAnimator;
import android.view.accessibility.AccessibilityNodeInfo;
import android.widget.Button;
import android.widget.FrameLayout;
import android.widget.LinearLayout;
@@ -154,7 +156,21 @@ public class WidgetCell extends LinearLayout {
        mWidgetDescription = findViewById(R.id.widget_description);
        mWidgetTextContainer = findViewById(R.id.widget_text_container);
        mWidgetAddButton = findViewById(R.id.widget_add_button);

        if (enableWidgetTapToAdd()) {

            setAccessibilityDelegate(new AccessibilityDelegate() {
                @Override
                public void onInitializeAccessibilityNodeInfo(View host,
                        AccessibilityNodeInfo info) {
                    super.onInitializeAccessibilityNodeInfo(host, info);
                    String accessibilityLabel = getResources().getString(mWidgetAddButton.isShown()
                            ? R.string.widget_cell_tap_to_hide_add_button_label
                            : R.string.widget_cell_tap_to_show_add_button_label);
                    info.addAction(new AccessibilityNodeInfo.AccessibilityAction(ACTION_CLICK,
                            accessibilityLabel));
                }
            });
            mWidgetAddButton.setVisibility(INVISIBLE);
        }
    }
+1 −1
Original line number Diff line number Diff line
@@ -123,7 +123,7 @@ public class AddConfigWidgetTest extends BaseLauncherActivityTest<Launcher> {
                v instanceof WidgetCell
                        && v.getTag() instanceof PendingAddWidgetInfo pawi
                        && mWidgetInfo.provider.equals(pawi.componentName)));
        addToWorkspace(widgetView);
        addWidgetToWorkspace(widgetView);

        // Widget id for which the config activity was opened
        mWidgetId = monitor.getWidgetId();
+12 −0
Original line number Diff line number Diff line
@@ -170,6 +170,18 @@ open class BaseLauncherActivityTest<LAUNCHER_TYPE : Launcher> {
        UiDevice.getInstance(getInstrumentation()).waitForIdle()
    }

    /**
     * Match the behavior with how widget is added in reality with "tap to add" (even with screen
     * readers).
     */
    fun addWidgetToWorkspace(view: View) {
        executeOnLauncher {
            view.performClick()
            UiDevice.getInstance(getInstrumentation()).waitForIdle()
            view.findViewById<View>(R.id.widget_add_button).performClick()
        }
    }

    fun ViewGroup.searchView(filter: Predicate<View>): View? {
        if (filter.test(this)) return this
        for (child in children) {