Search in sources :

Example 1 with StatusBarIconView

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;
}
Also used : IBinder(android.os.IBinder) StatusBarNotification(android.service.notification.StatusBarNotification) ArrayList(java.util.ArrayList) StatusBarIcon(com.android.internal.statusbar.StatusBarIcon) Point(android.graphics.Point) StatusBarIconView(com.android.systemui.statusbar.StatusBarIconView) Pair(android.util.Pair)

Example 2 with StatusBarIconView

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));
}
Also used : ColorDrawable(android.graphics.drawable.ColorDrawable) Drawable(android.graphics.drawable.Drawable) NinePatchDrawable(android.graphics.drawable.NinePatchDrawable) LinearLayout(android.widget.LinearLayout) StatusBarIconView(com.android.systemui.statusbar.StatusBarIconView)

Example 3 with StatusBarIconView

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);
        }
    }
}
Also used : MarginLayoutParams(android.view.ViewGroup.MarginLayoutParams) LayoutParams(android.view.ViewGroup.LayoutParams) Entry(com.android.systemui.statusbar.NotificationData.Entry) ArrayList(java.util.ArrayList) ImageView(android.widget.ImageView) QuickSettingsContainerView(com.android.systemui.statusbar.phone.QuickSettingsContainerView) View(android.view.View) TextView(android.widget.TextView) SignalClusterView(com.android.systemui.statusbar.SignalClusterView) StatusBarIconView(com.android.systemui.statusbar.StatusBarIconView) KeyButtonView(com.android.systemui.statusbar.policy.KeyButtonView) ScrollView(android.widget.ScrollView) Notification(android.app.Notification) StatusBarNotification(android.service.notification.StatusBarNotification) Point(android.graphics.Point) Entry(com.android.systemui.statusbar.NotificationData.Entry) StatusBarNotification(android.service.notification.StatusBarNotification) LinearLayout(android.widget.LinearLayout) StatusBarIconView(com.android.systemui.statusbar.StatusBarIconView) NotificationData(com.android.systemui.statusbar.NotificationData)

Example 4 with StatusBarIconView

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();
}
Also used : StatusBarIconView(com.android.systemui.statusbar.StatusBarIconView)

Example 5 with StatusBarIconView

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));
}
Also used : StatusBarIcon(com.android.internal.statusbar.StatusBarIcon) LinearLayout(android.widget.LinearLayout) StatusBarIconView(com.android.systemui.statusbar.StatusBarIconView)

Aggregations

StatusBarIconView (com.android.systemui.statusbar.StatusBarIconView)42 LinearLayout (android.widget.LinearLayout)17 NotificationData (com.android.systemui.statusbar.NotificationData)8 StatusBarIcon (com.android.internal.statusbar.StatusBarIcon)7 ArrayList (java.util.ArrayList)7 View (android.view.View)6 ImageView (android.widget.ImageView)6 Point (android.graphics.Point)4 StatusBarNotification (android.service.notification.StatusBarNotification)4 ColorDrawable (android.graphics.drawable.ColorDrawable)3 Drawable (android.graphics.drawable.Drawable)3 Notification (android.app.Notification)2 NinePatchDrawable (android.graphics.drawable.NinePatchDrawable)2 Entry (com.android.systemui.statusbar.NotificationData.Entry)2 PendingIntent (android.app.PendingIntent)1 Paint (android.graphics.Paint)1 Path (android.graphics.Path)1 BitmapDrawable (android.graphics.drawable.BitmapDrawable)1 IBinder (android.os.IBinder)1 RemoteException (android.os.RemoteException)1