Search in sources :

Example 1 with Entry

use of com.android.systemui.statusbar.NotificationData.Entry in project android_frameworks_base by ParanoidAndroid.

the class TabletStatusBar method updateNotificationIcons.

@Override
protected void updateNotificationIcons() {
    if (mIconLayout == null)
        return;
    // first, populate the main notification panel
    loadNotificationPanel();
    final LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(mIconSize + 2 * mIconHPadding, mNaturalBarHeight);
    // alternate behavior in DND mode
    if (mNotificationDNDMode) {
        if (mIconLayout.getChildCount() == 0) {
            final Notification dndNotification = new Notification.Builder(mContext).setContentTitle(mContext.getText(R.string.notifications_off_title)).setContentText(mContext.getText(R.string.notifications_off_text)).setSmallIcon(R.drawable.ic_notification_dnd).setOngoing(true).getNotification();
            final StatusBarIconView iconView = new StatusBarIconView(mContext, "_dnd", dndNotification);
            iconView.setImageResource(R.drawable.ic_notification_dnd);
            iconView.setScaleType(ImageView.ScaleType.CENTER_INSIDE);
            iconView.setPadding(mIconHPadding, 0, mIconHPadding, 0);
            mNotificationDNDDummyEntry = new NotificationData.Entry(null, new StatusBarNotification("", 0, "", 0, 0, Notification.PRIORITY_MAX, dndNotification, android.os.Process.myUserHandle()), iconView);
            mIconLayout.addView(iconView, params);
        }
        return;
    } else if (0 != (mDisabled & StatusBarManager.DISABLE_NOTIFICATION_ICONS)) {
        // just leave the area totally empty
        return;
    }
    int N = mNotificationData.size();
    if (DEBUG) {
        Slog.d(TAG, "refreshing icons: " + N + " notifications, mIconLayout=" + mIconLayout);
    }
    ArrayList<View> toShow = new ArrayList<View>();
    // Extra Special Icons
    // The IME switcher and compatibility mode icons take the place of notifications. You didn't
    // need to see all those new emails, did you?
    int maxNotificationIconsCount = mMaxNotificationIcons;
    if (mInputMethodSwitchButton.getVisibility() != View.GONE)
        maxNotificationIconsCount--;
    if (mCompatModeButton.getVisibility() != View.GONE)
        maxNotificationIconsCount--;
    final boolean provisioned = isDeviceProvisioned();
    // If the device hasn't been through Setup, we only show system notifications
    for (int i = 0; toShow.size() < maxNotificationIconsCount; i++) {
        if (i >= N)
            break;
        Entry ent = mNotificationData.get(N - i - 1);
        if ((provisioned && ent.notification.getScore() >= HIDE_ICONS_BELOW_SCORE) || showNotificationEvenIfUnprovisioned(ent.notification) || mHaloTaskerActive) {
            toShow.add(ent.icon);
        }
    }
    ArrayList<View> toRemove = new ArrayList<View>();
    for (int i = 0; i < mIconLayout.getChildCount(); i++) {
        View child = mIconLayout.getChildAt(i);
        if (!toShow.contains(child)) {
            toRemove.add(child);
        }
    }
    for (View remove : toRemove) {
        mIconLayout.removeView(remove);
    }
    for (int i = 0; i < toShow.size(); i++) {
        View v = toShow.get(i);
        v.setPadding(mIconHPadding, 0, mIconHPadding, 0);
        if (v.getParent() == null) {
            mIconLayout.addView(v, i, params);
        }
    }
}
Also used : MarginLayoutParams(android.view.ViewGroup.MarginLayoutParams) LayoutParams(android.view.ViewGroup.LayoutParams) Entry(com.android.systemui.statusbar.NotificationData.Entry) ArrayList(java.util.ArrayList) ImageView(android.widget.ImageView) QuickSettingsContainerView(com.android.systemui.statusbar.phone.QuickSettingsContainerView) View(android.view.View) TextView(android.widget.TextView) SignalClusterView(com.android.systemui.statusbar.SignalClusterView) StatusBarIconView(com.android.systemui.statusbar.StatusBarIconView) KeyButtonView(com.android.systemui.statusbar.policy.KeyButtonView) ScrollView(android.widget.ScrollView) Notification(android.app.Notification) StatusBarNotification(android.service.notification.StatusBarNotification) Point(android.graphics.Point) Entry(com.android.systemui.statusbar.NotificationData.Entry) StatusBarNotification(android.service.notification.StatusBarNotification) LinearLayout(android.widget.LinearLayout) StatusBarIconView(com.android.systemui.statusbar.StatusBarIconView) NotificationData(com.android.systemui.statusbar.NotificationData)

Example 2 with Entry

