FileDocCategorySizeDatePackage
ExpandableNotificationRow.javaAPI DocAndroid 5.1 API16804Thu Mar 12 22:22:42 GMT 2015com.android.systemui.statusbar

ExpandableNotificationRow

public class ExpandableNotificationRow extends ActivatableNotificationView

Fields Summary
private int
mRowMinHeight
private int
mRowMaxHeight
private boolean
mExpandable
Does this row contain layouts that can adapt to row expansion
private boolean
mHasUserChangedExpansion
Has the user actively changed the expansion state of this row
private boolean
mUserExpanded
If {@link #mHasUserChangedExpansion}, has the user expanded this row
private boolean
mUserLocked
Is the user touching this row
private boolean
mShowingPublic
Are we showing the "public" version
private boolean
mSensitive
private boolean
mShowingPublicInitialized
private boolean
mShowingPublicForIntrinsicHeight
private boolean
mIsSystemExpanded
Is this notification expanded by the system. The expansion state can be overridden by the user expansion.
private boolean
mExpansionDisabled
Whether the notification expansion is disabled. This is the case on Keyguard.
private NotificationContentView
mPublicLayout
private NotificationContentView
mPrivateLayout
private int
mMaxExpandHeight
private android.view.View
mVetoButton
private boolean
mClearable
private ExpansionLogger
mLogger
private String
mLoggingKey
private boolean
mWasReset
private NotificationGuts
mGuts
private android.service.notification.StatusBarNotification
mStatusBarNotification
private boolean
mIsHeadsUp
Constructors Summary
public ExpandableNotificationRow(android.content.Context context, android.util.AttributeSet attrs)

        super(context, attrs);
    
Methods Summary
private voidanimateShowingPublic(long delay, long duration)

        final View source = mShowingPublic ? mPrivateLayout : mPublicLayout;
        View target = mShowingPublic ? mPublicLayout : mPrivateLayout;
        source.setVisibility(View.VISIBLE);
        target.setVisibility(View.VISIBLE);
        target.setAlpha(0f);
        source.animate().cancel();
        target.animate().cancel();
        source.animate()
                .alpha(0f)
                .setStartDelay(delay)
                .setDuration(duration)
                .withEndAction(new Runnable() {
                    @Override
                    public void run() {
                        source.setVisibility(View.INVISIBLE);
                    }
                });
        target.animate()
                .alpha(1f)
                .setStartDelay(delay)
                .setDuration(duration);
    
public voidapplyExpansionToLayout()
Apply an expansion state to the layout.

        boolean expand = isExpanded();
        if (expand && mExpandable) {
            setActualHeight(mMaxExpandHeight);
        } else {
            setActualHeight(mRowMinHeight);
        }
    
protected booleanfilterMotionEvent(android.view.MotionEvent event)

        return mIsHeadsUp || super.filterMotionEvent(event);
    
public intgetIntrinsicHeight()

        if (isUserLocked()) {
            return getActualHeight();
        }
        boolean inExpansionState = isExpanded();
        if (!inExpansionState) {
            // not expanded, so we return the collapsed size
            return mRowMinHeight;
        }

        return mShowingPublicForIntrinsicHeight ? mRowMinHeight : getMaxExpandHeight();
    
public intgetMaxExpandHeight()

        return mShowingPublicForIntrinsicHeight ? mRowMinHeight : mMaxExpandHeight;
    
public intgetMaxHeight()

        NotificationContentView showingLayout = getShowingLayout();
        return showingLayout.getMaxHeight();
    
public intgetMinHeight()

        NotificationContentView showingLayout = getShowingLayout();
        return showingLayout.getMinHeight();
    
private NotificationContentViewgetShowingLayout()

        return mShowingPublic ? mPublicLayout : mPrivateLayout;
    
public android.service.notification.StatusBarNotificationgetStatusBarNotification()

        return mStatusBarNotification;
    
public booleanhasUserChangedExpansion()

return
whether the user has changed the expansion state

        return mHasUserChangedExpansion;
    
public booleanisClearable()

return
Can the underlying notification be cleared?

        return mStatusBarNotification != null && mStatusBarNotification.isClearable();
    
public booleanisContentExpandable()

        NotificationContentView showingLayout = getShowingLayout();
        return showingLayout.isContentExpandable();
    
public booleanisExpandable()

        return mExpandable;
    
private booleanisExpanded()
Check whether the view state is currently expanded. This is given by the system in {@link #setSystemExpanded(boolean)} and can be overridden by user expansion or collapsing in {@link #setUserExpanded(boolean)}. Note that the visual appearance of this view can differ from this state, if layout params are modified from outside.

return
whether the view state is currently expanded.

        return !mExpansionDisabled
                && (!hasUserChangedExpansion() && isSystemExpanded() || isUserExpanded());
    
public booleanisMaxExpandHeightInitialized()

        return mMaxExpandHeight != 0;
    
public booleanisSystemExpanded()

return
has the system set this notification to be expanded

        return mIsSystemExpanded;
    
public booleanisUserExpanded()

        return mUserExpanded;
    
public booleanisUserLocked()

        return mUserLocked;
    
private voidlogExpansionEvent(boolean userAction, boolean wasExpanded)

        final boolean nowExpanded = isExpanded();
        if (wasExpanded != nowExpanded && mLogger != null) {
            mLogger.logNotificationExpansion(mLoggingKey, userAction, nowExpanded) ;
        }
    
public voidnotifyContentUpdated()

        mPublicLayout.notifyContentUpdated();
        mPrivateLayout.notifyContentUpdated();
    
protected voidonFinishInflate()

        super.onFinishInflate();
        mPublicLayout = (NotificationContentView) findViewById(R.id.expandedPublic);
        mPrivateLayout = (NotificationContentView) findViewById(R.id.expanded);
        ViewStub gutsStub = (ViewStub) findViewById(R.id.notification_guts_stub);
        gutsStub.setOnInflateListener(new ViewStub.OnInflateListener() {
            @Override
            public void onInflate(ViewStub stub, View inflated) {
                mGuts = (NotificationGuts) inflated;
                mGuts.setClipTopAmount(getClipTopAmount());
                mGuts.setActualHeight(getActualHeight());
            }
        });
        mVetoButton = findViewById(R.id.veto);
    
protected voidonLayout(boolean changed, int left, int top, int right, int bottom)

        super.onLayout(changed, left, top, right, bottom);
        boolean updateExpandHeight = mMaxExpandHeight == 0 && !mWasReset;
        updateMaxExpandHeight();
        if (updateExpandHeight) {
            applyExpansionToLayout();
        }
        mWasReset = false;
    
public booleanonRequestSendAccessibilityEvent(android.view.View child, android.view.accessibility.AccessibilityEvent event)

        if (super.onRequestSendAccessibilityEvent(child, event)) {
            // Add a record for the entire layout since its content is somehow small.
            // The event comes from a leaf view that is interacted with.
            AccessibilityEvent record = AccessibilityEvent.obtain();
            onInitializeAccessibilityEvent(record);
            dispatchPopulateAccessibilityEvent(record);
            event.appendRecord(record);
            return true;
        }
        return false;
    
public voidreset()
Resets this view so it can be re-used for an updated notification.

        super.reset();
        mRowMinHeight = 0;
        final boolean wasExpanded = isExpanded();
        mRowMaxHeight = 0;
        mExpandable = false;
        mHasUserChangedExpansion = false;
        mUserLocked = false;
        mShowingPublic = false;
        mSensitive = false;
        mShowingPublicInitialized = false;
        mIsSystemExpanded = false;
        mExpansionDisabled = false;
        mPublicLayout.reset(mIsHeadsUp);
        mPrivateLayout.reset(mIsHeadsUp);
        resetHeight();
        logExpansionEvent(false, wasExpanded);
    
public voidresetHeight()

        if (mIsHeadsUp) {
            resetActualHeight();
        }
        mMaxExpandHeight = 0;
        mWasReset = true;
        onHeightReset();
        requestLayout();
    
public voidresetUserExpansion()

        mHasUserChangedExpansion = false;
        mUserExpanded = false;
    
public voidsetActualHeight(int height, boolean notifyListeners)

        mPrivateLayout.setActualHeight(height);
        mPublicLayout.setActualHeight(height);
        if (mGuts != null) {
            mGuts.setActualHeight(height);
        }
        invalidate();
        super.setActualHeight(height, notifyListeners);
    
public voidsetClipTopAmount(int clipTopAmount)

        super.setClipTopAmount(clipTopAmount);
        mPrivateLayout.setClipTopAmount(clipTopAmount);
        mPublicLayout.setClipTopAmount(clipTopAmount);
        if (mGuts != null) {
            mGuts.setClipTopAmount(clipTopAmount);
        }
    
public voidsetDark(boolean dark, boolean fade, long delay)

        super.setDark(dark, fade, delay);
        final NotificationContentView showing = getShowingLayout();
        if (showing != null) {
            showing.setDark(dark, fade, delay);
        }
    
public voidsetExpandable(boolean expandable)

        mExpandable = expandable;
    
public voidsetExpansionDisabled(boolean expansionDisabled)

param
expansionDisabled whether to prevent notification expansion

        if (expansionDisabled != mExpansionDisabled) {
            final boolean wasExpanded = isExpanded();
            mExpansionDisabled = expansionDisabled;
            logExpansionEvent(false, wasExpanded);
            if (wasExpanded != isExpanded()) {
                notifyHeightChanged();
            }
        }
    
public voidsetExpansionLogger(com.android.systemui.statusbar.ExpandableNotificationRow$ExpansionLogger logger, java.lang.String key)

        mLogger = logger;
        mLoggingKey = key;
    
public voidsetHeadsUp(boolean isHeadsUp)

        mIsHeadsUp = isHeadsUp;
    
public voidsetHeightRange(int rowMinHeight, int rowMaxHeight)

        mRowMinHeight = rowMinHeight;
        mRowMaxHeight = rowMaxHeight;
    
public voidsetHideSensitive(boolean hideSensitive, boolean animated, long delay, long duration)

        boolean oldShowingPublic = mShowingPublic;
        mShowingPublic = mSensitive && hideSensitive;
        if (mShowingPublicInitialized && mShowingPublic == oldShowingPublic) {
            return;
        }

        // bail out if no public version
        if (mPublicLayout.getChildCount() == 0) return;

        if (!animated) {
            mPublicLayout.animate().cancel();
            mPrivateLayout.animate().cancel();
            mPublicLayout.setAlpha(1f);
            mPrivateLayout.setAlpha(1f);
            mPublicLayout.setVisibility(mShowingPublic ? View.VISIBLE : View.INVISIBLE);
            mPrivateLayout.setVisibility(mShowingPublic ? View.INVISIBLE : View.VISIBLE);
        } else {
            animateShowingPublic(delay, duration);
        }

        updateVetoButton();
        mShowingPublicInitialized = true;
    
public voidsetHideSensitiveForIntrinsicHeight(boolean hideSensitive)

        mShowingPublicForIntrinsicHeight = mSensitive && hideSensitive;
    
public voidsetIconAnimationRunning(boolean running)

        setIconAnimationRunning(running, mPublicLayout);
        setIconAnimationRunning(running, mPrivateLayout);
    
private voidsetIconAnimationRunning(boolean running, NotificationContentView layout)

        if (layout != null) {
            View contractedChild = layout.getContractedChild();
            View expandedChild = layout.getExpandedChild();
            setIconAnimationRunningForChild(running, contractedChild);
            setIconAnimationRunningForChild(running, expandedChild);
        }
    
private voidsetIconAnimationRunningForChild(boolean running, android.view.View child)

        if (child != null) {
            ImageView icon = (ImageView) child.findViewById(com.android.internal.R.id.icon);
            setIconRunning(icon, running);
            ImageView rightIcon = (ImageView) child.findViewById(
                    com.android.internal.R.id.right_icon);
            setIconRunning(rightIcon, running);
        }
    
private voidsetIconRunning(android.widget.ImageView imageView, boolean running)

        if (imageView != null) {
            Drawable drawable = imageView.getDrawable();
            if (drawable instanceof AnimationDrawable) {
                AnimationDrawable animationDrawable = (AnimationDrawable) drawable;
                if (running) {
                    animationDrawable.start();
                } else {
                    animationDrawable.stop();
                }
            } else if (drawable instanceof AnimatedVectorDrawable) {
                AnimatedVectorDrawable animationDrawable = (AnimatedVectorDrawable) drawable;
                if (running) {
                    animationDrawable.start();
                } else {
                    animationDrawable.stop();
                }
            }
        }
    
public voidsetSensitive(boolean sensitive)

        mSensitive = sensitive;
    
public voidsetStatusBarNotification(android.service.notification.StatusBarNotification statusBarNotification)

        mStatusBarNotification = statusBarNotification;
        updateVetoButton();
    
public voidsetSystemExpanded(boolean expand)
Set this notification to be expanded by the system.

param
expand whether the system wants this notification to be expanded.

        if (expand != mIsSystemExpanded) {
            final boolean wasExpanded = isExpanded();
            mIsSystemExpanded = expand;
            notifyHeightChanged();
            logExpansionEvent(false, wasExpanded);
        }
    
public voidsetUserExpanded(boolean userExpanded)
Set this notification to be expanded by the user

param
userExpanded whether the user wants this notification to be expanded

        if (userExpanded && !mExpandable) return;
        final boolean wasExpanded = isExpanded();
        mHasUserChangedExpansion = true;
        mUserExpanded = userExpanded;
        logExpansionEvent(true, wasExpanded);
    
public voidsetUserLocked(boolean userLocked)

        mUserLocked = userLocked;
    
private voidupdateMaxExpandHeight()

        int intrinsicBefore = getIntrinsicHeight();
        mMaxExpandHeight = mPrivateLayout.getMaxHeight();
        if (intrinsicBefore != getIntrinsicHeight()) {
            notifyHeightChanged();
        }
    
private voidupdateVetoButton()

        // public versions cannot be dismissed
        mVetoButton.setVisibility(isClearable() && !mShowingPublic ? View.VISIBLE : View.GONE);