Merge changes from topic "sug-a11y" into main

* changes:
  Adjust tap target of the profile tabs in picker
  Focus on first item to match the behavior with widgets list
This commit is contained in:
Shamali Patwa
2024-08-20 21:50:44 +00:00
committed by Android (Google) Code Review
4 changed files with 43 additions and 46 deletions
+33 -30
View File
@@ -13,36 +13,39 @@
See the License for the specific language governing permissions and
limitations under the License.
-->
<ripple xmlns:android="http://schemas.android.com/apk/res/android"
android:color="@color/accent_ripple_color">
<inset xmlns:android="http://schemas.android.com/apk/res/android"
android:insetBottom="@dimen/widget_apps_tabs_vertical_padding"
android:insetTop="@dimen/widget_apps_tabs_vertical_padding">
<ripple
android:color="@color/accent_ripple_color">
<item android:id="@android:id/mask">
<shape android:shape="rectangle">
<corners android:radius="@dimen/all_apps_header_pill_corner_radius" />
<solid android:color="@color/accent_ripple_color" />
</shape>
</item>
<item android:id="@android:id/mask">
<shape android:shape="rectangle">
<corners android:radius="@dimen/all_apps_header_pill_corner_radius" />
<solid android:color="@color/accent_ripple_color" />
</shape>
</item>
<item>
<selector android:enterFadeDuration="100">
<item
android:id="@+id/unselected"
android:state_selected="false">
<shape android:shape="rectangle">
<corners android:radius="@dimen/all_apps_header_pill_corner_radius" />
<solid android:color="?attr/widgetPickerTabBackgroundUnselected"/>
</shape>
</item>
<item>
<selector android:enterFadeDuration="100">
<item
android:id="@+id/unselected"
android:state_selected="false">
<shape android:shape="rectangle">
<corners android:radius="@dimen/all_apps_header_pill_corner_radius" />
<solid android:color="?attr/widgetPickerTabBackgroundUnselected" />
</shape>
</item>
<item
android:id="@+id/selected"
android:state_selected="true">
<shape android:shape="rectangle">
<corners android:radius="@dimen/all_apps_header_pill_corner_radius" />
<solid android:color="?attr/widgetPickerTabBackgroundSelected"/>
</shape>
</item>
</selector>
</item>
</ripple>
<item
android:id="@+id/selected"
android:state_selected="true">
<shape android:shape="rectangle">
<corners android:radius="@dimen/all_apps_header_pill_corner_radius" />
<solid android:color="?attr/widgetPickerTabBackgroundSelected" />
</shape>
</item>
</selector>
</item>
</ripple>
</inset>
@@ -104,7 +104,6 @@
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_marginEnd="@dimen/widget_tabs_button_horizontal_padding"
android:layout_marginVertical="@dimen/widget_apps_tabs_vertical_padding"
android:layout_weight="1"
android:background="@drawable/widget_picker_tabs_background"
android:text="@string/widgets_full_sheet_personal_tab"
@@ -117,7 +116,6 @@
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_marginEnd="@dimen/widget_tabs_button_horizontal_padding"
android:layout_marginVertical="@dimen/widget_apps_tabs_vertical_padding"
android:layout_weight="1"
android:background="@drawable/widget_picker_tabs_background"
android:text="@string/widgets_full_sheet_work_tab"
@@ -115,7 +115,6 @@
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_marginEnd="@dimen/widget_tabs_button_horizontal_padding"
android:layout_marginVertical="@dimen/widget_apps_tabs_vertical_padding"
android:layout_weight="1"
android:background="@drawable/widget_picker_tabs_background"
android:text="@string/widgets_full_sheet_personal_tab"
@@ -128,7 +127,6 @@
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_marginEnd="@dimen/widget_tabs_button_horizontal_padding"
android:layout_marginVertical="@dimen/widget_apps_tabs_vertical_padding"
android:layout_weight="1"
android:background="@drawable/widget_picker_tabs_background"
android:text="@string/widgets_full_sheet_work_tab"
@@ -376,17 +376,14 @@ public class WidgetsTwoPaneSheet extends WidgetsFullSheet {
mSuggestedWidgetsPackageUserKey = PackageUserKey.fromPackageItemInfo(packageItemInfo);
final boolean isChangingHeaders = mSelectedHeader == null
|| !mSelectedHeader.equals(mSuggestedWidgetsPackageUserKey);
// If the initial focus view is still focused, it is likely a programmatic header
// click.
if (mSelectedHeader != null
&& !getAccessibilityInitialFocusView().isAccessibilityFocused()) {
post(() -> {
mRightPaneScrollView.setAccessibilityPaneTitle(suggestionsRightPaneTitle);
mRightPaneScrollView.performAccessibilityAction(
AccessibilityNodeInfo.ACTION_ACCESSIBILITY_FOCUS, null);
});
}
if (isChangingHeaders) {
// If the initial focus view is still focused or widget picker is still opening, it
// is likely a programmatic header click.
if (mSelectedHeader != null && !mOpenCloseAnimation.getAnimationPlayer().isRunning()
&& !getAccessibilityInitialFocusView().isAccessibilityFocused()) {
mRightPaneScrollView.setAccessibilityPaneTitle(suggestionsRightPaneTitle);
focusOnFirstWidgetCell(mWidgetRecommendationsView);
}
// If switching from another header, unselect any WidgetCells. This is necessary
// because we do not clear/recycle the WidgetCells in the recommendations container
// when the header is clicked, only when onRecommendationsBound is called. That
@@ -505,9 +502,10 @@ public class WidgetsTwoPaneSheet extends WidgetsFullSheet {
public void onHeaderChanged(@NonNull PackageUserKey selectedHeader) {
final boolean isSameHeader = mSelectedHeader != null
&& mSelectedHeader.equals(selectedHeader);
// If the initial focus view is still focused, it is likely a programmatic header
// click.
// If the initial focus view is still focused or widget picker is still opening, it
// is likely a programmatic header click.
final boolean isUserClick = mSelectedHeader != null
&& !mOpenCloseAnimation.getAnimationPlayer().isRunning()
&& !getAccessibilityInitialFocusView().isAccessibilityFocused();
mSelectedHeader = selectedHeader;
final boolean showDefaultWidgets = mWidgetOptionsMenuState != null