Merge "Add a reason the smart suggestion isn't shown to the layout params."
This commit is contained in:
committed by
Android (Google) Code Review
commit
caeabe22ad
@@ -264,6 +264,7 @@ public class SmartReplyView extends ViewGroup {
|
||||
if (maxNumActions != -1 // -1 means 'no limit'
|
||||
&& lp.mButtonType == SmartButtonType.ACTION
|
||||
&& numShownActions >= maxNumActions) {
|
||||
lp.mNoShowReason = "max-actions-shown";
|
||||
// We've reached the maximum number of actions, don't add another one!
|
||||
continue;
|
||||
}
|
||||
@@ -274,8 +275,15 @@ public class SmartReplyView extends ViewGroup {
|
||||
coveredSuggestions.add(child);
|
||||
|
||||
final int lineCount = ((Button) child).getLineCount();
|
||||
if (lineCount < 1 || lineCount > 2) {
|
||||
// If smart reply has no text, or more than two lines, then don't show it.
|
||||
if (lineCount < 1) {
|
||||
// If smart reply has no text, then don't show it.
|
||||
lp.mNoShowReason = "line-count-0";
|
||||
continue;
|
||||
|
||||
}
|
||||
if (lineCount > 2) {
|
||||
// If smart reply has more than two lines, then don't show it.
|
||||
lp.mNoShowReason = "line-count-3+";
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -324,6 +332,7 @@ public class SmartReplyView extends ViewGroup {
|
||||
markButtonsWithPendingSqueezeStatusAs(
|
||||
LayoutParams.SQUEEZE_STATUS_FAILED, coveredSuggestions);
|
||||
|
||||
lp.mNoShowReason = "overflow";
|
||||
// The current button doesn't fit, keep on adding lower-priority buttons in case
|
||||
// any of those fit.
|
||||
continue;
|
||||
@@ -336,6 +345,7 @@ public class SmartReplyView extends ViewGroup {
|
||||
}
|
||||
|
||||
lp.show = true;
|
||||
lp.mNoShowReason = "n/a";
|
||||
displayedChildCount++;
|
||||
if (lp.mButtonType == SmartButtonType.ACTION) {
|
||||
numShownActions++;
|
||||
@@ -349,6 +359,7 @@ public class SmartReplyView extends ViewGroup {
|
||||
for (View smartReplyButton : smartReplies) {
|
||||
final LayoutParams lp = (LayoutParams) smartReplyButton.getLayoutParams();
|
||||
lp.show = false;
|
||||
lp.mNoShowReason = "not-enough-system-replies";
|
||||
}
|
||||
// Reset our measures back to when we had only added actions (before adding
|
||||
// replies).
|
||||
@@ -427,6 +438,8 @@ public class SmartReplyView extends ViewGroup {
|
||||
pw.print(lp.squeezeStatus);
|
||||
pw.print(" show=");
|
||||
pw.print(lp.show);
|
||||
pw.print(" noShowReason=");
|
||||
pw.print(lp.mNoShowReason);
|
||||
pw.print(" view=");
|
||||
pw.println(child);
|
||||
}
|
||||
@@ -498,6 +511,7 @@ public class SmartReplyView extends ViewGroup {
|
||||
final LayoutParams lp = (LayoutParams) child.getLayoutParams();
|
||||
lp.show = false;
|
||||
lp.squeezeStatus = LayoutParams.SQUEEZE_STATUS_NONE;
|
||||
lp.mNoShowReason = "reset";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -772,6 +786,7 @@ public class SmartReplyView extends ViewGroup {
|
||||
private boolean show = false;
|
||||
private int squeezeStatus = SQUEEZE_STATUS_NONE;
|
||||
SmartButtonType mButtonType = SmartButtonType.REPLY;
|
||||
String mNoShowReason = "new";
|
||||
|
||||
private LayoutParams(Context c, AttributeSet attrs) {
|
||||
super(c, attrs);
|
||||
|
||||
Reference in New Issue
Block a user