Fix some warnings

Change-Id: I7290cd1fb675a1b85b9b6ac2d464c932b5bca1dd
main
Jean Chalard 2013-07-30 16:00:43 +09:00
parent f8c1aefd90
commit 93445b4821
20 changed files with 36 additions and 52 deletions

View File

@ -32,8 +32,6 @@ import java.lang.reflect.Field;
import java.util.ArrayList; import java.util.ArrayList;
public final class SuggestionSpanUtils { public final class SuggestionSpanUtils {
private static final String TAG = SuggestionSpanUtils.class.getSimpleName();
// Note that SuggestionSpan.FLAG_AUTO_CORRECTION has been introduced // Note that SuggestionSpan.FLAG_AUTO_CORRECTION has been introduced
// in API level 15 (Build.VERSION_CODES.ICE_CREAM_SANDWICH_MR1). // in API level 15 (Build.VERSION_CODES.ICE_CREAM_SANDWICH_MR1).
public static final Field FIELD_FLAG_AUTO_CORRECTION = CompatUtils.getField( public static final Field FIELD_FLAG_AUTO_CORRECTION = CompatUtils.getField(
@ -60,7 +58,7 @@ public final class SuggestionSpanUtils {
} }
final Spannable spannable = new SpannableString(text); final Spannable spannable = new SpannableString(text);
final SuggestionSpan suggestionSpan = new SuggestionSpan(context, null /* locale */, final SuggestionSpan suggestionSpan = new SuggestionSpan(context, null /* locale */,
new String[] {} /* suggestions */, (int)OBJ_FLAG_AUTO_CORRECTION, new String[] {} /* suggestions */, OBJ_FLAG_AUTO_CORRECTION,
SuggestionSpanPickedNotificationReceiver.class); SuggestionSpanPickedNotificationReceiver.class);
spannable.setSpan(suggestionSpan, 0, text.length(), spannable.setSpan(suggestionSpan, 0, text.length(),
Spanned.SPAN_EXCLUSIVE_EXCLUSIVE | Spanned.SPAN_COMPOSING); Spanned.SPAN_EXCLUSIVE_EXCLUSIVE | Spanned.SPAN_COMPOSING);

View File

@ -54,7 +54,6 @@ public final class DictionaryProvider extends ContentProvider {
private static final String QUERY_PARAMETER_MAY_PROMPT_USER = "mayPrompt"; private static final String QUERY_PARAMETER_MAY_PROMPT_USER = "mayPrompt";
private static final String QUERY_PARAMETER_TRUE = "true"; private static final String QUERY_PARAMETER_TRUE = "true";
private static final String QUERY_PARAMETER_DELETE_RESULT = "result"; private static final String QUERY_PARAMETER_DELETE_RESULT = "result";
private static final String QUERY_PARAMETER_SUCCESS = "success";
private static final String QUERY_PARAMETER_FAILURE = "failure"; private static final String QUERY_PARAMETER_FAILURE = "failure";
public static final String QUERY_PARAMETER_PROTOCOL_VERSION = "protocol"; public static final String QUERY_PARAMETER_PROTOCOL_VERSION = "protocol";
private static final int NO_MATCH = 0; private static final int NO_MATCH = 0;

View File

@ -50,8 +50,6 @@ import java.util.concurrent.TimeUnit;
* to access, and mark the current state as such. * to access, and mark the current state as such.
*/ */
public final class DictionaryService extends Service { public final class DictionaryService extends Service {
private static final String TAG = DictionaryService.class.getName();
/** /**
* The package name, to use in the intent actions. * The package name, to use in the intent actions.
*/ */

View File

@ -21,8 +21,6 @@ import android.content.Context;
import android.content.Intent; import android.content.Intent;
public final class EventHandler extends BroadcastReceiver { public final class EventHandler extends BroadcastReceiver {
private static final String TAG = EventHandler.class.getName();
/** /**
* Receives a intent broadcast. * Receives a intent broadcast.
* *

View File

@ -29,8 +29,8 @@ import com.android.inputmethod.latin.utils.RecapitalizeStatus;
* *
* The input events are {@link #onLoadKeyboard()}, {@link #onSaveKeyboardState()}, * The input events are {@link #onLoadKeyboard()}, {@link #onSaveKeyboardState()},
* {@link #onPressKey(int,boolean,int)}, {@link #onReleaseKey(int,boolean)}, * {@link #onPressKey(int,boolean,int)}, {@link #onReleaseKey(int,boolean)},
* {@link #onCodeInput(int,int)}, {@link #onFinishSlidingInput()}, {@link #onCancelInput()}, * {@link #onCodeInput(int,int)}, {@link #onFinishSlidingInput()},
* {@link #onUpdateShiftState(int,int)}. * {@link #onUpdateShiftState(int,int)}, {@link #onResetKeyboardStateToAlphabet()}.
* *
* The actions are {@link SwitchActions}'s methods. * The actions are {@link SwitchActions}'s methods.
*/ */

View File

@ -30,7 +30,6 @@ import java.util.Arrays;
public class MatrixUtils { public class MatrixUtils {
private static final String TAG = MatrixUtils.class.getSimpleName(); private static final String TAG = MatrixUtils.class.getSimpleName();
public static class MatrixOperationFailedException extends Exception { public static class MatrixOperationFailedException extends Exception {
private static final String TAG = MatrixOperationFailedException.class.getSimpleName();
private static final long serialVersionUID = 4384485606788583829L; private static final long serialVersionUID = 4384485606788583829L;
public MatrixOperationFailedException(String msg) { public MatrixOperationFailedException(String msg) {

View File

@ -62,7 +62,7 @@ public class SmoothingUtils {
for (int j = 0; j < COEFF_COUNT; ++j) { for (int j = 0; j < COEFF_COUNT; ++j) {
final int pow = i + j; final int pow = i + j;
for (int k = 0; k < N; ++k) { for (int k = 0; k < N; ++k) {
m0[i][j] += (float) Math.pow((double) xs[k], pow); m0[i][j] += (float) Math.pow(xs[k], pow);
} }
} }
} }

View File

@ -18,7 +18,6 @@ package com.android.inputmethod.latin;
import android.content.Context; import android.content.Context;
import android.content.SharedPreferences; import android.content.SharedPreferences;
import android.content.pm.PackageManager;
import android.content.res.AssetFileDescriptor; import android.content.res.AssetFileDescriptor;
import android.util.Log; import android.util.Log;

View File

@ -982,6 +982,7 @@ public final class BinaryDictIOUtils {
return null; return null;
} }
private static final int HEADER_READING_BUFFER_SIZE = 16384;
/** /**
* Convenience method to read the header of a binary file. * Convenience method to read the header of a binary file.
* *
@ -991,7 +992,6 @@ public final class BinaryDictIOUtils {
* @param offset The offset in the file where to start reading the data. * @param offset The offset in the file where to start reading the data.
* @param length The length of the data file. * @param length The length of the data file.
*/ */
private static final int HEADER_READING_BUFFER_SIZE = 16384;
public static FileHeader getDictionaryFileHeader( public static FileHeader getDictionaryFileHeader(
final File file, final long offset, final long length) final File file, final long offset, final long length)
throws FileNotFoundException, IOException, UnsupportedFormatException { throws FileNotFoundException, IOException, UnsupportedFormatException {

View File

@ -34,6 +34,8 @@ import java.util.LinkedList;
public final class FusionDictionary implements Iterable<Word> { public final class FusionDictionary implements Iterable<Word> {
private static final boolean DBG = MakedictLog.DBG; private static final boolean DBG = MakedictLog.DBG;
private static int CHARACTER_NOT_FOUND_INDEX = -1;
/** /**
* A node of the dictionary, containing several CharGroups. * A node of the dictionary, containing several CharGroups.
* *
@ -473,7 +475,7 @@ public final class FusionDictionary implements Iterable<Word> {
CharGroup currentGroup = null; CharGroup currentGroup = null;
int differentCharIndex = 0; // Set by the loop to the index of the char that differs int differentCharIndex = 0; // Set by the loop to the index of the char that differs
int nodeIndex = findIndexOfChar(mRoot, word[charIndex]); int nodeIndex = findIndexOfChar(mRoot, word[charIndex]);
while (CHARACTER_NOT_FOUND != nodeIndex) { while (CHARACTER_NOT_FOUND_INDEX != nodeIndex) {
currentGroup = currentNode.mData.get(nodeIndex); currentGroup = currentNode.mData.get(nodeIndex);
differentCharIndex = compareArrays(currentGroup.mChars, word, charIndex); differentCharIndex = compareArrays(currentGroup.mChars, word, charIndex);
if (ARRAYS_ARE_EQUAL != differentCharIndex if (ARRAYS_ARE_EQUAL != differentCharIndex
@ -485,7 +487,7 @@ public final class FusionDictionary implements Iterable<Word> {
nodeIndex = findIndexOfChar(currentNode, word[charIndex]); nodeIndex = findIndexOfChar(currentNode, word[charIndex]);
} }
if (-1 == nodeIndex) { if (CHARACTER_NOT_FOUND_INDEX == nodeIndex) {
// No node at this point to accept the word. Create one. // No node at this point to accept the word. Create one.
final int insertionIndex = findInsertionIndex(currentNode, word[charIndex]); final int insertionIndex = findInsertionIndex(currentNode, word[charIndex]);
final CharGroup newGroup = new CharGroup( final CharGroup newGroup = new CharGroup(
@ -612,20 +614,18 @@ public final class FusionDictionary implements Iterable<Word> {
return result >= 0 ? result : -result - 1; return result >= 0 ? result : -result - 1;
} }
private static int CHARACTER_NOT_FOUND = -1;
/** /**
* Find the index of a char in a node, if it exists. * Find the index of a char in a node, if it exists.
* *
* @param node the node to search in. * @param node the node to search in.
* @param character the character to search for. * @param character the character to search for.
* @return the position of the character if it's there, or CHARACTER_NOT_FOUND = -1 else. * @return the position of the character if it's there, or CHARACTER_NOT_FOUND_INDEX = -1 else.
*/ */
private static int findIndexOfChar(final Node node, int character) { private static int findIndexOfChar(final Node node, int character) {
final int insertionIndex = findInsertionIndex(node, character); final int insertionIndex = findInsertionIndex(node, character);
if (node.mData.size() <= insertionIndex) return CHARACTER_NOT_FOUND; if (node.mData.size() <= insertionIndex) return CHARACTER_NOT_FOUND_INDEX;
return character == node.mData.get(insertionIndex).mChars[0] ? insertionIndex return character == node.mData.get(insertionIndex).mChars[0] ? insertionIndex
: CHARACTER_NOT_FOUND; : CHARACTER_NOT_FOUND_INDEX;
} }
/** /**
@ -640,7 +640,7 @@ public final class FusionDictionary implements Iterable<Word> {
CharGroup currentGroup; CharGroup currentGroup;
do { do {
int indexOfGroup = findIndexOfChar(node, codePoints[index]); int indexOfGroup = findIndexOfChar(node, codePoints[index]);
if (CHARACTER_NOT_FOUND == indexOfGroup) return null; if (CHARACTER_NOT_FOUND_INDEX == indexOfGroup) return null;
currentGroup = node.mData.get(indexOfGroup); currentGroup = node.mData.get(indexOfGroup);
if (codePoints.length - index < currentGroup.mChars.length) return null; if (codePoints.length - index < currentGroup.mChars.length) return null;

View File

@ -24,7 +24,7 @@ import android.content.Context;
/** /**
* This class is a dictionary for the personalized language model that uses binary dictionary. * This class is a dictionary for the personalized language model that uses binary dictionary.
*/ */
public class PersonalizationDicitonary extends ExpandableBinaryDictionary { public class PersonalizationDictionary extends ExpandableBinaryDictionary {
private static final String NAME = "personalization"; private static final String NAME = "personalization";
public static void registerUpdateListener(PersonalizationDictionaryUpdateListener listener) { public static void registerUpdateListener(PersonalizationDictionaryUpdateListener listener) {
@ -35,7 +35,7 @@ public class PersonalizationDicitonary extends ExpandableBinaryDictionary {
private final String mLocale; private final String mLocale;
// Singleton // Singleton
private PersonalizationDicitonary(final Context context, final String locale) { private PersonalizationDictionary(final Context context, final String locale) {
super(context, getFilenameWithLocale(NAME, locale), Dictionary.TYPE_PERSONALIZATION); super(context, getFilenameWithLocale(NAME, locale), Dictionary.TYPE_PERSONALIZATION);
mLocale = locale; mLocale = locale;
} }

View File

@ -25,7 +25,7 @@ import android.content.SharedPreferences;
/** /**
* This class is a dictionary for the personalized prediction language model implemented in Java. * This class is a dictionary for the personalized prediction language model implemented in Java.
*/ */
public class PersonalizationPredictionDicitonary extends ExpandableDictionary { public class PersonalizationPredictionDictionary extends ExpandableDictionary {
public static void registerUpdateListener(PersonalizationDictionaryUpdateListener listener) { public static void registerUpdateListener(PersonalizationDictionaryUpdateListener listener) {
// TODO: Implement // TODO: Implement
} }
@ -35,7 +35,7 @@ public class PersonalizationPredictionDicitonary extends ExpandableDictionary {
private final SharedPreferences mPrefs; private final SharedPreferences mPrefs;
// Singleton // Singleton
private PersonalizationPredictionDicitonary(final Context context, final String locale, private PersonalizationPredictionDictionary(final Context context, final String locale,
final SharedPreferences sp) { final SharedPreferences sp) {
super(context, Dictionary.TYPE_PERSONALIZATION_PREDICTION_IN_JAVA); super(context, Dictionary.TYPE_PERSONALIZATION_PREDICTION_IN_JAVA);
mLocale = locale; mLocale = locale;

View File

@ -32,7 +32,6 @@ import com.android.inputmethod.latin.utils.ApplicationUtils;
public final class DebugSettings extends PreferenceFragment public final class DebugSettings extends PreferenceFragment
implements SharedPreferences.OnSharedPreferenceChangeListener { implements SharedPreferences.OnSharedPreferenceChangeListener {
private static final String TAG = DebugSettings.class.getSimpleName();
public static final String PREF_DEBUG_MODE = "debug_mode"; public static final String PREF_DEBUG_MODE = "debug_mode";
public static final String PREF_FORCE_NON_DISTINCT_MULTITOUCH = "force_non_distinct_multitouch"; public static final String PREF_FORCE_NON_DISTINCT_MULTITOUCH = "force_non_distinct_multitouch";

View File

@ -32,7 +32,6 @@ import com.android.inputmethod.latin.SuggestedWords;
import com.android.inputmethod.latin.SuggestedWords.SuggestedWordInfo; import com.android.inputmethod.latin.SuggestedWords.SuggestedWordInfo;
import com.android.inputmethod.latin.utils.CollectionUtils; import com.android.inputmethod.latin.utils.CollectionUtils;
import com.android.inputmethod.latin.utils.InputTypeUtils; import com.android.inputmethod.latin.utils.InputTypeUtils;
import com.android.inputmethod.latin.utils.RunInLocale;
import com.android.inputmethod.latin.utils.StringUtils; import com.android.inputmethod.latin.utils.StringUtils;
import java.util.ArrayList; import java.util.ArrayList;

View File

@ -103,7 +103,7 @@ public class UserDictionaryAddWordFragment extends Fragment
/** /**
* Callback for the framework when a menu option is pressed. * Callback for the framework when a menu option is pressed.
* *
* @param MenuItem the item that was pressed * @param item the item that was pressed
* @return false to allow normal menu processing to proceed, true to consume it here * @return false to allow normal menu processing to proceed, true to consume it here
*/ */
@Override @Override

View File

@ -22,7 +22,7 @@ import java.util.ArrayList;
/** /**
* Utility methods for parsing and serializing Comma-Separated Values. The public APIs of this * Utility methods for parsing and serializing Comma-Separated Values. The public APIs of this
* utility class are {@link #split(String)}, {@link #split(int,String)}, {@link #join(String)}, * utility class are {@link #split(String)}, {@link #split(int,String)}, {@link #join(String...)},
* {@link #join(int,String...)}, and {@link #join(int,int[],String...)}. * {@link #join(int,String...)}, and {@link #join(int,int[],String...)}.
* *
* This class implements CSV parsing and serializing methods conforming to RFC 4180 with an * This class implements CSV parsing and serializing methods conforming to RFC 4180 with an

View File

@ -191,7 +191,7 @@ public final class UsabilityStudyLogUtils {
Log.w(USABILITY_TAG, e2); Log.w(USABILITY_TAG, e2);
return; return;
} }
if (destFile == null || !destFile.exists()) { if (!destFile.exists()) {
Log.w(USABILITY_TAG, "Dest file doesn't exist."); Log.w(USABILITY_TAG, "Dest file doesn't exist.");
return; return;
} }

View File

@ -119,9 +119,9 @@ public abstract class MainLogBuffer extends FixedLogBuffer {
* *
* @param logUnits a LogUnit list to check for publishability * @param logUnits a LogUnit list to check for publishability
* @param nGramSize the smallest n-gram acceptable to be published. if * @param nGramSize the smallest n-gram acceptable to be published. if
* {@link ResearchLogger.IS_LOGGING_EVERYTHING} is true, then publish if there are more than * {@link ResearchLogger#IS_LOGGING_EVERYTHING} is true, then publish if there are more than
* {@code minNGramSize} words in the logUnits, otherwise wait. if {@link * {@code minNGramSize} words in the logUnits, otherwise wait. if {@link
* ResearchLogger.IS_LOGGING_EVERYTHING} is false, then ensure that there are exactly nGramSize * ResearchLogger#IS_LOGGING_EVERYTHING} is false, then ensure that there are exactly nGramSize
* words in the LogUnits. * words in the LogUnits.
* *
* @return one of the {@code PUBLISHABILITY_*} result codes defined in this class. * @return one of the {@code PUBLISHABILITY_*} result codes defined in this class.

View File

@ -315,16 +315,6 @@ public class MotionEventReader {
return pointerCoords; return pointerCoords;
} }
/**
* Tests that {@code x} is uninitialized.
*
* Assumes that {@code x} will never be given a valid value less than 0, and that
* UNINITIALIZED_FLOAT is less than 0.0f.
*/
private boolean isUninitializedFloat(final float x) {
return x < 0.0f;
}
private void addMotionEventData(final ReplayData replayData, final int actionType, private void addMotionEventData(final ReplayData replayData, final int actionType,
final long time, final PointerProperties[] pointerProperties, final long time, final PointerProperties[] pointerProperties,
final PointerCoords[] pointerCoords) { final PointerCoords[] pointerCoords) {

View File

@ -180,7 +180,6 @@ public class ResearchLogger implements SharedPreferences.OnSharedPreferenceChang
private ResearchLogDirectory mResearchLogDirectory; private ResearchLogDirectory mResearchLogDirectory;
private SplashScreen mSplashScreen; private SplashScreen mSplashScreen;
private Intent mUploadIntent;
private Intent mUploadNowIntent; private Intent mUploadNowIntent;
/* package for test */ LogUnit mCurrentLogUnit = new LogUnit(); /* package for test */ LogUnit mCurrentLogUnit = new LogUnit();
@ -233,7 +232,6 @@ public class ResearchLogger implements SharedPreferences.OnSharedPreferenceChang
resetLogBuffers(); resetLogBuffers();
// Initialize external services // Initialize external services
mUploadIntent = new Intent(mLatinIME, UploaderService.class);
mUploadNowIntent = new Intent(mLatinIME, UploaderService.class); mUploadNowIntent = new Intent(mLatinIME, UploaderService.class);
mUploadNowIntent.putExtra(UploaderService.EXTRA_UPLOAD_UNCONDITIONALLY, true); mUploadNowIntent.putExtra(UploaderService.EXTRA_UPLOAD_UNCONDITIONALLY, true);
if (ProductionFlag.USES_DEVELOPMENT_ONLY_DIAGNOSTICS) { if (ProductionFlag.USES_DEVELOPMENT_ONLY_DIAGNOSTICS) {
@ -319,12 +317,6 @@ public class ResearchLogger implements SharedPreferences.OnSharedPreferenceChang
restart(); restart();
} }
private void setLoggingAllowed(final boolean enableLogging) {
if (mPrefs == null) return;
sIsLogging = enableLogging;
ResearchSettings.writeResearchLoggerEnabledFlag(mPrefs, enableLogging);
}
private void checkForEmptyEditor() { private void checkForEmptyEditor() {
if (mLatinIME == null) { if (mLatinIME == null) {
return; return;
@ -1261,10 +1253,23 @@ public class ResearchLogger implements SharedPreferences.OnSharedPreferenceChang
private static final LogStatement LOGSTATEMENT_LATINIME_PICKSUGGESTIONMANUALLY = private static final LogStatement LOGSTATEMENT_LATINIME_PICKSUGGESTIONMANUALLY =
new LogStatement("LatinIMEPickSuggestionManually", true, false, "replacedWord", "index", new LogStatement("LatinIMEPickSuggestionManually", true, false, "replacedWord", "index",
"suggestion", "x", "y", "isBatchMode", "score", "kind", "sourceDict"); "suggestion", "x", "y", "isBatchMode", "score", "kind", "sourceDict");
/**
* Log a call to LatinIME.pickSuggestionManually().
*
* @param replacedWord the typed word that this manual suggestion replaces. May not be null.
* @param index the index in the suggestion strip
* @param suggestion the committed suggestion. May not be null.
* @param isBatchMode whether this was input in batch mode, aka gesture.
* @param score the internal score of the suggestion, as output by the dictionary
* @param kind the kind of suggestion, as one of the SuggestedWordInfo#KIND_* constants
* @param sourceDict the source origin of this word, as one of the Dictionary#TYPE_* constants.
*/
public static void latinIME_pickSuggestionManually(final String replacedWord, public static void latinIME_pickSuggestionManually(final String replacedWord,
final int index, final String suggestion, final boolean isBatchMode, final int index, final String suggestion, final boolean isBatchMode,
final int score, final int kind, final String sourceDict) { final int score, final int kind, final String sourceDict) {
final ResearchLogger researchLogger = getInstance(); final ResearchLogger researchLogger = getInstance();
// Note : suggestion can't be null here, because it's only called in a place where it
// can't be null.
if (!replacedWord.equals(suggestion.toString())) { if (!replacedWord.equals(suggestion.toString())) {
// The user chose something other than what was already there. // The user chose something other than what was already there.
researchLogger.setCurrentLogUnitContainsUserDeletions(); researchLogger.setCurrentLogUnitContainsUserDeletions();
@ -1273,7 +1278,7 @@ public class ResearchLogger implements SharedPreferences.OnSharedPreferenceChang
final String scrubbedWord = scrubDigitsFromString(suggestion); final String scrubbedWord = scrubDigitsFromString(suggestion);
researchLogger.enqueueEvent(LOGSTATEMENT_LATINIME_PICKSUGGESTIONMANUALLY, researchLogger.enqueueEvent(LOGSTATEMENT_LATINIME_PICKSUGGESTIONMANUALLY,
scrubDigitsFromString(replacedWord), index, scrubDigitsFromString(replacedWord), index,
suggestion == null ? null : scrubbedWord, Constants.SUGGESTION_STRIP_COORDINATE, scrubbedWord, Constants.SUGGESTION_STRIP_COORDINATE,
Constants.SUGGESTION_STRIP_COORDINATE, isBatchMode, score, kind, sourceDict); Constants.SUGGESTION_STRIP_COORDINATE, isBatchMode, score, kind, sourceDict);
researchLogger.commitCurrentLogUnitAsWord(scrubbedWord, Long.MAX_VALUE, isBatchMode); researchLogger.commitCurrentLogUnitAsWord(scrubbedWord, Long.MAX_VALUE, isBatchMode);
researchLogger.mStatistics.recordManualSuggestion(SystemClock.uptimeMillis()); researchLogger.mStatistics.recordManualSuggestion(SystemClock.uptimeMillis());