Search in sources :

Example 31 with StatusBarIcon

use of com.android.internal.statusbar.StatusBarIcon in project android_frameworks_base by ParanoidAndroid.

the class TabletTicker method makeTickerView.

private View makeTickerView(StatusBarNotification notification) {
    final Notification n = notification.getNotification();
    LayoutInflater inflater = (LayoutInflater) mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    ViewGroup group;
    int layoutId;
    int iconId;
    if (n.largeIcon != null) {
        iconId = R.id.right_icon;
    } else {
        iconId = R.id.left_icon;
    }
    if (n.tickerView != null) {
        group = (ViewGroup) inflater.inflate(R.layout.system_bar_ticker_panel, null, false);
        ViewGroup content = (FrameLayout) group.findViewById(R.id.ticker_expanded);
        View expanded = null;
        Exception exception = null;
        try {
            expanded = n.tickerView.apply(mContext, content);
        } catch (RuntimeException e) {
            exception = e;
        }
        if (expanded == null) {
            final String ident = notification.getPackageName() + "/0x" + Integer.toHexString(notification.getId());
            Slog.e(TAG, "couldn't inflate view for notification " + ident, exception);
            return null;
        }
        FrameLayout.LayoutParams lp = new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT);
        content.addView(expanded, lp);
    } else if (n.tickerText != null) {
        group = (ViewGroup) inflater.inflate(R.layout.system_bar_ticker_compat, mWindow, false);
        final Drawable icon = StatusBarIconView.getIcon(mContext, new StatusBarIcon(notification.getPackageName(), notification.getUser(), n.icon, n.iconLevel, 0, n.tickerText));
        ImageView iv = (ImageView) group.findViewById(iconId);
        iv.setImageDrawable(icon);
        iv.setVisibility(View.VISIBLE);
        TextView tv = (TextView) group.findViewById(R.id.text);
        tv.setText(n.tickerText);
    } else {
        throw new RuntimeException("tickerView==null && tickerText==null");
    }
    ImageView largeIcon = (ImageView) group.findViewById(R.id.large_icon);
    if (n.largeIcon != null) {
        largeIcon.setImageBitmap(n.largeIcon);
        largeIcon.setVisibility(View.VISIBLE);
        final ViewGroup.LayoutParams lp = largeIcon.getLayoutParams();
        final int statusBarHeight = mBar.getStatusBarHeight();
        if (n.largeIcon.getHeight() <= statusBarHeight) {
            // for smallish largeIcons, it looks a little odd to have them floating halfway up
            // the ticker, so we vertically center them in the status bar area instead
            lp.height = statusBarHeight;
        } else {
            lp.height = mLargeIconHeight;
        }
        largeIcon.setLayoutParams(lp);
    }
    if (CLICKABLE_TICKER) {
        PendingIntent contentIntent = notification.getNotification().contentIntent;
        if (contentIntent != null) {
            // create the usual notification clicker, but chain it together with a halt() call
            // to abort the ticker too
            final View.OnClickListener clicker = mBar.makeClicker(contentIntent, notification.getPackageName(), notification.getTag(), notification.getId());
            group.setOnClickListener(new View.OnClickListener() {

                public void onClick(View v) {
                    halt();
                    clicker.onClick(v);
                }
            });
        } else {
            group.setOnClickListener(null);
        }
    }
    return group;
}
Also used : ViewGroup(android.view.ViewGroup) Drawable(android.graphics.drawable.Drawable) StatusBarIconView(com.android.systemui.statusbar.StatusBarIconView) ImageView(android.widget.ImageView) View(android.view.View) TextView(android.widget.TextView) Notification(android.app.Notification) StatusBarNotification(android.service.notification.StatusBarNotification) LayoutInflater(android.view.LayoutInflater) FrameLayout(android.widget.FrameLayout) TextView(android.widget.TextView) StatusBarIcon(com.android.internal.statusbar.StatusBarIcon) ImageView(android.widget.ImageView) PendingIntent(android.app.PendingIntent)

Example 32 with StatusBarIcon

use of com.android.internal.statusbar.StatusBarIcon in project android_frameworks_base by ParanoidAndroid.

the class PieMenu method getNotifications.

