Commit 946d7072 authored by Alice Wang's avatar Alice Wang Committed by Commit Bot

[Android][WebSignin] Use more specific accessibility strings

This CL replaces the generic accessibility strings with more specific
ones in the web sign-in bottom sheet.

Bug: 1112696
Change-Id: I1dff9637b8df04a0f0f8c03940d21099196c3078
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2502431Reviewed-by: default avatarMatthew Jones <mdjones@chromium.org>
Commit-Queue: Alice Wang <aliceywang@chromium.org>
Cr-Commit-Position: refs/heads/master@{#825287}
parent bbe8da9b
......@@ -12,6 +12,7 @@ import android.widget.ProgressBar;
import android.widget.TextView;
import androidx.annotation.Nullable;
import androidx.annotation.StringRes;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
......@@ -53,6 +54,9 @@ class AccountPickerBottomSheetView implements BottomSheetContent {
private final ButtonCompat mContinueAsButton;
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 backPressListener The listener to be notified when the user taps the back button.
......@@ -79,6 +83,12 @@ class AccountPickerBottomSheetView implements BottomSheetContent {
mDismissButton = mContentView.findViewById(R.id.account_picker_dismiss_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.
*/
......@@ -281,29 +291,23 @@ class AccountPickerBottomSheetView implements BottomSheetContent {
@Override
public int getSheetContentDescriptionStringId() {
// TODO(https://crbug.com/1081253): The description will
// be adapter once the UI mock will be finalized
return R.string.signin_account_picker_dialog_title;
return mContentDescriptionId;
}
@Override
public int getSheetHalfHeightAccessibilityStringId() {
// TODO(https://crbug.com/1081253): The description will
// be adapter once the UI mock will be finalized
return R.string.signin_account_picker_dialog_title;
return mTitleId;
}
@Override
public int getSheetFullHeightAccessibilityStringId() {
// TODO(https://crbug.com/1081253): The description will
// be adapter once the UI mock will be finalized
return R.string.signin_account_picker_dialog_title;
return mTitleId;
}
@Override
public int getSheetClosedAccessibilityStringId() {
// TODO(https://crbug.com/1081253): The description will
// be adapter once the UI mock will be finalized
return R.string.signin_account_picker_dialog_title;
// TODO(https://crbug.com/1112696): Use more specific string to when the account
// picker is closed.
return R.string.close;
}
}
......@@ -4,6 +4,10 @@
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.DisplayableProfileData;
import org.chromium.chrome.browser.signin.account_picker.AccountPickerBottomSheetProperties.ViewState;
import org.chromium.ui.modelutil.PropertyKey;
......@@ -48,6 +52,8 @@ class AccountPickerBottomSheetViewBinder {
* {@link ViewState}.
*/
private static void switchToState(AccountPickerBottomSheetView view, @ViewState int viewState) {
view.setTitleAndContentDescriptionStrings(getTitleId(viewState), getSubtitleId(viewState));
switch (viewState) {
case ViewState.NO_ACCOUNTS:
view.collapseToNoAccountView();
......@@ -76,5 +82,42 @@ 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() {}
}
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