Bug 731056 Part 1 - Fix checkstyle warnings: fix whitespace. r=dougt

This commit is contained in:
Chris Peterson 2012-02-27 16:29:22 -08:00
parent 076a7f08b6
commit 9762508541

View File

@ -59,8 +59,8 @@ import android.util.*;
public class GeckoInputConnection public class GeckoInputConnection
extends BaseInputConnection extends BaseInputConnection
implements TextWatcher, InputConnectionHandler implements TextWatcher, InputConnectionHandler {
{
private static final boolean DEBUG = false; private static final boolean DEBUG = false;
protected static final String LOGTAG = "GeckoInputConnection"; protected static final String LOGTAG = "GeckoInputConnection";
@ -211,9 +211,9 @@ public class GeckoInputConnection
extract.text = content.toString(); extract.text = content.toString();
} catch (IndexOutOfBoundsException iob) { } catch (IndexOutOfBoundsException iob) {
Log.d(LOGTAG, Log.d(LOGTAG,
"IndexOutOfBoundsException thrown from getExtractedText(). start: " + "IndexOutOfBoundsException thrown from getExtractedText(). start: "
Selection.getSelectionStart(content) + + Selection.getSelectionStart(content)
" end: " + Selection.getSelectionEnd(content)); + " end: " + Selection.getSelectionEnd(content));
return null; return null;
} }
return extract; return extract;
@ -234,7 +234,7 @@ public class GeckoInputConnection
} }
private void replaceText(CharSequence text, int newCursorPosition, boolean composing) { private void replaceText(CharSequence text, int newCursorPosition, boolean composing) {
if (DEBUG) Log.d(LOGTAG, String.format("IME: replaceText(\"%s\", %d, %s)", text, newCursorPosition, composing?"true":"false")); if (DEBUG) Log.d(LOGTAG, String.format("IME: replaceText(\"%s\", %d, %b)", text, newCursorPosition, composing));
if (text == null) if (text == null)
text = ""; text = "";
@ -243,15 +243,15 @@ public class GeckoInputConnection
if (content == null) { if (content == null) {
return; return;
} }
beginBatchEdit(); beginBatchEdit();
// delete composing text set previously. // delete composing text set previously.
int a = getComposingSpanStart(content); int a = getComposingSpanStart(content);
int b = getComposingSpanEnd(content); int b = getComposingSpanEnd(content);
if (DEBUG) Log.d(LOGTAG, "Composing span: " + a + " to " + b); if (DEBUG) Log.d(LOGTAG, "Composing span: " + a + " to " + b);
if (b < a) { if (b < a) {
int tmp = a; int tmp = a;
a = b; a = b;
@ -280,15 +280,15 @@ public class GeckoInputConnection
sp.setSpan(COMPOSING_SPAN, 0, sp.length(), sp.setSpan(COMPOSING_SPAN, 0, sp.length(),
Spanned.SPAN_EXCLUSIVE_EXCLUSIVE | Spanned.SPAN_COMPOSING); Spanned.SPAN_EXCLUSIVE_EXCLUSIVE | Spanned.SPAN_COMPOSING);
} else { } else {
sp = (Spannable)text; sp = (Spannable) text;
} }
setComposingSpans(sp); setComposingSpans(sp);
} }
if (DEBUG) Log.d(LOGTAG, "Replacing from " + a + " to " + b + " with \"" if (DEBUG) Log.d(LOGTAG, "Replacing from " + a + " to " + b + " with \""
+ text + "\", composing=" + composing + text + "\", composing=" + composing
+ ", type=" + text.getClass().getCanonicalName()); + ", type=" + text.getClass().getCanonicalName());
if (DEBUG) { if (DEBUG) {
LogPrinter lp = new LogPrinter(Log.VERBOSE, LOGTAG); LogPrinter lp = new LogPrinter(Log.VERBOSE, LOGTAG);
lp.println("Current text:"); lp.println("Current text:");
@ -296,7 +296,7 @@ public class GeckoInputConnection
lp.println("Composing text:"); lp.println("Composing text:");
TextUtils.dumpSpans(text, lp, " "); TextUtils.dumpSpans(text, lp, " ");
} }
// Position the cursor appropriately, so that after replacing the // Position the cursor appropriately, so that after replacing the
// desired range of text it will be located in the correct spot. // desired range of text it will be located in the correct spot.
// This allows us to deal with filters performing edits on the text // This allows us to deal with filters performing edits on the text
@ -312,13 +312,13 @@ public class GeckoInputConnection
Selection.setSelection(content, newCursorPosition); Selection.setSelection(content, newCursorPosition);
content.replace(a, b, text); content.replace(a, b, text);
if (DEBUG) { if (DEBUG) {
LogPrinter lp = new LogPrinter(Log.VERBOSE, LOGTAG); LogPrinter lp = new LogPrinter(Log.VERBOSE, LOGTAG);
lp.println("Final text:"); lp.println("Final text:");
TextUtils.dumpSpans(content, lp, " "); TextUtils.dumpSpans(content, lp, " ");
} }
endBatchEdit(); endBatchEdit();
} }
@ -342,7 +342,7 @@ public class GeckoInputConnection
if (a < 0 || b < 0) if (a < 0 || b < 0)
return null; return null;
if (b < a) { if (b < a) {
int tmp = a; int tmp = a;
a = b; a = b;
@ -351,7 +351,7 @@ public class GeckoInputConnection
return TextUtils.substring(content, a, b); return TextUtils.substring(content, a, b);
} }
public boolean onKeyDel() { public boolean onKeyDel() {
// Some IMEs don't update us on deletions // Some IMEs don't update us on deletions
// In that case we are not updated when a composition // In that case we are not updated when a composition
@ -449,8 +449,7 @@ public class GeckoInputConnection
} }
// TextWatcher // TextWatcher
public void onTextChanged(CharSequence s, int start, int before, int count) public void onTextChanged(CharSequence s, int start, int before, int count) {
{
if (mComposing && mCompositionStart != start) { if (mComposing && mCompositionStart != start) {
// Changed range is different from the composition, need to reset the composition // Changed range is different from the composition, need to reset the composition
endComposition(); endComposition();
@ -523,25 +522,20 @@ public class GeckoInputConnection
continue; continue;
// Get and iterate through list of span objects within range // Get and iterate through list of span objects within range
CharacterStyle styles[] = span.getSpans( CharacterStyle[] styles = span.getSpans(spanStart, spanEnd, CharacterStyle.class);
spanStart, spanEnd, CharacterStyle.class);
for (CharacterStyle style : styles) { for (CharacterStyle style : styles) {
if (style instanceof UnderlineSpan) { if (style instanceof UnderlineSpan) {
// Text should be underlined // Text should be underlined
rangeStyles |= GeckoEvent.IME_RANGE_UNDERLINE; rangeStyles |= GeckoEvent.IME_RANGE_UNDERLINE;
} else if (style instanceof ForegroundColorSpan) { } else if (style instanceof ForegroundColorSpan) {
// Text should be of a different foreground color // Text should be of a different foreground color
rangeStyles |= GeckoEvent.IME_RANGE_FORECOLOR; rangeStyles |= GeckoEvent.IME_RANGE_FORECOLOR;
rangeForeColor = rangeForeColor = ((ForegroundColorSpan) style).getForegroundColor();
((ForegroundColorSpan)style).getForegroundColor();
} else if (style instanceof BackgroundColorSpan) { } else if (style instanceof BackgroundColorSpan) {
// Text should be of a different background color // Text should be of a different background color
rangeStyles |= GeckoEvent.IME_RANGE_BACKCOLOR; rangeStyles |= GeckoEvent.IME_RANGE_BACKCOLOR;
rangeBackColor = rangeBackColor = ((BackgroundColorSpan) style).getBackgroundColor();
((BackgroundColorSpan)style).getBackgroundColor();
} }
} }
@ -557,8 +551,8 @@ public class GeckoInputConnection
spanStart = spanEnd; spanStart = spanEnd;
} while (spanStart < text.length()); } while (spanStart < text.length());
} else { } else {
if (DEBUG) Log.d(LOGTAG, ". . . sendTextToGecko: IME_ADD_RANGE, 0, " + text.length() + if (DEBUG) Log.d(LOGTAG, ". . . sendTextToGecko: IME_ADD_RANGE, 0, " + text.length()
", IME_RANGE_RAWINPUT, IME_RANGE_UNDERLINE)"); + ", IME_RANGE_RAWINPUT, IME_RANGE_UNDERLINE)");
GeckoAppShell.sendEventToGecko( GeckoAppShell.sendEventToGecko(
GeckoEvent.createIMERangeEvent(0, text == null ? 0 : text.length(), GeckoEvent.createIMERangeEvent(0, text == null ? 0 : text.length(),
GeckoEvent.IME_RANGE_RAWINPUT, GeckoEvent.IME_RANGE_RAWINPUT,
@ -573,16 +567,13 @@ public class GeckoInputConnection
text.toString())); text.toString()));
} }
public void afterTextChanged(Editable s) public void afterTextChanged(Editable s) {
{
} }
public void beforeTextChanged(CharSequence s, int start, int count, int after) public void beforeTextChanged(CharSequence s, int start, int count, int after) {
{
} }
public InputConnection onCreateInputConnection(EditorInfo outAttrs) public InputConnection onCreateInputConnection(EditorInfo outAttrs) {
{
outAttrs.inputType = InputType.TYPE_CLASS_TEXT; outAttrs.inputType = InputType.TYPE_CLASS_TEXT;
outAttrs.imeOptions = EditorInfo.IME_ACTION_NONE; outAttrs.imeOptions = EditorInfo.IME_ACTION_NONE;
outAttrs.actionLabel = null; outAttrs.actionLabel = null;
@ -799,8 +790,7 @@ public class GeckoInputConnection
} }
public void notifyIMEEnabled(int state, String typeHint, public void notifyIMEEnabled(int state, String typeHint,
String actionHint, boolean landscapeFS) String actionHint, boolean landscapeFS) {
{
View v = GeckoApp.mAppContext.getLayerController().getView(); View v = GeckoApp.mAppContext.getLayerController().getView();
if (v == null) if (v == null)
@ -815,7 +805,6 @@ public class GeckoInputConnection
IMEStateUpdater.enableIME(); IMEStateUpdater.enableIME();
} }
public void notifyIMEChange(String text, int start, int end, int newEnd) { public void notifyIMEChange(String text, int start, int end, int newEnd) {
View v = GeckoApp.mAppContext.getLayerController().getView(); View v = GeckoApp.mAppContext.getLayerController().getView();
@ -837,7 +826,8 @@ public class GeckoInputConnection
mSelectionLength = selectionLength; mSelectionLength = selectionLength;
try { try {
mQueryResult.put(result); mQueryResult.put(result);
} catch (InterruptedException e) {} } catch (InterruptedException e) {
}
} }
static private final Timer mIMETimer = new Timer("GeckoInputConnection Timer"); static private final Timer mIMETimer = new Timer("GeckoInputConnection Timer");
@ -847,10 +837,8 @@ public class GeckoInputConnection
static private final int NOTIFY_IME_CANCELCOMPOSITION = 2; static private final int NOTIFY_IME_CANCELCOMPOSITION = 2;
static private final int NOTIFY_IME_FOCUSCHANGE = 3; static private final int NOTIFY_IME_FOCUSCHANGE = 3;
/* Delay updating IME states (see bug 573800) */ /* Delay updating IME states (see bug 573800) */
private static final class IMEStateUpdater extends TimerTask private static final class IMEStateUpdater extends TimerTask {
{
static private IMEStateUpdater instance; static private IMEStateUpdater instance;
private boolean mEnable, mReset; private boolean mEnable, mReset;
@ -872,12 +860,12 @@ public class GeckoInputConnection
public void run() { public void run() {
if (DEBUG) Log.d(LOGTAG, "IME: run()"); if (DEBUG) Log.d(LOGTAG, "IME: run()");
synchronized(IMEStateUpdater.class) { synchronized (IMEStateUpdater.class) {
instance = null; instance = null;
} }
View v = GeckoApp.mAppContext.getLayerController().getView(); View v = GeckoApp.mAppContext.getLayerController().getView();
if (DEBUG) Log.d(LOGTAG, "IME: v="+v); if (DEBUG) Log.d(LOGTAG, "IME: v=" + v);
InputMethodManager imm = (InputMethodManager) v.getContext().getSystemService(Context.INPUT_METHOD_SERVICE); InputMethodManager imm = (InputMethodManager) v.getContext().getSystemService(Context.INPUT_METHOD_SERVICE);
if (imm == null) if (imm == null)
@ -897,16 +885,14 @@ public class GeckoInputConnection
} }
} }
public void setEditable(String contents) public void setEditable(String contents) {
{
mEditable.removeSpan(this); mEditable.removeSpan(this);
mEditable.replace(0, mEditable.length(), contents); mEditable.replace(0, mEditable.length(), contents);
mEditable.setSpan(this, 0, contents.length(), Spanned.SPAN_INCLUSIVE_INCLUSIVE); mEditable.setSpan(this, 0, contents.length(), Spanned.SPAN_INCLUSIVE_INCLUSIVE);
Selection.setSelection(mEditable, contents.length()); Selection.setSelection(mEditable, contents.length());
} }
public void initEditable(String contents) public void initEditable(String contents) {
{
mEditable = mEditableFactory.newEditable(contents); mEditable = mEditableFactory.newEditable(contents);
mEditable.setSpan(this, 0, contents.length(), Spanned.SPAN_INCLUSIVE_INCLUSIVE); mEditable.setSpan(this, 0, contents.length(), Spanned.SPAN_INCLUSIVE_INCLUSIVE);
Selection.setSelection(mEditable, contents.length()); Selection.setSelection(mEditable, contents.length());
@ -953,9 +939,7 @@ public class GeckoInputConnection
SynchronousQueue<String> mQueryResult; SynchronousQueue<String> mQueryResult;
} }
class DebugGeckoInputConnection class DebugGeckoInputConnection extends GeckoInputConnection {
extends GeckoInputConnection
{
public DebugGeckoInputConnection(View targetView) { public DebugGeckoInputConnection(View targetView) {
super(targetView); super(targetView);
} }
@ -986,7 +970,7 @@ class DebugGeckoInputConnection
@Override @Override
public boolean deleteSurroundingText(int leftLength, int rightLength) { public boolean deleteSurroundingText(int leftLength, int rightLength) {
Log.d(LOGTAG, "IME: deleteSurroundingText(leftLen=" + leftLength +", rightLen=" + rightLength + ")"); Log.d(LOGTAG, "IME: deleteSurroundingText(leftLen=" + leftLength + ", rightLen=" + rightLength + ")");
return super.deleteSurroundingText(leftLength, rightLength); return super.deleteSurroundingText(leftLength, rightLength);
} }
@ -1059,7 +1043,7 @@ class DebugGeckoInputConnection
Log.d(LOGTAG, ". . . getComposingText: Composing text = \"" + s + "\""); Log.d(LOGTAG, ". . . getComposingText: Composing text = \"" + s + "\"");
return s; return s;
} }
@Override @Override
public boolean onKeyDel() { public boolean onKeyDel() {
Log.d(LOGTAG, "IME: onKeyDel"); Log.d(LOGTAG, "IME: onKeyDel");
@ -1088,29 +1072,25 @@ class DebugGeckoInputConnection
} }
@Override @Override
public void onTextChanged(CharSequence s, int start, int before, int count) public void onTextChanged(CharSequence s, int start, int before, int count) {
{
Log.d(LOGTAG, String.format("IME: onTextChanged(\"%s\" start=%d, before=%d, count=%d)", s, start, before, count)); Log.d(LOGTAG, String.format("IME: onTextChanged(\"%s\" start=%d, before=%d, count=%d)", s, start, before, count));
super.onTextChanged(s, start, before, count); super.onTextChanged(s, start, before, count);
} }
@Override @Override
public void afterTextChanged(Editable s) public void afterTextChanged(Editable s) {
{
Log.d(LOGTAG, "IME: afterTextChanged(\"" + s + "\")"); Log.d(LOGTAG, "IME: afterTextChanged(\"" + s + "\")");
super.afterTextChanged(s); super.afterTextChanged(s);
} }
@Override @Override
public void beforeTextChanged(CharSequence s, int start, int count, int after) public void beforeTextChanged(CharSequence s, int start, int count, int after) {
{
Log.d(LOGTAG, String.format("IME: beforeTextChanged(\"%s\", start=%d, count=%d, after=%d)", s, start, count, after)); Log.d(LOGTAG, String.format("IME: beforeTextChanged(\"%s\", start=%d, count=%d, after=%d)", s, start, count, after));
super.beforeTextChanged(s, start, count, after); super.beforeTextChanged(s, start, count, after);
} }
@Override @Override
public InputConnection onCreateInputConnection(EditorInfo outAttrs) public InputConnection onCreateInputConnection(EditorInfo outAttrs) {
{
Log.d(LOGTAG, "IME: handleCreateInputConnection called"); Log.d(LOGTAG, "IME: handleCreateInputConnection called");
return super.onCreateInputConnection(outAttrs); return super.onCreateInputConnection(outAttrs);
} }