Merge "Update accessibility hint for widget cell that shows add button." into main
This commit is contained in:
commit
2909e72d36
4 files changed
+33
-1
No files matched your search
@@ -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
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -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) {
|
||||
|
||||
Reference in new issue
Block a user