Commit 5b03f6fb authored by Hui(Andy) Wu's avatar Hui(Andy) Wu Committed by Commit Bot

[Autofill Assistant] Add show_attribution field to details proto.

Adding 'show_attribution' field to details proto and use it to control
if the modal dialog will show when user clicking on the image in
autobot details sections.

Change-Id: I8b5e05a124b88b85aba8579d079d6ef54e0bf9de
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1547197Reviewed-by: default avatarJordan Demeulenaere <jdemeulenaere@chromium.org>
Commit-Queue: Hui Wu <wuandy@chromium.org>
Cr-Commit-Position: refs/heads/master@{#646298}
parent e404014a
......@@ -24,6 +24,7 @@ public class AssistantDetails {
private final String mTitle;
private final String mImageUrl;
private final boolean mShowAttribution;
private final boolean mShowImagePlaceholder;
@Nullable
private final Date mDate;
......@@ -47,13 +48,15 @@ public class AssistantDetails {
/** An optional price label, such as 'Estimated Total incl. VAT'. */
private final String mTotalPriceLabel;
public AssistantDetails(String title, String imageUrl, boolean showImagePlaceholder,
String totalPriceLabel, String totalPrice, @Nullable Date date, String descriptionLine1,
String descriptionLine2, boolean userApprovalRequired, boolean highlightTitle,
boolean highlightLine1, boolean highlightLine2, boolean animatePlaceholders) {
public AssistantDetails(String title, String imageUrl, boolean showAttribution,
boolean showImagePlaceholder, String totalPriceLabel, String totalPrice,
@Nullable Date date, String descriptionLine1, String descriptionLine2,
boolean userApprovalRequired, boolean highlightTitle, boolean highlightLine1,
boolean highlightLine2, boolean animatePlaceholders) {
this.mTotalPriceLabel = totalPriceLabel;
this.mTitle = title;
this.mImageUrl = imageUrl;
this.mShowAttribution = showAttribution;
this.mShowImagePlaceholder = showImagePlaceholder;
this.mTotalPrice = totalPrice;
this.mDate = date;
......@@ -75,6 +78,10 @@ public class AssistantDetails {
return mImageUrl;
}
boolean getShowAttribution() {
return mShowAttribution;
}
boolean getShowImagePlaceholder() {
return mShowImagePlaceholder;
}
......@@ -124,7 +131,7 @@ public class AssistantDetails {
* Create details with the given values.
*/
@CalledByNative
private static AssistantDetails create(String title, String imageUrl,
private static AssistantDetails create(String title, String imageUrl, boolean showAttribution,
boolean showImagePlaceholder, String totalPriceLabel, String totalPrice,
String datetime, long year, int month, int day, int hour, int minute, int second,
String descriptionLine1, String descriptionLine2, boolean userApprovalRequired,
......@@ -148,8 +155,9 @@ public class AssistantDetails {
}
}
return new AssistantDetails(title, imageUrl, showImagePlaceholder, totalPriceLabel,
totalPrice, date, descriptionLine1, descriptionLine2, userApprovalRequired,
highlightTitle, highlightLine1, highlightLine2, animatePlaceholders);
return new AssistantDetails(title, imageUrl, showAttribution, showImagePlaceholder,
totalPriceLabel, totalPrice, date, descriptionLine1, descriptionLine2,
userApprovalRequired, highlightTitle, highlightLine1, highlightLine2,
animatePlaceholders);
}
}
......@@ -160,10 +160,7 @@ class AssistantDetailsViewBinder
CachedImageFetcher.ASSISTANT_DETAILS_UMA_CLIENT_NAME, image -> {
if (image != null) {
viewHolder.mImageView.setImageDrawable(getRoundedImage(image));
// TODO(wuandy): Actually pull 'showAttribution' from server response,
// once it is ready.
boolean showAttribution = false;
if (showAttribution) {
if (details.getShowAttribution()) {
viewHolder.mImageView.setOnClickListener(unusedView
-> onImageClicked(mContext, details.getImageUrl()));
} else {
......
......@@ -168,6 +168,7 @@ public class AutofillAssistantUiTest {
-> assistantCoordinator.getModel().getDetailsModel().set(
AssistantDetailsModel.DETAILS,
new AssistantDetails(movieTitle, /* imageUrl = */ "",
/* showAttribution = */ false,
/* showImage = */ false,
/* totalPriceLabel = */ "",
/* totalPrice = */ "", Calendar.getInstance().getTime(),
......
......@@ -622,7 +622,7 @@ void UiControllerAndroid::OnDetailsChanged(const Details* details) {
auto jdetails = Java_AssistantDetails_create(
env, base::android::ConvertUTF8ToJavaString(env, proto.title()),
base::android::ConvertUTF8ToJavaString(env, proto.image_url()),
proto.show_image_placeholder(),
proto.show_attribution(), proto.show_image_placeholder(),
base::android::ConvertUTF8ToJavaString(env, proto.total_price_label()),
base::android::ConvertUTF8ToJavaString(env, proto.total_price()),
base::android::ConvertUTF8ToJavaString(env, details->GetDatetime()),
......
......@@ -740,6 +740,10 @@ message DetailsProto {
bool show_image_placeholder = 10;
}
// Whether to show the original URL where image is extracted from. Only useful
// when 'image_url' is set.
optional bool show_attribution = 12;
// Optional label to provide additional price information.
optional string total_price_label = 9;
// The price containing the total amount and the currency to pay, formatted
......
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