Improve notification shade auto-collapse code.

- When the user dismisses a notification by swiping, also collapse
  notification shade if there are persistent notifications remaining.
  Only skip collapsing if there are still non-persistent notifications
  pending
- When the notification is removed by the app, wait a bit until
  collapsing the shade so the removal doesn't come as a surprise to the
  user
- Centralize the collapse trigger at one place

Change-Id: I4e5114f66e799a7c80e18b38abce5678da460846