Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit ad41a94b authored by Dianne Hackborn's avatar Dianne Hackborn Committed by Android (Google) Code Review
Browse files

Merge "Some optimizations." into ics-mr1

parents 2eca6133 0500b3cf
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -22849,6 +22849,7 @@ package android.view {
    method public void buildDrawingCache();
    method public void buildDrawingCache(boolean);
    method public void buildLayer();
    method public boolean callOnClick();
    method public boolean canScrollHorizontally(int);
    method public boolean canScrollVertically(int);
    method public void cancelLongPress();
@@ -23000,6 +23001,7 @@ package android.view {
    method public float getY();
    method public boolean hasFocus();
    method public boolean hasFocusable();
    method public boolean hasOnClickListeners();
    method public boolean hasWindowFocus();
    method public static android.view.View inflate(android.content.Context, int, android.view.ViewGroup);
    method protected void initializeFadingEdge(android.content.res.TypedArray);
+3 −1
Original line number Diff line number Diff line
@@ -2769,7 +2769,9 @@ public final class ActivityThread {
            if (info != null) {
                try {
                    // First create a thumbnail for the activity...
                    info.thumbnail = createThumbnailBitmap(r);
                    // For now, don't create the thumbnail here; we are
                    // doing that by doing a screen snapshot.
                    info.thumbnail = null; //createThumbnailBitmap(r);
                    info.description = r.activity.onCreateDescription();
                } catch (Exception e) {
                    if (!mInstrumentation.onException(r.activity, e)) {
+149 −87
Original line number Diff line number Diff line
@@ -1548,7 +1548,7 @@ public class View implements Drawable.Callback, Drawable.Callback2, KeyEvent.Cal
    int mID = NO_ID;
    /**
     * The stable ID of this view for accessibility porposes.
     * The stable ID of this view for accessibility purposes.
     */
    int mAccessibilityViewId = NO_ID;
@@ -2317,6 +2317,7 @@ public class View implements Drawable.Callback, Drawable.Callback2, KeyEvent.Cal
    private int mBackgroundResource;
    private boolean mBackgroundSizeChanged;
    static class ListenerInfo {
        /**
         * Listener used to dispatch focus change events.
         * This field should be made private, so it is hidden from the SDK.
@@ -2339,7 +2340,7 @@ public class View implements Drawable.Callback, Drawable.Callback2, KeyEvent.Cal
         * This field should be made private, so it is hidden from the SDK.
         * {@hide}
         */
    protected OnClickListener mOnClickListener;
        public OnClickListener mOnClickListener;
        /**
         * Listener used to dispatch long click events.
@@ -2366,6 +2367,9 @@ public class View implements Drawable.Callback, Drawable.Callback2, KeyEvent.Cal
        private OnDragListener mOnDragListener;
        private OnSystemUiVisibilityChangeListener mOnSystemUiVisibilityChangeListener;
    }
    ListenerInfo mListenerInfo;
    /**
     * The application environment this view lives in.
@@ -3346,13 +3350,21 @@ public class View implements Drawable.Callback, Drawable.Callback2, KeyEvent.Cal
        return mVerticalScrollbarPosition;
    }
    ListenerInfo getListenerInfo() {
        if (mListenerInfo != null) {
            return mListenerInfo;
        }
        mListenerInfo = new ListenerInfo();
        return mListenerInfo;
    }
    /**
     * Register a callback to be invoked when focus of this view changed.
     *
     * @param l The callback that will run.
     */
    public void setOnFocusChangeListener(OnFocusChangeListener l) {
        mOnFocusChangeListener = l;
        getListenerInfo().mOnFocusChangeListener = l;
    }
    /**
@@ -3362,11 +3374,12 @@ public class View implements Drawable.Callback, Drawable.Callback2, KeyEvent.Cal
     * @param listener The listener that will be called when layout bounds change.
     */
    public void addOnLayoutChangeListener(OnLayoutChangeListener listener) {
        if (mOnLayoutChangeListeners == null) {
            mOnLayoutChangeListeners = new ArrayList<OnLayoutChangeListener>();
        ListenerInfo li = getListenerInfo();
        if (li.mOnLayoutChangeListeners == null) {
            li.mOnLayoutChangeListeners = new ArrayList<OnLayoutChangeListener>();
        }
        if (!mOnLayoutChangeListeners.contains(listener)) {
            mOnLayoutChangeListeners.add(listener);
        if (!li.mOnLayoutChangeListeners.contains(listener)) {
            li.mOnLayoutChangeListeners.add(listener);
        }
    }
@@ -3376,10 +3389,11 @@ public class View implements Drawable.Callback, Drawable.Callback2, KeyEvent.Cal
     * @param listener The listener for layout bounds change.
     */
    public void removeOnLayoutChangeListener(OnLayoutChangeListener listener) {
        if (mOnLayoutChangeListeners == null) {
        ListenerInfo li = mListenerInfo;
        if (li == null || li.mOnLayoutChangeListeners == null) {
            return;
        }
        mOnLayoutChangeListeners.remove(listener);
        li.mOnLayoutChangeListeners.remove(listener);
    }
    /**
@@ -3393,10 +3407,12 @@ public class View implements Drawable.Callback, Drawable.Callback2, KeyEvent.Cal
     * @see #removeOnAttachStateChangeListener(OnAttachStateChangeListener)
     */
    public void addOnAttachStateChangeListener(OnAttachStateChangeListener listener) {
        if (mOnAttachStateChangeListeners == null) {
            mOnAttachStateChangeListeners = new CopyOnWriteArrayList<OnAttachStateChangeListener>();
        ListenerInfo li = getListenerInfo();
        if (li.mOnAttachStateChangeListeners == null) {
            li.mOnAttachStateChangeListeners
                    = new CopyOnWriteArrayList<OnAttachStateChangeListener>();
        }
        mOnAttachStateChangeListeners.add(listener);
        li.mOnAttachStateChangeListeners.add(listener);
    }
    /**
@@ -3407,10 +3423,11 @@ public class View implements Drawable.Callback, Drawable.Callback2, KeyEvent.Cal
     * @see #addOnAttachStateChangeListener(OnAttachStateChangeListener)
     */
    public void removeOnAttachStateChangeListener(OnAttachStateChangeListener listener) {
        if (mOnAttachStateChangeListeners == null) {
        ListenerInfo li = mListenerInfo;
        if (li == null || li.mOnAttachStateChangeListeners == null) {
            return;
        }
        mOnAttachStateChangeListeners.remove(listener);
        li.mOnAttachStateChangeListeners.remove(listener);
    }
    /**
@@ -3419,7 +3436,8 @@ public class View implements Drawable.Callback, Drawable.Callback2, KeyEvent.Cal
     * @return The callback, or null if one is not registered.
     */
    public OnFocusChangeListener getOnFocusChangeListener() {
        return mOnFocusChangeListener;
        ListenerInfo li = mListenerInfo;
        return li != null ? li.mOnFocusChangeListener : null;
    }
    /**
@@ -3434,7 +3452,16 @@ public class View implements Drawable.Callback, Drawable.Callback2, KeyEvent.Cal
        if (!isClickable()) {
            setClickable(true);
        }
        mOnClickListener = l;
        getListenerInfo().mOnClickListener = l;
    }
    /**
     * Return whether this view has an attached OnClickListener.  Returns
     * true if there is a listener, false if there is none.
     */
    public boolean hasOnClickListeners() {
        ListenerInfo li = mListenerInfo;
        return (li != null && li.mOnClickListener != null);
    }
    /**
@@ -3449,7 +3476,7 @@ public class View implements Drawable.Callback, Drawable.Callback2, KeyEvent.Cal
        if (!isLongClickable()) {
            setLongClickable(true);
        }
        mOnLongClickListener = l;
        getListenerInfo().mOnLongClickListener = l;
    }
    /**
@@ -3463,11 +3490,13 @@ public class View implements Drawable.Callback, Drawable.Callback2, KeyEvent.Cal
        if (!isLongClickable()) {
            setLongClickable(true);
        }
        mOnCreateContextMenuListener = l;
        getListenerInfo().mOnCreateContextMenuListener = l;
    }
    /**
     * Call this view's OnClickListener, if it is defined.
     * Call this view's OnClickListener, if it is defined.  Performs all normal
     * actions associated with clicking: reporting accessibility event, playing
     * a sound, etc.
     *
     * @return True there was an assigned OnClickListener that was called, false
     *         otherwise is returned.
@@ -3475,15 +3504,33 @@ public class View implements Drawable.Callback, Drawable.Callback2, KeyEvent.Cal
    public boolean performClick() {
        sendAccessibilityEvent(AccessibilityEvent.TYPE_VIEW_CLICKED);
        if (mOnClickListener != null) {
        ListenerInfo li = mListenerInfo;
        if (li != null && li.mOnClickListener != null) {
            playSoundEffect(SoundEffectConstants.CLICK);
            mOnClickListener.onClick(this);
            li.mOnClickListener.onClick(this);
            return true;
        }
        return false;
    }
    /**
     * Directly call any attached OnClickListener.  Unlike {@link #performClick()},
     * this only calls the listener, and does not do any associated clicking
     * actions like reporting an accessibility event.
     *
     * @return True there was an assigned OnClickListener that was called, false
     *         otherwise is returned.
     */
    public boolean callOnClick() {
        ListenerInfo li = mListenerInfo;
        if (li != null && li.mOnClickListener != null) {
            li.mOnClickListener.onClick(this);
            return true;
        }
        return false;
    }
    /**
     * Call this view's OnLongClickListener, if it is defined. Invokes the context menu if the
     * OnLongClickListener did not consume the event.
@@ -3494,8 +3541,9 @@ public class View implements Drawable.Callback, Drawable.Callback2, KeyEvent.Cal
        sendAccessibilityEvent(AccessibilityEvent.TYPE_VIEW_LONG_CLICKED);
        boolean handled = false;
        if (mOnLongClickListener != null) {
            handled = mOnLongClickListener.onLongClick(View.this);
        ListenerInfo li = mListenerInfo;
        if (li != null && li.mOnLongClickListener != null) {
            handled = li.mOnLongClickListener.onLongClick(View.this);
        }
        if (!handled) {
            handled = showContextMenu();
@@ -3563,7 +3611,7 @@ public class View implements Drawable.Callback, Drawable.Callback2, KeyEvent.Cal
     * @param l the key listener to attach to this view
     */
    public void setOnKeyListener(OnKeyListener l) {
        mOnKeyListener = l;
        getListenerInfo().mOnKeyListener = l;
    }
    /**
@@ -3571,7 +3619,7 @@ public class View implements Drawable.Callback, Drawable.Callback2, KeyEvent.Cal
     * @param l the touch listener to attach to this view
     */
    public void setOnTouchListener(OnTouchListener l) {
        mOnTouchListener = l;
        getListenerInfo().mOnTouchListener = l;
    }
    /**
@@ -3579,7 +3627,7 @@ public class View implements Drawable.Callback, Drawable.Callback2, KeyEvent.Cal
     * @param l the generic motion listener to attach to this view
     */
    public void setOnGenericMotionListener(OnGenericMotionListener l) {
        mOnGenericMotionListener = l;
        getListenerInfo().mOnGenericMotionListener = l;
    }
    /**
@@ -3587,7 +3635,7 @@ public class View implements Drawable.Callback, Drawable.Callback2, KeyEvent.Cal
     * @param l the hover listener to attach to this view
     */
    public void setOnHoverListener(OnHoverListener l) {
        mOnHoverListener = l;
        getListenerInfo().mOnHoverListener = l;
    }
    /**
@@ -3598,7 +3646,7 @@ public class View implements Drawable.Callback, Drawable.Callback2, KeyEvent.Cal
     * @param l An implementation of {@link android.view.View.OnDragListener}.
     */
    public void setOnDragListener(OnDragListener l) {
        mOnDragListener = l;
        getListenerInfo().mOnDragListener = l;
    }
    /**
@@ -3804,8 +3852,9 @@ public class View implements Drawable.Callback, Drawable.Callback2, KeyEvent.Cal
        }
        invalidate(true);
        if (mOnFocusChangeListener != null) {
            mOnFocusChangeListener.onFocusChange(this, gainFocus);
        ListenerInfo li = mListenerInfo;
        if (li != null && li.mOnFocusChangeListener != null) {
            li.mOnFocusChangeListener.onFocusChange(this, gainFocus);
        }
        if (mAttachInfo != null) {
@@ -5439,8 +5488,9 @@ public class View implements Drawable.Callback, Drawable.Callback2, KeyEvent.Cal
        // Give any attached key listener a first crack at the event.
        //noinspection SimplifiableIfStatement
        if (mOnKeyListener != null && (mViewFlags & ENABLED_MASK) == ENABLED
                && mOnKeyListener.onKey(this, event.getKeyCode(), event)) {
        ListenerInfo li = mListenerInfo;
        if (li != null && li.mOnKeyListener != null && (mViewFlags & ENABLED_MASK) == ENABLED
                && li.mOnKeyListener.onKey(this, event.getKeyCode(), event)) {
            return true;
        }
@@ -5479,8 +5529,9 @@ public class View implements Drawable.Callback, Drawable.Callback2, KeyEvent.Cal
        if (onFilterTouchEventForSecurity(event)) {
            //noinspection SimplifiableIfStatement
            if (mOnTouchListener != null && (mViewFlags & ENABLED_MASK) == ENABLED &&
                    mOnTouchListener.onTouch(this, event)) {
            ListenerInfo li = mListenerInfo;
            if (li != null && li.mOnTouchListener != null && (mViewFlags & ENABLED_MASK) == ENABLED
                    && li.mOnTouchListener.onTouch(this, event)) {
                return true;
            }
@@ -5572,8 +5623,10 @@ public class View implements Drawable.Callback, Drawable.Callback2, KeyEvent.Cal
    private boolean dispatchGenericMotionEventInternal(MotionEvent event) {
        //noinspection SimplifiableIfStatement
        if (mOnGenericMotionListener != null && (mViewFlags & ENABLED_MASK) == ENABLED
                && mOnGenericMotionListener.onGenericMotion(this, event)) {
        ListenerInfo li = mListenerInfo;
        if (li != null && li.mOnGenericMotionListener != null
                && (mViewFlags & ENABLED_MASK) == ENABLED
                && li.mOnGenericMotionListener.onGenericMotion(this, event)) {
            return true;
        }
@@ -5599,8 +5652,10 @@ public class View implements Drawable.Callback, Drawable.Callback2, KeyEvent.Cal
     */
    protected boolean dispatchHoverEvent(MotionEvent event) {
        //noinspection SimplifiableIfStatement
        if (mOnHoverListener != null && (mViewFlags & ENABLED_MASK) == ENABLED
                && mOnHoverListener.onHover(this, event)) {
        ListenerInfo li = mListenerInfo;
        if (li != null && li.mOnHoverListener != null
                && (mViewFlags & ENABLED_MASK) == ENABLED
                && li.mOnHoverListener.onHover(this, event)) {
            return true;
        }
@@ -5884,7 +5939,8 @@ public class View implements Drawable.Callback, Drawable.Callback2, KeyEvent.Cal
                mAttachInfo.mKeepScreenOn = true;
            }
            mAttachInfo.mSystemUiVisibility |= mSystemUiVisibility;
            if (mOnSystemUiVisibilityChangeListener != null) {
            ListenerInfo li = mListenerInfo;
            if (li != null && li.mOnSystemUiVisibilityChangeListener != null) {
                mAttachInfo.mHasSystemUiListeners = true;
            }
        }
@@ -6118,8 +6174,9 @@ public class View implements Drawable.Callback, Drawable.Callback2, KeyEvent.Cal
        ((MenuBuilder)menu).setCurrentMenuInfo(menuInfo);
        onCreateContextMenu(menu);
        if (mOnCreateContextMenuListener != null) {
            mOnCreateContextMenuListener.onCreateContextMenu(menu, this, menuInfo);
        ListenerInfo li = mListenerInfo;
        if (li != null && li.mOnCreateContextMenuListener != null) {
            li.mOnCreateContextMenuListener.onCreateContextMenu(menu, this, menuInfo);
        }
        // Clear the extra information so subsequent items that aren't mine don't
@@ -9723,8 +9780,9 @@ public class View implements Drawable.Callback, Drawable.Callback2, KeyEvent.Cal
        performCollectViewAttributes(visibility);
        onAttachedToWindow();
        ListenerInfo li = mListenerInfo;
        final CopyOnWriteArrayList<OnAttachStateChangeListener> listeners =
                mOnAttachStateChangeListeners;
                li != null ? li.mOnAttachStateChangeListeners : null;
        if (listeners != null && listeners.size() > 0) {
            // NOTE: because of the use of CopyOnWriteArrayList, we *must* use an iterator to
            // perform the dispatching. The iterator is a safe guard against listeners that
@@ -9756,8 +9814,9 @@ public class View implements Drawable.Callback, Drawable.Callback2, KeyEvent.Cal
        onDetachedFromWindow();
        ListenerInfo li = mListenerInfo;
        final CopyOnWriteArrayList<OnAttachStateChangeListener> listeners =
                mOnAttachStateChangeListeners;
                li != null ? li.mOnAttachStateChangeListeners : null;
        if (listeners != null && listeners.size() > 0) {
            // NOTE: because of the use of CopyOnWriteArrayList, we *must* use an iterator to
            // perform the dispatching. The iterator is a safe guard against listeners that
@@ -11193,9 +11252,10 @@ public class View implements Drawable.Callback, Drawable.Callback2, KeyEvent.Cal
            onLayout(changed, l, t, r, b);
            mPrivateFlags &= ~LAYOUT_REQUIRED;
            if (mOnLayoutChangeListeners != null) {
            ListenerInfo li = mListenerInfo;
            if (li != null && li.mOnLayoutChangeListeners != null) {
                ArrayList<OnLayoutChangeListener> listenersCopy =
                        (ArrayList<OnLayoutChangeListener>) mOnLayoutChangeListeners.clone();
                        (ArrayList<OnLayoutChangeListener>)li.mOnLayoutChangeListeners.clone();
                int numListeners = listenersCopy.size();
                for (int i = 0; i < numListeners; ++i) {
                    listenersCopy.get(i).onLayoutChange(this, l, t, r, b, oldL, oldT, oldR, oldB);
@@ -13065,7 +13125,7 @@ public class View implements Drawable.Callback, Drawable.Callback2, KeyEvent.Cal
     * @param l  The {@link OnSystemUiVisibilityChangeListener} to receive callbacks.
     */
    public void setOnSystemUiVisibilityChangeListener(OnSystemUiVisibilityChangeListener l) {
        mOnSystemUiVisibilityChangeListener = l;
        getListenerInfo().mOnSystemUiVisibilityChangeListener = l;
        if (mParent != null && mAttachInfo != null && !mAttachInfo.mRecomputeGlobalAttributes) {
            mParent.recomputeViewAttributes(this);
        }
@@ -13076,8 +13136,9 @@ public class View implements Drawable.Callback, Drawable.Callback2, KeyEvent.Cal
     * the view hierarchy.
     */
    public void dispatchSystemUiVisibilityChanged(int visibility) {
        if (mOnSystemUiVisibilityChangeListener != null) {
            mOnSystemUiVisibilityChangeListener.onSystemUiVisibilityChange(
        ListenerInfo li = mListenerInfo;
        if (li != null && li.mOnSystemUiVisibilityChangeListener != null) {
            li.mOnSystemUiVisibilityChangeListener.onSystemUiVisibilityChange(
                    visibility & PUBLIC_STATUS_BAR_VISIBILITY_MASK);
        }
    }
@@ -13349,8 +13410,9 @@ public class View implements Drawable.Callback, Drawable.Callback2, KeyEvent.Cal
     */
    public boolean dispatchDragEvent(DragEvent event) {
        //noinspection SimplifiableIfStatement
        if (mOnDragListener != null && (mViewFlags & ENABLED_MASK) == ENABLED
                && mOnDragListener.onDrag(this, event)) {
        ListenerInfo li = mListenerInfo;
        if (li != null && li.mOnDragListener != null && (mViewFlags & ENABLED_MASK) == ENABLED
                && li.mOnDragListener.onDrag(this, event)) {
            return true;
        }
        return onDragEvent(event);
+6 −3
Original line number Diff line number Diff line
@@ -352,7 +352,7 @@ public abstract class ViewGroup extends View implements ViewParent, ViewManager
    private static final int ARRAY_CAPACITY_INCREMENT = 12;

    // Used to draw cached views
    private final Paint mCachePaint = new Paint();
    private Paint mCachePaint;

    // Used to animate add/remove changes in layout
    private LayoutTransition mTransition;
@@ -405,8 +405,6 @@ public abstract class ViewGroup extends View implements ViewParent, ViewManager
        mChildren = new View[ARRAY_INITIAL_CAPACITY];
        mChildrenCount = 0;

        mCachePaint.setDither(false);

        mPersistentDrawingCache = PERSISTENT_SCROLLING_CACHE;
    }

@@ -2909,6 +2907,11 @@ public abstract class ViewGroup extends View implements ViewParent, ViewManager

            if (layerType == LAYER_TYPE_NONE) {
                cachePaint = mCachePaint;
                if (cachePaint == null) {
                    cachePaint = new Paint();
                    cachePaint.setDither(false);
                    mCachePaint = cachePaint;
                }
                if (alpha < 1.0f) {
                    cachePaint.setAlpha((int) (alpha * 255));
                    mGroupFlags |= FLAG_ALPHA_LOWER_THAN_ONE;
+6 −6
Original line number Diff line number Diff line
@@ -271,7 +271,7 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener
    private static final int SIGNED = 2;
    private static final int DECIMAL = 4;

    class Drawables {
    static class Drawables {
        final Rect mCompoundRect = new Rect();
        Drawable mDrawableTop, mDrawableBottom, mDrawableLeft, mDrawableRight,
                mDrawableStart, mDrawableEnd;
@@ -304,7 +304,7 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener

    private int mMarqueeRepeatLimit = 3;

    class InputContentType {
    static class InputContentType {
        int imeOptions = EditorInfo.IME_NULL;
        String privateImeOptions;
        CharSequence imeActionLabel;
@@ -315,7 +315,7 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener
    }
    InputContentType mInputContentType;

    class InputMethodState {
    static class InputMethodState {
        Rect mCursorRectInWindow = new Rect();
        RectF mTmpRectF = new RectF();
        float[] mTmpOffset = new float[2];
@@ -5363,7 +5363,7 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener
                    // don't let it be inserted into the text.
                    if ((event.getFlags() & KeyEvent.FLAG_EDITOR_ACTION) != 0
                            || shouldAdvanceFocusOnEnter()) {
                        if (mOnClickListener != null) {
                        if (hasOnClickListeners()) {
                            return 0;
                        }
                        return -1;
@@ -5497,7 +5497,7 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener
                     * call performClick(), but that won't do anything in
                     * this case.)
                     */
                    if (mOnClickListener == null) {
                    if (hasOnClickListeners()) {
                        if (mMovement != null && mText instanceof Editable
                                && mLayout != null && onCheckIsTextEditor()) {
                            InputMethodManager imm = InputMethodManager.peekInstance();
@@ -5535,7 +5535,7 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener
                         * call performClick(), but that won't do anything in
                         * this case.)
                         */
                        if (mOnClickListener == null) {
                        if (hasOnClickListeners()) {
                            View v = focusSearch(FOCUS_DOWN);

                            if (v != null) {
Loading