Fix Gmail undo state.

We forced all notifications to have an expanded
state, but the Gmail undo notification is totally
broken in that case.  This check exempts an obviosuly
bad expanded state from having to exist, fixing
Gmail's undo flow in the process.

Fixes: 173774694
Bug: 163626038
Bug: 173550917
Test: manual
Change-Id: I8973907ceb06ccf06c0a685fc0f2a2d283794fe5
This commit is contained in:
Jeff DeCew
2020-11-17 20:48:42 -05:00
parent 2b95ad43fc
commit 4d19b03fd5

View File

@@ -5520,7 +5520,7 @@ public class Notification implements Parcelable
result = mStyle.makeBigContentView();
hideLine1Text(result);
}
if (result == null) {
if (result == null && bigContentViewRequired()) {
result = applyStandardTemplateWithActions(getBigBaseLayoutResource(),
StandardTemplateParams.VIEW_TYPE_BIG, null /* result */);
}
@@ -5528,6 +5528,16 @@ public class Notification implements Parcelable
return result;
}
private boolean bigContentViewRequired() {
// If the big content view has no content, we can exempt the app from having to show it.
// TODO(b/173550917): add an UNDO style then force this requirement on apps targeting S
boolean exempt = mN.contentView != null && mN.bigContentView == null
&& mStyle == null && mActions.size() == 0
&& mN.extras.getCharSequence(EXTRA_TITLE) == null
&& mN.extras.getCharSequence(EXTRA_TEXT) == null;
return !exempt;
}
/**
* Construct a RemoteViews for the final notification header only. This will not be
* colorized.