Merge "Fixed an issue where the unread count would disappear too fast" into rvc-dev am: f9557e4400
Change-Id: Icd4466e73f3113c55f43064cec697bc2c366ab03
This commit is contained in:
@@ -386,14 +386,17 @@ public class ConversationLayout extends FrameLayout
|
|||||||
|
|
||||||
/** @hide */
|
/** @hide */
|
||||||
public void setUnreadCount(int unreadCount) {
|
public void setUnreadCount(int unreadCount) {
|
||||||
mUnreadBadge.setVisibility(mIsCollapsed && unreadCount > 1 ? VISIBLE : GONE);
|
boolean visible = mIsCollapsed && unreadCount > 1;
|
||||||
CharSequence text = unreadCount >= 100
|
mUnreadBadge.setVisibility(visible ? VISIBLE : GONE);
|
||||||
? getResources().getString(R.string.unread_convo_overflow, 99)
|
if (visible) {
|
||||||
: String.format(Locale.getDefault(), "%d", unreadCount);
|
CharSequence text = unreadCount >= 100
|
||||||
mUnreadBadge.setText(text);
|
? getResources().getString(R.string.unread_convo_overflow, 99)
|
||||||
mUnreadBadge.setBackgroundTintList(ColorStateList.valueOf(mLayoutColor));
|
: String.format(Locale.getDefault(), "%d", unreadCount);
|
||||||
boolean needDarkText = ColorUtils.calculateLuminance(mLayoutColor) > 0.5f;
|
mUnreadBadge.setText(text);
|
||||||
mUnreadBadge.setTextColor(needDarkText ? Color.BLACK : Color.WHITE);
|
mUnreadBadge.setBackgroundTintList(ColorStateList.valueOf(mLayoutColor));
|
||||||
|
boolean needDarkText = ColorUtils.calculateLuminance(mLayoutColor) > 0.5f;
|
||||||
|
mUnreadBadge.setTextColor(needDarkText ? Color.BLACK : Color.WHITE);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void addRemoteInputHistoryToMessages(
|
private void addRemoteInputHistoryToMessages(
|
||||||
|
|||||||
@@ -103,12 +103,20 @@ class ConversationNotificationManager @Inject constructor(
|
|||||||
override fun onEntryInflated(entry: NotificationEntry) {
|
override fun onEntryInflated(entry: NotificationEntry) {
|
||||||
if (!entry.ranking.isConversation) return
|
if (!entry.ranking.isConversation) return
|
||||||
fun updateCount(isExpanded: Boolean) {
|
fun updateCount(isExpanded: Boolean) {
|
||||||
if (isExpanded && !notifPanelCollapsed) {
|
if (isExpanded && (!notifPanelCollapsed || entry.isPinnedAndExpanded())) {
|
||||||
resetCount(entry.key)
|
resetCount(entry.key)
|
||||||
entry.row?.let(::resetBadgeUi)
|
entry.row?.let(::resetBadgeUi)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
entry.row?.setOnExpansionChangedListener(::updateCount)
|
entry.row?.setOnExpansionChangedListener { isExpanded ->
|
||||||
|
if (entry.row?.isShown == true && isExpanded) {
|
||||||
|
entry.row.performOnIntrinsicHeightReached {
|
||||||
|
updateCount(isExpanded)
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
updateCount(isExpanded)
|
||||||
|
}
|
||||||
|
}
|
||||||
updateCount(entry.row?.isExpanded == true)
|
updateCount(entry.row?.isExpanded == true)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -169,7 +177,8 @@ class ConversationNotificationManager @Inject constructor(
|
|||||||
|
|
||||||
private fun resetBadgeUi(row: ExpandableNotificationRow): Unit =
|
private fun resetBadgeUi(row: ExpandableNotificationRow): Unit =
|
||||||
(row.layouts?.asSequence() ?: emptySequence())
|
(row.layouts?.asSequence() ?: emptySequence())
|
||||||
.mapNotNull { layout -> layout.contractedChild as? ConversationLayout }
|
.flatMap { layout -> layout.allViews.asSequence()}
|
||||||
|
.mapNotNull { view -> view as? ConversationLayout }
|
||||||
.forEach { convoLayout -> convoLayout.setUnreadCount(0) }
|
.forEach { convoLayout -> convoLayout.setUnreadCount(0) }
|
||||||
|
|
||||||
private data class ConversationState(val unreadCount: Int, val notification: Notification)
|
private data class ConversationState(val unreadCount: Int, val notification: Notification)
|
||||||
|
|||||||
@@ -601,6 +601,13 @@ public final class NotificationEntry extends ListEntry {
|
|||||||
return row != null && row.isPinned();
|
return row != null && row.isPinned();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Is this entry pinned and was expanded while doing so
|
||||||
|
*/
|
||||||
|
public boolean isPinnedAndExpanded() {
|
||||||
|
return row != null && row.isPinnedAndExpanded();
|
||||||
|
}
|
||||||
|
|
||||||
public void setRowPinned(boolean pinned) {
|
public void setRowPinned(boolean pinned) {
|
||||||
if (row != null) row.setPinned(pinned);
|
if (row != null) row.setPinned(pinned);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -284,6 +284,12 @@ public class ExpandableNotificationRow extends ActivatableNotificationView
|
|||||||
if (isPinned()) {
|
if (isPinned()) {
|
||||||
nowExpanded = !mExpandedWhenPinned;
|
nowExpanded = !mExpandedWhenPinned;
|
||||||
mExpandedWhenPinned = nowExpanded;
|
mExpandedWhenPinned = nowExpanded;
|
||||||
|
// Also notify any expansion changed listeners. This is necessary since the
|
||||||
|
// expansion doesn't actually change (it's already system expanded) but it
|
||||||
|
// changes visually
|
||||||
|
if (mExpansionChangedListener != null) {
|
||||||
|
mExpansionChangedListener.onExpansionChanged(nowExpanded);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
nowExpanded = !isExpanded();
|
nowExpanded = !isExpanded();
|
||||||
setUserExpanded(nowExpanded);
|
setUserExpanded(nowExpanded);
|
||||||
@@ -326,6 +332,7 @@ public class ExpandableNotificationRow extends ActivatableNotificationView
|
|||||||
private NotificationInlineImageResolver mImageResolver;
|
private NotificationInlineImageResolver mImageResolver;
|
||||||
private NotificationMediaManager mMediaManager;
|
private NotificationMediaManager mMediaManager;
|
||||||
@Nullable private OnExpansionChangedListener mExpansionChangedListener;
|
@Nullable private OnExpansionChangedListener mExpansionChangedListener;
|
||||||
|
@Nullable private Runnable mOnIntrinsicHeightReachedRunnable;
|
||||||
|
|
||||||
private SystemNotificationAsyncTask mSystemNotificationAsyncTask =
|
private SystemNotificationAsyncTask mSystemNotificationAsyncTask =
|
||||||
new SystemNotificationAsyncTask();
|
new SystemNotificationAsyncTask();
|
||||||
@@ -358,6 +365,16 @@ public class ExpandableNotificationRow extends ActivatableNotificationView
|
|||||||
return Arrays.copyOf(mLayouts, mLayouts.length);
|
return Arrays.copyOf(mLayouts, mLayouts.length);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Is this entry pinned and was expanded while doing so
|
||||||
|
*/
|
||||||
|
public boolean isPinnedAndExpanded() {
|
||||||
|
if (!isPinned()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return mExpandedWhenPinned;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isGroupExpansionChanging() {
|
public boolean isGroupExpansionChanging() {
|
||||||
if (isChildInGroup()) {
|
if (isChildInGroup()) {
|
||||||
@@ -2690,6 +2707,7 @@ public class ExpandableNotificationRow extends ActivatableNotificationView
|
|||||||
if (mMenuRow != null && mMenuRow.getMenuView() != null) {
|
if (mMenuRow != null && mMenuRow.getMenuView() != null) {
|
||||||
mMenuRow.onParentHeightUpdate();
|
mMenuRow.onParentHeightUpdate();
|
||||||
}
|
}
|
||||||
|
handleIntrinsicHeightReached();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -2907,6 +2925,24 @@ public class ExpandableNotificationRow extends ActivatableNotificationView
|
|||||||
mExpansionChangedListener = listener;
|
mExpansionChangedListener = listener;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Perform an action when the notification height has reached its intrinsic height.
|
||||||
|
*
|
||||||
|
* @param runnable the runnable to run
|
||||||
|
*/
|
||||||
|
public void performOnIntrinsicHeightReached(@Nullable Runnable runnable) {
|
||||||
|
mOnIntrinsicHeightReachedRunnable = runnable;
|
||||||
|
handleIntrinsicHeightReached();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void handleIntrinsicHeightReached() {
|
||||||
|
if (mOnIntrinsicHeightReachedRunnable != null
|
||||||
|
&& getActualHeight() == getIntrinsicHeight()) {
|
||||||
|
mOnIntrinsicHeightReachedRunnable.run();
|
||||||
|
mOnIntrinsicHeightReachedRunnable = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onInitializeAccessibilityNodeInfoInternal(AccessibilityNodeInfo info) {
|
public void onInitializeAccessibilityNodeInfoInternal(AccessibilityNodeInfo info) {
|
||||||
super.onInitializeAccessibilityNodeInfoInternal(info);
|
super.onInitializeAccessibilityNodeInfoInternal(info);
|
||||||
|
|||||||
@@ -16,6 +16,7 @@
|
|||||||
|
|
||||||
package com.android.systemui.statusbar.notification.row;
|
package com.android.systemui.statusbar.notification.row;
|
||||||
|
|
||||||
|
import android.annotation.NonNull;
|
||||||
import android.annotation.Nullable;
|
import android.annotation.Nullable;
|
||||||
import android.app.Notification;
|
import android.app.Notification;
|
||||||
import android.app.PendingIntent;
|
import android.app.PendingIntent;
|
||||||
@@ -988,6 +989,14 @@ public class NotificationContentView extends FrameLayout {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public @NonNull View[] getAllViews() {
|
||||||
|
return new View[] {
|
||||||
|
mContractedChild,
|
||||||
|
mHeadsUpChild,
|
||||||
|
mExpandedChild,
|
||||||
|
mSingleLineView };
|
||||||
|
}
|
||||||
|
|
||||||
public NotificationViewWrapper getVisibleWrapper(int visibleType) {
|
public NotificationViewWrapper getVisibleWrapper(int visibleType) {
|
||||||
switch (visibleType) {
|
switch (visibleType) {
|
||||||
case VISIBLE_TYPE_EXPANDED:
|
case VISIBLE_TYPE_EXPANDED:
|
||||||
|
|||||||
Reference in New Issue
Block a user