Fix bug # 5863709 API request: Change param names of deleteSurroundingText to "before" and "after"

Change-Id: I727fad9a59cda915899674569bfabd29b9f5da60
This commit is contained in:
Fabrice Di Meglio
2012-01-23 15:06:42 -08:00
parent b2d81fead9
commit 0c95dd3f4f
5 changed files with 25 additions and 22 deletions

View File

@@ -193,10 +193,12 @@ public class BaseInputConnection implements InputConnection {
/**
* The default implementation performs the deletion around the current
* selection position of the editable text.
* @param beforeLength
* @param afterLength
*/
public boolean deleteSurroundingText(int leftLength, int rightLength) {
if (DEBUG) Log.v(TAG, "deleteSurroundingText " + leftLength
+ " / " + rightLength);
public boolean deleteSurroundingText(int beforeLength, int afterLength) {
if (DEBUG) Log.v(TAG, "deleteSurroundingText " + beforeLength
+ " / " + afterLength);
final Editable content = getEditable();
if (content == null) return false;
@@ -226,17 +228,17 @@ public class BaseInputConnection implements InputConnection {
int deleted = 0;
if (leftLength > 0) {
int start = a - leftLength;
if (beforeLength > 0) {
int start = a - beforeLength;
if (start < 0) start = 0;
content.delete(start, a);
deleted = a - start;
}
if (rightLength > 0) {
if (afterLength > 0) {
b = b - deleted;
int end = b + rightLength;
int end = b + afterLength;
if (end > content.length()) end = content.length();
content.delete(b, end);

View File

@@ -138,19 +138,20 @@ public interface InputConnection {
int flags);
/**
* Delete <var>leftLength</var> characters of text before the current cursor
* position, and delete <var>rightLength</var> characters of text after the
* Delete <var>beforeLength</var> characters of text before the current cursor
* position, and delete <var>afterLength</var> characters of text after the
* current cursor position, excluding composing text.
*
* @param leftLength The number of characters to be deleted before the
*
* @param beforeLength The number of characters to be deleted before the
* current cursor position.
* @param rightLength The number of characters to be deleted after the
* @param afterLength The number of characters to be deleted after the
* current cursor position.
*
*
* @return Returns true on success, false if the input connection is no longer
* valid.
*/
public boolean deleteSurroundingText(int leftLength, int rightLength);
public boolean deleteSurroundingText(int beforeLength, int afterLength);
/**
* Set composing text around the current cursor position with the given text,

View File

@@ -62,8 +62,8 @@ public class InputConnectionWrapper implements InputConnection {
return mTarget.getExtractedText(request, flags);
}
public boolean deleteSurroundingText(int leftLength, int rightLength) {
return mTarget.deleteSurroundingText(leftLength, rightLength);
public boolean deleteSurroundingText(int beforeLength, int afterLength) {
return mTarget.deleteSurroundingText(beforeLength, afterLength);
}
public boolean setComposingText(CharSequence text, int newCursorPosition) {

View File

@@ -383,17 +383,17 @@ public class WebView extends AbsoluteLayout
}
@Override
public boolean deleteSurroundingText(int leftLength, int rightLength) {
public boolean deleteSurroundingText(int beforeLength, int afterLength) {
// Look for one-character delete and send it as a key press.
if (leftLength == 1 && rightLength == 0) {
if (beforeLength == 1 && afterLength == 0) {
sendKeyPress(KeyEvent.KEYCODE_DEL);
} else if (leftLength == 0 && rightLength == 1){
} else if (beforeLength == 0 && afterLength == 1){
sendKeyPress(KeyEvent.KEYCODE_FORWARD_DEL);
} else if (mWebViewCore != null) {
mWebViewCore.sendMessage(EventHub.DELETE_SURROUNDING_TEXT,
leftLength, rightLength);
beforeLength, afterLength);
}
return super.deleteSurroundingText(leftLength, rightLength);
return super.deleteSurroundingText(beforeLength, afterLength);
}
}

View File

@@ -387,9 +387,9 @@ public class InputConnectionWrapper implements InputConnection {
}
}
public boolean deleteSurroundingText(int leftLength, int rightLength) {
public boolean deleteSurroundingText(int beforeLength, int afterLength) {
try {
mIInputContext.deleteSurroundingText(leftLength, rightLength);
mIInputContext.deleteSurroundingText(beforeLength, afterLength);
return true;
} catch (RemoteException e) {
return false;