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.
[email protected]
Bug: 1103262
Change-Id: I031b505fe347afb3265da4921c002a702a022421
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2346645
Reviewed-by: Rohit Agarwal <[email protected]>
Reviewed-by: Alice Wang <[email protected]>
Commit-Queue: Rohit Agarwal <[email protected]>
Cr-Commit-Position: refs/heads/master@{#798566}
diff --git a/chrome/android/chrome_java_resources.gni b/chrome/android/chrome_java_resources.gni
index eec87817..9d269f2 100644
--- a/chrome/android/chrome_java_resources.gni
+++ b/chrome/android/chrome_java_resources.gni
@@ -915,6 +915,7 @@
"java/res/layout/homepage_editor.xml",
"java/res/layout/icon_row_menu_footer.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/infobar_control_url_ellipsizer.xml",
"java/res/layout/infobar_translate_compact_content.xml",
diff --git a/chrome/android/java/res/layout/account_picker_bottom_sheet_view.xml b/chrome/android/java/res/layout/account_picker_bottom_sheet_view.xml
index 33f8628..59058fa 100644
--- a/chrome/android/java/res/layout/account_picker_bottom_sheet_view.xml
+++ b/chrome/android/java/res/layout/account_picker_bottom_sheet_view.xml
@@ -20,6 +20,7 @@
app:srcCompat="@drawable/drag_handlebar" />
<ImageView
+ android:id="@+id/account_picker_bottom_sheet_logo"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
@@ -91,4 +92,12 @@
android:layout_marginTop="32dp"
android:layout_marginBottom="132dp"
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>
\ No newline at end of file
diff --git a/chrome/android/java/res/layout/incognito_interstitial_bottom_sheet_view.xml b/chrome/android/java/res/layout/incognito_interstitial_bottom_sheet_view.xml
new file mode 100644
index 0000000..0eece5c9d
--- /dev/null
+++ b/chrome/android/java/res/layout/incognito_interstitial_bottom_sheet_view.xml
@@ -0,0 +1,31 @@
+<?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>
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/signin/account_picker/AccountPickerBottomSheetMediator.java b/chrome/android/java/src/org/chromium/chrome/browser/signin/account_picker/AccountPickerBottomSheetMediator.java
index 59fec37f..c759e37 100644
--- a/chrome/android/java/src/org/chromium/chrome/browser/signin/account_picker/AccountPickerBottomSheetMediator.java
+++ b/chrome/android/java/src/org/chromium/chrome/browser/signin/account_picker/AccountPickerBottomSheetMediator.java
@@ -78,6 +78,8 @@
*/
@Override
public void goIncognitoMode() {
+ mModel.set(AccountPickerBottomSheetProperties.ACCOUNT_PICKER_BOTTOM_SHEET_STATE,
+ AccountPickerBottomSheetState.INCOGNITO_INTERSTITIAL);
mAccountPickerDelegate.goIncognitoMode();
}
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/signin/account_picker/AccountPickerBottomSheetProperties.java b/chrome/android/java/src/org/chromium/chrome/browser/signin/account_picker/AccountPickerBottomSheetProperties.java
index 2fcac14..a91c3ac 100644
--- a/chrome/android/java/src/org/chromium/chrome/browser/signin/account_picker/AccountPickerBottomSheetProperties.java
+++ b/chrome/android/java/src/org/chromium/chrome/browser/signin/account_picker/AccountPickerBottomSheetProperties.java
@@ -28,7 +28,8 @@
@IntDef({AccountPickerBottomSheetState.NO_ACCOUNTS,
AccountPickerBottomSheetState.COLLAPSED_ACCOUNT_LIST,
AccountPickerBottomSheetState.EXPANDED_ACCOUNT_LIST,
- AccountPickerBottomSheetState.SIGNIN_IN_PROGRESS})
+ AccountPickerBottomSheetState.SIGNIN_IN_PROGRESS,
+ AccountPickerBottomSheetState.INCOGNITO_INTERSTITIAL})
@Retention(RetentionPolicy.SOURCE)
@interface AccountPickerBottomSheetState {
/**
@@ -67,6 +68,15 @@
* |Continue as| is clicked. This state does not lead to any other state.
*/
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.
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/signin/account_picker/AccountPickerBottomSheetView.java b/chrome/android/java/src/org/chromium/chrome/browser/signin/account_picker/AccountPickerBottomSheetView.java
index 0c172e7..a7755e5 100644
--- a/chrome/android/java/src/org/chromium/chrome/browser/signin/account_picker/AccountPickerBottomSheetView.java
+++ b/chrome/android/java/src/org/chromium/chrome/browser/signin/account_picker/AccountPickerBottomSheetView.java
@@ -32,6 +32,7 @@
private final TextView mAccountPickerTitle;
private final RecyclerView mAccountListView;
private final View mSelectedAccountView;
+ private final View mIncognitoInterstitialView;
private final ButtonCompat mContinueAsButton;
AccountPickerBottomSheetView(Context context) {
@@ -40,6 +41,8 @@
R.layout.account_picker_bottom_sheet_view, null);
mAccountPickerTitle = mContentView.findViewById(R.id.account_picker_bottom_sheet_title);
mAccountListView = mContentView.findViewById(R.id.account_picker_account_list);
+ mIncognitoInterstitialView =
+ mContentView.findViewById(R.id.incognito_interstitial_bottom_sheet_view);
mAccountListView.setLayoutManager(new LinearLayoutManager(
mAccountListView.getContext(), LinearLayoutManager.VERTICAL, false));
mSelectedAccountView = mContentView.findViewById(R.id.account_picker_selected_account);
@@ -126,6 +129,19 @@
.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
public View getContentView() {
return mContentView;
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/signin/account_picker/AccountPickerBottomSheetViewBinder.java b/chrome/android/java/src/org/chromium/chrome/browser/signin/account_picker/AccountPickerBottomSheetViewBinder.java
index 31776a4..20187b1 100644
--- a/chrome/android/java/src/org/chromium/chrome/browser/signin/account_picker/AccountPickerBottomSheetViewBinder.java
+++ b/chrome/android/java/src/org/chromium/chrome/browser/signin/account_picker/AccountPickerBottomSheetViewBinder.java
@@ -56,6 +56,9 @@
case AccountPickerBottomSheetState.SIGNIN_IN_PROGRESS:
view.setUpSignInInProgressView();
break;
+ case AccountPickerBottomSheetState.INCOGNITO_INTERSTITIAL:
+ view.setUpIncognitoInterstitialView();
+ break;
default:
throw new IllegalArgumentException(
"Cannot bind AccountPickerBottomSheetView for the state:"
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/signin/account_picker/AccountPickerProperties.java b/chrome/android/java/src/org/chromium/chrome/browser/signin/account_picker/AccountPickerProperties.java
index 764d02e..e3c3de8 100644
--- a/chrome/android/java/src/org/chromium/chrome/browser/signin/account_picker/AccountPickerProperties.java
+++ b/chrome/android/java/src/org/chromium/chrome/browser/signin/account_picker/AccountPickerProperties.java
@@ -49,9 +49,9 @@
private IncognitoAccountRowProperties() {}
- static PropertyModel createModel(Runnable runnableIncognitoAccount) {
+ static PropertyModel createModel(Runnable runnableIncognitoMode) {
return new PropertyModel.Builder(ALL_KEYS)
- .with(ON_CLICK_LISTENER, runnableIncognitoAccount)
+ .with(ON_CLICK_LISTENER, runnableIncognitoMode)
.build();
}
}
diff --git a/chrome/android/javatests/src/org/chromium/chrome/browser/signin/AccountPickerBottomSheetTest.java b/chrome/android/javatests/src/org/chromium/chrome/browser/signin/AccountPickerBottomSheetTest.java
index bb7c71a..8f58516e 100644
--- a/chrome/android/javatests/src/org/chromium/chrome/browser/signin/AccountPickerBottomSheetTest.java
+++ b/chrome/android/javatests/src/org/chromium/chrome/browser/signin/AccountPickerBottomSheetTest.java
@@ -339,6 +339,18 @@
onView(withText(R.string.signin_incognito_mode_secondary)).check(matches(isDisplayed()));
onView(withText(R.string.signin_incognito_mode_primary)).perform(click());
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() {