Commit 2d94515f authored by Hui(Andy) Wu's avatar Hui(Andy) Wu Committed by Commit Bot

[Autofill Assistant] Rename 'show_attribution' to 'allow_image_clickthrough'.

Refactor to make code more understandable.

Change-Id: I1439547ccbde474bf007adfea06748dc11b17ab1
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1546786Reviewed-by: default avatarJordan Demeulenaere <jdemeulenaere@chromium.org>
Commit-Queue: Hui Wu <wuandy@chromium.org>
Cr-Commit-Position: refs/heads/master@{#646471}
parent 695699a0
...@@ -24,7 +24,7 @@ public class AssistantDetails { ...@@ -24,7 +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 mAllowImageClickthrough;
private final boolean mShowImagePlaceholder; private final boolean mShowImagePlaceholder;
@Nullable @Nullable
private final Date mDate; private final Date mDate;
...@@ -48,7 +48,7 @@ public class AssistantDetails { ...@@ -48,7 +48,7 @@ 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 showAttribution, public AssistantDetails(String title, String imageUrl, boolean allowImageClickthrough,
boolean showImagePlaceholder, String totalPriceLabel, String totalPrice, boolean showImagePlaceholder, String totalPriceLabel, String totalPrice,
@Nullable Date date, String descriptionLine1, String descriptionLine2, @Nullable Date date, String descriptionLine1, String descriptionLine2,
boolean userApprovalRequired, boolean highlightTitle, boolean highlightLine1, boolean userApprovalRequired, boolean highlightTitle, boolean highlightLine1,
...@@ -56,7 +56,7 @@ public class AssistantDetails { ...@@ -56,7 +56,7 @@ public class AssistantDetails {
this.mTotalPriceLabel = totalPriceLabel; this.mTotalPriceLabel = totalPriceLabel;
this.mTitle = title; this.mTitle = title;
this.mImageUrl = imageUrl; this.mImageUrl = imageUrl;
this.mShowAttribution = showAttribution; this.mAllowImageClickthrough = allowImageClickthrough;
this.mShowImagePlaceholder = showImagePlaceholder; this.mShowImagePlaceholder = showImagePlaceholder;
this.mTotalPrice = totalPrice; this.mTotalPrice = totalPrice;
this.mDate = date; this.mDate = date;
...@@ -78,8 +78,8 @@ public class AssistantDetails { ...@@ -78,8 +78,8 @@ public class AssistantDetails {
return mImageUrl; return mImageUrl;
} }
boolean getShowAttribution() { boolean getAllowImageClickthrough() {
return mShowAttribution; return mAllowImageClickthrough;
} }
boolean getShowImagePlaceholder() { boolean getShowImagePlaceholder() {
...@@ -131,12 +131,12 @@ public class AssistantDetails { ...@@ -131,12 +131,12 @@ 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, boolean showAttribution, private static AssistantDetails create(String title, String imageUrl,
boolean showImagePlaceholder, String totalPriceLabel, String totalPrice, boolean allowImageClickthrough, boolean showImagePlaceholder, String totalPriceLabel,
String datetime, long year, int month, int day, int hour, int minute, int second, String totalPrice, String datetime, long year, int month, int day, int hour, int minute,
String descriptionLine1, String descriptionLine2, boolean userApprovalRequired, int second, String descriptionLine1, String descriptionLine2,
boolean highlightTitle, boolean highlightLine1, boolean highlightLine2, boolean userApprovalRequired, boolean highlightTitle, boolean highlightLine1,
boolean animatePlaceholders) { boolean highlightLine2, boolean animatePlaceholders) {
Date date = null; Date date = null;
if (year > 0 && month > 0 && day > 0 && hour >= 0 && minute >= 0 && second >= 0) { if (year > 0 && month > 0 && day > 0 && hour >= 0 && minute >= 0 && second >= 0) {
Calendar calendar = Calendar.getInstance(); Calendar calendar = Calendar.getInstance();
...@@ -155,7 +155,7 @@ public class AssistantDetails { ...@@ -155,7 +155,7 @@ public class AssistantDetails {
} }
} }
return new AssistantDetails(title, imageUrl, showAttribution, showImagePlaceholder, return new AssistantDetails(title, imageUrl, allowImageClickthrough, showImagePlaceholder,
totalPriceLabel, totalPrice, date, descriptionLine1, descriptionLine2, totalPriceLabel, totalPrice, date, descriptionLine1, descriptionLine2,
userApprovalRequired, highlightTitle, highlightLine1, highlightLine2, userApprovalRequired, highlightTitle, highlightLine1, highlightLine2,
animatePlaceholders); animatePlaceholders);
......
...@@ -160,7 +160,7 @@ class AssistantDetailsViewBinder ...@@ -160,7 +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));
if (details.getShowAttribution()) { if (details.getAllowImageClickthrough()) {
viewHolder.mImageView.setOnClickListener(unusedView viewHolder.mImageView.setOnClickListener(unusedView
-> onImageClicked(mContext, details.getImageUrl())); -> onImageClicked(mContext, details.getImageUrl()));
} else { } else {
......
...@@ -168,7 +168,7 @@ public class AutofillAssistantUiTest { ...@@ -168,7 +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, /* allowImageClickThrough = */ 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_attribution(), proto.show_image_placeholder(), proto.allow_image_clickthrough(), 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()),
......
...@@ -742,7 +742,7 @@ message DetailsProto { ...@@ -742,7 +742,7 @@ message DetailsProto {
// Whether to show the original URL where image is extracted from. Only useful // Whether to show the original URL where image is extracted from. Only useful
// when 'image_url' is set. // when 'image_url' is set.
optional bool show_attribution = 12; optional bool allow_image_clickthrough = 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;
......
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