diff options
author | Gilles Debunne <debunne@google.com> | 2010-12-03 11:45:09 -0800 |
---|---|---|
committer | Gilles Debunne <debunne@google.com> | 2010-12-06 12:37:24 -0800 |
commit | 1cafde04c5003fb58585afa212a103fb96757783 (patch) | |
tree | 3298f4e9290eac8f1a030059dbec6a6d809266da | |
parent | 38dab454d151423faa9eb8c17f9cb8579f5e79c8 (diff) | |
download | frameworks_base-1cafde04c5003fb58585afa212a103fb96757783.zip frameworks_base-1cafde04c5003fb58585afa212a103fb96757783.tar.gz frameworks_base-1cafde04c5003fb58585afa212a103fb96757783.tar.bz2 |
Moved Paste popup window up in TextView
Bug 3228601
A tap on the insertion handle displays the paste popup immediately.
Tapping again hides the popup.
Bug 3248651
Change-Id: I5a501b3ebe36e23cbbf0f1b3d588884c6ecd1d56
-rw-r--r-- | core/java/android/widget/TextView.java | 28 | ||||
-rw-r--r-- | core/res/res/layout/text_edit_no_paste_window.xml | 33 | ||||
-rw-r--r-- | core/res/res/layout/text_edit_paste_window.xml | 31 |
3 files changed, 38 insertions, 54 deletions
diff --git a/core/java/android/widget/TextView.java b/core/java/android/widget/TextView.java index 396c773..a86610d 100644 --- a/core/java/android/widget/TextView.java +++ b/core/java/android/widget/TextView.java @@ -8220,6 +8220,10 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener positionAtCursor(); coords[0] += mPositionX; coords[1] += mPositionY; + coords[0] = Math.max(0, coords[0]); + final int screenWidth = mContext.getResources().getDisplayMetrics().widthPixels; + coords[0] = Math.min(screenWidth - mContainer.getContentView().getMeasuredWidth(), + coords[0]); mContainer.showAtLocation(TextView.this, Gravity.NO_GRAVITY, coords[0], coords[1]); } @@ -8363,7 +8367,7 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener mContainerPositionY = coords[1] + mPositionY; mContainer.showAtLocation(TextView.this, 0, mContainerPositionX, mContainerPositionY); - // Hide paste view when handle is moved. + // Hide paste view when handle is moved on screen. if (mPastePopupWindow != null) { mPastePopupWindow.hide(); } @@ -8502,12 +8506,6 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener mIsDragging = true; if (mHasPastePopupWindow) { mTouchTimer = SystemClock.uptimeMillis(); - if (mPastePopupWindow != null && mPastePopupWindow.isShowing()) { - // Tapping on the handle again dismisses the displayed paste view, - mPastePopupWindow.hide(); - // and makes sure the action up does not display the paste view. - mTouchTimer = 0; - } } break; } @@ -8522,10 +8520,7 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener break; } case MotionEvent.ACTION_UP: - if (mPastePopupWindow != null) { - // Will show the paste popup after a delay. - mController.show(); - /* TEMP USER TEST: Display Paste as soon as handle is draggged + if (mHasPastePopupWindow) { long delay = SystemClock.uptimeMillis() - mTouchTimer; if (delay < ViewConfiguration.getTapTimeout()) { final float touchOffsetX = ev.getRawX() - mPositionX; @@ -8537,9 +8532,16 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener final int doubleTapSlop = viewConfiguration.getScaledDoubleTapSlop(); final int slopSquared = doubleTapSlop * doubleTapSlop; if (distanceSquared < slopSquared) { - showPastePopupWindow(); + if (mPastePopupWindow != null && mPastePopupWindow.isShowing()) { + // Tapping on the handle dismisses the displayed paste view, + mPastePopupWindow.hide(); + } else { + ((InsertionPointCursorController) mController).show(0); + } } - }*/ + } else { + mController.show(); + } } mIsDragging = false; break; diff --git a/core/res/res/layout/text_edit_no_paste_window.xml b/core/res/res/layout/text_edit_no_paste_window.xml index d409d97..fa50275 100644 --- a/core/res/res/layout/text_edit_no_paste_window.xml +++ b/core/res/res/layout/text_edit_no_paste_window.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="utf-8"?> -<!-- Copyright (C) 2008 The Android Open Source Project +<!-- Copyright (C) 2010 The Android Open Source Project Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,34 +14,25 @@ limitations under the License. --> -<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" +<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:background="@android:drawable/text_edit_paste_window"> - - <ImageView android:id="@+id/paste_icon" - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:paddingLeft="16dip" - android:paddingRight="8dip" - android:paddingTop="8dip" - android:paddingBottom="8dip" - android:layout_centerVertical="true" - android:background="@android:drawable/ic_menu_paste_dark" - /> + android:layout_height="wrap_content"> <TextView android:id="@+id/title" android:layout_width="wrap_content" android:layout_height="wrap_content" - android:paddingLeft="0dip" + android:paddingLeft="16dip" android:paddingRight="16dip" android:paddingTop="8dip" android:paddingBottom="8dip" - android:layout_centerVertical="true" - android:textAppearance="?android:attr/textAppearanceMedium" - android:text="@android:string/pasteDisabled" + android:drawableLeft="@android:drawable/ic_menu_paste_dark" + android:drawablePadding="8dip" + android:gravity="center" + android:textAppearance="?android:attr/textAppearanceMediumInverse" android:textColor="@android:color/dim_foreground_dark_inverse_disabled" - android:layout_toRightOf="@id/paste_icon" + android:background="@android:drawable/text_edit_paste_window" + android:text="@android:string/pasteDisabled" + android:layout_marginBottom="12dip" /> -</RelativeLayout> +</LinearLayout> diff --git a/core/res/res/layout/text_edit_paste_window.xml b/core/res/res/layout/text_edit_paste_window.xml index d153365..575b98e 100644 --- a/core/res/res/layout/text_edit_paste_window.xml +++ b/core/res/res/layout/text_edit_paste_window.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="utf-8"?> -<!-- Copyright (C) 2008 The Android Open Source Project +<!-- Copyright (C) 2010 The Android Open Source Project Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,34 +14,25 @@ limitations under the License. --> -<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" +<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:background="@android:drawable/text_edit_paste_window"> - - <ImageView android:id="@+id/paste_icon" - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:paddingLeft="16dip" - android:paddingRight="8dip" - android:paddingTop="8dip" - android:paddingBottom="8dip" - android:layout_centerVertical="true" - android:background="@android:drawable/ic_menu_paste_light" - /> + android:layout_height="wrap_content"> <TextView android:id="@+id/title" android:layout_width="wrap_content" android:layout_height="wrap_content" - android:paddingLeft="0dip" + android:paddingLeft="16dip" android:paddingRight="16dip" android:paddingTop="8dip" android:paddingBottom="8dip" - android:layout_centerVertical="true" + android:drawableLeft="@android:drawable/ic_menu_paste_light" + android:drawablePadding="8dip" + android:gravity="center" android:textAppearance="?android:attr/textAppearanceMediumInverse" - android:text="@android:string/paste" android:textColor="@android:color/black" - android:layout_toRightOf="@id/paste_icon" + android:background="@android:drawable/text_edit_paste_window" + android:text="@android:string/paste" + android:layout_marginBottom="12dip" /> -</RelativeLayout> +</LinearLayout> |