private void getNotifications() {
    NotificationData notifData = mPanel.getBar().getNotificationData();
    if (notifData != null) {
        mNotificationText = new String[notifData.size()];
        mNotificationIcon = new Bitmap[notifData.size()];
        mNotificationPath = new Path[notifData.size()];
        for (int i = 0; i < notifData.size(); i++) {
            NotificationData.Entry entry = notifData.get(i);
            StatusBarNotification statusNotif = entry.notification;
            if (statusNotif == null)
                continue;
            boolean hide = statusNotif.getPackageName().equals("com.paranoid.halo");
            if (hide) {
                mHiddenNotification++;
                continue;
            }
            Notification notif = statusNotif.getNotification();
            if (notif == null)
                continue;
            CharSequence tickerText = notif.tickerText;
            if (tickerText == null)
                continue;
            if (entry.icon != null) {
                StatusBarIconView iconView = entry.icon;
                StatusBarIcon icon = iconView.getStatusBarIcon();
                Drawable drawable = entry.icon.getIcon(mContext, icon);
                if (!(drawable instanceof BitmapDrawable))
                    continue;
                mNotificationIcon[mNotificationCount] = ((BitmapDrawable) drawable).getBitmap();
                String text = tickerText.toString();
                if (text.length() > 100)
                    text = text.substring(0, 100) + "..";
                mNotificationText[mNotificationCount] = text;
                Path notifictionPath = new Path();
                notifictionPath.addCircle(mCenter.x, mCenter.y, mNotificationsRadius + (mNotificationsRowSize * mNotificationCount) + (mNotificationsRowSize - mNotificationTextSize), Path.Direction.CW);
                mNotificationPath[mNotificationCount] = notifictionPath;
                mNotificationCount++;
            }
        }
    }
}
Also used : Path(android.graphics.Path) ColorDrawable(android.graphics.drawable.ColorDrawable) Drawable(android.graphics.drawable.Drawable) BitmapDrawable(android.graphics.drawable.BitmapDrawable) BitmapDrawable(android.graphics.drawable.BitmapDrawable) Paint(android.graphics.Paint) Point(android.graphics.Point) Notification(android.app.Notification) StatusBarNotification(android.service.notification.StatusBarNotification) StatusBarNotification(android.service.notification.StatusBarNotification) StatusBarIcon(com.android.internal.statusbar.StatusBarIcon) NotificationData(com.android.systemui.statusbar.NotificationData) StatusBarIconView(com.android.systemui.statusbar.StatusBarIconView)

Example 33 with StatusBarIcon

use of com.android.internal.statusbar.StatusBarIcon in project android_frameworks_base by ParanoidAndroid.

the class StatusBarManagerService method setIcon.

public void setIcon(String slot, String iconPackage, int iconId, int iconLevel, String contentDescription) {
    enforceStatusBar();
    synchronized (mIcons) {
        int index = mIcons.getSlotIndex(slot);
        if (index < 0) {
            throw new SecurityException("invalid status bar icon slot: " + slot);
        }
        StatusBarIcon icon = new StatusBarIcon(iconPackage, UserHandle.OWNER, iconId, iconLevel, 0, contentDescription);
        //Slog.d(TAG, "setIcon slot=" + slot + " index=" + index + " icon=" + icon);
        mIcons.setIcon(index, icon);
        if (mBar != null) {
            try {
                mBar.setIcon(index, icon);
            } catch (RemoteException ex) {
            }
        }
    }
}
Also used : StatusBarIcon(com.android.internal.statusbar.StatusBarIcon) RemoteException(android.os.RemoteException)

Example 34 with StatusBarIcon

use of com.android.internal.statusbar.StatusBarIcon in project android_frameworks_base by ParanoidAndroid.

the class StatusBarManagerService method setIconVisibility.

public void setIconVisibility(String slot, boolean visible) {
    enforceStatusBar();
    synchronized (mIcons) {
        int index = mIcons.getSlotIndex(slot);
        if (index < 0) {
            throw new SecurityException("invalid status bar icon slot: " + slot);
        }
        StatusBarIcon icon = mIcons.getIcon(index);
        if (icon == null) {
            return;
        }
        if (icon.visible != visible) {
            icon.visible = visible;
            if (mBar != null) {
                try {
                    mBar.setIcon(index, icon);
                } catch (RemoteException ex) {
                }
            }
        }
    }
}
Also used : StatusBarIcon(com.android.internal.statusbar.StatusBarIcon) RemoteException(android.os.RemoteException)

Example 35 with StatusBarIcon

use of com.android.internal.statusbar.StatusBarIcon in project platform_frameworks_base by android.

the class BaseStatusBar method updateNotification.

