Search in sources :

Example 76 with StatusBarNotification

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;
        }
    };
}
Also used : MenuItem(android.view.MenuItem) ImageView(android.widget.ImageView) QuickSettingsContainerView(com.android.systemui.statusbar.phone.QuickSettingsContainerView) View(android.view.View) TextView(android.widget.TextView) SearchPanelView(com.android.systemui.SearchPanelView) StatusBarNotification(android.service.notification.StatusBarNotification) PendingIntent(android.app.PendingIntent) PopupMenu(android.widget.PopupMenu)

Example 77 with StatusBarNotification

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;
}
Also used : LayoutParams(android.view.ViewGroup.LayoutParams) SizeAdaptiveLayout(com.android.internal.widget.SizeAdaptiveLayout) ViewGroup(android.view.ViewGroup) ImageView(android.widget.ImageView) QuickSettingsContainerView(com.android.systemui.statusbar.phone.QuickSettingsContainerView) View(android.view.View) TextView(android.widget.TextView) SearchPanelView(com.android.systemui.SearchPanelView) Paint(android.graphics.Paint) RemoteViews(android.widget.RemoteViews) StatusBarNotification(android.service.notification.StatusBarNotification) LayoutInflater(android.view.LayoutInflater) TextView(android.widget.TextView) PendingIntent(android.app.PendingIntent)

Example 78 with StatusBarNotification

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);
}
Also used : Entry(com.android.systemui.statusbar.NotificationData.Entry) StatusBarNotification(android.service.notification.StatusBarNotification) Point(android.graphics.Point) NotificationData(com.android.systemui.statusbar.NotificationData) StatusBarIconView(com.android.systemui.statusbar.StatusBarIconView)

Example 79 with StatusBarNotification

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;
}
Also used : IBinder(android.os.IBinder) StatusBarNotification(android.service.notification.StatusBarNotification) ArrayList(java.util.ArrayList) Point(android.graphics.Point) Pair(android.util.Pair)

Example 80 with StatusBarNotification

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;
}
Also used : ViewGroup(android.view.ViewGroup) Drawable(android.graphics.drawable.Drawable) StatusBarIconView(com.android.systemui.statusbar.StatusBarIconView) ImageView(android.widget.ImageView) View(android.view.View) TextView(android.widget.TextView) Notification(android.app.Notification) StatusBarNotification(android.service.notification.StatusBarNotification) LayoutInflater(android.view.LayoutInflater) FrameLayout(android.widget.FrameLayout) TextView(android.widget.TextView) StatusBarIcon(com.android.internal.statusbar.StatusBarIcon) ImageView(android.widget.ImageView) PendingIntent(android.app.PendingIntent)

Aggregations

StatusBarNotification (android.service.notification.StatusBarNotification)144 Notification (android.app.Notification)61 View (android.view.View)24 PendingIntent (android.app.PendingIntent)23 TextView (android.widget.TextView)23 ApplicationInfo (android.content.pm.ApplicationInfo)21 ImageView (android.widget.ImageView)21 NameNotFoundException (android.content.pm.PackageManager.NameNotFoundException)17 StatusBarIcon (com.android.internal.statusbar.StatusBarIcon)16 ITransientNotification (android.app.ITransientNotification)15 NotificationData (com.android.systemui.statusbar.NotificationData)14 Point (android.graphics.Point)13 RemoteViews (android.widget.RemoteViews)12 Entry (com.android.systemui.statusbar.NotificationData.Entry)12 PackageManager (android.content.pm.PackageManager)11 UserHandle (android.os.UserHandle)10 NavigationBarView (com.android.systemui.statusbar.phone.NavigationBarView)10 RemoteInputView (com.android.systemui.statusbar.policy.RemoteInputView)10 Drawable (android.graphics.drawable.Drawable)9 NotificationPanelView (com.android.systemui.statusbar.phone.NotificationPanelView)9