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

Commit c840a133 authored by Romain Guy's avatar Romain Guy Committed by Android (Google) Code Review
Browse files

Merge "Remove unnecessary allocations"

parents 0d6123e4 f6991305
Loading
Loading
Loading
Loading
+16 −21
Original line number Original line Diff line number Diff line
@@ -4575,11 +4575,8 @@ public class View implements Drawable.Callback, KeyEvent.Callback,
    }
    }
    boolean rootViewRequestFocus() {
    boolean rootViewRequestFocus() {
        View root = getRootView();
        final View root = getRootView();
        if (root != null) {
        return root != null && root.requestFocus();
            return root.requestFocus();
        }
        return false;
    }
    }
    /**
    /**
@@ -13482,7 +13479,8 @@ public class View implements Drawable.Callback, KeyEvent.Callback,
            onAnimationStart();
            onAnimationStart();
        }
        }
        boolean more = a.getTransformation(drawingTime, parent.mChildTransformation, 1f);
        final Transformation t = parent.getChildTransformation();
        boolean more = a.getTransformation(drawingTime, t, 1f);
        if (scalingRequired && mAttachInfo.mApplicationScale != 1f) {
        if (scalingRequired && mAttachInfo.mApplicationScale != 1f) {
            if (parent.mInvalidationTransformation == null) {
            if (parent.mInvalidationTransformation == null) {
                parent.mInvalidationTransformation = new Transformation();
                parent.mInvalidationTransformation = new Transformation();
@@ -13490,7 +13488,7 @@ public class View implements Drawable.Callback, KeyEvent.Callback,
            invalidationTransform = parent.mInvalidationTransformation;
            invalidationTransform = parent.mInvalidationTransformation;
            a.getTransformation(drawingTime, invalidationTransform, 1f);
            a.getTransformation(drawingTime, invalidationTransform, 1f);
        } else {
        } else {
            invalidationTransform = parent.mChildTransformation;
            invalidationTransform = t;
        }
        }
        if (more) {
        if (more) {
@@ -13543,17 +13541,15 @@ public class View implements Drawable.Callback, KeyEvent.Callback,
            if (mParent instanceof ViewGroup && (((ViewGroup) mParent).mGroupFlags &
            if (mParent instanceof ViewGroup && (((ViewGroup) mParent).mGroupFlags &
                    ViewGroup.FLAG_SUPPORT_STATIC_TRANSFORMATIONS) != 0) {
                    ViewGroup.FLAG_SUPPORT_STATIC_TRANSFORMATIONS) != 0) {
                ViewGroup parentVG = (ViewGroup) mParent;
                ViewGroup parentVG = (ViewGroup) mParent;
                final boolean hasTransform =
                final Transformation t = parentVG.getChildTransformation();
                        parentVG.getChildStaticTransformation(this, parentVG.mChildTransformation);
                if (parentVG.getChildStaticTransformation(this, t)) {
                if (hasTransform) {
                    final int transformType = t.getTransformationType();
                    Transformation transform = parentVG.mChildTransformation;
                    final int transformType = parentVG.mChildTransformation.getTransformationType();
                    if (transformType != Transformation.TYPE_IDENTITY) {
                    if (transformType != Transformation.TYPE_IDENTITY) {
                        if ((transformType & Transformation.TYPE_ALPHA) != 0) {
                        if ((transformType & Transformation.TYPE_ALPHA) != 0) {
                            alpha = transform.getAlpha();
                            alpha = t.getAlpha();
                        }
                        }
                        if ((transformType & Transformation.TYPE_MATRIX) != 0) {
                        if ((transformType & Transformation.TYPE_MATRIX) != 0) {
                            displayList.setMatrix(transform.getMatrix());
                            displayList.setMatrix(t.getMatrix());
                        }
                        }
                    }
                    }
                }
                }
@@ -13598,7 +13594,7 @@ public class View implements Drawable.Callback, KeyEvent.Callback,
        final int flags = parent.mGroupFlags;
        final int flags = parent.mGroupFlags;
        if ((flags & ViewGroup.FLAG_CLEAR_TRANSFORMATION) == ViewGroup.FLAG_CLEAR_TRANSFORMATION) {
        if ((flags & ViewGroup.FLAG_CLEAR_TRANSFORMATION) == ViewGroup.FLAG_CLEAR_TRANSFORMATION) {
            parent.mChildTransformation.clear();
            parent.getChildTransformation().clear();
            parent.mGroupFlags &= ~ViewGroup.FLAG_CLEAR_TRANSFORMATION;
            parent.mGroupFlags &= ~ViewGroup.FLAG_CLEAR_TRANSFORMATION;
        }
        }
@@ -13626,7 +13622,7 @@ public class View implements Drawable.Callback, KeyEvent.Callback,
            if (concatMatrix) {
            if (concatMatrix) {
                mPrivateFlags3 |= PFLAG3_VIEW_IS_ANIMATING_TRANSFORM;
                mPrivateFlags3 |= PFLAG3_VIEW_IS_ANIMATING_TRANSFORM;
            }
            }
            transformToApply = parent.mChildTransformation;
            transformToApply = parent.getChildTransformation();
        } else {
        } else {
            if ((mPrivateFlags3 & PFLAG3_VIEW_IS_ANIMATING_TRANSFORM) ==
            if ((mPrivateFlags3 & PFLAG3_VIEW_IS_ANIMATING_TRANSFORM) ==
                    PFLAG3_VIEW_IS_ANIMATING_TRANSFORM && mDisplayList != null) {
                    PFLAG3_VIEW_IS_ANIMATING_TRANSFORM && mDisplayList != null) {
@@ -13636,12 +13632,11 @@ public class View implements Drawable.Callback, KeyEvent.Callback,
            }
            }
            if (!useDisplayListProperties &&
            if (!useDisplayListProperties &&
                    (flags & ViewGroup.FLAG_SUPPORT_STATIC_TRANSFORMATIONS) != 0) {
                    (flags & ViewGroup.FLAG_SUPPORT_STATIC_TRANSFORMATIONS) != 0) {
                final boolean hasTransform =
                final Transformation t = parent.getChildTransformation();
                        parent.getChildStaticTransformation(this, parent.mChildTransformation);
                final boolean hasTransform = parent.getChildStaticTransformation(this, t);
                if (hasTransform) {
                if (hasTransform) {
                    final int transformType = parent.mChildTransformation.getTransformationType();
                    final int transformType = t.getTransformationType();
                    transformToApply = transformType != Transformation.TYPE_IDENTITY ?
                    transformToApply = transformType != Transformation.TYPE_IDENTITY ? t : null;
                            parent.mChildTransformation : null;
                    concatMatrix = (transformType & Transformation.TYPE_MATRIX) != 0;
                    concatMatrix = (transformType & Transformation.TYPE_MATRIX) != 0;
                }
                }
            }
            }
+8 −1
Original line number Original line Diff line number Diff line
@@ -128,7 +128,7 @@ public abstract class ViewGroup extends View implements ViewParent, ViewManager
     * A Transformation used when drawing children, to
     * A Transformation used when drawing children, to
     * apply on the child being drawn.
     * apply on the child being drawn.
     */
     */
    final Transformation mChildTransformation = new Transformation();
    private Transformation mChildTransformation;


    /**
    /**
     * Used to track the current invalidation region.
     * Used to track the current invalidation region.
@@ -3211,6 +3211,13 @@ public abstract class ViewGroup extends View implements ViewParent, ViewManager
        return false;
        return false;
    }
    }


    Transformation getChildTransformation() {
        if (mChildTransformation == null) {
            mChildTransformation = new Transformation();
        }
        return mChildTransformation;
    }

    /**
    /**
     * {@hide}
     * {@hide}
     */
     */
