use of com.android.systemui.statusbar.StatusBarIconView in project android_frameworks_base by ParanoidAndroid.
the class PhoneStatusBar method recreateStatusBar.
private void recreateStatusBar() {
mRecreating = true;
mStatusBarContainer.removeAllViews();
// extract icons from the soon-to-be recreated viewgroup.
int nIcons = mStatusIcons.getChildCount();
ArrayList<StatusBarIcon> icons = new ArrayList<StatusBarIcon>(nIcons);
ArrayList<String> iconSlots = new ArrayList<String>(nIcons);
for (int i = 0; i < nIcons; i++) {
StatusBarIconView iconView = (StatusBarIconView) mStatusIcons.getChildAt(i);
icons.add(iconView.getStatusBarIcon());
iconSlots.add(iconView.getStatusBarSlot());
}
// extract notifications.
int nNotifs = mNotificationData.size();
ArrayList<Pair<IBinder, StatusBarNotification>> notifications = new ArrayList<Pair<IBinder, StatusBarNotification>>(nNotifs);
copyNotifications(notifications, mNotificationData);
mNotificationData.clear();
makeStatusBarView();
repositionNavigationBar();
mNavigationBarView.updateResources();
// recreate StatusBarIconViews.
for (int i = 0; i < nIcons; i++) {
StatusBarIcon icon = icons.get(i);
String slot = iconSlots.get(i);
addIcon(slot, i, i, icon);
}
// recreate notifications.
for (int i = 0; i < nNotifs; i++) {
Pair<IBinder, StatusBarNotification> notifData = notifications.get(i);
addNotificationViews(notifData.first, notifData.second);
}
setAreThereNotifications();
mStatusBarContainer.addView(mStatusBarWindow);
updateExpandedViewPos(EXPANDED_LEAVE_ALONE);
mRecreating = false;
}
use of com.android.systemui.statusbar.StatusBarIconView in project android_frameworks_base by ParanoidAndroid.
the class PhoneStatusBar method addIcon.
public void addIcon(String slot, int index, int viewIndex, StatusBarIcon icon) {
if (SPEW)
Slog.d(TAG, "addIcon slot=" + slot + " index=" + index + " viewIndex=" + viewIndex + " icon=" + icon);
Drawable iconDrawable = StatusBarIconView.getIcon(mContext, icon);
if (mLastIconColor == null || mLastIconColor.isLastColorNull) {
iconDrawable.clearColorFilter();
} else {
iconDrawable.setColorFilter(mLastIconColor.lastColor, PorterDuff.Mode.SRC_IN);
}
StatusBarIconView view = new StatusBarIconView(mContext, slot, null);
view.set(icon);
mStatusIcons.addView(view, viewIndex, new LinearLayout.LayoutParams(mIconSize, mIconSize));
}
use of com.android.systemui.statusbar.StatusBarIconView in project android_frameworks_base by ParanoidAndroid.
the class TabletStatusBar method updateNotificationIcons.
@Override
protected void updateNotificationIcons() {
if (mIconLayout == null)
return;
// first, populate the main notification panel
loadNotificationPanel();
final LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(mIconSize + 2 * mIconHPadding, mNaturalBarHeight);
// alternate behavior in DND mode
if (mNotificationDNDMode) {
if (mIconLayout.getChildCount() == 0) {
final Notification dndNotification = new Notification.Builder(mContext).setContentTitle(mContext.getText(R.string.notifications_off_title)).setContentText(mContext.getText(R.string.notifications_off_text)).setSmallIcon(R.drawable.ic_notification_dnd).setOngoing(true).getNotification();
final StatusBarIconView iconView = new StatusBarIconView(mContext, "_dnd", dndNotification);
iconView.setImageResource(R.drawable.ic_notification_dnd);
iconView.setScaleType(ImageView.ScaleType.CENTER_INSIDE);
iconView.setPadding(mIconHPadding, 0, mIconHPadding, 0);
mNotificationDNDDummyEntry = new NotificationData.Entry(null, new StatusBarNotification("", 0, "", 0, 0, Notification.PRIORITY_MAX, dndNotification, android.os.Process.myUserHandle()), iconView);
mIconLayout.addView(iconView, params);
}
return;
} else if (0 != (mDisabled & StatusBarManager.DISABLE_NOTIFICATION_ICONS)) {
// just leave the area totally empty
return;
}
int N = mNotificationData.size();
if (DEBUG) {
Slog.d(TAG, "refreshing icons: " + N + " notifications, mIconLayout=" + mIconLayout);
}
ArrayList<View> toShow = new ArrayList<View>();
// Extra Special Icons
// The IME switcher and compatibility mode icons take the place of notifications. You didn't
// need to see all those new emails, did you?
int maxNotificationIconsCount = mMaxNotificationIcons;
if (mInputMethodSwitchButton.getVisibility() != View.GONE)
maxNotificationIconsCount--;
if (mCompatModeButton.getVisibility() != View.GONE)
maxNotificationIconsCount--;
final boolean provisioned = isDeviceProvisioned();
// If the device hasn't been through Setup, we only show system notifications
for (int i = 0; toShow.size() < maxNotificationIconsCount; i++) {
if (i >= N)
break;
Entry ent = mNotificationData.get(N - i - 1);
if ((provisioned && ent.notification.getScore() >= HIDE_ICONS_BELOW_SCORE) || showNotificationEvenIfUnprovisioned(ent.notification) || mHaloTaskerActive) {
toShow.add(ent.icon);
}
}
ArrayList<View> toRemove = new ArrayList<View>();
for (int i = 0; i < mIconLayout.getChildCount(); i++) {
View child = mIconLayout.getChildAt(i);
if (!toShow.contains(child)) {
toRemove.add(child);
}
}
for (View remove : toRemove) {
mIconLayout.removeView(remove);
}
for (int i = 0; i < toShow.size(); i++) {
View v = toShow.get(i);
v.setPadding(mIconHPadding, 0, mIconHPadding, 0);
if (v.getParent() == null) {
mIconLayout.addView(v, i, params);
}
}
}
use of com.android.systemui.statusbar.StatusBarIconView in project platform_frameworks_base by android.
the class StatusBarIconController method handleSet.
private void handleSet(int index, StatusBarIcon icon) {
int viewIndex = getViewIndex(index);
StatusBarIconView view = (StatusBarIconView) mStatusIcons.getChildAt(viewIndex);
view.set(icon);
view = (StatusBarIconView) mStatusIconsKeyguard.getChildAt(viewIndex);
view.set(icon);
applyIconTint();
}
use of com.android.systemui.statusbar.StatusBarIconView in project platform_frameworks_base by android.
the class DemoStatusIcons method updateSlot.
private void updateSlot(String slot, String iconPkg, int iconId) {
if (!mDemoMode)
return;
if (iconPkg == null) {
iconPkg = mContext.getPackageName();
}
int removeIndex = -1;
for (int i = 0; i < getChildCount(); i++) {
StatusBarIconView v = (StatusBarIconView) getChildAt(i);
if (slot.equals(v.getTag())) {
if (iconId == 0) {
removeIndex = i;
break;
} else {
StatusBarIcon icon = v.getStatusBarIcon();
icon.icon = Icon.createWithResource(icon.icon.getResPackage(), iconId);
v.set(icon);
v.updateDrawable();
return;
}
}
}
if (iconId == 0) {
if (removeIndex != -1) {
removeViewAt(removeIndex);
}
return;
}
StatusBarIcon icon = new StatusBarIcon(iconPkg, UserHandle.SYSTEM, iconId, 0, 0, "Demo");
StatusBarIconView v = new StatusBarIconView(getContext(), null, null);
v.setTag(slot);
v.set(icon);
addView(v, 0, new LinearLayout.LayoutParams(mIconSize, mIconSize));
}
Aggregations