use of com.android.systemui.statusbar.NotificationData.Entry in project android_frameworks_base by ParanoidAndroid.

the class PhoneStatusBar method updateNotificationIcons.

@Override
protected void updateNotificationIcons() {
    if (mNotificationIcons == null)
        return;
    loadNotificationShade();
    final LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(mIconSize + 2 * mIconHPadding, mNaturalBarHeight);
    int N = mNotificationData.size();
    if (DEBUG) {
        Slog.d(TAG, "refreshing icons: " + N + " notifications, mNotificationIcons=" + mNotificationIcons);
    }
    ArrayList<View> toShow = new ArrayList<View>();
    final boolean provisioned = isDeviceProvisioned();
    // If the device hasn't been through Setup, we only show system notifications
    for (int i = 0; i < N; i++) {
        Entry ent = mNotificationData.get(N - i - 1);
        if (!((provisioned && ent.notification.getScore() >= HIDE_ICONS_BELOW_SCORE) || showNotificationEvenIfUnprovisioned(ent.notification) || mHaloTaskerActive))
            continue;
        if (!notificationIsForCurrentUser(ent.notification))
            continue;
        toShow.add(ent.icon);
    }
    ArrayList<View> toRemove = new ArrayList<View>();
    for (int i = 0; i < mNotificationIcons.getChildCount(); i++) {
        View child = mNotificationIcons.getChildAt(i);
        if (!toShow.contains(child)) {
            toRemove.add(child);
        }
    }
    for (View remove : toRemove) {
        mNotificationIcons.removeView(remove);
    }
    for (int i = 0; i < toShow.size(); i++) {
        View v = toShow.get(i);
        if (v.getParent() == null) {
            mNotificationIcons.addView(v, i, params);
        }
    }
}
Also used : Entry(com.android.systemui.statusbar.NotificationData.Entry) LayoutParams(android.view.ViewGroup.LayoutParams) ArrayList(java.util.ArrayList) IntruderAlertView(com.android.systemui.statusbar.policy.IntruderAlertView) ImageView(android.widget.ImageView) DateView(com.android.systemui.statusbar.policy.DateView) View(android.view.View) TextView(android.widget.TextView) SignalClusterView(com.android.systemui.statusbar.SignalClusterView) StatusBarIconView(com.android.systemui.statusbar.StatusBarIconView) ScrollView(android.widget.ScrollView) LinearLayout(android.widget.LinearLayout) Point(android.graphics.Point)

Example 3 with Entry

use of com.android.systemui.statusbar.NotificationData.Entry in project android_frameworks_base by ParanoidAndroid.

the class PhoneStatusBar method loadNotificationShade.

private void loadNotificationShade() {
    if (mPile == null)
        return;
    int N = mNotificationData.size();
    ArrayList<View> toShow = new ArrayList<View>();
    final boolean provisioned = isDeviceProvisioned();
    // If the device hasn't been through Setup, we only show system notifications
    for (int i = 0; i < N; i++) {
        Entry ent = mNotificationData.get(N - i - 1);
        if (!(provisioned || showNotificationEvenIfUnprovisioned(ent.notification)))
            continue;
        if (!notificationIsForCurrentUser(ent.notification))
            continue;
        toShow.add(ent.row);
    }
    ArrayList<View> toRemove = new ArrayList<View>();
    for (int i = 0; i < mPile.getChildCount(); i++) {
        View child = mPile.getChildAt(i);
        if (!toShow.contains(child)) {
            toRemove.add(child);
        }
    }
    for (View remove : toRemove) {
        mPile.removeView(remove);
    }
    for (int i = 0; i < toShow.size(); i++) {
        View v = toShow.get(i);
        if (v.getParent() == null) {
            mPile.addView(v, i);
        }
    }
    if (mSettingsButton != null) {
        mSettingsButton.setEnabled(isDeviceProvisioned());
    }
    if (mHaloButton != null) {
        mHaloButton.setEnabled(isDeviceProvisioned());
    }
}
Also used : Entry(com.android.systemui.statusbar.NotificationData.Entry) ArrayList(java.util.ArrayList) IntruderAlertView(com.android.systemui.statusbar.policy.IntruderAlertView) ImageView(android.widget.ImageView) DateView(com.android.systemui.statusbar.policy.DateView) View(android.view.View) TextView(android.widget.TextView) SignalClusterView(com.android.systemui.statusbar.SignalClusterView) StatusBarIconView(com.android.systemui.statusbar.StatusBarIconView) ScrollView(android.widget.ScrollView) Point(android.graphics.Point)

Example 4 with Entry

use of com.android.systemui.statusbar.NotificationData.Entry in project android_frameworks_base by ResurrectionRemix.

the class PhoneStatusBar method updateNotificationShade.