+151 −57
Original line number Original line Diff line number Diff line
@@ -25,11 +25,11 @@ import android.graphics.drawable.Drawable;
import android.graphics.drawable.TransitionDrawable;
import android.graphics.drawable.TransitionDrawable;
import android.os.Bundle;
import android.os.Bundle;
import android.os.Debug;
import android.os.Debug;
import android.os.Handler;
import android.os.Parcel;
import android.os.Parcel;
import android.os.Parcelable;
import android.os.Parcelable;
import android.os.StrictMode;
import android.os.StrictMode;
import android.text.Editable;
import android.text.Editable;
import android.text.InputType;
import android.text.TextUtils;
import android.text.TextUtils;
import android.text.TextWatcher;
import android.text.TextWatcher;
import android.util.AttributeSet;
import android.util.AttributeSet;
@@ -61,9 +61,12 @@ import android.view.accessibility.AccessibilityNodeInfo;
import android.view.animation.Interpolator;
import android.view.animation.Interpolator;
import android.view.animation.LinearInterpolator;
import android.view.animation.LinearInterpolator;
import android.view.inputmethod.BaseInputConnection;
import android.view.inputmethod.BaseInputConnection;
import android.view.inputmethod.CompletionInfo;
import android.view.inputmethod.CorrectionInfo;
import android.view.inputmethod.EditorInfo;
import android.view.inputmethod.EditorInfo;
import android.view.inputmethod.ExtractedText;
import android.view.inputmethod.ExtractedTextRequest;
import android.view.inputmethod.InputConnection;
import android.view.inputmethod.InputConnection;
import android.view.inputmethod.InputConnectionWrapper;
import android.view.inputmethod.InputMethodManager;
import android.view.inputmethod.InputMethodManager;
import android.widget.RemoteViews.OnClickHandler;
import android.widget.RemoteViews.OnClickHandler;


