Merge "Fixed a bug where notifications could reappear" into nyc-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
4226dcef1e
@@ -40,7 +40,6 @@ import android.content.pm.PackageManager;
|
|||||||
import android.content.pm.PackageManager.NameNotFoundException;
|
import android.content.pm.PackageManager.NameNotFoundException;
|
||||||
import android.content.pm.UserInfo;
|
import android.content.pm.UserInfo;
|
||||||
import android.content.res.Configuration;
|
import android.content.res.Configuration;
|
||||||
import android.content.res.Resources;
|
|
||||||
import android.database.ContentObserver;
|
import android.database.ContentObserver;
|
||||||
import android.graphics.Rect;
|
import android.graphics.Rect;
|
||||||
import android.graphics.drawable.Drawable;
|
import android.graphics.drawable.Drawable;
|
||||||
@@ -959,18 +958,15 @@ public abstract class BaseStatusBar extends SystemUI implements
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected View bindVetoButtonClickListener(View row, final StatusBarNotification n) {
|
protected void bindDismissListener(final ExpandableNotificationRow row) {
|
||||||
View vetoButton = row.findViewById(R.id.veto);
|
row.setOnDismissListener(new View.OnClickListener() {
|
||||||
vetoButton.setOnClickListener(new View.OnClickListener() {
|
|
||||||
public void onClick(View v) {
|
public void onClick(View v) {
|
||||||
// Accessibility feedback
|
// Accessibility feedback
|
||||||
v.announceForAccessibility(
|
v.announceForAccessibility(
|
||||||
mContext.getString(R.string.accessibility_notification_dismissed));
|
mContext.getString(R.string.accessibility_notification_dismissed));
|
||||||
performRemoveNotification(n, false /* removeView */);
|
performRemoveNotification(row.getStatusBarNotification(), false /* removeView */);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
vetoButton.setImportantForAccessibility(View.IMPORTANT_FOR_ACCESSIBILITY_NO);
|
|
||||||
return vetoButton;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void performRemoveNotification(StatusBarNotification n, boolean removeView) {
|
protected void performRemoveNotification(StatusBarNotification n, boolean removeView) {
|
||||||
@@ -1647,9 +1643,7 @@ public abstract class BaseStatusBar extends SystemUI implements
|
|||||||
}
|
}
|
||||||
|
|
||||||
workAroundBadLayerDrawableOpacity(row);
|
workAroundBadLayerDrawableOpacity(row);
|
||||||
View vetoButton = bindVetoButtonClickListener(row, sbn);
|
bindDismissListener(row);
|
||||||
vetoButton.setContentDescription(mContext.getString(
|
|
||||||
R.string.accessibility_remove_notification));
|
|
||||||
|
|
||||||
// NB: the large icon is now handled entirely by the template
|
// NB: the large icon is now handled entirely by the template
|
||||||
|
|
||||||
@@ -2409,10 +2403,6 @@ public abstract class BaseStatusBar extends SystemUI implements
|
|||||||
updateHeadsUp(key, entry, shouldPeek, alertAgain);
|
updateHeadsUp(key, entry, shouldPeek, alertAgain);
|
||||||
updateNotifications();
|
updateNotifications();
|
||||||
|
|
||||||
// Update the veto button accordingly (and as a result, whether this row is
|
|
||||||
// swipe-dismissable)
|
|
||||||
bindVetoButtonClickListener(entry.row, notification);
|
|
||||||
|
|
||||||
if (!notification.isClearable()) {
|
if (!notification.isClearable()) {
|
||||||
// The user may have performed a dismiss action on the notification, since it's
|
// The user may have performed a dismiss action on the notification, since it's
|
||||||
// not clearable we should snap it back.
|
// not clearable we should snap it back.
|
||||||
|
|||||||
@@ -109,7 +109,6 @@ public class ExpandableNotificationRow extends ActivatableNotificationView {
|
|||||||
private int mHeadsUpHeight;
|
private int mHeadsUpHeight;
|
||||||
private View mVetoButton;
|
private View mVetoButton;
|
||||||
private int mNotificationColor;
|
private int mNotificationColor;
|
||||||
private boolean mClearable;
|
|
||||||
private ExpansionLogger mLogger;
|
private ExpansionLogger mLogger;
|
||||||
private String mLoggingKey;
|
private String mLoggingKey;
|
||||||
private NotificationSettingsIconRow mSettingsIconRow;
|
private NotificationSettingsIconRow mSettingsIconRow;
|
||||||
@@ -280,7 +279,6 @@ public class ExpandableNotificationRow extends ActivatableNotificationView {
|
|||||||
mPublicLayout.onNotificationUpdated(entry);
|
mPublicLayout.onNotificationUpdated(entry);
|
||||||
mShowingPublicInitialized = false;
|
mShowingPublicInitialized = false;
|
||||||
updateNotificationColor();
|
updateNotificationColor();
|
||||||
updateClearability();
|
|
||||||
if (mIsSummaryWithChildren) {
|
if (mIsSummaryWithChildren) {
|
||||||
mChildrenContainer.recreateNotificationHeader(mExpandClickListener, mEntry.notification);
|
mChildrenContainer.recreateNotificationHeader(mExpandClickListener, mEntry.notification);
|
||||||
mChildrenContainer.onNotificationUpdated();
|
mChildrenContainer.onNotificationUpdated();
|
||||||
@@ -779,6 +777,14 @@ public class ExpandableNotificationRow extends ActivatableNotificationView {
|
|||||||
return mGroupParentWhenDismissed;
|
return mGroupParentWhenDismissed;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void performDismiss() {
|
||||||
|
mVetoButton.performClick();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setOnDismissListener(OnClickListener listener) {
|
||||||
|
mVetoButton.setOnClickListener(listener);
|
||||||
|
}
|
||||||
|
|
||||||
public interface ExpansionLogger {
|
public interface ExpansionLogger {
|
||||||
public void logNotificationExpansion(String key, boolean userAction, boolean expanded);
|
public void logNotificationExpansion(String key, boolean userAction, boolean expanded);
|
||||||
}
|
}
|
||||||
@@ -880,6 +886,9 @@ public class ExpandableNotificationRow extends ActivatableNotificationView {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
mVetoButton = findViewById(R.id.veto);
|
mVetoButton = findViewById(R.id.veto);
|
||||||
|
mVetoButton.setImportantForAccessibility(View.IMPORTANT_FOR_ACCESSIBILITY_NO);
|
||||||
|
mVetoButton.setContentDescription(mContext.getString(
|
||||||
|
R.string.accessibility_remove_notification));
|
||||||
|
|
||||||
// Add the views that we translate to reveal the gear
|
// Add the views that we translate to reveal the gear
|
||||||
mTranslateableViews = new ArrayList<View>();
|
mTranslateableViews = new ArrayList<View>();
|
||||||
@@ -893,6 +902,10 @@ public class ExpandableNotificationRow extends ActivatableNotificationView {
|
|||||||
mTranslateableViews.remove(mGutsStub);
|
mTranslateableViews.remove(mGutsStub);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public View getVetoButton() {
|
||||||
|
return mVetoButton;
|
||||||
|
}
|
||||||
|
|
||||||
public void resetTranslation() {
|
public void resetTranslation() {
|
||||||
if (mTranslateableViews != null) {
|
if (mTranslateableViews != null) {
|
||||||
for (int i = 0; i < mTranslateableViews.size(); i++) {
|
for (int i = 0; i < mTranslateableViews.size(); i++) {
|
||||||
@@ -1157,7 +1170,9 @@ public class ExpandableNotificationRow extends ActivatableNotificationView {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return Can the underlying notification be cleared?
|
* @return Can the underlying notification be cleared? This can be different from whether the
|
||||||
|
* notification can be dismissed in case notifications are sensitive on the lockscreen.
|
||||||
|
* @see #canViewBeDismissed()
|
||||||
*/
|
*/
|
||||||
public boolean isClearable() {
|
public boolean isClearable() {
|
||||||
return mStatusBarNotification != null && mStatusBarNotification.isClearable();
|
return mStatusBarNotification != null && mStatusBarNotification.isClearable();
|
||||||
@@ -1317,7 +1332,6 @@ public class ExpandableNotificationRow extends ActivatableNotificationView {
|
|||||||
NotificationContentView showingLayout = getShowingLayout();
|
NotificationContentView showingLayout = getShowingLayout();
|
||||||
showingLayout.updateBackgroundColor(animated);
|
showingLayout.updateBackgroundColor(animated);
|
||||||
mPrivateLayout.updateExpandButtons(isExpandable());
|
mPrivateLayout.updateExpandButtons(isExpandable());
|
||||||
updateClearability();
|
|
||||||
mShowingPublicInitialized = true;
|
mShowingPublicInitialized = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1357,12 +1371,12 @@ public class ExpandableNotificationRow extends ActivatableNotificationView {
|
|||||||
return mIsHeadsUp;
|
return mIsHeadsUp;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void updateClearability() {
|
/**
|
||||||
// public versions cannot be dismissed
|
* @return Whether this view is allowed to be dismissed. Only valid for visible notifications as
|
||||||
mVetoButton.setVisibility(canViewBeDismissed() ? View.VISIBLE : View.GONE);
|
* otherwise some state might not be updated. To request about the general clearability
|
||||||
}
|
* see {@link #isClearable()}.
|
||||||
|
*/
|
||||||
private boolean canViewBeDismissed() {
|
public boolean canViewBeDismissed() {
|
||||||
return isClearable() && (!mShowingPublic || !mSensitiveHiddenInGeneral);
|
return isClearable() && (!mShowingPublic || !mSensitiveHiddenInGeneral);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -780,20 +780,20 @@ public class NotificationStackScrollLayout extends ViewGroup
|
|||||||
|
|
||||||
public static void performDismiss(View v, NotificationGroupManager groupManager,
|
public static void performDismiss(View v, NotificationGroupManager groupManager,
|
||||||
boolean fromAccessibility) {
|
boolean fromAccessibility) {
|
||||||
if (v instanceof ExpandableNotificationRow) {
|
if (!(v instanceof ExpandableNotificationRow)) {
|
||||||
ExpandableNotificationRow row = (ExpandableNotificationRow) v;
|
return;
|
||||||
if (groupManager.isOnlyChildInGroup(row.getStatusBarNotification())) {
|
|
||||||
ExpandableNotificationRow groupSummary =
|
|
||||||
groupManager.getLogicalGroupSummary(row.getStatusBarNotification());
|
|
||||||
if (groupSummary.isClearable()) {
|
|
||||||
performDismiss(groupSummary, groupManager, fromAccessibility);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
row.setDismissed(true, fromAccessibility);
|
|
||||||
}
|
}
|
||||||
final View veto = v.findViewById(R.id.veto);
|
ExpandableNotificationRow row = (ExpandableNotificationRow) v;
|
||||||
if (veto != null && veto.getVisibility() != View.GONE) {
|
if (groupManager.isOnlyChildInGroup(row.getStatusBarNotification())) {
|
||||||
veto.performClick();
|
ExpandableNotificationRow groupSummary =
|
||||||
|
groupManager.getLogicalGroupSummary(row.getStatusBarNotification());
|
||||||
|
if (groupSummary.isClearable()) {
|
||||||
|
performDismiss(groupSummary, groupManager, fromAccessibility);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
row.setDismissed(true, fromAccessibility);
|
||||||
|
if (row.isClearable()) {
|
||||||
|
row.performDismiss();
|
||||||
}
|
}
|
||||||
if (DEBUG) Log.v(TAG, "onChildDismissed: " + v);
|
if (DEBUG) Log.v(TAG, "onChildDismissed: " + v);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -173,14 +173,14 @@ public class StackScrollAlgorithm {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static boolean canChildBeDismissed(View v) {
|
public static boolean canChildBeDismissed(View v) {
|
||||||
if (v instanceof ExpandableNotificationRow) {
|
if (!(v instanceof ExpandableNotificationRow)) {
|
||||||
ExpandableNotificationRow row = (ExpandableNotificationRow) v;
|
return false;
|
||||||
if (row.areGutsExposed()) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
final View veto = v.findViewById(R.id.veto);
|
ExpandableNotificationRow row = (ExpandableNotificationRow) v;
|
||||||
return (veto != null && veto.getVisibility() != View.GONE);
|
if (row.areGutsExposed()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return row.canViewBeDismissed();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Reference in New Issue
Block a user