Projects >> platform_frameworks_base >>978dfdaa1e5c8654a2a02eae8d7d006e7ced8c64

Chunk
Conflicting content
            mPositionY = bounds.top;


<<<<<<< HEAD
                width = contentView.getMeasuredWidth();
    }
         * preventing the activity to be recycled.
         */
        public void onDetached();
    private class PastePopupMenu implements OnClickListener {
        private final PopupWindow mContainer;
        private int mPositionX;
        private int mPositionY;
        private final View[] mPasteViews = new View[4];
        private final int[] mPasteViewLayouts = new int[] { 
                mTextEditPasteWindowLayout,  mTextEditNoPasteWindowLayout, 
                mTextEditSidePasteWindowLayout, mTextEditSideNoPasteWindowLayout };
        
        public PastePopupMenu() {
            mContainer = new PopupWindow(TextView.this.mContext, null,
                    com.android.internal.R.attr.textSelectHandleWindowStyle);
            mContainer.setSplitTouchEnabled(true);
            mContainer.setClippingEnabled(false);
            mContainer.setWindowLayoutType(WindowManager.LayoutParams.TYPE_APPLICATION_SUB_PANEL);

            mContainer.setWidth(ViewGroup.LayoutParams.WRAP_CONTENT);
            mContainer.setHeight(ViewGroup.LayoutParams.WRAP_CONTENT);
        }

        private int viewIndex(boolean onTop) {
            return (onTop ? 0 : 1<<1) + (canPaste() ? 0 : 1<<0);
        }

        private void updateContent(boolean onTop) {
            final int viewIndex = viewIndex(onTop);
            View view = mPasteViews[viewIndex];

            if (view == null) {
                final int layout = mPasteViewLayouts[viewIndex];
                LayoutInflater inflater = (LayoutInflater)TextView.this.mContext.
                    getSystemService(Context.LAYOUT_INFLATER_SERVICE);
                if (inflater != null) {
                    view = inflater.inflate(layout, null);
                }

                if (view == null) {
                    throw new IllegalArgumentException("Unable to inflate TextEdit paste window");
                }

                final int size = View.MeasureSpec.makeMeasureSpec(0, View.MeasureSpec.UNSPECIFIED);
                view.setLayoutParams(new LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT,
                        ViewGroup.LayoutParams.WRAP_CONTENT));
                view.measure(size, size);

                view.setOnClickListener(this);
                
                mPasteViews[viewIndex] = view;
            }

            mContainer.setContentView(view);
        }

        public void show() {
            updateContent(true);
            positionAtCursor();
        }

        public void hide() {
            mContainer.dismiss();
        }

        public boolean isShowing() {
            return mContainer.isShowing();
        }

        @Override
        public void onClick(View v) {
            if (canPaste()) {
                paste(getSelectionStart(), getSelectionEnd());
            }
            hide();
        }

        void positionAtCursor() {
            View contentView = mContainer.getContentView();
            int width = contentView.getMeasuredWidth();
            int height = contentView.getMeasuredHeight();
            final int offset = TextView.this.getSelectionStart();
            final int line = mLayout.getLineForOffset(offset);
            final int lineTop = mLayout.getLineTop(line);
            float primaryHorizontal = mLayout.getPrimaryHorizontal(offset);

            final Rect bounds = sCursorControllerTempRect;
            bounds.left = (int) (primaryHorizontal - width / 2.0f);
            bounds.top = lineTop - height;

            bounds.right = bounds.left + width;
            bounds.bottom = bounds.top + height;

            convertFromViewportToContentCoordinates(bounds);

            mPositionX = bounds.left;
            final int[] coords = mTempCoords;
            TextView.this.getLocationInWindow(coords);
            coords[0] += mPositionX;
            coords[1] += mPositionY;

            final int screenWidth = mContext.getResources().getDisplayMetrics().widthPixels;
            if (coords[1] < 0) {
                updateContent(false);
                // Update dimensions from new view
                contentView = mContainer.getContentView();
                height = contentView.getMeasuredHeight();

                // Vertical clipping, move under edited line and to the side of insertion cursor 
                // TODO bottom clipping in case there is no system bar
                coords[1] += height;
                final int lineBottom = mLayout.getLineBottom(line);
                final int lineHeight = lineBottom - lineTop;
                coords[1] += lineHeight;

                // Move to right hand side of insertion cursor by default. TODO RTL text.
                final Drawable handle = mContext.getResources().getDrawable(mTextSelectHandleRes);
                final int handleHalfWidth = handle.getIntrinsicWidth() / 2;

                if (primaryHorizontal + handleHalfWidth + width < screenWidth) {
                    coords[0] += handleHalfWidth + width / 2;
                } else {
                    coords[0] -= handleHalfWidth + width / 2;                    
                }
            } else {
                // Horizontal clipping
                coords[0] = Math.max(0, coords[0]);
                coords[0] = Math.min(screenWidth - width, coords[0]);
            }

            mContainer.showAtLocation(TextView.this, Gravity.NO_GRAVITY, coords[0], coords[1]);
        }