@@ -5613,14 +5616,32 @@ public abstract class AbsListView extends AdapterView<ListAdapter> implements Te
    @Override
    @Override
    public InputConnection onCreateInputConnection(EditorInfo outAttrs) {
    public InputConnection onCreateInputConnection(EditorInfo outAttrs) {
        if (isTextFilterEnabled()) {
        if (isTextFilterEnabled()) {
            // XXX we need to have the text filter created, so we can get an
            // InputConnection to proxy to.  Unfortunately this means we pretty
            // much need to make it as soon as a list view gets focus.
            createTextFilter(false);
            if (mPublicInputConnection == null) {
            if (mPublicInputConnection == null) {
                mDefInputConnection = new BaseInputConnection(this, false);
                mDefInputConnection = new BaseInputConnection(this, false);
                mPublicInputConnection = new InputConnectionWrapper(
                mPublicInputConnection = new InputConnectionWrapper(outAttrs);
                        mTextFilter.onCreateInputConnection(outAttrs), true) {
            }
            outAttrs.inputType = EditorInfo.TYPE_CLASS_TEXT | EditorInfo.TYPE_TEXT_VARIATION_FILTER;
            outAttrs.imeOptions = EditorInfo.IME_ACTION_DONE;
            return mPublicInputConnection;
        }
        return null;
    }

    private class InputConnectionWrapper implements InputConnection {
        private final EditorInfo mOutAttrs;
        private InputConnection mTarget;

        public InputConnectionWrapper(EditorInfo outAttrs) {
            mOutAttrs = outAttrs;
        }

        private InputConnection getTarget() {
            if (mTarget == null) {
                mTarget = getTextFilterInput().onCreateInputConnection(mOutAttrs);
            }
            return mTarget;
        }

        @Override
        @Override
        public boolean reportFullscreenMode(boolean enabled) {
        public boolean reportFullscreenMode(boolean enabled) {
            // Use our own input connection, since it is
            // Use our own input connection, since it is
@@ -5634,8 +5655,7 @@ public abstract class AbsListView extends AdapterView<ListAdapter> implements Te
            // the one that does this.
            // the one that does this.
            if (editorAction == EditorInfo.IME_ACTION_DONE) {
            if (editorAction == EditorInfo.IME_ACTION_DONE) {
                InputMethodManager imm = (InputMethodManager)
                InputMethodManager imm = (InputMethodManager)
                                    getContext().getSystemService(
                        getContext().getSystemService(Context.INPUT_METHOD_SERVICE);
                                            Context.INPUT_METHOD_SERVICE);
                if (imm != null) {
                if (imm != null) {
                    imm.hideSoftInputFromWindow(getWindowToken(), 0);
                    imm.hideSoftInputFromWindow(getWindowToken(), 0);
                }
                }
@@ -5651,14 +5671,82 @@ public abstract class AbsListView extends AdapterView<ListAdapter> implements Te
            // no ViewAncestor to dispatch events with.
            // no ViewAncestor to dispatch events with.
            return mDefInputConnection.sendKeyEvent(event);
            return mDefInputConnection.sendKeyEvent(event);
        }
        }
                };

        public CharSequence getTextBeforeCursor(int n, int flags) {
            if (mTarget == null) return "";
            return mTarget.getTextBeforeCursor(n, flags);
        }
        }
            outAttrs.inputType = EditorInfo.TYPE_CLASS_TEXT

                    | EditorInfo.TYPE_TEXT_VARIATION_FILTER;
        public CharSequence getTextAfterCursor(int n, int flags) {
            outAttrs.imeOptions = EditorInfo.IME_ACTION_DONE;
            if (mTarget == null) return "";
            return mPublicInputConnection;
            return mTarget.getTextAfterCursor(n, flags);
        }

        public CharSequence getSelectedText(int flags) {
            if (mTarget == null) return "";
            return mTarget.getSelectedText(flags);
        }

        public int getCursorCapsMode(int reqModes) {
            if (mTarget == null) return InputType.TYPE_TEXT_FLAG_CAP_SENTENCES;
            return mTarget.getCursorCapsMode(reqModes);
        }

        public ExtractedText getExtractedText(ExtractedTextRequest request, int flags) {
            return getTarget().getExtractedText(request, flags);
        }

        public boolean deleteSurroundingText(int beforeLength, int afterLength) {
            return getTarget().deleteSurroundingText(beforeLength, afterLength);
        }

        public boolean setComposingText(CharSequence text, int newCursorPosition) {
            return getTarget().setComposingText(text, newCursorPosition);
        }

        public boolean setComposingRegion(int start, int end) {
            return getTarget().setComposingRegion(start, end);
        }

        public boolean finishComposingText() {
            return mTarget == null || mTarget.finishComposingText();
        }

        public boolean commitText(CharSequence text, int newCursorPosition) {
            return getTarget().commitText(text, newCursorPosition);
        }

        public boolean commitCompletion(CompletionInfo text) {
            return getTarget().commitCompletion(text);
        }

        public boolean commitCorrection(CorrectionInfo correctionInfo) {
            return getTarget().commitCorrection(correctionInfo);
        }

        public boolean setSelection(int start, int end) {
            return getTarget().setSelection(start, end);
        }

        public boolean performContextMenuAction(int id) {
            return getTarget().performContextMenuAction(id);
        }

        public boolean beginBatchEdit() {
            return getTarget().beginBatchEdit();
        }

        public boolean endBatchEdit() {
            return getTarget().endBatchEdit();
        }

        public boolean clearMetaKeyStates(int states) {
            return getTarget().clearMetaKeyStates(states);
        }

        public boolean performPrivateCommand(String action, Bundle data) {
            return getTarget().performPrivateCommand(action, data);
        }
        }
        return null;
    }
    }


    /**
    /**
@@ -5677,23 +5765,11 @@ public abstract class AbsListView extends AdapterView<ListAdapter> implements Te
     */
     */
    private void createTextFilter(boolean animateEntrance) {
    private void createTextFilter(boolean animateEntrance) {
        if (mPopup == null) {
        if (mPopup == null) {
            Context c = getContext();
            PopupWindow p = new PopupWindow(getContext());
            PopupWindow p = new PopupWindow(c);
            LayoutInflater layoutInflater = (LayoutInflater)
                    c.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
            mTextFilter = (EditText) layoutInflater.inflate(
                    com.android.internal.R.layout.typing_filter, null);
            // For some reason setting this as the "real" input type changes
            // the text view in some way that it doesn't work, and I don't
            // want to figure out why this is.
            mTextFilter.setRawInputType(EditorInfo.TYPE_CLASS_TEXT
                    | EditorInfo.TYPE_TEXT_VARIATION_FILTER);
            mTextFilter.setImeOptions(EditorInfo.IME_FLAG_NO_EXTRACT_UI);
            mTextFilter.addTextChangedListener(this);
            p.setFocusable(false);
            p.setFocusable(false);
            p.setTouchable(false);
            p.setTouchable(false);
            p.setInputMethodMode(PopupWindow.INPUT_METHOD_NOT_NEEDED);
            p.setInputMethodMode(PopupWindow.INPUT_METHOD_NOT_NEEDED);
            p.setContentView(mTextFilter);
            p.setContentView(getTextFilterInput());
            p.setWidth(LayoutParams.WRAP_CONTENT);
            p.setWidth(LayoutParams.WRAP_CONTENT);
            p.setHeight(LayoutParams.WRAP_CONTENT);
            p.setHeight(LayoutParams.WRAP_CONTENT);
            p.setBackgroundDrawable(null);
            p.setBackgroundDrawable(null);
@@ -5708,12 +5784,28 @@ public abstract class AbsListView extends AdapterView<ListAdapter> implements Te
        }
        }
    }
    }


    private EditText getTextFilterInput() {
        if (mTextFilter == null) {
            final LayoutInflater layoutInflater = LayoutInflater.from(getContext());
            mTextFilter = (EditText) layoutInflater.inflate(
                    com.android.internal.R.layout.typing_filter, null);
            // For some reason setting this as the "real" input type changes
            // the text view in some way that it doesn't work, and I don't
            // want to figure out why this is.
            mTextFilter.setRawInputType(EditorInfo.TYPE_CLASS_TEXT
                    | EditorInfo.TYPE_TEXT_VARIATION_FILTER);
            mTextFilter.setImeOptions(EditorInfo.IME_FLAG_NO_EXTRACT_UI);
            mTextFilter.addTextChangedListener(this);
        }
        return mTextFilter;
    }

    /**
    /**
     * Clear the text filter.
     * Clear the text filter.
     */
     */
    public void clearTextFilter() {
    public void clearTextFilter() {
        if (mFiltered) {
        if (mFiltered) {
            mTextFilter.setText("");
            getTextFilterInput().setText("");
            mFiltered = false;
            mFiltered = false;
            if (mPopup != null && mPopup.isShowing()) {
            if (mPopup != null && mPopup.isShowing()) {
                dismissPopup();
                dismissPopup();
@@ -5759,7 +5851,8 @@ public abstract class AbsListView extends AdapterView<ListAdapter> implements Te
     */
     */
    @Override
    @Override
    public void onTextChanged(CharSequence s, int start, int before, int count) {
    public void onTextChanged(CharSequence s, int start, int before, int count) {
        if (mPopup != null && isTextFilterEnabled()) {
        if (isTextFilterEnabled()) {
            createTextFilter(true);
            int length = s.length();
            int length = s.length();
            boolean showing = mPopup.isShowing();
            boolean showing = mPopup.isShowing();
            if (!showing && length > 0) {
            if (!showing && length > 0) {
@@ -6331,6 +6424,7 @@ public abstract class AbsListView extends AdapterView<ListAdapter> implements Te
            }
            }
            mFirstActivePosition = firstActivePosition;
            mFirstActivePosition = firstActivePosition;


            //noinspection MismatchedReadAndWriteOfArray
            final View[] activeViews = mActiveViews;
            final View[] activeViews = mActiveViews;
            for (int i = 0; i < childCount; i++) {
            for (int i = 0; i < childCount; i++) {
                View child = getChildAt(i);
                View child = getChildAt(i);
+1 −5
Original line number Original line Diff line number Diff line
@@ -20,19 +20,15 @@ import android.app.Activity;
import android.content.Context;
import android.content.Context;
import android.content.res.Resources;
import android.content.res.Resources;
import android.os.Bundle;
import android.os.Bundle;
import android.os.Environment;
import android.util.DisplayMetrics;
import android.util.DisplayMetrics;
import android.view.ContextMenu;
import android.view.ContextMenu;
import android.view.View;
import android.view.View;
import android.view.ViewDebug;
import android.view.ViewGroup;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.ArrayAdapter;
import android.widget.ListAdapter;
import android.widget.ListAdapter;
import android.widget.ListView;
import android.widget.ListView;
import android.widget.TextView;
import android.widget.TextView;


import java.io.File;

@SuppressWarnings({"UnusedDeclaration"})
@SuppressWarnings({"UnusedDeclaration"})
public class ListActivity extends Activity {
public class ListActivity extends Activity {
    private static final String[] DATA_LIST = {
    private static final String[] DATA_LIST = {
@@ -86,7 +82,7 @@ public class ListActivity extends Activity {


        ListAdapter adapter = new SimpleListAdapter(this);
        ListAdapter adapter = new SimpleListAdapter(this);


        ListView list = (ListView) findViewById(R.id.list);
        final ListView list = (ListView) findViewById(R.id.list);
        list.setAdapter(adapter);
        list.setAdapter(adapter);
        
        
        registerForContextMenu(list);
        registerForContextMenu(list);