Commit d7e861ce authored by Tomasz Wiszkowski's avatar Tomasz Wiszkowski Committed by Commit Bot

Treat calculation Suggestions as answers.

This change allows AnswerSuggestionProcessor to manage Calculation
suggestions as well, ensuring all answers (including calculation) are
uniformly processed when new answer layout is enabled.

Bug: 920396
Change-Id: If233480827eb286131eae4a761b8cb9d210cdc3a
Reviewed-on: https://chromium-review.googlesource.com/c/1481953Reviewed-by: default avatarTheresa <twellington@chromium.org>
Commit-Queue: Ender <ender@google.com>
Cr-Commit-Position: refs/heads/master@{#634832}
parent 324eaf9e
...@@ -145,9 +145,9 @@ class AutocompleteMediator implements OnSuggestionsReceivedListener, SuggestionH ...@@ -145,9 +145,9 @@ class AutocompleteMediator implements OnSuggestionsReceivedListener, SuggestionH
mAutocomplete = new AutocompleteController(this); mAutocomplete = new AutocompleteController(this);
mHandler = new Handler(); mHandler = new Handler();
mBasicSuggestionProcessor = new BasicSuggestionProcessor(mContext, this, textProvider); mBasicSuggestionProcessor = new BasicSuggestionProcessor(mContext, this, textProvider);
mAnswerSuggestionProcessor = new AnswerSuggestionProcessor(mContext, this, textProvider);
mEditUrlProcessor = new EditUrlSuggestionProcessor( mEditUrlProcessor = new EditUrlSuggestionProcessor(
delegate, (suggestion) -> onSelection(suggestion, 0)); delegate, (suggestion) -> onSelection(suggestion, 0));
mAnswerSuggestionProcessor = new AnswerSuggestionProcessor(mContext, this);
} }
/** /**
......
...@@ -12,6 +12,8 @@ import android.view.View; ...@@ -12,6 +12,8 @@ import android.view.View;
import org.chromium.base.ThreadUtils; import org.chromium.base.ThreadUtils;
import org.chromium.chrome.browser.ChromeFeatureList; import org.chromium.chrome.browser.ChromeFeatureList;
import org.chromium.chrome.browser.omnibox.OmniboxSuggestionType;
import org.chromium.chrome.browser.omnibox.UrlBarEditingTextStateProvider;
import org.chromium.chrome.browser.omnibox.suggestions.AnswersImageFetcher; import org.chromium.chrome.browser.omnibox.suggestions.AnswersImageFetcher;
import org.chromium.chrome.browser.omnibox.suggestions.AutocompleteCoordinator.SuggestionProcessor; import org.chromium.chrome.browser.omnibox.suggestions.AutocompleteCoordinator.SuggestionProcessor;
import org.chromium.chrome.browser.omnibox.suggestions.OmniboxSuggestion; import org.chromium.chrome.browser.omnibox.suggestions.OmniboxSuggestion;
...@@ -37,22 +39,27 @@ public class AnswerSuggestionProcessor implements SuggestionProcessor { ...@@ -37,22 +39,27 @@ public class AnswerSuggestionProcessor implements SuggestionProcessor {
private final Context mContext; private final Context mContext;
private final SuggestionHost mSuggestionHost; private final SuggestionHost mSuggestionHost;
private final AnswersImageFetcher mImageFetcher; private final AnswersImageFetcher mImageFetcher;
private final UrlBarEditingTextStateProvider mUrlBarEditingTextProvider;
private boolean mEnableNewAnswerLayout; private boolean mEnableNewAnswerLayout;
/** /**
* @param context An Android context. * @param context An Android context.
* @param suggestionHost A handle to the object using the suggestions. * @param suggestionHost A handle to the object using the suggestions.
*/ */
public AnswerSuggestionProcessor(Context context, SuggestionHost suggestionHost) { public AnswerSuggestionProcessor(Context context, SuggestionHost suggestionHost,
UrlBarEditingTextStateProvider editingTextProvider) {
mContext = context; mContext = context;
mSuggestionHost = suggestionHost; mSuggestionHost = suggestionHost;
mPendingAnswerRequestUrls = new HashMap<>(); mPendingAnswerRequestUrls = new HashMap<>();
mImageFetcher = new AnswersImageFetcher(); mImageFetcher = new AnswersImageFetcher();
mUrlBarEditingTextProvider = editingTextProvider;
} }
@Override @Override
public boolean doesProcessSuggestion(OmniboxSuggestion suggestion) { public boolean doesProcessSuggestion(OmniboxSuggestion suggestion) {
return suggestion.hasAnswer(); // Calculation answers are specific in a way that these are basic suggestions, but processed
// as answers, when new answer layout is enabled.
return suggestion.hasAnswer() || suggestion.getType() == OmniboxSuggestionType.CALCULATOR;
} }
@Override @Override
...@@ -81,9 +88,9 @@ public class AnswerSuggestionProcessor implements SuggestionProcessor { ...@@ -81,9 +88,9 @@ public class AnswerSuggestionProcessor implements SuggestionProcessor {
mSuggestionHost.createSuggestionViewDelegate(suggestion, position); mSuggestionHost.createSuggestionViewDelegate(suggestion, position);
if (mEnableNewAnswerLayout) { if (mEnableNewAnswerLayout) {
setStateForNewSuggestion(model, suggestion.getAnswer(), delegate); setStateForNewSuggestion(model, suggestion, delegate);
} else { } else {
setStateForClassicSuggestion(model, suggestion.getAnswer(), delegate); setStateForClassicSuggestion(model, suggestion, delegate);
} }
} }
...@@ -98,6 +105,7 @@ public class AnswerSuggestionProcessor implements SuggestionProcessor { ...@@ -98,6 +105,7 @@ public class AnswerSuggestionProcessor implements SuggestionProcessor {
// Attempting to fetch answer data before we have a profile to request it for. // Attempting to fetch answer data before we have a profile to request it for.
if (mSuggestionHost.getCurrentProfile() == null) return; if (mSuggestionHost.getCurrentProfile() == null) return;
// Note: we also handle calculations here, which do not have answer defined.
if (!suggestion.hasAnswer()) return; if (!suggestion.hasAnswer()) return;
final String url = suggestion.getAnswer().getSecondLine().getImage(); final String url = suggestion.getAnswer().getSecondLine().getImage();
if (url == null) return; if (url == null) return;
...@@ -140,33 +148,34 @@ public class AnswerSuggestionProcessor implements SuggestionProcessor { ...@@ -140,33 +148,34 @@ public class AnswerSuggestionProcessor implements SuggestionProcessor {
* Sets both lines of the Omnibox suggestion in a basic Suggestion result. * Sets both lines of the Omnibox suggestion in a basic Suggestion result.
*/ */
private void setStateForClassicSuggestion( private void setStateForClassicSuggestion(
PropertyModel model, SuggestionAnswer answer, SuggestionViewDelegate delegate) { PropertyModel model, OmniboxSuggestion suggestion, SuggestionViewDelegate delegate) {
SuggestionAnswer.ImageLine firstLine = answer.getFirstLine(); AnswerText[] details = AnswerTextClassic.from(mContext, suggestion);
SuggestionAnswer.ImageLine secondLine = answer.getSecondLine();
model.set(SuggestionViewProperties.IS_ANSWER, true); SuggestionAnswer answer = suggestion.getAnswer();
if (answer != null) {
AnswerText[] details = AnswerTextClassic.from(mContext, answer); model.set(SuggestionViewProperties.HAS_ANSWER_IMAGE, answer.getSecondLine().hasImage());
}
model.set(SuggestionViewProperties.IS_ANSWER, true);
model.set(SuggestionViewProperties.DELEGATE, delegate); model.set(SuggestionViewProperties.DELEGATE, delegate);
model.set(SuggestionViewProperties.TEXT_LINE_1_SIZING, model.set(SuggestionViewProperties.TEXT_LINE_1_SIZING,
Pair.create(TypedValue.COMPLEX_UNIT_SP, details[0].mHeightSp)); Pair.create(TypedValue.COMPLEX_UNIT_SP, details[0].mHeightSp));
model.set(SuggestionViewProperties.TEXT_LINE_2_SIZING,
Pair.create(TypedValue.COMPLEX_UNIT_SP, details[1].mHeightSp));
model.set(SuggestionViewProperties.TEXT_LINE_1_TEXT, model.set(SuggestionViewProperties.TEXT_LINE_1_TEXT,
new SuggestionTextContainer(details[0].mText)); new SuggestionTextContainer(details[0].mText));
model.set(SuggestionViewProperties.TEXT_LINE_2_TEXT,
new SuggestionTextContainer(details[1].mText));
model.set(SuggestionViewProperties.TEXT_LINE_1_MAX_LINES, details[0].mMaxLines); model.set(SuggestionViewProperties.TEXT_LINE_1_MAX_LINES, details[0].mMaxLines);
model.set(SuggestionViewProperties.TEXT_LINE_2_MAX_LINES, details[1].mMaxLines);
model.set(SuggestionViewProperties.TEXT_LINE_1_TEXT_DIRECTION, View.TEXT_DIRECTION_INHERIT); model.set(SuggestionViewProperties.TEXT_LINE_1_TEXT_DIRECTION, View.TEXT_DIRECTION_INHERIT);
model.set(SuggestionViewProperties.TEXT_LINE_2_TEXT_DIRECTION, View.TEXT_DIRECTION_INHERIT);
model.set(SuggestionViewProperties.HAS_ANSWER_IMAGE, secondLine.hasImage()); if (details[1] != null) {
model.set(SuggestionViewProperties.TEXT_LINE_2_SIZING,
Pair.create(TypedValue.COMPLEX_UNIT_SP, details[1].mHeightSp));
model.set(SuggestionViewProperties.TEXT_LINE_2_TEXT,
new SuggestionTextContainer(details[1].mText));
model.set(SuggestionViewProperties.TEXT_LINE_2_MAX_LINES, details[1].mMaxLines);
model.set(SuggestionViewProperties.TEXT_LINE_2_TEXT_DIRECTION,
View.TEXT_DIRECTION_INHERIT);
}
model.set(SuggestionViewProperties.SUGGESTION_ICON_TYPE, SuggestionIcon.MAGNIFIER); model.set(SuggestionViewProperties.SUGGESTION_ICON_TYPE, SuggestionIcon.MAGNIFIER);
model.set(SuggestionViewProperties.REFINABLE, true); model.set(SuggestionViewProperties.REFINABLE, true);
...@@ -176,11 +185,10 @@ public class AnswerSuggestionProcessor implements SuggestionProcessor { ...@@ -176,11 +185,10 @@ public class AnswerSuggestionProcessor implements SuggestionProcessor {
* Sets both lines of the Omnibox suggestion based on an Answers in Suggest result. * Sets both lines of the Omnibox suggestion based on an Answers in Suggest result.
*/ */
private void setStateForNewSuggestion( private void setStateForNewSuggestion(
PropertyModel model, SuggestionAnswer answer, SuggestionViewDelegate delegate) { PropertyModel model, OmniboxSuggestion suggestion, SuggestionViewDelegate delegate) {
SuggestionAnswer.ImageLine firstLine = answer.getFirstLine(); SuggestionAnswer answer = suggestion.getAnswer();
SuggestionAnswer.ImageLine secondLine = answer.getSecondLine(); AnswerText[] details = AnswerTextNewLayout.from(
mContext, suggestion, mUrlBarEditingTextProvider.getTextWithAutocomplete());
AnswerText[] details = AnswerTextNewLayout.from(mContext, answer);
model.set(AnswerSuggestionViewProperties.DELEGATE, delegate); model.set(AnswerSuggestionViewProperties.DELEGATE, delegate);
...@@ -196,33 +204,38 @@ public class AnswerSuggestionProcessor implements SuggestionProcessor { ...@@ -196,33 +204,38 @@ public class AnswerSuggestionProcessor implements SuggestionProcessor {
@AnswerIcon @AnswerIcon
int icon = AnswerIcon.UNDEFINED; int icon = AnswerIcon.UNDEFINED;
switch (answer.getType()) { if (answer != null) {
case AnswerType.DICTIONARY: switch (answer.getType()) {
icon = AnswerIcon.DICTIONARY; case AnswerType.DICTIONARY:
break; icon = AnswerIcon.DICTIONARY;
case AnswerType.FINANCE: break;
icon = AnswerIcon.FINANCE; case AnswerType.FINANCE:
break; icon = AnswerIcon.FINANCE;
case AnswerType.KNOWLEDGE_GRAPH: break;
icon = AnswerIcon.KNOWLEDGE; case AnswerType.KNOWLEDGE_GRAPH:
break; icon = AnswerIcon.KNOWLEDGE;
case AnswerType.SUNRISE: break;
icon = AnswerIcon.SUNRISE; case AnswerType.SUNRISE:
break; icon = AnswerIcon.SUNRISE;
case AnswerType.TRANSLATION: break;
icon = AnswerIcon.TRANSLATION; case AnswerType.TRANSLATION:
break; icon = AnswerIcon.TRANSLATION;
case AnswerType.WEATHER: break;
icon = AnswerIcon.WEATHER; case AnswerType.WEATHER:
break; icon = AnswerIcon.WEATHER;
case AnswerType.WHEN_IS: break;
icon = AnswerIcon.EVENT; case AnswerType.WHEN_IS:
break; icon = AnswerIcon.EVENT;
case AnswerType.CURRENCY: break;
icon = AnswerIcon.CURRENCY; case AnswerType.CURRENCY:
break; icon = AnswerIcon.CURRENCY;
case AnswerType.SPORTS: break;
icon = AnswerIcon.SPORTS; case AnswerType.SPORTS:
icon = AnswerIcon.SPORTS;
}
} else {
assert suggestion.getType() == OmniboxSuggestionType.CALCULATOR;
icon = AnswerIcon.CALCULATOR;
} }
model.set(AnswerSuggestionViewProperties.ANSWER_ICON_TYPE, icon); model.set(AnswerSuggestionViewProperties.ANSWER_ICON_TYPE, icon);
......
...@@ -49,6 +49,8 @@ abstract class AnswerText { ...@@ -49,6 +49,8 @@ abstract class AnswerText {
AnswerText(Context context) { AnswerText(Context context) {
mContext = context; mContext = context;
mDensity = context.getResources().getDisplayMetrics().density; mDensity = context.getResources().getDisplayMetrics().density;
mText = new SpannableStringBuilder();
mMaxLines = 1;
} }
/** /**
...@@ -58,16 +60,14 @@ abstract class AnswerText { ...@@ -58,16 +60,14 @@ abstract class AnswerText {
* @param delegate Callback converting AnswerTextType to an array of TextAppearanceSpan objects. * @param delegate Callback converting AnswerTextType to an array of TextAppearanceSpan objects.
*/ */
protected void build(SuggestionAnswer.ImageLine line) { protected void build(SuggestionAnswer.ImageLine line) {
mText = new SpannableStringBuilder();
mMaxLines = 1;
// This method also computes height of the entire text span. // This method also computes height of the entire text span.
// Ensure we're not rebuilding or appending once AnswerText has been constructed. // Ensure we're not rebuilding or appending once AnswerText has been constructed.
assert mHeightSp == 0; assert mHeightSp == 0;
List<SuggestionAnswer.TextField> textFields = line.getTextFields(); List<SuggestionAnswer.TextField> textFields = line.getTextFields();
for (int i = 0; i < textFields.size(); i++) { for (int i = 0; i < textFields.size(); i++) {
appendAndStyleText(textFields.get(i)); appendAndStyleText(
textFields.get(i).getText(), getAppearanceForText(textFields.get(i).getType()));
if (textFields.get(i).hasNumLines()) { if (textFields.get(i).hasNumLines()) {
mMaxLines = Math.max(mMaxLines, Math.min(3, textFields.get(i).getNumLines())); mMaxLines = Math.max(mMaxLines, Math.min(3, textFields.get(i).getNumLines()));
} }
...@@ -75,22 +75,24 @@ abstract class AnswerText { ...@@ -75,22 +75,24 @@ abstract class AnswerText {
if (line.hasAdditionalText()) { if (line.hasAdditionalText()) {
mText.append(" "); mText.append(" ");
appendAndStyleText(line.getAdditionalText()); appendAndStyleText(line.getAdditionalText().getText(),
getAppearanceForText(line.getAdditionalText().getType()));
} }
if (line.hasStatusText()) { if (line.hasStatusText()) {
mText.append(" "); mText.append(" ");
appendAndStyleText(line.getStatusText()); appendAndStyleText(line.getStatusText().getText(),
getAppearanceForText(line.getStatusText().getType()));
} }
} }
/** /**
* Append the styled text in textField to the supplied builder. * Append the styled text in textField to the supplied builder.
* *
* @param textField The text field (with text and type) to append. * @param text Text to be appended.
* @param styles Styles to be applied to appended text.
*/ */
@SuppressWarnings("deprecation") // Update usage of Html.fromHtml when API min is 24 @SuppressWarnings("deprecation") // Update usage of Html.fromHtml when API min is 24
private void appendAndStyleText(SuggestionAnswer.TextField textField) { protected void appendAndStyleText(String text, MetricAffectingSpan[] styles) {
MetricAffectingSpan[] styles = getAppearanceForText(textField.getType());
// Determine the maximum height of the TextAppearanceSpans that are applied for this field. // Determine the maximum height of the TextAppearanceSpans that are applied for this field.
for (MetricAffectingSpan style : styles) { for (MetricAffectingSpan style : styles) {
if (!(style instanceof TextAppearanceSpan)) continue; if (!(style instanceof TextAppearanceSpan)) continue;
...@@ -100,7 +102,7 @@ abstract class AnswerText { ...@@ -100,7 +102,7 @@ abstract class AnswerText {
} }
// Unescape HTML entities (e.g. "&quot;", "&gt;"). // Unescape HTML entities (e.g. "&quot;", "&gt;").
String text = Html.fromHtml(textField.getText()).toString(); text = Html.fromHtml(text).toString();
// Append as HTML (answer responses contain simple markup). // Append as HTML (answer responses contain simple markup).
int start = mText.length(); int start = mText.length();
......
...@@ -13,6 +13,8 @@ import android.text.style.TextAppearanceSpan; ...@@ -13,6 +13,8 @@ import android.text.style.TextAppearanceSpan;
import org.chromium.base.Log; import org.chromium.base.Log;
import org.chromium.chrome.R; import org.chromium.chrome.R;
import org.chromium.chrome.browser.omnibox.OmniboxSuggestionType;
import org.chromium.chrome.browser.omnibox.suggestions.OmniboxSuggestion;
import org.chromium.components.omnibox.AnswerTextType; import org.chromium.components.omnibox.AnswerTextType;
import org.chromium.components.omnibox.SuggestionAnswer; import org.chromium.components.omnibox.SuggestionAnswer;
...@@ -27,14 +29,22 @@ class AnswerTextClassic extends AnswerText { ...@@ -27,14 +29,22 @@ class AnswerTextClassic extends AnswerText {
* content. * content.
* *
* @param context Current context. * @param context Current context.
* @param answer Specifies answer to be converted. * @param suggestion Suggestion to be converted.
* @return array of AnswerText elements to use to construct suggestion item. * @return array of AnswerText elements to use to construct suggestion item.
*/ */
static AnswerText[] from(Context context, SuggestionAnswer answer) { static AnswerText[] from(Context context, OmniboxSuggestion suggestion) {
AnswerText[] result = new AnswerText[2]; AnswerText[] result = new AnswerText[2];
SuggestionAnswer answer = suggestion.getAnswer();
result[0] = new AnswerTextClassic(context, answer.getFirstLine()); if (answer == null) {
result[1] = new AnswerTextClassic(context, answer.getSecondLine()); // As an exception, we handle calculation suggestions, too, considering them an Answer,
// even if these are not one.
assert suggestion.getType() == OmniboxSuggestionType.CALCULATOR;
result[0] = new AnswerTextClassic(context, suggestion.getDisplayText());
result[1] = null;
} else {
result[0] = new AnswerTextClassic(context, answer.getFirstLine());
result[1] = new AnswerTextClassic(context, answer.getSecondLine());
}
// Trim number of presented query lines. // Trim number of presented query lines.
result[0].mMaxLines = 1; result[0].mMaxLines = 1;
...@@ -43,7 +53,7 @@ class AnswerTextClassic extends AnswerText { ...@@ -43,7 +53,7 @@ class AnswerTextClassic extends AnswerText {
} }
/** /**
* Create new instance of AnswerTextClassic. * Create new instance of AnswerTextClassic for answer suggestions.
* *
* @param context Current context. * @param context Current context.
* @param line Suggestion line that will be converted to Answer Text. * @param line Suggestion line that will be converted to Answer Text.
...@@ -53,6 +63,17 @@ class AnswerTextClassic extends AnswerText { ...@@ -53,6 +63,17 @@ class AnswerTextClassic extends AnswerText {
build(line); build(line);
} }
/**
* Create new instance of AnswerTextClassic for non-answer suggestions.
*
* @param context Current context.
* @param text Suggestion text.
*/
AnswerTextClassic(Context context, String text) {
super(context);
appendAndStyleText(text, getAppearanceForText(AnswerTextType.SUGGESTION));
}
/** /**
* Return the TextAppearanceSpan array specifying text decorations for a given field type. * Return the TextAppearanceSpan array specifying text decorations for a given field type.
* *
......
...@@ -11,6 +11,8 @@ import android.text.style.TextAppearanceSpan; ...@@ -11,6 +11,8 @@ import android.text.style.TextAppearanceSpan;
import org.chromium.base.Log; import org.chromium.base.Log;
import org.chromium.chrome.R; import org.chromium.chrome.R;
import org.chromium.chrome.browser.omnibox.OmniboxSuggestionType;
import org.chromium.chrome.browser.omnibox.suggestions.OmniboxSuggestion;
import org.chromium.components.omnibox.AnswerTextType; import org.chromium.components.omnibox.AnswerTextType;
import org.chromium.components.omnibox.AnswerType; import org.chromium.components.omnibox.AnswerType;
import org.chromium.components.omnibox.SuggestionAnswer; import org.chromium.components.omnibox.SuggestionAnswer;
...@@ -27,17 +29,24 @@ class AnswerTextNewLayout extends AnswerText { ...@@ -27,17 +29,24 @@ class AnswerTextNewLayout extends AnswerText {
* content. * content.
* *
* @param context Current context. * @param context Current context.
* @param answer Specifies answer to be converted. * @param suggestion Suggestion to be converted.
* @param query Query that triggered the suggestion.
* @return array of AnswerText elements to use to construct suggestion item. * @return array of AnswerText elements to use to construct suggestion item.
*/ */
static AnswerText[] from(Context context, SuggestionAnswer answer) { static AnswerText[] from(Context context, OmniboxSuggestion suggestion, String query) {
AnswerText[] result = new AnswerText[2]; AnswerText[] result = new AnswerText[2];
if (answer.getType() == AnswerType.DICTIONARY) { SuggestionAnswer answer = suggestion.getAnswer();
if (answer == null) {
// As an exception, we handle calculation suggestions, too, considering them an Answer,
// even if these are not one.
assert suggestion.getType() == OmniboxSuggestionType.CALCULATOR;
result[0] = new AnswerTextNewLayout(context, suggestion.getFillIntoEdit(), true);
result[1] = new AnswerTextNewLayout(context, query, false);
} else if (answer.getType() == AnswerType.DICTIONARY) {
result[0] = new AnswerTextNewLayout(context, answer.getFirstLine(), true); result[0] = new AnswerTextNewLayout(context, answer.getFirstLine(), true);
result[1] = new AnswerTextNewLayout(context, answer.getSecondLine(), false); result[1] = new AnswerTextNewLayout(context, answer.getSecondLine(), false);
result[0].mMaxLines = 1; result[0].mMaxLines = 1;
} else { } else {
result[0] = new AnswerTextNewLayout(context, answer.getSecondLine(), true); result[0] = new AnswerTextNewLayout(context, answer.getSecondLine(), true);
result[1] = new AnswerTextNewLayout(context, answer.getFirstLine(), false); result[1] = new AnswerTextNewLayout(context, answer.getFirstLine(), false);
...@@ -48,11 +57,11 @@ class AnswerTextNewLayout extends AnswerText { ...@@ -48,11 +57,11 @@ class AnswerTextNewLayout extends AnswerText {
} }
/** /**
* Create new instance of AnswerTextNewLayout. * Create new instance of AnswerTextNewLayout for answer suggestions.
* *
* @param context Current context. * @param context Current context.
* @param line Suggestion line that will be converted to Answer Text. * @param line Suggestion line that will be converted to Answer Text.
* @param isAnswerLine True, whether this instance holds answer. * @param isAnswerLine True, if this instance holds answer.
*/ */
AnswerTextNewLayout(Context context, SuggestionAnswer.ImageLine line, boolean isAnswerLine) { AnswerTextNewLayout(Context context, SuggestionAnswer.ImageLine line, boolean isAnswerLine) {
super(context); super(context);
...@@ -60,6 +69,18 @@ class AnswerTextNewLayout extends AnswerText { ...@@ -60,6 +69,18 @@ class AnswerTextNewLayout extends AnswerText {
build(line); build(line);
} }
/**
* Create new instance of AnswerTextNewLayout for non-answer suggestions.
* @param context Current context.
* @param text Suggestion text.
* @param isAnswerLine True, if this instance holds answer.
*/
AnswerTextNewLayout(Context context, String text, boolean isAnswerLine) {
super(context);
mIsAnswer = isAnswerLine;
appendAndStyleText(text, getAppearanceForText(AnswerTextType.SUGGESTION));
}
/** /**
* Return the TextAppearanceSpan array specifying text decorations for a given field type. * Return the TextAppearanceSpan array specifying text decorations for a given field type.
* *
......
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