use of android.service.notification.StatusBarNotification in project android_frameworks_base by ParanoidAndroid.
the class BaseStatusBar method getNotificationLongClicker.
protected View.OnLongClickListener getNotificationLongClicker() {
return new View.OnLongClickListener() {
@Override
public boolean onLongClick(View v) {
NotificationData.Entry entry = (NotificationData.Entry) v.getTag();
if (entry.notification == null)
return false;
StatusBarNotification sbn = entry.notification;
final String packageNameF = sbn.getPackageName();
final PendingIntent contentIntent = sbn.getNotification().contentIntent;
boolean expanded = Settings.System.getInt(mContext.getContentResolver(), Settings.System.EXPANDED_DESKTOP_STATE, 0) == 1;
if (packageNameF == null)
return false;
if (v.getWindowToken() == null)
return false;
//Long click menu broken on PIE mode...pop up menu is useless (auto-launch on long click)
if (expanded) {
launchFloating(contentIntent);
animateCollapsePanels(CommandQueue.FLAG_EXCLUDE_NONE);
return true;
}
mNotificationBlamePopup = new PopupMenu(mContext, v);
mNotificationBlamePopup.getMenuInflater().inflate(R.menu.notification_popup_menu, mNotificationBlamePopup.getMenu());
mNotificationBlamePopup.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() {
public boolean onMenuItemClick(MenuItem item) {
if (item.getItemId() == R.id.notification_inspect_item) {
startApplicationDetailsActivity(packageNameF);
animateCollapsePanels(CommandQueue.FLAG_EXCLUDE_NONE);
} else if (item.getItemId() == R.id.notification_floating_item) {
launchFloating(contentIntent);
animateCollapsePanels(CommandQueue.FLAG_EXCLUDE_NONE);
} else {
return false;
}
return true;
}
});
mNotificationBlamePopup.setOnDismissListener(new PopupMenu.OnDismissListener() {
@Override
public void onDismiss(PopupMenu popupMenu) {
mNotificationBlamePopup = null;
}
});
mNotificationBlamePopup.show();
return true;
}
};
}
use of android.service.notification.StatusBarNotification in project android_frameworks_base by ParanoidAndroid.
the class BaseStatusBar method inflateViews.
protected boolean inflateViews(NotificationData.Entry entry, ViewGroup parent) {
int minHeight = mContext.getResources().getDimensionPixelSize(R.dimen.notification_min_height);
int maxHeight = mContext.getResources().getDimensionPixelSize(R.dimen.notification_max_height);
StatusBarNotification sbn = entry.notification;
RemoteViews oneU = sbn.getNotification().contentView;
RemoteViews large = sbn.getNotification().bigContentView;
if (oneU == null) {
return false;
}
// create the row view
LayoutInflater inflater = (LayoutInflater) mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
View row = inflater.inflate(R.layout.status_bar_notification_row, parent, false);
// for blaming (see SwipeHelper.setLongPressListener)
row.setTag(entry);
workAroundBadLayerDrawableOpacity(row);
View vetoButton = updateNotificationVetoButton(row, sbn);
vetoButton.setContentDescription(mContext.getString(R.string.accessibility_remove_notification));
// NB: the large icon is now handled entirely by the template
// bind the click event to the content area
ViewGroup content = (ViewGroup) row.findViewById(R.id.content);
ViewGroup adaptive = (ViewGroup) row.findViewById(R.id.adaptive);
content.setDescendantFocusability(ViewGroup.FOCUS_BLOCK_DESCENDANTS);
PendingIntent contentIntent = sbn.getNotification().contentIntent;
if (contentIntent != null) {
final View.OnClickListener listener = new NotificationClicker(contentIntent, sbn.getPackageName(), sbn.getTag(), sbn.getId());
content.setOnClickListener(listener);
} else {
content.setOnClickListener(null);
}
// TODO(cwren) normalize variable names with those in updateNotification
View expandedOneU = null;
View expandedLarge = null;
try {
expandedOneU = oneU.apply(mContext, adaptive, mOnClickHandler);
if (large != null) {
expandedLarge = large.apply(mContext, adaptive, mOnClickHandler);
}
} catch (RuntimeException e) {
final String ident = sbn.getPackageName() + "/0x" + Integer.toHexString(sbn.getId());
Slog.e(TAG, "couldn't inflate view for notification " + ident, e);
return false;
}
if (expandedOneU != null) {
SizeAdaptiveLayout.LayoutParams params = new SizeAdaptiveLayout.LayoutParams(expandedOneU.getLayoutParams());
params.minHeight = minHeight;
params.maxHeight = minHeight;
adaptive.addView(expandedOneU, params);
}
if (expandedLarge != null) {
SizeAdaptiveLayout.LayoutParams params = new SizeAdaptiveLayout.LayoutParams(expandedLarge.getLayoutParams());
params.minHeight = minHeight + 1;
params.maxHeight = maxHeight;
adaptive.addView(expandedLarge, params);
}
row.setDrawingCacheEnabled(true);
applyLegacyRowBackground(sbn, content);
row.setTag(R.id.expandable_tag, Boolean.valueOf(large != null));
if (MULTIUSER_DEBUG) {
TextView debug = (TextView) row.findViewById(R.id.debug_info);
if (debug != null) {
debug.setVisibility(View.VISIBLE);
debug.setText("U " + entry.notification.getUserId());
}
}
entry.row = row;
entry.content = content;
entry.expanded = expandedOneU;
entry.setLargeView(expandedLarge);
return true;
}
use of android.service.notification.StatusBarNotification in project android_frameworks_base by ParanoidAndroid.
the class PhoneStatusBar method dump.
public void dump(FileDescriptor fd, PrintWriter pw, String[] args) {
synchronized (mQueueLock) {
pw.println("Current Status Bar state:");
pw.println(" mExpandedVisible=" + mExpandedVisible + ", mTrackingPosition=" + mTrackingPosition);
pw.println(" mTicking=" + mTicking);
pw.println(" mTracking=" + mTracking);
pw.println(" mDisplayMetrics=" + mDisplayMetrics);
pw.println(" mPile: " + viewInfo(mPile));
pw.println(" mTickerView: " + viewInfo(mTickerView));
pw.println(" mScrollView: " + viewInfo(mScrollView) + " scroll " + mScrollView.getScrollX() + "," + mScrollView.getScrollY());
}
pw.print(" mNavigationBarView=");
if (mNavigationBarView == null) {
pw.println("null");
} else {
mNavigationBarView.dump(fd, pw, args);
}
pw.println(" Panels: ");
if (mNotificationPanel != null) {
pw.println(" mNotificationPanel=" + mNotificationPanel + " params=" + mNotificationPanel.getLayoutParams().debug(""));
pw.print(" ");
mNotificationPanel.dump(fd, pw, args);
}
if (mSettingsPanel != null) {
pw.println(" mSettingsPanel=" + mSettingsPanel + " params=" + mSettingsPanel.getLayoutParams().debug(""));
pw.print(" ");
mSettingsPanel.dump(fd, pw, args);
}
if (DUMPTRUCK) {
synchronized (mNotificationData) {
int N = mNotificationData.size();
pw.println(" notification icons: " + N);
for (int i = 0; i < N; i++) {
NotificationData.Entry e = mNotificationData.get(i);
pw.println(" [" + i + "] key=" + e.key + " icon=" + e.icon);
StatusBarNotification n = e.notification;
pw.println(" pkg=" + n.getPackageName() + " id=" + n.getId() + " score=" + n.getScore());
pw.println(" notification=" + n.getNotification());
pw.println(" tickerText=\"" + n.getNotification().tickerText + "\"");
}
}
int N = mStatusIcons.getChildCount();
pw.println(" system icons: " + N);
for (int i = 0; i < N; i++) {
StatusBarIconView ic = (StatusBarIconView) mStatusIcons.getChildAt(i);
pw.println(" [" + i + "] icon=" + ic);
}
if (false) {
pw.println("see the logcat for a dump of the views we have created.");
// must happen on ui thread
mHandler.post(new Runnable() {
public void run() {
mStatusBarView.getLocationOnScreen(mAbsPos);
Slog.d(TAG, "mStatusBarView: ----- (" + mAbsPos[0] + "," + mAbsPos[1] + ") " + mStatusBarView.getWidth() + "x" + getStatusBarHeight());
mStatusBarView.debug();
}
});
}
}
if (DEBUG_GESTURES) {
pw.print(" status bar gestures: ");
mGestureRec.dump(fd, pw, args);
}
mNetworkController.dump(fd, pw, args);
}
use of android.service.notification.StatusBarNotification in project android_frameworks_base by ParanoidAndroid.
the class TabletStatusBar method recreateStatusBar.
private void recreateStatusBar() {
mRecreating = true;
mStatusBarContainer.removeAllViews();
// extract notifications.
int nNotifs = mNotificationData.size();
ArrayList<Pair<IBinder, StatusBarNotification>> notifications = new ArrayList<Pair<IBinder, StatusBarNotification>>(nNotifs);
copyNotifications(notifications, mNotificationData);
mNotificationData.clear();
mStatusBarContainer.addView(makeStatusBarView());
addPanelWindows();
// recreate notifications.
for (int i = 0; i < nNotifs; i++) {
Pair<IBinder, StatusBarNotification> notifData = notifications.get(i);
addNotificationViews(notifData.first, notifData.second);
}
setAreThereNotifications();
mRecreating = false;
}
use of android.service.notification.StatusBarNotification 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;
}
Aggregations