Search in sources :

Example 16 with StatusBarIcon

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

the class Ticker method addEntry.

public void addEntry(StatusBarNotification n, boolean isMusic, MediaMetadata mediaMetaData) {
    int initialCount = mSegments.size();
    ContentResolver resolver = mContext.getContentResolver();
    if (isMusic) {
        CharSequence artist = mediaMetaData.getText(MediaMetadata.METADATA_KEY_ARTIST);
        CharSequence album = mediaMetaData.getText(MediaMetadata.METADATA_KEY_ALBUM);
        CharSequence title = mediaMetaData.getText(MediaMetadata.METADATA_KEY_TITLE);
        if (artist != null && album != null && title != null) {
            n.getNotification().tickerText = artist.toString() + " - " + album.toString() + " - " + title.toString();
        } else {
            return;
        }
    }
    // 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 && charSequencesEqual(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 (initialCount == 0 && mSegments.size() > 0) {
        Segment seg = mSegments.get(0);
        seg.first = false;
        mIconSwitcher.setAnimateFirstView(false);
        mIconSwitcher.reset();
        setAppIconColor(seg.icon);
        mTextSwitcher.setAnimateFirstView(false);
        mTextSwitcher.reset();
        mTextSwitcher.setText(seg.getText());
        mTextSwitcher.setTextColor(mTextColor);
        tickerStarting();
        scheduleAdvance();
    }
}
Also used : Drawable(android.graphics.drawable.Drawable) StatusBarIcon(com.android.internal.statusbar.StatusBarIcon) TextPaint(android.text.TextPaint) ContentResolver(android.content.ContentResolver)

Example 17 with StatusBarIcon

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

the class StatusBarIconController method setIconVisibility.

public void setIconVisibility(String slot, boolean visibility) {
    int index = getSlotIndex(slot);
    StatusBarIcon icon = getIcon(index);
    if (icon == null || icon.visible == visibility) {
        return;
    }
    icon.visible = visibility;
    handleSet(index, icon);
}
Also used : StatusBarIcon(com.android.internal.statusbar.StatusBarIcon)

Example 18 with StatusBarIcon

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

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 19 with StatusBarIcon

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

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 20 with StatusBarIcon

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

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

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