public void updateNotification(StatusBarNotification notification, RankingMap ranking) {
    if (DEBUG)
        Log.d(TAG, "updateNotification(" + notification + ")");
    final String key = notification.getKey();
    Entry entry = mNotificationData.get(key);
    if (entry == null) {
        return;
    } else {
        mHeadsUpEntriesToRemoveOnSwitch.remove(entry);
        mRemoteInputEntriesToRemoveOnCollapse.remove(entry);
    }
    Notification n = notification.getNotification();
    mNotificationData.updateRanking(ranking);
    boolean applyInPlace;
    try {
        applyInPlace = entry.cacheContentViews(mContext, notification.getNotification());
    } catch (RuntimeException e) {
        Log.e(TAG, "Unable to get notification remote views", e);
        applyInPlace = false;
    }
    boolean shouldPeek = shouldPeek(entry, notification);
    boolean alertAgain = alertAgain(entry, n);
    if (DEBUG) {
        Log.d(TAG, "applyInPlace=" + applyInPlace + " shouldPeek=" + shouldPeek + " alertAgain=" + alertAgain);
    }
    final StatusBarNotification oldNotification = entry.notification;
    entry.notification = notification;
    mGroupManager.onEntryUpdated(entry, oldNotification);
    boolean updateSuccessful = false;
    if (applyInPlace) {
        if (DEBUG)
            Log.d(TAG, "reusing notification for key: " + key);
        try {
            if (entry.icon != null) {
                // Update the icon
                final StatusBarIcon ic = new StatusBarIcon(notification.getUser(), notification.getPackageName(), n.getSmallIcon(), n.iconLevel, n.number, StatusBarIconView.contentDescForNotification(mContext, n));
                entry.icon.setNotification(n);
                if (!entry.icon.set(ic)) {
                    handleNotificationError(notification, "Couldn't update icon: " + ic);
                    return;
                }
            }
            updateNotificationViews(entry, notification);
            updateSuccessful = true;
        } catch (RuntimeException e) {
            // It failed to apply cleanly.
            Log.w(TAG, "Couldn't reapply views for package " + notification.getPackageName(), e);
        }
    }
    if (!updateSuccessful) {
        if (DEBUG)
            Log.d(TAG, "not reusing notification for key: " + key);
        final StatusBarIcon ic = new StatusBarIcon(notification.getUser(), notification.getPackageName(), n.getSmallIcon(), n.iconLevel, n.number, StatusBarIconView.contentDescForNotification(mContext, n));
        entry.icon.setNotification(n);
        entry.icon.set(ic);
        if (!inflateViews(entry, mStackScroller)) {
            handleNotificationError(notification, "Couldn't update remote views for: " + notification);
        }
    }
    updateHeadsUp(key, entry, shouldPeek, alertAgain);
    updateNotifications();
    if (!notification.isClearable()) {
        // The user may have performed a dismiss action on the notification, since it's
        // not clearable we should snap it back.
        mStackScroller.snapViewIfNeeded(entry.row);
    }
    if (DEBUG) {
        // Is this for you?
        boolean isForCurrentUser = isNotificationForCurrentProfiles(notification);
        Log.d(TAG, "notification is " + (isForCurrentUser ? "" : "not ") + "for you");
    }
    setAreThereNotifications();
}
Also used : Entry(com.android.systemui.statusbar.NotificationData.Entry) StatusBarNotification(android.service.notification.StatusBarNotification) StatusBarIcon(com.android.internal.statusbar.StatusBarIcon) Notification(android.app.Notification) StatusBarNotification(android.service.notification.StatusBarNotification)

Aggregations

StatusBarIcon (com.android.internal.statusbar.StatusBarIcon)56 StatusBarNotification (android.service.notification.StatusBarNotification)16 Notification (android.app.Notification)13 RemoteException (android.os.RemoteException)13 ComponentName (android.content.ComponentName)10 Drawable (android.graphics.drawable.Drawable)8 StatusBarIconView (com.android.systemui.statusbar.StatusBarIconView)8 IBinder (android.os.IBinder)7 ArrayList (java.util.ArrayList)7 IntentFilter (android.content.IntentFilter)6 Rect (android.graphics.Rect)6 PackageInfo (android.content.pm.PackageInfo)5 PackageManager (android.content.pm.PackageManager)5 Configuration (android.content.res.Configuration)5 Icon (android.graphics.drawable.Icon)5 UserHandle (android.os.UserHandle)5 IVrManager (android.service.vr.IVrManager)5 LinearLayout (android.widget.LinearLayout)5 LockPatternUtils (com.android.internal.widget.LockPatternUtils)5 Entry (com.android.systemui.statusbar.NotificationData.Entry)5