private void updateNotificationShade() {
    if (mStackScroller == null)
        return;
    // Do not modify the notifications during collapse.
    if (isCollapsing()) {
        addPostCollapseAction(new Runnable() {

            @Override
            public void run() {
                updateNotificationShade();
            }
        });
        return;
    }
    ArrayList<Entry> activeNotifications = mNotificationData.getActiveNotifications();
    ArrayList<ExpandableNotificationRow> toShow = new ArrayList<>(activeNotifications.size());
    final int N = activeNotifications.size();
    for (int i = 0; i < N; i++) {
        Entry ent = activeNotifications.get(i);
        if (ent.row.isDismissed() || ent.row.isRemoved()) {
            // temporarily become children if they were isolated before.
            continue;
        }
        int vis = ent.notification.getNotification().visibility;
        // Display public version of the notification if we need to redact.
        final boolean hideSensitive = !userAllowsPrivateNotificationsInPublic(ent.notification.getUserId());
        boolean sensitiveNote = vis == Notification.VISIBILITY_PRIVATE;
        boolean sensitivePackage = packageHasVisibilityOverride(ent.notification.getKey());
        boolean sensitive = (sensitiveNote && hideSensitive) || sensitivePackage;
        boolean showingPublic = sensitive && isLockscreenPublicMode();
        if (showingPublic) {
            updatePublicContentView(ent, ent.notification);
        }
        ent.row.setSensitive(sensitive, hideSensitive);
        if (ent.autoRedacted && ent.legacy) {
            // for legacy auto redacted notifications.
            if (showingPublic) {
                ent.row.setShowingLegacyBackground(false);
            } else {
                ent.row.setShowingLegacyBackground(true);
            }
        }
        if (mGroupManager.isChildInGroupWithSummary(ent.row.getStatusBarNotification())) {
            ExpandableNotificationRow summary = mGroupManager.getGroupSummary(ent.row.getStatusBarNotification());
            List<ExpandableNotificationRow> orderedChildren = mTmpChildOrderMap.get(summary);
            if (orderedChildren == null) {
                orderedChildren = new ArrayList<>();
                mTmpChildOrderMap.put(summary, orderedChildren);
            }
            orderedChildren.add(ent.row);
        } else {
            toShow.add(ent.row);
        }
    }
    ArrayList<ExpandableNotificationRow> toRemove = new ArrayList<>();
    for (int i = 0; i < mStackScroller.getChildCount(); i++) {
        View child = mStackScroller.getChildAt(i);
        if (!toShow.contains(child) && child instanceof ExpandableNotificationRow) {
            toRemove.add((ExpandableNotificationRow) child);
        }
    }
    for (ExpandableNotificationRow remove : toRemove) {
        if (mGroupManager.isChildInGroupWithSummary(remove.getStatusBarNotification())) {
            // we are only transfering this notification to its parent, don't generate an animation
            mStackScroller.setChildTransferInProgress(true);
        }
        if (remove.isSummaryWithChildren()) {
            remove.removeAllChildren();
        }
        mStackScroller.removeView(remove);
        mStackScroller.setChildTransferInProgress(false);
    }
    removeNotificationChildren();
    for (int i = 0; i < toShow.size(); i++) {
        View v = toShow.get(i);
        if (v.getParent() == null) {
            mVisualStabilityManager.notifyViewAddition(v);
            mStackScroller.addView(v);
        }
    }
    addNotificationChildrenAndSort();
    // So after all this work notifications still aren't sorted correctly.
    // Let's do that now by advancing through toShow and mStackScroller in
    // lock-step, making sure mStackScroller matches what we see in toShow.
    int j = 0;
    for (int i = 0; i < mStackScroller.getChildCount(); i++) {
        View child = mStackScroller.getChildAt(i);
        if (!(child instanceof ExpandableNotificationRow)) {
            // We don't care about non-notification views.
            continue;
        }
        ExpandableNotificationRow targetChild = toShow.get(j);
        if (child != targetChild) {
            // here and advance both lists.
            if (mVisualStabilityManager.canReorderNotification(targetChild)) {
                mStackScroller.changeViewPosition(targetChild, i);
            } else {
                mVisualStabilityManager.addReorderingAllowedCallback(this);
            }
        }
        j++;
    }
    mVisualStabilityManager.onReorderingFinished();
    // clear the map again for the next usage
    mTmpChildOrderMap.clear();
    updateRowStates();
    updateSpeedbump();
    updateClearAll();
    updateEmptyShadeView();
    updateQsExpansionEnabled();
    mShadeUpdates.check();
}
Also used : Entry(com.android.systemui.statusbar.NotificationData.Entry) ArrayList(java.util.ArrayList) ActivatableNotificationView(com.android.systemui.statusbar.ActivatableNotificationView) BatteryMeterView(com.android.systemui.BatteryMeterView) DismissView(com.android.systemui.statusbar.DismissView) NotificationBackgroundView(com.android.systemui.statusbar.NotificationBackgroundView) VisualizerView(com.android.systemui.statusbar.VisualizerView) SignalClusterView(com.android.systemui.statusbar.SignalClusterView) KeyguardStatusView(com.android.keyguard.KeyguardStatusView) ImageView(android.widget.ImageView) BatteryLevelTextView(com.android.systemui.BatteryLevelTextView) BackDropView(com.android.systemui.statusbar.BackDropView) KeyButtonView(com.android.systemui.statusbar.policy.KeyButtonView) EmptyShadeView(com.android.systemui.statusbar.EmptyShadeView) View(android.view.View) TextView(android.widget.TextView) ScrimView(com.android.systemui.statusbar.ScrimView) Point(android.graphics.Point) ExpandableNotificationRow(com.android.systemui.statusbar.ExpandableNotificationRow) MediaExpandableNotificationRow(com.android.systemui.statusbar.MediaExpandableNotificationRow)

