Merge "Make Notification long clickable" into tm-qpr-dev am: ae1b2e33b1

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/21335160

Change-Id: Ie4599db441ee7d6ed2d989f4511b01c23564c8b4
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
Ibrahim Yilmaz
2023-02-15 18:48:50 +00:00
committed by Automerger Merge Worker
2 changed files with 29 additions and 2 deletions

View File

@@ -1196,6 +1196,22 @@ public class ExpandableNotificationRow extends ActivatableNotificationView
return getShowingLayout().getVisibleWrapper();
}
/**
* @return whether the notification row is long clickable or not.
*/
public boolean isNotificationRowLongClickable() {
if (mLongPressListener == null) {
return false;
}
if (!areGutsExposed()) { // guts is not opened
return true;
}
// if it is leave behind, it shouldn't be long clickable.
return !isGutsLeaveBehind();
}
public void setLongPressListener(LongPressListener longPressListener) {
mLongPressListener = longPressListener;
}
@@ -2947,6 +2963,10 @@ public class ExpandableNotificationRow extends ActivatableNotificationView
return (mGuts != null && mGuts.isExposed());
}
private boolean isGutsLeaveBehind() {
return (mGuts != null && mGuts.isLeavebehind());
}
@Override
public boolean isContentExpandable() {
if (mIsSummaryWithChildren && !shouldShowPublic()) {
@@ -3394,7 +3414,12 @@ public class ExpandableNotificationRow extends ActivatableNotificationView
@Override
public void onInitializeAccessibilityNodeInfoInternal(AccessibilityNodeInfo info) {
super.onInitializeAccessibilityNodeInfoInternal(info);
info.addAction(AccessibilityNodeInfo.AccessibilityAction.ACTION_LONG_CLICK);
final boolean isLongClickable = isNotificationRowLongClickable();
if (isLongClickable) {
info.addAction(AccessibilityNodeInfo.AccessibilityAction.ACTION_LONG_CLICK);
}
info.setLongClickable(isLongClickable);
if (canViewBeDismissed() && !mIsSnoozed) {
info.addAction(AccessibilityNodeInfo.AccessibilityAction.ACTION_DISMISS);
}

View File

@@ -586,7 +586,9 @@ public class NotificationGutsManager implements NotifGutsViewManager {
}
final ExpandableNotificationRow row = (ExpandableNotificationRow) view;
view.performHapticFeedback(HapticFeedbackConstants.LONG_PRESS);
if (row.isNotificationRowLongClickable()) {
view.performHapticFeedback(HapticFeedbackConstants.LONG_PRESS);
}
if (row.areGutsExposed()) {
closeAndSaveGuts(false /* removeLeavebehind */, false /* force */,
true /* removeControls */, -1 /* x */, -1 /* y */,