Search in sources :

Example 6 with Entry

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

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);
        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) {
            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) {
            // Oops, wrong notification at this position. Put the right one
            // here and advance both lists.
            mStackScroller.changeViewPosition(targetChild, i);
        }
        j++;
    }
    // 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) ImageView(android.widget.ImageView) ActivatableNotificationView(com.android.systemui.statusbar.ActivatableNotificationView) BatteryMeterView(com.android.systemui.BatteryMeterView) BackDropView(com.android.systemui.statusbar.BackDropView) DismissView(com.android.systemui.statusbar.DismissView) EmptyShadeView(com.android.systemui.statusbar.EmptyShadeView) View(android.view.View) TextView(android.widget.TextView) ScrimView(com.android.systemui.statusbar.ScrimView) SignalClusterView(com.android.systemui.statusbar.SignalClusterView) Point(android.graphics.Point) ExpandableNotificationRow(com.android.systemui.statusbar.ExpandableNotificationRow)

Example 7 with Entry

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

the class PhoneStatusBar method resetUserExpandedStates.

public void resetUserExpandedStates() {
    ArrayList<Entry> activeNotifications = mNotificationData.getActiveNotifications();
    final int notificationCount = activeNotifications.size();
    for (int i = 0; i < notificationCount; i++) {
        NotificationData.Entry entry = activeNotifications.get(i);
        if (entry.row != null) {
            entry.row.resetUserExpansion();
        }
    }
}
Also used : Entry(com.android.systemui.statusbar.NotificationData.Entry) Entry(com.android.systemui.statusbar.NotificationData.Entry) Point(android.graphics.Point) NotificationData(com.android.systemui.statusbar.NotificationData)

Example 8 with Entry

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

the class PhoneStatusBar method startKeyguard.

protected void startKeyguard() {
    Trace.beginSection("PhoneStatusBar#startKeyguard");
    KeyguardViewMediator keyguardViewMediator = getComponent(KeyguardViewMediator.class);
    mFingerprintUnlockController = new FingerprintUnlockController(mContext, mStatusBarWindowManager, mDozeScrimController, keyguardViewMediator, mScrimController, this);
    mStatusBarKeyguardViewManager = keyguardViewMediator.registerStatusBar(this, getBouncerContainer(), mStatusBarWindowManager, mScrimController, mFingerprintUnlockController);
    mKeyguardIndicationController.setStatusBarKeyguardViewManager(mStatusBarKeyguardViewManager);
    mFingerprintUnlockController.setStatusBarKeyguardViewManager(mStatusBarKeyguardViewManager);
    mIconPolicy.setStatusBarKeyguardViewManager(mStatusBarKeyguardViewManager);
    mRemoteInputController.addCallback(mStatusBarKeyguardViewManager);
    mRemoteInputController.addCallback(new RemoteInputController.Callback() {

        @Override
        public void onRemoteInputSent(Entry entry) {
            if (FORCE_REMOTE_INPUT_HISTORY && mKeysKeptForRemoteInput.contains(entry.key)) {
                removeNotification(entry.key, null);
            } else if (mRemoteInputEntriesToRemoveOnCollapse.contains(entry)) {
                // We're currently holding onto this notification, but from the apps point of
                // view it is already canceled, so we'll need to cancel it on the apps behalf
                // after sending - unless the app posts an update in the mean time, so wait a
                // bit.
                mHandler.postDelayed(() -> {
                    if (mRemoteInputEntriesToRemoveOnCollapse.remove(entry)) {
                        removeNotification(entry.key, null);
                    }
                }, REMOTE_INPUT_KEPT_ENTRY_AUTO_CANCEL_DELAY);
            }
        }
    });
    mKeyguardViewMediatorCallback = keyguardViewMediator.getViewMediatorCallback();
    mLightStatusBarController.setFingerprintUnlockController(mFingerprintUnlockController);
    Trace.endSection();
}
Also used : KeyguardViewMediator(com.android.systemui.keyguard.KeyguardViewMediator) Entry(com.android.systemui.statusbar.NotificationData.Entry) RemoteInputController(com.android.systemui.statusbar.RemoteInputController)

Example 9 with Entry

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

the class PhoneStatusBar method removeNotification.