Example 5 with Entry

use of com.android.systemui.statusbar.NotificationData.Entry in project android_frameworks_base by ResurrectionRemix.

the class PhoneStatusBar method addNotification.

@Override
public void addNotification(StatusBarNotification notification, RankingMap ranking, Entry oldEntry) {
    if (DEBUG)
        Log.d(TAG, "addNotification key=" + notification.getKey());
    mNotificationData.updateRanking(ranking);
    Entry shadeEntry = createNotificationViews(notification);
    if (shadeEntry == null) {
        return;
    }
    boolean isHeadsUped = shouldPeek(shadeEntry);
    if (isHeadsUped) {
        mHeadsUpManager.showNotification(shadeEntry);
        // Mark as seen immediately
        setNotificationShown(notification);
    }
    if (!isHeadsUped && notification.getNotification().fullScreenIntent != null) {
        if (shouldSuppressFullScreenIntent(notification.getKey())) {
            if (DEBUG) {
                Log.d(TAG, "No Fullscreen intent: suppressed by DND: " + notification.getKey());
            }
        } else if (importanceToLevel(mNotificationData.getImportance(notification.getKey())) < importanceToLevel(NotificationListenerService.Ranking.IMPORTANCE_MAX)) {
            if (DEBUG) {
                Log.d(TAG, "No Fullscreen intent: not important enough: " + notification.getKey());
            }
        } else {
            // Stop screensaver if the notification has a full-screen intent.
            // (like an incoming phone call)
            awakenDreams();
            // not immersive & a full-screen alert should be shown
            if (DEBUG)
                Log.d(TAG, "Notification has fullScreenIntent; sending fullScreenIntent");
            try {
                EventLog.writeEvent(EventLogTags.SYSUI_FULLSCREEN_NOTIFICATION, notification.getKey());
                notification.getNotification().fullScreenIntent.send();
                shadeEntry.notifyFullScreenIntentLaunched();
                MetricsLogger.count(mContext, "note_fullscreen", 1);
            } catch (PendingIntent.CanceledException e) {
            }
        }
    } else {
        tick(notification, true, false, null);
    }
    addNotificationViews(shadeEntry, ranking);
    // Recalculate the position of the sliding windows and the titles.
    setAreThereNotifications();
}
Also used : Entry(com.android.systemui.statusbar.NotificationData.Entry)

Aggregations

Entry (com.android.systemui.statusbar.NotificationData.Entry)81 Point (android.graphics.Point)39 ArrayList (java.util.ArrayList)14 View (android.view.View)13 ImageView (android.widget.ImageView)13 TextView (android.widget.TextView)13 Notification (android.app.Notification)11 StatusBarNotification (android.service.notification.StatusBarNotification)11 ExpandableNotificationRow (com.android.systemui.statusbar.ExpandableNotificationRow)10 SignalClusterView (com.android.systemui.statusbar.SignalClusterView)9 StatusBarManager.windowStateToString (android.app.StatusBarManager.windowStateToString)8 NotificationData (com.android.systemui.statusbar.NotificationData)8 MediaExpandableNotificationRow (com.android.systemui.statusbar.MediaExpandableNotificationRow)6 KeyButtonView (com.android.systemui.statusbar.policy.KeyButtonView)6 MediaController (android.media.session.MediaController)5 MediaSession (android.media.session.MediaSession)5 StatusBarIcon (com.android.internal.statusbar.StatusBarIcon)5 BatteryMeterView (com.android.systemui.BatteryMeterView)5 KeyguardViewMediator (com.android.systemui.keyguard.KeyguardViewMediator)5 ActivatableNotificationView (com.android.systemui.statusbar.ActivatableNotificationView)5