am d3a4c513: Fix Javadoc and null analysis related warnings
* commit 'd3a4c5132422b189c8dbb94dbbe84a9b9761b0a8': Fix Javadoc and null analysis related warningsmain
commit
77e6afd1f2
|
@ -18,6 +18,7 @@ package com.android.inputmethod.compat;
|
||||||
|
|
||||||
import android.content.pm.PackageInfo;
|
import android.content.pm.PackageInfo;
|
||||||
|
|
||||||
|
@SuppressWarnings("unused")
|
||||||
public class AppWorkaroundsHelper {
|
public class AppWorkaroundsHelper {
|
||||||
private AppWorkaroundsHelper() {
|
private AppWorkaroundsHelper() {
|
||||||
// This helper class is not publicly instantiable.
|
// This helper class is not publicly instantiable.
|
||||||
|
|
|
@ -21,6 +21,7 @@ import android.content.Context;
|
||||||
/**
|
/**
|
||||||
* Helper to get the metadata URI from its base URI and the additional ID, if any.
|
* Helper to get the metadata URI from its base URI and the additional ID, if any.
|
||||||
*/
|
*/
|
||||||
|
@SuppressWarnings("unused")
|
||||||
public class MetadataUriGetter {
|
public class MetadataUriGetter {
|
||||||
private MetadataUriGetter() {
|
private MetadataUriGetter() {
|
||||||
// This helper class is not instantiable.
|
// This helper class is not instantiable.
|
||||||
|
|
|
@ -40,6 +40,7 @@ public class LoginAccountUtils {
|
||||||
* @return an array of accounts. Empty (never null) if no accounts are available for login.
|
* @return an array of accounts. Empty (never null) if no accounts are available for login.
|
||||||
*/
|
*/
|
||||||
@Nonnull
|
@Nonnull
|
||||||
|
@SuppressWarnings("unused")
|
||||||
public static String[] getAccountsForLogin(final Context context) {
|
public static String[] getAccountsForLogin(final Context context) {
|
||||||
return new String[0];
|
return new String[0];
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,7 +24,8 @@ public final class ProductionFlags {
|
||||||
public static final boolean IS_HARDWARE_KEYBOARD_SUPPORTED = false;
|
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;
|
public static final boolean INCLUDE_RAW_SUGGESTIONS = false;
|
||||||
|
|
||||||
|
|
|
@ -20,6 +20,7 @@ import android.content.Context;
|
||||||
|
|
||||||
import com.android.inputmethod.latin.DictionaryFacilitator;
|
import com.android.inputmethod.latin.DictionaryFacilitator;
|
||||||
|
|
||||||
|
@SuppressWarnings("unused")
|
||||||
public class ContextualDictionaryUpdater {
|
public class ContextualDictionaryUpdater {
|
||||||
public ContextualDictionaryUpdater(final Context context,
|
public ContextualDictionaryUpdater(final Context context,
|
||||||
final DictionaryFacilitator dictionaryFacilitator,
|
final DictionaryFacilitator dictionaryFacilitator,
|
||||||
|
|
|
@ -20,6 +20,7 @@ import android.content.Context;
|
||||||
|
|
||||||
import com.android.inputmethod.latin.DictionaryFacilitator;
|
import com.android.inputmethod.latin.DictionaryFacilitator;
|
||||||
|
|
||||||
|
@SuppressWarnings("unused")
|
||||||
public class PersonalizationDictionaryUpdater {
|
public class PersonalizationDictionaryUpdater {
|
||||||
final Context mContext;
|
final Context mContext;
|
||||||
final DictionaryFacilitator mDictionaryFacilitator;
|
final DictionaryFacilitator mDictionaryFacilitator;
|
||||||
|
|
|
@ -29,6 +29,7 @@ import javax.annotation.Nonnull;
|
||||||
/**
|
/**
|
||||||
* Utility class for managing additional features settings.
|
* Utility class for managing additional features settings.
|
||||||
*/
|
*/
|
||||||
|
@SuppressWarnings("unused")
|
||||||
public class AdditionalFeaturesSettingUtils {
|
public class AdditionalFeaturesSettingUtils {
|
||||||
public static final int ADDITIONAL_FEATURES_SETTINGS_SIZE = 0;
|
public static final int ADDITIONAL_FEATURES_SETTINGS_SIZE = 0;
|
||||||
|
|
||||||
|
|
|
@ -17,6 +17,7 @@
|
||||||
package com.android.inputmethod.latin.touchinputconsumer;
|
package com.android.inputmethod.latin.touchinputconsumer;
|
||||||
|
|
||||||
import android.view.inputmethod.EditorInfo;
|
import android.view.inputmethod.EditorInfo;
|
||||||
|
|
||||||
import com.android.inputmethod.keyboard.Keyboard;
|
import com.android.inputmethod.keyboard.Keyboard;
|
||||||
import com.android.inputmethod.latin.InputPointers;
|
import com.android.inputmethod.latin.InputPointers;
|
||||||
import com.android.inputmethod.latin.SuggestedWords;
|
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 methods of this class should only be called from a single thread, e.g.,
|
||||||
* the UI Thread.
|
* the UI Thread.
|
||||||
*/
|
*/
|
||||||
|
@SuppressWarnings("unused")
|
||||||
public class GestureConsumer {
|
public class GestureConsumer {
|
||||||
public static final GestureConsumer NULL_GESTURE_CONSUMER =
|
public static final GestureConsumer NULL_GESTURE_CONSUMER =
|
||||||
new GestureConsumer();
|
new GestureConsumer();
|
||||||
|
|
|
@ -19,6 +19,7 @@ package com.android.inputmethod.latin.utils;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
|
|
||||||
|
@SuppressWarnings("unused")
|
||||||
public class FeedbackUtils {
|
public class FeedbackUtils {
|
||||||
public static boolean isHelpAndFeedbackFormSupported() {
|
public static boolean isHelpAndFeedbackFormSupported() {
|
||||||
return false;
|
return false;
|
||||||
|
|
|
@ -23,6 +23,7 @@ import android.content.Context;
|
||||||
/**
|
/**
|
||||||
* Helper class to get the metadata URI and the additional ID.
|
* Helper class to get the metadata URI and the additional ID.
|
||||||
*/
|
*/
|
||||||
|
@SuppressWarnings("unused")
|
||||||
public class MetadataFileUriGetter {
|
public class MetadataFileUriGetter {
|
||||||
private MetadataFileUriGetter() {
|
private MetadataFileUriGetter() {
|
||||||
// This helper class is not instantiable.
|
// This helper class is not instantiable.
|
||||||
|
|
|
@ -22,6 +22,7 @@ import com.android.inputmethod.latin.settings.SettingsValues;
|
||||||
|
|
||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
|
|
||||||
|
@SuppressWarnings("unused")
|
||||||
public final class StatsUtils {
|
public final class StatsUtils {
|
||||||
|
|
||||||
private StatsUtils() {
|
private StatsUtils() {
|
||||||
|
|
|
@ -21,6 +21,7 @@ import android.content.Context;
|
||||||
|
|
||||||
import com.android.inputmethod.latin.settings.SettingsValues;
|
import com.android.inputmethod.latin.settings.SettingsValues;
|
||||||
|
|
||||||
|
@SuppressWarnings("unused")
|
||||||
public class StatsUtilsManager {
|
public class StatsUtilsManager {
|
||||||
|
|
||||||
private static final StatsUtilsManager sInstance = new StatsUtilsManager();
|
private static final StatsUtilsManager sInstance = new StatsUtilsManager();
|
||||||
|
|
|
@ -43,15 +43,18 @@
|
||||||
</declare-styleable>
|
</declare-styleable>
|
||||||
|
|
||||||
<declare-styleable name="KeyboardView">
|
<declare-styleable name="KeyboardView">
|
||||||
<!-- Background image for the key. This image needs to be a {@link StateListDrawable},
|
<!-- Background image for the key. This image needs to be a
|
||||||
with the following possible states: normal, pressed, checkable, checkable+pressed,
|
{@link android.graphics.drawable.StateListDrawable}, with the following possible states:
|
||||||
checkable+checked, checkable+checked+pressed. -->
|
normal, pressed, checkable, checkable+pressed, checkable+checked,
|
||||||
|
checkable+checked+pressed. -->
|
||||||
<attr name="keyBackground" format="reference" />
|
<attr name="keyBackground" format="reference" />
|
||||||
<!-- Background image for the functional key. This image needs to be a
|
<!-- 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" />
|
<attr name="functionalKeyBackground" format="reference" />
|
||||||
<!-- Background image for the spacebar. This image needs to be a
|
<!-- 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="spacebarBackground" format="reference" />
|
||||||
<attr name="spacebarIconWidthRatio" format="float" />
|
<attr name="spacebarIconWidthRatio" format="float" />
|
||||||
<!-- Right padding of hint letter to the edge of the key.-->
|
<!-- Right padding of hint letter to the edge of the key.-->
|
||||||
|
@ -200,7 +203,8 @@
|
||||||
|
|
||||||
<declare-styleable name="SuggestionStripView">
|
<declare-styleable name="SuggestionStripView">
|
||||||
<attr name="suggestionStripOptions" format="integer">
|
<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="autoCorrectBold" value="0x01" />
|
||||||
<flag name="autoCorrectUnderline" value="0x02" />
|
<flag name="autoCorrectUnderline" value="0x02" />
|
||||||
<flag name="validTypedWordBold" value="0x04" />
|
<flag name="validTypedWordBold" value="0x04" />
|
||||||
|
@ -218,7 +222,8 @@
|
||||||
|
|
||||||
<declare-styleable name="Keyboard">
|
<declare-styleable name="Keyboard">
|
||||||
<attr name="themeId" format="enum">
|
<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="ICS" value="0" />
|
||||||
<enum name="KLP" value="2" />
|
<enum name="KLP" value="2" />
|
||||||
<enum name="LXXLight" value="3" />
|
<enum name="LXXLight" value="3" />
|
||||||
|
@ -240,8 +245,8 @@
|
||||||
<attr name="verticalGap" format="fraction" />
|
<attr name="verticalGap" format="fraction" />
|
||||||
<!-- More keys keyboard layout template -->
|
<!-- More keys keyboard layout template -->
|
||||||
<attr name="moreKeysTemplate" format="reference" />
|
<attr name="moreKeysTemplate" format="reference" />
|
||||||
<!-- Icon set for key top and key preview.
|
<!-- Icon set for key top and key preview. These should be aligned with
|
||||||
These should be aligned with KeyboardIconsSet.NAMES_AND_ATTR_IDS[] -->
|
{@link com.android.inputmethod.keyboard.internal.KeyboardIconsSet#NAMES_AND_ATTR_IDS} -->
|
||||||
<attr name="iconShiftKey" format="reference" />
|
<attr name="iconShiftKey" format="reference" />
|
||||||
<attr name="iconDeleteKey" format="reference" />
|
<attr name="iconDeleteKey" format="reference" />
|
||||||
<attr name="iconSettingsKey" format="reference" />
|
<attr name="iconSettingsKey" format="reference" />
|
||||||
|
@ -287,7 +292,8 @@
|
||||||
<!-- Maximum column of more keys keyboard -->
|
<!-- Maximum column of more keys keyboard -->
|
||||||
<attr name="maxMoreKeysColumn" format="integer" />
|
<attr name="maxMoreKeysColumn" format="integer" />
|
||||||
<attr name="backgroundType" format="enum">
|
<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="empty" value="0" />
|
||||||
<enum name="normal" value="1" />
|
<enum name="normal" value="1" />
|
||||||
<enum name="functional" value="2" />
|
<enum name="functional" value="2" />
|
||||||
|
@ -298,7 +304,8 @@
|
||||||
</attr>
|
</attr>
|
||||||
<!-- The key action flags. -->
|
<!-- The key action flags. -->
|
||||||
<attr name="keyActionFlags" format="integer">
|
<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="isRepeatable" value="0x01" />
|
||||||
<flag name="noKeyPreview" value="0x02" />
|
<flag name="noKeyPreview" value="0x02" />
|
||||||
<flag name="altCodeWhileTyping" value="0x04" />
|
<flag name="altCodeWhileTyping" value="0x04" />
|
||||||
|
@ -312,7 +319,8 @@
|
||||||
<attr name="keyHintLabelVerticalAdjustment" format="fraction" />
|
<attr name="keyHintLabelVerticalAdjustment" format="fraction" />
|
||||||
<!-- The key label flags. -->
|
<!-- The key label flags. -->
|
||||||
<attr name="keyLabelFlags" format="integer">
|
<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="alignHintLabelToBottom" value="0x02" />
|
||||||
<flag name="alignIconToBottom" value="0x04" />
|
<flag name="alignIconToBottom" value="0x04" />
|
||||||
<flag name="alignLabelOffCenter" value="0x08" />
|
<flag name="alignLabelOffCenter" value="0x08" />
|
||||||
|
@ -357,7 +365,8 @@
|
||||||
<!-- Width of the key, in the proportion of keyboard width.
|
<!-- 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
|
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. -->
|
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">
|
<attr name="keyWidth" format="fraction|enum">
|
||||||
<enum name="fillRight" value="-1" />
|
<enum name="fillRight" value="-1" />
|
||||||
</attr>
|
</attr>
|
||||||
|
@ -368,7 +377,7 @@
|
||||||
|
|
||||||
<!-- Key top visual attributes -->
|
<!-- Key top visual attributes -->
|
||||||
<attr name="keyTypeface" format="enum">
|
<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="normal" value="0" />
|
||||||
<enum name="bold" value="1" />
|
<enum name="bold" value="1" />
|
||||||
<enum name="italic" value="2" />
|
<enum name="italic" value="2" />
|
||||||
|
@ -391,11 +400,11 @@
|
||||||
<attr name="keyShiftedLetterHintRatio" format="fraction" />
|
<attr name="keyShiftedLetterHintRatio" format="fraction" />
|
||||||
<!-- The label's horizontal offset to the center of the key. Negative is to left and
|
<!-- 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
|
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" />
|
<attr name="keyLabelOffCenterRatio" format="fraction" />
|
||||||
<!-- The hint label's horizontal offset to the center of the key. Negative is to left and
|
<!-- 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
|
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" />
|
<attr name="keyHintLabelOffCenterRatio" format="fraction" />
|
||||||
<!-- Color to use for the label in a key. -->
|
<!-- Color to use for the label in a key. -->
|
||||||
<attr name="keyTextColor" format="color" />
|
<attr name="keyTextColor" format="color" />
|
||||||
|
@ -425,7 +434,8 @@
|
||||||
|
|
||||||
<declare-styleable name="Keyboard_Case">
|
<declare-styleable name="Keyboard_Case">
|
||||||
<attr name="keyboardLayoutSet" format="string" />
|
<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">
|
<attr name="keyboardLayoutSetElement" format="enum|string">
|
||||||
<enum name="alphabet" value="0" />
|
<enum name="alphabet" value="0" />
|
||||||
<enum name="alphabetManualShifted" value="1" />
|
<enum name="alphabetManualShifted" value="1" />
|
||||||
|
@ -445,14 +455,16 @@
|
||||||
<enum name="emojiCategory5" value="15" />
|
<enum name="emojiCategory5" value="15" />
|
||||||
<enum name="emojiCategory6" value="16" />
|
<enum name="emojiCategory6" value="16" />
|
||||||
</attr>
|
</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">
|
<attr name="keyboardTheme" format="enum|string">
|
||||||
<enum name="ICS" value="0" />
|
<enum name="ICS" value="0" />
|
||||||
<enum name="KLP" value="2" />
|
<enum name="KLP" value="2" />
|
||||||
<enum name="LXXLight" value="3" />
|
<enum name="LXXLight" value="3" />
|
||||||
<enum name="LXXDark" value="4" />
|
<enum name="LXXDark" value="4" />
|
||||||
</attr>
|
</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">
|
<attr name="mode" format="enum|string">
|
||||||
<enum name="text" value="0" />
|
<enum name="text" value="0" />
|
||||||
<enum name="url" value="1" />
|
<enum name="url" value="1" />
|
||||||
|
@ -469,7 +481,8 @@
|
||||||
<attr name="languageSwitchKeyEnabled" format="boolean" />
|
<attr name="languageSwitchKeyEnabled" format="boolean" />
|
||||||
<attr name="isMultiLine" format="boolean" />
|
<attr name="isMultiLine" format="boolean" />
|
||||||
<attr name="imeAction" format="enum">
|
<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="actionUnspecified" value="0" />
|
||||||
<enum name="actionNone" value="1" />
|
<enum name="actionNone" value="1" />
|
||||||
<enum name="actionGo" value="2" />
|
<enum name="actionGo" value="2" />
|
||||||
|
@ -478,7 +491,8 @@
|
||||||
<enum name="actionNext" value="5" />
|
<enum name="actionNext" value="5" />
|
||||||
<enum name="actionDone" value="6" />
|
<enum name="actionDone" value="6" />
|
||||||
<enum name="actionPrevious" value="7" />
|
<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" />
|
<enum name="actionCustomLabel" value="0x100" />
|
||||||
</attr>
|
</attr>
|
||||||
<attr name="isIconDefined" format="string" />
|
<attr name="isIconDefined" format="string" />
|
||||||
|
@ -495,7 +509,8 @@
|
||||||
</declare-styleable>
|
</declare-styleable>
|
||||||
|
|
||||||
<declare-styleable name="KeyboardLayoutSet_Element">
|
<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">
|
<attr name="elementName" format="enum">
|
||||||
<enum name="alphabet" value="0" />
|
<enum name="alphabet" value="0" />
|
||||||
<enum name="alphabetManualShifted" value="1" />
|
<enum name="alphabetManualShifted" value="1" />
|
||||||
|
@ -525,7 +540,8 @@
|
||||||
</declare-styleable>
|
</declare-styleable>
|
||||||
|
|
||||||
<declare-styleable name="KeyboardLayoutSet_Feature">
|
<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">
|
<attr name="supportedScript" format="enum">
|
||||||
<enum name="arabic" value="0" />
|
<enum name="arabic" value="0" />
|
||||||
<enum name="armenian" value="1" />
|
<enum name="armenian" value="1" />
|
||||||
|
|
|
@ -19,7 +19,7 @@
|
||||||
-->
|
-->
|
||||||
<resources xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
|
<resources xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
|
||||||
<!-- For backward compatibility.
|
<!-- 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>
|
<string name="voice_mode_main">0</string>
|
||||||
|
|
||||||
<!-- Subtype locale display name exceptions.
|
<!-- Subtype locale display name exceptions.
|
||||||
|
|
|
@ -25,7 +25,8 @@
|
||||||
<item>@string/keyboard_theme_holo_white</item>
|
<item>@string/keyboard_theme_holo_white</item>
|
||||||
<item>@string/keyboard_theme_holo_blue</item>
|
<item>@string/keyboard_theme_holo_blue</item>
|
||||||
</string-array>
|
</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">
|
<integer-array name="keyboard_theme_ids" translatable="false">
|
||||||
<item>3</item>
|
<item>3</item>
|
||||||
<item>4</item>
|
<item>4</item>
|
||||||
|
|
|
@ -105,8 +105,10 @@
|
||||||
<style
|
<style
|
||||||
name="MainKeyboardView"
|
name="MainKeyboardView"
|
||||||
parent="KeyboardView" />
|
parent="KeyboardView" />
|
||||||
<!-- Though {@link EmojiPalettesView} doesn't extend {@link KeyboardView}, some views inside it,
|
<!-- Though {@link com.android.inputmethod.keyboard.emoji.EmojiPalettesView} doesn't extend
|
||||||
for instance delete button, need themed {@link KeyboardView} attributes. -->
|
{@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="EmojiPalettesView" />
|
||||||
<style name="MoreKeysKeyboard" />
|
<style name="MoreKeysKeyboard" />
|
||||||
<style name="MoreKeysKeyboardView" />
|
<style name="MoreKeysKeyboardView" />
|
||||||
|
|
|
@ -73,8 +73,10 @@
|
||||||
<item name="languageOnSpacebarTextShadowRadius">1.0</item>
|
<item name="languageOnSpacebarTextShadowRadius">1.0</item>
|
||||||
<item name="languageOnSpacebarTextShadowColor">@color/spacebar_text_shadow_color_holo</item>
|
<item name="languageOnSpacebarTextShadowColor">@color/spacebar_text_shadow_color_holo</item>
|
||||||
</style>
|
</style>
|
||||||
<!-- Though {@link EmojiPalettesView} doesn't extend {@link KeyboardView}, some views inside it,
|
<!-- Though {@link com.android.inputmethod.keyboard.emoji.EmojiPalettesView} doesn't extend
|
||||||
for instance delete button, need themed {@link KeyboardView} attributes. -->
|
{@link com.android.inputmethod.keyboard.KeyboardView}, some views inside it, for instance
|
||||||
|
delete button, need themed {@link com.android.inputmethod.keyboard.KeyboardView}
|
||||||
|
attributes. -->
|
||||||
<style
|
<style
|
||||||
name="EmojiPalettesView.ICS"
|
name="EmojiPalettesView.ICS"
|
||||||
parent="MainKeyboardView.ICS"
|
parent="MainKeyboardView.ICS"
|
||||||
|
|
|
@ -73,8 +73,10 @@
|
||||||
<item name="languageOnSpacebarTextShadowRadius">1.0</item>
|
<item name="languageOnSpacebarTextShadowRadius">1.0</item>
|
||||||
<item name="languageOnSpacebarTextShadowColor">@color/spacebar_text_shadow_color_holo</item>
|
<item name="languageOnSpacebarTextShadowColor">@color/spacebar_text_shadow_color_holo</item>
|
||||||
</style>
|
</style>
|
||||||
<!-- Though {@link EmojiPalettesView} doesn't extend {@link KeyboardView}, some views inside it,
|
<!-- Though {@link com.android.inputmethod.keyboard.emoji.EmojiPalettesView} doesn't extend
|
||||||
for instance delete button, need themed {@link KeyboardView} attributes. -->
|
{@link com.android.inputmethod.keyboard.KeyboardView}, some views inside it, for instance
|
||||||
|
delete button, need themed {@link com.android.inputmethod.keyboard.KeyboardView}
|
||||||
|
attributes. -->
|
||||||
<style
|
<style
|
||||||
name="EmojiPalettesView.KLP"
|
name="EmojiPalettesView.KLP"
|
||||||
parent="MainKeyboardView.KLP"
|
parent="MainKeyboardView.KLP"
|
||||||
|
|
|
@ -73,8 +73,10 @@
|
||||||
<!-- A negative value to disable text shadow layer. -->
|
<!-- A negative value to disable text shadow layer. -->
|
||||||
<item name="languageOnSpacebarTextShadowRadius">-1.0</item>
|
<item name="languageOnSpacebarTextShadowRadius">-1.0</item>
|
||||||
</style>
|
</style>
|
||||||
<!-- Though {@link EmojiPalettesView} doesn't extend {@link KeyboardView}, some views inside it,
|
<!-- Though {@link com.android.inputmethod.keyboard.emoji.EmojiPalettesView} doesn't extend
|
||||||
for instance delete button, need themed {@link KeyboardView} attributes. -->
|
{@link com.android.inputmethod.keyboard.KeyboardView}, some views inside it, for instance
|
||||||
|
delete button, need themed {@link com.android.inputmethod.keyboard.KeyboardView}
|
||||||
|
attributes. -->
|
||||||
<style
|
<style
|
||||||
name="EmojiPalettesView.LXX_Dark"
|
name="EmojiPalettesView.LXX_Dark"
|
||||||
parent="MainKeyboardView.LXX_Dark"
|
parent="MainKeyboardView.LXX_Dark"
|
||||||
|
|
|
@ -73,8 +73,10 @@
|
||||||
<!-- A negative value to disable text shadow layer. -->
|
<!-- A negative value to disable text shadow layer. -->
|
||||||
<item name="languageOnSpacebarTextShadowRadius">-1.0</item>
|
<item name="languageOnSpacebarTextShadowRadius">-1.0</item>
|
||||||
</style>
|
</style>
|
||||||
<!-- Though {@link EmojiPalettesView} doesn't extend {@link KeyboardView}, some views inside it,
|
<!-- Though {@link com.android.inputmethod.keyboard.emoji.EmojiPalettesView} doesn't extend
|
||||||
for instance delete button, need themed {@link KeyboardView} attributes. -->
|
{@link com.android.inputmethod.keyboard.KeyboardView}, some views inside it, for instance
|
||||||
|
delete button, need themed {@link com.android.inputmethod.keyboard.KeyboardView}
|
||||||
|
attributes. -->
|
||||||
<style
|
<style
|
||||||
name="EmojiPalettesView.LXX_Light"
|
name="EmojiPalettesView.LXX_Light"
|
||||||
parent="MainKeyboardView.LXX_Light"
|
parent="MainKeyboardView.LXX_Light"
|
||||||
|
|
|
@ -82,10 +82,12 @@ public class CursorAnchorInfoCompatWrapper {
|
||||||
throw new UnsupportedOperationException("not supported.");
|
throw new UnsupportedOperationException("not supported.");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("unused")
|
||||||
public RectF getCharacterBounds(final int index) {
|
public RectF getCharacterBounds(final int index) {
|
||||||
throw new UnsupportedOperationException("not supported.");
|
throw new UnsupportedOperationException("not supported.");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("unused")
|
||||||
public int getCharacterBoundsFlags(final int index) {
|
public int getCharacterBoundsFlags(final int index) {
|
||||||
throw new UnsupportedOperationException("not supported.");
|
throw new UnsupportedOperationException("not supported.");
|
||||||
}
|
}
|
||||||
|
|
|
@ -52,6 +52,7 @@ public final class InputMethodSubtypeCompatUtils {
|
||||||
// This utility class is not publicly instantiable.
|
// This utility class is not publicly instantiable.
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("deprecation")
|
||||||
public static InputMethodSubtype newInputMethodSubtype(int nameId, int iconId, String locale,
|
public static InputMethodSubtype newInputMethodSubtype(int nameId, int iconId, String locale,
|
||||||
String mode, String extraValue, boolean isAuxiliary,
|
String mode, String extraValue, boolean isAuxiliary,
|
||||||
boolean overridesImplicitlyEnabledSubtype, int id) {
|
boolean overridesImplicitlyEnabledSubtype, int id) {
|
||||||
|
|
|
@ -18,7 +18,9 @@ package com.android.inputmethod.dictionarypack;
|
||||||
|
|
||||||
import com.android.inputmethod.latin.utils.FragmentUtils;
|
import com.android.inputmethod.latin.utils.FragmentUtils;
|
||||||
|
|
||||||
|
import android.annotation.TargetApi;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
|
import android.os.Build;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.preference.PreferenceActivity;
|
import android.preference.PreferenceActivity;
|
||||||
|
|
||||||
|
@ -44,8 +46,8 @@ public final class DictionarySettingsActivity extends PreferenceActivity {
|
||||||
return modIntent;
|
return modIntent;
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: Uncomment the override annotation once we start using SDK version 19.
|
@TargetApi(Build.VERSION_CODES.KITKAT)
|
||||||
// @Override
|
@Override
|
||||||
public boolean isValidFragment(String fragmentName) {
|
public boolean isValidFragment(String fragmentName) {
|
||||||
return FragmentUtils.isValidFragment(fragmentName);
|
return FragmentUtils.isValidFragment(fragmentName);
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,6 +24,7 @@ import android.view.View;
|
||||||
import android.widget.Button;
|
import android.widget.Button;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
|
||||||
|
import com.android.inputmethod.annotations.ExternallyReferenced;
|
||||||
import com.android.inputmethod.latin.R;
|
import com.android.inputmethod.latin.R;
|
||||||
|
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
|
@ -63,11 +64,19 @@ public final class DownloadOverMeteredDialog extends Activity {
|
||||||
allowButton.setText(String.format(allowButtonFormat, ((float)size)/(1024*1024)));
|
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) {
|
public void onClickDeny(final View v) {
|
||||||
UpdateHandler.setDownloadOverMeteredSetting(this, false);
|
UpdateHandler.setDownloadOverMeteredSetting(this, false);
|
||||||
finish();
|
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) {
|
public void onClickAllow(final View v) {
|
||||||
UpdateHandler.setDownloadOverMeteredSetting(this, true);
|
UpdateHandler.setDownloadOverMeteredSetting(this, true);
|
||||||
UpdateHandler.installIfNeverRequested(this, mClientId, mWordListToDownload,
|
UpdateHandler.installIfNeverRequested(this, mClientId, mWordListToDownload,
|
||||||
|
|
|
@ -97,7 +97,8 @@ public class CombinerChain {
|
||||||
* new event. However it may never be null.
|
* new event. However it may never be null.
|
||||||
*/
|
*/
|
||||||
@Nonnull
|
@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);
|
final ArrayList<Event> modifiablePreviousEvents = new ArrayList<>(previousEvents);
|
||||||
Event event = newEvent;
|
Event event = newEvent;
|
||||||
for (final Combiner combiner : mCombiners) {
|
for (final Combiner combiner : mCombiners) {
|
||||||
|
|
|
@ -217,11 +217,8 @@ public class DeadKeyCombiner implements Combiner {
|
||||||
|
|
||||||
@Nonnull
|
@Nonnull
|
||||||
private static Event createEventChainFromSequence(final @Nonnull CharSequence text,
|
private static Event createEventChainFromSequence(final @Nonnull CharSequence text,
|
||||||
final Event originalEvent) {
|
@Nonnull final Event originalEvent) {
|
||||||
if (text.length() <= 0) {
|
Event lastEvent = originalEvent;
|
||||||
return originalEvent;
|
|
||||||
}
|
|
||||||
Event lastEvent = null;
|
|
||||||
int codePoint = 0;
|
int codePoint = 0;
|
||||||
for (int i = text.length(); i > 0; i -= Character.charCount(codePoint)) {
|
for (int i = text.length(); i > 0; i -= Character.charCount(codePoint)) {
|
||||||
codePoint = Character.codePointBefore(text, i);
|
codePoint = Character.codePointBefore(text, i);
|
||||||
|
|
|
@ -223,6 +223,7 @@ public class Event {
|
||||||
* Creates an input event representing the manual pick of a punctuation suggestion.
|
* Creates an input event representing the manual pick of a punctuation suggestion.
|
||||||
* @return an event for this suggestion pick.
|
* @return an event for this suggestion pick.
|
||||||
*/
|
*/
|
||||||
|
@Nonnull
|
||||||
public static Event createPunctuationSuggestionPickedEvent(
|
public static Event createPunctuationSuggestionPickedEvent(
|
||||||
final SuggestedWordInfo suggestedWordInfo) {
|
final SuggestedWordInfo suggestedWordInfo) {
|
||||||
final int primaryCode = suggestedWordInfo.mWord.charAt(0);
|
final int primaryCode = suggestedWordInfo.mWord.charAt(0);
|
||||||
|
|
|
@ -74,7 +74,7 @@ public class TextDecorator {
|
||||||
void onClickComposingTextToAddToDictionary(final String word);
|
void onClickComposingTextToAddToDictionary(final String word);
|
||||||
}
|
}
|
||||||
|
|
||||||
public TextDecorator(final Listener listener) {
|
public TextDecorator(@Nullable final Listener listener) {
|
||||||
mListener = (listener != null) ? listener : EMPTY_LISTENER;
|
mListener = (listener != null) ? listener : EMPTY_LISTENER;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -83,7 +83,7 @@ public class TextDecorator {
|
||||||
* delegated to the associated UI operator.
|
* delegated to the associated UI operator.
|
||||||
* @param uiOperator the UI operator to be associated.
|
* @param uiOperator the UI operator to be associated.
|
||||||
*/
|
*/
|
||||||
public void setUiOperator(final TextDecoratorUiOperator uiOperator) {
|
public void setUiOperator(@Nonnull final TextDecoratorUiOperator uiOperator) {
|
||||||
mUiOperator.disposeUi();
|
mUiOperator.disposeUi();
|
||||||
mUiOperator = uiOperator;
|
mUiOperator = uiOperator;
|
||||||
mUiOperator.setOnClickListener(getOnClickHandler());
|
mUiOperator.setOnClickListener(getOnClickHandler());
|
||||||
|
@ -347,12 +347,14 @@ public class TextDecorator {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Nonnull
|
||||||
private final static Listener EMPTY_LISTENER = new Listener() {
|
private final static Listener EMPTY_LISTENER = new Listener() {
|
||||||
@Override
|
@Override
|
||||||
public void onClickComposingTextToAddToDictionary(final String word) {
|
public void onClickComposingTextToAddToDictionary(final String word) {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@Nonnull
|
||||||
private final static TextDecoratorUiOperator EMPTY_UI_OPERATOR = new TextDecoratorUiOperator() {
|
private final static TextDecoratorUiOperator EMPTY_UI_OPERATOR = new TextDecoratorUiOperator() {
|
||||||
@Override
|
@Override
|
||||||
public void disposeUi() {
|
public void disposeUi() {
|
||||||
|
|
|
@ -19,6 +19,7 @@ package com.android.inputmethod.keyboard.internal;
|
||||||
import android.graphics.Canvas;
|
import android.graphics.Canvas;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
|
|
||||||
|
import com.android.inputmethod.keyboard.MainKeyboardView;
|
||||||
import com.android.inputmethod.keyboard.PointerTracker;
|
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.
|
* The class that is overriding this method must call this super implementation.
|
||||||
*
|
*
|
||||||
* @param originCoords the top-left coordinates of the {@link MainKeyboardView} in
|
* @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}.
|
* extended class, such as {@link GestureTrailsDrawingPreview}.
|
||||||
* @param width the width of {@link MainKeyboardView}.
|
* @param width the width of {@link MainKeyboardView}.
|
||||||
* @param height the height of {@link MainKeyboardView}.
|
* @param height the height of {@link MainKeyboardView}.
|
||||||
|
|
|
@ -47,6 +47,8 @@ import java.io.IOException;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
|
|
||||||
|
import javax.annotation.Nonnull;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Keyboard Building helper.
|
* Keyboard Building helper.
|
||||||
*
|
*
|
||||||
|
@ -859,7 +861,7 @@ public class KeyboardBuilder<KP extends KeyboardParams> {
|
||||||
mTopEdge = false;
|
mTopEdge = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void endKey(final Key key) {
|
private void endKey(@Nonnull final Key key) {
|
||||||
mParams.onAddKey(key);
|
mParams.onAddKey(key);
|
||||||
if (mLeftEdge) {
|
if (mLeftEdge) {
|
||||||
key.markAsLeftEdge(mParams);
|
key.markAsLeftEdge(mParams);
|
||||||
|
|
|
@ -31,6 +31,8 @@ import java.util.Arrays;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
|
|
||||||
|
import javax.annotation.Nonnull;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The more key specification object. The more keys are an array of {@link MoreKeySpec}.
|
* 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);
|
mIconId = KeySpecParser.getIconId(moreKeySpec);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Nonnull
|
||||||
public Key buildKey(final int x, final int y, final int labelFlags,
|
public Key buildKey(final int x, final int y, final int labelFlags,
|
||||||
final KeyboardParams params) {
|
final KeyboardParams params) {
|
||||||
return new Key(mLabel, mIconId, mCode, mOutputText, null /* hintLabel */, labelFlags,
|
return new Key(mLabel, mIconId, mCode, mOutputText, null /* hintLabel */, labelFlags,
|
||||||
|
|
|
@ -80,7 +80,7 @@ public final class TouchPositionCorrection {
|
||||||
return mRadii.length;
|
return mRadii.length;
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("static-method")
|
@SuppressWarnings({ "static-method", "unused" })
|
||||||
public float getX(final int row) {
|
public float getX(final int row) {
|
||||||
return 0.0f;
|
return 0.0f;
|
||||||
// Touch position correction data for X coordinate is obsolete.
|
// Touch position correction data for X coordinate is obsolete.
|
||||||
|
|
|
@ -351,15 +351,19 @@ public final class BinaryDictionary extends Dictionary {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getFrequency(final String word) {
|
public int getFrequency(final String word) {
|
||||||
if (TextUtils.isEmpty(word)) return NOT_A_PROBABILITY;
|
if (TextUtils.isEmpty(word)) {
|
||||||
int[] codePoints = StringUtils.toCodePointArray(word);
|
return NOT_A_PROBABILITY;
|
||||||
|
}
|
||||||
|
final int[] codePoints = StringUtils.toCodePointArray(word);
|
||||||
return getProbabilityNative(mNativeDict, codePoints);
|
return getProbabilityNative(mNativeDict, codePoints);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getMaxFrequencyOfExactMatches(final String word) {
|
public int getMaxFrequencyOfExactMatches(final String word) {
|
||||||
if (TextUtils.isEmpty(word)) return NOT_A_PROBABILITY;
|
if (TextUtils.isEmpty(word)) {
|
||||||
int[] codePoints = StringUtils.toCodePointArray(word);
|
return NOT_A_PROBABILITY;
|
||||||
|
}
|
||||||
|
final int[] codePoints = StringUtils.toCodePointArray(word);
|
||||||
return getMaxProbabilityOfExactMatchesNative(mNativeDict, codePoints);
|
return getMaxProbabilityOfExactMatchesNative(mNativeDict, codePoints);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -523,7 +527,9 @@ public final class BinaryDictionary extends Dictionary {
|
||||||
|
|
||||||
@UsedForTesting
|
@UsedForTesting
|
||||||
public void addMultipleDictionaryEntries(final LanguageModelParam[] languageModelParams) {
|
public void addMultipleDictionaryEntries(final LanguageModelParam[] languageModelParams) {
|
||||||
if (!isValidDictionary()) return;
|
if (!isValidDictionary()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
int processedParamCount = 0;
|
int processedParamCount = 0;
|
||||||
while (processedParamCount < languageModelParams.length) {
|
while (processedParamCount < languageModelParams.length) {
|
||||||
if (needsToRunGC(true /* mindsBlockByGC */)) {
|
if (needsToRunGC(true /* mindsBlockByGC */)) {
|
||||||
|
@ -550,7 +556,9 @@ public final class BinaryDictionary extends Dictionary {
|
||||||
|
|
||||||
// Flush to dict file if the dictionary has been updated.
|
// Flush to dict file if the dictionary has been updated.
|
||||||
public boolean flush() {
|
public boolean flush() {
|
||||||
if (!isValidDictionary()) return false;
|
if (!isValidDictionary()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
if (mHasUpdated) {
|
if (mHasUpdated) {
|
||||||
if (!flushNative(mNativeDict, mDictFilePath)) {
|
if (!flushNative(mNativeDict, mDictFilePath)) {
|
||||||
return false;
|
return false;
|
||||||
|
@ -570,7 +578,9 @@ public final class BinaryDictionary extends Dictionary {
|
||||||
|
|
||||||
// Run GC and flush to dict file.
|
// Run GC and flush to dict file.
|
||||||
public boolean flushWithGC() {
|
public boolean flushWithGC() {
|
||||||
if (!isValidDictionary()) return false;
|
if (!isValidDictionary()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
if (!flushWithGCNative(mNativeDict, mDictFilePath)) {
|
if (!flushWithGCNative(mNativeDict, mDictFilePath)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -585,7 +595,9 @@ public final class BinaryDictionary extends Dictionary {
|
||||||
* @return whether GC is needed to run or not.
|
* @return whether GC is needed to run or not.
|
||||||
*/
|
*/
|
||||||
public boolean needsToRunGC(final boolean mindsBlockByGC) {
|
public boolean needsToRunGC(final boolean mindsBlockByGC) {
|
||||||
if (!isValidDictionary()) return false;
|
if (!isValidDictionary()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
return needsToRunGCNative(mNativeDict, mindsBlockByGC);
|
return needsToRunGCNative(mNativeDict, mindsBlockByGC);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -630,7 +642,9 @@ public final class BinaryDictionary extends Dictionary {
|
||||||
|
|
||||||
@UsedForTesting
|
@UsedForTesting
|
||||||
public String getPropertyForGettingStats(final String query) {
|
public String getPropertyForGettingStats(final String query) {
|
||||||
if (!isValidDictionary()) return "";
|
if (!isValidDictionary()) {
|
||||||
|
return "";
|
||||||
|
}
|
||||||
return getPropertyNative(mNativeDict, query);
|
return getPropertyNative(mNativeDict, query);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -223,7 +223,7 @@ final public class BinaryDictionaryGetter {
|
||||||
// ## HACK ## we prevent usage of a dictionary before version 18. The reason for this is, since
|
// ## 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
|
// those do not include whitelist entries, the new code with an old version of the dictionary
|
||||||
// would lose whitelist functionality.
|
// would lose whitelist functionality.
|
||||||
private static boolean hackCanUseDictionaryFile(final Locale locale, final File file) {
|
private static boolean hackCanUseDictionaryFile(final File file) {
|
||||||
try {
|
try {
|
||||||
// Read the version of the file
|
// Read the version of the file
|
||||||
final DictionaryHeader header = BinaryDictionaryUtils.getHeader(file);
|
final DictionaryHeader header = BinaryDictionaryUtils.getHeader(file);
|
||||||
|
@ -275,7 +275,7 @@ final public class BinaryDictionaryGetter {
|
||||||
// cachedWordLists may not be null, see doc for getCachedDictionaryList
|
// cachedWordLists may not be null, see doc for getCachedDictionaryList
|
||||||
for (final File f : cachedWordLists) {
|
for (final File f : cachedWordLists) {
|
||||||
final String wordListId = DictionaryInfoUtils.getWordListIdFromFileName(f.getName());
|
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)) {
|
if (canUse && DictionaryInfoUtils.isMainWordListId(wordListId)) {
|
||||||
foundMainDict = true;
|
foundMainDict = true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -233,8 +233,8 @@ public final class Constants {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Special keys code. Must be negative.
|
* Special keys code. Must be negative.
|
||||||
* These should be aligned with {@link KeyboardCodesSet#ID_TO_NAME},
|
* These should be aligned with constants in
|
||||||
* {@link KeyboardCodesSet#DEFAULT}, and {@link KeyboardCodesSet#RTL}.
|
* {@link com.android.inputmethod.keyboard.internal.KeyboardCodesSet}.
|
||||||
*/
|
*/
|
||||||
public static final int CODE_SHIFT = -1;
|
public static final int CODE_SHIFT = -1;
|
||||||
public static final int CODE_CAPSLOCK = -2;
|
public static final int CODE_CAPSLOCK = -2;
|
||||||
|
@ -309,8 +309,8 @@ public final class Constants {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Default capacity of gesture points container.
|
* Default capacity of gesture points container.
|
||||||
* This constant is used by {@link BatchInputArbiter} and etc. to preallocate regions that
|
* This constant is used by {@link com.android.inputmethod.keyboard.internal.BatchInputArbiter}
|
||||||
* contain gesture event points.
|
* and etc. to preallocate regions that contain gesture event points.
|
||||||
*/
|
*/
|
||||||
public static final int DEFAULT_GESTURE_POINTS_CAPACITY = 128;
|
public static final int DEFAULT_GESTURE_POINTS_CAPACITY = 128;
|
||||||
|
|
||||||
|
|
|
@ -28,7 +28,7 @@ import android.provider.ContactsContract;
|
||||||
import android.provider.ContactsContract.Contacts;
|
import android.provider.ContactsContract.Contacts;
|
||||||
import android.util.Log;
|
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.personalization.AccountUtils;
|
||||||
import com.android.inputmethod.latin.utils.ExecutorUtils;
|
import com.android.inputmethod.latin.utils.ExecutorUtils;
|
||||||
import com.android.inputmethod.latin.utils.StringUtils;
|
import com.android.inputmethod.latin.utils.StringUtils;
|
||||||
|
@ -82,7 +82,8 @@ public class ContactsBinaryDictionary extends ExpandableBinaryDictionary {
|
||||||
reloadDictionaryIfRequired();
|
reloadDictionaryIfRequired();
|
||||||
}
|
}
|
||||||
|
|
||||||
@UsedForTesting
|
// Note: This method is called by {@link DictionaryFacilitator} using Java reflection.
|
||||||
|
@ExternallyReferenced
|
||||||
public static ContactsBinaryDictionary getDictionary(final Context context, final Locale locale,
|
public static ContactsBinaryDictionary getDictionary(final Context context, final Locale locale,
|
||||||
final File dictFile, final String dictNamePrefix) {
|
final File dictFile, final String dictNamePrefix) {
|
||||||
return new ContactsBinaryDictionary(context, locale, dictFile, dictNamePrefix + NAME);
|
return new ContactsBinaryDictionary(context, locale, dictFile, dictNamePrefix + NAME);
|
||||||
|
|
|
@ -120,10 +120,18 @@ public abstract class Dictionary {
|
||||||
*/
|
*/
|
||||||
abstract public boolean isInDictionary(final String word);
|
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) {
|
public int getFrequency(final String word) {
|
||||||
return NOT_A_PROBABILITY;
|
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) {
|
public int getMaxFrequencyOfExactMatches(final String word) {
|
||||||
return NOT_A_PROBABILITY;
|
return NOT_A_PROBABILITY;
|
||||||
}
|
}
|
||||||
|
|
|
@ -53,6 +53,9 @@ import java.util.concurrent.ConcurrentHashMap;
|
||||||
import java.util.concurrent.CountDownLatch;
|
import java.util.concurrent.CountDownLatch;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
|
import javax.annotation.Nonnull;
|
||||||
|
import javax.annotation.Nullable;
|
||||||
|
|
||||||
// TODO: Consolidate dictionaries in native code.
|
// TODO: Consolidate dictionaries in native code.
|
||||||
public class DictionaryFacilitator {
|
public class DictionaryFacilitator {
|
||||||
public static final String TAG = DictionaryFacilitator.class.getSimpleName();
|
public static final String TAG = DictionaryFacilitator.class.getSimpleName();
|
||||||
|
@ -274,6 +277,7 @@ public class DictionaryFacilitator {
|
||||||
mMostProbableDictionaryGroup = newMostProbableDictionaryGroup;
|
mMostProbableDictionaryGroup = newMostProbableDictionaryGroup;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Nullable
|
||||||
private static ExpandableBinaryDictionary getSubDict(final String dictType,
|
private static ExpandableBinaryDictionary getSubDict(final String dictType,
|
||||||
final Context context, final Locale locale, final File dictFile,
|
final Context context, final Locale locale, final File dictFile,
|
||||||
final String dictNamePrefix) {
|
final String dictNamePrefix) {
|
||||||
|
@ -303,6 +307,7 @@ public class DictionaryFacilitator {
|
||||||
usePersonalizedDicts, forceReloadMainDictionary, listener, "" /* dictNamePrefix */);
|
usePersonalizedDicts, forceReloadMainDictionary, listener, "" /* dictNamePrefix */);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Nullable
|
||||||
static DictionaryGroup findDictionaryGroupWithLocale(final DictionaryGroup[] dictionaryGroups,
|
static DictionaryGroup findDictionaryGroupWithLocale(final DictionaryGroup[] dictionaryGroups,
|
||||||
final Locale locale) {
|
final Locale locale) {
|
||||||
for (int i = 0; i < dictionaryGroups.length; ++i) {
|
for (int i = 0; i < dictionaryGroups.length; ++i) {
|
||||||
|
@ -317,7 +322,7 @@ public class DictionaryFacilitator {
|
||||||
final Locale[] newLocales,
|
final Locale[] newLocales,
|
||||||
final boolean useContactsDict, final boolean usePersonalizedDicts,
|
final boolean useContactsDict, final boolean usePersonalizedDicts,
|
||||||
final boolean forceReloadMainDictionary,
|
final boolean forceReloadMainDictionary,
|
||||||
final DictionaryInitializationListener listener,
|
@Nullable final DictionaryInitializationListener listener,
|
||||||
final String dictNamePrefix) {
|
final String dictNamePrefix) {
|
||||||
final HashMap<Locale, ArrayList<String>> existingDictsToCleanup = new HashMap<>();
|
final HashMap<Locale, ArrayList<String>> existingDictsToCleanup = new HashMap<>();
|
||||||
// TODO: Make subDictTypesToUse configurable by resource or a static final list.
|
// 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,
|
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 boolean blockPotentiallyOffensive) {
|
||||||
final DictionaryGroup dictionaryGroup = getDictionaryGroupForMostProbableLanguage();
|
final DictionaryGroup dictionaryGroup = getDictionaryGroupForMostProbableLanguage();
|
||||||
final String[] words = suggestion.split(Constants.WORD_SEPARATOR);
|
final String[] words = suggestion.split(Constants.WORD_SEPARATOR);
|
||||||
|
|
|
@ -53,6 +53,10 @@ import javax.annotation.Nullable;
|
||||||
* Abstract base class for an expandable dictionary that can be created and updated dynamically
|
* 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
|
* 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.
|
* 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 {
|
abstract public class ExpandableBinaryDictionary extends Dictionary {
|
||||||
private static final boolean DEBUG = false;
|
private static final boolean DEBUG = false;
|
||||||
|
|
|
@ -139,7 +139,10 @@ public final class InputView extends FrameLayout {
|
||||||
return y - mEventReceivingRect.top;
|
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) {}
|
protected void onForwardingEvent(final MotionEvent me) {}
|
||||||
|
|
||||||
// Returns true if a {@link MotionEvent} is needed to be forwarded to
|
// Returns true if a {@link MotionEvent} is needed to be forwarded to
|
||||||
|
|
|
@ -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
|
// This method is public for testability of LatinIME, but also in the future it should
|
||||||
// completely replace #onCodeInput.
|
// completely replace #onCodeInput.
|
||||||
public void onEvent(final Event event) {
|
public void onEvent(@Nonnull final Event event) {
|
||||||
if (Constants.CODE_SHORTCUT == event.mKeyCode) {
|
if (Constants.CODE_SHORTCUT == event.mKeyCode) {
|
||||||
mSubtypeSwitcher.switchToShortcutIME(this);
|
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
|
// 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.
|
// 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
|
// 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,
|
public static Event createSoftwareKeypressEvent(final int keyCodeOrCodePoint, final int keyX,
|
||||||
final int keyY, final boolean isKeyRepeat) {
|
final int keyY, final boolean isKeyRepeat) {
|
||||||
final int keyCode;
|
final int keyCode;
|
||||||
|
|
|
@ -23,13 +23,17 @@ import com.android.inputmethod.latin.utils.StringUtils;
|
||||||
|
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
|
|
||||||
|
import javax.annotation.Nonnull;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class to represent information of previous words. This class is used to add n-gram entries
|
* 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.
|
* into binary dictionaries, to get predictions, and to get suggestions.
|
||||||
*/
|
*/
|
||||||
public class NgramContext {
|
public class NgramContext {
|
||||||
|
@Nonnull
|
||||||
public static final NgramContext EMPTY_PREV_WORDS_INFO =
|
public static final NgramContext EMPTY_PREV_WORDS_INFO =
|
||||||
new NgramContext(WordInfo.EMPTY_WORD_INFO);
|
new NgramContext(WordInfo.EMPTY_WORD_INFO);
|
||||||
|
@Nonnull
|
||||||
public static final NgramContext BEGINNING_OF_SENTENCE =
|
public static final NgramContext BEGINNING_OF_SENTENCE =
|
||||||
new NgramContext(WordInfo.BEGINNING_OF_SENTENCE_WORD_INFO);
|
new NgramContext(WordInfo.BEGINNING_OF_SENTENCE_WORD_INFO);
|
||||||
|
|
||||||
|
@ -37,7 +41,9 @@ public class NgramContext {
|
||||||
* Word information used to represent previous words information.
|
* Word information used to represent previous words information.
|
||||||
*/
|
*/
|
||||||
public static class WordInfo {
|
public static class WordInfo {
|
||||||
|
@Nonnull
|
||||||
public static final WordInfo EMPTY_WORD_INFO = new WordInfo(null);
|
public static final WordInfo EMPTY_WORD_INFO = new WordInfo(null);
|
||||||
|
@Nonnull
|
||||||
public static final WordInfo BEGINNING_OF_SENTENCE_WORD_INFO = new WordInfo();
|
public static final WordInfo BEGINNING_OF_SENTENCE_WORD_INFO = new WordInfo();
|
||||||
|
|
||||||
// This is an empty char sequence when mIsBeginningOfSentence is true.
|
// This is an empty char sequence when mIsBeginningOfSentence is true.
|
||||||
|
@ -97,6 +103,7 @@ public class NgramContext {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create next prevWordsInfo using current prevWordsInfo.
|
// Create next prevWordsInfo using current prevWordsInfo.
|
||||||
|
@Nonnull
|
||||||
public NgramContext getNextNgramContext(final WordInfo wordInfo) {
|
public NgramContext getNextNgramContext(final WordInfo wordInfo) {
|
||||||
final int nextPrevWordCount = Math.min(Constants.MAX_PREV_WORD_COUNT_FOR_N_GRAM,
|
final int nextPrevWordCount = Math.min(Constants.MAX_PREV_WORD_COUNT_FOR_N_GRAM,
|
||||||
mPrevWordsCount + 1);
|
mPrevWordsCount + 1);
|
||||||
|
|
|
@ -56,7 +56,7 @@ public final class PunctuationSuggestions extends SuggestedWords {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@inheritDoc}
|
* {@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.
|
* The suggested punctuation should be gotten by parsing the key specification.
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
|
@ -70,7 +70,7 @@ public final class PunctuationSuggestions extends SuggestedWords {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@inheritDoc}
|
* {@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.
|
* The displayed text should be gotten by parsing the key specification.
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
|
@ -82,7 +82,7 @@ public final class PunctuationSuggestions extends SuggestedWords {
|
||||||
/**
|
/**
|
||||||
* {@inheritDoc}
|
* {@inheritDoc}
|
||||||
* Note that {@link #getWord(int)} returns a suggested punctuation. We should create a
|
* 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
|
@Override
|
||||||
public SuggestedWordInfo getInfo(final int index) {
|
public SuggestedWordInfo getInfo(final int index) {
|
||||||
|
|
|
@ -44,6 +44,8 @@ import com.android.inputmethod.latin.utils.SpannableStringUtils;
|
||||||
import com.android.inputmethod.latin.utils.StringUtils;
|
import com.android.inputmethod.latin.utils.StringUtils;
|
||||||
import com.android.inputmethod.latin.utils.TextRange;
|
import com.android.inputmethod.latin.utils.TextRange;
|
||||||
|
|
||||||
|
import javax.annotation.Nonnull;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Enrichment class for InputConnection to simplify interaction and add functionality.
|
* Enrichment class for InputConnection to simplify interaction and add functionality.
|
||||||
*
|
*
|
||||||
|
@ -591,6 +593,7 @@ public final class RichInputConnection implements PrivateCommandPerformer {
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("unused")
|
@SuppressWarnings("unused")
|
||||||
|
@Nonnull
|
||||||
public NgramContext getNgramContextFromNthPreviousWord(
|
public NgramContext getNgramContextFromNthPreviousWord(
|
||||||
final SpacingAndPunctuations spacingAndPunctuations, final int n) {
|
final SpacingAndPunctuations spacingAndPunctuations, final int n) {
|
||||||
mIC = mParent.getCurrentInputConnection();
|
mIC = mParent.getCurrentInputConnection();
|
||||||
|
|
|
@ -38,6 +38,8 @@ import java.util.Collections;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
import javax.annotation.Nonnull;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Enrichment class for InputMethodManager to simplify interaction and add functionality.
|
* Enrichment class for InputMethodManager to simplify interaction and add functionality.
|
||||||
*/
|
*/
|
||||||
|
@ -301,12 +303,13 @@ public class RichInputMethodManager {
|
||||||
return INDEX_NOT_FOUND;
|
return INDEX_NOT_FOUND;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Nonnull
|
||||||
public InputMethodSubtype getCurrentRawSubtype() {
|
public InputMethodSubtype getCurrentRawSubtype() {
|
||||||
return mImmWrapper.mImm.getCurrentInputMethodSubtype();
|
return mImmWrapper.mImm.getCurrentInputMethodSubtype();
|
||||||
}
|
}
|
||||||
|
|
||||||
public RichInputMethodSubtype createCurrentRichInputMethodSubtype(
|
public RichInputMethodSubtype createCurrentRichInputMethodSubtype(
|
||||||
final InputMethodSubtype rawSubtype) {
|
@Nonnull final InputMethodSubtype rawSubtype) {
|
||||||
return AdditionalFeaturesSettingUtils.createRichInputMethodSubtype(this, rawSubtype,
|
return AdditionalFeaturesSettingUtils.createRichInputMethodSubtype(this, rawSubtype,
|
||||||
mContext);
|
mContext);
|
||||||
}
|
}
|
||||||
|
|
|
@ -44,6 +44,8 @@ import java.util.Locale;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
|
import javax.annotation.Nonnull;
|
||||||
|
|
||||||
public final class SubtypeSwitcher {
|
public final class SubtypeSwitcher {
|
||||||
private static boolean DBG = DebugFlags.DEBUG_ENABLED;
|
private static boolean DBG = DebugFlags.DEBUG_ENABLED;
|
||||||
private static final String TAG = SubtypeSwitcher.class.getSimpleName();
|
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.
|
// 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 =
|
final RichInputMethodSubtype richSubtype =
|
||||||
mRichImm.createCurrentRichInputMethodSubtype(newSubtype);
|
mRichImm.createCurrentRichInputMethodSubtype(newSubtype);
|
||||||
if (DBG) {
|
if (DBG) {
|
||||||
|
|
|
@ -28,7 +28,7 @@ import android.provider.UserDictionary.Words;
|
||||||
import android.text.TextUtils;
|
import android.text.TextUtils;
|
||||||
import android.util.Log;
|
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.compat.UserDictionaryCompatUtils;
|
||||||
import com.android.inputmethod.latin.utils.SubtypeLocaleUtils;
|
import com.android.inputmethod.latin.utils.SubtypeLocaleUtils;
|
||||||
|
|
||||||
|
@ -101,7 +101,8 @@ public class UserBinaryDictionary extends ExpandableBinaryDictionary {
|
||||||
reloadDictionaryIfRequired();
|
reloadDictionaryIfRequired();
|
||||||
}
|
}
|
||||||
|
|
||||||
@UsedForTesting
|
// Note: This method is called by {@link DictionaryFacilitator} using Java reflection.
|
||||||
|
@ExternallyReferenced
|
||||||
public static UserBinaryDictionary getDictionary(final Context context, final Locale locale,
|
public static UserBinaryDictionary getDictionary(final Context context, final Locale locale,
|
||||||
final File dictFile, final String dictNamePrefix) {
|
final File dictFile, final String dictNamePrefix) {
|
||||||
return new UserBinaryDictionary(context, locale, false /* alsoUseMoreRestrictiveLocales */,
|
return new UserBinaryDictionary(context, locale, false /* alsoUseMoreRestrictiveLocales */,
|
||||||
|
|
|
@ -182,7 +182,7 @@ public final class WordComposer {
|
||||||
* @return the processed event. Never null, but may be marked as consumed.
|
* @return the processed event. Never null, but may be marked as consumed.
|
||||||
*/
|
*/
|
||||||
@Nonnull
|
@Nonnull
|
||||||
public Event processEvent(final Event event) {
|
public Event processEvent(@Nonnull final Event event) {
|
||||||
final Event processedEvent = mCombinerChain.processEvent(mEvents, event);
|
final Event processedEvent = mCombinerChain.processEvent(mEvents, event);
|
||||||
// The retained state of the combiner chain may have changed while processing the event,
|
// The retained state of the combiner chain may have changed while processing the event,
|
||||||
// so we need to update our cache.
|
// so we need to update our cache.
|
||||||
|
|
|
@ -68,6 +68,8 @@ import java.util.ArrayList;
|
||||||
import java.util.TreeSet;
|
import java.util.TreeSet;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
|
import javax.annotation.Nonnull;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This class manages the input logic.
|
* This class manages the input logic.
|
||||||
*/
|
*/
|
||||||
|
@ -454,8 +456,8 @@ public final class InputLogic {
|
||||||
* {@link com.android.inputmethod.keyboard.KeyboardSwitcher#getKeyboardShiftMode()}
|
* {@link com.android.inputmethod.keyboard.KeyboardSwitcher#getKeyboardShiftMode()}
|
||||||
* @return the complete transaction object
|
* @return the complete transaction object
|
||||||
*/
|
*/
|
||||||
public InputTransaction onCodeInput(final SettingsValues settingsValues, final Event event,
|
public InputTransaction onCodeInput(final SettingsValues settingsValues,
|
||||||
final int keyboardShiftMode,
|
@Nonnull final Event event, final int keyboardShiftMode,
|
||||||
// TODO: remove these arguments
|
// TODO: remove these arguments
|
||||||
final int currentKeyboardScriptId, final LatinIME.UIHandler handler) {
|
final int currentKeyboardScriptId, final LatinIME.UIHandler handler) {
|
||||||
final Event processedEvent = mWordComposer.processEvent(event);
|
final Event processedEvent = mWordComposer.processEvent(event);
|
||||||
|
@ -1373,7 +1375,7 @@ public final class InputLogic {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void performAdditionToUserHistoryDictionary(final SettingsValues settingsValues,
|
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.
|
// 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
|
// That's to avoid unintended additions in some sensitive fields, or fields that
|
||||||
// expect to receive non-words.
|
// expect to receive non-words.
|
||||||
|
@ -2301,7 +2303,7 @@ public final class InputLogic {
|
||||||
* Sets the UI operator for {@link TextDecorator}.
|
* Sets the UI operator for {@link TextDecorator}.
|
||||||
* @param uiOperator the UI operator which should be associated with {@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);
|
mTextDecorator.setUiOperator(uiOperator);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -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.
|
* 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.
|
* TODO: Remove @UsedForTesting after this method is actually used.
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -18,7 +18,7 @@ package com.android.inputmethod.latin.personalization;
|
||||||
|
|
||||||
import android.content.Context;
|
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.Dictionary;
|
||||||
import com.android.inputmethod.latin.ExpandableBinaryDictionary;
|
import com.android.inputmethod.latin.ExpandableBinaryDictionary;
|
||||||
|
|
||||||
|
@ -36,7 +36,9 @@ public class ContextualDictionary extends ExpandableBinaryDictionary {
|
||||||
clear();
|
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,
|
public static ContextualDictionary getDictionary(final Context context, final Locale locale,
|
||||||
final File dictFile, final String dictNamePrefix) {
|
final File dictFile, final String dictNamePrefix) {
|
||||||
return new ContextualDictionary(context, locale, dictFile);
|
return new ContextualDictionary(context, locale, dictFile);
|
||||||
|
|
|
@ -18,7 +18,7 @@ package com.android.inputmethod.latin.personalization;
|
||||||
|
|
||||||
import android.content.Context;
|
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.Dictionary;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
|
@ -33,7 +33,9 @@ public class PersonalizationDictionary extends DecayingExpandableBinaryDictionar
|
||||||
Dictionary.TYPE_PERSONALIZATION, null /* dictFile */);
|
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,
|
public static PersonalizationDictionary getDictionary(final Context context,
|
||||||
final Locale locale, final File dictFile, final String dictNamePrefix) {
|
final Locale locale, final File dictFile, final String dictNamePrefix) {
|
||||||
return PersonalizationHelper.getPersonalizationDictionary(context, locale);
|
return PersonalizationHelper.getPersonalizationDictionary(context, locale);
|
||||||
|
|
|
@ -18,7 +18,7 @@ package com.android.inputmethod.latin.personalization;
|
||||||
|
|
||||||
import android.content.Context;
|
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.Constants;
|
||||||
import com.android.inputmethod.latin.Dictionary;
|
import com.android.inputmethod.latin.Dictionary;
|
||||||
import com.android.inputmethod.latin.ExpandableBinaryDictionary;
|
import com.android.inputmethod.latin.ExpandableBinaryDictionary;
|
||||||
|
@ -28,6 +28,8 @@ import com.android.inputmethod.latin.utils.DistracterFilter;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
|
|
||||||
|
import javax.annotation.Nonnull;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Locally gathers stats about the words user types and various other signals like auto-correction
|
* 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.
|
* 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 */);
|
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,
|
public static UserHistoryDictionary getDictionary(final Context context, final Locale locale,
|
||||||
final File dictFile, final String dictNamePrefix) {
|
final File dictFile, final String dictNamePrefix) {
|
||||||
return PersonalizationHelper.getUserHistoryDictionary(context, locale);
|
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
|
* @param distracterFilter the filter to check whether the word is a distracter
|
||||||
*/
|
*/
|
||||||
public static void addToDictionary(final ExpandableBinaryDictionary userHistoryDictionary,
|
public static void addToDictionary(final ExpandableBinaryDictionary userHistoryDictionary,
|
||||||
final NgramContext ngramContext, final String word, final boolean isValid,
|
@Nonnull final NgramContext ngramContext, final String word, final boolean isValid,
|
||||||
final int timestamp, final DistracterFilter distracterFilter) {
|
final int timestamp, @Nonnull final DistracterFilter distracterFilter) {
|
||||||
if (word.length() > Constants.DICTIONARY_MAX_WORD_LENGTH) {
|
if (word.length() > Constants.DICTIONARY_MAX_WORD_LENGTH) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
@ -40,6 +40,8 @@ import java.util.Locale;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.concurrent.locks.ReentrantLock;
|
import java.util.concurrent.locks.ReentrantLock;
|
||||||
|
|
||||||
|
import javax.annotation.Nonnull;
|
||||||
|
|
||||||
public final class Settings implements SharedPreferences.OnSharedPreferenceChangeListener {
|
public final class Settings implements SharedPreferences.OnSharedPreferenceChangeListener {
|
||||||
private static final String TAG = Settings.class.getSimpleName();
|
private static final String TAG = Settings.class.getSimpleName();
|
||||||
// Settings screens
|
// Settings screens
|
||||||
|
@ -175,7 +177,7 @@ public final class Settings implements SharedPreferences.OnSharedPreferenceChang
|
||||||
}
|
}
|
||||||
|
|
||||||
public void loadSettings(final Context context, final Locale locale,
|
public void loadSettings(final Context context, final Locale locale,
|
||||||
final InputAttributes inputAttributes) {
|
@Nonnull final InputAttributes inputAttributes) {
|
||||||
mSettingsValuesLock.lock();
|
mSettingsValuesLock.lock();
|
||||||
mContext = context;
|
mContext = context;
|
||||||
try {
|
try {
|
||||||
|
|
|
@ -37,6 +37,8 @@ import com.android.inputmethod.latin.utils.TargetPackageInfoGetterTask;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.Locale;
|
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
|
* 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}.
|
* using {@link com.android.inputmethod.latin.utils.RunInLocale}.
|
||||||
|
@ -85,6 +87,7 @@ public class SettingsValues {
|
||||||
public final int mScreenMetrics;
|
public final int mScreenMetrics;
|
||||||
|
|
||||||
// From the input box
|
// From the input box
|
||||||
|
@Nonnull
|
||||||
public final InputAttributes mInputAttributes;
|
public final InputAttributes mInputAttributes;
|
||||||
|
|
||||||
// Deduced settings
|
// Deduced settings
|
||||||
|
@ -115,7 +118,7 @@ public class SettingsValues {
|
||||||
public final float mKeyPreviewDismissEndYScale;
|
public final float mKeyPreviewDismissEndYScale;
|
||||||
|
|
||||||
public SettingsValues(final Context context, final SharedPreferences prefs, final Resources res,
|
public SettingsValues(final Context context, final SharedPreferences prefs, final Resources res,
|
||||||
final InputAttributes inputAttributes) {
|
@Nonnull final InputAttributes inputAttributes) {
|
||||||
mLocale = res.getConfiguration().locale;
|
mLocale = res.getConfiguration().locale;
|
||||||
// Get the resources
|
// Get the resources
|
||||||
mDelayInMillisecondsToUpdateOldSuggestions =
|
mDelayInMillisecondsToUpdateOldSuggestions =
|
||||||
|
@ -123,12 +126,7 @@ public class SettingsValues {
|
||||||
mSpacingAndPunctuations = new SpacingAndPunctuations(res);
|
mSpacingAndPunctuations = new SpacingAndPunctuations(res);
|
||||||
|
|
||||||
// Store the input attributes
|
// Store the input attributes
|
||||||
if (null == inputAttributes) {
|
|
||||||
mInputAttributes = new InputAttributes(
|
|
||||||
null, false /* isFullscreenMode */, context.getPackageName());
|
|
||||||
} else {
|
|
||||||
mInputAttributes = inputAttributes;
|
mInputAttributes = inputAttributes;
|
||||||
}
|
|
||||||
|
|
||||||
// Get the settings preferences
|
// Get the settings preferences
|
||||||
mAutoCap = prefs.getBoolean(Settings.PREF_AUTO_CAP, true);
|
mAutoCap = prefs.getBoolean(Settings.PREF_AUTO_CAP, true);
|
||||||
|
|
|
@ -16,8 +16,10 @@
|
||||||
|
|
||||||
package com.android.inputmethod.latin.spellcheck;
|
package com.android.inputmethod.latin.spellcheck;
|
||||||
|
|
||||||
|
import android.annotation.TargetApi;
|
||||||
import android.content.res.Resources;
|
import android.content.res.Resources;
|
||||||
import android.os.Binder;
|
import android.os.Binder;
|
||||||
|
import android.os.Build;
|
||||||
import android.text.TextUtils;
|
import android.text.TextUtils;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
import android.view.textservice.SentenceSuggestionsInfo;
|
import android.view.textservice.SentenceSuggestionsInfo;
|
||||||
|
@ -42,6 +44,7 @@ public final class AndroidSpellCheckerSession extends AndroidWordLevelSpellCheck
|
||||||
mResources = service.getResources();
|
mResources = service.getResources();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TargetApi(Build.VERSION_CODES.JELLY_BEAN)
|
||||||
private SentenceSuggestionsInfo fixWronglyInvalidatedWordWithSingleQuote(TextInfo ti,
|
private SentenceSuggestionsInfo fixWronglyInvalidatedWordWithSingleQuote(TextInfo ti,
|
||||||
SentenceSuggestionsInfo ssi) {
|
SentenceSuggestionsInfo ssi) {
|
||||||
final CharSequence typedText = TextInfoCompatUtils.getCharSequenceOrString(ti);
|
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 textInfos an array of the text metadata
|
||||||
* @param suggestionsLimit the maximum number of suggestions to be returned
|
* @param suggestionsLimit the maximum number of suggestions to be returned
|
||||||
* @return an array of {@link SentenceSuggestionsInfo} returned by
|
* @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) {
|
private SentenceSuggestionsInfo[] splitAndSuggest(TextInfo[] textInfos, int suggestionsLimit) {
|
||||||
if (textInfos == null || textInfos.length == 0) {
|
if (textInfos == null || textInfos.length == 0) {
|
||||||
|
|
|
@ -18,7 +18,9 @@ package com.android.inputmethod.latin.spellcheck;
|
||||||
|
|
||||||
import com.android.inputmethod.latin.utils.FragmentUtils;
|
import com.android.inputmethod.latin.utils.FragmentUtils;
|
||||||
|
|
||||||
|
import android.annotation.TargetApi;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
|
import android.os.Build;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.preference.PreferenceActivity;
|
import android.preference.PreferenceActivity;
|
||||||
|
|
||||||
|
@ -41,8 +43,8 @@ public final class SpellCheckerSettingsActivity extends PreferenceActivity {
|
||||||
return modIntent;
|
return modIntent;
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: Uncomment the override annotation once we start using SDK version 19.
|
@TargetApi(Build.VERSION_CODES.KITKAT)
|
||||||
// @Override
|
@Override
|
||||||
public boolean isValidFragment(String fragmentName) {
|
public boolean isValidFragment(String fragmentName) {
|
||||||
return FragmentUtils.isValidFragment(fragmentName);
|
return FragmentUtils.isValidFragment(fragmentName);
|
||||||
}
|
}
|
||||||
|
|
|
@ -47,12 +47,12 @@ public class UserDictionaryList extends PreferenceFragment {
|
||||||
"android.settings.USER_DICTIONARY_SETTINGS";
|
"android.settings.USER_DICTIONARY_SETTINGS";
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onCreate(Bundle icicle) {
|
public void onCreate(final Bundle icicle) {
|
||||||
super.onCreate(icicle);
|
super.onCreate(icicle);
|
||||||
setPreferenceScreen(getPreferenceManager().createPreferenceScreen(getActivity()));
|
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,
|
final Cursor cursor = activity.getContentResolver().query(UserDictionary.Words.CONTENT_URI,
|
||||||
new String[] { UserDictionary.Words.LOCALE },
|
new String[] { UserDictionary.Words.LOCALE },
|
||||||
null, null, null);
|
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.
|
* 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.
|
* @param userDictGroup The group to put the settings in.
|
||||||
*/
|
*/
|
||||||
protected void createUserDictSettings(PreferenceGroup userDictGroup) {
|
protected void createUserDictSettings(final PreferenceGroup userDictGroup) {
|
||||||
final Activity activity = getActivity();
|
final Activity activity = getActivity();
|
||||||
userDictGroup.removeAll();
|
userDictGroup.removeAll();
|
||||||
final TreeSet<String> localeSet =
|
final TreeSet<String> localeSet =
|
||||||
|
@ -121,10 +121,10 @@ public class UserDictionaryList extends PreferenceFragment {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (localeSet.isEmpty()) {
|
if (localeSet.isEmpty()) {
|
||||||
userDictGroup.addPreference(createUserDictionaryPreference(null, activity));
|
userDictGroup.addPreference(createUserDictionaryPreference(null));
|
||||||
} else {
|
} else {
|
||||||
for (String locale : localeSet) {
|
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.
|
* @param locale The locale for which this user dictionary is for.
|
||||||
* @return The corresponding preference.
|
* @return The corresponding preference.
|
||||||
*/
|
*/
|
||||||
protected Preference createUserDictionaryPreference(String locale, Activity activity) {
|
protected Preference createUserDictionaryPreference(final String locale) {
|
||||||
final Preference newPref = new Preference(getActivity());
|
final Preference newPref = new Preference(getActivity());
|
||||||
final Intent intent = new Intent(USER_DICTIONARY_SETTINGS_INTENT_ACTION);
|
final Intent intent = new Intent(USER_DICTIONARY_SETTINGS_INTENT_ACTION);
|
||||||
if (null == locale) {
|
if (null == locale) {
|
||||||
|
|
|
@ -186,7 +186,7 @@ public class UserDictionarySettings extends ListFragment {
|
||||||
|
|
||||||
private ListAdapter createAdapter() {
|
private ListAdapter createAdapter() {
|
||||||
return new MyAdapter(getActivity(), R.layout.user_dictionary_item, mCursor,
|
return new MyAdapter(getActivity(), R.layout.user_dictionary_item, mCursor,
|
||||||
ADAPTER_FROM, ADAPTER_TO, this);
|
ADAPTER_FROM, ADAPTER_TO);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -288,7 +288,7 @@ public class UserDictionarySettings extends ListFragment {
|
||||||
private ViewBinder mViewBinder = new ViewBinder() {
|
private ViewBinder mViewBinder = new ViewBinder() {
|
||||||
|
|
||||||
@Override
|
@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) {
|
if (!IS_SHORTCUT_API_SUPPORTED) {
|
||||||
// just let SimpleCursorAdapter set the view values
|
// just let SimpleCursorAdapter set the view values
|
||||||
return false;
|
return false;
|
||||||
|
@ -309,10 +309,9 @@ public class UserDictionarySettings extends ListFragment {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@SuppressWarnings("deprecation")
|
public MyAdapter(final Context context, final int layout, final Cursor c,
|
||||||
public MyAdapter(Context context, int layout, Cursor c, String[] from, int[] to,
|
final String[] from, final int[] to) {
|
||||||
UserDictionarySettings settings) {
|
super(context, layout, c, from, to, 0 /* flags */);
|
||||||
super(context, layout, c, from, to);
|
|
||||||
|
|
||||||
if (null != c) {
|
if (null != c) {
|
||||||
final String alphabet = context.getString(R.string.user_dict_fast_scroll_alphabet);
|
final String alphabet = context.getString(R.string.user_dict_fast_scroll_alphabet);
|
||||||
|
@ -323,12 +322,12 @@ public class UserDictionarySettings extends ListFragment {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getPositionForSection(int section) {
|
public int getPositionForSection(final int section) {
|
||||||
return null == mIndexer ? 0 : mIndexer.getPositionForSection(section);
|
return null == mIndexer ? 0 : mIndexer.getPositionForSection(section);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getSectionForPosition(int position) {
|
public int getSectionForPosition(final int position) {
|
||||||
return null == mIndexer ? 0 : mIndexer.getSectionForPosition(position);
|
return null == mIndexer ? 0 : mIndexer.getSectionForPosition(position);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -16,14 +16,16 @@
|
||||||
|
|
||||||
package com.android.inputmethod.latin.utils;
|
package com.android.inputmethod.latin.utils;
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Locale;
|
|
||||||
|
|
||||||
import android.view.inputmethod.InputMethodSubtype;
|
import android.view.inputmethod.InputMethodSubtype;
|
||||||
|
|
||||||
import com.android.inputmethod.annotations.UsedForTesting;
|
import com.android.inputmethod.annotations.UsedForTesting;
|
||||||
import com.android.inputmethod.latin.NgramContext;
|
import com.android.inputmethod.latin.NgramContext;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Locale;
|
||||||
|
|
||||||
|
import javax.annotation.Nonnull;
|
||||||
|
|
||||||
public interface DistracterFilter {
|
public interface DistracterFilter {
|
||||||
/**
|
/**
|
||||||
* Determine whether a word is a distracter to words in dictionaries.
|
* 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) {
|
public static boolean shouldBeHandledAsOov(final int handlingType) {
|
||||||
return (handlingType & SHOULD_BE_HANDLED_AS_OOV) != 0;
|
return (handlingType & SHOULD_BE_HANDLED_AS_OOV) != 0;
|
||||||
}
|
}
|
||||||
};
|
}
|
||||||
|
|
||||||
|
@Nonnull
|
||||||
public static final DistracterFilter EMPTY_DISTRACTER_FILTER = new DistracterFilter() {
|
public static final DistracterFilter EMPTY_DISTRACTER_FILTER = new DistracterFilter() {
|
||||||
@Override
|
@Override
|
||||||
public boolean isDistracterToWordsInDictionaries(NgramContext ngramContext,
|
public boolean isDistracterToWordsInDictionaries(NgramContext ngramContext,
|
||||||
|
|
|
@ -16,14 +16,16 @@
|
||||||
|
|
||||||
package com.android.inputmethod.latin.utils;
|
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.Constants;
|
||||||
import com.android.inputmethod.latin.NgramContext;
|
import com.android.inputmethod.latin.NgramContext;
|
||||||
import com.android.inputmethod.latin.NgramContext.WordInfo;
|
import com.android.inputmethod.latin.NgramContext.WordInfo;
|
||||||
import com.android.inputmethod.latin.settings.SpacingAndPunctuations;
|
import com.android.inputmethod.latin.settings.SpacingAndPunctuations;
|
||||||
|
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.regex.Pattern;
|
||||||
|
|
||||||
|
import javax.annotation.Nonnull;
|
||||||
|
|
||||||
public final class NgramContextUtils {
|
public final class NgramContextUtils {
|
||||||
private NgramContextUtils() {
|
private NgramContextUtils() {
|
||||||
// Intentional empty constructor for utility class.
|
// 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 |" -> beginning-of-sentence
|
// (n = 2) "abc |" -> beginning-of-sentence
|
||||||
// (n = 2) "abc. def|" -> beginning-of-sentence
|
// (n = 2) "abc. def|" -> beginning-of-sentence
|
||||||
|
@Nonnull
|
||||||
public static NgramContext getNgramContextFromNthPreviousWord(final CharSequence prev,
|
public static NgramContext getNgramContextFromNthPreviousWord(final CharSequence prev,
|
||||||
final SpacingAndPunctuations spacingAndPunctuations, final int n) {
|
final SpacingAndPunctuations spacingAndPunctuations, final int n) {
|
||||||
if (prev == null) return NgramContext.EMPTY_PREV_WORDS_INFO;
|
if (prev == null) return NgramContext.EMPTY_PREV_WORDS_INFO;
|
||||||
|
|
|
@ -110,7 +110,6 @@ public final class ResourceUtils {
|
||||||
* are true for the specified key value pairs.
|
* are true for the specified key value pairs.
|
||||||
*
|
*
|
||||||
* For example, "condition,constant" has the following format.
|
* For example, "condition,constant" has the following format.
|
||||||
* (See {@link ResourceUtilsTests#testFindConstantForKeyValuePairsRegexp()})
|
|
||||||
* - HARDWARE=mako,constantForNexus4
|
* - HARDWARE=mako,constantForNexus4
|
||||||
* - MODEL=Nexus 4:MANUFACTURER=LGE,constantForNexus4
|
* - MODEL=Nexus 4:MANUFACTURER=LGE,constantForNexus4
|
||||||
* - ,defaultConstant
|
* - ,defaultConstant
|
||||||
|
@ -119,6 +118,7 @@ public final class ResourceUtils {
|
||||||
* @param conditionConstantArray an array of "condition,constant" elements to be searched.
|
* @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
|
* @return the constant part of the matched "condition,constant" element. Returns null if no
|
||||||
* condition matches.
|
* condition matches.
|
||||||
|
* @see com.android.inputmethod.latin.utils.ResourceUtilsTests#testFindConstantForKeyValuePairsRegexp()
|
||||||
*/
|
*/
|
||||||
@UsedForTesting
|
@UsedForTesting
|
||||||
static String findConstantForKeyValuePairs(final HashMap<String, String> keyValuePairs,
|
static String findConstantForKeyValuePairs(final HashMap<String, String> keyValuePairs,
|
||||||
|
|
|
@ -521,12 +521,12 @@ public final class StringUtils {
|
||||||
* {@code charSequence.toString().split(regex, preserveTrailingEmptySegments ? -1 : 0)}
|
* {@code charSequence.toString().split(regex, preserveTrailingEmptySegments ? -1 : 0)}
|
||||||
* except that the spans are preserved in the result array.
|
* except that the spans are preserved in the result array.
|
||||||
* </p>
|
* </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 regex the regex pattern to be used as the separator.
|
||||||
* @param preserveTrailingEmptySegments {@code true} to preserve the trailing empty
|
* @param preserveTrailingEmptySegments {@code true} to preserve the trailing empty
|
||||||
* segments. Otherwise, trailing empty segments will be removed before being returned.
|
* 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
|
* @return the array which contains the result. All the spans in the <code>charSequence</code>
|
||||||
* preserved.
|
* is preserved.
|
||||||
*/
|
*/
|
||||||
@UsedForTesting
|
@UsedForTesting
|
||||||
public static CharSequence[] split(final CharSequence charSequence, final String regex,
|
public static CharSequence[] split(final CharSequence charSequence, final String regex,
|
||||||
|
|
|
@ -165,7 +165,7 @@ public final class BinaryDictDecoderUtils {
|
||||||
*
|
*
|
||||||
* @param codePoints the code point array to write.
|
* @param codePoints the code point array to write.
|
||||||
* @param buffer the byte buffer to write to.
|
* @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.
|
* @param codePointToOneByteCodeMap the map to convert the code point.
|
||||||
* @return the index after the last character.
|
* @return the index after the last character.
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -535,7 +535,7 @@ public class BinaryDictEncoderUtils {
|
||||||
* Helper method to write a children position to a file.
|
* Helper method to write a children position to a file.
|
||||||
*
|
*
|
||||||
* @param buffer the buffer to write to.
|
* @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.
|
* @param position the position to write.
|
||||||
* @return the size in bytes the address actually took.
|
* @return the size in bytes the address actually took.
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -44,7 +44,7 @@ public final class BinaryDictIOUtils {
|
||||||
public static DictDecoder getDictDecoder(final File dictFile, final long offset,
|
public static DictDecoder getDictDecoder(final File dictFile, final long offset,
|
||||||
final long length, final int bufferType) {
|
final long length, final int bufferType) {
|
||||||
if (dictFile.isDirectory()) {
|
if (dictFile.isDirectory()) {
|
||||||
return new Ver4DictDecoder(dictFile, bufferType);
|
return new Ver4DictDecoder(dictFile);
|
||||||
} else if (dictFile.isFile()) {
|
} else if (dictFile.isFile()) {
|
||||||
return new Ver2DictDecoder(dictFile, offset, length, bufferType);
|
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,
|
public static DictDecoder getDictDecoder(final File dictFile, final long offset,
|
||||||
final long length, final DictionaryBufferFactory factory) {
|
final long length, final DictionaryBufferFactory factory) {
|
||||||
if (dictFile.isDirectory()) {
|
if (dictFile.isDirectory()) {
|
||||||
return new Ver4DictDecoder(dictFile, factory);
|
return new Ver4DictDecoder(dictFile);
|
||||||
} else if (dictFile.isFile()) {
|
} else if (dictFile.isFile()) {
|
||||||
return new Ver2DictDecoder(dictFile, offset, length, factory);
|
return new Ver2DictDecoder(dictFile, offset, length, factory);
|
||||||
}
|
}
|
||||||
|
|
|
@ -33,12 +33,7 @@ public class Ver4DictDecoder extends AbstractDictDecoder {
|
||||||
final File mDictDirectory;
|
final File mDictDirectory;
|
||||||
|
|
||||||
@UsedForTesting
|
@UsedForTesting
|
||||||
/* package */ Ver4DictDecoder(final File dictDirectory, final int factoryFlag) {
|
/* package */ Ver4DictDecoder(final File dictDirectory) {
|
||||||
this(dictDirectory, null /* factory */);
|
|
||||||
}
|
|
||||||
|
|
||||||
@UsedForTesting
|
|
||||||
/* package */ Ver4DictDecoder(final File dictDirectory, final DictionaryBufferFactory factory) {
|
|
||||||
mDictDirectory = dictDirectory;
|
mDictDirectory = dictDirectory;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -29,7 +29,7 @@ import java.util.Collections;
|
||||||
@SmallTest
|
@SmallTest
|
||||||
public class CollectionUtilsTests extends AndroidTestCase {
|
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.
|
* results for a few valid inputs.
|
||||||
*/
|
*/
|
||||||
public void testArrayAsList() {
|
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.
|
* results for a few cases.
|
||||||
*/
|
*/
|
||||||
public void testIsNullOrEmpty() {
|
public void testIsNullOrEmpty() {
|
||||||
|
|
|
@ -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));
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -16,6 +16,7 @@
|
||||||
|
|
||||||
package com.android.inputmethod.keyboard;
|
package com.android.inputmethod.keyboard;
|
||||||
|
|
||||||
|
@SuppressWarnings("unused")
|
||||||
public class Keyboard {
|
public class Keyboard {
|
||||||
private final Key KEY = new Key();
|
private final Key KEY = new Key();
|
||||||
public final Key getKey(final int i) { return KEY; }
|
public final Key getKey(final int i) { return KEY; }
|
||||||
|
|
|
@ -64,8 +64,7 @@ public class Info extends Dicttool.Command {
|
||||||
+ " whitelist entries)");
|
+ " whitelist entries)");
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void showWordInfo(final FusionDictionary dict, final String word,
|
private static void showWordInfo(final FusionDictionary dict, final String word) {
|
||||||
final boolean plumbing) {
|
|
||||||
final PtNode ptNode = FusionDictionary.findWordInTree(dict.mRootNodeArray, word);
|
final PtNode ptNode = FusionDictionary.findWordInTree(dict.mRootNodeArray, word);
|
||||||
if (null == ptNode) {
|
if (null == ptNode) {
|
||||||
System.out.println(word + " is not in the dictionary");
|
System.out.println(word + " is not in the dictionary");
|
||||||
|
@ -124,7 +123,7 @@ public class Info extends Dicttool.Command {
|
||||||
showInfo(dict, plumbing);
|
showInfo(dict, plumbing);
|
||||||
} else {
|
} else {
|
||||||
for (int i = 1; i < mArgs.length; ++i) {
|
for (int i = 1; i < mArgs.length; ++i) {
|
||||||
showWordInfo(dict, mArgs[i], plumbing);
|
showWordInfo(dict, mArgs[i]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,6 +16,7 @@
|
||||||
|
|
||||||
package com.android.inputmethod.latin.personalization;
|
package com.android.inputmethod.latin.personalization;
|
||||||
|
|
||||||
|
@SuppressWarnings("unused")
|
||||||
public class PersonalizationHelper {
|
public class PersonalizationHelper {
|
||||||
public static void currentTimeChangedForTesting(final int currentTimestamp) {
|
public static void currentTimeChangedForTesting(final int currentTimestamp) {
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue