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 { ...@@ -24,6 +24,7 @@ public class AssistantDetails {
private final String mTitle; private final String mTitle;
private final String mImageUrl; private final String mImageUrl;
private final boolean mShowAttribution;
private final boolean mShowImagePlaceholder; private final boolean mShowImagePlaceholder;
@Nullable @Nullable
private final Date mDate; private final Date mDate;
...@@ -47,13 +48,15 @@ public class AssistantDetails { ...@@ -47,13 +48,15 @@ public class AssistantDetails {
/** An optional price label, such as 'Estimated Total incl. VAT'. */ /** An optional price label, such as 'Estimated Total incl. VAT'. */
private final String mTotalPriceLabel; private final String mTotalPriceLabel;
public AssistantDetails(String title, String imageUrl, boolean showImagePlaceholder, public AssistantDetails(String title, String imageUrl, boolean showAttribution,
String totalPriceLabel, String totalPrice, @Nullable Date date, String descriptionLine1, boolean showImagePlaceholder, String totalPriceLabel, String totalPrice,
String descriptionLine2, boolean userApprovalRequired, boolean highlightTitle, @Nullable Date date, String descriptionLine1, String descriptionLine2,
boolean highlightLine1, boolean highlightLine2, boolean animatePlaceholders) { boolean userApprovalRequired, boolean highlightTitle, boolean highlightLine1,
boolean highlightLine2, boolean animatePlaceholders) {
this.mTotalPriceLabel = totalPriceLabel; this.mTotalPriceLabel = totalPriceLabel;
this.mTitle = title; this.mTitle = title;
this.mImageUrl = imageUrl; this.mImageUrl = imageUrl;
this.mShowAttribution = showAttribution;
this.mShowImagePlaceholder = showImagePlaceholder; this.mShowImagePlaceholder = showImagePlaceholder;
this.mTotalPrice = totalPrice; this.mTotalPrice = totalPrice;
this.mDate = date; this.mDate = date;
...@@ -75,6 +78,10 @@ public class AssistantDetails { ...@@ -75,6 +78,10 @@ public class AssistantDetails {
return mImageUrl; return mImageUrl;
} }
boolean getShowAttribution() {
return mShowAttribution;
}
boolean getShowImagePlaceholder() { boolean getShowImagePlaceholder() {
return mShowImagePlaceholder; return mShowImagePlaceholder;
} }
...@@ -124,7 +131,7 @@ public class AssistantDetails { ...@@ -124,7 +131,7 @@ public class AssistantDetails {
* Create details with the given values. * Create details with the given values.
*/ */
@CalledByNative @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, boolean showImagePlaceholder, String totalPriceLabel, String totalPrice,
String datetime, long year, int month, int day, int hour, int minute, int second, String datetime, long year, int month, int day, int hour, int minute, int second,
String descriptionLine1, String descriptionLine2, boolean userApprovalRequired, String descriptionLine1, String descriptionLine2, boolean userApprovalRequired,
...@@ -148,8 +155,9 @@ public class AssistantDetails { ...@@ -148,8 +155,9 @@ public class AssistantDetails {
} }
} }
return new AssistantDetails(title, imageUrl, showImagePlaceholder, totalPriceLabel, return new AssistantDetails(title, imageUrl, showAttribution, showImagePlaceholder,
totalPrice, date, descriptionLine1, descriptionLine2, userApprovalRequired, totalPriceLabel, totalPrice, date, descriptionLine1, descriptionLine2,
highlightTitle, highlightLine1, highlightLine2, animatePlaceholders); userApprovalRequired, highlightTitle, highlightLine1, highlightLine2,
animatePlaceholders);
} }
} }
...@@ -160,10 +160,7 @@ class AssistantDetailsViewBinder ...@@ -160,10 +160,7 @@ class AssistantDetailsViewBinder
CachedImageFetcher.ASSISTANT_DETAILS_UMA_CLIENT_NAME, image -> { CachedImageFetcher.ASSISTANT_DETAILS_UMA_CLIENT_NAME, image -> {
if (image != null) { if (image != null) {
viewHolder.mImageView.setImageDrawable(getRoundedImage(image)); viewHolder.mImageView.setImageDrawable(getRoundedImage(image));
// TODO(wuandy): Actually pull 'showAttribution' from server response, if (details.getShowAttribution()) {
// once it is ready.
boolean showAttribution = false;
if (showAttribution) {
viewHolder.mImageView.setOnClickListener(unusedView viewHolder.mImageView.setOnClickListener(unusedView
-> onImageClicked(mContext, details.getImageUrl())); -> onImageClicked(mContext, details.getImageUrl()));
} else { } else {
......
...@@ -168,6 +168,7 @@ public class AutofillAssistantUiTest { ...@@ -168,6 +168,7 @@ public class AutofillAssistantUiTest {
-> assistantCoordinator.getModel().getDetailsModel().set( -> assistantCoordinator.getModel().getDetailsModel().set(
AssistantDetailsModel.DETAILS, AssistantDetailsModel.DETAILS,
new AssistantDetails(movieTitle, /* imageUrl = */ "", new AssistantDetails(movieTitle, /* imageUrl = */ "",
/* showAttribution = */ false,
/* showImage = */ false, /* showImage = */ false,
/* totalPriceLabel = */ "", /* totalPriceLabel = */ "",
/* totalPrice = */ "", Calendar.getInstance().getTime(), /* totalPrice = */ "", Calendar.getInstance().getTime(),
......
...@@ -622,7 +622,7 @@ void UiControllerAndroid::OnDetailsChanged(const Details* details) { ...@@ -622,7 +622,7 @@ void UiControllerAndroid::OnDetailsChanged(const Details* details) {
auto jdetails = Java_AssistantDetails_create( auto jdetails = Java_AssistantDetails_create(
env, base::android::ConvertUTF8ToJavaString(env, proto.title()), env, base::android::ConvertUTF8ToJavaString(env, proto.title()),
base::android::ConvertUTF8ToJavaString(env, proto.image_url()), 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_label()),
base::android::ConvertUTF8ToJavaString(env, proto.total_price()), base::android::ConvertUTF8ToJavaString(env, proto.total_price()),
base::android::ConvertUTF8ToJavaString(env, details->GetDatetime()), base::android::ConvertUTF8ToJavaString(env, details->GetDatetime()),
......
...@@ -740,6 +740,10 @@ message DetailsProto { ...@@ -740,6 +740,10 @@ message DetailsProto {
bool show_image_placeholder = 10; 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 label to provide additional price information.
optional string total_price_label = 9; optional string total_price_label = 9;
// The price containing the total amount and the currency to pay, formatted // 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