Merge "Fixed a bug with auto cancelling" into nyc-dev
This commit is contained in:
@@ -956,32 +956,39 @@ public abstract class BaseStatusBar extends SystemUI implements
|
|||||||
|
|
||||||
protected View bindVetoButtonClickListener(View row, final StatusBarNotification n) {
|
protected View bindVetoButtonClickListener(View row, final StatusBarNotification n) {
|
||||||
View vetoButton = row.findViewById(R.id.veto);
|
View vetoButton = row.findViewById(R.id.veto);
|
||||||
final String _pkg = n.getPackageName();
|
|
||||||
final String _tag = n.getTag();
|
|
||||||
final int _id = n.getId();
|
|
||||||
final int _userId = n.getUserId();
|
|
||||||
vetoButton.setOnClickListener(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));
|
||||||
try {
|
performRemoveNotification(n, false /* removeView */);
|
||||||
mBarService.onNotificationClear(_pkg, _tag, _id, _userId);
|
|
||||||
if (FORCE_REMOTE_INPUT_HISTORY
|
|
||||||
&& mKeysKeptForRemoteInput.contains(n.getKey())) {
|
|
||||||
removeNotification(n.getKey(), null);
|
|
||||||
mKeysKeptForRemoteInput.remove(n.getKey());
|
|
||||||
}
|
|
||||||
|
|
||||||
} catch (RemoteException ex) {
|
|
||||||
// system process is dead if we're here.
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
vetoButton.setImportantForAccessibility(View.IMPORTANT_FOR_ACCESSIBILITY_NO);
|
vetoButton.setImportantForAccessibility(View.IMPORTANT_FOR_ACCESSIBILITY_NO);
|
||||||
return vetoButton;
|
return vetoButton;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void performRemoveNotification(StatusBarNotification n, boolean removeView) {
|
||||||
|
final String pkg = n.getPackageName();
|
||||||
|
final String tag = n.getTag();
|
||||||
|
final int id = n.getId();
|
||||||
|
final int userId = n.getUserId();
|
||||||
|
try {
|
||||||
|
mBarService.onNotificationClear(pkg, tag, id, userId);
|
||||||
|
if (FORCE_REMOTE_INPUT_HISTORY
|
||||||
|
&& mKeysKeptForRemoteInput.contains(n.getKey())) {
|
||||||
|
mKeysKeptForRemoteInput.remove(n.getKey());
|
||||||
|
removeView = true;
|
||||||
|
}
|
||||||
|
if (removeView) {
|
||||||
|
removeNotification(n.getKey(), null);
|
||||||
|
}
|
||||||
|
|
||||||
|
} catch (RemoteException ex) {
|
||||||
|
// system process is dead if we're here.
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
protected void applyColorsAndBackgrounds(StatusBarNotification sbn,
|
protected void applyColorsAndBackgrounds(StatusBarNotification sbn,
|
||||||
NotificationData.Entry entry) {
|
NotificationData.Entry entry) {
|
||||||
@@ -1826,6 +1833,13 @@ public abstract class BaseStatusBar extends SystemUI implements
|
|||||||
}, afterKeyguardGone);
|
}, afterKeyguardGone);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void addPostCollapseAction(Runnable r) {
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isCollapsing() {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
private final class NotificationClicker implements View.OnClickListener {
|
private final class NotificationClicker implements View.OnClickListener {
|
||||||
public void onClick(final View v) {
|
public void onClick(final View v) {
|
||||||
if (!(v instanceof ExpandableNotificationRow)) {
|
if (!(v instanceof ExpandableNotificationRow)) {
|
||||||
@@ -1875,6 +1889,15 @@ public abstract class BaseStatusBar extends SystemUI implements
|
|||||||
HeadsUpManager.setIsClickedNotification(row, true);
|
HeadsUpManager.setIsClickedNotification(row, true);
|
||||||
mHeadsUpManager.releaseImmediately(notificationKey);
|
mHeadsUpManager.releaseImmediately(notificationKey);
|
||||||
}
|
}
|
||||||
|
StatusBarNotification parentToCancel = null;
|
||||||
|
if (shouldAutoCancel(sbn) && mGroupManager.isOnlyChildInGroup(sbn)) {
|
||||||
|
StatusBarNotification summarySbn = mGroupManager.getLogicalGroupSummary(sbn)
|
||||||
|
.getStatusBarNotification();
|
||||||
|
if (shouldAutoCancel(summarySbn)) {
|
||||||
|
parentToCancel = summarySbn;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
final StatusBarNotification parentToCancelFinal = parentToCancel;
|
||||||
new Thread() {
|
new Thread() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
@@ -1930,6 +1953,28 @@ public abstract class BaseStatusBar extends SystemUI implements
|
|||||||
} catch (RemoteException ex) {
|
} catch (RemoteException ex) {
|
||||||
// system process is dead if we're here.
|
// system process is dead if we're here.
|
||||||
}
|
}
|
||||||
|
if (parentToCancelFinal != null) {
|
||||||
|
// We have to post it to the UI thread for synchronization
|
||||||
|
mHandler.post(new Runnable() {
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
Runnable removeRunnable = new Runnable() {
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
performRemoveNotification(parentToCancelFinal,
|
||||||
|
true);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
if (isCollapsing()) {
|
||||||
|
// To avoid lags we're only performing the remove
|
||||||
|
// after the shade was collapsed
|
||||||
|
addPostCollapseAction(removeRunnable);
|
||||||
|
} else {
|
||||||
|
removeRunnable.run();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}.start();
|
}.start();
|
||||||
|
|
||||||
@@ -1943,6 +1988,17 @@ public abstract class BaseStatusBar extends SystemUI implements
|
|||||||
}, afterKeyguardGone);
|
}, afterKeyguardGone);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private boolean shouldAutoCancel(StatusBarNotification sbn) {
|
||||||
|
int flags = sbn.getNotification().flags;
|
||||||
|
if ((flags & Notification.FLAG_AUTO_CANCEL) != Notification.FLAG_AUTO_CANCEL) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if ((flags & Notification.FLAG_FOREGROUND_SERVICE) != 0) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
public void register(ExpandableNotificationRow row, StatusBarNotification sbn) {
|
public void register(ExpandableNotificationRow row, StatusBarNotification sbn) {
|
||||||
Notification notification = sbn.getNotification();
|
Notification notification = sbn.getNotification();
|
||||||
if (notification.contentIntent != null || notification.fullScreenIntent != null) {
|
if (notification.contentIntent != null || notification.fullScreenIntent != null) {
|
||||||
|
|||||||
@@ -215,7 +215,11 @@ public class NotificationGroupManager implements HeadsUpManager.OnHeadsUpChanged
|
|||||||
|
|
||||||
public boolean isOnlyChildInSuppressedGroup(StatusBarNotification sbn) {
|
public boolean isOnlyChildInSuppressedGroup(StatusBarNotification sbn) {
|
||||||
return isGroupSuppressed(sbn.getGroupKey())
|
return isGroupSuppressed(sbn.getGroupKey())
|
||||||
&& !sbn.getNotification().isGroupSummary()
|
&& isOnlyChildInGroup(sbn);
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isOnlyChildInGroup(StatusBarNotification sbn) {
|
||||||
|
return !sbn.getNotification().isGroupSummary()
|
||||||
&& getTotalNumberOfChildren(sbn) == 1;
|
&& getTotalNumberOfChildren(sbn) == 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -3828,10 +3828,12 @@ public class PhoneStatusBar extends BaseStatusBar implements DemoMode,
|
|||||||
updateMediaMetaData(true /* metaDataChanged */, true);
|
updateMediaMetaData(true /* metaDataChanged */, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public boolean isCollapsing() {
|
public boolean isCollapsing() {
|
||||||
return mNotificationPanel.isCollapsing();
|
return mNotificationPanel.isCollapsing();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void addPostCollapseAction(Runnable r) {
|
public void addPostCollapseAction(Runnable r) {
|
||||||
mPostCollapseRunnables.add(r);
|
mPostCollapseRunnables.add(r);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user