Commit b8b242f8 authored by Alice Wang's avatar Alice Wang Committed by Chromium LUCI CQ

[Android][WebSignin] Announce screen title when new screen opens

This CL make account picker bottom sheet announces the title when
a new screen opens.


Bug: 1144826, 1143259
Change-Id: I6e5b28733d0d6dfd99b4d1ed36e1e8de799f846c
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2565533Reviewed-by: default avatarTheresa  <twellington@chromium.org>
Reviewed-by: default avatarMatthew Jones <mdjones@chromium.org>
Commit-Queue: Alice Wang <aliceywang@chromium.org>
Cr-Commit-Position: refs/heads/master@{#833360}
parent a8a19e64
...@@ -15,6 +15,7 @@ ...@@ -15,6 +15,7 @@
app:srcCompat="@drawable/chrome_sync_logo" /> app:srcCompat="@drawable/chrome_sync_logo" />
<TextView <TextView
android:id="@+id/account_picker_header_title"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginTop="12dp" android:layout_marginTop="12dp"
......
...@@ -18,6 +18,7 @@ ...@@ -18,6 +18,7 @@
app:srcCompat="@drawable/ic_warning_red_24dp" /> app:srcCompat="@drawable/ic_warning_red_24dp" />
<TextView <TextView
android:id="@+id/account_picker_auth_error_title"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginTop="12dp" android:layout_marginTop="12dp"
......
...@@ -18,6 +18,7 @@ ...@@ -18,6 +18,7 @@
app:srcCompat="@drawable/ic_warning_red_24dp" /> app:srcCompat="@drawable/ic_warning_red_24dp" />
<TextView <TextView
android:id="@+id/account_picker_general_error_title"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginTop="12dp" android:layout_marginTop="12dp"
......
...@@ -18,6 +18,7 @@ ...@@ -18,6 +18,7 @@
app:srcCompat="@drawable/chrome_sync_logo" /> app:srcCompat="@drawable/chrome_sync_logo" />
<TextView <TextView
android:id="@+id/account_picker_signin_in_progress_title"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginTop="12dp" android:layout_marginTop="12dp"
......
...@@ -8,6 +8,7 @@ import android.app.Activity; ...@@ -8,6 +8,7 @@ import android.app.Activity;
import android.view.LayoutInflater; import android.view.LayoutInflater;
import android.view.View; import android.view.View;
import android.view.View.OnClickListener; import android.view.View.OnClickListener;
import android.view.accessibility.AccessibilityEvent;
import android.widget.ImageView; import android.widget.ImageView;
import android.widget.ViewFlipper; import android.widget.ViewFlipper;
...@@ -42,6 +43,21 @@ class AccountPickerBottomSheetView implements BottomSheetContent { ...@@ -42,6 +43,21 @@ class AccountPickerBottomSheetView implements BottomSheetContent {
boolean onBackPressed(); boolean onBackPressed();
} }
/**
* The title id for each screen of the bottom sheet's view flipper, the position of
* each id corresponds to the value of {@link ViewState}. It is used to set focus
* on title when the view flipper moves to a new screen.
*/
private static final @IdRes int[] sTitleIds = new int[] {
R.id.account_picker_header_title,
R.id.account_picker_header_title,
R.id.account_picker_header_title,
R.id.account_picker_signin_in_progress_title,
R.id.incognito_interstitial_title,
R.id.account_picker_general_error_title,
R.id.account_picker_auth_error_title,
};
private final Activity mActivity; private final Activity mActivity;
private final BackPressListener mBackPressListener; private final BackPressListener mBackPressListener;
private final View mContentView; private final View mContentView;
...@@ -50,9 +66,6 @@ class AccountPickerBottomSheetView implements BottomSheetContent { ...@@ -50,9 +66,6 @@ class AccountPickerBottomSheetView implements BottomSheetContent {
private final View mSelectedAccountView; private final View mSelectedAccountView;
private final ButtonCompat mDismissButton; private final ButtonCompat mDismissButton;
private @StringRes int mTitleId;
private @StringRes int mContentDescriptionId;
/** /**
* @param activity The activity that hosts this view. Used for inflating views. * @param activity The activity that hosts this view. Used for inflating views.
* @param backPressListener The listener to be notified when the user taps the back button. * @param backPressListener The listener to be notified when the user taps the back button.
...@@ -87,12 +100,6 @@ class AccountPickerBottomSheetView implements BottomSheetContent { ...@@ -87,12 +100,6 @@ class AccountPickerBottomSheetView implements BottomSheetContent {
R.string.auth_error_card_button); R.string.auth_error_card_button);
} }
void setTitleAndContentDescriptionStrings(
@StringRes int titleId, @StringRes @Nullable Integer subtitleId) {
mTitleId = titleId;
mContentDescriptionId = subtitleId != null ? subtitleId : titleId;
}
/** /**
* The account list view is visible when the account list is expanded. * The account list view is visible when the account list is expanded.
*/ */
...@@ -140,6 +147,8 @@ class AccountPickerBottomSheetView implements BottomSheetContent { ...@@ -140,6 +147,8 @@ class AccountPickerBottomSheetView implements BottomSheetContent {
*/ */
void setDisplayedView(@ViewState int state) { void setDisplayedView(@ViewState int state) {
mViewFlipper.setDisplayedChild(state); mViewFlipper.setDisplayedChild(state);
View titleView = mViewFlipper.getChildAt(state).findViewById(sTitleIds[state]);
titleView.sendAccessibilityEvent(AccessibilityEvent.TYPE_VIEW_FOCUSED);
} }
/** /**
...@@ -208,22 +217,27 @@ class AccountPickerBottomSheetView implements BottomSheetContent { ...@@ -208,22 +217,27 @@ class AccountPickerBottomSheetView implements BottomSheetContent {
@Override @Override
public int getSheetContentDescriptionStringId() { public int getSheetContentDescriptionStringId() {
return mContentDescriptionId; // TODO(https://crbug.com/1112696): Use more specific string
// account picker content description
return R.string.signin_account_picker_bottom_sheet_subtitle;
} }
@Override @Override
public int getSheetHalfHeightAccessibilityStringId() { public int getSheetHalfHeightAccessibilityStringId() {
return mTitleId; return R.string.signin_account_picker_dialog_title;
} }
@Override @Override
public int getSheetFullHeightAccessibilityStringId() { public int getSheetFullHeightAccessibilityStringId() {
return mTitleId; // TODO(https://crbug.com/1112696): Use more specific string
// like |Open account picker bottom sheet...| when bottom sheet opens
// after a11y meeting
return R.string.signin_account_picker_dialog_title;
} }
@Override @Override
public int getSheetClosedAccessibilityStringId() { public int getSheetClosedAccessibilityStringId() {
// TODO(https://crbug.com/1112696): Use more specific string to when the account // TODO(https://crbug.com/1112696): Use more specific string when the account
// picker is closed. // picker is closed.
return R.string.close; return R.string.close;
} }
......
...@@ -4,10 +4,6 @@ ...@@ -4,10 +4,6 @@
package org.chromium.chrome.browser.signin.account_picker; package org.chromium.chrome.browser.signin.account_picker;
import androidx.annotation.Nullable;
import androidx.annotation.StringRes;
import org.chromium.chrome.R;
import org.chromium.chrome.browser.signin.account_picker.AccountPickerBottomSheetProperties.ViewState; import org.chromium.chrome.browser.signin.account_picker.AccountPickerBottomSheetProperties.ViewState;
import org.chromium.chrome.browser.signin.services.DisplayableProfileData; import org.chromium.chrome.browser.signin.services.DisplayableProfileData;
import org.chromium.ui.modelutil.PropertyKey; import org.chromium.ui.modelutil.PropertyKey;
...@@ -25,8 +21,6 @@ class AccountPickerBottomSheetViewBinder { ...@@ -25,8 +21,6 @@ class AccountPickerBottomSheetViewBinder {
} else if (propertyKey == AccountPickerBottomSheetProperties.VIEW_STATE) { } else if (propertyKey == AccountPickerBottomSheetProperties.VIEW_STATE) {
@ViewState @ViewState
int viewState = model.get(AccountPickerBottomSheetProperties.VIEW_STATE); int viewState = model.get(AccountPickerBottomSheetProperties.VIEW_STATE);
view.setTitleAndContentDescriptionStrings(
getTitleId(viewState), getSubtitleId(viewState));
view.setDisplayedView(viewState); view.setDisplayedView(viewState);
} else if (propertyKey == AccountPickerBottomSheetProperties.SELECTED_ACCOUNT_DATA) { } else if (propertyKey == AccountPickerBottomSheetProperties.SELECTED_ACCOUNT_DATA) {
DisplayableProfileData profileData = DisplayableProfileData profileData =
...@@ -43,42 +37,5 @@ class AccountPickerBottomSheetViewBinder { ...@@ -43,42 +37,5 @@ class AccountPickerBottomSheetViewBinder {
} }
} }
private static @StringRes int getTitleId(@ViewState int viewState) {
switch (viewState) {
case ViewState.NO_ACCOUNTS:
case ViewState.COLLAPSED_ACCOUNT_LIST:
case ViewState.EXPANDED_ACCOUNT_LIST:
return R.string.signin_account_picker_dialog_title;
case ViewState.SIGNIN_IN_PROGRESS:
return R.string.signin_account_picker_bottom_sheet_signin_title;
case ViewState.INCOGNITO_INTERSTITIAL:
return R.string.incognito_interstitial_title;
case ViewState.SIGNIN_GENERAL_ERROR:
case ViewState.SIGNIN_AUTH_ERROR:
return R.string.signin_account_picker_bottom_sheet_error_title;
default:
throw new IllegalArgumentException("Unknown ViewState:" + viewState);
}
}
private static @Nullable @StringRes Integer getSubtitleId(@ViewState int viewState) {
switch (viewState) {
case ViewState.NO_ACCOUNTS:
case ViewState.COLLAPSED_ACCOUNT_LIST:
case ViewState.EXPANDED_ACCOUNT_LIST:
return R.string.signin_account_picker_bottom_sheet_subtitle;
case ViewState.INCOGNITO_INTERSTITIAL:
return R.string.incognito_interstitial_message;
case ViewState.SIGNIN_GENERAL_ERROR:
return R.string.signin_account_picker_general_error_subtitle;
case ViewState.SIGNIN_AUTH_ERROR:
return R.string.signin_account_picker_auth_error_subtitle;
case ViewState.SIGNIN_IN_PROGRESS:
return null;
default:
throw new IllegalArgumentException("Unknown ViewState:" + viewState);
}
}
private AccountPickerBottomSheetViewBinder() {} private AccountPickerBottomSheetViewBinder() {}
} }
...@@ -19,6 +19,7 @@ ...@@ -19,6 +19,7 @@
app:srcCompat="@drawable/ic_incognito_filled_24dp" /> app:srcCompat="@drawable/ic_incognito_filled_24dp" />
<TextView <TextView
android:id="@+id/incognito_interstitial_title"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginTop="12dp" android:layout_marginTop="12dp"
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment