Implement setAreThereNotifications.

Change-Id: I8b69330c35d613ce808a472748dd2651adb5efa3
This commit is contained in:
Joe Onorato
2010-05-24 16:39:29 -04:00
parent 0e26dffd6c
commit 20da8f8ac9
2 changed files with 29 additions and 7 deletions

View File

@@ -16,6 +16,7 @@
package com.android.policy.statusbar.phone; package com.android.policy.statusbar.phone;
import android.app.Notification;
import android.os.IBinder; import android.os.IBinder;
import android.view.View; import android.view.View;
@@ -89,4 +90,26 @@ public class NotificationData {
} }
return N; return N;
} }
/**
* Return whether there are any visible items (i.e. items without an error).
*/
public boolean hasVisibleItems() {
return mEntries.size() != 0; // TODO
}
/**
* Return whether there are any clearable items (that aren't errors).
*/
public boolean hasClearableItems() {
final int N = mEntries.size();
for (int i=0; i<N; i++) {
Entry entry = mEntries.get(i);
// TODO: if (!entry.error)
if ((entry.notification.notification.flags & Notification.FLAG_NO_CLEAR) == 0) {
return true;
}
}
return false;
}
} }

View File

@@ -324,7 +324,8 @@ public class PhoneStatusBarService extends StatusBarService {
// show the ticker // show the ticker
// TODO // TODO
// recalculate the position of the sliding windows // Recalculate the position of the sliding windows and the titles.
setAreThereNotifications();
updateExpandedViewPos(EXPANDED_LEAVE_ALONE); updateExpandedViewPos(EXPANDED_LEAVE_ALONE);
} }
@@ -483,7 +484,6 @@ public class PhoneStatusBarService extends StatusBarService {
final int iconIndex = chooseIconIndex(isOngoing, viewIndex); final int iconIndex = chooseIconIndex(isOngoing, viewIndex);
mNotificationIcons.addView(iconView, iconIndex, mNotificationIcons.addView(iconView, iconIndex,
new LinearLayout.LayoutParams(mIconWidth, mHeight)); new LinearLayout.LayoutParams(mIconWidth, mHeight));
} }
void removeNotificationViews(IBinder key) { void removeNotificationViews(IBinder key) {
@@ -502,11 +502,11 @@ public class PhoneStatusBarService extends StatusBarService {
} }
private void setAreThereNotifications() { private void setAreThereNotifications() {
/* boolean ongoing = mOngoing.hasVisibleItems();
boolean ongoing = mOngoingItems.getChildCount() != 0; boolean latest = mLatest.hasVisibleItems();
boolean latest = mLatestItems.getChildCount() != 0;
if (mNotificationData.hasClearableItems()) { // (no ongoing notifications are clearable)
if (mLatest.hasClearableItems()) {
mClearButton.setVisibility(View.VISIBLE); mClearButton.setVisibility(View.VISIBLE);
} else { } else {
mClearButton.setVisibility(View.INVISIBLE); mClearButton.setVisibility(View.INVISIBLE);
@@ -520,7 +520,6 @@ public class PhoneStatusBarService extends StatusBarService {
} else { } else {
mNoNotificationsTitle.setVisibility(View.VISIBLE); mNoNotificationsTitle.setVisibility(View.VISIBLE);
} }
*/
} }