am d3a4c513: Fix Javadoc and null analysis related warnings

* commit 'd3a4c5132422b189c8dbb94dbbe84a9b9761b0a8':
  Fix Javadoc and null analysis related warnings
main
Tadashi G. Takaoka 2014-10-23 07:54:35 +00:00 committed by Android Git Automerger
commit 77e6afd1f2
72 changed files with 273 additions and 179 deletions

View File

@ -18,6 +18,7 @@ package com.android.inputmethod.compat;
import android.content.pm.PackageInfo;
@SuppressWarnings("unused")
public class AppWorkaroundsHelper {
private AppWorkaroundsHelper() {
// This helper class is not publicly instantiable.

View File

@ -21,6 +21,7 @@ import android.content.Context;
/**
* Helper to get the metadata URI from its base URI and the additional ID, if any.
*/
@SuppressWarnings("unused")
public class MetadataUriGetter {
private MetadataUriGetter() {
// This helper class is not instantiable.

View File

@ -40,6 +40,7 @@ public class LoginAccountUtils {
* @return an array of accounts. Empty (never null) if no accounts are available for login.
*/
@Nonnull
@SuppressWarnings("unused")
public static String[] getAccountsForLogin(final Context context) {
return new String[0];
}

View File

@ -24,7 +24,8 @@ public final class ProductionFlags {
public static final boolean IS_HARDWARE_KEYBOARD_SUPPORTED = false;
/**
* Include all suggestions from all dictionaries in {@link SuggestedWords#mRawSuggestions}.
* Include all suggestions from all dictionaries in
* {@link com.android.inputmethod.latin.SuggestedWords#mRawSuggestions}.
*/
public static final boolean INCLUDE_RAW_SUGGESTIONS = false;

View File

@ -20,6 +20,7 @@ import android.content.Context;
import com.android.inputmethod.latin.DictionaryFacilitator;
@SuppressWarnings("unused")
public class ContextualDictionaryUpdater {
public ContextualDictionaryUpdater(final Context context,
final DictionaryFacilitator dictionaryFacilitator,

View File

@ -20,6 +20,7 @@ import android.content.Context;
import com.android.inputmethod.latin.DictionaryFacilitator;
@SuppressWarnings("unused")
public class PersonalizationDictionaryUpdater {
final Context mContext;
final DictionaryFacilitator mDictionaryFacilitator;

View File

@ -29,6 +29,7 @@ import javax.annotation.Nonnull;
/**
* Utility class for managing additional features settings.
*/
@SuppressWarnings("unused")
public class AdditionalFeaturesSettingUtils {
public static final int ADDITIONAL_FEATURES_SETTINGS_SIZE = 0;

View File

@ -17,6 +17,7 @@
package com.android.inputmethod.latin.touchinputconsumer;
import android.view.inputmethod.EditorInfo;
import com.android.inputmethod.keyboard.Keyboard;
import com.android.inputmethod.latin.InputPointers;
import com.android.inputmethod.latin.SuggestedWords;
@ -31,6 +32,7 @@ import java.util.Locale;
* The methods of this class should only be called from a single thread, e.g.,
* the UI Thread.
*/
@SuppressWarnings("unused")
public class GestureConsumer {
public static final GestureConsumer NULL_GESTURE_CONSUMER =
new GestureConsumer();

View File

@ -19,6 +19,7 @@ package com.android.inputmethod.latin.utils;
import android.content.Context;
import android.content.Intent;
@SuppressWarnings("unused")
public class FeedbackUtils {
public static boolean isHelpAndFeedbackFormSupported() {
return false;

View File

@ -23,6 +23,7 @@ import android.content.Context;
/**
* Helper class to get the metadata URI and the additional ID.
*/
@SuppressWarnings("unused")
public class MetadataFileUriGetter {
private MetadataFileUriGetter() {
// This helper class is not instantiable.

View File

@ -22,6 +22,7 @@ import com.android.inputmethod.latin.settings.SettingsValues;
import javax.annotation.Nullable;
@SuppressWarnings("unused")
public final class StatsUtils {
private StatsUtils() {

View File

@ -21,6 +21,7 @@ import android.content.Context;
import com.android.inputmethod.latin.settings.SettingsValues;
@SuppressWarnings("unused")
public class StatsUtilsManager {
private static final StatsUtilsManager sInstance = new StatsUtilsManager();

View File

@ -43,15 +43,18 @@
</declare-styleable>
<declare-styleable name="KeyboardView">
<!-- Background image for the key. This image needs to be a {@link StateListDrawable},
with the following possible states: normal, pressed, checkable, checkable+pressed,
checkable+checked, checkable+checked+pressed. -->
<!-- Background image for the key. This image needs to be a
{@link android.graphics.drawable.StateListDrawable}, with the following possible states:
normal, pressed, checkable, checkable+pressed, checkable+checked,
checkable+checked+pressed. -->
<attr name="keyBackground" format="reference" />
<!-- Background image for the functional key. This image needs to be a
{@link StateListDrawable}, with the following possible states: normal, pressed. -->
{@link android.graphics.drawable.StateListDrawable}, with the following possible
states: normal, pressed. -->
<attr name="functionalKeyBackground" format="reference" />
<!-- Background image for the spacebar. This image needs to be a
{@link StateListDrawable}, with the following possible states: normal, pressed. -->
{@link android.graphics.drawable.StateListDrawable}, with the following possible
states: normal, pressed. -->
<attr name="spacebarBackground" format="reference" />
<attr name="spacebarIconWidthRatio" format="float" />
<!-- Right padding of hint letter to the edge of the key.-->
@ -200,7 +203,8 @@
<declare-styleable name="SuggestionStripView">
<attr name="suggestionStripOptions" format="integer">
<!-- This should be aligned with SuggestionStripLayoutHelper.AUTO_CORRECT_* and etc. -->
<!-- This should be aligned with
{@link com.android.inputmethod.latin.suggestions.SuggestionStripLayoutHelper.AUTO_CORRECT_BOLD} etc. -->
<flag name="autoCorrectBold" value="0x01" />
<flag name="autoCorrectUnderline" value="0x02" />
<flag name="validTypedWordBold" value="0x04" />
@ -218,7 +222,8 @@
<declare-styleable name="Keyboard">
<attr name="themeId" format="enum">
<!-- This should be aligned with KeyboardTheme.THEME_ID_*. -->
<!-- This should be aligned with
{@link com.android.inputmethod.keyboard.KeyboardTheme#THEME_ID_ICS} etc. -->
<enum name="ICS" value="0" />
<enum name="KLP" value="2" />
<enum name="LXXLight" value="3" />
@ -240,8 +245,8 @@
<attr name="verticalGap" format="fraction" />
<!-- More keys keyboard layout template -->
<attr name="moreKeysTemplate" format="reference" />
<!-- Icon set for key top and key preview.
These should be aligned with KeyboardIconsSet.NAMES_AND_ATTR_IDS[] -->
<!-- Icon set for key top and key preview. These should be aligned with
{@link com.android.inputmethod.keyboard.internal.KeyboardIconsSet#NAMES_AND_ATTR_IDS} -->
<attr name="iconShiftKey" format="reference" />
<attr name="iconDeleteKey" format="reference" />
<attr name="iconSettingsKey" format="reference" />
@ -287,7 +292,8 @@
<!-- Maximum column of more keys keyboard -->
<attr name="maxMoreKeysColumn" format="integer" />
<attr name="backgroundType" format="enum">
<!-- This should be aligned with Key.BACKGROUND_TYPE_* -->
<!-- This should be aligned with
{@link com.android.inputmethod.keyboard.Key#BACKGROUND_TYPE_NORMAL} etc. -->
<enum name="empty" value="0" />
<enum name="normal" value="1" />
<enum name="functional" value="2" />
@ -298,7 +304,8 @@
</attr>
<!-- The key action flags. -->
<attr name="keyActionFlags" format="integer">
<!-- This should be aligned with Key.ACTION_FLAGS_* -->
<!-- This should be aligned with
{@link com.android.inputmethod.keyboard.Key#ACTION_FLAGS_IS_REPEATABLE} etc. -->
<flag name="isRepeatable" value="0x01" />
<flag name="noKeyPreview" value="0x02" />
<flag name="altCodeWhileTyping" value="0x04" />
@ -312,7 +319,8 @@
<attr name="keyHintLabelVerticalAdjustment" format="fraction" />
<!-- The key label flags. -->
<attr name="keyLabelFlags" format="integer">
<!-- This should be aligned with Key.LABEL_FLAGS__* -->
<!-- This should be aligned with
{@link com.android.inputmethod.keyboard.Key#LABEL_FLAGS_FONT_NORMAL} etc. -->
<flag name="alignHintLabelToBottom" value="0x02" />
<flag name="alignIconToBottom" value="0x04" />
<flag name="alignLabelOffCenter" value="0x08" />
@ -357,7 +365,8 @@
<!-- Width of the key, in the proportion of keyboard width.
If the value is fillRight, the actual key width will be determined to fill out the
area up to the right edge of the keyboard. -->
<!-- This should be aligned with KeyboardBuilder.Row.KEYWIDTH_* -->
<!-- This should be aligned with
{@link com.android.inputmethod.keyboard.internal.KeyboardRow#KEYWIDTH_FILL_RIGHT}. -->
<attr name="keyWidth" format="fraction|enum">
<enum name="fillRight" value="-1" />
</attr>
@ -368,7 +377,7 @@
<!-- Key top visual attributes -->
<attr name="keyTypeface" format="enum">
<!-- This should be aligned with Typeface.NORMAL etc. -->
<!-- This should be aligned with {@link android.graphics.Typeface#NORMAL} etc. -->
<enum name="normal" value="0" />
<enum name="bold" value="1" />
<enum name="italic" value="2" />
@ -391,11 +400,11 @@
<attr name="keyShiftedLetterHintRatio" format="fraction" />
<!-- The label's horizontal offset to the center of the key. Negative is to left and
positive is to right. The value is in proportion of the width of
TypefaceUtils.KEY_LABEL_REFERENCE_CHAR. -->
{@link com.android.inputmethod.latin.utils.TypefaceUtils#KEY_LABEL_REFERENCE_CHAR}. -->
<attr name="keyLabelOffCenterRatio" format="fraction" />
<!-- The hint label's horizontal offset to the center of the key. Negative is to left and
positive is to right. The value is in proportion of the width of
TypefaceUtils.KEY_LABEL_REFERENCE_CHAR. -->
{@link com.android.inputmethod.latin.utils.TypefaceUtils#KEY_LABEL_REFERENCE_CHAR}. -->
<attr name="keyHintLabelOffCenterRatio" format="fraction" />
<!-- Color to use for the label in a key. -->
<attr name="keyTextColor" format="color" />
@ -425,7 +434,8 @@
<declare-styleable name="Keyboard_Case">
<attr name="keyboardLayoutSet" format="string" />
<!-- This should be aligned with KeyboardLayoutSet_Element's elementName. -->
<!-- This should be aligned with
{@link com.android.inputmethod.keyboard.KeyboardId#ELEMENT_ALPHABET} etc. -->
<attr name="keyboardLayoutSetElement" format="enum|string">
<enum name="alphabet" value="0" />
<enum name="alphabetManualShifted" value="1" />
@ -445,14 +455,16 @@
<enum name="emojiCategory5" value="15" />
<enum name="emojiCategory6" value="16" />
</attr>
<!-- This should be aligned with Keyboard.themeId and KeyboardTheme.THEME_ID_* -->
<!-- This should be aligned with Keyboard.themeId and
{@link com.android.inputmethod.keyboard.KeyboardTheme#THEME_ID_ICS} etc. -->
<attr name="keyboardTheme" format="enum|string">
<enum name="ICS" value="0" />
<enum name="KLP" value="2" />
<enum name="LXXLight" value="3" />
<enum name="LXXDark" value="4" />
</attr>
<!-- This should be aligned with KeyboardId.MODE_* -->
<!-- This should be aligned with
{@link com.android.inputmethod.keyboard.KeyboardId#MODE_TEXT} etc. -->
<attr name="mode" format="enum|string">
<enum name="text" value="0" />
<enum name="url" value="1" />
@ -469,7 +481,8 @@
<attr name="languageSwitchKeyEnabled" format="boolean" />
<attr name="isMultiLine" format="boolean" />
<attr name="imeAction" format="enum">
<!-- This should be aligned with EditorInfo.IME_ACTION_* -->
<!-- This should be aligned with
{@link android.view.inputmethod.EditorInfo#IME_ACTION_GO} etc. -->
<enum name="actionUnspecified" value="0" />
<enum name="actionNone" value="1" />
<enum name="actionGo" value="2" />
@ -478,7 +491,8 @@
<enum name="actionNext" value="5" />
<enum name="actionDone" value="6" />
<enum name="actionPrevious" value="7" />
<!-- This should be aligned with KeyboardId.IME_ACTION_* -->
<!-- This should be aligned with
{@link com.android.inputmethod.latin.utils.InputTypeUtils#IME_ACTION_CUSTOM_LABEL}. -->
<enum name="actionCustomLabel" value="0x100" />
</attr>
<attr name="isIconDefined" format="string" />
@ -495,7 +509,8 @@
</declare-styleable>
<declare-styleable name="KeyboardLayoutSet_Element">
<!-- This should be aligned with KeyboardId.ELEMENT_* -->
<!-- This should be aligned with
{@link com.android.inputmethod.keyboard.KeyboardId#ELEMENT_ALPHABET} etc. -->
<attr name="elementName" format="enum">
<enum name="alphabet" value="0" />
<enum name="alphabetManualShifted" value="1" />
@ -525,7 +540,8 @@
</declare-styleable>
<declare-styleable name="KeyboardLayoutSet_Feature">
<!-- This should be aligned with ScriptUtils.SCRIPT_* -->
<!-- This should be aligned with
{@link com.android.inputmethod.latin.utils.ScriptUtils#SCRIPT_ARABIC} etc. -->
<attr name="supportedScript" format="enum">
<enum name="arabic" value="0" />
<enum name="armenian" value="1" />

View File

@ -19,7 +19,7 @@
-->
<resources xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
<!-- For backward compatibility.
See {@link SettingsValues#needsToShowVoiceInputKey(SharedPreferences,Resources)} -->
@see com.android.inputmethod.latin.settings.SettingsValues#needsToShowVoiceInputKey(android.content.SharedPreferences,android.content.res.Resources) -->
<string name="voice_mode_main">0</string>
<!-- Subtype locale display name exceptions.

View File

@ -25,7 +25,8 @@
<item>@string/keyboard_theme_holo_white</item>
<item>@string/keyboard_theme_holo_blue</item>
</string-array>
<!-- An element must be a keyboard theme id of {@link KeyboardTheme#THEME_ID_*}. -->
<!-- An element must be a keyboard theme id of
{@link com.android.inputmethod.keyboard.KeyboardTheme#THEME_ID_ICS} etc. -->
<integer-array name="keyboard_theme_ids" translatable="false">
<item>3</item>
<item>4</item>

View File

@ -105,8 +105,10 @@
<style
name="MainKeyboardView"
parent="KeyboardView" />
<!-- Though {@link EmojiPalettesView} doesn't extend {@link KeyboardView}, some views inside it,
for instance delete button, need themed {@link KeyboardView} attributes. -->
<!-- Though {@link com.android.inputmethod.keyboard.emoji.EmojiPalettesView} doesn't extend
{@link com.android.inputmethod.keyboard.KeyboardView}, some views inside it, for instance
delete button, need themed {@link com.android.inputmethod.keyboard.KeyboardView}
attributes. -->
<style name="EmojiPalettesView" />
<style name="MoreKeysKeyboard" />
<style name="MoreKeysKeyboardView" />

View File

@ -73,8 +73,10 @@
<item name="languageOnSpacebarTextShadowRadius">1.0</item>
<item name="languageOnSpacebarTextShadowColor">@color/spacebar_text_shadow_color_holo</item>
</style>
<!-- Though {@link EmojiPalettesView} doesn't extend {@link KeyboardView}, some views inside it,
for instance delete button, need themed {@link KeyboardView} attributes. -->
<!-- Though {@link com.android.inputmethod.keyboard.emoji.EmojiPalettesView} doesn't extend
{@link com.android.inputmethod.keyboard.KeyboardView}, some views inside it, for instance
delete button, need themed {@link com.android.inputmethod.keyboard.KeyboardView}
attributes. -->
<style
name="EmojiPalettesView.ICS"
parent="MainKeyboardView.ICS"

View File

@ -73,8 +73,10 @@
<item name="languageOnSpacebarTextShadowRadius">1.0</item>
<item name="languageOnSpacebarTextShadowColor">@color/spacebar_text_shadow_color_holo</item>
</style>
<!-- Though {@link EmojiPalettesView} doesn't extend {@link KeyboardView}, some views inside it,
for instance delete button, need themed {@link KeyboardView} attributes. -->
<!-- Though {@link com.android.inputmethod.keyboard.emoji.EmojiPalettesView} doesn't extend
{@link com.android.inputmethod.keyboard.KeyboardView}, some views inside it, for instance
delete button, need themed {@link com.android.inputmethod.keyboard.KeyboardView}
attributes. -->
<style
name="EmojiPalettesView.KLP"
parent="MainKeyboardView.KLP"

View File

@ -73,8 +73,10 @@
<!-- A negative value to disable text shadow layer. -->
<item name="languageOnSpacebarTextShadowRadius">-1.0</item>
</style>
<!-- Though {@link EmojiPalettesView} doesn't extend {@link KeyboardView}, some views inside it,
for instance delete button, need themed {@link KeyboardView} attributes. -->
<!-- Though {@link com.android.inputmethod.keyboard.emoji.EmojiPalettesView} doesn't extend
{@link com.android.inputmethod.keyboard.KeyboardView}, some views inside it, for instance
delete button, need themed {@link com.android.inputmethod.keyboard.KeyboardView}
attributes. -->
<style
name="EmojiPalettesView.LXX_Dark"
parent="MainKeyboardView.LXX_Dark"

View File

@ -73,8 +73,10 @@
<!-- A negative value to disable text shadow layer. -->
<item name="languageOnSpacebarTextShadowRadius">-1.0</item>
</style>
<!-- Though {@link EmojiPalettesView} doesn't extend {@link KeyboardView}, some views inside it,
for instance delete button, need themed {@link KeyboardView} attributes. -->
<!-- Though {@link com.android.inputmethod.keyboard.emoji.EmojiPalettesView} doesn't extend
{@link com.android.inputmethod.keyboard.KeyboardView}, some views inside it, for instance
delete button, need themed {@link com.android.inputmethod.keyboard.KeyboardView}
attributes. -->
<style
name="EmojiPalettesView.LXX_Light"
parent="MainKeyboardView.LXX_Light"

View File

@ -82,10 +82,12 @@ public class CursorAnchorInfoCompatWrapper {
throw new UnsupportedOperationException("not supported.");
}
@SuppressWarnings("unused")
public RectF getCharacterBounds(final int index) {
throw new UnsupportedOperationException("not supported.");
}
@SuppressWarnings("unused")
public int getCharacterBoundsFlags(final int index) {
throw new UnsupportedOperationException("not supported.");
}

View File

@ -52,6 +52,7 @@ public final class InputMethodSubtypeCompatUtils {
// This utility class is not publicly instantiable.
}
@SuppressWarnings("deprecation")
public static InputMethodSubtype newInputMethodSubtype(int nameId, int iconId, String locale,
String mode, String extraValue, boolean isAuxiliary,
boolean overridesImplicitlyEnabledSubtype, int id) {

View File

@ -18,7 +18,9 @@ package com.android.inputmethod.dictionarypack;
import com.android.inputmethod.latin.utils.FragmentUtils;
import android.annotation.TargetApi;
import android.content.Intent;
import android.os.Build;
import android.os.Bundle;
import android.preference.PreferenceActivity;
@ -44,8 +46,8 @@ public final class DictionarySettingsActivity extends PreferenceActivity {
return modIntent;
}
// TODO: Uncomment the override annotation once we start using SDK version 19.
// @Override
@TargetApi(Build.VERSION_CODES.KITKAT)
@Override
public boolean isValidFragment(String fragmentName) {
return FragmentUtils.isValidFragment(fragmentName);
}

View File

@ -24,6 +24,7 @@ import android.view.View;
import android.widget.Button;
import android.widget.TextView;
import com.android.inputmethod.annotations.ExternallyReferenced;
import com.android.inputmethod.latin.R;
import java.util.Locale;
@ -63,11 +64,19 @@ public final class DownloadOverMeteredDialog extends Activity {
allowButton.setText(String.format(allowButtonFormat, ((float)size)/(1024*1024)));
}
// This method is externally referenced from layout/download_over_metered.xml using onClick
// attribute of Button.
@ExternallyReferenced
@SuppressWarnings("unused")
public void onClickDeny(final View v) {
UpdateHandler.setDownloadOverMeteredSetting(this, false);
finish();
}
// This method is externally referenced from layout/download_over_metered.xml using onClick
// attribute of Button.
@ExternallyReferenced
@SuppressWarnings("unused")
public void onClickAllow(final View v) {
UpdateHandler.setDownloadOverMeteredSetting(this, true);
UpdateHandler.installIfNeverRequested(this, mClientId, mWordListToDownload,

View File

@ -97,7 +97,8 @@ public class CombinerChain {
* new event. However it may never be null.
*/
@Nonnull
public Event processEvent(final ArrayList<Event> previousEvents, final Event newEvent) {
public Event processEvent(final ArrayList<Event> previousEvents,
@Nonnull final Event newEvent) {
final ArrayList<Event> modifiablePreviousEvents = new ArrayList<>(previousEvents);
Event event = newEvent;
for (final Combiner combiner : mCombiners) {

View File

@ -217,11 +217,8 @@ public class DeadKeyCombiner implements Combiner {
@Nonnull
private static Event createEventChainFromSequence(final @Nonnull CharSequence text,
final Event originalEvent) {
if (text.length() <= 0) {
return originalEvent;
}
Event lastEvent = null;
@Nonnull final Event originalEvent) {
Event lastEvent = originalEvent;
int codePoint = 0;
for (int i = text.length(); i > 0; i -= Character.charCount(codePoint)) {
codePoint = Character.codePointBefore(text, i);

View File

@ -223,6 +223,7 @@ public class Event {
* Creates an input event representing the manual pick of a punctuation suggestion.
* @return an event for this suggestion pick.
*/
@Nonnull
public static Event createPunctuationSuggestionPickedEvent(
final SuggestedWordInfo suggestedWordInfo) {
final int primaryCode = suggestedWordInfo.mWord.charAt(0);

View File

@ -74,7 +74,7 @@ public class TextDecorator {
void onClickComposingTextToAddToDictionary(final String word);
}
public TextDecorator(final Listener listener) {
public TextDecorator(@Nullable final Listener listener) {
mListener = (listener != null) ? listener : EMPTY_LISTENER;
}
@ -83,7 +83,7 @@ public class TextDecorator {
* delegated to the associated UI operator.
* @param uiOperator the UI operator to be associated.
*/
public void setUiOperator(final TextDecoratorUiOperator uiOperator) {
public void setUiOperator(@Nonnull final TextDecoratorUiOperator uiOperator) {
mUiOperator.disposeUi();
mUiOperator = uiOperator;
mUiOperator.setOnClickListener(getOnClickHandler());
@ -347,12 +347,14 @@ public class TextDecorator {
}
}
@Nonnull
private final static Listener EMPTY_LISTENER = new Listener() {
@Override
public void onClickComposingTextToAddToDictionary(final String word) {
}
};
@Nonnull
private final static TextDecoratorUiOperator EMPTY_UI_OPERATOR = new TextDecoratorUiOperator() {
@Override
public void disposeUi() {

View File

@ -19,6 +19,7 @@ package com.android.inputmethod.keyboard.internal;
import android.graphics.Canvas;
import android.view.View;
import com.android.inputmethod.keyboard.MainKeyboardView;
import com.android.inputmethod.keyboard.PointerTracker;
/**
@ -51,11 +52,11 @@ public abstract class AbstractDrawingPreview {
}
/**
* Set {@link MainKeyboardView} geometry and position in the {@link SoftInputWindow}.
* Set {@link MainKeyboardView} geometry and position in the window of input method.
* The class that is overriding this method must call this super implementation.
*
* @param originCoords the top-left coordinates of the {@link MainKeyboardView} in
* {@link SoftInputWindow} coordinate-system. This is unused but has a point in an
* the input method window coordinate-system. This is unused but has a point in an
* extended class, such as {@link GestureTrailsDrawingPreview}.
* @param width the width of {@link MainKeyboardView}.
* @param height the height of {@link MainKeyboardView}.

View File

@ -47,6 +47,8 @@ import java.io.IOException;
import java.util.Arrays;
import java.util.Locale;
import javax.annotation.Nonnull;
/**
* Keyboard Building helper.
*
@ -859,7 +861,7 @@ public class KeyboardBuilder<KP extends KeyboardParams> {
mTopEdge = false;
}
private void endKey(final Key key) {
private void endKey(@Nonnull final Key key) {
mParams.onAddKey(key);
if (mLeftEdge) {
key.markAsLeftEdge(mParams);

View File

@ -31,6 +31,8 @@ import java.util.Arrays;
import java.util.HashSet;
import java.util.Locale;
import javax.annotation.Nonnull;
/**
* The more key specification object. The more keys are an array of {@link MoreKeySpec}.
*
@ -70,6 +72,7 @@ public final class MoreKeySpec {
mIconId = KeySpecParser.getIconId(moreKeySpec);
}
@Nonnull
public Key buildKey(final int x, final int y, final int labelFlags,
final KeyboardParams params) {
return new Key(mLabel, mIconId, mCode, mOutputText, null /* hintLabel */, labelFlags,

View File

@ -80,7 +80,7 @@ public final class TouchPositionCorrection {
return mRadii.length;
}
@SuppressWarnings("static-method")
@SuppressWarnings({ "static-method", "unused" })
public float getX(final int row) {
return 0.0f;
// Touch position correction data for X coordinate is obsolete.

View File

@ -351,15 +351,19 @@ public final class BinaryDictionary extends Dictionary {
@Override
public int getFrequency(final String word) {
if (TextUtils.isEmpty(word)) return NOT_A_PROBABILITY;
int[] codePoints = StringUtils.toCodePointArray(word);
if (TextUtils.isEmpty(word)) {
return NOT_A_PROBABILITY;
}
final int[] codePoints = StringUtils.toCodePointArray(word);
return getProbabilityNative(mNativeDict, codePoints);
}
@Override
public int getMaxFrequencyOfExactMatches(final String word) {
if (TextUtils.isEmpty(word)) return NOT_A_PROBABILITY;
int[] codePoints = StringUtils.toCodePointArray(word);
if (TextUtils.isEmpty(word)) {
return NOT_A_PROBABILITY;
}
final int[] codePoints = StringUtils.toCodePointArray(word);
return getMaxProbabilityOfExactMatchesNative(mNativeDict, codePoints);
}
@ -523,7 +527,9 @@ public final class BinaryDictionary extends Dictionary {
@UsedForTesting
public void addMultipleDictionaryEntries(final LanguageModelParam[] languageModelParams) {
if (!isValidDictionary()) return;
if (!isValidDictionary()) {
return;
}
int processedParamCount = 0;
while (processedParamCount < languageModelParams.length) {
if (needsToRunGC(true /* mindsBlockByGC */)) {
@ -550,7 +556,9 @@ public final class BinaryDictionary extends Dictionary {
// Flush to dict file if the dictionary has been updated.
public boolean flush() {
if (!isValidDictionary()) return false;
if (!isValidDictionary()) {
return false;
}
if (mHasUpdated) {
if (!flushNative(mNativeDict, mDictFilePath)) {
return false;
@ -570,7 +578,9 @@ public final class BinaryDictionary extends Dictionary {
// Run GC and flush to dict file.
public boolean flushWithGC() {
if (!isValidDictionary()) return false;
if (!isValidDictionary()) {
return false;
}
if (!flushWithGCNative(mNativeDict, mDictFilePath)) {
return false;
}
@ -585,7 +595,9 @@ public final class BinaryDictionary extends Dictionary {
* @return whether GC is needed to run or not.
*/
public boolean needsToRunGC(final boolean mindsBlockByGC) {
if (!isValidDictionary()) return false;
if (!isValidDictionary()) {
return false;
}
return needsToRunGCNative(mNativeDict, mindsBlockByGC);
}
@ -630,7 +642,9 @@ public final class BinaryDictionary extends Dictionary {
@UsedForTesting
public String getPropertyForGettingStats(final String query) {
if (!isValidDictionary()) return "";
if (!isValidDictionary()) {
return "";
}
return getPropertyNative(mNativeDict, query);
}

View File

@ -223,7 +223,7 @@ final public class BinaryDictionaryGetter {
// ## HACK ## we prevent usage of a dictionary before version 18. The reason for this is, since
// those do not include whitelist entries, the new code with an old version of the dictionary
// would lose whitelist functionality.
private static boolean hackCanUseDictionaryFile(final Locale locale, final File file) {
private static boolean hackCanUseDictionaryFile(final File file) {
try {
// Read the version of the file
final DictionaryHeader header = BinaryDictionaryUtils.getHeader(file);
@ -275,7 +275,7 @@ final public class BinaryDictionaryGetter {
// cachedWordLists may not be null, see doc for getCachedDictionaryList
for (final File f : cachedWordLists) {
final String wordListId = DictionaryInfoUtils.getWordListIdFromFileName(f.getName());
final boolean canUse = f.canRead() && hackCanUseDictionaryFile(locale, f);
final boolean canUse = f.canRead() && hackCanUseDictionaryFile(f);
if (canUse && DictionaryInfoUtils.isMainWordListId(wordListId)) {
foundMainDict = true;
}

View File

@ -233,8 +233,8 @@ public final class Constants {
/**
* Special keys code. Must be negative.
* These should be aligned with {@link KeyboardCodesSet#ID_TO_NAME},
* {@link KeyboardCodesSet#DEFAULT}, and {@link KeyboardCodesSet#RTL}.
* These should be aligned with constants in
* {@link com.android.inputmethod.keyboard.internal.KeyboardCodesSet}.
*/
public static final int CODE_SHIFT = -1;
public static final int CODE_CAPSLOCK = -2;
@ -309,8 +309,8 @@ public final class Constants {
/**
* Default capacity of gesture points container.
* This constant is used by {@link BatchInputArbiter} and etc. to preallocate regions that
* contain gesture event points.
* This constant is used by {@link com.android.inputmethod.keyboard.internal.BatchInputArbiter}
* and etc. to preallocate regions that contain gesture event points.
*/
public static final int DEFAULT_GESTURE_POINTS_CAPACITY = 128;

View File

@ -28,7 +28,7 @@ import android.provider.ContactsContract;
import android.provider.ContactsContract.Contacts;
import android.util.Log;
import com.android.inputmethod.annotations.UsedForTesting;
import com.android.inputmethod.annotations.ExternallyReferenced;
import com.android.inputmethod.latin.personalization.AccountUtils;
import com.android.inputmethod.latin.utils.ExecutorUtils;
import com.android.inputmethod.latin.utils.StringUtils;
@ -82,7 +82,8 @@ public class ContactsBinaryDictionary extends ExpandableBinaryDictionary {
reloadDictionaryIfRequired();
}
@UsedForTesting
// Note: This method is called by {@link DictionaryFacilitator} using Java reflection.
@ExternallyReferenced
public static ContactsBinaryDictionary getDictionary(final Context context, final Locale locale,
final File dictFile, final String dictNamePrefix) {
return new ContactsBinaryDictionary(context, locale, dictFile, dictNamePrefix + NAME);

View File

@ -120,10 +120,18 @@ public abstract class Dictionary {
*/
abstract public boolean isInDictionary(final String word);
/**
* Get the frequency of the word.
* @param word the word to get the frequency of.
*/
public int getFrequency(final String word) {
return NOT_A_PROBABILITY;
}
/**
* Get the maximum frequency of the word.
* @param word the word to get the maximum frequency of.
*/
public int getMaxFrequencyOfExactMatches(final String word) {
return NOT_A_PROBABILITY;
}

View File

@ -53,6 +53,9 @@ import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.TimeUnit;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
// TODO: Consolidate dictionaries in native code.
public class DictionaryFacilitator {
public static final String TAG = DictionaryFacilitator.class.getSimpleName();
@ -274,6 +277,7 @@ public class DictionaryFacilitator {
mMostProbableDictionaryGroup = newMostProbableDictionaryGroup;
}
@Nullable
private static ExpandableBinaryDictionary getSubDict(final String dictType,
final Context context, final Locale locale, final File dictFile,
final String dictNamePrefix) {
@ -303,6 +307,7 @@ public class DictionaryFacilitator {
usePersonalizedDicts, forceReloadMainDictionary, listener, "" /* dictNamePrefix */);
}
@Nullable
static DictionaryGroup findDictionaryGroupWithLocale(final DictionaryGroup[] dictionaryGroups,
final Locale locale) {
for (int i = 0; i < dictionaryGroups.length; ++i) {
@ -317,7 +322,7 @@ public class DictionaryFacilitator {
final Locale[] newLocales,
final boolean useContactsDict, final boolean usePersonalizedDicts,
final boolean forceReloadMainDictionary,
final DictionaryInitializationListener listener,
@Nullable final DictionaryInitializationListener listener,
final String dictNamePrefix) {
final HashMap<Locale, ArrayList<String>> existingDictsToCleanup = new HashMap<>();
// TODO: Make subDictTypesToUse configurable by resource or a static final list.
@ -593,7 +598,7 @@ public class DictionaryFacilitator {
}
public void addToUserHistory(final String suggestion, final boolean wasAutoCapitalized,
final NgramContext ngramContext, final int timeStampInSeconds,
@Nonnull final NgramContext ngramContext, final int timeStampInSeconds,
final boolean blockPotentiallyOffensive) {
final DictionaryGroup dictionaryGroup = getDictionaryGroupForMostProbableLanguage();
final String[] words = suggestion.split(Constants.WORD_SEPARATOR);

View File

@ -53,6 +53,10 @@ import javax.annotation.Nullable;
* Abstract base class for an expandable dictionary that can be created and updated dynamically
* during runtime. When updated it automatically generates a new binary dictionary to handle future
* queries in native code. This binary dictionary is written to internal storage.
*
* A class that extends this abstract class must have a static factory method named
* getDictionary(Context context, Locale locale, File dictFile, String dictNamePrefix)
* @see DictionaryFacilitator#getSubDict(String,Context,Locale,File,String)
*/
abstract public class ExpandableBinaryDictionary extends Dictionary {
private static final boolean DEBUG = false;

View File

@ -139,7 +139,10 @@ public final class InputView extends FrameLayout {
return y - mEventReceivingRect.top;
}
// Callback when a {@link MotionEvent} is forwarded.
/**
* Callback when a {@link MotionEvent} is forwarded.
* @param me the motion event to be forwarded.
*/
protected void onForwardingEvent(final MotionEvent me) {}
// Returns true if a {@link MotionEvent} is needed to be forwarded to

View File

@ -1419,7 +1419,7 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
// This method is public for testability of LatinIME, but also in the future it should
// completely replace #onCodeInput.
public void onEvent(final Event event) {
public void onEvent(@Nonnull final Event event) {
if (Constants.CODE_SHORTCUT == event.mKeyCode) {
mSubtypeSwitcher.switchToShortcutIME(this);
}
@ -1434,6 +1434,7 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
// A helper method to split the code point and the key code. Ultimately, they should not be
// squashed into the same variable, and this method should be removed.
// public for testing, as we don't want to copy the same logic into test code
@Nonnull
public static Event createSoftwareKeypressEvent(final int keyCodeOrCodePoint, final int keyX,
final int keyY, final boolean isKeyRepeat) {
final int keyCode;

View File

@ -23,13 +23,17 @@ import com.android.inputmethod.latin.utils.StringUtils;
import java.util.Arrays;
import javax.annotation.Nonnull;
/**
* Class to represent information of previous words. This class is used to add n-gram entries
* into binary dictionaries, to get predictions, and to get suggestions.
*/
public class NgramContext {
@Nonnull
public static final NgramContext EMPTY_PREV_WORDS_INFO =
new NgramContext(WordInfo.EMPTY_WORD_INFO);
@Nonnull
public static final NgramContext BEGINNING_OF_SENTENCE =
new NgramContext(WordInfo.BEGINNING_OF_SENTENCE_WORD_INFO);
@ -37,7 +41,9 @@ public class NgramContext {
* Word information used to represent previous words information.
*/
public static class WordInfo {
@Nonnull
public static final WordInfo EMPTY_WORD_INFO = new WordInfo(null);
@Nonnull
public static final WordInfo BEGINNING_OF_SENTENCE_WORD_INFO = new WordInfo();
// This is an empty char sequence when mIsBeginningOfSentence is true.
@ -97,6 +103,7 @@ public class NgramContext {
}
// Create next prevWordsInfo using current prevWordsInfo.
@Nonnull
public NgramContext getNextNgramContext(final WordInfo wordInfo) {
final int nextPrevWordCount = Math.min(Constants.MAX_PREV_WORD_COUNT_FOR_N_GRAM,
mPrevWordsCount + 1);

View File

@ -56,7 +56,7 @@ public final class PunctuationSuggestions extends SuggestedWords {
/**
* {@inheritDoc}
* Note that {@link super#getWord(int)} returns a punctuation key specification text.
* Note that {@link SuggestedWords#getWord(int)} returns a punctuation key specification text.
* The suggested punctuation should be gotten by parsing the key specification.
*/
@Override
@ -70,7 +70,7 @@ public final class PunctuationSuggestions extends SuggestedWords {
/**
* {@inheritDoc}
* Note that {@link super#getWord(int)} returns a punctuation key specification text.
* Note that {@link SuggestedWords#getWord(int)} returns a punctuation key specification text.
* The displayed text should be gotten by parsing the key specification.
*/
@Override
@ -82,7 +82,7 @@ public final class PunctuationSuggestions extends SuggestedWords {
/**
* {@inheritDoc}
* Note that {@link #getWord(int)} returns a suggested punctuation. We should create a
* {@link SuggestedWordInfo} object that represents a hard coded word.
* {@link SuggestedWords.SuggestedWordInfo} object that represents a hard coded word.
*/
@Override
public SuggestedWordInfo getInfo(final int index) {

View File

@ -44,6 +44,8 @@ import com.android.inputmethod.latin.utils.SpannableStringUtils;
import com.android.inputmethod.latin.utils.StringUtils;
import com.android.inputmethod.latin.utils.TextRange;
import javax.annotation.Nonnull;
/**
* Enrichment class for InputConnection to simplify interaction and add functionality.
*
@ -591,6 +593,7 @@ public final class RichInputConnection implements PrivateCommandPerformer {
}
@SuppressWarnings("unused")
@Nonnull
public NgramContext getNgramContextFromNthPreviousWord(
final SpacingAndPunctuations spacingAndPunctuations, final int n) {
mIC = mParent.getCurrentInputConnection();

View File

@ -38,6 +38,8 @@ import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import javax.annotation.Nonnull;
/**
* Enrichment class for InputMethodManager to simplify interaction and add functionality.
*/
@ -301,12 +303,13 @@ public class RichInputMethodManager {
return INDEX_NOT_FOUND;
}
@Nonnull
public InputMethodSubtype getCurrentRawSubtype() {
return mImmWrapper.mImm.getCurrentInputMethodSubtype();
}
public RichInputMethodSubtype createCurrentRichInputMethodSubtype(
final InputMethodSubtype rawSubtype) {
@Nonnull final InputMethodSubtype rawSubtype) {
return AdditionalFeaturesSettingUtils.createRichInputMethodSubtype(this, rawSubtype,
mContext);
}

View File

@ -44,6 +44,8 @@ import java.util.Locale;
import java.util.Map;
import java.util.Set;
import javax.annotation.Nonnull;
public final class SubtypeSwitcher {
private static boolean DBG = DebugFlags.DEBUG_ENABLED;
private static final String TAG = SubtypeSwitcher.class.getSimpleName();
@ -169,7 +171,7 @@ public final class SubtypeSwitcher {
}
// Update the current subtype. LatinIME.onCurrentInputMethodSubtypeChanged calls this function.
public void onSubtypeChanged(final InputMethodSubtype newSubtype) {
public void onSubtypeChanged(@Nonnull final InputMethodSubtype newSubtype) {
final RichInputMethodSubtype richSubtype =
mRichImm.createCurrentRichInputMethodSubtype(newSubtype);
if (DBG) {

View File

@ -28,7 +28,7 @@ import android.provider.UserDictionary.Words;
import android.text.TextUtils;
import android.util.Log;
import com.android.inputmethod.annotations.UsedForTesting;
import com.android.inputmethod.annotations.ExternallyReferenced;
import com.android.inputmethod.compat.UserDictionaryCompatUtils;
import com.android.inputmethod.latin.utils.SubtypeLocaleUtils;
@ -101,7 +101,8 @@ public class UserBinaryDictionary extends ExpandableBinaryDictionary {
reloadDictionaryIfRequired();
}
@UsedForTesting
// Note: This method is called by {@link DictionaryFacilitator} using Java reflection.
@ExternallyReferenced
public static UserBinaryDictionary getDictionary(final Context context, final Locale locale,
final File dictFile, final String dictNamePrefix) {
return new UserBinaryDictionary(context, locale, false /* alsoUseMoreRestrictiveLocales */,

View File

@ -182,7 +182,7 @@ public final class WordComposer {
* @return the processed event. Never null, but may be marked as consumed.
*/
@Nonnull
public Event processEvent(final Event event) {
public Event processEvent(@Nonnull final Event event) {
final Event processedEvent = mCombinerChain.processEvent(mEvents, event);
// The retained state of the combiner chain may have changed while processing the event,
// so we need to update our cache.

View File

@ -68,6 +68,8 @@ import java.util.ArrayList;
import java.util.TreeSet;
import java.util.concurrent.TimeUnit;
import javax.annotation.Nonnull;
/**
* This class manages the input logic.
*/
@ -454,8 +456,8 @@ public final class InputLogic {
* {@link com.android.inputmethod.keyboard.KeyboardSwitcher#getKeyboardShiftMode()}
* @return the complete transaction object
*/
public InputTransaction onCodeInput(final SettingsValues settingsValues, final Event event,
final int keyboardShiftMode,
public InputTransaction onCodeInput(final SettingsValues settingsValues,
@Nonnull final Event event, final int keyboardShiftMode,
// TODO: remove these arguments
final int currentKeyboardScriptId, final LatinIME.UIHandler handler) {
final Event processedEvent = mWordComposer.processEvent(event);
@ -1373,7 +1375,7 @@ public final class InputLogic {
}
private void performAdditionToUserHistoryDictionary(final SettingsValues settingsValues,
final String suggestion, final NgramContext ngramContext) {
final String suggestion, @Nonnull final NgramContext ngramContext) {
// If correction is not enabled, we don't add words to the user history dictionary.
// That's to avoid unintended additions in some sensitive fields, or fields that
// expect to receive non-words.
@ -2301,7 +2303,7 @@ public final class InputLogic {
* Sets the UI operator for {@link TextDecorator}.
* @param uiOperator the UI operator which should be associated with {@link TextDecorator}.
*/
public void setTextDecoratorUi(final TextDecoratorUiOperator uiOperator) {
public void setTextDecoratorUi(@Nonnull final TextDecoratorUiOperator uiOperator) {
mTextDecorator.setUiOperator(uiOperator);
}

View File

@ -95,7 +95,7 @@ public class HttpUrlConnectionBuilder {
}
/**
* Sets the connect timeout. Defaults to {@value #DEFAULT_TIMEOUT} milliseconds.
* Sets the connect timeout. Defaults to {@value #DEFAULT_TIMEOUT_MILLIS} milliseconds.
*
* TODO: Remove @UsedForTesting after this method is actually used.
*/
@ -110,7 +110,7 @@ public class HttpUrlConnectionBuilder {
}
/**
* Sets the read timeout. Defaults to {@value #DEFAULT_TIMEOUT} milliseconds.
* Sets the read timeout. Defaults to {@value #DEFAULT_TIMEOUT_MILLIS} milliseconds.
*
* TODO: Remove @UsedForTesting after this method is actually used.
*/

View File

@ -18,7 +18,7 @@ package com.android.inputmethod.latin.personalization;
import android.content.Context;
import com.android.inputmethod.annotations.UsedForTesting;
import com.android.inputmethod.annotations.ExternallyReferenced;
import com.android.inputmethod.latin.Dictionary;
import com.android.inputmethod.latin.ExpandableBinaryDictionary;
@ -36,7 +36,9 @@ public class ContextualDictionary extends ExpandableBinaryDictionary {
clear();
}
@UsedForTesting
// Note: This method is called by {@link DictionaryFacilitator} using Java reflection.
@SuppressWarnings("unused")
@ExternallyReferenced
public static ContextualDictionary getDictionary(final Context context, final Locale locale,
final File dictFile, final String dictNamePrefix) {
return new ContextualDictionary(context, locale, dictFile);

View File

@ -18,7 +18,7 @@ package com.android.inputmethod.latin.personalization;
import android.content.Context;
import com.android.inputmethod.annotations.UsedForTesting;
import com.android.inputmethod.annotations.ExternallyReferenced;
import com.android.inputmethod.latin.Dictionary;
import java.io.File;
@ -33,7 +33,9 @@ public class PersonalizationDictionary extends DecayingExpandableBinaryDictionar
Dictionary.TYPE_PERSONALIZATION, null /* dictFile */);
}
@UsedForTesting
// Note: This method is called by {@link DictionaryFacilitator} using Java reflection.
@SuppressWarnings("unused")
@ExternallyReferenced
public static PersonalizationDictionary getDictionary(final Context context,
final Locale locale, final File dictFile, final String dictNamePrefix) {
return PersonalizationHelper.getPersonalizationDictionary(context, locale);

View File

@ -18,7 +18,7 @@ package com.android.inputmethod.latin.personalization;
import android.content.Context;
import com.android.inputmethod.annotations.UsedForTesting;
import com.android.inputmethod.annotations.ExternallyReferenced;
import com.android.inputmethod.latin.Constants;
import com.android.inputmethod.latin.Dictionary;
import com.android.inputmethod.latin.ExpandableBinaryDictionary;
@ -28,6 +28,8 @@ import com.android.inputmethod.latin.utils.DistracterFilter;
import java.io.File;
import java.util.Locale;
import javax.annotation.Nonnull;
/**
* Locally gathers stats about the words user types and various other signals like auto-correction
* cancellation or manual picks. This allows the keyboard to adapt to the typist over time.
@ -41,7 +43,9 @@ public class UserHistoryDictionary extends DecayingExpandableBinaryDictionaryBas
Dictionary.TYPE_USER_HISTORY, null /* dictFile */);
}
@UsedForTesting
// Note: This method is called by {@link DictionaryFacilitator} using Java reflection.
@SuppressWarnings("unused")
@ExternallyReferenced
public static UserHistoryDictionary getDictionary(final Context context, final Locale locale,
final File dictFile, final String dictNamePrefix) {
return PersonalizationHelper.getUserHistoryDictionary(context, locale);
@ -58,8 +62,8 @@ public class UserHistoryDictionary extends DecayingExpandableBinaryDictionaryBas
* @param distracterFilter the filter to check whether the word is a distracter
*/
public static void addToDictionary(final ExpandableBinaryDictionary userHistoryDictionary,
final NgramContext ngramContext, final String word, final boolean isValid,
final int timestamp, final DistracterFilter distracterFilter) {
@Nonnull final NgramContext ngramContext, final String word, final boolean isValid,
final int timestamp, @Nonnull final DistracterFilter distracterFilter) {
if (word.length() > Constants.DICTIONARY_MAX_WORD_LENGTH) {
return;
}

View File

@ -40,6 +40,8 @@ import java.util.Locale;
import java.util.Set;
import java.util.concurrent.locks.ReentrantLock;
import javax.annotation.Nonnull;
public final class Settings implements SharedPreferences.OnSharedPreferenceChangeListener {
private static final String TAG = Settings.class.getSimpleName();
// Settings screens
@ -175,7 +177,7 @@ public final class Settings implements SharedPreferences.OnSharedPreferenceChang
}
public void loadSettings(final Context context, final Locale locale,
final InputAttributes inputAttributes) {
@Nonnull final InputAttributes inputAttributes) {
mSettingsValuesLock.lock();
mContext = context;
try {

View File

@ -37,6 +37,8 @@ import com.android.inputmethod.latin.utils.TargetPackageInfoGetterTask;
import java.util.Arrays;
import java.util.Locale;
import javax.annotation.Nonnull;
/**
* When you call the constructor of this class, you may want to change the current system locale by
* using {@link com.android.inputmethod.latin.utils.RunInLocale}.
@ -85,6 +87,7 @@ public class SettingsValues {
public final int mScreenMetrics;
// From the input box
@Nonnull
public final InputAttributes mInputAttributes;
// Deduced settings
@ -115,7 +118,7 @@ public class SettingsValues {
public final float mKeyPreviewDismissEndYScale;
public SettingsValues(final Context context, final SharedPreferences prefs, final Resources res,
final InputAttributes inputAttributes) {
@Nonnull final InputAttributes inputAttributes) {
mLocale = res.getConfiguration().locale;
// Get the resources
mDelayInMillisecondsToUpdateOldSuggestions =
@ -123,12 +126,7 @@ public class SettingsValues {
mSpacingAndPunctuations = new SpacingAndPunctuations(res);
// Store the input attributes
if (null == inputAttributes) {
mInputAttributes = new InputAttributes(
null, false /* isFullscreenMode */, context.getPackageName());
} else {
mInputAttributes = inputAttributes;
}
mInputAttributes = inputAttributes;
// Get the settings preferences
mAutoCap = prefs.getBoolean(Settings.PREF_AUTO_CAP, true);

View File

@ -16,8 +16,10 @@
package com.android.inputmethod.latin.spellcheck;
import android.annotation.TargetApi;
import android.content.res.Resources;
import android.os.Binder;
import android.os.Build;
import android.text.TextUtils;
import android.util.Log;
import android.view.textservice.SentenceSuggestionsInfo;
@ -42,6 +44,7 @@ public final class AndroidSpellCheckerSession extends AndroidWordLevelSpellCheck
mResources = service.getResources();
}
@TargetApi(Build.VERSION_CODES.JELLY_BEAN)
private SentenceSuggestionsInfo fixWronglyInvalidatedWordWithSingleQuote(TextInfo ti,
SentenceSuggestionsInfo ssi) {
final CharSequence typedText = TextInfoCompatUtils.getCharSequenceOrString(ti);
@ -149,7 +152,7 @@ public final class AndroidSpellCheckerSession extends AndroidWordLevelSpellCheck
* @param textInfos an array of the text metadata
* @param suggestionsLimit the maximum number of suggestions to be returned
* @return an array of {@link SentenceSuggestionsInfo} returned by
* {@link SpellCheckerService.Session#onGetSuggestions(TextInfo, int)}
* {@link android.service.textservice.SpellCheckerService.Session#onGetSuggestions(TextInfo, int)}
*/
private SentenceSuggestionsInfo[] splitAndSuggest(TextInfo[] textInfos, int suggestionsLimit) {
if (textInfos == null || textInfos.length == 0) {

View File

@ -18,7 +18,9 @@ package com.android.inputmethod.latin.spellcheck;
import com.android.inputmethod.latin.utils.FragmentUtils;
import android.annotation.TargetApi;
import android.content.Intent;
import android.os.Build;
import android.os.Bundle;
import android.preference.PreferenceActivity;
@ -41,8 +43,8 @@ public final class SpellCheckerSettingsActivity extends PreferenceActivity {
return modIntent;
}
// TODO: Uncomment the override annotation once we start using SDK version 19.
// @Override
@TargetApi(Build.VERSION_CODES.KITKAT)
@Override
public boolean isValidFragment(String fragmentName) {
return FragmentUtils.isValidFragment(fragmentName);
}

View File

@ -47,12 +47,12 @@ public class UserDictionaryList extends PreferenceFragment {
"android.settings.USER_DICTIONARY_SETTINGS";
@Override
public void onCreate(Bundle icicle) {
public void onCreate(final Bundle icicle) {
super.onCreate(icicle);
setPreferenceScreen(getPreferenceManager().createPreferenceScreen(getActivity()));
}
public static TreeSet<String> getUserDictionaryLocalesSet(Activity activity) {
public static TreeSet<String> getUserDictionaryLocalesSet(final Activity activity) {
final Cursor cursor = activity.getContentResolver().query(UserDictionary.Words.CONTENT_URI,
new String[] { UserDictionary.Words.LOCALE },
null, null, null);
@ -108,7 +108,7 @@ public class UserDictionaryList extends PreferenceFragment {
* Creates the entries that allow the user to go into the user dictionary for each locale.
* @param userDictGroup The group to put the settings in.
*/
protected void createUserDictSettings(PreferenceGroup userDictGroup) {
protected void createUserDictSettings(final PreferenceGroup userDictGroup) {
final Activity activity = getActivity();
userDictGroup.removeAll();
final TreeSet<String> localeSet =
@ -121,10 +121,10 @@ public class UserDictionaryList extends PreferenceFragment {
}
if (localeSet.isEmpty()) {
userDictGroup.addPreference(createUserDictionaryPreference(null, activity));
userDictGroup.addPreference(createUserDictionaryPreference(null));
} else {
for (String locale : localeSet) {
userDictGroup.addPreference(createUserDictionaryPreference(locale, activity));
userDictGroup.addPreference(createUserDictionaryPreference(locale));
}
}
}
@ -134,7 +134,7 @@ public class UserDictionaryList extends PreferenceFragment {
* @param locale The locale for which this user dictionary is for.
* @return The corresponding preference.
*/
protected Preference createUserDictionaryPreference(String locale, Activity activity) {
protected Preference createUserDictionaryPreference(final String locale) {
final Preference newPref = new Preference(getActivity());
final Intent intent = new Intent(USER_DICTIONARY_SETTINGS_INTENT_ACTION);
if (null == locale) {

View File

@ -186,7 +186,7 @@ public class UserDictionarySettings extends ListFragment {
private ListAdapter createAdapter() {
return new MyAdapter(getActivity(), R.layout.user_dictionary_item, mCursor,
ADAPTER_FROM, ADAPTER_TO, this);
ADAPTER_FROM, ADAPTER_TO);
}
@Override
@ -288,7 +288,7 @@ public class UserDictionarySettings extends ListFragment {
private ViewBinder mViewBinder = new ViewBinder() {
@Override
public boolean setViewValue(View v, Cursor c, int columnIndex) {
public boolean setViewValue(final View v, final Cursor c, final int columnIndex) {
if (!IS_SHORTCUT_API_SUPPORTED) {
// just let SimpleCursorAdapter set the view values
return false;
@ -309,10 +309,9 @@ public class UserDictionarySettings extends ListFragment {
}
};
@SuppressWarnings("deprecation")
public MyAdapter(Context context, int layout, Cursor c, String[] from, int[] to,
UserDictionarySettings settings) {
super(context, layout, c, from, to);
public MyAdapter(final Context context, final int layout, final Cursor c,
final String[] from, final int[] to) {
super(context, layout, c, from, to, 0 /* flags */);
if (null != c) {
final String alphabet = context.getString(R.string.user_dict_fast_scroll_alphabet);
@ -323,12 +322,12 @@ public class UserDictionarySettings extends ListFragment {
}
@Override
public int getPositionForSection(int section) {
public int getPositionForSection(final int section) {
return null == mIndexer ? 0 : mIndexer.getPositionForSection(section);
}
@Override
public int getSectionForPosition(int position) {
public int getSectionForPosition(final int position) {
return null == mIndexer ? 0 : mIndexer.getSectionForPosition(position);
}

View File

@ -16,14 +16,16 @@
package com.android.inputmethod.latin.utils;
import java.util.List;
import java.util.Locale;
import android.view.inputmethod.InputMethodSubtype;
import com.android.inputmethod.annotations.UsedForTesting;
import com.android.inputmethod.latin.NgramContext;
import java.util.List;
import java.util.Locale;
import javax.annotation.Nonnull;
public interface DistracterFilter {
/**
* Determine whether a word is a distracter to words in dictionaries.
@ -68,8 +70,9 @@ public interface DistracterFilter {
public static boolean shouldBeHandledAsOov(final int handlingType) {
return (handlingType & SHOULD_BE_HANDLED_AS_OOV) != 0;
}
};
}
@Nonnull
public static final DistracterFilter EMPTY_DISTRACTER_FILTER = new DistracterFilter() {
@Override
public boolean isDistracterToWordsInDictionaries(NgramContext ngramContext,

View File

@ -16,14 +16,16 @@
package com.android.inputmethod.latin.utils;
import java.util.Arrays;
import java.util.regex.Pattern;
import com.android.inputmethod.latin.Constants;
import com.android.inputmethod.latin.NgramContext;
import com.android.inputmethod.latin.NgramContext.WordInfo;
import com.android.inputmethod.latin.settings.SpacingAndPunctuations;
import java.util.Arrays;
import java.util.regex.Pattern;
import javax.annotation.Nonnull;
public final class NgramContextUtils {
private NgramContextUtils() {
// Intentional empty constructor for utility class.
@ -52,6 +54,7 @@ public final class NgramContextUtils {
// (n = 2) "abc|" -> beginning-of-sentence
// (n = 2) "abc |" -> beginning-of-sentence
// (n = 2) "abc. def|" -> beginning-of-sentence
@Nonnull
public static NgramContext getNgramContextFromNthPreviousWord(final CharSequence prev,
final SpacingAndPunctuations spacingAndPunctuations, final int n) {
if (prev == null) return NgramContext.EMPTY_PREV_WORDS_INFO;

View File

@ -110,7 +110,6 @@ public final class ResourceUtils {
* are true for the specified key value pairs.
*
* For example, "condition,constant" has the following format.
* (See {@link ResourceUtilsTests#testFindConstantForKeyValuePairsRegexp()})
* - HARDWARE=mako,constantForNexus4
* - MODEL=Nexus 4:MANUFACTURER=LGE,constantForNexus4
* - ,defaultConstant
@ -119,6 +118,7 @@ public final class ResourceUtils {
* @param conditionConstantArray an array of "condition,constant" elements to be searched.
* @return the constant part of the matched "condition,constant" element. Returns null if no
* condition matches.
* @see com.android.inputmethod.latin.utils.ResourceUtilsTests#testFindConstantForKeyValuePairsRegexp()
*/
@UsedForTesting
static String findConstantForKeyValuePairs(final HashMap<String, String> keyValuePairs,

View File

@ -521,12 +521,12 @@ public final class StringUtils {
* {@code charSequence.toString().split(regex, preserveTrailingEmptySegments ? -1 : 0)}
* except that the spans are preserved in the result array.
* </p>
* @param input the character sequence to be split.
* @param charSequence the character sequence to be split.
* @param regex the regex pattern to be used as the separator.
* @param preserveTrailingEmptySegments {@code true} to preserve the trailing empty
* segments. Otherwise, trailing empty segments will be removed before being returned.
* @return the array which contains the result. All the spans in the {@param input} is
* preserved.
* @return the array which contains the result. All the spans in the <code>charSequence</code>
* is preserved.
*/
@UsedForTesting
public static CharSequence[] split(final CharSequence charSequence, final String regex,

View File

@ -165,7 +165,7 @@ public final class BinaryDictDecoderUtils {
*
* @param codePoints the code point array to write.
* @param buffer the byte buffer to write to.
* @param index the index in buffer to write the character array to.
* @param fromIndex the index in buffer to write the character array to.
* @param codePointToOneByteCodeMap the map to convert the code point.
* @return the index after the last character.
*/

View File

@ -535,7 +535,7 @@ public class BinaryDictEncoderUtils {
* Helper method to write a children position to a file.
*
* @param buffer the buffer to write to.
* @param index the index in the buffer to write the address to.
* @param fromIndex the index in the buffer to write the address to.
* @param position the position to write.
* @return the size in bytes the address actually took.
*/

View File

@ -44,7 +44,7 @@ public final class BinaryDictIOUtils {
public static DictDecoder getDictDecoder(final File dictFile, final long offset,
final long length, final int bufferType) {
if (dictFile.isDirectory()) {
return new Ver4DictDecoder(dictFile, bufferType);
return new Ver4DictDecoder(dictFile);
} else if (dictFile.isFile()) {
return new Ver2DictDecoder(dictFile, offset, length, bufferType);
}
@ -54,7 +54,7 @@ public final class BinaryDictIOUtils {
public static DictDecoder getDictDecoder(final File dictFile, final long offset,
final long length, final DictionaryBufferFactory factory) {
if (dictFile.isDirectory()) {
return new Ver4DictDecoder(dictFile, factory);
return new Ver4DictDecoder(dictFile);
} else if (dictFile.isFile()) {
return new Ver2DictDecoder(dictFile, offset, length, factory);
}

View File

@ -33,12 +33,7 @@ public class Ver4DictDecoder extends AbstractDictDecoder {
final File mDictDirectory;
@UsedForTesting
/* package */ Ver4DictDecoder(final File dictDirectory, final int factoryFlag) {
this(dictDirectory, null /* factory */);
}
@UsedForTesting
/* package */ Ver4DictDecoder(final File dictDirectory, final DictionaryBufferFactory factory) {
/* package */ Ver4DictDecoder(final File dictDirectory) {
mDictDirectory = dictDirectory;
}

View File

@ -29,7 +29,7 @@ import java.util.Collections;
@SmallTest
public class CollectionUtilsTests extends AndroidTestCase {
/**
* Tests that {@link CollectionUtils#arrayAsList(E[],int,int)} gives the expected
* Tests that {@link CollectionUtils#arrayAsList(Object[],int,int)} gives the expected
* results for a few valid inputs.
*/
public void testArrayAsList() {
@ -42,7 +42,7 @@ public class CollectionUtilsTests extends AndroidTestCase {
}
/**
* Tests that {@link CollectionUtils#isEmpty(java.util.Collection)} gives the expected
* Tests that {@link CollectionUtils#isNullOrEmpty(java.util.Collection)} gives the expected
* results for a few cases.
*/
public void testIsNullOrEmpty() {

View File

@ -1,35 +0,0 @@
/*
* Copyright (C) 2013 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.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package android.test;
import junit.framework.Assert;
/**
* This is a compatibility class that aims at emulating android.test.MoreAsserts from the
* Android library as simply as possible, and only to the extent that is used by the client classes.
* Its purpose is to provide compatibility without having to pull the whole Android library.
*/
public class MoreAsserts {
public static void assertNotEqual(Object unexpected, Object actual) {
if (equal(unexpected, actual)) {
Assert.fail("expected not to be:<" + unexpected + ">");
}
}
private static boolean equal(Object a, Object b) {
return a == b || (a != null && a.equals(b));
}
}

View File

@ -16,6 +16,7 @@
package com.android.inputmethod.keyboard;
@SuppressWarnings("unused")
public class Keyboard {
private final Key KEY = new Key();
public final Key getKey(final int i) { return KEY; }

View File

@ -64,8 +64,7 @@ public class Info extends Dicttool.Command {
+ " whitelist entries)");
}
private static void showWordInfo(final FusionDictionary dict, final String word,
final boolean plumbing) {
private static void showWordInfo(final FusionDictionary dict, final String word) {
final PtNode ptNode = FusionDictionary.findWordInTree(dict.mRootNodeArray, word);
if (null == ptNode) {
System.out.println(word + " is not in the dictionary");
@ -124,7 +123,7 @@ public class Info extends Dicttool.Command {
showInfo(dict, plumbing);
} else {
for (int i = 1; i < mArgs.length; ++i) {
showWordInfo(dict, mArgs[i], plumbing);
showWordInfo(dict, mArgs[i]);
}
}
}

View File

@ -16,6 +16,7 @@
package com.android.inputmethod.latin.personalization;
@SuppressWarnings("unused")
public class PersonalizationHelper {
public static void currentTimeChangedForTesting(final int currentTimestamp) {
}