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();
}
}
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);
}
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));
}
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();
}
}
}
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));
}
Aggregations