Merge "Allowing the notification to be a bit bigger for the remote input history" into pi-dev

am: 9e3d7d6378

Change-Id: I0ded19e5d634ef3c81c68a58b92061b9dfda2c00
This commit is contained in:
Selim Cinek
2018-05-23 12:25:58 -07:00
committed by android-build-merger
4 changed files with 71 additions and 4 deletions

View File

@@ -4922,7 +4922,8 @@ public class Notification implements Parcelable
CharSequence[] replyText = mN.extras.getCharSequenceArray(EXTRA_REMOTE_INPUT_HISTORY);
if (!p.ambient && validRemoteInput && replyText != null
&& replyText.length > 0 && !TextUtils.isEmpty(replyText[0])) {
&& replyText.length > 0 && !TextUtils.isEmpty(replyText[0])
&& p.maxRemoteInputHistory > 0) {
boolean showSpinner = mN.extras.getBoolean(EXTRA_SHOW_REMOTE_INPUT_SPINNER);
big.setViewVisibility(R.id.notification_material_reply_container, View.VISIBLE);
big.setViewVisibility(R.id.notification_material_reply_text_1_container,
@@ -4937,13 +4938,15 @@ public class Notification implements Parcelable
ColorStateList.valueOf(
isColorized() ? getPrimaryTextColor() : resolveContrastColor()));
if (replyText.length > 1 && !TextUtils.isEmpty(replyText[1])) {
if (replyText.length > 1 && !TextUtils.isEmpty(replyText[1])
&& p.maxRemoteInputHistory > 1) {
big.setViewVisibility(R.id.notification_material_reply_text_2, View.VISIBLE);
big.setTextViewText(R.id.notification_material_reply_text_2,
processTextSpans(replyText[1]));
setTextViewColorSecondary(big, R.id.notification_material_reply_text_2);
if (replyText.length > 2 && !TextUtils.isEmpty(replyText[2])) {
if (replyText.length > 2 && !TextUtils.isEmpty(replyText[2])
&& p.maxRemoteInputHistory > 2) {
big.setViewVisibility(
R.id.notification_material_reply_text_3, View.VISIBLE);
big.setTextViewText(R.id.notification_material_reply_text_3,
@@ -5106,7 +5109,13 @@ public class Notification implements Parcelable
return null;
}
return applyStandardTemplateWithActions(getBigBaseLayoutResource(), null /* result */);
// We only want at most a single remote input history to be shown here, otherwise
// the content would become squished.
StandardTemplateParams p = mParams.reset().fillTextsFrom(this)
.setMaxRemoteInputHistory(1);
return applyStandardTemplateWithActions(getBigBaseLayoutResource(),
p,
null /* result */);
}
/**
@@ -5975,6 +5984,12 @@ public class Notification implements Parcelable
* object.
*/
public static abstract class Style {
/**
* The number of items allowed simulatanously in the remote input history.
* @hide
*/
static final int MAX_REMOTE_INPUT_HISTORY_LINES = 3;
private CharSequence mBigContentTitle;
/**
@@ -7434,6 +7449,11 @@ public class Notification implements Parcelable
* @see Notification#bigContentView
*/
public static class InboxStyle extends Style {
/**
* The number of lines of remote input history allowed until we start reducing lines.
*/
private static final int NUMBER_OF_HISTORY_ALLOWED_UNTIL_REDUCTION = 1;
private ArrayList<CharSequence> mTexts = new ArrayList<CharSequence>(5);
public InboxStyle() {
@@ -7533,6 +7553,28 @@ public class Notification implements Parcelable
if (mBuilder.mActions.size() > 0) {
maxRows--;
}
CharSequence[] remoteInputHistory = mBuilder.mN.extras.getCharSequenceArray(
EXTRA_REMOTE_INPUT_HISTORY);
if (remoteInputHistory != null
&& remoteInputHistory.length > NUMBER_OF_HISTORY_ALLOWED_UNTIL_REDUCTION) {
// Let's remove some messages to make room for the remote input history.
// 1 is always able to fit, but let's remove them if they are 2 or 3
int numRemoteInputs = Math.min(remoteInputHistory.length,
MAX_REMOTE_INPUT_HISTORY_LINES);
int totalNumRows = mTexts.size() + numRemoteInputs
- NUMBER_OF_HISTORY_ALLOWED_UNTIL_REDUCTION;
if (totalNumRows > maxRows) {
int overflow = totalNumRows - maxRows;
if (mTexts.size() > maxRows) {
// Heuristic: if the Texts don't fit anyway, we'll rather drop the last
// few messages, even with the remote input
maxRows -= overflow;
} else {
// otherwise we drop the first messages
i = overflow;
}
}
}
while (i < mTexts.size() && i < maxRows) {
CharSequence str = mTexts.get(i);
if (!TextUtils.isEmpty(str)) {
@@ -9603,6 +9645,7 @@ public class Notification implements Parcelable
CharSequence title;
CharSequence text;
CharSequence headerTextSecondary;
int maxRemoteInputHistory = Style.MAX_REMOTE_INPUT_HISTORY_LINES;
boolean hideLargeIcon;
boolean hideReplyIcon;
@@ -9612,6 +9655,7 @@ public class Notification implements Parcelable
title = null;
text = null;
headerTextSecondary = null;
maxRemoteInputHistory = Style.MAX_REMOTE_INPUT_HISTORY_LINES;
return this;
}
@@ -9663,5 +9707,15 @@ public class Notification implements Parcelable
this.text = b.processLegacyText(text, ambient);
return this;
}
/**
* Set the maximum lines of remote input history lines allowed.
* @param maxRemoteInputHistory The number of lines.
* @return The builder for method chaining.
*/
public StandardTemplateParams setMaxRemoteInputHistory(int maxRemoteInputHistory) {
this.maxRemoteInputHistory = maxRemoteInputHistory;
return this;
}
}
}

View File

@@ -960,6 +960,10 @@
add about 88dp of height to the notifications. -->
<dimen name="smart_reply_button_max_height">100dp</dimen>
<!-- The extra height that we allow a notification with a remote input history to be taller than
the regular notification, when we have remote input history texts present. -->
<dimen name="remote_input_history_extra_height">60dp</dimen>
<!-- Fingerprint Dialog values -->
<dimen name="fingerprint_dialog_fp_icon_size">64dp</dimen>
<dimen name="fingerprint_dialog_animation_translation_offset">350dp</dimen>

View File

@@ -189,6 +189,7 @@ public class NotificationContentView extends FrameLayout {
if (mExpandedSmartReplyView != null) {
notificationMaxHeight += mExpandedSmartReplyView.getHeightUpperLimit();
}
notificationMaxHeight += mExpandedWrapper.getExtraMeasureHeight();
int size = notificationMaxHeight;
ViewGroup.LayoutParams layoutParams = mExpandedChild.getLayoutParams();
boolean useExactly = false;

View File

@@ -34,6 +34,7 @@ import android.widget.TextView;
import com.android.internal.util.NotificationColorUtil;
import com.android.internal.widget.NotificationActionListLayout;
import com.android.systemui.Dependency;
import com.android.systemui.R;
import com.android.systemui.UiOffloadThread;
import com.android.systemui.statusbar.CrossFadeHelper;
import com.android.systemui.statusbar.ExpandableNotificationRow;
@@ -58,6 +59,7 @@ public class NotificationTemplateViewWrapper extends NotificationHeaderViewWrapp
private NotificationActionListLayout mActions;
private ArraySet<PendingIntent> mCancelledPendingIntents = new ArraySet<>();
private UiOffloadThread mUiOffloadThread;
private View mRemoteInputHistory;
protected NotificationTemplateViewWrapper(Context ctx, View view,
ExpandableNotificationRow row) {
@@ -146,6 +148,8 @@ public class NotificationTemplateViewWrapper extends NotificationHeaderViewWrapp
mActionsContainer = mView.findViewById(com.android.internal.R.id.actions_container);
mActions = mView.findViewById(com.android.internal.R.id.actions);
mReplyAction = mView.findViewById(com.android.internal.R.id.reply_icon_action);
mRemoteInputHistory = mView.findViewById(
com.android.internal.R.id.notification_material_reply_container);
updatePendingIntentCancellations();
}
@@ -329,6 +333,10 @@ public class NotificationTemplateViewWrapper extends NotificationHeaderViewWrapp
if (mActions != null) {
extra = mActions.getExtraMeasureHeight();
}
if (mRemoteInputHistory != null && mRemoteInputHistory.getVisibility() != View.GONE) {
extra += mRow.getContext().getResources().getDimensionPixelSize(
R.dimen.remote_input_history_extra_height);
}
return extra + super.getExtraMeasureHeight();
}
}