From 574b80aacee95df26e85e6b78876a73d7076a672 Mon Sep 17 00:00:00 2001
From: Jean Chalard <jchalard@google.com>
Date: Mon, 1 Oct 2012 16:03:21 +0900
Subject: [PATCH] Remove debug prints.

Bug: 7226098
Change-Id: Ibacb740022a6af56c9d555d6797dd402a89f6ca4
---
 .../android/inputmethod/latin/LatinIME.java   |  4 +++
 .../latin/RichInputConnection.java            | 25 ++++++++++---------
 2 files changed, 17 insertions(+), 12 deletions(-)

diff --git a/java/src/com/android/inputmethod/latin/LatinIME.java b/java/src/com/android/inputmethod/latin/LatinIME.java
index 268d36ad27..311355374a 100644
--- a/java/src/com/android/inputmethod/latin/LatinIME.java
+++ b/java/src/com/android/inputmethod/latin/LatinIME.java
@@ -1878,6 +1878,10 @@ public final class LatinIME extends InputMethodService implements KeyboardAction
             mIsAutoCorrectionIndicatorOn = newAutoCorrectionIndicator;
             final CharSequence textWithUnderline =
                     getTextWithUnderline(mWordComposer.getTypedWord());
+            // TODO: when called from an updateSuggestionStrip() call that results from a posted
+            // message, this is called outside any batch edit. Potentially, this may result in some
+            // janky flickering of the screen, although the display speed makes it unlikely in
+            // the practice.
             mConnection.setComposingText(textWithUnderline, 1);
         }
     }
diff --git a/java/src/com/android/inputmethod/latin/RichInputConnection.java b/java/src/com/android/inputmethod/latin/RichInputConnection.java
index 1acca5860a..b27db579fa 100644
--- a/java/src/com/android/inputmethod/latin/RichInputConnection.java
+++ b/java/src/com/android/inputmethod/latin/RichInputConnection.java
@@ -45,6 +45,7 @@ public final class RichInputConnection {
     private static final String TAG = RichInputConnection.class.getSimpleName();
     private static final boolean DBG = false;
     private static final boolean DEBUG_PREVIOUS_TEXT = false;
+    private static final boolean DEBUG_BATCH_NESTING = false;
     // Provision for a long word pair and a separator
     private static final int LOOKBACK_CHARACTER_NUM = BinaryDictionary.MAX_WORD_LENGTH * 2 + 1;
     private static final Pattern spaceRegex = Pattern.compile("\\s+");
@@ -128,7 +129,7 @@ public final class RichInputConnection {
                 Log.e(TAG, "Nest level too deep : " + mNestLevel);
             }
         }
-        checkBatchEdit();
+        if (DEBUG_BATCH_NESTING) checkBatchEdit();
         if (DEBUG_PREVIOUS_TEXT) checkConsistencyForDebug();
     }
 
@@ -163,7 +164,7 @@ public final class RichInputConnection {
     }
 
     public void finishComposingText() {
-        checkBatchEdit();
+        if (DEBUG_BATCH_NESTING) checkBatchEdit();
         if (DEBUG_PREVIOUS_TEXT) checkConsistencyForDebug();
         mCommittedTextBeforeComposingText.append(mComposingText);
         mCurrentCursorPosition += mComposingText.length();
@@ -177,7 +178,7 @@ public final class RichInputConnection {
     }
 
     public void commitText(final CharSequence text, final int i) {
-        checkBatchEdit();
+        if (DEBUG_BATCH_NESTING) checkBatchEdit();
         if (DEBUG_PREVIOUS_TEXT) checkConsistencyForDebug();
         mCommittedTextBeforeComposingText.append(text);
         mCurrentCursorPosition += text.length() - mComposingText.length();
@@ -247,7 +248,7 @@ public final class RichInputConnection {
     }
 
     public void deleteSurroundingText(final int i, final int j) {
-        checkBatchEdit();
+        if (DEBUG_BATCH_NESTING) checkBatchEdit();
         final int remainingChars = mComposingText.length() - i;
         if (remainingChars >= 0) {
             mComposingText.setLength(remainingChars);
@@ -283,7 +284,7 @@ public final class RichInputConnection {
     }
 
     public void sendKeyEvent(final KeyEvent keyEvent) {
-        checkBatchEdit();
+        if (DEBUG_BATCH_NESTING) checkBatchEdit();
         if (keyEvent.getAction() == KeyEvent.ACTION_DOWN) {
             if (DEBUG_PREVIOUS_TEXT) checkConsistencyForDebug();
             // This method is only called for enter or backspace when speaking to old
@@ -331,7 +332,7 @@ public final class RichInputConnection {
     }
 
     public void setComposingText(final CharSequence text, final int i) {
-        checkBatchEdit();
+        if (DEBUG_BATCH_NESTING) checkBatchEdit();
         if (DEBUG_PREVIOUS_TEXT) checkConsistencyForDebug();
         mCurrentCursorPosition += text.length() - mComposingText.length();
         mComposingText.setLength(0);
@@ -347,7 +348,7 @@ public final class RichInputConnection {
     }
 
     public void setSelection(final int from, final int to) {
-        checkBatchEdit();
+        if (DEBUG_BATCH_NESTING) checkBatchEdit();
         if (DEBUG_PREVIOUS_TEXT) checkConsistencyForDebug();
         if (null != mIC) {
             mIC.setSelection(from, to);
@@ -361,7 +362,7 @@ public final class RichInputConnection {
     }
 
     public void commitCorrection(final CorrectionInfo correctionInfo) {
-        checkBatchEdit();
+        if (DEBUG_BATCH_NESTING) checkBatchEdit();
         if (DEBUG_PREVIOUS_TEXT) checkConsistencyForDebug();
         // This has no effect on the text field and does not change its content. It only makes
         // TextView flash the text for a second based on indices contained in the argument.
@@ -375,7 +376,7 @@ public final class RichInputConnection {
     }
 
     public void commitCompletion(final CompletionInfo completionInfo) {
-        checkBatchEdit();
+        if (DEBUG_BATCH_NESTING) checkBatchEdit();
         if (DEBUG_PREVIOUS_TEXT) checkConsistencyForDebug();
         final CharSequence text = completionInfo.getText();
         mCommittedTextBeforeComposingText.append(text);
@@ -575,7 +576,7 @@ public final class RichInputConnection {
     }
 
     public void removeTrailingSpace() {
-        checkBatchEdit();
+        if (DEBUG_BATCH_NESTING) checkBatchEdit();
         final CharSequence lastOne = getTextBeforeCursor(1, 0);
         if (lastOne != null && lastOne.length() == 1
                 && lastOne.charAt(0) == Keyboard.CODE_SPACE) {
@@ -631,7 +632,7 @@ public final class RichInputConnection {
     }
 
     public boolean revertDoubleSpace() {
-        checkBatchEdit();
+        if (DEBUG_BATCH_NESTING) checkBatchEdit();
         // Here we test whether we indeed have a period and a space before us. This should not
         // be needed, but it's there just in case something went wrong.
         final CharSequence textBeforeCursor = getTextBeforeCursor(2, 0);
@@ -649,7 +650,7 @@ public final class RichInputConnection {
     }
 
     public boolean revertSwapPunctuation() {
-        checkBatchEdit();
+        if (DEBUG_BATCH_NESTING) checkBatchEdit();
         // Here we test whether we indeed have a space and something else before us. This should not
         // be needed, but it's there just in case something went wrong.
         final CharSequence textBeforeCursor = getTextBeforeCursor(2, 0);
-- 
GitLab