=======
>>>>>>> 826fbdf7b621861f24b71a16fbad53c2ccff1de7
    }

    private class HandleView extends View {
Solution content
            mContainer.setContentView(view);
        }

        public void show() {
            updateContent(true);
                
                mPasteViews[viewIndex] = view;
            }

         * preventing the activity to be recycled.
         */
        public void onDetached();
    }

    private class PastePopupMenu implements OnClickListener {
        private final PopupWindow mContainer;
        private int mPositionX;
        private int mPositionY;
        private final View[] mPasteViews = new View[4];
        private final int[] mPasteViewLayouts = new int[] { 
                mTextEditPasteWindowLayout,  mTextEditNoPasteWindowLayout, 
                mTextEditSidePasteWindowLayout, mTextEditSideNoPasteWindowLayout };
        
        public PastePopupMenu() {
            mContainer = new PopupWindow(TextView.this.mContext, null,
                    com.android.internal.R.attr.textSelectHandleWindowStyle);
            mContainer.setSplitTouchEnabled(true);
            mContainer.setClippingEnabled(false);
            mContainer.setWindowLayoutType(WindowManager.LayoutParams.TYPE_APPLICATION_SUB_PANEL);

            mContainer.setWidth(ViewGroup.LayoutParams.WRAP_CONTENT);
            mContainer.setHeight(ViewGroup.LayoutParams.WRAP_CONTENT);
        }

        private int viewIndex(boolean onTop) {
            return (onTop ? 0 : 1<<1) + (canPaste() ? 0 : 1<<0);
        }

        private void updateContent(boolean onTop) {
            final int viewIndex = viewIndex(onTop);
            View view = mPasteViews[viewIndex];

            if (view == null) {
                final int layout = mPasteViewLayouts[viewIndex];
                LayoutInflater inflater = (LayoutInflater)TextView.this.mContext.
                    getSystemService(Context.LAYOUT_INFLATER_SERVICE);
                if (inflater != null) {
                    view = inflater.inflate(layout, null);
                }

                if (view == null) {
                    throw new IllegalArgumentException("Unable to inflate TextEdit paste window");
                }

                final int size = View.MeasureSpec.makeMeasureSpec(0, View.MeasureSpec.UNSPECIFIED);
                view.setLayoutParams(new LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT,
                        ViewGroup.LayoutParams.WRAP_CONTENT));
                view.measure(size, size);

                view.setOnClickListener(this);
            positionAtCursor();
        }

        public void hide() {
            mContainer.dismiss();
        }

        public boolean isShowing() {
            return mContainer.isShowing();
        }

        @Override
        public void onClick(View v) {
            if (canPaste()) {
                paste(getSelectionStart(), getSelectionEnd());
            }
            hide();
        }

        void positionAtCursor() {
            View contentView = mContainer.getContentView();
            int width = contentView.getMeasuredWidth();
            int height = contentView.getMeasuredHeight();
            final int offset = TextView.this.getSelectionStart();
            final int line = mLayout.getLineForOffset(offset);
            final int lineTop = mLayout.getLineTop(line);
            float primaryHorizontal = mLayout.getPrimaryHorizontal(offset);

            final Rect bounds = sCursorControllerTempRect;
            bounds.left = (int) (primaryHorizontal - width / 2.0f);
            bounds.top = lineTop - height;

            bounds.right = bounds.left + width;
            bounds.bottom = bounds.top + height;

            convertFromViewportToContentCoordinates(bounds);

            mPositionX = bounds.left;
            mPositionY = bounds.top;


            final int[] coords = mTempCoords;
            TextView.this.getLocationInWindow(coords);
            coords[0] += mPositionX;
            coords[1] += mPositionY;

            final int screenWidth = mContext.getResources().getDisplayMetrics().widthPixels;
            if (coords[1] < 0) {
                updateContent(false);
                // Update dimensions from new view
                contentView = mContainer.getContentView();
                width = contentView.getMeasuredWidth();
                height = contentView.getMeasuredHeight();

                // Vertical clipping, move under edited line and to the side of insertion cursor 
                // TODO bottom clipping in case there is no system bar
                coords[1] += height;
                final int lineBottom = mLayout.getLineBottom(line);
                final int lineHeight = lineBottom - lineTop;
                coords[1] += lineHeight;

                // Move to right hand side of insertion cursor by default. TODO RTL text.
                final Drawable handle = mContext.getResources().getDrawable(mTextSelectHandleRes);
                final int handleHalfWidth = handle.getIntrinsicWidth() / 2;

                if (primaryHorizontal + handleHalfWidth + width < screenWidth) {
                    coords[0] += handleHalfWidth + width / 2;
                } else {
                    coords[0] -= handleHalfWidth + width / 2;                    
                }
            } else {
                // Horizontal clipping
                coords[0] = Math.max(0, coords[0]);
                coords[0] = Math.min(screenWidth - width, coords[0]);
            }

            mContainer.showAtLocation(TextView.this, Gravity.NO_GRAVITY, coords[0], coords[1]);
        }
    }

    private class HandleView extends View {
File
TextView.java
Developer's decision
Version 1
Kind of conflict
Annotation
Attribute
Class signature
Method declaration
Method invocation
Chunk
Conflicting content
        }

        public void hide() {
<<<<<<< HEAD
            if (mHandle != null) {
                mHandle.hide();
            }
            removeHiderCallback();
            removePastePopupCallback();
        }

        private void hideDelayed() {
            removeHiderCallback();
            if (mHider == null) {
                mHider = new Runnable() {
                    public void run() {
                        hide();
                    }
                };
            }
            postDelayed(mHider, DELAY_BEFORE_FADE_OUT);
=======
            mHandle.hide();
            removeCallbacks(mHider);
        }

        private void hideDelayed(int msec) {
            removeCallbacks(mHider);
            postDelayed(mHider, msec);
>>>>>>> 826fbdf7b621861f24b71a16fbad53c2ccff1de7
        }

        public boolean isShowing() {
Solution content
        }

        public void hide() {
            if (mHandle != null) {
                mHandle.hide();
            }
            removeHiderCallback();
            removePastePopupCallback();
        }

        private void hideDelayed() {
            removeHiderCallback();
            if (mHider == null) {
                mHider = new Runnable() {
                    public void run() {
                        hide();
                    }
                };
            }
            postDelayed(mHider, DELAY_BEFORE_FADE_OUT);
        }

        public boolean isShowing() {
File
TextView.java
Developer's decision
Version 1
Kind of conflict
If statement
Method invocation
Method signature
Chunk
Conflicting content
            }
        }

