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

Commit f3fbea8a authored by The Android Automerger's avatar The Android Automerger
Browse files

Merge branch 'gingerbread' into gingerbread-release

parents ea17de78 29332971
Loading
Loading
Loading
Loading
+24 −0
Original line number Original line Diff line number Diff line
@@ -1354,8 +1354,23 @@ public class Camera {
        /**
        /**
         * Sets the dimensions for preview pictures.
         * Sets the dimensions for preview pictures.
         *
         *
         * The sides of width and height are based on camera orientation. That
         * is, the preview size is the size before it is rotated by display
         * orientation. So applications need to consider the display orientation
         * while setting preview size. For example, suppose the camera supports
         * both 480x320 and 320x480 preview sizes. The application wants a 3:2
         * preview ratio. If the display orientation is set to 0 or 180, preview
         * size should be set to 480x320. If the display orientation is set to
         * 90 or 270, preview size should be set to 320x480. The display
         * orientation should also be considered while setting picture size and
         * thumbnail size.
         *
         * @param width  the width of the pictures, in pixels
         * @param width  the width of the pictures, in pixels
         * @param height the height of the pictures, in pixels
         * @param height the height of the pictures, in pixels
         * @see #setDisplayOrientation(int)
         * @see #getCameraInfo(int, CameraInfo)
         * @see #setPictureSize(int, int)
         * @see #setJpegThumbnailSize(int, int)
         */
         */
        public void setPreviewSize(int width, int height) {
        public void setPreviewSize(int width, int height) {
            String v = Integer.toString(width) + "x" + Integer.toString(height);
            String v = Integer.toString(width) + "x" + Integer.toString(height);
@@ -1389,8 +1404,12 @@ public class Camera {
         * applications set both width and height to 0, EXIF will not contain
         * applications set both width and height to 0, EXIF will not contain
         * thumbnail.
         * thumbnail.
         *
         *
         * Applications need to consider the display orientation. See {@link
         * #setPreviewSize(int,int)} for reference.
         *
         * @param width  the width of the thumbnail, in pixels
         * @param width  the width of the thumbnail, in pixels
         * @param height the height of the thumbnail, in pixels
         * @param height the height of the thumbnail, in pixels
         * @see #setPreviewSize(int,int)
         */
         */
        public void setJpegThumbnailSize(int width, int height) {
        public void setJpegThumbnailSize(int width, int height) {
            set(KEY_JPEG_THUMBNAIL_WIDTH, width);
            set(KEY_JPEG_THUMBNAIL_WIDTH, width);
@@ -1606,8 +1625,13 @@ public class Camera {
        /**
        /**
         * Sets the dimensions for pictures.
         * Sets the dimensions for pictures.
         *
         *
         * Applications need to consider the display orientation. See {@link
         * #setPreviewSize(int,int)} for reference.
         *
         * @param width  the width for pictures, in pixels
         * @param width  the width for pictures, in pixels
         * @param height the height for pictures, in pixels
         * @param height the height for pictures, in pixels
         * @see #setPreviewSize(int,int)
         *
         */
         */
        public void setPictureSize(int width, int height) {
        public void setPictureSize(int width, int height) {
            String v = Integer.toString(width) + "x" + Integer.toString(height);
            String v = Integer.toString(width) + "x" + Integer.toString(height);
+93 −51
Original line number Original line Diff line number Diff line
@@ -287,9 +287,13 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener
    }
    }
    InputMethodState mInputMethodState;
    InputMethodState mInputMethodState;


    private int mTextSelectHandleLeftRes;
    int mTextSelectHandleLeftRes;
    private int mTextSelectHandleRightRes;
    int mTextSelectHandleRightRes;
    private int mTextSelectHandleRes;
    int mTextSelectHandleRes;

    Drawable mSelectHandleLeft;
    Drawable mSelectHandleRight;
    Drawable mSelectHandleCenter;


    /*
    /*
     * Kick-start the font cache for the zygote process (to pay the cost of
     * Kick-start the font cache for the zygote process (to pay the cost of
@@ -7651,26 +7655,74 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener
        private int mPositionY;
        private int mPositionY;
        private CursorController mController;
        private CursorController mController;
        private boolean mIsDragging;
        private boolean mIsDragging;
        private float mOffsetX;
        private float mTouchToWindowOffsetX;
        private float mOffsetY;
        private float mTouchToWindowOffsetY;
        private float mHotspotX;
        private float mHotspotX;
        private float mHotspotY;
        private float mHotspotY;
        private int mHeight;
        private float mTouchOffsetY;
        private int mLastParentX;
        private int mLastParentX;
        private int mLastParentY;
        private int mLastParentY;


        public HandleView(CursorController controller, Drawable handle) {
        public static final int LEFT = 0;
        public static final int CENTER = 1;
        public static final int RIGHT = 2;

        public HandleView(CursorController controller, int pos) {
            super(TextView.this.mContext);
            super(TextView.this.mContext);
            mController = controller;
            mController = controller;
            mDrawable = handle;
            mContainer = new PopupWindow(TextView.this.mContext, null,
            mContainer = new PopupWindow(TextView.this.mContext, null,
                    com.android.internal.R.attr.textSelectHandleWindowStyle);
                    com.android.internal.R.attr.textSelectHandleWindowStyle);
            mContainer.setSplitTouchEnabled(true);
            mContainer.setSplitTouchEnabled(true);
            mContainer.setClippingEnabled(false);
            mContainer.setClippingEnabled(false);


            final int handleWidth = mDrawable.getIntrinsicWidth();
            setOrientation(pos);
        }

        public void setOrientation(int pos) {
            int handleWidth;
            switch (pos) {
            case LEFT: {
                if (mSelectHandleLeft == null) {
                    mSelectHandleLeft = mContext.getResources().getDrawable(
                            mTextSelectHandleLeftRes);
                }
                mDrawable = mSelectHandleLeft;
                handleWidth = mDrawable.getIntrinsicWidth();
                mHotspotX = handleWidth / 4 * 3;
                break;
            }

            case RIGHT: {
                if (mSelectHandleRight == null) {
                    mSelectHandleRight = mContext.getResources().getDrawable(
                            mTextSelectHandleRightRes);
                }
                mDrawable = mSelectHandleRight;
                handleWidth = mDrawable.getIntrinsicWidth();
                mHotspotX = handleWidth / 4;
                break;
            }

            case CENTER:
            default: {
                if (mSelectHandleCenter == null) {
                    mSelectHandleCenter = mContext.getResources().getDrawable(
                            mTextSelectHandleRes);
                }
                mDrawable = mSelectHandleCenter;
                handleWidth = mDrawable.getIntrinsicWidth();
                mHotspotX = handleWidth / 2;
                break;
            }
            }

            final int handleHeight = mDrawable.getIntrinsicHeight();
            final int handleHeight = mDrawable.getIntrinsicHeight();
            mHotspotX = handleWidth * 0.5f;

            mHotspotY = -handleHeight * 0.2f;
            mTouchOffsetY = -handleHeight * 0.3f;
            mHotspotY = 0;
            mHeight = handleHeight;
            invalidate();
        }
        }


        @Override
        @Override
@@ -7735,10 +7787,10 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener
            final int[] coords = mTempCoords;
            final int[] coords = mTempCoords;
            hostView.getLocationInWindow(coords);
            hostView.getLocationInWindow(coords);
            final int posX = coords[0] + mPositionX + (int) mHotspotX;
            final int posX = coords[0] + mPositionX + (int) mHotspotX;
            final int posY = coords[1] + mPositionY;
            final int posY = coords[1] + mPositionY + (int) mHotspotY;


            return posX >= clip.left && posX <= clip.right &&
            return posX >= clip.left && posX <= clip.right &&
                    posY >= clip.top && posY + mHotspotY <= clip.bottom;
                    posY >= clip.top && posY <= clip.bottom;
        }
        }


        private void moveTo(int x, int y) {
        private void moveTo(int x, int y) {
@@ -7761,8 +7813,8 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener
                        TextView.this.getLocationInWindow(coords);
                        TextView.this.getLocationInWindow(coords);
                    }
                    }
                    if (coords[0] != mLastParentX || coords[1] != mLastParentY) {
                    if (coords[0] != mLastParentX || coords[1] != mLastParentY) {
                        mOffsetX += coords[0] - mLastParentX;
                        mTouchToWindowOffsetX += coords[0] - mLastParentX;
                        mOffsetY += coords[1] - mLastParentY;
                        mTouchToWindowOffsetY += coords[1] - mLastParentY;
                        mLastParentX = coords[0];
                        mLastParentX = coords[0];
                        mLastParentY = coords[1];
                        mLastParentY = coords[1];
                    }
                    }
@@ -7791,8 +7843,8 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener
            case MotionEvent.ACTION_DOWN: {
            case MotionEvent.ACTION_DOWN: {
                final float rawX = ev.getRawX();
                final float rawX = ev.getRawX();
                final float rawY = ev.getRawY();
                final float rawY = ev.getRawY();
                mOffsetX = rawX - mPositionX;
                mTouchToWindowOffsetX = rawX - mPositionX;
                mOffsetY = rawY - mPositionY;
                mTouchToWindowOffsetY = rawY - mPositionY;
                final int[] coords = mTempCoords;
                final int[] coords = mTempCoords;
                TextView.this.getLocationInWindow(coords);
                TextView.this.getLocationInWindow(coords);
                mLastParentX = coords[0];
                mLastParentX = coords[0];
@@ -7803,8 +7855,8 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener
            case MotionEvent.ACTION_MOVE: {
            case MotionEvent.ACTION_MOVE: {
                final float rawX = ev.getRawX();
                final float rawX = ev.getRawX();
                final float rawY = ev.getRawY();
                final float rawY = ev.getRawY();
                final float newPosX = rawX - mOffsetX + mHotspotX;
                final float newPosX = rawX - mTouchToWindowOffsetX + mHotspotX;
                final float newPosY = rawY - mOffsetY + mHotspotY;
                final float newPosY = rawY - mTouchToWindowOffsetY + mHotspotY + mTouchOffsetY;


                mController.updatePosition(this, (int) Math.round(newPosX),
                mController.updatePosition(this, (int) Math.round(newPosX),
                        (int) Math.round(newPosY));
                        (int) Math.round(newPosY));
@@ -7830,9 +7882,9 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener
            final int lineBottom = mLayout.getLineBottom(line);
            final int lineBottom = mLayout.getLineBottom(line);


            final Rect bounds = sCursorControllerTempRect;
            final Rect bounds = sCursorControllerTempRect;
            bounds.left = (int) (mLayout.getPrimaryHorizontal(offset) - width / 2.0)
            bounds.left = (int) (mLayout.getPrimaryHorizontal(offset) - mHotspotX)
                + TextView.this.mScrollX;
                + TextView.this.mScrollX;
            bounds.top = (bottom ? lineBottom : lineTop) + TextView.this.mScrollY;
            bounds.top = (bottom ? lineBottom : lineTop - mHeight) + TextView.this.mScrollY;


            bounds.right = bounds.left + width;
            bounds.right = bounds.left + width;
            bounds.bottom = bounds.top + height;
            bounds.bottom = bounds.top + height;
@@ -7855,8 +7907,7 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener
        };
        };


        InsertionPointCursorController() {
        InsertionPointCursorController() {
            Resources res = mContext.getResources();
            mHandle = new HandleView(this, HandleView.CENTER);
            mHandle = new HandleView(this, res.getDrawable(mTextSelectHandleRes));
        }
        }


        public void show() {
        public void show() {
@@ -7931,9 +7982,8 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener
        };
        };


        SelectionModifierCursorController() {
        SelectionModifierCursorController() {
            Resources res = mContext.getResources();
            mStartHandle = new HandleView(this, HandleView.LEFT);
            mStartHandle = new HandleView(this, res.getDrawable(mTextSelectHandleLeftRes));
            mEndHandle = new HandleView(this, HandleView.RIGHT);
            mEndHandle = new HandleView(this, res.getDrawable(mTextSelectHandleRightRes));
        }
        }


        public void show() {
        public void show() {
@@ -7974,31 +8024,25 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener


            // Handle the case where start and end are swapped, making sure start <= end
            // Handle the case where start and end are swapped, making sure start <= end
            if (handle == mStartHandle) {
            if (handle == mStartHandle) {
                if (offset <= selectionEnd) {
                if (selectionStart == offset || offset > selectionEnd) {
                    if (selectionStart == offset) {
                    return; // no change, no need to redraw;
                    return; // no change, no need to redraw;
                }
                }
                    selectionStart = offset;
                // If the user "closes" the selection entirely they were probably trying to
                } else {
                // select a single character. Help them out.
                    selectionStart = selectionEnd;
                if (offset == selectionEnd) {
                    selectionEnd = offset;
                    offset = selectionEnd - 1;
                    HandleView temp = mStartHandle;
                    mStartHandle = mEndHandle;
                    mEndHandle = temp;
                }
                }
                selectionStart = offset;
            } else {
            } else {
                if (offset >= selectionStart) {
                if (selectionEnd == offset || offset < selectionStart) {
                    if (selectionEnd == offset) {
                    return; // no change, no need to redraw;
                    return; // no change, no need to redraw;
                }
                }
                    selectionEnd = offset;
                // If the user "closes" the selection entirely they were probably trying to
                } else {
                // select a single character. Help them out.
                    selectionEnd = selectionStart;
                if (offset == selectionStart) {
                    selectionStart = offset;
                    offset = selectionStart + 1;
                    HandleView temp = mStartHandle;
                    mStartHandle = mEndHandle;
                    mEndHandle = temp;
                }
                }
                selectionEnd = offset;
            }
            }


            Selection.setSelection((Spannable) mText, selectionStart, selectionEnd);
            Selection.setSelection((Spannable) mText, selectionStart, selectionEnd);
@@ -8016,9 +8060,7 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener
                return;
                return;
            }
            }


            boolean oneLineSelection = mLayout.getLineForOffset(selectionStart) ==
            mStartHandle.positionAtCursor(selectionStart, true);
                    mLayout.getLineForOffset(selectionEnd);
            mStartHandle.positionAtCursor(selectionStart, oneLineSelection);
            mEndHandle.positionAtCursor(selectionEnd, true);
            mEndHandle.positionAtCursor(selectionEnd, true);
            hideDelayed(DELAY_BEFORE_FADE_OUT);
            hideDelayed(DELAY_BEFORE_FADE_OUT);
        }
        }
@@ -8144,7 +8186,7 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener
        final int previousLine = layout.getLineForOffset(previousOffset);
        final int previousLine = layout.getLineForOffset(previousOffset);
        final int previousLineTop = layout.getLineTop(previousLine);
        final int previousLineTop = layout.getLineTop(previousLine);
        final int previousLineBottom = layout.getLineBottom(previousLine);
        final int previousLineBottom = layout.getLineBottom(previousLine);
        final int hysteresisThreshold = (previousLineBottom - previousLineTop) / 6;
        final int hysteresisThreshold = (previousLineBottom - previousLineTop) / 8;


        // If new line is just before or after previous line and y position is less than
        // If new line is just before or after previous line and y position is less than
        // hysteresisThreshold away from previous line, keep cursor on previous line.
        // hysteresisThreshold away from previous line, keep cursor on previous line.
+865 B (2.49 KiB)
Loading image diff...
(1.75 KiB)

File mode changed from 100644 to 100755.

+730 B (2.61 KiB)
Loading image diff...
Loading