am 34301f69: am 6f80ed39: Merge "Rename LatinImeLogger to DebugFlags" into lmp-dev

* commit '34301f69a1e47fb6f7ee5498815dd30cad488921':
  Rename LatinImeLogger to DebugFlags
main
Tadashi G. Takaoka 2014-07-17 18:36:00 +00:00 committed by Android Git Automerger
commit 68fffa73b4
19 changed files with 53 additions and 40 deletions

View File

@ -23,9 +23,9 @@ import android.text.Spanned;
import android.text.TextUtils;
import android.text.style.SuggestionSpan;
import com.android.inputmethod.latin.LatinImeLogger;
import com.android.inputmethod.latin.SuggestedWords;
import com.android.inputmethod.latin.SuggestedWords.SuggestedWordInfo;
import com.android.inputmethod.latin.define.DebugFlags;
import com.android.inputmethod.latin.SuggestionSpanPickedNotificationReceiver;
import java.lang.reflect.Field;
@ -40,7 +40,7 @@ public final class SuggestionSpanUtils {
null /* receiver */, null /* defaultValue */, FIELD_FLAG_AUTO_CORRECTION);
static {
if (LatinImeLogger.sDBG) {
if (DebugFlags.DEBUG_ENABLED) {
if (OBJ_FLAG_AUTO_CORRECTION == null) {
throw new RuntimeException("Field is accidentially null.");
}

View File

@ -36,9 +36,9 @@ import com.android.inputmethod.keyboard.internal.KeyboardBuilder;
import com.android.inputmethod.keyboard.internal.KeyboardParams;
import com.android.inputmethod.keyboard.internal.KeysCache;
import com.android.inputmethod.latin.InputAttributes;
import com.android.inputmethod.latin.LatinImeLogger;
import com.android.inputmethod.latin.R;
import com.android.inputmethod.latin.SubtypeSwitcher;
import com.android.inputmethod.latin.define.DebugFlags;
import com.android.inputmethod.latin.utils.InputTypeUtils;
import com.android.inputmethod.latin.utils.ScriptUtils;
import com.android.inputmethod.latin.utils.SubtypeLocaleUtils;
@ -60,7 +60,7 @@ import java.util.HashMap;
*/
public final class KeyboardLayoutSet {
private static final String TAG = KeyboardLayoutSet.class.getSimpleName();
private static final boolean DEBUG_CACHE = LatinImeLogger.sDBG;
private static final boolean DEBUG_CACHE = DebugFlags.DEBUG_ENABLED;
private static final String TAG_KEYBOARD_SET = "KeyboardLayoutSet";
private static final String TAG_ELEMENT = "Element";

View File

@ -33,8 +33,8 @@ import com.android.inputmethod.keyboard.internal.PointerTrackerQueue;
import com.android.inputmethod.keyboard.internal.TypingTimeRecorder;
import com.android.inputmethod.latin.Constants;
import com.android.inputmethod.latin.InputPointers;
import com.android.inputmethod.latin.LatinImeLogger;
import com.android.inputmethod.latin.R;
import com.android.inputmethod.latin.define.DebugFlags;
import com.android.inputmethod.latin.settings.Settings;
import com.android.inputmethod.latin.utils.CoordinateUtils;
import com.android.inputmethod.latin.utils.ResourceUtils;
@ -47,7 +47,7 @@ public final class PointerTracker implements PointerTrackerQueue.Element,
private static final boolean DEBUG_EVENT = false;
private static final boolean DEBUG_MOVE_EVENT = false;
private static final boolean DEBUG_LISTENER = false;
private static boolean DEBUG_MODE = LatinImeLogger.sDBG || DEBUG_EVENT;
private static boolean DEBUG_MODE = DebugFlags.DEBUG_ENABLED || DEBUG_EVENT;
public interface DrawingProxy {
public void invalidateKey(Key key);

View File

@ -21,13 +21,13 @@ import android.util.DisplayMetrics;
import android.util.Log;
import com.android.inputmethod.latin.Constants;
import com.android.inputmethod.latin.LatinImeLogger;
import com.android.inputmethod.latin.R;
import com.android.inputmethod.latin.define.DebugFlags;
// This hack is applied to certain classes of tablets.
public final class BogusMoveEventDetector {
private static final String TAG = BogusMoveEventDetector.class.getSimpleName();
private static final boolean DEBUG_MODE = LatinImeLogger.sDBG;
private static final boolean DEBUG_MODE = DebugFlags.DEBUG_ENABLED;
// Move these thresholds to resource.
// These thresholds' unit is a diagonal length of a key.

View File

@ -20,7 +20,7 @@ import android.text.TextUtils;
import com.android.inputmethod.keyboard.Key;
import com.android.inputmethod.latin.Constants;
import com.android.inputmethod.latin.LatinImeLogger;
import com.android.inputmethod.latin.define.DebugFlags;
import com.android.inputmethod.latin.utils.CollectionUtils;
import com.android.inputmethod.latin.utils.StringUtils;
@ -110,7 +110,7 @@ public final class MoreKeySpec {
}
}
private static final boolean DEBUG = LatinImeLogger.sDBG;
private static final boolean DEBUG = DebugFlags.DEBUG_ENABLED;
// Constants for parsing.
private static final char COMMA = Constants.CODE_COMMA;
private static final char BACKSLASH = Constants.CODE_BACKSLASH;

View File

@ -17,7 +17,7 @@
package com.android.inputmethod.keyboard.internal;
import com.android.inputmethod.annotations.UsedForTesting;
import com.android.inputmethod.latin.LatinImeLogger;
import com.android.inputmethod.latin.define.DebugFlags;
public final class TouchPositionCorrection {
private static final int TOUCH_POSITION_CORRECTION_RECORD_SIZE = 3;
@ -30,7 +30,7 @@ public final class TouchPositionCorrection {
public void load(final String[] data) {
final int dataLength = data.length;
if (dataLength % TOUCH_POSITION_CORRECTION_RECORD_SIZE != 0) {
if (LatinImeLogger.sDBG) {
if (DebugFlags.DEBUG_ENABLED) {
throw new RuntimeException(
"the size of touch position correction data is invalid");
}
@ -56,7 +56,7 @@ public final class TouchPositionCorrection {
}
mEnabled = dataLength > 0;
} catch (NumberFormatException e) {
if (LatinImeLogger.sDBG) {
if (DebugFlags.DEBUG_ENABLED) {
throw new RuntimeException(
"the number format for touch position correction data is invalid");
}

View File

@ -20,6 +20,7 @@ import android.util.Log;
import android.util.SparseIntArray;
import com.android.inputmethod.annotations.UsedForTesting;
import com.android.inputmethod.latin.define.DebugFlags;
import com.android.inputmethod.latin.utils.ResizableIntArray;
// TODO: This class is not thread-safe.
@ -60,7 +61,7 @@ public final class InputPointers {
mXCoordinates.addAt(index, x);
mYCoordinates.addAt(index, y);
mPointerIds.addAt(index, pointerId);
if (LatinImeLogger.sDBG || DEBUG_TIME) {
if (DebugFlags.DEBUG_ENABLED || DEBUG_TIME) {
fillWithLastTimeUntil(index);
}
mTimes.addAt(index, time);
@ -145,7 +146,7 @@ public final class InputPointers {
}
public int[] getTimes() {
if (LatinImeLogger.sDBG || DEBUG_TIME) {
if (DebugFlags.DEBUG_ENABLED || DEBUG_TIME) {
if (!isValidTimeStamps()) {
throw new RuntimeException("Time stamps are invalid.");
}

View File

@ -37,6 +37,7 @@ import android.net.ConnectivityManager;
import android.os.Debug;
import android.os.IBinder;
import android.os.Message;
import android.preference.PreferenceManager;
import android.text.InputType;
import android.text.TextUtils;
import android.util.Log;
@ -67,6 +68,7 @@ import com.android.inputmethod.keyboard.KeyboardSwitcher;
import com.android.inputmethod.keyboard.MainKeyboardView;
import com.android.inputmethod.latin.Suggest.OnGetSuggestedWordsCallback;
import com.android.inputmethod.latin.SuggestedWords.SuggestedWordInfo;
import com.android.inputmethod.latin.define.DebugFlags;
import com.android.inputmethod.latin.define.ProductionFlag;
import com.android.inputmethod.latin.inputlogic.InputLogic;
import com.android.inputmethod.latin.personalization.ContextualDictionaryUpdater;
@ -516,7 +518,7 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
@Override
public void onCreate() {
Settings.init(this);
LatinImeLogger.init(this);
DebugFlags.init(PreferenceManager.getDefaultSharedPreferences(this));
RichInputMethodManager.init(this);
mRichImm = RichInputMethodManager.getInstance();
SubtypeSwitcher.init(this);
@ -528,7 +530,7 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
super.onCreate();
mHandler.onCreate();
DEBUG = LatinImeLogger.sDBG;
DEBUG = DebugFlags.DEBUG_ENABLED;
// TODO: Resolve mutual dependencies of {@link #loadSettings()} and {@link #initSuggest()}.
loadSettings();
@ -764,7 +766,7 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
if (editorInfo == null) {
Log.e(TAG, "Null EditorInfo in onStartInputView()");
if (LatinImeLogger.sDBG) {
if (DebugFlags.DEBUG_ENABLED) {
throw new NullPointerException("Null EditorInfo in onStartInputView()");
}
return;

View File

@ -35,6 +35,7 @@ import com.android.inputmethod.annotations.UsedForTesting;
import com.android.inputmethod.compat.InputMethodSubtypeCompatUtils;
import com.android.inputmethod.keyboard.KeyboardSwitcher;
import com.android.inputmethod.keyboard.internal.LanguageOnSpacebarHelper;
import com.android.inputmethod.latin.define.DebugFlags;
import com.android.inputmethod.latin.utils.LocaleUtils;
import com.android.inputmethod.latin.utils.SubtypeLocaleUtils;
@ -45,7 +46,7 @@ import java.util.Map;
import java.util.Set;
public final class SubtypeSwitcher {
private static boolean DBG = LatinImeLogger.sDBG;
private static boolean DBG = DebugFlags.DEBUG_ENABLED;
private static final String TAG = SubtypeSwitcher.class.getSimpleName();
private static final SubtypeSwitcher sInstance = new SubtypeSwitcher();

View File

@ -20,6 +20,7 @@ import android.text.TextUtils;
import com.android.inputmethod.keyboard.ProximityInfo;
import com.android.inputmethod.latin.SuggestedWords.SuggestedWordInfo;
import com.android.inputmethod.latin.define.DebugFlags;
import com.android.inputmethod.latin.settings.SettingsValuesForSuggestion;
import com.android.inputmethod.latin.utils.AutoCorrectionUtils;
import com.android.inputmethod.latin.utils.BinaryDictionaryUtils;
@ -50,7 +51,7 @@ public final class Suggest {
// Close to -2**31
private static final int SUPPRESS_SUGGEST_THRESHOLD = -2000000000;
private static final boolean DBG = LatinImeLogger.sDBG;
private static final boolean DBG = DebugFlags.DEBUG_ENABLED;
private final DictionaryFacilitator mDictionaryFacilitator;
private float mAutoCorrectionThreshold;

View File

@ -19,6 +19,7 @@ package com.android.inputmethod.latin;
import android.text.TextUtils;
import android.view.inputmethod.CompletionInfo;
import com.android.inputmethod.latin.define.DebugFlags;
import com.android.inputmethod.latin.utils.StringUtils;
import java.util.ArrayList;
@ -130,7 +131,7 @@ public class SuggestedWords {
}
public String getDebugString(final int pos) {
if (!LatinImeLogger.sDBG) {
if (!DebugFlags.DEBUG_ENABLED) {
return null;
}
final SuggestedWordInfo wordInfo = getInfo(pos);

View File

@ -22,8 +22,10 @@ import android.content.Intent;
import android.text.style.SuggestionSpan;
import android.util.Log;
import com.android.inputmethod.latin.define.DebugFlags;
public final class SuggestionSpanPickedNotificationReceiver extends BroadcastReceiver {
private static final boolean DBG = LatinImeLogger.sDBG;
private static final boolean DBG = DebugFlags.DEBUG_ENABLED;
private static final String TAG =
SuggestionSpanPickedNotificationReceiver.class.getSimpleName();

View File

@ -18,6 +18,7 @@ package com.android.inputmethod.latin;
import com.android.inputmethod.event.CombinerChain;
import com.android.inputmethod.event.Event;
import com.android.inputmethod.latin.define.DebugFlags;
import com.android.inputmethod.latin.utils.CoordinateUtils;
import com.android.inputmethod.latin.utils.StringUtils;
@ -29,7 +30,7 @@ import java.util.Collections;
*/
public final class WordComposer {
private static final int MAX_WORD_LENGTH = Constants.DICTIONARY_MAX_WORD_LENGTH;
private static final boolean DBG = LatinImeLogger.sDBG;
private static final boolean DBG = DebugFlags.DEBUG_ENABLED;
public static final int CAPS_MODE_OFF = 0;
// 1 is shift bit, 2 is caps bit, 4 is auto bit but this is just a convention as these bits

View File

@ -1,5 +1,5 @@
/*
* Copyright (C) 2010 The Android Open Source Project
* Copyright (C) 2014 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.
@ -14,14 +14,18 @@
* limitations under the License.
*/
package com.android.inputmethod.latin;
package com.android.inputmethod.latin.define;
import android.content.Context;
import android.content.SharedPreferences;
// TODO: Rename this class name to make it more relevant.
public final class LatinImeLogger {
public static final boolean sDBG = false;
public final class DebugFlags {
public static final boolean DEBUG_ENABLED = false;
public static void init(Context context) {
private DebugFlags() {
// This class is not publicly instantiable.
}
@SuppressWarnings("unused")
public static void init(final SharedPreferences prefs) {
}
}

View File

@ -37,7 +37,6 @@ import com.android.inputmethod.latin.DictionaryFacilitator;
import com.android.inputmethod.latin.InputPointers;
import com.android.inputmethod.latin.LastComposedWord;
import com.android.inputmethod.latin.LatinIME;
import com.android.inputmethod.latin.LatinImeLogger;
import com.android.inputmethod.latin.PrevWordsInfo;
import com.android.inputmethod.latin.RichInputConnection;
import com.android.inputmethod.latin.Suggest;
@ -45,6 +44,7 @@ import com.android.inputmethod.latin.Suggest.OnGetSuggestedWordsCallback;
import com.android.inputmethod.latin.SuggestedWords;
import com.android.inputmethod.latin.SuggestedWords.SuggestedWordInfo;
import com.android.inputmethod.latin.WordComposer;
import com.android.inputmethod.latin.define.DebugFlags;
import com.android.inputmethod.latin.settings.SettingsValues;
import com.android.inputmethod.latin.settings.SettingsValuesForSuggestion;
import com.android.inputmethod.latin.settings.SpacingAndPunctuations;
@ -1434,7 +1434,7 @@ public final class InputLogic {
final int separatorLength = mLastComposedWord.mSeparatorString.length();
// TODO: should we check our saved separator against the actual contents of the text view?
final int deleteLength = cancelLength + separatorLength;
if (LatinImeLogger.sDBG) {
if (DebugFlags.DEBUG_ENABLED) {
if (mWordComposer.isComposingWord()) {
throw new RuntimeException("revertCommit, but we are composing a word");
}

View File

@ -45,11 +45,11 @@ import android.widget.LinearLayout;
import android.widget.TextView;
import com.android.inputmethod.accessibility.AccessibilityUtils;
import com.android.inputmethod.latin.LatinImeLogger;
import com.android.inputmethod.latin.PunctuationSuggestions;
import com.android.inputmethod.latin.R;
import com.android.inputmethod.latin.SuggestedWords;
import com.android.inputmethod.latin.SuggestedWords.SuggestedWordInfo;
import com.android.inputmethod.latin.define.DebugFlags;
import com.android.inputmethod.latin.utils.AutoCorrectionUtils;
import com.android.inputmethod.latin.utils.ResourceUtils;
import com.android.inputmethod.latin.utils.SubtypeLocaleUtils;
@ -264,7 +264,7 @@ final class SuggestionStripLayoutHelper {
} else {
color = mColorSuggested;
}
if (LatinImeLogger.sDBG && suggestedWords.size() > 1) {
if (DebugFlags.DEBUG_ENABLED && suggestedWords.size() > 1) {
// If we auto-correct, then the autocorrection is in slot 0 and the typed word
// is in slot 1.
if (positionInStrip == mCenterPositionInStrip

View File

@ -43,10 +43,10 @@ import com.android.inputmethod.keyboard.MainKeyboardView;
import com.android.inputmethod.keyboard.MoreKeysPanel;
import com.android.inputmethod.latin.AudioAndHapticFeedbackManager;
import com.android.inputmethod.latin.Constants;
import com.android.inputmethod.latin.LatinImeLogger;
import com.android.inputmethod.latin.R;
import com.android.inputmethod.latin.SuggestedWords;
import com.android.inputmethod.latin.SuggestedWords.SuggestedWordInfo;
import com.android.inputmethod.latin.define.DebugFlags;
import com.android.inputmethod.latin.settings.Settings;
import com.android.inputmethod.latin.settings.SettingsValues;
import com.android.inputmethod.latin.suggestions.MoreSuggestionsView.MoreSuggestionsListener;
@ -63,7 +63,7 @@ public final class SuggestionStripView extends RelativeLayout implements OnClick
public void onCodeInput(int primaryCode, int x, int y, boolean isKeyRepeat);
}
static final boolean DBG = LatinImeLogger.sDBG;
static final boolean DBG = DebugFlags.DEBUG_ENABLED;
private static final float DEBUG_INFO_TEXT_SIZE_IN_DIP = 6.0f;
private final ViewGroup mSuggestionsStrip;

View File

@ -18,11 +18,11 @@ package com.android.inputmethod.latin.utils;
import android.util.Log;
import com.android.inputmethod.latin.LatinImeLogger;
import com.android.inputmethod.latin.SuggestedWords.SuggestedWordInfo;
import com.android.inputmethod.latin.define.DebugFlags;
public final class AutoCorrectionUtils {
private static final boolean DBG = LatinImeLogger.sDBG;
private static final boolean DBG = DebugFlags.DEBUG_ENABLED;
private static final String TAG = AutoCorrectionUtils.class.getSimpleName();
private static final int MINIMUM_SAFETY_NET_CHAR_LENGTH = 4;

View File

@ -18,14 +18,14 @@ package com.android.inputmethod.latin.utils;
import android.util.Log;
import com.android.inputmethod.latin.LatinImeLogger;
import com.android.inputmethod.latin.define.DebugFlags;
/**
* A class for logging and debugging utility methods.
*/
public final class DebugLogUtils {
private final static String TAG = DebugLogUtils.class.getSimpleName();
private final static boolean sDBG = LatinImeLogger.sDBG;
private final static boolean sDBG = DebugFlags.DEBUG_ENABLED;
/**
* Calls .toString() on its non-null argument or returns "null"