Merge "Moved Paste popup window up in TextView"

This commit is contained in:
Gilles Debunne
2010-12-06 13:57:47 -08:00
committed by Android (Google) Code Review
3 changed files with 38 additions and 54 deletions

View File

@@ -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;

View File

@@ -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>

View File

@@ -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>