Search in sources :

Example 26 with StatusBarIcon

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

the class StatusBarManagerService method dump.

// ================================================================================
// Always called from UI thread
// ================================================================================
protected void dump(FileDescriptor fd, PrintWriter pw, String[] args) {
    if (mContext.checkCallingOrSelfPermission(android.Manifest.permission.DUMP) != PackageManager.PERMISSION_GRANTED) {
        pw.println("Permission Denial: can't dump StatusBar from from pid=" + Binder.getCallingPid() + ", uid=" + Binder.getCallingUid());
        return;
    }
    synchronized (mLock) {
        pw.println("  mDisabled1=0x" + Integer.toHexString(mDisabled1));
        pw.println("  mDisabled2=0x" + Integer.toHexString(mDisabled2));
        final int N = mDisableRecords.size();
        pw.println("  mDisableRecords.size=" + N);
        for (int i = 0; i < N; i++) {
            DisableRecord tok = mDisableRecords.get(i);
            pw.println("    [" + i + "] userId=" + tok.userId + " what1=0x" + Integer.toHexString(tok.what1) + " what2=0x" + Integer.toHexString(tok.what2) + " pkg=" + tok.pkg + " token=" + tok.token);
        }
        pw.println("  mCurrentUserId=" + mCurrentUserId);
        pw.println("  mIcons=");
        for (String slot : mIcons.keySet()) {
            pw.println("    ");
            pw.print(slot);
            pw.print(" -> ");
            final StatusBarIcon icon = mIcons.get(slot);
            pw.print(icon);
            if (!TextUtils.isEmpty(icon.contentDescription)) {
                pw.print(" \"");
                pw.print(icon.contentDescription);
                pw.print("\"");
            }
            pw.println();
        }
    }
}
Also used : StatusBarIcon(com.android.internal.statusbar.StatusBarIcon)

Example 27 with StatusBarIcon

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

the class StatusBarIconController method setIcon.

public void setIcon(String slot, int resourceId, CharSequence contentDescription) {
    int index = getSlotIndex(slot);
    StatusBarIcon icon = getIcon(index);
    if (icon == null) {
        icon = new StatusBarIcon(UserHandle.SYSTEM, mContext.getPackageName(), Icon.createWithResource(mContext, resourceId), 0, 0, contentDescription);
        setIcon(slot, icon);
    } else {
        icon.icon = Icon.createWithResource(mContext, resourceId);
        icon.contentDescription = contentDescription;
        handleSet(index, icon);
    }
}
Also used : StatusBarIcon(com.android.internal.statusbar.StatusBarIcon)

Example 28 with StatusBarIcon

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

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)

Example 29 with StatusBarIcon

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

the class BaseStatusBar method addNotificationViews.

protected StatusBarIconView addNotificationViews(IBinder key, StatusBarNotification notification) {
    if (DEBUG) {
        Slog.d(TAG, "addNotificationViews(key=" + key + ", notification=" + notification);
    }
    // Construct the icon.
    final StatusBarIconView iconView = new StatusBarIconView(mContext, notification.getPackageName() + "/0x" + Integer.toHexString(notification.getId()), notification.getNotification());
    iconView.setScaleType(ImageView.ScaleType.CENTER_INSIDE);
    final StatusBarIcon ic = new StatusBarIcon(notification.getPackageName(), notification.getUser(), notification.getNotification().icon, notification.getNotification().iconLevel, notification.getNotification().number, notification.getNotification().tickerText);
    if (!iconView.set(ic)) {
        handleNotificationError(key, notification, "Couldn't create icon: " + ic);
        return null;
    }
    NotificationData.Entry entry = new NotificationData.Entry(key, notification, iconView);
    prepareHaloNotification(entry, notification, false);
    entry.hide = entry.notification.getPackageName().equals("com.paranoid.halo");
    final PendingIntent contentIntent = notification.getNotification().contentIntent;
    if (contentIntent != null) {
        entry.floatingIntent = makeClicker(contentIntent, notification.getPackageName(), notification.getTag(), notification.getId());
        entry.floatingIntent.makeFloating(true);
    }
    // Construct the expanded view.
    if (!inflateViews(entry, mPile)) {
        handleNotificationError(key, notification, "Couldn't expand RemoteViews for: " + notification);
        return null;
    }
    // Add the expanded view and icon.
    int pos = mNotificationData.add(entry);
    if (DEBUG) {
        Slog.d(TAG, "addNotificationViews: added at " + pos);
    }
    updateExpansionStates();
    updateNotificationIcons();
    return iconView;
}
Also used : StatusBarIcon(com.android.internal.statusbar.StatusBarIcon) PendingIntent(android.app.PendingIntent) Paint(android.graphics.Paint)

Example 30 with StatusBarIcon

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

the class Ticker method addEntry.

public void addEntry(StatusBarNotification n) {
    int initialCount = mSegments.size();
    // a notification storm).
    if (initialCount > 0) {
        final Segment seg = mSegments.get(0);
        if (n.getPackageName().equals(seg.notification.getPackageName()) && n.getNotification().icon == seg.notification.getNotification().icon && n.getNotification().iconLevel == seg.notification.getNotification().iconLevel && CharSequences.equals(seg.notification.getNotification().tickerText, n.getNotification().tickerText)) {
            return;
        }
    }
    final Drawable icon = StatusBarIconView.getIcon(mContext, new StatusBarIcon(n.getPackageName(), n.getUser(), n.getNotification().icon, n.getNotification().iconLevel, 0, n.getNotification().tickerText));
    final CharSequence text = n.getNotification().tickerText;
    final Segment newSegment = new Segment(n, icon, text);
    // If there's already a notification schedule for this package and id, remove it.
    for (int i = 0; i < mSegments.size(); i++) {
        Segment seg = mSegments.get(i);
        if (n.getId() == seg.notification.getId() && n.getPackageName().equals(seg.notification.getPackageName())) {
            // just update that one to use this new data instead
            // restart iteration here
            mSegments.remove(i--);
        }
    }
    mSegments.add(newSegment);
    if (mEvent != null) {
        if (newSegment != null) {
            mEvent.updateTicker(newSegment.notification, text.toString());
        }
    }
    if (initialCount == 0 && mSegments.size() > 0) {
        Segment seg = mSegments.get(0);
        seg.first = false;
        mIconSwitcher.setAnimateFirstView(false);
        mIconSwitcher.reset();
        mIconSwitcher.setImageDrawable(seg.icon);
        mTextSwitcher.setAnimateFirstView(false);
        mTextSwitcher.reset();
        mTextSwitcher.setText(seg.getText());
        tickerStarting();
        scheduleAdvance();
    }
}
Also used : Drawable(android.graphics.drawable.Drawable) StatusBarIcon(com.android.internal.statusbar.StatusBarIcon) TextPaint(android.text.TextPaint)

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