diff options
Diffstat (limited to 'java/src/com/android/inputmethod/latin/EditingUtils.java')
-rw-r--r-- | java/src/com/android/inputmethod/latin/EditingUtils.java | 34 |
1 files changed, 7 insertions, 27 deletions
diff --git a/java/src/com/android/inputmethod/latin/EditingUtils.java b/java/src/com/android/inputmethod/latin/EditingUtils.java index 634dbbdfc..b3f613bae 100644 --- a/java/src/com/android/inputmethod/latin/EditingUtils.java +++ b/java/src/com/android/inputmethod/latin/EditingUtils.java @@ -1,12 +1,12 @@ /* * Copyright (C) 2009 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. You may obtain a copy of * the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the @@ -16,8 +16,6 @@ package com.android.inputmethod.latin; -import com.android.inputmethod.compat.InputConnectionCompatUtils; - import android.text.TextUtils; import android.view.inputmethod.ExtractedText; import android.view.inputmethod.ExtractedTextRequest; @@ -87,23 +85,6 @@ public class EditingUtils { } /** - * Removes the word surrounding the cursor. Parameters are identical to - * getWordAtCursor. - */ - public static void deleteWordAtCursor(InputConnection connection, String separators) { - // getWordRangeAtCursor returns null if the connection is null - Range range = getWordRangeAtCursor(connection, separators); - if (range == null) return; - - connection.finishComposingText(); - // Move cursor to beginning of word, to avoid crash when cursor is outside - // of valid range after deleting text. - int newCursor = getCursorPosition(connection) - range.mCharsBefore; - connection.setSelection(newCursor, newCursor); - connection.deleteSurroundingText(0, range.mCharsBefore + range.mCharsAfter); - } - - /** * Represents a range of text, relative to the current cursor position. */ public static class Range { @@ -263,7 +244,7 @@ public class EditingUtils { if (selStart == selEnd) { // There is just a cursor, so get the word at the cursor // getWordRangeAtCursor returns null if the connection is null - EditingUtils.Range range = getWordRangeAtCursor(ic, wordSeparators); + final EditingUtils.Range range = getWordRangeAtCursor(ic, wordSeparators); if (range != null && !TextUtils.isEmpty(range.mWord)) { return new SelectedWord(selStart - range.mCharsBefore, selEnd + range.mCharsAfter, range.mWord); @@ -271,20 +252,19 @@ public class EditingUtils { } else { if (null == ic) return null; // Is the previous character empty or a word separator? If not, return null. - CharSequence charsBefore = ic.getTextBeforeCursor(1, 0); + final CharSequence charsBefore = ic.getTextBeforeCursor(1, 0); if (!isWordBoundary(charsBefore, wordSeparators)) { return null; } // Is the next character empty or a word separator? If not, return null. - CharSequence charsAfter = ic.getTextAfterCursor(1, 0); + final CharSequence charsAfter = ic.getTextAfterCursor(1, 0); if (!isWordBoundary(charsAfter, wordSeparators)) { return null; } // Extract the selection alone - CharSequence touching = InputConnectionCompatUtils.getSelectedText( - ic, selStart, selEnd); + final CharSequence touching = ic.getSelectedText(0); if (TextUtils.isEmpty(touching)) return null; // Is any part of the selection a separator? If so, return null. final int length = touching.length(); |