Merge "Allow extra height for the smartreply buttons" into pi-dev

am: 85678bfbbd

Change-Id: I4a0548757f366a24113bea9aaa70ae0d6f53db12
This commit is contained in:
Milo Sredkov
2018-04-12 01:06:13 -07:00
committed by android-build-merger
3 changed files with 33 additions and 4 deletions

View File

@@ -933,6 +933,11 @@
<dimen name="smart_reply_button_font_size">14sp</dimen>
<dimen name="smart_reply_button_line_spacing_extra">6sp</dimen> <!-- Total line height 20sp. -->
<!-- A reasonable upper bound for the height of the smart reply button. The measuring code
needs to start with a guess for the maximum size. Currently two-line smart reply buttons
add about 88dp of height to the notifications. -->
<dimen name="smart_reply_button_max_height">100dp</dimen>
<!-- Fingerprint Dialog values -->
<dimen name="fingerprint_dialog_fp_icon_size">64dp</dimen>
<dimen name="fingerprint_dialog_animation_translation_offset">350dp</dimen>

View File

@@ -80,6 +80,7 @@ public class NotificationContentView extends FrameLayout {
private RemoteInputView mHeadsUpRemoteInput;
private SmartReplyConstants mSmartReplyConstants;
private SmartReplyView mExpandedSmartReplyView;
private SmartReplyLogger mSmartReplyLogger;
private NotificationViewWrapper mContractedWrapper;
@@ -184,7 +185,11 @@ public class NotificationContentView extends FrameLayout {
}
int maxChildHeight = 0;
if (mExpandedChild != null) {
int size = Math.min(maxSize, mNotificationMaxHeight);
int notificationMaxHeight = mNotificationMaxHeight;
if (mExpandedSmartReplyView != null) {
notificationMaxHeight += mExpandedSmartReplyView.getHeightUpperLimit();
}
int size = Math.min(maxSize, notificationMaxHeight);
ViewGroup.LayoutParams layoutParams = mExpandedChild.getLayoutParams();
boolean useExactly = false;
if (layoutParams.height >= 0) {
@@ -1348,10 +1353,10 @@ public class NotificationContentView extends FrameLayout {
private void applySmartReplyView(RemoteInput remoteInput, PendingIntent pendingIntent,
NotificationData.Entry entry) {
if (mExpandedChild != null) {
SmartReplyView view =
mExpandedSmartReplyView =
applySmartReplyView(mExpandedChild, remoteInput, pendingIntent, entry);
if (view != null && remoteInput != null && remoteInput.getChoices() != null
&& remoteInput.getChoices().length > 0) {
if (mExpandedSmartReplyView != null && remoteInput != null
&& remoteInput.getChoices() != null && remoteInput.getChoices().length > 0) {
mSmartReplyLogger.smartRepliesAdded(entry, remoteInput.getChoices().length);
}
}

View File

@@ -25,6 +25,7 @@ import com.android.systemui.Dependency;
import com.android.systemui.R;
import com.android.systemui.statusbar.NotificationData;
import com.android.systemui.statusbar.SmartReplyLogger;
import com.android.systemui.statusbar.notification.NotificationUtils;
import com.android.systemui.statusbar.phone.KeyguardDismissUtil;
import java.text.BreakIterator;
@@ -48,6 +49,12 @@ public class SmartReplyView extends ViewGroup {
private final SmartReplyConstants mConstants;
private final KeyguardDismissUtil mKeyguardDismissUtil;
/**
* The upper bound for the height of this view in pixels. Notifications are automatically
* recreated on density or font size changes so caching this should be fine.
*/
private final int mHeightUpperLimit;
/** Spacing to be applied between views. */
private final int mSpacing;
@@ -69,6 +76,9 @@ public class SmartReplyView extends ViewGroup {
mConstants = Dependency.get(SmartReplyConstants.class);
mKeyguardDismissUtil = Dependency.get(KeyguardDismissUtil.class);
mHeightUpperLimit = NotificationUtils.getFontScaledHeight(mContext,
R.dimen.smart_reply_button_max_height);
int spacing = 0;
int singleLineButtonPaddingHorizontal = 0;
int doubleLineButtonPaddingHorizontal = 0;
@@ -98,10 +108,19 @@ public class SmartReplyView extends ViewGroup {
mSingleToDoubleLineButtonWidthIncrease =
2 * (doubleLineButtonPaddingHorizontal - singleLineButtonPaddingHorizontal);
mBreakIterator = BreakIterator.getLineInstance();
reallocateCandidateButtonQueueForSqueezing();
}
/**
* Returns an upper bound for the height of this view in pixels. This method is intended to be
* invoked before onMeasure, so it doesn't do any analysis on the contents of the buttons.
*/
public int getHeightUpperLimit() {
return mHeightUpperLimit;
}
private void reallocateCandidateButtonQueueForSqueezing() {
// Instead of clearing the priority queue, we re-allocate so that it would fit all buttons
// exactly. This avoids (1) wasting memory because PriorityQueue never shrinks and