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