@Override
public void removeNotification(String key, RankingMap ranking) {
    boolean deferRemoval = false;
    if (mHeadsUpManager.isHeadsUp(key)) {
        // A cancel() in repsonse to a remote input shouldn't be delayed, as it makes the
        // sending look longer than it takes.
        boolean ignoreEarliestRemovalTime = mRemoteInputController.isSpinning(key) && !FORCE_REMOTE_INPUT_HISTORY;
        deferRemoval = !mHeadsUpManager.removeNotification(key, ignoreEarliestRemovalTime);
    }
    if (key.equals(mMediaNotificationKey)) {
        clearCurrentMediaNotification();
        updateMediaMetaData(true, true);
    }
    if (FORCE_REMOTE_INPUT_HISTORY && mRemoteInputController.isSpinning(key)) {
        Entry entry = mNotificationData.get(key);
        StatusBarNotification sbn = entry.notification;
        Notification.Builder b = Notification.Builder.recoverBuilder(mContext, sbn.getNotification().clone());
        CharSequence[] oldHistory = sbn.getNotification().extras.getCharSequenceArray(Notification.EXTRA_REMOTE_INPUT_HISTORY);
        CharSequence[] newHistory;
        if (oldHistory == null) {
            newHistory = new CharSequence[1];
        } else {
            newHistory = new CharSequence[oldHistory.length + 1];
            for (int i = 0; i < oldHistory.length; i++) {
                newHistory[i + 1] = oldHistory[i];
            }
        }
        newHistory[0] = String.valueOf(entry.remoteInputText);
        b.setRemoteInputHistory(newHistory);
        Notification newNotification = b.build();
        // Undo any compatibility view inflation
        newNotification.contentView = sbn.getNotification().contentView;
        newNotification.bigContentView = sbn.getNotification().bigContentView;
        newNotification.headsUpContentView = sbn.getNotification().headsUpContentView;
        StatusBarNotification newSbn = new StatusBarNotification(sbn.getPackageName(), sbn.getOpPkg(), sbn.getId(), sbn.getTag(), sbn.getUid(), sbn.getInitialPid(), 0, newNotification, sbn.getUser(), sbn.getPostTime());
        updateNotification(newSbn, null);
        mKeysKeptForRemoteInput.add(entry.key);
        return;
    }
    if (deferRemoval) {
        mLatestRankingMap = ranking;
        mHeadsUpEntriesToRemoveOnSwitch.add(mHeadsUpManager.getEntry(key));
        return;
    }
    Entry entry = mNotificationData.get(key);
    if (entry != null && mRemoteInputController.isRemoteInputActive(entry) && (entry.row != null && !entry.row.isDismissed())) {
        mLatestRankingMap = ranking;
        mRemoteInputEntriesToRemoveOnCollapse.add(entry);
        return;
    }
    if (entry != null && entry.row != null) {
        entry.row.setRemoved();
    }
    // Let's remove the children if this was a summary
    handleGroupSummaryRemoved(key, ranking);
    StatusBarNotification old = removeNotificationViews(key, ranking);
    if (SPEW)
        Log.d(TAG, "removeNotification key=" + key + " old=" + old);
    if (old != null) {
        if (CLOSE_PANEL_WHEN_EMPTIED && !hasActiveNotifications() && !mNotificationPanel.isTracking() && !mNotificationPanel.isQsExpanded()) {
            if (mState == StatusBarState.SHADE) {
                animateCollapsePanels();
            } else if (mState == StatusBarState.SHADE_LOCKED && !isCollapsing()) {
                goToKeyguard();
            }
        }
    }
    setAreThereNotifications();
}
Also used : Entry(com.android.systemui.statusbar.NotificationData.Entry) StatusBarNotification(android.service.notification.StatusBarNotification) Notification(android.app.Notification) StatusBarNotification(android.service.notification.StatusBarNotification) Point(android.graphics.Point)

Example 10 with Entry

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

the class BaseStatusBar method onDensityOrFontScaleChanged.

protected void onDensityOrFontScaleChanged() {
    ArrayList<Entry> activeNotifications = mNotificationData.getActiveNotifications();
    for (int i = 0; i < activeNotifications.size(); i++) {
        Entry entry = activeNotifications.get(i);
        boolean exposedGuts = entry.row.getGuts() == mNotificationGutsExposed;
        entry.row.reInflateViews();
        if (exposedGuts) {
            mNotificationGutsExposed = entry.row.getGuts();
            bindGuts(entry.row);
        }
        inflateViews(entry, mStackScroller);
    }
}
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