Commit 03a986b7 authored by Rohit Agarwal's avatar Rohit Agarwal Committed by Commit Bot

Add incognito interstitial in the AccountPickerBottomSheet.

In the Account picker Dialog we had implemented an option for users
to sign in temporarily via Incognito mode.

This CL adds the functionality of showing an incognito interstitial when
the user clicks on the incognito mode button.

The incognito interstitial is currently blank expect the Learn more
and Continue buttons. The functionality of these buttons and the
contents of the interstitial would be followed up later.

This CL also adds tests to ensure the UI elements of the incognito
interstitial are shown properly and the state switch happened smoothly
and didn't leave any past UI elements.

TBR=bsazonov@chromium.org

Bug: 1103262
Change-Id: I031b505fe347afb3265da4921c002a702a022421
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2346645Reviewed-by: default avatarRohit Agarwal <roagarwal@chromium.org>
Reviewed-by: default avatarAlice Wang <aliceywang@chromium.org>
Commit-Queue: Rohit Agarwal <roagarwal@chromium.org>
Cr-Commit-Position: refs/heads/master@{#798566}
parent 0a0ad92f
...@@ -915,6 +915,7 @@ chrome_java_resources = [ ...@@ -915,6 +915,7 @@ chrome_java_resources = [
"java/res/layout/homepage_editor.xml", "java/res/layout/homepage_editor.xml",
"java/res/layout/icon_row_menu_footer.xml", "java/res/layout/icon_row_menu_footer.xml",
"java/res/layout/incognito_description_layout.xml", "java/res/layout/incognito_description_layout.xml",
"java/res/layout/incognito_interstitial_bottom_sheet_view.xml",
"java/res/layout/incognito_toggle_tabs.xml", "java/res/layout/incognito_toggle_tabs.xml",
"java/res/layout/infobar_control_url_ellipsizer.xml", "java/res/layout/infobar_control_url_ellipsizer.xml",
"java/res/layout/infobar_translate_compact_content.xml", "java/res/layout/infobar_translate_compact_content.xml",
......
...@@ -20,6 +20,7 @@ ...@@ -20,6 +20,7 @@
app:srcCompat="@drawable/drag_handlebar" /> app:srcCompat="@drawable/drag_handlebar" />
<ImageView <ImageView
android:id="@+id/account_picker_bottom_sheet_logo"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_gravity="center_horizontal" android:layout_gravity="center_horizontal"
...@@ -91,4 +92,12 @@ ...@@ -91,4 +92,12 @@
android:layout_marginTop="32dp" android:layout_marginTop="32dp"
android:layout_marginBottom="132dp" android:layout_marginBottom="132dp"
android:visibility="gone" /> android:visibility="gone" />
<include
android:id="@+id/incognito_interstitial_bottom_sheet_view"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:visibility="gone"
layout="@layout/incognito_interstitial_bottom_sheet_view"/>
</LinearLayout> </LinearLayout>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright 2020 The Chromium Authors. All rights reserved.
Use of this source code is governed by a BSD-style license that can be
found in the LICENSE file. -->
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="8dp"
android:orientation="horizontal">
<TextView
android:id="@+id/incognito_interstitial_learn_more"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="112dp"
android:layout_marginEnd="24dp"
android:layout_gravity="center_vertical"
android:text="@string/learn_more"
android:textAppearance="@style/TextAppearance.TextMediumThick.Blue" />
<org.chromium.ui.widget.ButtonCompat
android:id="@+id/incognito_interstitial_continue_button"
style="@style/FilledButton.Flat"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="24dp"
android:text="@string/continue_button"/>
</LinearLayout>
...@@ -78,6 +78,8 @@ class AccountPickerBottomSheetMediator implements AccountPickerCoordinator.Liste ...@@ -78,6 +78,8 @@ class AccountPickerBottomSheetMediator implements AccountPickerCoordinator.Liste
*/ */
@Override @Override
public void goIncognitoMode() { public void goIncognitoMode() {
mModel.set(AccountPickerBottomSheetProperties.ACCOUNT_PICKER_BOTTOM_SHEET_STATE,
AccountPickerBottomSheetState.INCOGNITO_INTERSTITIAL);
mAccountPickerDelegate.goIncognitoMode(); mAccountPickerDelegate.goIncognitoMode();
} }
......
...@@ -28,7 +28,8 @@ class AccountPickerBottomSheetProperties { ...@@ -28,7 +28,8 @@ class AccountPickerBottomSheetProperties {
@IntDef({AccountPickerBottomSheetState.NO_ACCOUNTS, @IntDef({AccountPickerBottomSheetState.NO_ACCOUNTS,
AccountPickerBottomSheetState.COLLAPSED_ACCOUNT_LIST, AccountPickerBottomSheetState.COLLAPSED_ACCOUNT_LIST,
AccountPickerBottomSheetState.EXPANDED_ACCOUNT_LIST, AccountPickerBottomSheetState.EXPANDED_ACCOUNT_LIST,
AccountPickerBottomSheetState.SIGNIN_IN_PROGRESS}) AccountPickerBottomSheetState.SIGNIN_IN_PROGRESS,
AccountPickerBottomSheetState.INCOGNITO_INTERSTITIAL})
@Retention(RetentionPolicy.SOURCE) @Retention(RetentionPolicy.SOURCE)
@interface AccountPickerBottomSheetState { @interface AccountPickerBottomSheetState {
/** /**
...@@ -67,6 +68,15 @@ class AccountPickerBottomSheetProperties { ...@@ -67,6 +68,15 @@ class AccountPickerBottomSheetProperties {
* |Continue as| is clicked. This state does not lead to any other state. * |Continue as| is clicked. This state does not lead to any other state.
*/ */
int SIGNIN_IN_PROGRESS = 3; int SIGNIN_IN_PROGRESS = 3;
/**
* When the account list is expanded, the user sees the account list of all the accounts
* on device and some additional rows like |Add account to device| and |Go incognito mode|.
*
* This state can only be reached from EXPANDED_ACCOUNT_LIST and would represent that the
* user has clicked the "Go incognito mode" option.
*/
int INCOGNITO_INTERSTITIAL = 4;
} }
// PropertyKeys for the selected account view when the account list is collapsed. // PropertyKeys for the selected account view when the account list is collapsed.
......
...@@ -32,6 +32,7 @@ class AccountPickerBottomSheetView implements BottomSheetContent { ...@@ -32,6 +32,7 @@ class AccountPickerBottomSheetView implements BottomSheetContent {
private final TextView mAccountPickerTitle; private final TextView mAccountPickerTitle;
private final RecyclerView mAccountListView; private final RecyclerView mAccountListView;
private final View mSelectedAccountView; private final View mSelectedAccountView;
private final View mIncognitoInterstitialView;
private final ButtonCompat mContinueAsButton; private final ButtonCompat mContinueAsButton;
AccountPickerBottomSheetView(Context context) { AccountPickerBottomSheetView(Context context) {
...@@ -40,6 +41,8 @@ class AccountPickerBottomSheetView implements BottomSheetContent { ...@@ -40,6 +41,8 @@ class AccountPickerBottomSheetView implements BottomSheetContent {
R.layout.account_picker_bottom_sheet_view, null); R.layout.account_picker_bottom_sheet_view, null);
mAccountPickerTitle = mContentView.findViewById(R.id.account_picker_bottom_sheet_title); mAccountPickerTitle = mContentView.findViewById(R.id.account_picker_bottom_sheet_title);
mAccountListView = mContentView.findViewById(R.id.account_picker_account_list); mAccountListView = mContentView.findViewById(R.id.account_picker_account_list);
mIncognitoInterstitialView =
mContentView.findViewById(R.id.incognito_interstitial_bottom_sheet_view);
mAccountListView.setLayoutManager(new LinearLayoutManager( mAccountListView.setLayoutManager(new LinearLayoutManager(
mAccountListView.getContext(), LinearLayoutManager.VERTICAL, false)); mAccountListView.getContext(), LinearLayoutManager.VERTICAL, false));
mSelectedAccountView = mContentView.findViewById(R.id.account_picker_selected_account); mSelectedAccountView = mContentView.findViewById(R.id.account_picker_selected_account);
...@@ -126,6 +129,19 @@ class AccountPickerBottomSheetView implements BottomSheetContent { ...@@ -126,6 +129,19 @@ class AccountPickerBottomSheetView implements BottomSheetContent {
.setVisibility(View.VISIBLE); .setVisibility(View.VISIBLE);
} }
void setUpIncognitoInterstitialView() {
// TODO(crbug.com/1103262): Setup the incognito interstitial strings.
ImageView logo = mContentView.findViewById(R.id.account_picker_bottom_sheet_logo);
logo.setImageResource(R.drawable.location_bar_incognito_badge);
mAccountPickerTitle.setVisibility(View.GONE);
mContentView.findViewById(R.id.account_picker_bottom_sheet_subtitle)
.setVisibility(View.GONE);
mContentView.findViewById(R.id.account_picker_horizontal_divider).setVisibility(View.GONE);
mAccountListView.setVisibility(View.GONE);
mIncognitoInterstitialView.setVisibility(View.VISIBLE);
}
@Override @Override
public View getContentView() { public View getContentView() {
return mContentView; return mContentView;
......
...@@ -56,6 +56,9 @@ class AccountPickerBottomSheetViewBinder { ...@@ -56,6 +56,9 @@ class AccountPickerBottomSheetViewBinder {
case AccountPickerBottomSheetState.SIGNIN_IN_PROGRESS: case AccountPickerBottomSheetState.SIGNIN_IN_PROGRESS:
view.setUpSignInInProgressView(); view.setUpSignInInProgressView();
break; break;
case AccountPickerBottomSheetState.INCOGNITO_INTERSTITIAL:
view.setUpIncognitoInterstitialView();
break;
default: default:
throw new IllegalArgumentException( throw new IllegalArgumentException(
"Cannot bind AccountPickerBottomSheetView for the state:" "Cannot bind AccountPickerBottomSheetView for the state:"
......
...@@ -49,9 +49,9 @@ class AccountPickerProperties { ...@@ -49,9 +49,9 @@ class AccountPickerProperties {
private IncognitoAccountRowProperties() {} private IncognitoAccountRowProperties() {}
static PropertyModel createModel(Runnable runnableIncognitoAccount) { static PropertyModel createModel(Runnable runnableIncognitoMode) {
return new PropertyModel.Builder(ALL_KEYS) return new PropertyModel.Builder(ALL_KEYS)
.with(ON_CLICK_LISTENER, runnableIncognitoAccount) .with(ON_CLICK_LISTENER, runnableIncognitoMode)
.build(); .build();
} }
} }
......
...@@ -339,6 +339,18 @@ public class AccountPickerBottomSheetTest { ...@@ -339,6 +339,18 @@ public class AccountPickerBottomSheetTest {
onView(withText(R.string.signin_incognito_mode_secondary)).check(matches(isDisplayed())); onView(withText(R.string.signin_incognito_mode_secondary)).check(matches(isDisplayed()));
onView(withText(R.string.signin_incognito_mode_primary)).perform(click()); onView(withText(R.string.signin_incognito_mode_primary)).perform(click());
verify(mAccountPickerDelegateMock).goIncognitoMode(); verify(mAccountPickerDelegateMock).goIncognitoMode();
checkIncognitoInterstitialSheet();
}
private void checkIncognitoInterstitialSheet() {
onView(withId(R.id.account_picker_bottom_sheet_logo)).check(matches(isDisplayed()));
onView(withId(R.id.account_picker_bottom_sheet_title)).check(matches(not(isDisplayed())));
onView(withId(R.id.account_picker_bottom_sheet_subtitle))
.check(matches(not(isDisplayed())));
onView(withId(R.id.account_picker_horizontal_divider)).check(matches(not(isDisplayed())));
onView(withId(R.id.account_picker_account_list)).check(matches(not(isDisplayed())));
onView(withId(R.id.incognito_interstitial_bottom_sheet_view)).check(matches(isDisplayed()));
} }
private void checkZeroAccountBottomSheet() { private void checkZeroAccountBottomSheet() {
......
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