Commit 3a77eb64 authored by Jordan Demeulenaere's avatar Jordan Demeulenaere Committed by Commit Bot

[Autofill Assistant] Improve onboarding screen.

Before:
 * https://screenshot.googleplex.com/BpQHiNsZkrK.png

After:
 * https://screenshot.googleplex.com/9m7YwMN9L03.png
 * https://screenshot.googleplex.com/udJvgvVyR5k.png

Binary-Size: Adding image resources for the Autofill Assistant feature that will be in a DFM before M75.
Change-Id: I0e0506dc235a3b06f712e47ddb0d01ebd3ede337
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1560155
Commit-Queue: Jordan Demeulenaere <jdemeulenaere@chromium.org>
Reviewed-by: default avatarClemens Arbesser <arbesser@google.com>
Cr-Commit-Position: refs/heads/master@{#649838}
parent db0f6727
...@@ -16,6 +16,7 @@ ...@@ -16,6 +16,7 @@
android:clipToPadding="false" android:clipToPadding="false"
android:orientation="vertical"> android:orientation="vertical">
<LinearLayout <LinearLayout
android:id="@+id/header"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:minHeight="56dp" android:minHeight="56dp"
......
...@@ -25,45 +25,63 @@ ...@@ -25,45 +25,63 @@
android:paddingStart="24dp" android:paddingStart="24dp"
android:paddingEnd="24dp"> android:paddingEnd="24dp">
<Space android:layout_width="0dp" android:layout_height="12dp"/>
<!-- Image background --> <!-- Image background -->
<ImageView <ImageView
android:id="@+id/onboarding_image"
tools:ignore="contentDescription" tools:ignore="contentDescription"
android:layout_width="250dp" android:layout_width="250dp"
android:layout_height="141dp" android:layout_height="wrap_content"
android:scaleType="centerCrop" android:scaleType="centerCrop"
android:src="@drawable/onboarding_background" android:src="@drawable/autofill_assistant_onboarding_bg"
android:paddingBottom="15dp"/> android:layout_marginTop="12dp" />
<!-- Title (e.g., 'Fast Checkout')--> <!-- "Try Google Assistant in Chrome" -->
<TextView <ImageView
android:id="@+id/onboarding_try_assistant"
tools:ignore="contentDescription"
android:layout_width="185dp"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_width="wrap_content" android:layout_marginTop="16dp"
android:textAppearance="@style/TextAppearance.AssistantBlackTitle" android:src="@drawable/autofill_assistant_onboarding_try" />
android:gravity="center_horizontal"
android:text="@string/autofill_assistant_onboarding_title" />
<!-- Subtitle (e.g., 'Google Assistant saves you time...')--> <!-- Subtitle (e.g., 'Google Assistant saves you time...')-->
<Space android:layout_width="0dp" android:layout_height="16dp"/> <LinearLayout
<TextView android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content">
android:layout_width="wrap_content" <Space
android:textAppearance="@style/TextAppearance.AssistantBlackBody" android:layout_width="0dp"
android:paddingStart="12dp" android:layout_height="1dp"
android:paddingEnd="12dp" android:layout_weight="1"/>
android:gravity="center_horizontal" <!-- The subtitle takes 4/6 of the screen width. -->
android:text="@string/autofill_assistant_init_message" /> <TextView
android:id="@+id/onboarding_subtitle"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="4"
android:layout_marginTop="24dp"
android:textAppearance="@style/TextAppearance.AssistantBlackBody"
android:gravity="center_horizontal"
android:text="@string/autofill_assistant_init_message" />
<Space
android:layout_width="0dp"
android:layout_height="1dp"
android:layout_weight="1"/>
</LinearLayout>
<!-- Separator --> <!-- Separator -->
<Space android:layout_width="0dp" android:layout_height="24dp"/>
<LinearLayout <LinearLayout
android:id="@+id/onboarding_separator"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginTop="24dp"
android:gravity="center_horizontal" android:gravity="center_horizontal"
android:orientation="horizontal" android:orientation="horizontal"
android:weightSum="1.0"> android:weightSum="1.0">
<View style="@style/HorizontalDivider" <View style="@style/HorizontalDivider"
android:layout_width="0dp" android:layout_width="0dp"
android:layout_height="2dp" android:layout_height="1dp"
android:layout_weight="0.33"/> android:layout_weight="0.33"/>
</LinearLayout> </LinearLayout>
<Space android:layout_width="0dp" android:layout_height="24dp"/> <Space android:layout_width="0dp" android:layout_height="24dp"/>
...@@ -72,10 +90,7 @@ ...@@ -72,10 +90,7 @@
<LinearLayout <LinearLayout
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_width="match_parent" android:layout_width="match_parent"
android:paddingStart="12dp"
android:paddingEnd="12dp"
android:paddingBottom="9dp"> android:paddingBottom="9dp">
<TextView <TextView
android:id="@+id/google_terms_message" android:id="@+id/google_terms_message"
android:layout_width="wrap_content" android:layout_width="wrap_content"
......
...@@ -134,7 +134,7 @@ class AssistantBottomBarCoordinator { ...@@ -134,7 +134,7 @@ class AssistantBottomBarCoordinator {
* proceed, false otherwise. * proceed, false otherwise.
*/ */
public void showOnboarding(Callback<Boolean> callback) { public void showOnboarding(Callback<Boolean> callback) {
mModel.getHeaderModel().set(AssistantHeaderModel.FEEDBACK_VISIBLE, false); mModel.getHeaderModel().set(AssistantHeaderModel.VISIBLE, false);
// Show overlay to prevent user from interacting with the page during onboarding. // Show overlay to prevent user from interacting with the page during onboarding.
mModel.getOverlayModel().set(AssistantOverlayModel.STATE, AssistantOverlayState.FULL); mModel.getOverlayModel().set(AssistantOverlayModel.STATE, AssistantOverlayState.FULL);
...@@ -147,7 +147,7 @@ class AssistantBottomBarCoordinator { ...@@ -147,7 +147,7 @@ class AssistantBottomBarCoordinator {
return; return;
} }
mModel.getHeaderModel().set(AssistantHeaderModel.FEEDBACK_VISIBLE, true); mModel.getHeaderModel().set(AssistantHeaderModel.VISIBLE, true);
// Hide overlay. // Hide overlay.
mModel.getOverlayModel().set( mModel.getOverlayModel().set(
......
...@@ -23,6 +23,9 @@ import org.chromium.ui.text.SpanApplier; ...@@ -23,6 +23,9 @@ import org.chromium.ui.text.SpanApplier;
* Assistant for the first time. * Assistant for the first time.
*/ */
class AssistantOnboardingCoordinator { class AssistantOnboardingCoordinator {
// TODO(crbug.com/806868): Wire this with A/B experiment.
private static final boolean SHOW_SMALL_ONBOARDING = false;
/** /**
* Shows the onboarding screen and returns whether we should proceed. * Shows the onboarding screen and returns whether we should proceed.
*/ */
...@@ -55,9 +58,20 @@ class AssistantOnboardingCoordinator { ...@@ -55,9 +58,20 @@ class AssistantOnboardingCoordinator {
initView.announceForAccessibility( initView.announceForAccessibility(
context.getString(R.string.autofill_assistant_first_run_accessibility)); context.getString(R.string.autofill_assistant_first_run_accessibility));
// Hide views that should not be displayed when showing the small onboarding.
if (SHOW_SMALL_ONBOARDING) {
hide(initView, R.id.onboarding_image);
hide(initView, R.id.onboarding_subtitle);
hide(initView, R.id.onboarding_separator);
}
return initView; return initView;
} }
private static void hide(View root, int resId) {
root.findViewById(resId).setVisibility(View.GONE);
}
private static void onClicked( private static void onClicked(
boolean accept, ViewGroup root, View initView, Callback<Boolean> callback) { boolean accept, ViewGroup root, View initView, Callback<Boolean> callback) {
AutofillAssistantPreferencesUtil.setInitialPreferences(accept); AutofillAssistantPreferencesUtil.setInitialPreferences(accept);
......
...@@ -15,7 +15,8 @@ import org.chromium.ui.modelutil.PropertyModelChangeProcessor; ...@@ -15,7 +15,8 @@ import org.chromium.ui.modelutil.PropertyModelChangeProcessor;
* Coordinator for the header of the Autofill Assistant. * Coordinator for the header of the Autofill Assistant.
*/ */
public class AssistantHeaderCoordinator { public class AssistantHeaderCoordinator {
public AssistantHeaderCoordinator(Context context, ViewGroup root, AssistantHeaderModel model) { public AssistantHeaderCoordinator(
Context context, ViewGroup bottomBarView, AssistantHeaderModel model) {
// Create the poodle and insert it before the status message. We have to create a view // Create the poodle and insert it before the status message. We have to create a view
// bigger than the desired poodle size (24dp) because the actual downstream implementation // bigger than the desired poodle size (24dp) because the actual downstream implementation
// needs extra space for the animation. // needs extra space for the animation.
...@@ -24,13 +25,16 @@ public class AssistantHeaderCoordinator { ...@@ -24,13 +25,16 @@ public class AssistantHeaderCoordinator {
R.dimen.autofill_assistant_poodle_view_size), R.dimen.autofill_assistant_poodle_view_size),
context.getResources().getDimensionPixelSize( context.getResources().getDimensionPixelSize(
R.dimen.autofill_assistant_poodle_size)); R.dimen.autofill_assistant_poodle_size));
addPoodle(root, poodle.getView()); addPoodle(bottomBarView, poodle.getView());
// Bind view and mediator through the model. // Bind view and mediator through the model.
AssistantHeaderViewBinder.ViewHolder viewHolder = AssistantHeaderViewBinder.ViewHolder viewHolder =
new AssistantHeaderViewBinder.ViewHolder(root, poodle); new AssistantHeaderViewBinder.ViewHolder(bottomBarView, poodle);
AssistantHeaderViewBinder viewBinder = new AssistantHeaderViewBinder(); AssistantHeaderViewBinder viewBinder = new AssistantHeaderViewBinder();
PropertyModelChangeProcessor.create(model, viewHolder, viewBinder); PropertyModelChangeProcessor.create(model, viewHolder, viewBinder);
model.set(AssistantHeaderModel.VISIBLE, true);
model.set(AssistantHeaderModel.PROGRESS_VISIBLE, true);
} }
private void addPoodle(ViewGroup root, View poodleView) { private void addPoodle(ViewGroup root, View poodleView) {
......
...@@ -14,15 +14,12 @@ import org.chromium.ui.modelutil.PropertyModel; ...@@ -14,15 +14,12 @@ import org.chromium.ui.modelutil.PropertyModel;
*/ */
@JNINamespace("autofill_assistant") @JNINamespace("autofill_assistant")
public class AssistantHeaderModel extends PropertyModel { public class AssistantHeaderModel extends PropertyModel {
public static final WritableBooleanPropertyKey VISIBLE = new WritableBooleanPropertyKey();
@VisibleForTesting @VisibleForTesting
public static final WritableObjectPropertyKey<String> STATUS_MESSAGE = public static final WritableObjectPropertyKey<String> STATUS_MESSAGE =
new WritableObjectPropertyKey<>(); new WritableObjectPropertyKey<>();
// TODO(crbug.com/806868): Change visibility to package-private once this is only set through
// native calls.
public static final WritableBooleanPropertyKey FEEDBACK_VISIBLE =
new WritableBooleanPropertyKey();
static final WritableIntPropertyKey PROGRESS = new WritableIntPropertyKey(); static final WritableIntPropertyKey PROGRESS = new WritableIntPropertyKey();
@VisibleForTesting @VisibleForTesting
...@@ -35,7 +32,7 @@ public class AssistantHeaderModel extends PropertyModel { ...@@ -35,7 +32,7 @@ public class AssistantHeaderModel extends PropertyModel {
new WritableObjectPropertyKey<>(); new WritableObjectPropertyKey<>();
public AssistantHeaderModel() { public AssistantHeaderModel() {
super(STATUS_MESSAGE, FEEDBACK_VISIBLE, PROGRESS, PROGRESS_VISIBLE, SPIN_POODLE, super(VISIBLE, STATUS_MESSAGE, PROGRESS, PROGRESS_VISIBLE, SPIN_POODLE,
FEEDBACK_BUTTON_CALLBACK); FEEDBACK_BUTTON_CALLBACK);
} }
......
...@@ -24,35 +24,34 @@ class AssistantHeaderViewBinder ...@@ -24,35 +24,34 @@ class AssistantHeaderViewBinder
*/ */
static class ViewHolder { static class ViewHolder {
final AnimatedPoodle mPoodle; final AnimatedPoodle mPoodle;
final View mHeader;
final TextView mStatusMessage; final TextView mStatusMessage;
final AnimatedProgressBar mProgressBar; final AnimatedProgressBar mProgressBar;
final View mFeedbackButton; final View mFeedbackButton;
public ViewHolder(View headerView, AnimatedPoodle poodle) { public ViewHolder(View bottomBarView, AnimatedPoodle poodle) {
mPoodle = poodle; mPoodle = poodle;
mStatusMessage = headerView.findViewById(R.id.status_message); mHeader = bottomBarView.findViewById(R.id.header);
mProgressBar = new AnimatedProgressBar(headerView.findViewById(R.id.progress_bar)); mStatusMessage = bottomBarView.findViewById(R.id.status_message);
mFeedbackButton = headerView.findViewById(R.id.feedback_button); mProgressBar = new AnimatedProgressBar(bottomBarView.findViewById(R.id.progress_bar));
mFeedbackButton = bottomBarView.findViewById(R.id.feedback_button);
} }
} }
@Override @Override
public void bind(AssistantHeaderModel model, ViewHolder view, PropertyKey propertyKey) { public void bind(AssistantHeaderModel model, ViewHolder view, PropertyKey propertyKey) {
if (AssistantHeaderModel.STATUS_MESSAGE == propertyKey) { if (AssistantHeaderModel.VISIBLE == propertyKey) {
view.mHeader.setVisibility(
model.get(AssistantHeaderModel.VISIBLE) ? View.VISIBLE : View.GONE);
setProgressBarVisibility(view, model);
} else if (AssistantHeaderModel.STATUS_MESSAGE == propertyKey) {
String message = model.get(AssistantHeaderModel.STATUS_MESSAGE); String message = model.get(AssistantHeaderModel.STATUS_MESSAGE);
view.mStatusMessage.setText(message); view.mStatusMessage.setText(message);
view.mStatusMessage.announceForAccessibility(message); view.mStatusMessage.announceForAccessibility(message);
} else if (AssistantHeaderModel.FEEDBACK_VISIBLE == propertyKey) {
view.mFeedbackButton.setVisibility(
model.get(AssistantHeaderModel.FEEDBACK_VISIBLE) ? View.VISIBLE : View.GONE);
} else if (AssistantHeaderModel.PROGRESS == propertyKey) { } else if (AssistantHeaderModel.PROGRESS == propertyKey) {
view.mProgressBar.setProgress(model.get(AssistantHeaderModel.PROGRESS)); view.mProgressBar.setProgress(model.get(AssistantHeaderModel.PROGRESS));
} else if (AssistantHeaderModel.PROGRESS_VISIBLE == propertyKey) { } else if (AssistantHeaderModel.PROGRESS_VISIBLE == propertyKey) {
if (model.get(AssistantHeaderModel.PROGRESS_VISIBLE)) { setProgressBarVisibility(view, model);
view.mProgressBar.show();
} else {
view.mProgressBar.hide();
}
} else if (AssistantHeaderModel.SPIN_POODLE == propertyKey) { } else if (AssistantHeaderModel.SPIN_POODLE == propertyKey) {
view.mPoodle.setSpinEnabled(model.get(AssistantHeaderModel.SPIN_POODLE)); view.mPoodle.setSpinEnabled(model.get(AssistantHeaderModel.SPIN_POODLE));
} else if (AssistantHeaderModel.FEEDBACK_BUTTON_CALLBACK == propertyKey) { } else if (AssistantHeaderModel.FEEDBACK_BUTTON_CALLBACK == propertyKey) {
...@@ -62,4 +61,13 @@ class AssistantHeaderViewBinder ...@@ -62,4 +61,13 @@ class AssistantHeaderViewBinder
assert false : "Unhandled property detected in AssistantHeaderViewBinder!"; assert false : "Unhandled property detected in AssistantHeaderViewBinder!";
} }
} }
private void setProgressBarVisibility(ViewHolder view, AssistantHeaderModel model) {
if (model.get(AssistantHeaderModel.VISIBLE)
&& model.get(AssistantHeaderModel.PROGRESS_VISIBLE)) {
view.mProgressBar.show();
} else {
view.mProgressBar.hide();
}
}
} }
...@@ -112,9 +112,6 @@ ...@@ -112,9 +112,6 @@
</translations> </translations>
<release allow_pseudo="false" seq="1"> <release allow_pseudo="false" seq="1">
<messages fallback_to_english="true"> <messages fallback_to_english="true">
<message name="IDS_AUTOFILL_ASSISTANT_ONBOARDING_TITLE" desc="Onboarding title for the autofill assistant.">
Google Assistant\nin Chrome
</message>
<message name="IDS_INIT_OK" desc="Init screen confirmation text."> <message name="IDS_INIT_OK" desc="Init screen confirmation text.">
I accept I accept
</message> </message>
......
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