<<<<<<< HEAD
        private HandleView getHandle() {
            if (mHandle == null) {
                mHandle = new HandleView(this, HandleView.CENTER);
            }
            return mHandle;
        }

        @Override
        public void onDetached() {
            removeHiderCallback();
            removePastePopupCallback();
=======
        @Override
        public void onDetached() {
            removeCallbacks(mHider);
>>>>>>> 826fbdf7b621861f24b71a16fbad53c2ccff1de7
        }
    }
Solution content
            }
        }

        private HandleView getHandle() {
            if (mHandle == null) {
                mHandle = new HandleView(this, HandleView.CENTER);
            }
            return mHandle;
        }

        @Override
        public void onDetached() {
            removeHiderCallback();
            removePastePopupCallback();
        }
    }
File
TextView.java
Developer's decision
Version 1
Kind of conflict
Annotation
Method declaration
Method invocation
Method signature
Chunk
Conflicting content
        }

        @Override
<<<<<<< HEAD
        public void onDetached() {}
=======
        public void onDetached() {
            removeCallbacks(mHider);
        }
>>>>>>> 826fbdf7b621861f24b71a16fbad53c2ccff1de7
    }

    private void hideInsertionPointCursorController() {
Solution content
        }

        @Override
        public void onDetached() {}
    }

    private void hideInsertionPointCursorController() {
File
TextView.java
Developer's decision
Version 1
Kind of conflict
Method declaration