Removing code from RichInputConnection.

Followup CL that removes some more unused methods and variables.

Change-Id: I4163c7cd017f59d1fd445adb6294fc89dcaafe6e
main
Dan Zivkovic 2015-02-04 16:47:56 -08:00
parent f3c319fb8a
commit a6d2cf5ec7
2 changed files with 4 additions and 55 deletions

View File

@ -94,12 +94,6 @@ public final class RichInputConnection implements PrivateCommandPerformer {
* to avoid object creation. * to avoid object creation.
*/ */
private SpannableStringBuilder mTempObjectForCommitText = new SpannableStringBuilder(); private SpannableStringBuilder mTempObjectForCommitText = new SpannableStringBuilder();
/**
* This variable is used to track whether the last committed text had the background color or
* not.
* TODO: Omit this flag if possible.
*/
private boolean mLastCommittedTextHasBackgroundColor = false;
private final InputMethodService mParent; private final InputMethodService mParent;
InputConnection mIC; InputConnection mIC;
@ -238,8 +232,6 @@ public final class RichInputConnection implements PrivateCommandPerformer {
// it works, but it's wrong and should be fixed. // it works, but it's wrong and should be fixed.
mCommittedTextBeforeComposingText.append(mComposingText); mCommittedTextBeforeComposingText.append(mComposingText);
mComposingText.setLength(0); mComposingText.setLength(0);
// TODO: Clear this flag in setComposingRegion() and setComposingText() as well if needed.
mLastCommittedTextHasBackgroundColor = false;
if (null != mIC) { if (null != mIC) {
mIC.finishComposingText(); mIC.finishComposingText();
} }
@ -261,7 +253,6 @@ public final class RichInputConnection implements PrivateCommandPerformer {
mExpectedSelStart += text.length() - mComposingText.length(); mExpectedSelStart += text.length() - mComposingText.length();
mExpectedSelEnd = mExpectedSelStart; mExpectedSelEnd = mExpectedSelStart;
mComposingText.setLength(0); mComposingText.setLength(0);
mLastCommittedTextHasBackgroundColor = false;
if (null != mIC) { if (null != mIC) {
mTempObjectForCommitText.clear(); mTempObjectForCommitText.clear();
mTempObjectForCommitText.append(text); mTempObjectForCommitText.append(text);
@ -288,27 +279,6 @@ public final class RichInputConnection implements PrivateCommandPerformer {
} }
} }
/**
* Removes the background color from the highlighted text if necessary. Should be called while
* there is no on-going composing text.
*
* <p>CAVEAT: This method internally calls {@link InputConnection#finishComposingText()}.
* Be careful of any unexpected side effects.</p>
*/
public void removeBackgroundColorFromHighlightedTextIfNecessary() {
// TODO: We haven't yet full tested if we really need to check this flag or not. Omit this
// flag if everything works fine without this condition.
if (!mLastCommittedTextHasBackgroundColor) {
return;
}
if (mComposingText.length() > 0) {
Log.e(TAG, "clearSpansWithComposingFlags should be called when composing text is " +
"empty. mComposingText=" + mComposingText);
return;
}
finishComposingText();
}
public CharSequence getSelectedText(final int flags) { public CharSequence getSelectedText(final int flags) {
return (null == mIC) ? null : mIC.getSelectedText(flags); return (null == mIC) ? null : mIC.getSelectedText(flags);
} }
@ -936,8 +906,6 @@ public final class RichInputConnection implements PrivateCommandPerformer {
} }
} }
private boolean mCursorAnchorInfoMonitorEnabled = false;
/** /**
* Requests the editor to call back {@link InputMethodManager#updateCursorAnchorInfo}. * Requests the editor to call back {@link InputMethodManager#updateCursorAnchorInfo}.
* @param enableMonitor {@code true} to request the editor to call back the method whenever the * @param enableMonitor {@code true} to request the editor to call back the method whenever the
@ -952,23 +920,10 @@ public final class RichInputConnection implements PrivateCommandPerformer {
public boolean requestCursorUpdates(final boolean enableMonitor, public boolean requestCursorUpdates(final boolean enableMonitor,
final boolean requestImmediateCallback) { final boolean requestImmediateCallback) {
mIC = mParent.getCurrentInputConnection(); mIC = mParent.getCurrentInputConnection();
final boolean scheduled; if (mIC == null) {
if (null != mIC) { return false;
scheduled = InputConnectionCompatUtils.requestCursorUpdates(mIC, enableMonitor,
requestImmediateCallback);
} else {
scheduled = false;
} }
mCursorAnchorInfoMonitorEnabled = (scheduled && enableMonitor); return InputConnectionCompatUtils.requestCursorUpdates(
return scheduled; mIC, enableMonitor, requestImmediateCallback);
}
/**
* @return {@code true} if the application reported that the monitor mode of
* {@link InputMethodService#onUpdateCursorAnchorInfo(android.view.inputmethod.CursorAnchorInfo)}
* is currently enabled.
*/
public boolean isCursorAnchorInfoMonitorEnabled() {
return mCursorAnchorInfoMonitorEnabled;
} }
} }

View File

@ -475,8 +475,6 @@ public final class InputLogic {
++mAutoCommitSequenceNumber; ++mAutoCommitSequenceNumber;
mConnection.beginBatchEdit(); mConnection.beginBatchEdit();
if (!mWordComposer.isComposingWord()) { if (!mWordComposer.isComposingWord()) {
mConnection.removeBackgroundColorFromHighlightedTextIfNecessary();
} else {
if (mWordComposer.isCursorFrontOrMiddleOfComposingWord()) { if (mWordComposer.isCursorFrontOrMiddleOfComposingWord()) {
// If we are in the middle of a recorrection, we need to commit the recorrection // If we are in the middle of a recorrection, we need to commit the recorrection
// first so that we can insert the batch input at the current cursor position. // first so that we can insert the batch input at the current cursor position.
@ -767,10 +765,6 @@ public final class InputLogic {
final InputTransaction inputTransaction, final InputTransaction inputTransaction,
// TODO: remove this argument // TODO: remove this argument
final LatinIME.UIHandler handler) { final LatinIME.UIHandler handler) {
if (!mWordComposer.isComposingWord()) {
mConnection.removeBackgroundColorFromHighlightedTextIfNecessary();
}
final int codePoint = event.mCodePoint; final int codePoint = event.mCodePoint;
mSpaceState = SpaceState.NONE; mSpaceState = SpaceState.NONE;
if (inputTransaction.mSettingsValues.isWordSeparator(codePoint) if (inputTransaction.mSettingsValues.isWordSeparator(codePoint)