mirror of
https://github.com/Helium314/HeliBoard.git
synced 2025-05-18 07:53:07 +00:00
change nullable / nonnull annotations to androidx
This commit is contained in:
parent
e2d2889d81
commit
2a19114ccb
76 changed files with 609 additions and 613 deletions
|
@ -19,6 +19,8 @@ package com.android.inputmethod.keyboard;
|
|||
import android.graphics.Rect;
|
||||
import android.util.Log;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
|
||||
import org.dslul.openboard.inputmethod.keyboard.Key;
|
||||
import org.dslul.openboard.inputmethod.keyboard.internal.TouchPositionCorrection;
|
||||
import org.dslul.openboard.inputmethod.latin.common.Constants;
|
||||
|
@ -29,8 +31,6 @@ import java.util.Arrays;
|
|||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
public class ProximityInfo {
|
||||
private static final String TAG = ProximityInfo.class.getSimpleName();
|
||||
private static final boolean DEBUG = false;
|
||||
|
@ -39,7 +39,7 @@ public class ProximityInfo {
|
|||
public static final int MAX_PROXIMITY_CHARS_SIZE = 16;
|
||||
/** Number of key widths from current touch point to search for nearest keys. */
|
||||
private static final float SEARCH_DISTANCE = 1.2f;
|
||||
@Nonnull
|
||||
@NonNull
|
||||
private static final List<Key> EMPTY_KEY_LIST = Collections.emptyList();
|
||||
private static final float DEFAULT_TOUCH_POSITION_CORRECTION_RADIUS = 0.15f;
|
||||
|
||||
|
@ -53,16 +53,16 @@ public class ProximityInfo {
|
|||
private final int mKeyboardHeight;
|
||||
private final int mMostCommonKeyWidth;
|
||||
private final int mMostCommonKeyHeight;
|
||||
@Nonnull
|
||||
@NonNull
|
||||
private final List<Key> mSortedKeys;
|
||||
@Nonnull
|
||||
@NonNull
|
||||
private final List<Key>[] mGridNeighbors;
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public ProximityInfo(final int gridWidth, final int gridHeight, final int minWidth, final int height,
|
||||
final int mostCommonKeyWidth, final int mostCommonKeyHeight,
|
||||
@Nonnull final List<Key> sortedKeys,
|
||||
@Nonnull final TouchPositionCorrection touchPositionCorrection) {
|
||||
@NonNull final List<Key> sortedKeys,
|
||||
@NonNull final TouchPositionCorrection touchPositionCorrection) {
|
||||
mGridWidth = gridWidth;
|
||||
mGridHeight = gridHeight;
|
||||
mGridSize = mGridWidth * mGridHeight;
|
||||
|
@ -112,7 +112,7 @@ public class ProximityInfo {
|
|||
}
|
||||
|
||||
private long createNativeProximityInfo(
|
||||
@Nonnull final TouchPositionCorrection touchPositionCorrection) {
|
||||
@NonNull final TouchPositionCorrection touchPositionCorrection) {
|
||||
final List<Key>[] gridNeighborKeys = mGridNeighbors;
|
||||
final int[] proximityCharsArray = new int[mGridSize * MAX_PROXIMITY_CHARS_SIZE];
|
||||
Arrays.fill(proximityCharsArray, Constants.NOT_A_CODE);
|
||||
|
@ -393,7 +393,7 @@ y |---+---+---+---+-v-+-|-+---+---+---+---+---| | thresholdBase and get
|
|||
}
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@NonNull
|
||||
public List<Key> getNearestKeys(final int x, final int y) {
|
||||
if (x >= 0 && x < mKeyboardMinWidth && y >= 0 && y < mKeyboardHeight) {
|
||||
int index = (y / mCellHeight) * mGridWidth + (x / mCellWidth);
|
||||
|
|
|
@ -20,6 +20,8 @@ import android.text.TextUtils;
|
|||
import android.util.Log;
|
||||
import android.util.SparseArray;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
|
||||
import org.dslul.openboard.inputmethod.annotations.UsedForTesting;
|
||||
import org.dslul.openboard.inputmethod.latin.Dictionary;
|
||||
import org.dslul.openboard.inputmethod.latin.NgramContext;
|
||||
|
@ -46,8 +48,6 @@ import java.util.HashMap;
|
|||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
/**
|
||||
* Implements a static, compacted, binary dictionary of standard words.
|
||||
*/
|
||||
|
@ -497,7 +497,7 @@ public final class BinaryDictionary extends Dictionary {
|
|||
}
|
||||
|
||||
// Update entries for the word occurrence with the ngramContext.
|
||||
public boolean updateEntriesForWordWithNgramContext(@Nonnull final NgramContext ngramContext,
|
||||
public boolean updateEntriesForWordWithNgramContext(@NonNull final NgramContext ngramContext,
|
||||
final String word, final boolean isValidWord, final int count, final int timestamp) {
|
||||
if (TextUtils.isEmpty(word)) {
|
||||
return false;
|
||||
|
|
|
@ -38,15 +38,15 @@ import org.dslul.openboard.inputmethod.latin.common.StringUtils;
|
|||
import java.util.Arrays;
|
||||
import java.util.Locale;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import static org.dslul.openboard.inputmethod.keyboard.internal.KeyboardIconsSet.ICON_UNDEFINED;
|
||||
import static org.dslul.openboard.inputmethod.latin.common.Constants.CODE_OUTPUT_TEXT;
|
||||
import static org.dslul.openboard.inputmethod.latin.common.Constants.CODE_SHIFT;
|
||||
import static org.dslul.openboard.inputmethod.latin.common.Constants.CODE_SWITCH_ALPHA_SYMBOL;
|
||||
import static org.dslul.openboard.inputmethod.latin.common.Constants.CODE_UNSPECIFIED;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
/**
|
||||
* Class for describing the position and characteristics of a single key in the keyboard.
|
||||
*/
|
||||
|
@ -117,7 +117,7 @@ public class Key implements Comparable<Key> {
|
|||
/** Y coordinate of the top-left corner of the key in the keyboard layout, excluding the gap. */
|
||||
private final int mY;
|
||||
/** Hit bounding box of the key */
|
||||
@Nonnull
|
||||
@NonNull
|
||||
private final Rect mHitBox = new Rect();
|
||||
|
||||
/** More keys. It is guaranteed that this is null or an array of one or more elements */
|
||||
|
@ -328,9 +328,9 @@ public class Key implements Comparable<Key> {
|
|||
* @param row the row that this key belongs to. row's x-coordinate will be the right edge of
|
||||
* this key.
|
||||
*/
|
||||
public Key(@Nullable final String keySpec, @Nonnull final TypedArray keyAttr,
|
||||
@Nonnull final KeyStyle style, @Nonnull final KeyboardParams params,
|
||||
@Nonnull final KeyboardRow row) {
|
||||
public Key(@Nullable final String keySpec, @NonNull final TypedArray keyAttr,
|
||||
@NonNull final KeyStyle style, @NonNull final KeyboardParams params,
|
||||
@NonNull final KeyboardRow row) {
|
||||
mHorizontalGap = isSpacer() ? 0 : params.mHorizontalGap;
|
||||
mVerticalGap = params.mVerticalGap;
|
||||
|
||||
|
@ -490,7 +490,7 @@ public class Key implements Comparable<Key> {
|
|||
* @param labelHint the label hint that should be assigned to this key.
|
||||
* @param backgroundType the background type that should be assigned to this key.
|
||||
*/
|
||||
protected Key(@Nonnull final Key key, @Nullable final MoreKeySpec[] moreKeys,
|
||||
protected Key(@NonNull final Key key, @Nullable final MoreKeySpec[] moreKeys,
|
||||
@Nullable final String labelHint, final int backgroundType) {
|
||||
// Final attributes.
|
||||
mCode = key.mCode;
|
||||
|
@ -517,7 +517,7 @@ public class Key implements Comparable<Key> {
|
|||
mEnabled = key.mEnabled;
|
||||
}
|
||||
|
||||
private Key(@Nonnull final Key key, @Nullable final MoreKeySpec[] moreKeys) {
|
||||
private Key(@NonNull final Key key, @Nullable final MoreKeySpec[] moreKeys) {
|
||||
// Final attributes.
|
||||
mCode = key.mCode;
|
||||
mLabel = key.mLabel;
|
||||
|
@ -543,9 +543,9 @@ public class Key implements Comparable<Key> {
|
|||
mEnabled = key.mEnabled;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
public static Key removeRedundantMoreKeys(@Nonnull final Key key,
|
||||
@Nonnull final MoreKeySpec.LettersOnBaseLayout lettersOnBaseLayout) {
|
||||
@NonNull
|
||||
public static Key removeRedundantMoreKeys(@NonNull final Key key,
|
||||
@NonNull final MoreKeySpec.LettersOnBaseLayout lettersOnBaseLayout) {
|
||||
final MoreKeySpec[] moreKeys = key.getMoreKeys();
|
||||
final MoreKeySpec[] filteredMoreKeys = MoreKeySpec.removeRedundantMoreKeys(
|
||||
moreKeys, lettersOnBaseLayout);
|
||||
|
@ -734,7 +734,7 @@ public class Key implements Comparable<Key> {
|
|||
return mKeyVisualAttributes;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@NonNull
|
||||
public final Typeface selectTypeface(final KeyDrawParams params) {
|
||||
switch (mLabelFlags & LABEL_FLAGS_FONT_MASK) {
|
||||
case LABEL_FLAGS_FONT_NORMAL:
|
||||
|
@ -811,7 +811,7 @@ public class Key implements Comparable<Key> {
|
|||
return params.mLetterSize;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@NonNull
|
||||
public Typeface selectPreviewTypeface(final KeyDrawParams params) {
|
||||
if (previewHasLetterSize()) {
|
||||
return selectTypeface(params);
|
||||
|
@ -1031,7 +1031,7 @@ public class Key implements Comparable<Key> {
|
|||
mEnabled = enabled;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@NonNull
|
||||
public Rect getHitBox() {
|
||||
return mHitBox;
|
||||
}
|
||||
|
@ -1103,11 +1103,11 @@ public class Key implements Comparable<Key> {
|
|||
* @return the background drawable of the key.
|
||||
* @see android.graphics.drawable.StateListDrawable#setState(int[])
|
||||
*/
|
||||
@Nonnull
|
||||
public final Drawable selectBackgroundDrawable(@Nonnull final Drawable keyBackground,
|
||||
@Nonnull final Drawable functionalKeyBackground,
|
||||
@Nonnull final Drawable spacebarBackground,
|
||||
@Nonnull final Drawable actionKeyBackground) {
|
||||
@NonNull
|
||||
public final Drawable selectBackgroundDrawable(@NonNull final Drawable keyBackground,
|
||||
@NonNull final Drawable functionalKeyBackground,
|
||||
@NonNull final Drawable spacebarBackground,
|
||||
@NonNull final Drawable actionKeyBackground) {
|
||||
final Drawable background;
|
||||
if (isAccentColored()) {
|
||||
background = actionKeyBackground;
|
||||
|
|
|
@ -18,6 +18,9 @@ package org.dslul.openboard.inputmethod.keyboard;
|
|||
|
||||
import android.util.SparseArray;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
import com.android.inputmethod.keyboard.ProximityInfo;
|
||||
|
||||
import org.dslul.openboard.inputmethod.keyboard.internal.KeyVisualAttributes;
|
||||
|
@ -30,9 +33,6 @@ import java.util.ArrayList;
|
|||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
/**
|
||||
* Loads an XML description of a keyboard and stores the attributes of the keys. A keyboard
|
||||
* consists of rows of keys.
|
||||
|
@ -52,7 +52,7 @@ import javax.annotation.Nullable;
|
|||
* </pre>
|
||||
*/
|
||||
public class Keyboard {
|
||||
@Nonnull
|
||||
@NonNull
|
||||
public final KeyboardId mId;
|
||||
public final int mThemeId;
|
||||
|
||||
|
@ -84,25 +84,25 @@ public class Keyboard {
|
|||
public final int mMaxMoreKeysKeyboardColumn;
|
||||
|
||||
/** List of keys in this keyboard */
|
||||
@Nonnull
|
||||
@NonNull
|
||||
private final List<Key> mSortedKeys;
|
||||
@Nonnull
|
||||
@NonNull
|
||||
public final List<Key> mShiftKeys;
|
||||
@Nonnull
|
||||
@NonNull
|
||||
public final List<Key> mAltCodeKeysWhileTyping;
|
||||
@Nonnull
|
||||
@NonNull
|
||||
public final KeyboardIconsSet mIconsSet;
|
||||
|
||||
private final SparseArray<Key> mKeyCache = new SparseArray<>();
|
||||
|
||||
@Nonnull
|
||||
@NonNull
|
||||
private final ProximityInfo mProximityInfo;
|
||||
@Nonnull
|
||||
@NonNull
|
||||
private final KeyboardLayout mKeyboardLayout;
|
||||
|
||||
private final boolean mProximityCharsCorrectionEnabled;
|
||||
|
||||
public Keyboard(@Nonnull final KeyboardParams params) {
|
||||
public Keyboard(@NonNull final KeyboardParams params) {
|
||||
mId = params.mId;
|
||||
mThemeId = params.mThemeId;
|
||||
mOccupiedHeight = params.mOccupiedHeight;
|
||||
|
@ -130,7 +130,7 @@ public class Keyboard {
|
|||
mMostCommonKeyHeight, mOccupiedWidth, mOccupiedHeight);
|
||||
}
|
||||
|
||||
protected Keyboard(@Nonnull final Keyboard keyboard) {
|
||||
protected Keyboard(@NonNull final Keyboard keyboard) {
|
||||
mId = keyboard.mId;
|
||||
mThemeId = keyboard.mThemeId;
|
||||
mOccupiedHeight = keyboard.mOccupiedHeight;
|
||||
|
@ -167,12 +167,12 @@ public class Keyboard {
|
|||
return canAssumeNativeHasProximityCharsInfoOfAllKeys || Character.isLetter(code);
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@NonNull
|
||||
public ProximityInfo getProximityInfo() {
|
||||
return mProximityInfo;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@NonNull
|
||||
public KeyboardLayout getKeyboardLayout() {
|
||||
return mKeyboardLayout;
|
||||
}
|
||||
|
@ -183,7 +183,7 @@ public class Keyboard {
|
|||
* The list may contain {@link Key.Spacer} object as well.
|
||||
* @return the sorted unmodifiable list of {@link Key}s of this keyboard.
|
||||
*/
|
||||
@Nonnull
|
||||
@NonNull
|
||||
public List<Key> getSortedKeys() {
|
||||
return mSortedKeys;
|
||||
}
|
||||
|
@ -210,7 +210,7 @@ public class Keyboard {
|
|||
}
|
||||
}
|
||||
|
||||
public boolean hasKey(@Nonnull final Key aKey) {
|
||||
public boolean hasKey(@NonNull final Key aKey) {
|
||||
if (mKeyCache.indexOfValue(aKey) >= 0) {
|
||||
return true;
|
||||
}
|
||||
|
@ -236,7 +236,7 @@ public class Keyboard {
|
|||
* @return the list of the nearest keys to the given point. If the given
|
||||
* point is out of range, then an array of size zero is returned.
|
||||
*/
|
||||
@Nonnull
|
||||
@NonNull
|
||||
public List<Key> getNearestKeys(final int x, final int y) {
|
||||
// Avoid dead pixels at edges of the keyboard
|
||||
final int adjustedX = Math.max(0, Math.min(x, mOccupiedWidth - 1));
|
||||
|
@ -244,8 +244,8 @@ public class Keyboard {
|
|||
return mProximityInfo.getNearestKeys(adjustedX, adjustedY);
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
public int[] getCoordinates(@Nonnull final int[] codePoints) {
|
||||
@NonNull
|
||||
public int[] getCoordinates(@NonNull final int[] codePoints) {
|
||||
final int length = codePoints.length;
|
||||
final int[] coordinates = CoordinateUtils.newCoordinateArray(length);
|
||||
for (int i = 0; i < length; ++i) {
|
||||
|
|
|
@ -16,6 +16,8 @@
|
|||
|
||||
package org.dslul.openboard.inputmethod.keyboard;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
|
||||
import com.android.inputmethod.keyboard.ProximityInfo;
|
||||
|
||||
import org.dslul.openboard.inputmethod.annotations.UsedForTesting;
|
||||
|
@ -23,8 +25,6 @@ import org.dslul.openboard.inputmethod.annotations.UsedForTesting;
|
|||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
/**
|
||||
* KeyboardLayout maintains the keyboard layout information.
|
||||
*/
|
||||
|
@ -108,7 +108,7 @@ public class KeyboardLayout {
|
|||
/**
|
||||
* Factory method to create {@link KeyboardLayout} objects.
|
||||
*/
|
||||
public static KeyboardLayout newKeyboardLayout(@Nonnull final List<Key> sortedKeys,
|
||||
public static KeyboardLayout newKeyboardLayout(@NonNull final List<Key> sortedKeys,
|
||||
int mostCommonKeyWidth, int mostCommonKeyHeight,
|
||||
int occupiedWidth, int occupiedHeight) {
|
||||
final ArrayList<Key> layoutKeys = new ArrayList<Key>();
|
||||
|
|
|
@ -28,7 +28,6 @@ import android.view.inputmethod.EditorInfo;
|
|||
import android.view.inputmethod.InputMethodSubtype;
|
||||
|
||||
import org.dslul.openboard.inputmethod.compat.EditorInfoCompatUtils;
|
||||
import org.dslul.openboard.inputmethod.compat.InputMethodSubtypeCompatUtils;
|
||||
import org.dslul.openboard.inputmethod.compat.UserManagerCompatUtils;
|
||||
import org.dslul.openboard.inputmethod.keyboard.internal.KeyboardBuilder;
|
||||
import org.dslul.openboard.inputmethod.keyboard.internal.KeyboardParams;
|
||||
|
@ -36,7 +35,6 @@ import org.dslul.openboard.inputmethod.keyboard.internal.UniqueKeysCache;
|
|||
import org.dslul.openboard.inputmethod.latin.InputAttributes;
|
||||
import org.dslul.openboard.inputmethod.latin.R;
|
||||
import org.dslul.openboard.inputmethod.latin.RichInputMethodSubtype;
|
||||
import org.dslul.openboard.inputmethod.latin.common.StringUtils;
|
||||
import org.dslul.openboard.inputmethod.latin.utils.InputTypeUtils;
|
||||
import org.dslul.openboard.inputmethod.latin.utils.ScriptUtils;
|
||||
import org.dslul.openboard.inputmethod.latin.utils.SubtypeLocaleUtils;
|
||||
|
@ -48,12 +46,12 @@ import java.io.IOException;
|
|||
import java.lang.ref.SoftReference;
|
||||
import java.util.HashMap;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import static org.dslul.openboard.inputmethod.latin.common.Constants.ImeOption.FORCE_ASCII;
|
||||
import static org.dslul.openboard.inputmethod.latin.common.Constants.ImeOption.NO_SETTINGS_KEY;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
/**
|
||||
* This class represents a set of keyboard layouts. Each of them represents a different keyboard
|
||||
* specific to a keyboard state, such as alphabet, symbols, and so on. Layouts in the same
|
||||
|
@ -72,7 +70,7 @@ public final class KeyboardLayoutSet {
|
|||
private static final String KEYBOARD_LAYOUT_SET_RESOURCE_PREFIX = "keyboard_layout_set_";
|
||||
|
||||
private final Context mContext;
|
||||
@Nonnull
|
||||
@NonNull
|
||||
private final Params mParams;
|
||||
|
||||
// How many layouts we forcibly keep in cache. This only includes ALPHABET (default) and
|
||||
|
@ -85,7 +83,7 @@ public final class KeyboardLayoutSet {
|
|||
private static final Keyboard[] sForcibleKeyboardCache = new Keyboard[FORCIBLE_CACHE_SIZE];
|
||||
private static final HashMap<KeyboardId, SoftReference<Keyboard>> sKeyboardCache =
|
||||
new HashMap<>();
|
||||
@Nonnull
|
||||
@NonNull
|
||||
private static final UniqueKeysCache sUniqueKeysCache = UniqueKeysCache.newInstance();
|
||||
private final static HashMap<InputMethodSubtype, Integer> sScriptIdsForSubtypes =
|
||||
new HashMap<>();
|
||||
|
@ -153,7 +151,7 @@ public final class KeyboardLayoutSet {
|
|||
}
|
||||
|
||||
public static int getScriptId(final Resources resources,
|
||||
@Nonnull final InputMethodSubtype subtype) {
|
||||
@NonNull final InputMethodSubtype subtype) {
|
||||
final Integer value = sScriptIdsForSubtypes.get(subtype);
|
||||
if (null == value) {
|
||||
final int scriptId = Builder.readScriptId(resources, subtype);
|
||||
|
@ -163,14 +161,14 @@ public final class KeyboardLayoutSet {
|
|||
return value;
|
||||
}
|
||||
|
||||
KeyboardLayoutSet(final Context context, @Nonnull final Params params) {
|
||||
KeyboardLayoutSet(final Context context, @NonNull final Params params) {
|
||||
mContext = context;
|
||||
mParams = params;
|
||||
}
|
||||
|
||||
public static final String LOCALE_GEORGIAN = "ka";
|
||||
|
||||
@Nonnull
|
||||
@NonNull
|
||||
public Keyboard getKeyboard(final int baseKeyboardLayoutSetElementId) {
|
||||
final int keyboardLayoutSetElementId;
|
||||
switch (mParams.mMode) {
|
||||
|
@ -218,7 +216,7 @@ public final class KeyboardLayoutSet {
|
|||
}
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@NonNull
|
||||
private Keyboard getKeyboard(final ElementParams elementParams, final KeyboardId id) {
|
||||
final SoftReference<Keyboard> ref = sKeyboardCache.get(id);
|
||||
final Keyboard cachedKeyboard = (ref == null) ? null : ref.get();
|
||||
|
@ -303,7 +301,7 @@ public final class KeyboardLayoutSet {
|
|||
return this;
|
||||
}
|
||||
|
||||
public Builder setSubtype(@Nonnull final RichInputMethodSubtype subtype) {
|
||||
public Builder setSubtype(@NonNull final RichInputMethodSubtype subtype) {
|
||||
final boolean asciiCapable = subtype.getRawSubtype().isAsciiCapable();
|
||||
// TODO: Consolidate with {@link InputAttributes}.
|
||||
@SuppressWarnings("deprecation") final boolean deprecatedForceAscii = InputAttributes.inPrivateImeOptions(
|
||||
|
|
|
@ -49,8 +49,6 @@ import org.dslul.openboard.inputmethod.latin.utils.RecapitalizeStatus;
|
|||
import org.dslul.openboard.inputmethod.latin.utils.ResourceUtils;
|
||||
import org.dslul.openboard.inputmethod.latin.utils.ScriptUtils;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
public final class KeyboardSwitcher implements KeyboardState.SwitchActions {
|
||||
private static final String TAG = KeyboardSwitcher.class.getSimpleName();
|
||||
|
||||
|
@ -164,8 +162,8 @@ public final class KeyboardSwitcher implements KeyboardState.SwitchActions {
|
|||
}
|
||||
|
||||
private void setKeyboard(
|
||||
@Nonnull final int keyboardId,
|
||||
@Nonnull final KeyboardSwitchState toggleState) {
|
||||
@NonNull final int keyboardId,
|
||||
@NonNull final KeyboardSwitchState toggleState) {
|
||||
// Make {@link MainKeyboardView} visible and hide {@link EmojiPalettesView}.
|
||||
final SettingsValues currentSettingsValues = Settings.getInstance().getCurrent();
|
||||
setMainKeyboardFrame(currentSettingsValues, toggleState);
|
||||
|
@ -288,14 +286,14 @@ public final class KeyboardSwitcher implements KeyboardState.SwitchActions {
|
|||
}
|
||||
|
||||
public boolean isImeSuppressedByHardwareKeyboard(
|
||||
@Nonnull final SettingsValues settingsValues,
|
||||
@Nonnull final KeyboardSwitchState toggleState) {
|
||||
@NonNull final SettingsValues settingsValues,
|
||||
@NonNull final KeyboardSwitchState toggleState) {
|
||||
return settingsValues.mHasHardwareKeyboard && toggleState == KeyboardSwitchState.HIDDEN;
|
||||
}
|
||||
|
||||
private void setMainKeyboardFrame(
|
||||
@Nonnull final SettingsValues settingsValues,
|
||||
@Nonnull final KeyboardSwitchState toggleState) {
|
||||
@NonNull final SettingsValues settingsValues,
|
||||
@NonNull final KeyboardSwitchState toggleState) {
|
||||
final int visibility = isImeSuppressedByHardwareKeyboard(settingsValues, toggleState)
|
||||
? View.GONE : View.VISIBLE;
|
||||
mKeyboardView.setVisibility(visibility);
|
||||
|
@ -385,7 +383,7 @@ public final class KeyboardSwitcher implements KeyboardState.SwitchActions {
|
|||
return KeyboardSwitchState.OTHER;
|
||||
}
|
||||
|
||||
public void onToggleKeyboard(@Nonnull final KeyboardSwitchState toggleState) {
|
||||
public void onToggleKeyboard(@NonNull final KeyboardSwitchState toggleState) {
|
||||
KeyboardSwitchState currentState = getKeyboardSwitchState();
|
||||
Log.w(TAG, "onToggleKeyboard() : Current = " + currentState + " : Toggle = " + toggleState);
|
||||
if (currentState == toggleState) {
|
||||
|
@ -489,7 +487,7 @@ public final class KeyboardSwitcher implements KeyboardState.SwitchActions {
|
|||
mState.onEvent(event, currentAutoCapsState, currentRecapitalizeState);
|
||||
}
|
||||
|
||||
public boolean isShowingKeyboardId(@Nonnull int... keyboardIds) {
|
||||
public boolean isShowingKeyboardId(@NonNull int... keyboardIds) {
|
||||
if (mKeyboardView == null || !mKeyboardView.isShown()) {
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -32,6 +32,9 @@ import android.text.TextUtils;
|
|||
import android.util.AttributeSet;
|
||||
import android.view.View;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
import org.dslul.openboard.inputmethod.keyboard.emoji.EmojiPageKeyboardView;
|
||||
import org.dslul.openboard.inputmethod.keyboard.internal.KeyDrawParams;
|
||||
import org.dslul.openboard.inputmethod.keyboard.internal.KeyVisualAttributes;
|
||||
|
@ -45,9 +48,6 @@ import org.dslul.openboard.inputmethod.latin.utils.TypefaceUtils;
|
|||
|
||||
import java.util.HashSet;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
/**
|
||||
* A view that renders a virtual {@link Keyboard}.
|
||||
*
|
||||
|
@ -107,10 +107,10 @@ public class KeyboardView extends View {
|
|||
private static final float MAX_LABEL_RATIO = 0.90f;
|
||||
|
||||
// Main keyboard
|
||||
// TODO: Consider having a dummy keyboard object to make this @Nonnull
|
||||
// TODO: Consider having a dummy keyboard object to make this @NonNull
|
||||
@Nullable
|
||||
private Keyboard mKeyboard;
|
||||
@Nonnull
|
||||
@NonNull
|
||||
private final KeyDrawParams mKeyDrawParams = new KeyDrawParams();
|
||||
|
||||
// Drawing
|
||||
|
@ -125,9 +125,9 @@ public class KeyboardView extends View {
|
|||
/** Flag for whether the key hints should be displayed */
|
||||
private boolean mShowsHints;
|
||||
/** The canvas for the above mutable keyboard bitmap */
|
||||
@Nonnull
|
||||
@NonNull
|
||||
private final Canvas mOffscreenCanvas = new Canvas();
|
||||
@Nonnull
|
||||
@NonNull
|
||||
private final Paint mPaint = new Paint();
|
||||
private final Paint.FontMetrics mFontMetrics = new Paint.FontMetrics();
|
||||
|
||||
|
@ -209,7 +209,7 @@ public class KeyboardView extends View {
|
|||
return mKeyVisualAttributes;
|
||||
}
|
||||
|
||||
private static void blendAlpha(@Nonnull final Paint paint, final int alpha) {
|
||||
private static void blendAlpha(@NonNull final Paint paint, final int alpha) {
|
||||
final int color = paint.getColor();
|
||||
paint.setARGB((paint.getAlpha() * alpha) / Constants.Color.ALPHA_OPAQUE,
|
||||
Color.red(color), Color.green(color), Color.blue(color));
|
||||
|
@ -228,7 +228,7 @@ public class KeyboardView extends View {
|
|||
* @see #getKeyboard()
|
||||
* @param keyboard the keyboard to display in this view
|
||||
*/
|
||||
public void setKeyboard(@Nonnull final Keyboard keyboard) {
|
||||
public void setKeyboard(@NonNull final Keyboard keyboard) {
|
||||
mKeyboard = keyboard;
|
||||
final int keyHeight = keyboard.mMostCommonKeyHeight - keyboard.mVerticalGap;
|
||||
mKeyDrawParams.updateParams(keyHeight, mKeyVisualAttributes);
|
||||
|
@ -251,7 +251,7 @@ public class KeyboardView extends View {
|
|||
return mVerticalCorrection;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@NonNull
|
||||
protected KeyDrawParams getKeyDrawParams() {
|
||||
return mKeyDrawParams;
|
||||
}
|
||||
|
@ -317,7 +317,7 @@ public class KeyboardView extends View {
|
|||
}
|
||||
}
|
||||
|
||||
private void onDrawKeyboard(@Nonnull final Canvas canvas) {
|
||||
private void onDrawKeyboard(@NonNull final Canvas canvas) {
|
||||
final Keyboard keyboard = getKeyboard();
|
||||
if (keyboard == null) {
|
||||
return;
|
||||
|
@ -364,8 +364,8 @@ public class KeyboardView extends View {
|
|||
mInvalidateAllKeys = false;
|
||||
}
|
||||
|
||||
private void onDrawKey(@Nonnull final Key key, @Nonnull final Canvas canvas,
|
||||
@Nonnull final Paint paint) {
|
||||
private void onDrawKey(@NonNull final Key key, @NonNull final Canvas canvas,
|
||||
@NonNull final Paint paint) {
|
||||
final int keyDrawX = key.getDrawX() + getPaddingLeft();
|
||||
final int keyDrawY = key.getY() + getPaddingTop();
|
||||
canvas.translate(keyDrawX, keyDrawY);
|
||||
|
@ -385,8 +385,8 @@ public class KeyboardView extends View {
|
|||
}
|
||||
|
||||
// Draw key background.
|
||||
protected void onDrawKeyBackground(@Nonnull final Key key, @Nonnull final Canvas canvas,
|
||||
@Nonnull final Drawable background) {
|
||||
protected void onDrawKeyBackground(@NonNull final Key key, @NonNull final Canvas canvas,
|
||||
@NonNull final Drawable background) {
|
||||
final int keyWidth = key.getDrawWidth();
|
||||
final int keyHeight = key.getHeight();
|
||||
final int bgWidth, bgHeight, bgX, bgY;
|
||||
|
@ -411,8 +411,8 @@ public class KeyboardView extends View {
|
|||
}
|
||||
|
||||
// Draw key top visuals.
|
||||
protected void onDrawKeyTopVisuals(@Nonnull final Key key, @Nonnull final Canvas canvas,
|
||||
@Nonnull final Paint paint, @Nonnull final KeyDrawParams params) {
|
||||
protected void onDrawKeyTopVisuals(@NonNull final Key key, @NonNull final Canvas canvas,
|
||||
@NonNull final Paint paint, @NonNull final KeyDrawParams params) {
|
||||
final int keyWidth = key.getDrawWidth();
|
||||
final int keyHeight = key.getHeight();
|
||||
final float centerX = keyWidth * 0.5f;
|
||||
|
@ -541,8 +541,8 @@ public class KeyboardView extends View {
|
|||
}
|
||||
|
||||
// Draw popup hint "..." at the bottom right corner of the key.
|
||||
protected void drawKeyPopupHint(@Nonnull final Key key, @Nonnull final Canvas canvas,
|
||||
@Nonnull final Paint paint, @Nonnull final KeyDrawParams params) {
|
||||
protected void drawKeyPopupHint(@NonNull final Key key, @NonNull final Canvas canvas,
|
||||
@NonNull final Paint paint, @NonNull final KeyDrawParams params) {
|
||||
if (TextUtils.isEmpty(mKeyPopupHintLetter)) {
|
||||
return;
|
||||
}
|
||||
|
@ -559,7 +559,7 @@ public class KeyboardView extends View {
|
|||
canvas.drawText(mKeyPopupHintLetter, hintX, hintY, paint);
|
||||
}
|
||||
|
||||
protected static void drawIcon(@Nonnull final Canvas canvas,@Nonnull final Drawable icon,
|
||||
protected static void drawIcon(@NonNull final Canvas canvas,@NonNull final Drawable icon,
|
||||
final int x, final int y, final int width, final int height) {
|
||||
canvas.translate(x, y);
|
||||
icon.setBounds(0, 0, width, height);
|
||||
|
|
|
@ -34,6 +34,9 @@ import android.view.MotionEvent;
|
|||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
import org.dslul.openboard.inputmethod.accessibility.AccessibilityUtils;
|
||||
import org.dslul.openboard.inputmethod.accessibility.MainKeyboardAccessibilityDelegate;
|
||||
import org.dslul.openboard.inputmethod.annotations.ExternallyReferenced;
|
||||
|
@ -63,14 +66,10 @@ import org.dslul.openboard.inputmethod.latin.utils.LanguageOnSpacebarUtils;
|
|||
import org.dslul.openboard.inputmethod.latin.utils.TypefaceUtils;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.WeakHashMap;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
/**
|
||||
* A view that is responsible for detecting key presses and touch movements.
|
||||
*
|
||||
|
@ -470,7 +469,7 @@ public final class MainKeyboardView extends KeyboardView implements DrawingProxy
|
|||
|
||||
// Implements {@link DrawingProxy#onKeyPressed(Key,boolean)}.
|
||||
@Override
|
||||
public void onKeyPressed(@Nonnull final Key key, final boolean withPreview) {
|
||||
public void onKeyPressed(@NonNull final Key key, final boolean withPreview) {
|
||||
key.onPressed();
|
||||
invalidateKey(key);
|
||||
if (withPreview && !key.noKeyPreview()) {
|
||||
|
@ -478,7 +477,7 @@ public final class MainKeyboardView extends KeyboardView implements DrawingProxy
|
|||
}
|
||||
}
|
||||
|
||||
private void showKeyPreview(@Nonnull final Key key) {
|
||||
private void showKeyPreview(@NonNull final Key key) {
|
||||
final Keyboard keyboard = getKeyboard();
|
||||
if (keyboard == null) {
|
||||
return;
|
||||
|
@ -495,14 +494,14 @@ public final class MainKeyboardView extends KeyboardView implements DrawingProxy
|
|||
getWidth(), mOriginCoords, mDrawingPreviewPlacerView);
|
||||
}
|
||||
|
||||
private void dismissKeyPreviewWithoutDelay(@Nonnull final Key key) {
|
||||
private void dismissKeyPreviewWithoutDelay(@NonNull final Key key) {
|
||||
mKeyPreviewChoreographer.dismissKeyPreview(key);
|
||||
invalidateKey(key);
|
||||
}
|
||||
|
||||
// Implements {@link DrawingProxy#onKeyReleased(Key,boolean)}.
|
||||
@Override
|
||||
public void onKeyReleased(@Nonnull final Key key, final boolean withAnimation) {
|
||||
public void onKeyReleased(@NonNull final Key key, final boolean withAnimation) {
|
||||
key.onReleased();
|
||||
invalidateKey(key);
|
||||
if (!key.noKeyPreview()) {
|
||||
|
@ -514,7 +513,7 @@ public final class MainKeyboardView extends KeyboardView implements DrawingProxy
|
|||
}
|
||||
}
|
||||
|
||||
private void dismissKeyPreview(@Nonnull final Key key) {
|
||||
private void dismissKeyPreview(@NonNull final Key key) {
|
||||
if (isHardwareAccelerated()) {
|
||||
mKeyPreviewChoreographer.dismissKeyPreview(key);
|
||||
}
|
||||
|
@ -540,12 +539,12 @@ public final class MainKeyboardView extends KeyboardView implements DrawingProxy
|
|||
mGestureTrailsDrawingPreview.setPreviewEnabled(isGestureTrailEnabled);
|
||||
}
|
||||
|
||||
public void showGestureFloatingPreviewText(@Nonnull final SuggestedWords suggestedWords,
|
||||
public void showGestureFloatingPreviewText(@NonNull final SuggestedWords suggestedWords,
|
||||
final boolean dismissDelayed) {
|
||||
locatePreviewPlacerView();
|
||||
final GestureFloatingTextDrawingPreview gestureFloatingTextDrawingPreview =
|
||||
mGestureFloatingTextDrawingPreview;
|
||||
gestureFloatingTextDrawingPreview.setSuggetedWords(suggestedWords);
|
||||
gestureFloatingTextDrawingPreview.setSuggestedWords(suggestedWords);
|
||||
if (dismissDelayed) {
|
||||
mTimerHandler.postDismissGestureFloatingPreviewText(
|
||||
mGestureFloatingPreviewTextLingerTimeout);
|
||||
|
@ -559,7 +558,7 @@ public final class MainKeyboardView extends KeyboardView implements DrawingProxy
|
|||
}
|
||||
|
||||
@Override
|
||||
public void showGestureTrail(@Nonnull final PointerTracker tracker,
|
||||
public void showGestureTrail(@NonNull final PointerTracker tracker,
|
||||
final boolean showsFloatingPreviewText) {
|
||||
locatePreviewPlacerView();
|
||||
if (showsFloatingPreviewText) {
|
||||
|
@ -597,8 +596,8 @@ public final class MainKeyboardView extends KeyboardView implements DrawingProxy
|
|||
// Implements {@link DrawingProxy@showMoreKeysKeyboard(Key,PointerTracker)}.
|
||||
@Override
|
||||
@Nullable
|
||||
public MoreKeysPanel showMoreKeysKeyboard(@Nonnull final Key key,
|
||||
@Nonnull final PointerTracker tracker) {
|
||||
public MoreKeysPanel showMoreKeysKeyboard(@NonNull final Key key,
|
||||
@NonNull final PointerTracker tracker) {
|
||||
final MoreKeySpec[] moreKeys = key.getMoreKeys();
|
||||
if (moreKeys == null) {
|
||||
return null;
|
||||
|
|
|
@ -19,6 +19,8 @@ package org.dslul.openboard.inputmethod.keyboard;
|
|||
import android.content.Context;
|
||||
import android.graphics.Paint;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
|
||||
import org.dslul.openboard.inputmethod.annotations.UsedForTesting;
|
||||
import org.dslul.openboard.inputmethod.keyboard.internal.KeyboardBuilder;
|
||||
import org.dslul.openboard.inputmethod.keyboard.internal.KeyboardParams;
|
||||
|
@ -27,8 +29,6 @@ import org.dslul.openboard.inputmethod.latin.R;
|
|||
import org.dslul.openboard.inputmethod.latin.common.StringUtils;
|
||||
import org.dslul.openboard.inputmethod.latin.utils.TypefaceUtils;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
public final class MoreKeysKeyboard extends Keyboard {
|
||||
private final int mDefaultKeyCoordX;
|
||||
|
||||
|
@ -330,7 +330,7 @@ public final class MoreKeysKeyboard extends Keyboard {
|
|||
}
|
||||
|
||||
@Override
|
||||
@Nonnull
|
||||
@NonNull
|
||||
public MoreKeysKeyboard build() {
|
||||
final MoreKeysKeyboardParams params = mParams;
|
||||
final int moreKeyFlags = mParentKey.getMoreKeyLabelFlags();
|
||||
|
|
|
@ -24,6 +24,9 @@ import android.os.SystemClock;
|
|||
import android.util.Log;
|
||||
import android.view.MotionEvent;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
import org.dslul.openboard.inputmethod.keyboard.internal.BatchInputArbiter;
|
||||
import org.dslul.openboard.inputmethod.keyboard.internal.BatchInputArbiter.BatchInputArbiterListener;
|
||||
import org.dslul.openboard.inputmethod.keyboard.internal.BogusMoveEventDetector;
|
||||
|
@ -45,9 +48,6 @@ import org.dslul.openboard.inputmethod.latin.utils.ResourceUtils;
|
|||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
public final class PointerTracker implements PointerTrackerQueue.Element,
|
||||
BatchInputArbiterListener {
|
||||
private static final String TAG = PointerTracker.class.getSimpleName();
|
||||
|
@ -117,7 +117,7 @@ public final class PointerTracker implements PointerTrackerQueue.Element,
|
|||
|
||||
// The position and time at which first down event occurred.
|
||||
private long mDownTime;
|
||||
@Nonnull
|
||||
@NonNull
|
||||
private int[] mDownCoordinates = CoordinateUtils.newInstance();
|
||||
private long mUpTime;
|
||||
|
||||
|
@ -470,7 +470,7 @@ public final class PointerTracker implements PointerTrackerQueue.Element,
|
|||
return mGestureStrokeDrawingPoints;
|
||||
}
|
||||
|
||||
public void getLastCoordinates(@Nonnull final int[] outCoords) {
|
||||
public void getLastCoordinates(@NonNull final int[] outCoords) {
|
||||
CoordinateUtils.set(outCoords, mLastX, mLastY);
|
||||
}
|
||||
|
||||
|
@ -478,7 +478,7 @@ public final class PointerTracker implements PointerTrackerQueue.Element,
|
|||
return mDownTime;
|
||||
}
|
||||
|
||||
public void getDownCoordinates(@Nonnull final int[] outCoords) {
|
||||
public void getDownCoordinates(@NonNull final int[] outCoords) {
|
||||
CoordinateUtils.copy(outCoords, mDownCoordinates);
|
||||
}
|
||||
|
||||
|
|
|
@ -20,14 +20,15 @@ import android.content.SharedPreferences;
|
|||
import android.text.TextUtils;
|
||||
import android.util.Log;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
import org.dslul.openboard.inputmethod.keyboard.Key;
|
||||
import org.dslul.openboard.inputmethod.keyboard.Keyboard;
|
||||
import org.dslul.openboard.inputmethod.keyboard.internal.MoreKeySpec;
|
||||
import org.dslul.openboard.inputmethod.latin.settings.Settings;
|
||||
import org.dslul.openboard.inputmethod.latin.utils.JsonUtils;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.ArrayDeque;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
|
@ -250,7 +251,7 @@ final class DynamicGridKeyboard extends Keyboard {
|
|||
private int mCurrentX;
|
||||
private int mCurrentY;
|
||||
|
||||
public GridKey(@Nonnull final Key originalKey, @Nullable final MoreKeySpec[] moreKeys,
|
||||
public GridKey(@NonNull final Key originalKey, @Nullable final MoreKeySpec[] moreKeys,
|
||||
@Nullable final String labelHint, final int backgroundType) {
|
||||
super(originalKey, moreKeys, labelHint, backgroundType);
|
||||
}
|
||||
|
|
|
@ -32,6 +32,10 @@ import android.view.ViewParent;
|
|||
import android.view.accessibility.AccessibilityEvent;
|
||||
|
||||
import android.widget.FrameLayout;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
import org.dslul.openboard.inputmethod.accessibility.AccessibilityUtils;
|
||||
import org.dslul.openboard.inputmethod.accessibility.KeyboardAccessibilityDelegate;
|
||||
import org.dslul.openboard.inputmethod.keyboard.Key;
|
||||
|
@ -46,8 +50,6 @@ import org.dslul.openboard.inputmethod.latin.R;
|
|||
import org.dslul.openboard.inputmethod.latin.common.CoordinateUtils;
|
||||
import org.dslul.openboard.inputmethod.latin.settings.Settings;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.WeakHashMap;
|
||||
|
||||
/**
|
||||
|
@ -179,7 +181,7 @@ public final class EmojiPageKeyboardView extends KeyboardView implements
|
|||
}
|
||||
|
||||
@Nullable
|
||||
public MoreKeysPanel showMoreKeysKeyboard(@Nonnull final Key key, final int lastX, final int lastY) {
|
||||
public MoreKeysPanel showMoreKeysKeyboard(@NonNull final Key key, final int lastX, final int lastY) {
|
||||
final MoreKeySpec[] moreKeys = key.getMoreKeys();
|
||||
if (moreKeys == null) {
|
||||
return null;
|
||||
|
|
|
@ -19,11 +19,11 @@ package org.dslul.openboard.inputmethod.keyboard.internal;
|
|||
import android.graphics.Canvas;
|
||||
import android.view.View;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
|
||||
import org.dslul.openboard.inputmethod.keyboard.MainKeyboardView;
|
||||
import org.dslul.openboard.inputmethod.keyboard.PointerTracker;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
/**
|
||||
* Abstract base class for previews that are drawn on DrawingPreviewPlacerView, e.g.,
|
||||
* GestureFloatingTextDrawingPreview, GestureTrailsDrawingPreview, and
|
||||
|
@ -34,7 +34,7 @@ public abstract class AbstractDrawingPreview {
|
|||
private boolean mPreviewEnabled;
|
||||
private boolean mHasValidGeometry;
|
||||
|
||||
public void setDrawingView(@Nonnull final DrawingPreviewPlacerView drawingView) {
|
||||
public void setDrawingView(@NonNull final DrawingPreviewPlacerView drawingView) {
|
||||
mDrawingView = drawingView;
|
||||
drawingView.addPreview(this);
|
||||
}
|
||||
|
@ -63,7 +63,7 @@ public abstract class AbstractDrawingPreview {
|
|||
* @param width the width of {@link MainKeyboardView}.
|
||||
* @param height the height of {@link MainKeyboardView}.
|
||||
*/
|
||||
public void setKeyboardViewGeometry(@Nonnull final int[] originCoords, final int width,
|
||||
public void setKeyboardViewGeometry(@NonNull final int[] originCoords, final int width,
|
||||
final int height) {
|
||||
mHasValidGeometry = (width > 0 && height > 0);
|
||||
}
|
||||
|
@ -74,11 +74,11 @@ public abstract class AbstractDrawingPreview {
|
|||
* Draws the preview
|
||||
* @param canvas The canvas where the preview is drawn.
|
||||
*/
|
||||
public abstract void drawPreview(@Nonnull final Canvas canvas);
|
||||
public abstract void drawPreview(@NonNull final Canvas canvas);
|
||||
|
||||
/**
|
||||
* Set the position of the preview.
|
||||
* @param tracker The new location of the preview is based on the points in PointerTracker.
|
||||
*/
|
||||
public abstract void setPreviewPosition(@Nonnull final PointerTracker tracker);
|
||||
public abstract void setPreviewPosition(@NonNull final PointerTracker tracker);
|
||||
}
|
||||
|
|
|
@ -16,27 +16,27 @@
|
|||
|
||||
package org.dslul.openboard.inputmethod.keyboard.internal;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
import org.dslul.openboard.inputmethod.keyboard.Key;
|
||||
import org.dslul.openboard.inputmethod.keyboard.MoreKeysPanel;
|
||||
import org.dslul.openboard.inputmethod.keyboard.PointerTracker;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
public interface DrawingProxy {
|
||||
/**
|
||||
* Called when a key is being pressed.
|
||||
* @param key the {@link Key} that is being pressed.
|
||||
* @param withPreview true if key popup preview should be displayed.
|
||||
*/
|
||||
void onKeyPressed(@Nonnull Key key, boolean withPreview);
|
||||
void onKeyPressed(@NonNull Key key, boolean withPreview);
|
||||
|
||||
/**
|
||||
* Called when a key is being released.
|
||||
* @param key the {@link Key} that is being released.
|
||||
* @param withAnimation when true, key popup preview should be dismissed with animation.
|
||||
*/
|
||||
void onKeyReleased(@Nonnull Key key, boolean withAnimation);
|
||||
void onKeyReleased(@NonNull Key key, boolean withAnimation);
|
||||
|
||||
/**
|
||||
* Start showing more keys keyboard of a key that is being long pressed.
|
||||
|
@ -46,7 +46,7 @@ public interface DrawingProxy {
|
|||
* keyboard.
|
||||
*/
|
||||
@Nullable
|
||||
MoreKeysPanel showMoreKeysKeyboard(@Nonnull Key key, @Nonnull PointerTracker tracker);
|
||||
MoreKeysPanel showMoreKeysKeyboard(@NonNull Key key, @NonNull PointerTracker tracker);
|
||||
|
||||
/**
|
||||
* Start a while-typing-animation.
|
||||
|
@ -70,7 +70,7 @@ public interface DrawingProxy {
|
|||
* @param showsFloatingPreviewText when true, a gesture floating preview text will be shown
|
||||
* with this <code>tracker</code>'s trail.
|
||||
*/
|
||||
void showGestureTrail(@Nonnull PointerTracker tracker, boolean showsFloatingPreviewText);
|
||||
void showGestureTrail(@NonNull PointerTracker tracker, boolean showsFloatingPreviewText);
|
||||
|
||||
/**
|
||||
* Dismiss a gesture floating preview text without delay.
|
||||
|
|
|
@ -24,6 +24,8 @@ import android.graphics.Rect;
|
|||
import android.graphics.RectF;
|
||||
import android.text.TextUtils;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
|
||||
import org.dslul.openboard.inputmethod.keyboard.PointerTracker;
|
||||
import org.dslul.openboard.inputmethod.latin.R;
|
||||
import org.dslul.openboard.inputmethod.latin.SuggestedWords;
|
||||
|
@ -31,8 +33,6 @@ import org.dslul.openboard.inputmethod.latin.common.Colors;
|
|||
import org.dslul.openboard.inputmethod.latin.common.CoordinateUtils;
|
||||
import org.dslul.openboard.inputmethod.latin.settings.Settings;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
/**
|
||||
* The class for single gesture preview text. The class for multiple gesture preview text will be
|
||||
* derived from it.
|
||||
|
@ -114,10 +114,10 @@ public class GestureFloatingTextDrawingPreview extends AbstractDrawingPreview {
|
|||
}
|
||||
|
||||
public void dismissGestureFloatingPreviewText() {
|
||||
setSuggetedWords(SuggestedWords.getEmptyInstance());
|
||||
setSuggestedWords(SuggestedWords.getEmptyInstance());
|
||||
}
|
||||
|
||||
public void setSuggetedWords(@Nonnull final SuggestedWords suggestedWords) {
|
||||
public void setSuggestedWords(@NonNull final SuggestedWords suggestedWords) {
|
||||
if (!isPreviewEnabled()) {
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -18,13 +18,13 @@ package org.dslul.openboard.inputmethod.keyboard.internal;
|
|||
|
||||
import android.graphics.Typeface;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
import org.dslul.openboard.inputmethod.latin.utils.ResourceUtils;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
public final class KeyDrawParams {
|
||||
@Nonnull
|
||||
@NonNull
|
||||
public Typeface mTypeface = Typeface.DEFAULT;
|
||||
|
||||
public int mLetterSize;
|
||||
|
@ -53,7 +53,7 @@ public final class KeyDrawParams {
|
|||
|
||||
public KeyDrawParams() {}
|
||||
|
||||
private KeyDrawParams(@Nonnull final KeyDrawParams copyFrom) {
|
||||
private KeyDrawParams(@NonNull final KeyDrawParams copyFrom) {
|
||||
mTypeface = copyFrom.mTypeface;
|
||||
|
||||
mLetterSize = copyFrom.mLetterSize;
|
||||
|
@ -121,7 +121,7 @@ public final class KeyDrawParams {
|
|||
attr.mHintLabelOffCenterRatio, mHintLabelOffCenterRatio);
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@NonNull
|
||||
public KeyDrawParams mayCloneAndUpdateParams(final int keyHeight,
|
||||
@Nullable final KeyVisualAttributes attr) {
|
||||
if (attr == null) {
|
||||
|
|
|
@ -19,12 +19,12 @@ package org.dslul.openboard.inputmethod.keyboard.internal;
|
|||
import org.dslul.openboard.inputmethod.latin.common.Constants;
|
||||
import org.dslul.openboard.inputmethod.latin.common.StringUtils;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import static org.dslul.openboard.inputmethod.latin.common.Constants.CODE_OUTPUT_TEXT;
|
||||
import static org.dslul.openboard.inputmethod.latin.common.Constants.CODE_UNSPECIFIED;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
/**
|
||||
* The string parser of the key specification.
|
||||
*
|
||||
|
@ -56,11 +56,11 @@ public final class KeySpecParser {
|
|||
// Intentional empty constructor for utility class.
|
||||
}
|
||||
|
||||
private static boolean hasIcon(@Nonnull final String keySpec) {
|
||||
private static boolean hasIcon(@NonNull final String keySpec) {
|
||||
return keySpec.startsWith(KeyboardIconsSet.PREFIX_ICON);
|
||||
}
|
||||
|
||||
private static boolean hasCode(@Nonnull final String keySpec, final int labelEnd) {
|
||||
private static boolean hasCode(@NonNull final String keySpec, final int labelEnd) {
|
||||
if (labelEnd <= 0 || labelEnd + 1 >= keySpec.length()) {
|
||||
return false;
|
||||
}
|
||||
|
@ -72,8 +72,8 @@ public final class KeySpecParser {
|
|||
return keySpec.startsWith(PREFIX_HEX, labelEnd + 1);
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
private static String parseEscape(@Nonnull final String text) {
|
||||
@NonNull
|
||||
private static String parseEscape(@NonNull final String text) {
|
||||
if (text.indexOf(BACKSLASH) < 0) {
|
||||
return text;
|
||||
}
|
||||
|
@ -92,7 +92,7 @@ public final class KeySpecParser {
|
|||
return sb.toString();
|
||||
}
|
||||
|
||||
private static int indexOfLabelEnd(@Nonnull final String keySpec) {
|
||||
private static int indexOfLabelEnd(@NonNull final String keySpec) {
|
||||
final int length = keySpec.length();
|
||||
if (keySpec.indexOf(BACKSLASH) < 0) {
|
||||
final int labelEnd = keySpec.indexOf(VERTICAL_BAR);
|
||||
|
@ -117,17 +117,17 @@ public final class KeySpecParser {
|
|||
return -1;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
private static String getBeforeLabelEnd(@Nonnull final String keySpec, final int labelEnd) {
|
||||
@NonNull
|
||||
private static String getBeforeLabelEnd(@NonNull final String keySpec, final int labelEnd) {
|
||||
return (labelEnd < 0) ? keySpec : keySpec.substring(0, labelEnd);
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
private static String getAfterLabelEnd(@Nonnull final String keySpec, final int labelEnd) {
|
||||
@NonNull
|
||||
private static String getAfterLabelEnd(@NonNull final String keySpec, final int labelEnd) {
|
||||
return keySpec.substring(labelEnd + /* VERTICAL_BAR */1);
|
||||
}
|
||||
|
||||
private static void checkDoubleLabelEnd(@Nonnull final String keySpec, final int labelEnd) {
|
||||
private static void checkDoubleLabelEnd(@NonNull final String keySpec, final int labelEnd) {
|
||||
if (indexOfLabelEnd(getAfterLabelEnd(keySpec, labelEnd)) < 0) {
|
||||
return;
|
||||
}
|
||||
|
@ -152,7 +152,7 @@ public final class KeySpecParser {
|
|||
}
|
||||
|
||||
@Nullable
|
||||
private static String getOutputTextInternal(@Nonnull final String keySpec, final int labelEnd) {
|
||||
private static String getOutputTextInternal(@NonNull final String keySpec, final int labelEnd) {
|
||||
if (labelEnd <= 0) {
|
||||
return null;
|
||||
}
|
||||
|
|
|
@ -18,8 +18,8 @@ package org.dslul.openboard.inputmethod.keyboard.internal;
|
|||
|
||||
import android.content.res.TypedArray;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
public abstract class KeyStyle {
|
||||
private final KeyboardTextsSet mTextsSet;
|
||||
|
@ -29,7 +29,7 @@ public abstract class KeyStyle {
|
|||
public abstract int getInt(TypedArray a, int index, int defaultValue);
|
||||
public abstract int getFlags(TypedArray a, int index);
|
||||
|
||||
protected KeyStyle(@Nonnull final KeyboardTextsSet textsSet) {
|
||||
protected KeyStyle(@NonNull final KeyboardTextsSet textsSet) {
|
||||
mTextsSet = textsSet;
|
||||
}
|
||||
|
||||
|
|
|
@ -20,6 +20,9 @@ import android.content.res.TypedArray;
|
|||
import android.util.Log;
|
||||
import android.util.SparseArray;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
import org.dslul.openboard.inputmethod.latin.R;
|
||||
import org.dslul.openboard.inputmethod.latin.utils.XmlParseUtils;
|
||||
import org.xmlpull.v1.XmlPullParser;
|
||||
|
@ -28,31 +31,28 @@ import org.xmlpull.v1.XmlPullParserException;
|
|||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
public final class KeyStylesSet {
|
||||
private static final String TAG = KeyStylesSet.class.getSimpleName();
|
||||
private static final boolean DEBUG = false;
|
||||
|
||||
@Nonnull
|
||||
@NonNull
|
||||
private final HashMap<String, KeyStyle> mStyles = new HashMap<>();
|
||||
|
||||
@Nonnull
|
||||
@NonNull
|
||||
private final KeyboardTextsSet mTextsSet;
|
||||
@Nonnull
|
||||
@NonNull
|
||||
private final KeyStyle mEmptyKeyStyle;
|
||||
@Nonnull
|
||||
@NonNull
|
||||
private static final String EMPTY_STYLE_NAME = "<empty>";
|
||||
|
||||
public KeyStylesSet(@Nonnull final KeyboardTextsSet textsSet) {
|
||||
public KeyStylesSet(@NonNull final KeyboardTextsSet textsSet) {
|
||||
mTextsSet = textsSet;
|
||||
mEmptyKeyStyle = new EmptyKeyStyle(textsSet);
|
||||
mStyles.put(EMPTY_STYLE_NAME, mEmptyKeyStyle);
|
||||
}
|
||||
|
||||
private static final class EmptyKeyStyle extends KeyStyle {
|
||||
EmptyKeyStyle(@Nonnull final KeyboardTextsSet textsSet) {
|
||||
EmptyKeyStyle(@NonNull final KeyboardTextsSet textsSet) {
|
||||
super(textsSet);
|
||||
}
|
||||
|
||||
|
@ -84,9 +84,9 @@ public final class KeyStylesSet {
|
|||
private final String mParentStyleName;
|
||||
private final SparseArray<Object> mStyleAttributes = new SparseArray<>();
|
||||
|
||||
public DeclaredKeyStyle(@Nonnull final String parentStyleName,
|
||||
@Nonnull final KeyboardTextsSet textsSet,
|
||||
@Nonnull final HashMap<String, KeyStyle> styles) {
|
||||
public DeclaredKeyStyle(@NonNull final String parentStyleName,
|
||||
@NonNull final KeyboardTextsSet textsSet,
|
||||
@NonNull final HashMap<String, KeyStyle> styles) {
|
||||
super(textsSet);
|
||||
mParentStyleName = parentStyleName;
|
||||
mStyles = styles;
|
||||
|
@ -213,7 +213,7 @@ public final class KeyStylesSet {
|
|||
mStyles.put(styleName, style);
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@NonNull
|
||||
public KeyStyle getKeyStyle(final TypedArray keyAttr, final XmlPullParser parser)
|
||||
throws XmlParseUtils.ParseException {
|
||||
final String styleName = keyAttr.getString(R.styleable.Keyboard_Key_keyStyle);
|
||||
|
|
|
@ -20,14 +20,14 @@ import android.content.res.TypedArray;
|
|||
import android.graphics.Typeface;
|
||||
import android.util.SparseIntArray;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
import org.dslul.openboard.inputmethod.latin.R;
|
||||
import org.dslul.openboard.inputmethod.latin.common.Colors;
|
||||
import org.dslul.openboard.inputmethod.latin.settings.Settings;
|
||||
import org.dslul.openboard.inputmethod.latin.utils.ResourceUtils;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
public final class KeyVisualAttributes {
|
||||
@Nullable
|
||||
public final Typeface mTypeface;
|
||||
|
@ -88,7 +88,7 @@ public final class KeyVisualAttributes {
|
|||
}
|
||||
|
||||
@Nullable
|
||||
public static KeyVisualAttributes newInstance(@Nonnull final TypedArray keyAttr) {
|
||||
public static KeyVisualAttributes newInstance(@NonNull final TypedArray keyAttr) {
|
||||
final int indexCount = keyAttr.getIndexCount();
|
||||
for (int i = 0; i < indexCount; i++) {
|
||||
final int attrId = keyAttr.getIndex(i);
|
||||
|
@ -100,7 +100,7 @@ public final class KeyVisualAttributes {
|
|||
return null;
|
||||
}
|
||||
|
||||
private KeyVisualAttributes(@Nonnull final TypedArray keyAttr) {
|
||||
private KeyVisualAttributes(@NonNull final TypedArray keyAttr) {
|
||||
if (keyAttr.hasValue(R.styleable.Keyboard_Key_keyTypeface)) {
|
||||
mTypeface = Typeface.defaultFromStyle(
|
||||
keyAttr.getInt(R.styleable.Keyboard_Key_keyTypeface, Typeface.NORMAL));
|
||||
|
|
|
@ -27,6 +27,8 @@ import android.util.Log;
|
|||
import android.util.TypedValue;
|
||||
import android.util.Xml;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
|
||||
import org.dslul.openboard.inputmethod.annotations.UsedForTesting;
|
||||
import org.dslul.openboard.inputmethod.keyboard.Key;
|
||||
import org.dslul.openboard.inputmethod.keyboard.Keyboard;
|
||||
|
@ -46,8 +48,6 @@ import java.io.IOException;
|
|||
import java.util.Arrays;
|
||||
import java.util.Locale;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
/**
|
||||
* Keyboard Building helper.
|
||||
*
|
||||
|
@ -139,7 +139,7 @@ public class KeyboardBuilder<KP extends KeyboardParams> {
|
|||
private static final int DEFAULT_KEYBOARD_COLUMNS = 10;
|
||||
private static final int DEFAULT_KEYBOARD_ROWS = 4;
|
||||
|
||||
@Nonnull
|
||||
@NonNull
|
||||
protected final KP mParams;
|
||||
protected final Context mContext;
|
||||
protected final Resources mResources;
|
||||
|
@ -150,7 +150,7 @@ public class KeyboardBuilder<KP extends KeyboardParams> {
|
|||
private boolean mTopEdge;
|
||||
private Key mRightEdgeKey = null;
|
||||
|
||||
public KeyboardBuilder(final Context context, @Nonnull final KP params) {
|
||||
public KeyboardBuilder(final Context context, @NonNull final KP params) {
|
||||
mContext = context;
|
||||
final Resources res = context.getResources();
|
||||
mResources = res;
|
||||
|
@ -191,7 +191,7 @@ public class KeyboardBuilder<KP extends KeyboardParams> {
|
|||
mParams.mProximityCharsCorrectionEnabled = enabled;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@NonNull
|
||||
public Keyboard build() {
|
||||
return new Keyboard(mParams);
|
||||
}
|
||||
|
@ -893,7 +893,7 @@ public class KeyboardBuilder<KP extends KeyboardParams> {
|
|||
mTopEdge = false;
|
||||
}
|
||||
|
||||
private void endKey(@Nonnull final Key key) {
|
||||
private void endKey(@NonNull final Key key) {
|
||||
mParams.onAddKey(key);
|
||||
if (mLeftEdge) {
|
||||
key.markAsLeftEdge(mParams);
|
||||
|
|
|
@ -22,13 +22,13 @@ import android.graphics.drawable.Drawable;
|
|||
import android.util.Log;
|
||||
import android.util.SparseIntArray;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
import org.dslul.openboard.inputmethod.latin.R;
|
||||
|
||||
import java.util.HashMap;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
public final class KeyboardIconsSet {
|
||||
private static final String TAG = KeyboardIconsSet.class.getSimpleName();
|
||||
|
||||
|
@ -146,7 +146,7 @@ public final class KeyboardIconsSet {
|
|||
return iconId >= 0 && iconId < ICON_NAMES.length;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@NonNull
|
||||
public static String getIconName(final int iconId) {
|
||||
return isValidIconId(iconId) ? ICON_NAMES[iconId] : "unknown<" + iconId + ">";
|
||||
}
|
||||
|
|
|
@ -18,6 +18,9 @@ package org.dslul.openboard.inputmethod.keyboard.internal;
|
|||
|
||||
import android.util.SparseIntArray;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
import org.dslul.openboard.inputmethod.keyboard.Key;
|
||||
import org.dslul.openboard.inputmethod.keyboard.KeyboardId;
|
||||
import org.dslul.openboard.inputmethod.latin.common.Constants;
|
||||
|
@ -27,9 +30,6 @@ import java.util.Comparator;
|
|||
import java.util.SortedSet;
|
||||
import java.util.TreeSet;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
public class KeyboardParams {
|
||||
public KeyboardId mId;
|
||||
public int mThemeId;
|
||||
|
@ -64,20 +64,20 @@ public class KeyboardParams {
|
|||
public int GRID_HEIGHT;
|
||||
|
||||
// Keys are sorted from top-left to bottom-right order.
|
||||
@Nonnull
|
||||
@NonNull
|
||||
public final SortedSet<Key> mSortedKeys = new TreeSet<>(ROW_COLUMN_COMPARATOR);
|
||||
@Nonnull
|
||||
@NonNull
|
||||
public final ArrayList<Key> mShiftKeys = new ArrayList<>();
|
||||
@Nonnull
|
||||
@NonNull
|
||||
public final ArrayList<Key> mAltCodeKeysWhileTyping = new ArrayList<>();
|
||||
@Nonnull
|
||||
@NonNull
|
||||
public final KeyboardIconsSet mIconsSet = new KeyboardIconsSet();
|
||||
@Nonnull
|
||||
@NonNull
|
||||
public final KeyboardTextsSet mTextsSet = new KeyboardTextsSet();
|
||||
@Nonnull
|
||||
@NonNull
|
||||
public final KeyStylesSet mKeyStyles = new KeyStylesSet(mTextsSet);
|
||||
|
||||
@Nonnull
|
||||
@NonNull
|
||||
private final UniqueKeysCache mUniqueKeysCache;
|
||||
public boolean mAllowRedundantMoreKeys;
|
||||
|
||||
|
@ -86,7 +86,7 @@ public class KeyboardParams {
|
|||
|
||||
public boolean mProximityCharsCorrectionEnabled;
|
||||
|
||||
@Nonnull
|
||||
@NonNull
|
||||
public final TouchPositionCorrection mTouchPositionCorrection =
|
||||
new TouchPositionCorrection();
|
||||
|
||||
|
@ -106,7 +106,7 @@ public class KeyboardParams {
|
|||
this(UniqueKeysCache.NO_CACHE);
|
||||
}
|
||||
|
||||
public KeyboardParams(@Nonnull final UniqueKeysCache keysCache) {
|
||||
public KeyboardParams(@NonNull final UniqueKeysCache keysCache) {
|
||||
mUniqueKeysCache = keysCache;
|
||||
}
|
||||
|
||||
|
@ -116,7 +116,7 @@ public class KeyboardParams {
|
|||
clearHistogram();
|
||||
}
|
||||
|
||||
public void onAddKey(@Nonnull final Key newKey) {
|
||||
public void onAddKey(@NonNull final Key newKey) {
|
||||
final Key key = mUniqueKeysCache.getUniqueKey(newKey);
|
||||
final boolean isSpacer = key.isSpacer();
|
||||
if (isSpacer && key.getWidth() == 0) {
|
||||
|
|
|
@ -18,9 +18,10 @@ package org.dslul.openboard.inputmethod.keyboard.internal;
|
|||
|
||||
import android.os.Build;
|
||||
import android.text.TextUtils;
|
||||
import org.dslul.openboard.inputmethod.latin.common.StringUtils;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
import org.dslul.openboard.inputmethod.latin.common.StringUtils;
|
||||
|
||||
/**
|
||||
* The string parser of moreCodesArray specification for <GridRows />. The attribute moreCodesArray is an
|
||||
|
|
|
@ -19,6 +19,9 @@ package org.dslul.openboard.inputmethod.keyboard.internal;
|
|||
import android.text.TextUtils;
|
||||
import android.util.SparseIntArray;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
import org.dslul.openboard.inputmethod.keyboard.Key;
|
||||
import org.dslul.openboard.inputmethod.latin.common.CollectionUtils;
|
||||
import org.dslul.openboard.inputmethod.latin.common.Constants;
|
||||
|
@ -28,9 +31,6 @@ import java.util.ArrayList;
|
|||
import java.util.HashSet;
|
||||
import java.util.Locale;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
/**
|
||||
* The more key specification object. The more keys are an array of {@link MoreKeySpec}.
|
||||
*
|
||||
|
@ -51,8 +51,8 @@ public final class MoreKeySpec {
|
|||
public final String mOutputText;
|
||||
public final int mIconId;
|
||||
|
||||
public MoreKeySpec(@Nonnull final String moreKeySpec, boolean needsToUpperCase,
|
||||
@Nonnull final Locale locale) {
|
||||
public MoreKeySpec(@NonNull final String moreKeySpec, boolean needsToUpperCase,
|
||||
@NonNull final Locale locale) {
|
||||
if (moreKeySpec.isEmpty()) {
|
||||
throw new KeySpecParser.KeySpecParserError("Empty more key spec");
|
||||
}
|
||||
|
@ -75,9 +75,9 @@ public final class MoreKeySpec {
|
|||
mIconId = KeySpecParser.getIconId(moreKeySpec);
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@NonNull
|
||||
public Key buildKey(final int x, final int y, final int labelFlags,
|
||||
@Nonnull final KeyboardParams params) {
|
||||
@NonNull final KeyboardParams params) {
|
||||
return new Key(mLabel, mIconId, mCode, mOutputText, null /* hintLabel */, labelFlags,
|
||||
Key.BACKGROUND_TYPE_NORMAL, x, y, params.mDefaultKeyWidth, params.mDefaultRowHeight,
|
||||
params.mHorizontalGap, params.mVerticalGap);
|
||||
|
@ -126,7 +126,7 @@ public final class MoreKeySpec {
|
|||
private final SparseIntArray mCodes = new SparseIntArray();
|
||||
private final HashSet<String> mTexts = new HashSet<>();
|
||||
|
||||
public void addLetter(@Nonnull final Key key) {
|
||||
public void addLetter(@NonNull final Key key) {
|
||||
final int code = key.getCode();
|
||||
if (Character.isAlphabetic(code)) {
|
||||
mCodes.put(code, 0);
|
||||
|
@ -135,7 +135,7 @@ public final class MoreKeySpec {
|
|||
}
|
||||
}
|
||||
|
||||
public boolean contains(@Nonnull final MoreKeySpec moreKey) {
|
||||
public boolean contains(@NonNull final MoreKeySpec moreKey) {
|
||||
final int code = moreKey.mCode;
|
||||
if (Character.isAlphabetic(code) && mCodes.indexOfKey(code) >= 0) {
|
||||
return true;
|
||||
|
@ -145,7 +145,7 @@ public final class MoreKeySpec {
|
|||
|
||||
@Nullable
|
||||
public static MoreKeySpec[] removeRedundantMoreKeys(@Nullable final MoreKeySpec[] moreKeys,
|
||||
@Nonnull final LettersOnBaseLayout lettersOnBaseLayout) {
|
||||
@NonNull final LettersOnBaseLayout lettersOnBaseLayout) {
|
||||
if (moreKeys == null) {
|
||||
return null;
|
||||
}
|
||||
|
@ -225,10 +225,10 @@ public final class MoreKeySpec {
|
|||
return list.toArray(new String[list.size()]);
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@NonNull
|
||||
private static final String[] EMPTY_STRING_ARRAY = new String[0];
|
||||
|
||||
@Nonnull
|
||||
@NonNull
|
||||
private static String[] filterOutEmptyString(@Nullable final String[] array) {
|
||||
if (array == null) {
|
||||
return EMPTY_STRING_ARRAY;
|
||||
|
|
|
@ -20,13 +20,13 @@ import android.os.Message;
|
|||
import android.os.SystemClock;
|
||||
import android.view.ViewConfiguration;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
|
||||
import org.dslul.openboard.inputmethod.keyboard.Key;
|
||||
import org.dslul.openboard.inputmethod.keyboard.PointerTracker;
|
||||
import org.dslul.openboard.inputmethod.latin.common.Constants;
|
||||
import org.dslul.openboard.inputmethod.latin.utils.LeakGuardHandlerWrapper;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
public final class TimerHandler extends LeakGuardHandlerWrapper<DrawingProxy>
|
||||
implements TimerProxy {
|
||||
private static final int MSG_TYPING_STATE_EXPIRED = 0;
|
||||
|
@ -41,7 +41,7 @@ public final class TimerHandler extends LeakGuardHandlerWrapper<DrawingProxy>
|
|||
private final int mIgnoreAltCodeKeyTimeout;
|
||||
private final int mGestureRecognitionUpdateTime;
|
||||
|
||||
public TimerHandler(@Nonnull final DrawingProxy ownerInstance,
|
||||
public TimerHandler(@NonNull final DrawingProxy ownerInstance,
|
||||
final int ignoreAltCodeKeyTimeout, final int gestureRecognitionUpdateTime) {
|
||||
super(ownerInstance);
|
||||
mIgnoreAltCodeKeyTimeout = ignoreAltCodeKeyTimeout;
|
||||
|
@ -83,7 +83,7 @@ public final class TimerHandler extends LeakGuardHandlerWrapper<DrawingProxy>
|
|||
}
|
||||
|
||||
@Override
|
||||
public void startKeyRepeatTimerOf(@Nonnull final PointerTracker tracker, final int repeatCount,
|
||||
public void startKeyRepeatTimerOf(@NonNull final PointerTracker tracker, final int repeatCount,
|
||||
final int delay) {
|
||||
final Key key = tracker.getKey();
|
||||
if (key == null || delay == 0) {
|
||||
|
@ -107,7 +107,7 @@ public final class TimerHandler extends LeakGuardHandlerWrapper<DrawingProxy>
|
|||
}
|
||||
|
||||
@Override
|
||||
public void startLongPressTimerOf(@Nonnull final PointerTracker tracker, final int delay) {
|
||||
public void startLongPressTimerOf(@NonNull final PointerTracker tracker, final int delay) {
|
||||
final Key key = tracker.getKey();
|
||||
if (key == null) {
|
||||
return;
|
||||
|
@ -120,7 +120,7 @@ public final class TimerHandler extends LeakGuardHandlerWrapper<DrawingProxy>
|
|||
}
|
||||
|
||||
@Override
|
||||
public void cancelLongPressTimersOf(@Nonnull final PointerTracker tracker) {
|
||||
public void cancelLongPressTimersOf(@NonNull final PointerTracker tracker) {
|
||||
removeMessages(MSG_LONGPRESS_KEY, tracker);
|
||||
removeMessages(MSG_LONGPRESS_SHIFT_KEY, tracker);
|
||||
}
|
||||
|
@ -136,7 +136,7 @@ public final class TimerHandler extends LeakGuardHandlerWrapper<DrawingProxy>
|
|||
}
|
||||
|
||||
@Override
|
||||
public void startTypingStateTimer(@Nonnull final Key typedKey) {
|
||||
public void startTypingStateTimer(@NonNull final Key typedKey) {
|
||||
if (typedKey.isModifier() || typedKey.altCodeWhileTyping()) {
|
||||
return;
|
||||
}
|
||||
|
@ -187,7 +187,7 @@ public final class TimerHandler extends LeakGuardHandlerWrapper<DrawingProxy>
|
|||
}
|
||||
|
||||
@Override
|
||||
public void cancelKeyTimersOf(@Nonnull final PointerTracker tracker) {
|
||||
public void cancelKeyTimersOf(@NonNull final PointerTracker tracker) {
|
||||
cancelKeyRepeatTimerOf(tracker);
|
||||
cancelLongPressTimersOf(tracker);
|
||||
}
|
||||
|
@ -198,7 +198,7 @@ public final class TimerHandler extends LeakGuardHandlerWrapper<DrawingProxy>
|
|||
}
|
||||
|
||||
@Override
|
||||
public void startUpdateBatchInputTimer(@Nonnull final PointerTracker tracker) {
|
||||
public void startUpdateBatchInputTimer(@NonNull final PointerTracker tracker) {
|
||||
if (mGestureRecognitionUpdateTime <= 0) {
|
||||
return;
|
||||
}
|
||||
|
@ -208,7 +208,7 @@ public final class TimerHandler extends LeakGuardHandlerWrapper<DrawingProxy>
|
|||
}
|
||||
|
||||
@Override
|
||||
public void cancelUpdateBatchInputTimer(@Nonnull final PointerTracker tracker) {
|
||||
public void cancelUpdateBatchInputTimer(@NonNull final PointerTracker tracker) {
|
||||
removeMessages(MSG_UPDATE_BATCH_INPUT, tracker);
|
||||
}
|
||||
|
||||
|
@ -217,7 +217,7 @@ public final class TimerHandler extends LeakGuardHandlerWrapper<DrawingProxy>
|
|||
removeMessages(MSG_UPDATE_BATCH_INPUT);
|
||||
}
|
||||
|
||||
public void postDismissKeyPreview(@Nonnull final Key key, final long delay) {
|
||||
public void postDismissKeyPreview(@NonNull final Key key, final long delay) {
|
||||
sendMessageDelayed(obtainMessage(MSG_DISMISS_KEY_PREVIEW, key), delay);
|
||||
}
|
||||
|
||||
|
|
|
@ -16,17 +16,17 @@
|
|||
|
||||
package org.dslul.openboard.inputmethod.keyboard.internal;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
|
||||
import org.dslul.openboard.inputmethod.keyboard.Key;
|
||||
import org.dslul.openboard.inputmethod.keyboard.PointerTracker;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
public interface TimerProxy {
|
||||
/**
|
||||
* Start a timer to detect if a user is typing keys.
|
||||
* @param typedKey the key that is typed.
|
||||
*/
|
||||
void startTypingStateTimer(@Nonnull Key typedKey);
|
||||
void startTypingStateTimer(@NonNull Key typedKey);
|
||||
|
||||
/**
|
||||
* Check if a user is key typing.
|
||||
|
@ -40,7 +40,7 @@ public interface TimerProxy {
|
|||
* @param repeatCount the number of times that the key is repeating. Starting from 1.
|
||||
* @param delay the interval delay to the next key repeat, in millisecond.
|
||||
*/
|
||||
void startKeyRepeatTimerOf(@Nonnull PointerTracker tracker, int repeatCount, int delay);
|
||||
void startKeyRepeatTimerOf(@NonNull PointerTracker tracker, int repeatCount, int delay);
|
||||
|
||||
/**
|
||||
* Start a timer to detect a long pressed key.
|
||||
|
@ -49,13 +49,13 @@ public interface TimerProxy {
|
|||
* @param tracker the {@link PointerTracker} that starts long pressing.
|
||||
* @param delay the delay to fire the long press timer, in millisecond.
|
||||
*/
|
||||
void startLongPressTimerOf(@Nonnull PointerTracker tracker, int delay);
|
||||
void startLongPressTimerOf(@NonNull PointerTracker tracker, int delay);
|
||||
|
||||
/**
|
||||
* Cancel timers for detecting a long pressed key and a long press shift key.
|
||||
* @param tracker cancel long press timers of this {@link PointerTracker}.
|
||||
*/
|
||||
void cancelLongPressTimersOf(@Nonnull PointerTracker tracker);
|
||||
void cancelLongPressTimersOf(@NonNull PointerTracker tracker);
|
||||
|
||||
/**
|
||||
* Cancel a timer for detecting a long pressed shift key.
|
||||
|
@ -66,7 +66,7 @@ public interface TimerProxy {
|
|||
* Cancel timers for detecting repeated key press, long pressed key, and long pressed shift key.
|
||||
* @param tracker the {@link PointerTracker} that starts timers to be canceled.
|
||||
*/
|
||||
void cancelKeyTimersOf(@Nonnull PointerTracker tracker);
|
||||
void cancelKeyTimersOf(@NonNull PointerTracker tracker);
|
||||
|
||||
/**
|
||||
* Start a timer to detect double tapped shift key.
|
||||
|
@ -88,13 +88,13 @@ public interface TimerProxy {
|
|||
* Start a timer to fire updating batch input while <code>tracker</code> is on hold.
|
||||
* @param tracker the {@link PointerTracker} that stops moving.
|
||||
*/
|
||||
void startUpdateBatchInputTimer(@Nonnull PointerTracker tracker);
|
||||
void startUpdateBatchInputTimer(@NonNull PointerTracker tracker);
|
||||
|
||||
/**
|
||||
* Cancel a timer of firing updating batch input.
|
||||
* @param tracker the {@link PointerTracker} that resumes moving or ends gesture input.
|
||||
*/
|
||||
void cancelUpdateBatchInputTimer(@Nonnull PointerTracker tracker);
|
||||
void cancelUpdateBatchInputTimer(@NonNull PointerTracker tracker);
|
||||
|
||||
/**
|
||||
* Cancel all timers of firing updating batch input.
|
||||
|
@ -103,20 +103,20 @@ public interface TimerProxy {
|
|||
|
||||
class Adapter implements TimerProxy {
|
||||
@Override
|
||||
public void startTypingStateTimer(@Nonnull Key typedKey) {}
|
||||
public void startTypingStateTimer(@NonNull Key typedKey) {}
|
||||
@Override
|
||||
public boolean isTypingState() { return false; }
|
||||
@Override
|
||||
public void startKeyRepeatTimerOf(@Nonnull PointerTracker tracker, int repeatCount,
|
||||
public void startKeyRepeatTimerOf(@NonNull PointerTracker tracker, int repeatCount,
|
||||
int delay) {}
|
||||
@Override
|
||||
public void startLongPressTimerOf(@Nonnull PointerTracker tracker, int delay) {}
|
||||
public void startLongPressTimerOf(@NonNull PointerTracker tracker, int delay) {}
|
||||
@Override
|
||||
public void cancelLongPressTimersOf(@Nonnull PointerTracker tracker) {}
|
||||
public void cancelLongPressTimersOf(@NonNull PointerTracker tracker) {}
|
||||
@Override
|
||||
public void cancelLongPressShiftKeyTimer() {}
|
||||
@Override
|
||||
public void cancelKeyTimersOf(@Nonnull PointerTracker tracker) {}
|
||||
public void cancelKeyTimersOf(@NonNull PointerTracker tracker) {}
|
||||
@Override
|
||||
public void startDoubleTapShiftKeyTimer() {}
|
||||
@Override
|
||||
|
@ -124,9 +124,9 @@ public interface TimerProxy {
|
|||
@Override
|
||||
public boolean isInDoubleTapShiftKeyTimeout() { return false; }
|
||||
@Override
|
||||
public void startUpdateBatchInputTimer(@Nonnull PointerTracker tracker) {}
|
||||
public void startUpdateBatchInputTimer(@NonNull PointerTracker tracker) {}
|
||||
@Override
|
||||
public void cancelUpdateBatchInputTimer(@Nonnull PointerTracker tracker) {}
|
||||
public void cancelUpdateBatchInputTimer(@NonNull PointerTracker tracker) {}
|
||||
@Override
|
||||
public void cancelAllUpdateBatchInputTimers() {}
|
||||
}
|
||||
|
|
|
@ -16,18 +16,18 @@
|
|||
|
||||
package org.dslul.openboard.inputmethod.keyboard.internal;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
|
||||
import org.dslul.openboard.inputmethod.keyboard.Key;
|
||||
|
||||
import java.util.HashMap;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
public abstract class UniqueKeysCache {
|
||||
public abstract void setEnabled(boolean enabled);
|
||||
public abstract void clear();
|
||||
public abstract @Nonnull Key getUniqueKey(@Nonnull Key key);
|
||||
public abstract @NonNull Key getUniqueKey(@NonNull Key key);
|
||||
|
||||
@Nonnull
|
||||
@NonNull
|
||||
public static final UniqueKeysCache NO_CACHE = new UniqueKeysCache() {
|
||||
@Override
|
||||
public void setEnabled(boolean enabled) {}
|
||||
|
@ -39,7 +39,7 @@ public abstract class UniqueKeysCache {
|
|||
public Key getUniqueKey(Key key) { return key; }
|
||||
};
|
||||
|
||||
@Nonnull
|
||||
@NonNull
|
||||
public static UniqueKeysCache newInstance() {
|
||||
return new UniqueKeysCacheImpl();
|
||||
}
|
||||
|
|
|
@ -23,6 +23,8 @@ import android.provider.ContactsContract;
|
|||
import android.provider.ContactsContract.Contacts;
|
||||
import android.util.Log;
|
||||
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
import com.android.inputmethod.latin.BinaryDictionary;
|
||||
|
||||
import org.dslul.openboard.inputmethod.annotations.ExternallyReferenced;
|
||||
|
@ -34,8 +36,6 @@ import java.io.File;
|
|||
import java.util.ArrayList;
|
||||
import java.util.Locale;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
public class ContactsBinaryDictionary extends ExpandableBinaryDictionary
|
||||
implements ContactsChangedListener {
|
||||
private static final String TAG = ContactsBinaryDictionary.class.getSimpleName();
|
||||
|
|
|
@ -19,6 +19,9 @@ package org.dslul.openboard.inputmethod.latin;
|
|||
import android.content.Context;
|
||||
import android.util.LruCache;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
import org.dslul.openboard.inputmethod.annotations.UsedForTesting;
|
||||
import org.dslul.openboard.inputmethod.keyboard.Keyboard;
|
||||
import org.dslul.openboard.inputmethod.latin.common.ComposedData;
|
||||
|
@ -33,9 +36,6 @@ import java.util.Locale;
|
|||
import java.util.Map;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
/**
|
||||
* Interface that facilitates interaction with different kinds of dictionaries. Provides APIs to
|
||||
* instantiate and select the correct dictionaries (based on language or account), update entries
|
||||
|
@ -154,16 +154,16 @@ public interface DictionaryFacilitator {
|
|||
throws InterruptedException;
|
||||
|
||||
void addToUserHistory(final String suggestion, final boolean wasAutoCapitalized,
|
||||
@Nonnull final NgramContext ngramContext, final long timeStampInSeconds,
|
||||
@NonNull final NgramContext ngramContext, final long timeStampInSeconds,
|
||||
final boolean blockPotentiallyOffensive);
|
||||
|
||||
void unlearnFromUserHistory(final String word,
|
||||
@Nonnull final NgramContext ngramContext, final long timeStampInSeconds,
|
||||
@NonNull final NgramContext ngramContext, final long timeStampInSeconds,
|
||||
final int eventType);
|
||||
|
||||
// TODO: Revise the way to fusion suggestion results.
|
||||
@Nonnull SuggestionResults getSuggestionResults(final ComposedData composedData,
|
||||
final NgramContext ngramContext, @Nonnull final Keyboard keyboard,
|
||||
@NonNull SuggestionResults getSuggestionResults(final ComposedData composedData,
|
||||
final NgramContext ngramContext, @NonNull final Keyboard keyboard,
|
||||
final SettingsValuesForSuggestion settingsValuesForSuggestion, final int sessionId,
|
||||
final int inputStyle);
|
||||
|
||||
|
@ -177,5 +177,5 @@ public interface DictionaryFacilitator {
|
|||
|
||||
void dumpDictionaryForDebug(final String dictName);
|
||||
|
||||
@Nonnull List<DictionaryStats> getDictionaryStats(final Context context);
|
||||
@NonNull List<DictionaryStats> getDictionaryStats(final Context context);
|
||||
}
|
||||
|
|
|
@ -23,6 +23,9 @@ import android.text.TextUtils;
|
|||
import android.util.Log;
|
||||
import android.util.LruCache;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
import org.dslul.openboard.inputmethod.annotations.UsedForTesting;
|
||||
import org.dslul.openboard.inputmethod.keyboard.Keyboard;
|
||||
import org.dslul.openboard.inputmethod.latin.NgramContext.WordInfo;
|
||||
|
@ -56,9 +59,6 @@ import java.util.concurrent.ConcurrentHashMap;
|
|||
import java.util.concurrent.CountDownLatch;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
/**
|
||||
* Facilitates interaction with different kinds of dictionaries. Provides APIs
|
||||
* to instantiate and select the correct dictionaries (based on language or account),
|
||||
|
@ -614,7 +614,7 @@ public class DictionaryFacilitatorImpl implements DictionaryFacilitator {
|
|||
}
|
||||
|
||||
public void addToUserHistory(final String suggestion, final boolean wasAutoCapitalized,
|
||||
@Nonnull final NgramContext ngramContext, final long timeStampInSeconds,
|
||||
@NonNull final NgramContext ngramContext, final long timeStampInSeconds,
|
||||
final boolean blockPotentiallyOffensive) {
|
||||
// Update the spelling cache before learning. Words that are not yet added to user history
|
||||
// and appear in no other language model are not considered valid.
|
||||
|
@ -713,8 +713,8 @@ public class DictionaryFacilitatorImpl implements DictionaryFacilitator {
|
|||
}
|
||||
|
||||
private void putWordIntoValidSpellingWordCache(
|
||||
@Nonnull final String caller,
|
||||
@Nonnull final String originalWord) {
|
||||
@NonNull final String caller,
|
||||
@NonNull final String originalWord) {
|
||||
if (mValidSpellingWordWriteCache == null) {
|
||||
return;
|
||||
}
|
||||
|
@ -811,7 +811,7 @@ public class DictionaryFacilitatorImpl implements DictionaryFacilitator {
|
|||
|
||||
@Override
|
||||
public void unlearnFromUserHistory(final String word,
|
||||
@Nonnull final NgramContext ngramContext, final long timeStampInSeconds,
|
||||
@NonNull final NgramContext ngramContext, final long timeStampInSeconds,
|
||||
final int eventType) {
|
||||
// TODO: Decide whether or not to remove the word on EVENT_BACKSPACE.
|
||||
if (eventType != Constants.EVENT_BACKSPACE) {
|
||||
|
@ -825,8 +825,8 @@ public class DictionaryFacilitatorImpl implements DictionaryFacilitator {
|
|||
|
||||
// TODO: Revise the way to fusion suggestion results.
|
||||
@Override
|
||||
@Nonnull public SuggestionResults getSuggestionResults(ComposedData composedData,
|
||||
NgramContext ngramContext, @Nonnull final Keyboard keyboard,
|
||||
@NonNull public SuggestionResults getSuggestionResults(ComposedData composedData,
|
||||
NgramContext ngramContext, @NonNull final Keyboard keyboard,
|
||||
SettingsValuesForSuggestion settingsValuesForSuggestion, int sessionId,
|
||||
int inputStyle) {
|
||||
long proximityInfoHandle = keyboard.getProximityInfo().getNativeProximityInfo();
|
||||
|
@ -1080,7 +1080,7 @@ public class DictionaryFacilitatorImpl implements DictionaryFacilitator {
|
|||
|
||||
@Override
|
||||
// this is unused, so leave it for now
|
||||
@Nonnull public List<DictionaryStats> getDictionaryStats(final Context context) {
|
||||
@NonNull public List<DictionaryStats> getDictionaryStats(final Context context) {
|
||||
final ArrayList<DictionaryStats> statsOfEnabledSubDicts = new ArrayList<>();
|
||||
for (final String dictType : DYNAMIC_DICTIONARY_TYPES) {
|
||||
final ExpandableBinaryDictionary dictionary = mDictionaryGroups.get(0).getSubDict(dictType);
|
||||
|
|
|
@ -16,13 +16,13 @@
|
|||
|
||||
package org.dslul.openboard.inputmethod.latin;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
import java.io.File;
|
||||
import java.math.BigDecimal;
|
||||
import java.util.Locale;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
public class DictionaryStats {
|
||||
public static final int NOT_AN_ENTRY_COUNT = -1;
|
||||
|
||||
|
@ -34,8 +34,8 @@ public class DictionaryStats {
|
|||
public final int mWordCount;
|
||||
|
||||
public DictionaryStats(
|
||||
@Nonnull final Locale locale,
|
||||
@Nonnull final String dictType,
|
||||
@NonNull final Locale locale,
|
||||
@NonNull final String dictType,
|
||||
@Nullable final String dictFileName,
|
||||
@Nullable final File dictFile,
|
||||
final int contentVersion) {
|
||||
|
@ -48,8 +48,8 @@ public class DictionaryStats {
|
|||
}
|
||||
|
||||
public DictionaryStats(
|
||||
@Nonnull final Locale locale,
|
||||
@Nonnull final String dictType,
|
||||
@NonNull final Locale locale,
|
||||
@NonNull final String dictType,
|
||||
final int wordCount) {
|
||||
mLocale = locale;
|
||||
mDictType = dictType;
|
||||
|
|
|
@ -21,6 +21,8 @@ import android.util.Log;
|
|||
import android.util.Pair;
|
||||
import android.view.KeyEvent;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
|
||||
import org.dslul.openboard.inputmethod.keyboard.KeyboardSwitcher;
|
||||
import org.dslul.openboard.inputmethod.latin.settings.Settings;
|
||||
|
||||
|
@ -28,8 +30,6 @@ import java.util.ArrayList;
|
|||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
/**
|
||||
* A class for detecting Emoji-Alt physical key.
|
||||
*/
|
||||
|
@ -54,7 +54,7 @@ final class EmojiAltPhysicalKeyDetector {
|
|||
mCanFire = false;
|
||||
}
|
||||
|
||||
public void onKeyDown(@Nonnull final KeyEvent keyEvent) {
|
||||
public void onKeyDown(@NonNull final KeyEvent keyEvent) {
|
||||
if (DEBUG) {
|
||||
Log.d(TAG, "EmojiHotKeys.onKeyDown() - " + mName + " - considering " + keyEvent);
|
||||
}
|
||||
|
@ -75,7 +75,7 @@ final class EmojiAltPhysicalKeyDetector {
|
|||
}
|
||||
}
|
||||
|
||||
public void onKeyUp(@Nonnull final KeyEvent keyEvent) {
|
||||
public void onKeyUp(@NonNull final KeyEvent keyEvent) {
|
||||
if (DEBUG) {
|
||||
Log.d(TAG, "EmojiHotKeys.onKeyUp() - " + mName + " - considering " + keyEvent);
|
||||
}
|
||||
|
@ -119,7 +119,7 @@ final class EmojiAltPhysicalKeyDetector {
|
|||
protected abstract void action();
|
||||
}
|
||||
|
||||
public EmojiAltPhysicalKeyDetector(@Nonnull final Resources resources) {
|
||||
public EmojiAltPhysicalKeyDetector(@NonNull final Resources resources) {
|
||||
mHotKeysList = new ArrayList<EmojiHotKeys>();
|
||||
|
||||
final HotKeySet emojiSwitchSet = parseHotKeys(
|
||||
|
@ -145,7 +145,7 @@ final class EmojiAltPhysicalKeyDetector {
|
|||
mHotKeysList.add(symbolsHotKeys);
|
||||
}
|
||||
|
||||
public void onKeyDown(@Nonnull final KeyEvent keyEvent) {
|
||||
public void onKeyDown(@NonNull final KeyEvent keyEvent) {
|
||||
if (DEBUG) {
|
||||
Log.d(TAG, "onKeyDown(): " + keyEvent);
|
||||
}
|
||||
|
@ -157,7 +157,7 @@ final class EmojiAltPhysicalKeyDetector {
|
|||
}
|
||||
}
|
||||
|
||||
public void onKeyUp(@Nonnull final KeyEvent keyEvent) {
|
||||
public void onKeyUp(@NonNull final KeyEvent keyEvent) {
|
||||
if (DEBUG) {
|
||||
Log.d(TAG, "onKeyUp(): " + keyEvent);
|
||||
}
|
||||
|
@ -169,7 +169,7 @@ final class EmojiAltPhysicalKeyDetector {
|
|||
}
|
||||
}
|
||||
|
||||
private static boolean shouldProcessEvent(@Nonnull final KeyEvent keyEvent) {
|
||||
private static boolean shouldProcessEvent(@NonNull final KeyEvent keyEvent) {
|
||||
if (!Settings.getInstance().getCurrent().mEnableEmojiAltPhysicalKey) {
|
||||
// The feature is disabled.
|
||||
if (DEBUG) {
|
||||
|
@ -182,7 +182,7 @@ final class EmojiAltPhysicalKeyDetector {
|
|||
}
|
||||
|
||||
private static HotKeySet parseHotKeys(
|
||||
@Nonnull final Resources resources, final int resourceId) {
|
||||
@NonNull final Resources resources, final int resourceId) {
|
||||
final HotKeySet keySet = new HotKeySet();
|
||||
final String name = resources.getResourceEntryName(resourceId);
|
||||
final String[] values = resources.getStringArray(resourceId);
|
||||
|
|
|
@ -19,6 +19,9 @@ package org.dslul.openboard.inputmethod.latin;
|
|||
import android.content.Context;
|
||||
import android.util.Log;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
import com.android.inputmethod.latin.BinaryDictionary;
|
||||
|
||||
import org.dslul.openboard.inputmethod.annotations.UsedForTesting;
|
||||
|
@ -47,9 +50,6 @@ import java.util.concurrent.atomic.AtomicBoolean;
|
|||
import java.util.concurrent.locks.Lock;
|
||||
import java.util.concurrent.locks.ReentrantReadWriteLock;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
/**
|
||||
* Abstract base class for an expandable dictionary that can be created and updated dynamically
|
||||
* during runtime. When updated it automatically generates a new binary dictionary to handle future
|
||||
|
@ -278,7 +278,7 @@ abstract public class ExpandableBinaryDictionary extends Dictionary {
|
|||
}
|
||||
}
|
||||
|
||||
private void updateDictionaryWithWriteLock(@Nonnull final Runnable updateTask) {
|
||||
private void updateDictionaryWithWriteLock(@NonNull final Runnable updateTask) {
|
||||
reloadDictionaryIfRequired();
|
||||
final Runnable task = new Runnable() {
|
||||
@Override
|
||||
|
@ -342,7 +342,7 @@ abstract public class ExpandableBinaryDictionary extends Dictionary {
|
|||
/**
|
||||
* Adds n-gram information of a word to the dictionary. May overwrite an existing entry.
|
||||
*/
|
||||
public void addNgramEntry(@Nonnull final NgramContext ngramContext, final String word,
|
||||
public void addNgramEntry(@NonNull final NgramContext ngramContext, final String word,
|
||||
final int frequency, final int timestamp) {
|
||||
reloadDictionaryIfRequired();
|
||||
asyncExecuteTaskWithWriteLock(new Runnable() {
|
||||
|
@ -357,7 +357,7 @@ abstract public class ExpandableBinaryDictionary extends Dictionary {
|
|||
});
|
||||
}
|
||||
|
||||
protected void addNgramEntryLocked(@Nonnull final NgramContext ngramContext, final String word,
|
||||
protected void addNgramEntryLocked(@NonNull final NgramContext ngramContext, final String word,
|
||||
final int frequency, final int timestamp) {
|
||||
if (!mBinaryDictionary.addNgramEntry(ngramContext, word, frequency, timestamp)) {
|
||||
if (DEBUG) {
|
||||
|
@ -370,7 +370,7 @@ abstract public class ExpandableBinaryDictionary extends Dictionary {
|
|||
/**
|
||||
* Update dictionary for the word with the ngramContext.
|
||||
*/
|
||||
public void updateEntriesForWord(@Nonnull final NgramContext ngramContext,
|
||||
public void updateEntriesForWord(@NonNull final NgramContext ngramContext,
|
||||
final String word, final boolean isValidWord, final int count, final int timestamp) {
|
||||
updateDictionaryWithWriteLock(new Runnable() {
|
||||
@Override
|
||||
|
@ -407,7 +407,7 @@ abstract public class ExpandableBinaryDictionary extends Dictionary {
|
|||
*/
|
||||
@UsedForTesting
|
||||
public void updateEntriesForInputEvents(
|
||||
@Nonnull final ArrayList<WordInputEventForPersonalization> inputEvents,
|
||||
@NonNull final ArrayList<WordInputEventForPersonalization> inputEvents,
|
||||
final UpdateEntriesForInputEventsCallback callback) {
|
||||
reloadDictionaryIfRequired();
|
||||
asyncExecuteTaskWithWriteLock(new Runnable() {
|
||||
|
|
|
@ -96,14 +96,12 @@ import java.util.List;
|
|||
import java.util.Locale;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import static org.dslul.openboard.inputmethod.latin.common.Constants.ImeOption.FORCE_ASCII;
|
||||
import static org.dslul.openboard.inputmethod.latin.common.Constants.ImeOption.NO_MICROPHONE;
|
||||
import static org.dslul.openboard.inputmethod.latin.common.Constants.ImeOption.NO_MICROPHONE_COMPAT;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
/**
|
||||
* Input method implementation for Qwerty'ish keyboard.
|
||||
|
@ -166,7 +164,8 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
|
|||
private boolean mIsExecutingStartShowingInputView;
|
||||
|
||||
// Used for re-initialize keyboard layout after onConfigurationChange.
|
||||
@Nullable private Context mDisplayContext;
|
||||
@Nullable
|
||||
private Context mDisplayContext;
|
||||
|
||||
// Object for reacting to adding/removing a dictionary pack.
|
||||
private final BroadcastReceiver mDictionaryPackInstallReceiver =
|
||||
|
@ -248,7 +247,7 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
|
|||
private int mDelayInMillisecondsToUpdateSuggestions;
|
||||
private int mDelayInMillisecondsToUpdateShiftState;
|
||||
|
||||
public UIHandler(@Nonnull final LatinIME ownerInstance) {
|
||||
public UIHandler(@NonNull final LatinIME ownerInstance) {
|
||||
super(ownerInstance);
|
||||
}
|
||||
|
||||
|
@ -1540,7 +1539,7 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
|
|||
|
||||
// This method is public for testability of LatinIME, but also in the future it should
|
||||
// completely replace #onCodeInput.
|
||||
public void onEvent(@Nonnull final Event event) {
|
||||
public void onEvent(@NonNull final Event event) {
|
||||
if (Constants.CODE_SHORTCUT == event.getMKeyCode()) {
|
||||
mRichImm.switchToShortcutIme(this);
|
||||
}
|
||||
|
@ -1555,7 +1554,7 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
|
|||
// A helper method to split the code point and the key code. Ultimately, they should not be
|
||||
// squashed into the same variable, and this method should be removed.
|
||||
// public for testing, as we don't want to copy the same logic into test code
|
||||
@Nonnull
|
||||
@NonNull
|
||||
public static Event createSoftwareKeypressEvent(final int keyCodeOrCodePoint, final int keyX,
|
||||
final int keyY, final boolean isKeyRepeat) {
|
||||
final int keyCode;
|
||||
|
@ -1621,7 +1620,7 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
|
|||
}
|
||||
|
||||
// This method must run on the UI Thread.
|
||||
void showGesturePreviewAndSuggestionStrip(@Nonnull final SuggestedWords suggestedWords,
|
||||
void showGesturePreviewAndSuggestionStrip(@NonNull final SuggestedWords suggestedWords,
|
||||
final boolean dismissGestureFloatingPreviewText) {
|
||||
showSuggestionStrip(suggestedWords);
|
||||
final MainKeyboardView mainKeyboardView = mKeyboardSwitcher.getMainKeyboardView();
|
||||
|
|
|
@ -18,6 +18,8 @@ package org.dslul.openboard.inputmethod.latin;
|
|||
|
||||
import android.text.TextUtils;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
|
||||
import org.dslul.openboard.inputmethod.annotations.UsedForTesting;
|
||||
import org.dslul.openboard.inputmethod.latin.common.StringUtils;
|
||||
import org.dslul.openboard.inputmethod.latin.define.DecoderSpecificConstants;
|
||||
|
@ -25,17 +27,15 @@ import org.dslul.openboard.inputmethod.latin.define.DecoderSpecificConstants;
|
|||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
/**
|
||||
* Class to represent information of previous words. This class is used to add n-gram entries
|
||||
* into binary dictionaries, to get predictions, and to get suggestions.
|
||||
*/
|
||||
public class NgramContext {
|
||||
@Nonnull
|
||||
@NonNull
|
||||
public static final NgramContext EMPTY_PREV_WORDS_INFO =
|
||||
new NgramContext(WordInfo.EMPTY_WORD_INFO);
|
||||
@Nonnull
|
||||
@NonNull
|
||||
public static final NgramContext BEGINNING_OF_SENTENCE =
|
||||
new NgramContext(WordInfo.BEGINNING_OF_SENTENCE_WORD_INFO);
|
||||
|
||||
|
@ -51,9 +51,9 @@ public class NgramContext {
|
|||
* Word information used to represent previous words information.
|
||||
*/
|
||||
public static class WordInfo {
|
||||
@Nonnull
|
||||
@NonNull
|
||||
public static final WordInfo EMPTY_WORD_INFO = new WordInfo(null);
|
||||
@Nonnull
|
||||
@NonNull
|
||||
public static final WordInfo BEGINNING_OF_SENTENCE_WORD_INFO = new WordInfo();
|
||||
|
||||
// This is an empty char sequence when mIsBeginningOfSentence is true.
|
||||
|
@ -122,7 +122,7 @@ public class NgramContext {
|
|||
/**
|
||||
* Create next prevWordsInfo using current prevWordsInfo.
|
||||
*/
|
||||
@Nonnull
|
||||
@NonNull
|
||||
public NgramContext getNextNgramContext(final WordInfo wordInfo) {
|
||||
final int nextPrevWordCount = Math.min(mMaxPrevWordCount, mPrevWordsCount + 1);
|
||||
final WordInfo[] prevWordsInfo = new WordInfo[nextPrevWordCount];
|
||||
|
|
|
@ -25,6 +25,9 @@ import android.provider.UserDictionary;
|
|||
import android.text.TextUtils;
|
||||
import android.util.Log;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
import org.dslul.openboard.inputmethod.annotations.UsedForTesting;
|
||||
import org.dslul.openboard.inputmethod.latin.common.CollectionUtils;
|
||||
import org.dslul.openboard.inputmethod.latin.common.LocaleUtils;
|
||||
|
@ -44,9 +47,6 @@ import java.util.concurrent.ScheduledFuture;
|
|||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.concurrent.atomic.AtomicBoolean;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
/**
|
||||
* This class provides the ability to look into the system-wide "Personal dictionary". It loads the
|
||||
* data once when created and reloads it when notified of changes to {@link UserDictionary}
|
||||
|
@ -106,11 +106,11 @@ public class PersonalDictionaryLookup implements Closeable {
|
|||
|
||||
private final Set<PersonalDictionaryListener> mListeners = new HashSet<>();
|
||||
|
||||
public void addListener(@Nonnull final PersonalDictionaryListener listener) {
|
||||
public void addListener(@NonNull final PersonalDictionaryListener listener) {
|
||||
mListeners.add(listener);
|
||||
}
|
||||
|
||||
public void removeListener(@Nonnull final PersonalDictionaryListener listener) {
|
||||
public void removeListener(@NonNull final PersonalDictionaryListener listener) {
|
||||
mListeners.remove(listener);
|
||||
}
|
||||
|
||||
|
@ -219,8 +219,8 @@ public class PersonalDictionaryLookup implements Closeable {
|
|||
* @param context the context from which to obtain content resolver
|
||||
*/
|
||||
public PersonalDictionaryLookup(
|
||||
@Nonnull final Context context,
|
||||
@Nonnull final String serviceName) {
|
||||
@NonNull final Context context,
|
||||
@NonNull final String serviceName) {
|
||||
mTag = serviceName + ".Personal";
|
||||
|
||||
Log.i(mTag, "create()");
|
||||
|
@ -315,7 +315,7 @@ public class PersonalDictionaryLookup implements Closeable {
|
|||
* @param inputLocale the locale to restrict for
|
||||
* @return set of words that apply to the given locale.
|
||||
*/
|
||||
public Set<String> getWordsForLocale(@Nonnull final Locale inputLocale) {
|
||||
public Set<String> getWordsForLocale(@NonNull final Locale inputLocale) {
|
||||
final HashMap<String, HashMap<Locale, String>> dictWords = mDictWords;
|
||||
if (CollectionUtils.isNullOrEmpty(dictWords)) {
|
||||
return Collections.emptySet();
|
||||
|
@ -349,7 +349,7 @@ public class PersonalDictionaryLookup implements Closeable {
|
|||
* @param inputLocale the locale to restrict for
|
||||
* @return set of shortcuts that apply to the given locale.
|
||||
*/
|
||||
public Set<String> getShortcutsForLocale(@Nonnull final Locale inputLocale) {
|
||||
public Set<String> getShortcutsForLocale(@NonNull final Locale inputLocale) {
|
||||
final Map<Locale, HashMap<String, String>> shortcutsPerLocale = mShortcutsPerLocale;
|
||||
if (CollectionUtils.isNullOrEmpty(shortcutsPerLocale)) {
|
||||
return Collections.emptySet();
|
||||
|
@ -391,7 +391,7 @@ public class PersonalDictionaryLookup implements Closeable {
|
|||
* @param inputLocale the locale in which to match the word
|
||||
* @return true iff the word has been matched for this locale in the dictionary.
|
||||
*/
|
||||
public boolean isValidWord(@Nonnull final String word, @Nonnull final Locale inputLocale) {
|
||||
public boolean isValidWord(@NonNull final String word, @NonNull final Locale inputLocale) {
|
||||
if (!isLoaded()) {
|
||||
// This is a corner case in the event the initial load of the dictionary has not
|
||||
// completed. In that case, we assume the word is not a valid word in the dictionary.
|
||||
|
@ -455,7 +455,7 @@ public class PersonalDictionaryLookup implements Closeable {
|
|||
* @return expanded shortcut iff the word is a shortcut in the dictionary.
|
||||
*/
|
||||
@Nullable public String expandShortcut(
|
||||
@Nonnull final String shortcut, @Nonnull final Locale inputLocale) {
|
||||
@NonNull final String shortcut, @NonNull final Locale inputLocale) {
|
||||
if (DebugFlags.DEBUG_ENABLED) {
|
||||
Log.d(mTag, "expandShortcut() : Shortcut [" + shortcut + "] for [" + inputLocale + "]");
|
||||
}
|
||||
|
@ -507,8 +507,8 @@ public class PersonalDictionaryLookup implements Closeable {
|
|||
|
||||
@Nullable private String expandShortcut(
|
||||
@Nullable final HashMap<Locale, HashMap<String, String>> shortcutsPerLocale,
|
||||
@Nonnull final String shortcut,
|
||||
@Nonnull final Locale locale) {
|
||||
@NonNull final String shortcut,
|
||||
@NonNull final Locale locale) {
|
||||
if (CollectionUtils.isNullOrEmpty(shortcutsPerLocale)) {
|
||||
return null;
|
||||
}
|
||||
|
|
|
@ -16,6 +16,8 @@
|
|||
|
||||
package org.dslul.openboard.inputmethod.latin;
|
||||
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
import org.dslul.openboard.inputmethod.keyboard.internal.KeySpecParser;
|
||||
import org.dslul.openboard.inputmethod.latin.common.Constants;
|
||||
import org.dslul.openboard.inputmethod.latin.common.StringUtils;
|
||||
|
@ -23,8 +25,6 @@ import org.dslul.openboard.inputmethod.latin.common.StringUtils;
|
|||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
/**
|
||||
* The extended {@link SuggestedWords} class to represent punctuation suggestions.
|
||||
*
|
||||
|
|
|
@ -31,6 +31,9 @@ import android.view.inputmethod.ExtractedTextRequest;
|
|||
import android.view.inputmethod.InputConnection;
|
||||
import android.view.inputmethod.InputMethodManager;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
import org.dslul.openboard.inputmethod.compat.InputConnectionCompatUtils;
|
||||
import org.dslul.openboard.inputmethod.latin.common.Constants;
|
||||
import org.dslul.openboard.inputmethod.latin.common.StringUtils;
|
||||
|
@ -47,9 +50,6 @@ import org.dslul.openboard.inputmethod.latin.utils.TextRange;
|
|||
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
/**
|
||||
* Enrichment class for InputConnection to simplify interaction and add functionality.
|
||||
*
|
||||
|
@ -652,7 +652,7 @@ public final class RichInputConnection implements PrivateCommandPerformer {
|
|||
}
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
@Nonnull
|
||||
@NonNull
|
||||
public NgramContext getNgramContextFromNthPreviousWord(
|
||||
final SpacingAndPunctuations spacingAndPunctuations, final int n) {
|
||||
mIC = mParent.getCurrentInputConnection();
|
||||
|
|
|
@ -41,11 +41,11 @@ import java.util.Locale;
|
|||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import static org.dslul.openboard.inputmethod.latin.common.Constants.Subtype.KEYBOARD_MODE;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
/**
|
||||
* Enrichment class for InputMethodManager to simplify interaction and add functionality.
|
||||
*/
|
||||
|
@ -229,7 +229,7 @@ public class RichInputMethodManager {
|
|||
return INDEX_NOT_FOUND;
|
||||
}
|
||||
|
||||
public void onSubtypeChanged(@Nonnull final InputMethodSubtype newSubtype) {
|
||||
public void onSubtypeChanged(@NonNull final InputMethodSubtype newSubtype) {
|
||||
updateCurrentSubtype(newSubtype);
|
||||
updateShortcutIme();
|
||||
if (DEBUG) {
|
||||
|
@ -240,11 +240,11 @@ public class RichInputMethodManager {
|
|||
private static RichInputMethodSubtype sForcedSubtypeForTesting = null;
|
||||
|
||||
@UsedForTesting
|
||||
static void forceSubtype(@Nonnull final InputMethodSubtype subtype) {
|
||||
static void forceSubtype(@NonNull final InputMethodSubtype subtype) {
|
||||
sForcedSubtypeForTesting = RichInputMethodSubtype.getRichInputMethodSubtype(subtype);
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@NonNull
|
||||
public Locale getCurrentSubtypeLocale() {
|
||||
if (null != sForcedSubtypeForTesting) {
|
||||
return sForcedSubtypeForTesting.getLocale();
|
||||
|
@ -252,7 +252,7 @@ public class RichInputMethodManager {
|
|||
return getCurrentSubtype().getLocale();
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@NonNull
|
||||
public RichInputMethodSubtype getCurrentSubtype() {
|
||||
if (null != sForcedSubtypeForTesting) {
|
||||
return sForcedSubtypeForTesting;
|
||||
|
|
|
@ -28,11 +28,11 @@ import org.dslul.openboard.inputmethod.latin.utils.SubtypeLocaleUtils;
|
|||
import java.util.HashMap;
|
||||
import java.util.Locale;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import static org.dslul.openboard.inputmethod.latin.common.Constants.Subtype.KEYBOARD_MODE;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
/**
|
||||
* Enrichment class for InputMethodSubtype to enable concurrent multi-lingual input.
|
||||
*
|
||||
|
@ -53,14 +53,14 @@ public class RichInputMethodSubtype {
|
|||
return map;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@NonNull
|
||||
private final InputMethodSubtype mSubtype;
|
||||
@Nonnull
|
||||
@NonNull
|
||||
private final Locale mLocale;
|
||||
@Nonnull
|
||||
@NonNull
|
||||
private final Locale mOriginalLocale;
|
||||
|
||||
public RichInputMethodSubtype(@Nonnull final InputMethodSubtype subtype) {
|
||||
public RichInputMethodSubtype(@NonNull final InputMethodSubtype subtype) {
|
||||
mSubtype = subtype;
|
||||
mOriginalLocale = InputMethodSubtypeCompatUtils.getLocaleObject(mSubtype);
|
||||
final Locale mappedLocale = sLocaleMap.get(mOriginalLocale);
|
||||
|
@ -69,7 +69,7 @@ public class RichInputMethodSubtype {
|
|||
|
||||
// Extra values are determined by the primary subtype. This is probably right, but
|
||||
// we may have to revisit this later.
|
||||
public String getExtraValueOf(@Nonnull final String key) {
|
||||
public String getExtraValueOf(@NonNull final String key) {
|
||||
return mSubtype.getExtraValueOf(key);
|
||||
}
|
||||
|
||||
|
@ -104,7 +104,7 @@ public class RichInputMethodSubtype {
|
|||
// en_US azerty T English English (US)
|
||||
// zz azerty T AZERTY AZERTY
|
||||
// Get the RichInputMethodSubtype's full display name in its locale.
|
||||
@Nonnull
|
||||
@NonNull
|
||||
public String getFullDisplayName() {
|
||||
if (isNoLanguage()) {
|
||||
return SubtypeLocaleUtils.getKeyboardLayoutSetDisplayName(mSubtype);
|
||||
|
@ -113,7 +113,7 @@ public class RichInputMethodSubtype {
|
|||
}
|
||||
|
||||
// Get the RichInputMethodSubtype's middle display name in its locale.
|
||||
@Nonnull
|
||||
@NonNull
|
||||
public String getMiddleDisplayName() {
|
||||
if (isNoLanguage()) {
|
||||
return SubtypeLocaleUtils.getKeyboardLayoutSetDisplayName(mSubtype);
|
||||
|
@ -140,12 +140,12 @@ public class RichInputMethodSubtype {
|
|||
return "Multi-lingual subtype: " + mSubtype + ", " + mLocale;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@NonNull
|
||||
public Locale getLocale() {
|
||||
return mLocale;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@NonNull
|
||||
public Locale getOriginalLocale() {
|
||||
return mOriginalLocale;
|
||||
}
|
||||
|
@ -156,10 +156,10 @@ public class RichInputMethodSubtype {
|
|||
}
|
||||
|
||||
// TODO: remove this method
|
||||
@Nonnull
|
||||
@NonNull
|
||||
public InputMethodSubtype getRawSubtype() { return mSubtype; }
|
||||
|
||||
@Nonnull
|
||||
@NonNull
|
||||
public String getKeyboardLayoutSetName() {
|
||||
return SubtypeLocaleUtils.getKeyboardLayoutSetName(mSubtype);
|
||||
}
|
||||
|
@ -180,7 +180,7 @@ public class RichInputMethodSubtype {
|
|||
+ "," + Constants.Subtype.ExtraValue.ASCII_CAPABLE
|
||||
+ "," + Constants.Subtype.ExtraValue.ENABLED_WHEN_DEFAULT_IS_NOT_ASCII_CAPABLE
|
||||
+ "," + Constants.Subtype.ExtraValue.EMOJI_CAPABLE;
|
||||
@Nonnull
|
||||
@NonNull
|
||||
private static final RichInputMethodSubtype DUMMY_NO_LANGUAGE_SUBTYPE =
|
||||
new RichInputMethodSubtype(new InputMethodSubtype(
|
||||
R.string.subtype_no_language_qwerty, R.drawable.ic_ime_switcher_dark,
|
||||
|
@ -194,7 +194,7 @@ public class RichInputMethodSubtype {
|
|||
private static final String EXTRA_VALUE_OF_DUMMY_EMOJI_SUBTYPE =
|
||||
"KeyboardLayoutSet=" + SubtypeLocaleUtils.EMOJI
|
||||
+ "," + Constants.Subtype.ExtraValue.EMOJI_CAPABLE;
|
||||
@Nonnull
|
||||
@NonNull
|
||||
private static final RichInputMethodSubtype DUMMY_EMOJI_SUBTYPE = new RichInputMethodSubtype(
|
||||
new InputMethodSubtype(
|
||||
R.string.subtype_emoji, R.drawable.ic_ime_switcher_dark,
|
||||
|
@ -205,7 +205,7 @@ public class RichInputMethodSubtype {
|
|||
private static RichInputMethodSubtype sNoLanguageSubtype;
|
||||
private static RichInputMethodSubtype sEmojiSubtype;
|
||||
|
||||
@Nonnull
|
||||
@NonNull
|
||||
public static RichInputMethodSubtype getNoLanguageSubtype() {
|
||||
RichInputMethodSubtype noLanguageSubtype = sNoLanguageSubtype;
|
||||
if (noLanguageSubtype == null) {
|
||||
|
@ -226,7 +226,7 @@ public class RichInputMethodSubtype {
|
|||
return DUMMY_NO_LANGUAGE_SUBTYPE;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@NonNull
|
||||
public static RichInputMethodSubtype getEmojiSubtype() {
|
||||
RichInputMethodSubtype emojiSubtype = sEmojiSubtype;
|
||||
if (emojiSubtype == null) {
|
||||
|
|
|
@ -36,11 +36,11 @@ import java.util.HashMap;
|
|||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
import static org.dslul.openboard.inputmethod.latin.define.DecoderSpecificConstants.SHOULD_AUTO_CORRECT_USING_NON_WHITE_LISTED_SUGGESTION;
|
||||
import static org.dslul.openboard.inputmethod.latin.define.DecoderSpecificConstants.SHOULD_REMOVE_PREVIOUSLY_REJECTED_SUGGESTION;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
|
||||
/**
|
||||
* This class loads a dictionary and provides a list of suggestions for a given sequence of
|
||||
* characters. This includes corrections and completions.
|
||||
|
@ -140,7 +140,7 @@ public final class Suggest {
|
|||
}
|
||||
|
||||
private static SuggestedWordInfo getWhitelistedWordInfoOrNull(
|
||||
@Nonnull final List<SuggestedWordInfo> suggestions) {
|
||||
@NonNull final List<SuggestedWordInfo> suggestions) {
|
||||
if (suggestions.isEmpty()) {
|
||||
return null;
|
||||
}
|
||||
|
|
|
@ -19,6 +19,9 @@ package org.dslul.openboard.inputmethod.latin;
|
|||
import android.text.TextUtils;
|
||||
import android.view.inputmethod.CompletionInfo;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
import org.dslul.openboard.inputmethod.annotations.UsedForTesting;
|
||||
import org.dslul.openboard.inputmethod.latin.common.StringUtils;
|
||||
import org.dslul.openboard.inputmethod.latin.define.DebugFlags;
|
||||
|
@ -27,9 +30,6 @@ import java.util.ArrayList;
|
|||
import java.util.Arrays;
|
||||
import java.util.HashSet;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
public class SuggestedWords {
|
||||
public static final int INDEX_OF_TYPED_WORD = 0;
|
||||
public static final int INDEX_OF_AUTO_CORRECTION = 1;
|
||||
|
@ -48,7 +48,7 @@ public class SuggestedWords {
|
|||
public static final int MAX_SUGGESTIONS = 18;
|
||||
|
||||
private static final ArrayList<SuggestedWordInfo> EMPTY_WORD_INFO_LIST = new ArrayList<>(0);
|
||||
@Nonnull
|
||||
@NonNull
|
||||
private static final SuggestedWords EMPTY = new SuggestedWords(
|
||||
EMPTY_WORD_INFO_LIST, null /* rawSuggestions */, null /* typedWord */,
|
||||
false /* typedWordValid */, false /* willAutoCorrect */,
|
||||
|
@ -66,12 +66,12 @@ public class SuggestedWords {
|
|||
// INPUT_STYLE_* constants above.
|
||||
public final int mInputStyle;
|
||||
public final int mSequenceNumber; // Sequence number for auto-commit.
|
||||
@Nonnull
|
||||
@NonNull
|
||||
protected final ArrayList<SuggestedWordInfo> mSuggestedWordInfoList;
|
||||
@Nullable
|
||||
public final ArrayList<SuggestedWordInfo> mRawSuggestions;
|
||||
|
||||
public SuggestedWords(@Nonnull final ArrayList<SuggestedWordInfo> suggestedWordInfoList,
|
||||
public SuggestedWords(@NonNull final ArrayList<SuggestedWordInfo> suggestedWordInfoList,
|
||||
@Nullable final ArrayList<SuggestedWordInfo> rawSuggestions,
|
||||
@Nullable final SuggestedWordInfo typedWordInfo,
|
||||
final boolean typedWordValid,
|
||||
|
@ -202,7 +202,7 @@ public class SuggestedWords {
|
|||
return result;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@NonNull
|
||||
public static final SuggestedWords getEmptyInstance() {
|
||||
return SuggestedWords.EMPTY;
|
||||
}
|
||||
|
@ -210,8 +210,8 @@ public class SuggestedWords {
|
|||
// Should get rid of the first one (what the user typed previously) from suggestions
|
||||
// and replace it with what the user currently typed.
|
||||
public static ArrayList<SuggestedWordInfo> getTypedWordAndPreviousSuggestions(
|
||||
@Nonnull final SuggestedWordInfo typedWordInfo,
|
||||
@Nonnull final SuggestedWords previousSuggestions) {
|
||||
@NonNull final SuggestedWordInfo typedWordInfo,
|
||||
@NonNull final SuggestedWords previousSuggestions) {
|
||||
final ArrayList<SuggestedWordInfo> suggestionsList = new ArrayList<>();
|
||||
final HashSet<String> alreadySeen = new HashSet<>();
|
||||
suggestionsList.add(typedWordInfo);
|
||||
|
@ -389,7 +389,7 @@ public class SuggestedWords {
|
|||
*/
|
||||
public static int removeDupsAndTypedWord(
|
||||
@Nullable final String typedWord,
|
||||
@Nonnull final ArrayList<SuggestedWordInfo> candidates) {
|
||||
@NonNull final ArrayList<SuggestedWordInfo> candidates) {
|
||||
if (candidates.isEmpty()) {
|
||||
return -1;
|
||||
}
|
||||
|
@ -406,8 +406,8 @@ public class SuggestedWords {
|
|||
}
|
||||
|
||||
private static int removeSuggestedWordInfoFromList(
|
||||
@Nonnull final String word,
|
||||
@Nonnull final ArrayList<SuggestedWordInfo> candidates,
|
||||
@NonNull final String word,
|
||||
@NonNull final ArrayList<SuggestedWordInfo> candidates,
|
||||
final int startIndexExclusive) {
|
||||
int firstOccurrenceOfWord = -1;
|
||||
for (int i = startIndexExclusive + 1; i < candidates.size(); ++i) {
|
||||
|
|
|
@ -26,6 +26,8 @@ import android.provider.UserDictionary.Words;
|
|||
import android.text.TextUtils;
|
||||
import android.util.Log;
|
||||
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
import com.android.inputmethod.latin.BinaryDictionary;
|
||||
|
||||
import org.dslul.openboard.inputmethod.annotations.ExternallyReferenced;
|
||||
|
@ -35,8 +37,6 @@ import java.io.File;
|
|||
import java.util.Arrays;
|
||||
import java.util.Locale;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
/**
|
||||
* An expandable dictionary that stores the words in the user dictionary provider into a binary
|
||||
* dictionary file to use it from native code.
|
||||
|
|
|
@ -16,6 +16,8 @@
|
|||
|
||||
package org.dslul.openboard.inputmethod.latin;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
|
||||
import org.dslul.openboard.inputmethod.annotations.UsedForTesting;
|
||||
import org.dslul.openboard.inputmethod.event.CombinerChain;
|
||||
import org.dslul.openboard.inputmethod.event.Event;
|
||||
|
@ -31,8 +33,6 @@ import org.dslul.openboard.inputmethod.latin.define.DecoderSpecificConstants;
|
|||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
/**
|
||||
* A place to store the currently composing word with information such as adjacent key codes as well
|
||||
*/
|
||||
|
@ -157,8 +157,8 @@ public final class WordComposer {
|
|||
* @param event the unprocessed event.
|
||||
* @return the processed event. Never null, but may be marked as consumed.
|
||||
*/
|
||||
@Nonnull
|
||||
public Event processEvent(@Nonnull final Event event) {
|
||||
@NonNull
|
||||
public Event processEvent(@NonNull final Event event) {
|
||||
final Event processedEvent = mCombinerChain.processEvent(mEvents, event);
|
||||
// The retained state of the combiner chain may have changed while processing the event,
|
||||
// so we need to update our cache.
|
||||
|
|
|
@ -16,12 +16,12 @@
|
|||
|
||||
package org.dslul.openboard.inputmethod.latin.common;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
|
||||
import org.dslul.openboard.inputmethod.annotations.UsedForTesting;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
// Utility methods related with code points used for tests.
|
||||
// TODO: Figure out where this class should be.
|
||||
@UsedForTesting
|
||||
|
@ -67,9 +67,9 @@ public class CodePointUtils {
|
|||
};
|
||||
|
||||
@UsedForTesting
|
||||
@Nonnull
|
||||
@NonNull
|
||||
public static int[] generateCodePointSet(final int codePointSetSize,
|
||||
@Nonnull final Random random) {
|
||||
@NonNull final Random random) {
|
||||
final int[] codePointSet = new int[codePointSetSize];
|
||||
for (int i = codePointSet.length - 1; i >= 0; ) {
|
||||
final int r = Math.abs(random.nextInt());
|
||||
|
@ -94,9 +94,9 @@ public class CodePointUtils {
|
|||
* Generates a random word.
|
||||
*/
|
||||
@UsedForTesting
|
||||
@Nonnull
|
||||
public static String generateWord(@Nonnull final Random random,
|
||||
@Nonnull final int[] codePointSet) {
|
||||
@NonNull
|
||||
public static String generateWord(@NonNull final Random random,
|
||||
@NonNull final int[] codePointSet) {
|
||||
final StringBuilder builder = new StringBuilder();
|
||||
// 8 * 4 = 32 chars max, but we do it the following way so as to bias the random toward
|
||||
// longer words. This should be closer to natural language, and more importantly, it will
|
||||
|
|
|
@ -16,15 +16,15 @@
|
|||
|
||||
package org.dslul.openboard.inputmethod.latin.common;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
import org.dslul.openboard.inputmethod.annotations.UsedForTesting;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
/**
|
||||
* Utility methods for working with collections.
|
||||
*/
|
||||
|
@ -40,8 +40,8 @@ public final class CollectionUtils {
|
|||
* @param end Last index exclusive to be converted.
|
||||
* @throws IllegalArgumentException if start or end are out of range or start > end.
|
||||
*/
|
||||
@Nonnull
|
||||
public static <E> ArrayList<E> arrayAsList(@Nonnull final E[] array, final int start,
|
||||
@NonNull
|
||||
public static <E> ArrayList<E> arrayAsList(@NonNull final E[] array, final int start,
|
||||
final int end) {
|
||||
if (start < 0 || start > end || end > array.length) {
|
||||
throw new IllegalArgumentException("Invalid start: " + start + " end: " + end
|
||||
|
|
|
@ -16,20 +16,20 @@
|
|||
|
||||
package org.dslul.openboard.inputmethod.latin.common;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import androidx.annotation.NonNull;
|
||||
|
||||
/**
|
||||
* An immutable class that encapsulates a snapshot of word composition data.
|
||||
*/
|
||||
public class ComposedData {
|
||||
@Nonnull
|
||||
@NonNull
|
||||
public final InputPointers mInputPointers;
|
||||
public final boolean mIsBatchMode;
|
||||
@Nonnull
|
||||
@NonNull
|
||||
public final String mTypedWord;
|
||||
|
||||
public ComposedData(@Nonnull final InputPointers inputPointers, final boolean isBatchMode,
|
||||
@Nonnull final String typedWord) {
|
||||
public ComposedData(@NonNull final InputPointers inputPointers, final boolean isBatchMode,
|
||||
@NonNull final String typedWord) {
|
||||
mInputPointers = inputPointers;
|
||||
mIsBatchMode = isBatchMode;
|
||||
mTypedWord = typedWord;
|
||||
|
@ -45,7 +45,7 @@ public class ComposedData {
|
|||
* @return the number of copied code points.
|
||||
*/
|
||||
public int copyCodePointsExceptTrailingSingleQuotesAndReturnCodePointCount(
|
||||
@Nonnull final int[] destination) {
|
||||
@NonNull final int[] destination) {
|
||||
// lastIndex is exclusive
|
||||
final int lastIndex = mTypedWord.length()
|
||||
- StringUtils.getTrailingSingleQuotesCount(mTypedWord);
|
||||
|
|
|
@ -16,11 +16,11 @@
|
|||
|
||||
package org.dslul.openboard.inputmethod.latin.common;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
|
||||
import org.dslul.openboard.inputmethod.annotations.UsedForTesting;
|
||||
import org.dslul.openboard.inputmethod.latin.BuildConfig;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
public final class Constants {
|
||||
|
||||
public static final class Color {
|
||||
|
@ -261,7 +261,7 @@ public final class Constants {
|
|||
return code >= CODE_SPACE;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@NonNull
|
||||
public static String printableCode(final int code) {
|
||||
switch (code) {
|
||||
case CODE_SHIFT: return "shift";
|
||||
|
@ -297,8 +297,8 @@ public final class Constants {
|
|||
}
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
public static String printableCodes(@Nonnull final int[] codes) {
|
||||
@NonNull
|
||||
public static String printableCodes(@NonNull final int[] codes) {
|
||||
final StringBuilder sb = new StringBuilder();
|
||||
boolean addDelimiter = false;
|
||||
for (final int code : codes) {
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
|
||||
package org.dslul.openboard.inputmethod.latin.common;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import androidx.annotation.NonNull;
|
||||
|
||||
public final class CoordinateUtils {
|
||||
private static final int INDEX_X = 0;
|
||||
|
@ -27,35 +27,35 @@ public final class CoordinateUtils {
|
|||
// This utility class is not publicly instantiable.
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@NonNull
|
||||
public static int[] newInstance() {
|
||||
return new int[ELEMENT_SIZE];
|
||||
}
|
||||
|
||||
public static int x(@Nonnull final int[] coords) {
|
||||
public static int x(@NonNull final int[] coords) {
|
||||
return coords[INDEX_X];
|
||||
}
|
||||
|
||||
public static int y(@Nonnull final int[] coords) {
|
||||
public static int y(@NonNull final int[] coords) {
|
||||
return coords[INDEX_Y];
|
||||
}
|
||||
|
||||
public static void set(@Nonnull final int[] coords, final int x, final int y) {
|
||||
public static void set(@NonNull final int[] coords, final int x, final int y) {
|
||||
coords[INDEX_X] = x;
|
||||
coords[INDEX_Y] = y;
|
||||
}
|
||||
|
||||
public static void copy(@Nonnull final int[] destination, @Nonnull final int[] source) {
|
||||
public static void copy(@NonNull final int[] destination, @NonNull final int[] source) {
|
||||
destination[INDEX_X] = source[INDEX_X];
|
||||
destination[INDEX_Y] = source[INDEX_Y];
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@NonNull
|
||||
public static int[] newCoordinateArray(final int arraySize) {
|
||||
return new int[ELEMENT_SIZE * arraySize];
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@NonNull
|
||||
public static int[] newCoordinateArray(final int arraySize,
|
||||
final int defaultX, final int defaultY) {
|
||||
final int[] result = new int[ELEMENT_SIZE * arraySize];
|
||||
|
@ -65,30 +65,30 @@ public final class CoordinateUtils {
|
|||
return result;
|
||||
}
|
||||
|
||||
public static int xFromArray(@Nonnull final int[] coordsArray, final int index) {
|
||||
public static int xFromArray(@NonNull final int[] coordsArray, final int index) {
|
||||
return coordsArray[ELEMENT_SIZE * index + INDEX_X];
|
||||
}
|
||||
|
||||
public static int yFromArray(@Nonnull final int[] coordsArray, final int index) {
|
||||
public static int yFromArray(@NonNull final int[] coordsArray, final int index) {
|
||||
return coordsArray[ELEMENT_SIZE * index + INDEX_Y];
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
public static int[] coordinateFromArray(@Nonnull final int[] coordsArray, final int index) {
|
||||
@NonNull
|
||||
public static int[] coordinateFromArray(@NonNull final int[] coordsArray, final int index) {
|
||||
final int[] coords = newInstance();
|
||||
set(coords, xFromArray(coordsArray, index), yFromArray(coordsArray, index));
|
||||
return coords;
|
||||
}
|
||||
|
||||
public static void setXYInArray(@Nonnull final int[] coordsArray, final int index,
|
||||
public static void setXYInArray(@NonNull final int[] coordsArray, final int index,
|
||||
final int x, final int y) {
|
||||
final int baseIndex = ELEMENT_SIZE * index;
|
||||
coordsArray[baseIndex + INDEX_X] = x;
|
||||
coordsArray[baseIndex + INDEX_Y] = y;
|
||||
}
|
||||
|
||||
public static void setCoordinateInArray(@Nonnull final int[] coordsArray, final int index,
|
||||
@Nonnull final int[] coords) {
|
||||
public static void setCoordinateInArray(@NonNull final int[] coordsArray, final int index,
|
||||
@NonNull final int[] coords) {
|
||||
setXYInArray(coordsArray, index, x(coords), y(coords));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -16,9 +16,9 @@
|
|||
|
||||
package org.dslul.openboard.inputmethod.latin.common;
|
||||
|
||||
import org.dslul.openboard.inputmethod.annotations.UsedForTesting;
|
||||
import androidx.annotation.NonNull;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import org.dslul.openboard.inputmethod.annotations.UsedForTesting;
|
||||
|
||||
// TODO: This class is not thread-safe.
|
||||
public final class InputPointers {
|
||||
|
@ -72,14 +72,14 @@ public final class InputPointers {
|
|||
mTimes.add(time);
|
||||
}
|
||||
|
||||
public void set(@Nonnull final InputPointers ip) {
|
||||
public void set(@NonNull final InputPointers ip) {
|
||||
mXCoordinates.set(ip.mXCoordinates);
|
||||
mYCoordinates.set(ip.mYCoordinates);
|
||||
mPointerIds.set(ip.mPointerIds);
|
||||
mTimes.set(ip.mTimes);
|
||||
}
|
||||
|
||||
public void copy(@Nonnull final InputPointers ip) {
|
||||
public void copy(@NonNull final InputPointers ip) {
|
||||
mXCoordinates.copy(ip.mXCoordinates);
|
||||
mYCoordinates.copy(ip.mYCoordinates);
|
||||
mPointerIds.copy(ip.mPointerIds);
|
||||
|
@ -96,9 +96,9 @@ public final class InputPointers {
|
|||
* @param startPos the starting index of the data in {@code times} and etc.
|
||||
* @param length the number of data to be appended.
|
||||
*/
|
||||
public void append(final int pointerId, @Nonnull final ResizableIntArray times,
|
||||
@Nonnull final ResizableIntArray xCoordinates,
|
||||
@Nonnull final ResizableIntArray yCoordinates, final int startPos, final int length) {
|
||||
public void append(final int pointerId, @NonNull final ResizableIntArray times,
|
||||
@NonNull final ResizableIntArray xCoordinates,
|
||||
@NonNull final ResizableIntArray yCoordinates, final int startPos, final int length) {
|
||||
if (length == 0) {
|
||||
return;
|
||||
}
|
||||
|
@ -132,17 +132,17 @@ public final class InputPointers {
|
|||
return mXCoordinates.getLength();
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@NonNull
|
||||
public int[] getXCoordinates() {
|
||||
return mXCoordinates.getPrimitiveArray();
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@NonNull
|
||||
public int[] getYCoordinates() {
|
||||
return mYCoordinates.getPrimitiveArray();
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@NonNull
|
||||
public int[] getPointerIds() {
|
||||
return mPointerIds.getPrimitiveArray();
|
||||
}
|
||||
|
@ -153,7 +153,7 @@ public final class InputPointers {
|
|||
* @return The time each point was registered, in milliseconds, relative to the first event in
|
||||
* the sequence.
|
||||
*/
|
||||
@Nonnull
|
||||
@NonNull
|
||||
public int[] getTimes() {
|
||||
return mTimes.getPrimitiveArray();
|
||||
}
|
||||
|
|
|
@ -18,15 +18,15 @@ package org.dslul.openboard.inputmethod.latin.common;
|
|||
|
||||
import android.content.Context;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
import org.dslul.openboard.inputmethod.latin.R;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.Locale;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
/**
|
||||
* A class to help with handling Locales in string form.
|
||||
*
|
||||
|
@ -177,8 +177,8 @@ public final class LocaleUtils {
|
|||
* @param localeString a string specification of a locale, in a format of "ll_cc_variant" where
|
||||
* "ll" is a language code, "cc" is a country code.
|
||||
*/
|
||||
@Nonnull
|
||||
public static Locale constructLocaleFromString(@Nonnull final String localeString) {
|
||||
@NonNull
|
||||
public static Locale constructLocaleFromString(@NonNull final String localeString) {
|
||||
synchronized (sLocaleCache) {
|
||||
if (sLocaleCache.containsKey(localeString)) {
|
||||
return sLocaleCache.get(localeString);
|
||||
|
@ -213,7 +213,7 @@ public final class LocaleUtils {
|
|||
sRtlLanguageCodes.add("yi"); // Yiddish
|
||||
}
|
||||
|
||||
public static boolean isRtlLanguage(@Nonnull final Locale locale) {
|
||||
public static boolean isRtlLanguage(@NonNull final Locale locale) {
|
||||
return sRtlLanguageCodes.contains(locale.getLanguage());
|
||||
}
|
||||
|
||||
|
|
|
@ -16,15 +16,15 @@
|
|||
|
||||
package org.dslul.openboard.inputmethod.latin.common;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
|
||||
import org.dslul.openboard.inputmethod.annotations.UsedForTesting;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
// TODO: This class is not thread-safe.
|
||||
public final class ResizableIntArray {
|
||||
@Nonnull
|
||||
@NonNull
|
||||
private int[] mArray;
|
||||
private int mLength;
|
||||
|
||||
|
@ -94,18 +94,18 @@ public final class ResizableIntArray {
|
|||
mLength = 0;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@NonNull
|
||||
public int[] getPrimitiveArray() {
|
||||
return mArray;
|
||||
}
|
||||
|
||||
public void set(@Nonnull final ResizableIntArray ip) {
|
||||
public void set(@NonNull final ResizableIntArray ip) {
|
||||
// TODO: Implement primitive array pool.
|
||||
mArray = ip.mArray;
|
||||
mLength = ip.mLength;
|
||||
}
|
||||
|
||||
public void copy(@Nonnull final ResizableIntArray ip) {
|
||||
public void copy(@NonNull final ResizableIntArray ip) {
|
||||
final int newCapacity = calculateCapacity(ip.mLength);
|
||||
if (newCapacity > 0) {
|
||||
// TODO: Implement primitive array pool.
|
||||
|
@ -115,7 +115,7 @@ public final class ResizableIntArray {
|
|||
mLength = ip.mLength;
|
||||
}
|
||||
|
||||
public void append(@Nonnull final ResizableIntArray src, final int startPos, final int length) {
|
||||
public void append(@NonNull final ResizableIntArray src, final int startPos, final int length) {
|
||||
if (length == 0) {
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -18,6 +18,9 @@ package org.dslul.openboard.inputmethod.latin.common;
|
|||
|
||||
import android.renderscript.Script;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
import org.dslul.openboard.inputmethod.annotations.UsedForTesting;
|
||||
import org.dslul.openboard.inputmethod.latin.utils.ScriptUtils;
|
||||
|
||||
|
@ -25,16 +28,13 @@ import java.util.ArrayList;
|
|||
import java.util.Arrays;
|
||||
import java.util.Locale;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
public final class StringUtils {
|
||||
|
||||
public static final int CAPITALIZE_NONE = 0; // No caps, or mixed case
|
||||
public static final int CAPITALIZE_FIRST = 1; // First only
|
||||
public static final int CAPITALIZE_ALL = 2; // All caps
|
||||
|
||||
@Nonnull
|
||||
@NonNull
|
||||
private static final String EMPTY_STRING = "";
|
||||
|
||||
private static final char CHAR_LINE_FEED = 0X000A;
|
||||
|
@ -71,9 +71,9 @@ public final class StringUtils {
|
|||
* @param tokens an array objects to be joined. Strings will be formed from
|
||||
* the objects by calling object.toString().
|
||||
*/
|
||||
@Nonnull
|
||||
public static String join(@Nonnull final CharSequence delimiter,
|
||||
@Nonnull final Iterable<?> tokens) {
|
||||
@NonNull
|
||||
public static String join(@NonNull final CharSequence delimiter,
|
||||
@NonNull final Iterable<?> tokens) {
|
||||
final StringBuilder sb = new StringBuilder();
|
||||
boolean firstTime = true;
|
||||
for (final Object token : tokens) {
|
||||
|
@ -124,7 +124,7 @@ public final class StringUtils {
|
|||
return Character.codePointCount(text, 0, text.length());
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@NonNull
|
||||
public static String newSingleCodePointString(final int codePoint) {
|
||||
if (Character.charCount(codePoint) == 1) {
|
||||
// Optimization: avoid creating a temporary array for characters that are
|
||||
|
@ -135,8 +135,8 @@ public final class StringUtils {
|
|||
return new String(Character.toChars(codePoint));
|
||||
}
|
||||
|
||||
public static boolean containsInArray(@Nonnull final String text,
|
||||
@Nonnull final String[] array) {
|
||||
public static boolean containsInArray(@NonNull final String text,
|
||||
@NonNull final String[] array) {
|
||||
for (final String element : array) {
|
||||
if (text.equals(element)) {
|
||||
return true;
|
||||
|
@ -150,10 +150,10 @@ public final class StringUtils {
|
|||
* Unlike CSV, Comma-Splittable Text has no escaping mechanism, so that the text can't contain
|
||||
* a comma character in it.
|
||||
*/
|
||||
@Nonnull
|
||||
@NonNull
|
||||
private static final String SEPARATOR_FOR_COMMA_SPLITTABLE_TEXT = ",";
|
||||
|
||||
public static boolean containsInCommaSplittableText(@Nonnull final String text,
|
||||
public static boolean containsInCommaSplittableText(@NonNull final String text,
|
||||
@Nullable final String extraValues) {
|
||||
if (isEmpty(extraValues)) {
|
||||
return false;
|
||||
|
@ -161,8 +161,8 @@ public final class StringUtils {
|
|||
return containsInArray(text, extraValues.split(SEPARATOR_FOR_COMMA_SPLITTABLE_TEXT));
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
public static String removeFromCommaSplittableTextIfExists(@Nonnull final String text,
|
||||
@NonNull
|
||||
public static String removeFromCommaSplittableTextIfExists(@NonNull final String text,
|
||||
@Nullable final String extraValues) {
|
||||
if (isEmpty(extraValues)) {
|
||||
return EMPTY_STRING;
|
||||
|
@ -186,7 +186,7 @@ public final class StringUtils {
|
|||
* This method will always keep the first occurrence of all strings at their position
|
||||
* in the array, removing the subsequent ones.
|
||||
*/
|
||||
public static void removeDupes(@Nonnull final ArrayList<String> suggestions) {
|
||||
public static void removeDupes(@NonNull final ArrayList<String> suggestions) {
|
||||
if (suggestions.size() < 2) {
|
||||
return;
|
||||
}
|
||||
|
@ -207,9 +207,9 @@ public final class StringUtils {
|
|||
}
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
public static String capitalizeFirstCodePoint(@Nonnull final String s,
|
||||
@Nonnull final Locale locale) {
|
||||
@NonNull
|
||||
public static String capitalizeFirstCodePoint(@NonNull final String s,
|
||||
@NonNull final Locale locale) {
|
||||
if (s.length() <= 1) {
|
||||
return s.toUpperCase(getLocaleUsedForToTitleCase(locale));
|
||||
}
|
||||
|
@ -220,9 +220,9 @@ public final class StringUtils {
|
|||
+ s.substring(cutoff);
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
public static String capitalizeFirstAndDowncaseRest(@Nonnull final String s,
|
||||
@Nonnull final Locale locale) {
|
||||
@NonNull
|
||||
public static String capitalizeFirstAndDowncaseRest(@NonNull final String s,
|
||||
@NonNull final Locale locale) {
|
||||
if (s.length() <= 1) {
|
||||
return s.toUpperCase(getLocaleUsedForToTitleCase(locale));
|
||||
}
|
||||
|
@ -238,12 +238,12 @@ public final class StringUtils {
|
|||
+ s.substring(cutoff).toLowerCase(locale);
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
public static int[] toCodePointArray(@Nonnull final CharSequence charSequence) {
|
||||
@NonNull
|
||||
public static int[] toCodePointArray(@NonNull final CharSequence charSequence) {
|
||||
return toCodePointArray(charSequence, 0, charSequence.length());
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@NonNull
|
||||
private static final int[] EMPTY_CODEPOINTS = {};
|
||||
|
||||
/**
|
||||
|
@ -254,8 +254,8 @@ public final class StringUtils {
|
|||
* @param endIndex the end index inside the string in java chars, exclusive.
|
||||
* @return a new array of code points. At most endIndex - startIndex, but possibly less.
|
||||
*/
|
||||
@Nonnull
|
||||
public static int[] toCodePointArray(@Nonnull final CharSequence charSequence,
|
||||
@NonNull
|
||||
public static int[] toCodePointArray(@NonNull final CharSequence charSequence,
|
||||
final int startIndex, final int endIndex) {
|
||||
final int length = charSequence.length();
|
||||
if (length <= 0) {
|
||||
|
@ -286,8 +286,8 @@ public final class StringUtils {
|
|||
* @param downCase if this is true, code points will be downcased before being copied.
|
||||
* @return the number of copied code points.
|
||||
*/
|
||||
public static int copyCodePointsAndReturnCodePointCount(@Nonnull final int[] destination,
|
||||
@Nonnull final CharSequence charSequence, final int startIndex, final int endIndex,
|
||||
public static int copyCodePointsAndReturnCodePointCount(@NonNull final int[] destination,
|
||||
@NonNull final CharSequence charSequence, final int startIndex, final int endIndex,
|
||||
final boolean downCase) {
|
||||
int destIndex = 0;
|
||||
for (int index = startIndex; index < endIndex;
|
||||
|
@ -301,8 +301,8 @@ public final class StringUtils {
|
|||
return destIndex;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
public static int[] toSortedCodePointArray(@Nonnull final String string) {
|
||||
@NonNull
|
||||
public static int[] toSortedCodePointArray(@NonNull final String string) {
|
||||
final int[] codePoints = toCodePointArray(string);
|
||||
Arrays.sort(codePoints);
|
||||
return codePoints;
|
||||
|
@ -315,9 +315,9 @@ public final class StringUtils {
|
|||
* shorter than the array length.
|
||||
* @return a string constructed from the code point array.
|
||||
*/
|
||||
@Nonnull
|
||||
@NonNull
|
||||
public static String getStringFromNullTerminatedCodePointArray(
|
||||
@Nonnull final int[] codePoints) {
|
||||
@NonNull final int[] codePoints) {
|
||||
int stringLength = codePoints.length;
|
||||
for (int i = 0; i < codePoints.length; i++) {
|
||||
if (codePoints[i] == 0) {
|
||||
|
@ -329,7 +329,7 @@ public final class StringUtils {
|
|||
}
|
||||
|
||||
// This method assumes the text is not null. For the empty string, it returns CAPITALIZE_NONE.
|
||||
public static int getCapitalizationType(@Nonnull final String text) {
|
||||
public static int getCapitalizationType(@NonNull final String text) {
|
||||
// If the first char is not uppercase, then the word is either all lower case or
|
||||
// camel case, and in either case we return CAPITALIZE_NONE.
|
||||
final int len = text.length();
|
||||
|
@ -365,7 +365,7 @@ public final class StringUtils {
|
|||
return (letterCount == capsCount ? CAPITALIZE_ALL : CAPITALIZE_NONE);
|
||||
}
|
||||
|
||||
public static boolean isIdenticalAfterUpcase(@Nonnull final String text) {
|
||||
public static boolean isIdenticalAfterUpcase(@NonNull final String text) {
|
||||
final int length = text.length();
|
||||
int i = 0;
|
||||
while (i < length) {
|
||||
|
@ -378,7 +378,7 @@ public final class StringUtils {
|
|||
return true;
|
||||
}
|
||||
|
||||
public static boolean isIdenticalAfterDowncase(@Nonnull final String text) {
|
||||
public static boolean isIdenticalAfterDowncase(@NonNull final String text) {
|
||||
final int length = text.length();
|
||||
int i = 0;
|
||||
while (i < length) {
|
||||
|
@ -391,8 +391,8 @@ public final class StringUtils {
|
|||
return true;
|
||||
}
|
||||
|
||||
public static boolean isIdenticalAfterCapitalizeEachWord(@Nonnull final String text,
|
||||
@Nonnull final int[] sortedSeparators) {
|
||||
public static boolean isIdenticalAfterCapitalizeEachWord(@NonNull final String text,
|
||||
@NonNull final int[] sortedSeparators) {
|
||||
boolean needsCapsNext = true;
|
||||
final int len = text.length();
|
||||
for (int i = 0; i < len; i = text.offsetByCodePoints(i, 1)) {
|
||||
|
@ -411,9 +411,9 @@ public final class StringUtils {
|
|||
|
||||
// TODO: like capitalizeFirst*, this does not work perfectly for Dutch because of the IJ digraph
|
||||
// which should be capitalized together in *some* cases.
|
||||
@Nonnull
|
||||
public static String capitalizeEachWord(@Nonnull final String text,
|
||||
@Nonnull final int[] sortedSeparators, @Nonnull final Locale locale) {
|
||||
@NonNull
|
||||
public static String capitalizeEachWord(@NonNull final String text,
|
||||
@NonNull final int[] sortedSeparators, @NonNull final Locale locale) {
|
||||
final StringBuilder builder = new StringBuilder();
|
||||
boolean needsCapsNext = true;
|
||||
final int len = text.length();
|
||||
|
@ -447,7 +447,7 @@ public final class StringUtils {
|
|||
* TODO: This will return that "abc./def" and ".abc/def" look like URLs to keep down the
|
||||
* code complexity, but ideally it should not. It's acceptable for now.
|
||||
*/
|
||||
public static boolean lastPartLooksLikeURL(@Nonnull final CharSequence text) {
|
||||
public static boolean lastPartLooksLikeURL(@NonNull final CharSequence text) {
|
||||
int i = text.length();
|
||||
if (0 == i) {
|
||||
return false;
|
||||
|
@ -516,7 +516,7 @@ public final class StringUtils {
|
|||
* @param text the text to examine.
|
||||
* @return whether we're inside a double quote.
|
||||
*/
|
||||
public static boolean isInsideDoubleQuoteOrAfterDigit(@Nonnull final CharSequence text) {
|
||||
public static boolean isInsideDoubleQuoteOrAfterDigit(@NonNull final CharSequence text) {
|
||||
int i = text.length();
|
||||
if (0 == i) {
|
||||
return false;
|
||||
|
@ -548,7 +548,7 @@ public final class StringUtils {
|
|||
return Constants.CODE_DOUBLE_QUOTE == codePoint;
|
||||
}
|
||||
|
||||
public static boolean isEmptyStringOrWhiteSpaces(@Nonnull final String s) {
|
||||
public static boolean isEmptyStringOrWhiteSpaces(@NonNull final String s) {
|
||||
final int N = codePointCount(s);
|
||||
for (int i = 0; i < N; ++i) {
|
||||
if (!Character.isWhitespace(s.codePointAt(i))) {
|
||||
|
@ -559,7 +559,7 @@ public final class StringUtils {
|
|||
}
|
||||
|
||||
@UsedForTesting
|
||||
@Nonnull
|
||||
@NonNull
|
||||
public static String byteArrayToHexString(@Nullable final byte[] bytes) {
|
||||
if (bytes == null || bytes.length == 0) {
|
||||
return EMPTY_STRING;
|
||||
|
@ -595,8 +595,8 @@ public final class StringUtils {
|
|||
|
||||
private static final String LANGUAGE_GREEK = "el";
|
||||
|
||||
@Nonnull
|
||||
private static Locale getLocaleUsedForToTitleCase(@Nonnull final Locale locale) {
|
||||
@NonNull
|
||||
private static Locale getLocaleUsedForToTitleCase(@NonNull final Locale locale) {
|
||||
// In Greek locale {@link String#toUpperCase(Locale)} eliminates accents from its result.
|
||||
// In order to get accented upper case letter, {@link Locale#ROOT} should be used.
|
||||
if (LANGUAGE_GREEK.equals(locale.getLanguage())) {
|
||||
|
@ -607,7 +607,7 @@ public final class StringUtils {
|
|||
|
||||
@Nullable
|
||||
public static String toTitleCaseOfKeyLabel(@Nullable final String label,
|
||||
@Nonnull final Locale locale) {
|
||||
@NonNull final Locale locale) {
|
||||
if (label == null || !ScriptUtils.scriptSupportsUppercase(locale)) {
|
||||
return label;
|
||||
}
|
||||
|
@ -615,7 +615,7 @@ public final class StringUtils {
|
|||
return label.toUpperCase(getLocaleUsedForToTitleCase(locale));
|
||||
}
|
||||
|
||||
public static int toTitleCaseOfKeyCode(final int code, @Nonnull final Locale locale) {
|
||||
public static int toTitleCaseOfKeyCode(final int code, @NonNull final Locale locale) {
|
||||
if (!Constants.isLetterCode(code)) {
|
||||
return code;
|
||||
}
|
||||
|
@ -625,7 +625,7 @@ public final class StringUtils {
|
|||
? titleCaseLabel.codePointAt(0) : Constants.CODE_UNSPECIFIED;
|
||||
}
|
||||
|
||||
public static int getTrailingSingleQuotesCount(@Nonnull final CharSequence charSequence) {
|
||||
public static int getTrailingSingleQuotesCount(@NonNull final CharSequence charSequence) {
|
||||
final int lastIndex = charSequence.length() - 1;
|
||||
int i = lastIndex;
|
||||
while (i >= 0 && charSequence.charAt(i) == Constants.CODE_SINGLE_QUOTE) {
|
||||
|
@ -636,11 +636,11 @@ public final class StringUtils {
|
|||
|
||||
@UsedForTesting
|
||||
public static class Stringizer<E> {
|
||||
@Nonnull
|
||||
@NonNull
|
||||
private static final String[] EMPTY_STRING_ARRAY = new String[0];
|
||||
|
||||
@UsedForTesting
|
||||
@Nonnull
|
||||
@NonNull
|
||||
public String stringize(@Nullable final E element) {
|
||||
if (element == null) {
|
||||
return "null";
|
||||
|
@ -649,7 +649,7 @@ public final class StringUtils {
|
|||
}
|
||||
|
||||
@UsedForTesting
|
||||
@Nonnull
|
||||
@NonNull
|
||||
public final String join(@Nullable final E[] array) {
|
||||
return joinStringArray(toStringArray(array), null /* delimiter */);
|
||||
}
|
||||
|
@ -659,7 +659,7 @@ public final class StringUtils {
|
|||
return joinStringArray(toStringArray(array), delimiter);
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@NonNull
|
||||
protected String[] toStringArray(@Nullable final E[] array) {
|
||||
if (array == null) {
|
||||
return EMPTY_STRING_ARRAY;
|
||||
|
@ -671,8 +671,8 @@ public final class StringUtils {
|
|||
return stringArray;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
protected String joinStringArray(@Nonnull final String[] stringArray,
|
||||
@NonNull
|
||||
protected String joinStringArray(@NonNull final String[] stringArray,
|
||||
@Nullable final String delimiter) {
|
||||
if (delimiter == null) {
|
||||
return Arrays.toString(stringArray);
|
||||
|
|
|
@ -30,6 +30,8 @@ import android.view.KeyEvent;
|
|||
import android.view.inputmethod.CorrectionInfo;
|
||||
import android.view.inputmethod.EditorInfo;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
|
||||
import org.dslul.openboard.inputmethod.compat.SuggestionSpanUtils;
|
||||
import org.dslul.openboard.inputmethod.event.Event;
|
||||
import org.dslul.openboard.inputmethod.event.InputTransaction;
|
||||
|
@ -65,8 +67,6 @@ import java.util.Locale;
|
|||
import java.util.TreeSet;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
/**
|
||||
* This class manages the input logic.
|
||||
*/
|
||||
|
@ -442,7 +442,7 @@ public final class InputLogic {
|
|||
* @return the complete transaction object
|
||||
*/
|
||||
public InputTransaction onCodeInput(final SettingsValues settingsValues,
|
||||
@Nonnull final Event event, final int keyboardShiftMode,
|
||||
@NonNull final Event event, final int keyboardShiftMode,
|
||||
final int currentKeyboardScriptId, final LatinIME.UIHandler handler) {
|
||||
mWordBeingCorrectedByCursor = null;
|
||||
mJustRevertedACommit = false;
|
||||
|
@ -1483,7 +1483,7 @@ public final class InputLogic {
|
|||
}
|
||||
|
||||
private void performAdditionToUserHistoryDictionary(final SettingsValues settingsValues,
|
||||
final String suggestion, @Nonnull final NgramContext ngramContext) {
|
||||
final String suggestion, @NonNull final NgramContext ngramContext) {
|
||||
// If correction is not enabled, we don't add words to the user history dictionary.
|
||||
// That's to avoid unintended additions in some sensitive fields, or fields that
|
||||
// expect to receive non-words.
|
||||
|
@ -1990,7 +1990,7 @@ public final class InputLogic {
|
|||
* @return the {@link Locale} of the {@link #mDictionaryFacilitator} if available. Otherwise
|
||||
* {@link Locale#ROOT}.
|
||||
*/
|
||||
@Nonnull
|
||||
@NonNull
|
||||
private Locale getDictionaryFacilitatorLocale() {
|
||||
return mDictionaryFacilitator != null ? mDictionaryFacilitator.getLocale() : Locale.ROOT;
|
||||
}
|
||||
|
|
|
@ -16,26 +16,26 @@
|
|||
|
||||
package org.dslul.openboard.inputmethod.latin.makedict;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
import org.dslul.openboard.inputmethod.latin.makedict.FormatSpec.DictionaryOptions;
|
||||
import org.dslul.openboard.inputmethod.latin.makedict.FormatSpec.FormatOptions;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
/**
|
||||
* Class representing dictionary header.
|
||||
*/
|
||||
public final class DictionaryHeader {
|
||||
public final int mBodyOffset;
|
||||
@Nonnull
|
||||
@NonNull
|
||||
public final DictionaryOptions mDictionaryOptions;
|
||||
@Nonnull
|
||||
@NonNull
|
||||
public final FormatOptions mFormatOptions;
|
||||
@Nonnull
|
||||
@NonNull
|
||||
public final String mLocaleString;
|
||||
@Nonnull
|
||||
@NonNull
|
||||
public final String mVersionString;
|
||||
@Nonnull
|
||||
@NonNull
|
||||
public final String mIdString;
|
||||
|
||||
// Note that these are corresponding definitions in native code in latinime::HeaderPolicy
|
||||
|
@ -58,8 +58,8 @@ public final class DictionaryHeader {
|
|||
public static final String CODE_POINT_TABLE_KEY = "codePointTable";
|
||||
|
||||
public DictionaryHeader(final int headerSize,
|
||||
@Nonnull final DictionaryOptions dictionaryOptions,
|
||||
@Nonnull final FormatOptions formatOptions) throws UnsupportedFormatException {
|
||||
@NonNull final DictionaryOptions dictionaryOptions,
|
||||
@NonNull final FormatOptions formatOptions) throws UnsupportedFormatException {
|
||||
mDictionaryOptions = dictionaryOptions;
|
||||
mFormatOptions = formatOptions;
|
||||
mBodyOffset = formatOptions.mVersion < FormatSpec.VERSION4 ? headerSize : 0;
|
||||
|
|
|
@ -16,6 +16,8 @@
|
|||
|
||||
package org.dslul.openboard.inputmethod.latin.makedict;
|
||||
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
import org.dslul.openboard.inputmethod.annotations.UsedForTesting;
|
||||
import com.android.inputmethod.latin.BinaryDictionary;
|
||||
import org.dslul.openboard.inputmethod.latin.Dictionary;
|
||||
|
@ -27,8 +29,6 @@ import org.dslul.openboard.inputmethod.latin.utils.CombinedFormatUtils;
|
|||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
/**
|
||||
* Utility class for a word with a probability.
|
||||
*
|
||||
|
|
|
@ -19,13 +19,13 @@ package org.dslul.openboard.inputmethod.latin.permissions;
|
|||
import android.app.Activity;
|
||||
import android.content.Context;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
/**
|
||||
* Manager to perform permission related tasks. Always call on the UI thread.
|
||||
*/
|
||||
|
@ -46,8 +46,8 @@ public class PermissionsManager {
|
|||
mContext = context;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
public static synchronized PermissionsManager get(@Nonnull Context context) {
|
||||
@NonNull
|
||||
public static synchronized PermissionsManager get(@NonNull Context context) {
|
||||
if (sInstance == null) {
|
||||
sInstance = new PermissionsManager(context);
|
||||
}
|
||||
|
@ -59,7 +59,7 @@ public class PermissionsManager {
|
|||
}
|
||||
|
||||
|
||||
public synchronized void requestPermissions(@Nonnull PermissionsResultCallback callback,
|
||||
public synchronized void requestPermissions(@NonNull PermissionsResultCallback callback,
|
||||
@Nullable Activity activity,
|
||||
String... permissionsToRequest) {
|
||||
List<String> deniedPermissions = PermissionsUtil.getDeniedPermissions(
|
||||
|
|
|
@ -19,6 +19,9 @@ package org.dslul.openboard.inputmethod.latin.personalization;
|
|||
import android.content.Context;
|
||||
import android.util.Log;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
import org.dslul.openboard.inputmethod.latin.common.FileUtils;
|
||||
|
||||
import java.io.File;
|
||||
|
@ -27,9 +30,6 @@ import java.lang.ref.SoftReference;
|
|||
import java.util.Locale;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
/**
|
||||
* Helps handle and manage personalized dictionaries such as {@link UserHistoryDictionary}.
|
||||
*/
|
||||
|
@ -40,7 +40,7 @@ public class PersonalizationHelper {
|
|||
private static final ConcurrentHashMap<String, SoftReference<UserHistoryDictionary>>
|
||||
sLangUserHistoryDictCache = new ConcurrentHashMap<>();
|
||||
|
||||
@Nonnull
|
||||
@NonNull
|
||||
public static UserHistoryDictionary getUserHistoryDictionary(
|
||||
final Context context, final Locale locale, @Nullable final String accountName) {
|
||||
String lookupStr = locale.toString();
|
||||
|
|
|
@ -18,6 +18,9 @@ package org.dslul.openboard.inputmethod.latin.personalization;
|
|||
|
||||
import android.content.Context;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
import org.dslul.openboard.inputmethod.annotations.ExternallyReferenced;
|
||||
import org.dslul.openboard.inputmethod.annotations.UsedForTesting;
|
||||
import com.android.inputmethod.latin.BinaryDictionary;
|
||||
|
@ -30,9 +33,6 @@ import java.io.File;
|
|||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
/**
|
||||
* Locally gathers statistics about the words user types and various other signals like
|
||||
* auto-correction cancellation or manual picks. This allows the keyboard to adapt to the
|
||||
|
@ -77,7 +77,7 @@ public class UserHistoryDictionary extends ExpandableBinaryDictionary {
|
|||
* @param timestamp the timestamp when the word has been inputted
|
||||
*/
|
||||
public static void addToDictionary(final ExpandableBinaryDictionary userHistoryDictionary,
|
||||
@Nonnull final NgramContext ngramContext, final String word, final boolean isValid,
|
||||
@NonNull final NgramContext ngramContext, final String word, final boolean isValid,
|
||||
final int timestamp) {
|
||||
if (word.length() > BinaryDictionary.DICTIONARY_MAX_WORD_LENGTH) {
|
||||
return;
|
||||
|
|
|
@ -21,11 +21,11 @@ import android.content.SharedPreferences;
|
|||
import android.preference.PreferenceFragment;
|
||||
import android.view.inputmethod.InputMethodSubtype;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
|
||||
import org.dslul.openboard.inputmethod.latin.RichInputMethodManager;
|
||||
import org.dslul.openboard.inputmethod.latin.RichInputMethodSubtype;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
/**
|
||||
* Utility class for managing additional features settings.
|
||||
*/
|
||||
|
@ -47,10 +47,10 @@ public class AdditionalFeaturesSettingUtils {
|
|||
// do nothing.
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@NonNull
|
||||
public static RichInputMethodSubtype createRichInputMethodSubtype(
|
||||
@Nonnull final RichInputMethodManager imm,
|
||||
@Nonnull final InputMethodSubtype subtype,
|
||||
@NonNull final RichInputMethodManager imm,
|
||||
@NonNull final InputMethodSubtype subtype,
|
||||
final Context context) {
|
||||
return new RichInputMethodSubtype(subtype);
|
||||
}
|
||||
|
|
|
@ -27,6 +27,8 @@ import android.util.Log;
|
|||
|
||||
import android.view.Gravity;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
|
||||
import org.dslul.openboard.inputmethod.keyboard.KeyboardTheme;
|
||||
import org.dslul.openboard.inputmethod.latin.AudioAndHapticFeedbackManager;
|
||||
import org.dslul.openboard.inputmethod.latin.InputAttributes;
|
||||
|
@ -48,8 +50,6 @@ import java.util.Locale;
|
|||
import java.util.Set;
|
||||
import java.util.concurrent.locks.ReentrantLock;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
public final class Settings implements SharedPreferences.OnSharedPreferenceChangeListener {
|
||||
private static final String TAG = Settings.class.getSimpleName();
|
||||
// Settings screens
|
||||
|
@ -227,7 +227,7 @@ public final class Settings implements SharedPreferences.OnSharedPreferenceChang
|
|||
}
|
||||
|
||||
public void loadSettings(final Context context, final Locale locale,
|
||||
@Nonnull final InputAttributes inputAttributes) {
|
||||
@NonNull final InputAttributes inputAttributes) {
|
||||
mSettingsValuesLock.lock();
|
||||
mContext = context;
|
||||
try {
|
||||
|
|
|
@ -24,6 +24,9 @@ import android.content.res.Resources;
|
|||
import android.util.Log;
|
||||
import android.view.inputmethod.EditorInfo;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
import org.dslul.openboard.inputmethod.compat.AppWorkaroundsUtils;
|
||||
import org.dslul.openboard.inputmethod.latin.InputAttributes;
|
||||
import org.dslul.openboard.inputmethod.latin.R;
|
||||
|
@ -39,9 +42,6 @@ import java.util.Arrays;
|
|||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
/**
|
||||
* When you call the constructor of this class, you may want to change the current system locale by
|
||||
* using {@link org.dslul.openboard.inputmethod.latin.utils.RunInLocale}.
|
||||
|
@ -111,7 +111,7 @@ public class SettingsValues {
|
|||
public final boolean mCustomNavBarColor;
|
||||
|
||||
// From the input box
|
||||
@Nonnull
|
||||
@NonNull
|
||||
public final InputAttributes mInputAttributes;
|
||||
|
||||
// Deduced settings
|
||||
|
@ -144,7 +144,7 @@ public class SettingsValues {
|
|||
public final String mAccount;
|
||||
|
||||
public SettingsValues(final Context context, final SharedPreferences prefs, final Resources res,
|
||||
@Nonnull final InputAttributes inputAttributes) {
|
||||
@NonNull final InputAttributes inputAttributes) {
|
||||
mLocale = res.getConfiguration().locale;
|
||||
// Get the resources
|
||||
mDelayInMillisecondsToUpdateOldSuggestions =
|
||||
|
|
|
@ -27,12 +27,13 @@ import android.os.Message;
|
|||
import android.provider.Settings;
|
||||
import android.util.Log;
|
||||
import android.view.View;
|
||||
import android.view.inputmethod.InputMethodInfo;
|
||||
import android.view.inputmethod.InputMethodManager;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
import android.widget.VideoView;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
|
||||
import org.dslul.openboard.inputmethod.latin.R;
|
||||
import org.dslul.openboard.inputmethod.latin.settings.SettingsActivity;
|
||||
import org.dslul.openboard.inputmethod.latin.utils.LeakGuardHandlerWrapper;
|
||||
|
@ -40,8 +41,6 @@ import org.dslul.openboard.inputmethod.latin.utils.UncachedInputMethodManagerUti
|
|||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
// TODO: Use Fragment to implement welcome screen and setup steps.
|
||||
public final class SetupWizardActivity extends Activity implements View.OnClickListener {
|
||||
static final String TAG = SetupWizardActivity.class.getSimpleName();
|
||||
|
@ -82,7 +81,7 @@ public final class SetupWizardActivity extends Activity implements View.OnClickL
|
|||
|
||||
private final InputMethodManager mImmInHandler;
|
||||
|
||||
public SettingsPoolingHandler(@Nonnull final SetupWizardActivity ownerInstance,
|
||||
public SettingsPoolingHandler(@NonNull final SetupWizardActivity ownerInstance,
|
||||
final InputMethodManager imm) {
|
||||
super(ownerInstance);
|
||||
mImmInHandler = imm;
|
||||
|
|
|
@ -24,6 +24,8 @@ import android.view.inputmethod.EditorInfo;
|
|||
import android.view.inputmethod.InputMethodSubtype;
|
||||
import android.view.textservice.SuggestionsInfo;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
|
||||
import org.dslul.openboard.inputmethod.keyboard.Keyboard;
|
||||
import org.dslul.openboard.inputmethod.keyboard.KeyboardId;
|
||||
import org.dslul.openboard.inputmethod.keyboard.KeyboardLayoutSet;
|
||||
|
@ -45,8 +47,6 @@ import java.util.concurrent.ConcurrentHashMap;
|
|||
import java.util.concurrent.ConcurrentLinkedQueue;
|
||||
import java.util.concurrent.Semaphore;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
/**
|
||||
* Service for spell checking, using LatinIME's dictionaries and mechanisms.
|
||||
*/
|
||||
|
@ -178,7 +178,7 @@ public final class AndroidSpellCheckerService extends SpellCheckerService
|
|||
|
||||
public SuggestionResults getSuggestionResults(final Locale locale,
|
||||
final ComposedData composedData, final NgramContext ngramContext,
|
||||
@Nonnull final Keyboard keyboard) {
|
||||
@NonNull final Keyboard keyboard) {
|
||||
Integer sessionId = null;
|
||||
mSemaphore.acquireUninterruptibly();
|
||||
try {
|
||||
|
|
|
@ -43,6 +43,9 @@ import android.view.ViewGroup;
|
|||
import android.widget.LinearLayout;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
import org.dslul.openboard.inputmethod.accessibility.AccessibilityUtils;
|
||||
import org.dslul.openboard.inputmethod.annotations.UsedForTesting;
|
||||
import org.dslul.openboard.inputmethod.latin.PunctuationSuggestions;
|
||||
|
@ -57,9 +60,6 @@ import org.dslul.openboard.inputmethod.latin.utils.ViewLayoutUtils;
|
|||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
final class SuggestionStripLayoutHelper {
|
||||
private static final int DEFAULT_SUGGESTIONS_COUNT_IN_STRIP = 3;
|
||||
private static final float DEFAULT_CENTER_SUGGESTION_PERCENTILE = 0.40f;
|
||||
|
@ -570,7 +570,7 @@ final class SuggestionStripLayoutHelper {
|
|||
|
||||
@Nullable
|
||||
private static CharSequence getEllipsizedTextWithSettingScaleX(
|
||||
@Nullable final CharSequence text, final int maxWidth, @Nonnull final TextPaint paint) {
|
||||
@Nullable final CharSequence text, final int maxWidth, @NonNull final TextPaint paint) {
|
||||
if (text == null) {
|
||||
return null;
|
||||
}
|
||||
|
@ -610,7 +610,7 @@ final class SuggestionStripLayoutHelper {
|
|||
return false;
|
||||
}
|
||||
|
||||
private static void addStyleSpan(@Nonnull final Spannable text, final CharacterStyle style) {
|
||||
private static void addStyleSpan(@NonNull final Spannable text, final CharacterStyle style) {
|
||||
text.removeSpan(style);
|
||||
text.setSpan(style, 0, text.length(), Spanned.SPAN_INCLUSIVE_EXCLUSIVE);
|
||||
}
|
||||
|
|
|
@ -26,6 +26,8 @@ import android.text.TextUtils;
|
|||
import android.view.View;
|
||||
import android.widget.EditText;
|
||||
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
import org.dslul.openboard.inputmethod.latin.R;
|
||||
import org.dslul.openboard.inputmethod.latin.common.LocaleUtils;
|
||||
|
||||
|
@ -33,8 +35,6 @@ import java.util.ArrayList;
|
|||
import java.util.Locale;
|
||||
import java.util.TreeSet;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
// Caveat: This class is basically taken from
|
||||
// packages/apps/Settings/src/com/android/settings/inputmethod/UserDictionaryAddWordContents.java
|
||||
// in order to deal with some devices that have issues with the user dictionary handling
|
||||
|
|
|
@ -31,6 +31,8 @@ import android.view.inputmethod.InputMethodInfo;
|
|||
import android.view.inputmethod.InputMethodManager;
|
||||
import android.view.inputmethod.InputMethodSubtype;
|
||||
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
import org.dslul.openboard.inputmethod.latin.R;
|
||||
import org.dslul.openboard.inputmethod.latin.common.LocaleUtils;
|
||||
|
||||
|
@ -38,8 +40,6 @@ import java.util.List;
|
|||
import java.util.Locale;
|
||||
import java.util.TreeSet;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
// Caveat: This class is basically taken from
|
||||
// packages/apps/Settings/src/com/android/settings/inputmethod/UserDictionaryList.java
|
||||
// in order to deal with some devices that have issues with the user dictionary handling
|
||||
|
|
|
@ -30,10 +30,10 @@ import android.view.ViewParent;
|
|||
import android.view.inputmethod.CursorAnchorInfo;
|
||||
import android.widget.TextView;
|
||||
|
||||
import org.dslul.openboard.inputmethod.compat.CursorAnchorInfoCompatWrapper;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
import org.dslul.openboard.inputmethod.compat.CursorAnchorInfoCompatWrapper;
|
||||
|
||||
/**
|
||||
* This class allows input methods to extract {@link CursorAnchorInfo} directly from the given
|
||||
|
@ -94,7 +94,7 @@ public final class CursorAnchorInfoUtils {
|
|||
*/
|
||||
@Nullable
|
||||
public static CursorAnchorInfoCompatWrapper extractFromTextView(
|
||||
@Nonnull final TextView textView) {
|
||||
@NonNull final TextView textView) {
|
||||
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) {
|
||||
return null;
|
||||
}
|
||||
|
@ -109,7 +109,7 @@ public final class CursorAnchorInfoUtils {
|
|||
*/
|
||||
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
|
||||
@Nullable
|
||||
private static CursorAnchorInfo extractFromTextViewInternal(@Nonnull final TextView textView) {
|
||||
private static CursorAnchorInfo extractFromTextViewInternal(@NonNull final TextView textView) {
|
||||
final Layout layout = textView.getLayout();
|
||||
if (layout == null) {
|
||||
return null;
|
||||
|
|
|
@ -24,6 +24,9 @@ import android.text.TextUtils;
|
|||
import android.util.Log;
|
||||
import android.view.inputmethod.InputMethodSubtype;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
import com.android.inputmethod.latin.utils.BinaryDictionaryUtils;
|
||||
|
||||
import org.dslul.openboard.inputmethod.annotations.UsedForTesting;
|
||||
|
@ -45,9 +48,6 @@ import java.util.List;
|
|||
import java.util.Locale;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
/**
|
||||
* This class encapsulates the logic for the Latin-IME side of dictionary information management.
|
||||
*/
|
||||
|
@ -70,15 +70,15 @@ public class DictionaryInfoUtils {
|
|||
private static final String FILESIZE_COLUMN = "filesize";
|
||||
private static final String VERSION_COLUMN = "version";
|
||||
|
||||
@Nonnull public final String mId;
|
||||
@Nonnull public final Locale mLocale;
|
||||
@NonNull public final String mId;
|
||||
@NonNull public final Locale mLocale;
|
||||
@Nullable public final String mDescription;
|
||||
@Nullable public final String mFilename;
|
||||
public final long mFilesize;
|
||||
public final long mModifiedTimeMillis;
|
||||
public final int mVersion;
|
||||
|
||||
public DictionaryInfo(@Nonnull String id, @Nonnull Locale locale,
|
||||
public DictionaryInfo(@NonNull String id, @NonNull Locale locale,
|
||||
@Nullable String description, @Nullable String filename,
|
||||
long filesize, long modifiedTimeMillis, int version) {
|
||||
mId = id;
|
||||
|
@ -175,8 +175,8 @@ public class DictionaryInfoUtils {
|
|||
/**
|
||||
* Reverse escaping done by {@link #replaceFileNameDangerousCharacters(String)}.
|
||||
*/
|
||||
@Nonnull
|
||||
public static String getWordListIdFromFileName(@Nonnull final String fname) {
|
||||
@NonNull
|
||||
public static String getWordListIdFromFileName(@NonNull final String fname) {
|
||||
final StringBuilder sb = new StringBuilder();
|
||||
final int fnameLength = fname.length();
|
||||
for (int i = 0; i < fnameLength; i = fname.offsetByCodePoints(i, 1)) {
|
||||
|
@ -213,7 +213,7 @@ public class DictionaryInfoUtils {
|
|||
* @return The category as a string or null if it can't be found in the file name.
|
||||
*/
|
||||
@Nullable
|
||||
public static String getCategoryFromFileName(@Nonnull final String fileName) {
|
||||
public static String getCategoryFromFileName(@NonNull final String fileName) {
|
||||
final String id = getWordListIdFromFileName(fileName);
|
||||
final String[] idArray = id.split(DICTIONARY_CATEGORY_SEPARATOR_EXPRESSION);
|
||||
// An id is supposed to be in format category:locale, so splitting on the separator
|
||||
|
@ -317,7 +317,7 @@ public class DictionaryInfoUtils {
|
|||
* unique ID to them. This ID is just the name of the language (locale-wise) they
|
||||
* are for, and this method returns this ID.
|
||||
*/
|
||||
public static String getMainDictId(@Nonnull final Locale locale) {
|
||||
public static String getMainDictId(@NonNull final Locale locale) {
|
||||
// This works because we don't include by default different dictionaries for
|
||||
// different countries. This actually needs to return the id that we would
|
||||
// like to use for word lists included in resources, and the following is okay.
|
||||
|
@ -325,7 +325,7 @@ public class DictionaryInfoUtils {
|
|||
BinaryDictionaryGetter.ID_CATEGORY_SEPARATOR + locale.toString().toLowerCase();
|
||||
}
|
||||
|
||||
public static String getMainDictFilename(@Nonnull final String locale) {
|
||||
public static String getMainDictFilename(@NonNull final String locale) {
|
||||
return MAIN_DICT_PREFIX + locale.toLowerCase(Locale.ENGLISH) + ".dict";
|
||||
}
|
||||
|
||||
|
@ -351,7 +351,7 @@ public class DictionaryInfoUtils {
|
|||
* @return information of the specified dictionary.
|
||||
*/
|
||||
private static DictionaryInfo createDictionaryInfoFromFileAddress(
|
||||
@Nonnull final AssetFileAddress fileAddress, final Locale locale) {
|
||||
@NonNull final AssetFileAddress fileAddress, final Locale locale) {
|
||||
final String id = getMainDictId(locale);
|
||||
final int version = DictionaryHeaderUtils.getContentVersion(fileAddress);
|
||||
final String description = SubtypeLocaleUtils
|
||||
|
@ -371,7 +371,7 @@ public class DictionaryInfoUtils {
|
|||
*/
|
||||
@Nullable
|
||||
private static DictionaryInfo createDictionaryInfoForUnCachedFile(
|
||||
@Nonnull final AssetFileAddress fileAddress, final Locale locale) {
|
||||
@NonNull final AssetFileAddress fileAddress, final Locale locale) {
|
||||
final String id = getMainDictId(locale);
|
||||
final int version = DictionaryHeaderUtils.getContentVersion(fileAddress);
|
||||
|
||||
|
|
|
@ -18,14 +18,14 @@ package org.dslul.openboard.inputmethod.latin.utils;
|
|||
|
||||
import android.view.inputmethod.InputMethodSubtype;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
|
||||
import org.dslul.openboard.inputmethod.latin.RichInputMethodSubtype;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
/**
|
||||
* This class determines that the language name on the spacebar should be displayed in what format.
|
||||
*/
|
||||
|
@ -42,7 +42,7 @@ public final class LanguageOnSpacebarUtils {
|
|||
}
|
||||
|
||||
public static int getLanguageOnSpacebarFormatType(
|
||||
@Nonnull final RichInputMethodSubtype subtype) {
|
||||
@NonNull final RichInputMethodSubtype subtype) {
|
||||
if (subtype.isNoLanguage()) {
|
||||
return FORMAT_TYPE_FULL_LOCALE;
|
||||
}
|
||||
|
@ -70,12 +70,12 @@ public final class LanguageOnSpacebarUtils {
|
|||
: FORMAT_TYPE_LANGUAGE_ONLY;
|
||||
}
|
||||
|
||||
public static void setEnabledSubtypes(@Nonnull final List<InputMethodSubtype> enabledSubtypes) {
|
||||
public static void setEnabledSubtypes(@NonNull final List<InputMethodSubtype> enabledSubtypes) {
|
||||
sEnabledSubtypes = enabledSubtypes;
|
||||
}
|
||||
|
||||
public static void onSubtypeChanged(@Nonnull final RichInputMethodSubtype subtype,
|
||||
final boolean implicitlyEnabledSubtype, @Nonnull final Locale systemLocale) {
|
||||
public static void onSubtypeChanged(@NonNull final RichInputMethodSubtype subtype,
|
||||
final boolean implicitlyEnabledSubtype, @NonNull final Locale systemLocale) {
|
||||
final Locale newLocale = subtype.getLocale();
|
||||
if (systemLocale.equals(newLocale)) {
|
||||
sIsSystemLanguageSameAsInputLanguage = true;
|
||||
|
|
|
@ -19,19 +19,19 @@ package org.dslul.openboard.inputmethod.latin.utils;
|
|||
import android.os.Handler;
|
||||
import android.os.Looper;
|
||||
|
||||
import java.lang.ref.WeakReference;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
import java.lang.ref.WeakReference;
|
||||
|
||||
public class LeakGuardHandlerWrapper<T> extends Handler {
|
||||
private final WeakReference<T> mOwnerInstanceRef;
|
||||
|
||||
public LeakGuardHandlerWrapper(@Nonnull final T ownerInstance) {
|
||||
public LeakGuardHandlerWrapper(@NonNull final T ownerInstance) {
|
||||
this(ownerInstance, Looper.myLooper());
|
||||
}
|
||||
|
||||
public LeakGuardHandlerWrapper(@Nonnull final T ownerInstance, final Looper looper) {
|
||||
public LeakGuardHandlerWrapper(@NonNull final T ownerInstance, final Looper looper) {
|
||||
super(looper);
|
||||
mOwnerInstanceRef = new WeakReference<>(ownerInstance);
|
||||
}
|
||||
|
|
|
@ -16,6 +16,8 @@
|
|||
|
||||
package org.dslul.openboard.inputmethod.latin.utils;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
|
||||
import org.dslul.openboard.inputmethod.latin.NgramContext;
|
||||
import org.dslul.openboard.inputmethod.latin.NgramContext.WordInfo;
|
||||
import org.dslul.openboard.inputmethod.latin.define.DecoderSpecificConstants;
|
||||
|
@ -24,8 +26,6 @@ import org.dslul.openboard.inputmethod.latin.settings.SpacingAndPunctuations;
|
|||
import java.util.Arrays;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
public final class NgramContextUtils {
|
||||
private NgramContextUtils() {
|
||||
// Intentional empty constructor for utility class.
|
||||
|
@ -55,7 +55,7 @@ public final class NgramContextUtils {
|
|||
// (n = 2) "abc|" -> beginning-of-sentence
|
||||
// (n = 2) "abc |" -> beginning-of-sentence
|
||||
// (n = 2) "abc. def|" -> beginning-of-sentence
|
||||
@Nonnull
|
||||
@NonNull
|
||||
public static NgramContext getNgramContextFromNthPreviousWord(final CharSequence prev,
|
||||
final SpacingAndPunctuations spacingAndPunctuations, final int n) {
|
||||
if (prev == null) return NgramContext.EMPTY_PREV_WORDS_INFO;
|
||||
|
|
|
@ -28,13 +28,13 @@ import org.dslul.openboard.inputmethod.latin.common.StringUtils;
|
|||
import java.util.HashMap;
|
||||
import java.util.Locale;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import static org.dslul.openboard.inputmethod.latin.common.Constants.Subtype.ExtraValue.COMBINING_RULES;
|
||||
import static org.dslul.openboard.inputmethod.latin.common.Constants.Subtype.ExtraValue.KEYBOARD_LAYOUT_SET;
|
||||
import static org.dslul.openboard.inputmethod.latin.common.Constants.Subtype.ExtraValue.UNTRANSLATABLE_STRING_IN_SUBTYPE_NAME;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
/**
|
||||
* A helper class to deal with subtype locales.
|
||||
*/
|
||||
|
@ -170,8 +170,8 @@ public final class SubtypeLocaleUtils {
|
|||
return nameId == null ? UNKNOWN_KEYBOARD_LAYOUT : nameId;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
public static Locale getDisplayLocaleOfSubtypeLocale(@Nonnull final String localeString) {
|
||||
@NonNull
|
||||
public static Locale getDisplayLocaleOfSubtypeLocale(@NonNull final String localeString) {
|
||||
if (NO_LANGUAGE.equals(localeString)) {
|
||||
return sResources.getConfiguration().locale;
|
||||
}
|
||||
|
@ -182,19 +182,19 @@ public final class SubtypeLocaleUtils {
|
|||
}
|
||||
|
||||
public static String getSubtypeLocaleDisplayNameInSystemLocale(
|
||||
@Nonnull final String localeString) {
|
||||
@NonNull final String localeString) {
|
||||
final Locale displayLocale = sResources.getConfiguration().locale;
|
||||
return getSubtypeLocaleDisplayNameInternal(localeString, displayLocale);
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
public static String getSubtypeLocaleDisplayName(@Nonnull final String localeString) {
|
||||
@NonNull
|
||||
public static String getSubtypeLocaleDisplayName(@NonNull final String localeString) {
|
||||
final Locale displayLocale = getDisplayLocaleOfSubtypeLocale(localeString);
|
||||
return getSubtypeLocaleDisplayNameInternal(localeString, displayLocale);
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
public static String getSubtypeLanguageDisplayName(@Nonnull final String localeString) {
|
||||
@NonNull
|
||||
public static String getSubtypeLanguageDisplayName(@NonNull final String localeString) {
|
||||
final Locale displayLocale = getDisplayLocaleOfSubtypeLocale(localeString);
|
||||
final String languageString;
|
||||
if (sExceptionalLocaleDisplayedInRootLocale.containsKey(localeString)) {
|
||||
|
@ -205,9 +205,9 @@ public final class SubtypeLocaleUtils {
|
|||
return getSubtypeLocaleDisplayNameInternal(languageString, displayLocale);
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
private static String getSubtypeLocaleDisplayNameInternal(@Nonnull final String localeString,
|
||||
@Nonnull final Locale displayLocale) {
|
||||
@NonNull
|
||||
private static String getSubtypeLocaleDisplayNameInternal(@NonNull final String localeString,
|
||||
@NonNull final Locale displayLocale) {
|
||||
if (NO_LANGUAGE.equals(localeString)) {
|
||||
// No language subtype should be displayed in system locale.
|
||||
return sResources.getString(R.string.subtype_no_language);
|
||||
|
@ -256,23 +256,23 @@ public final class SubtypeLocaleUtils {
|
|||
// en_US azerty T English (US) (AZERTY) exception
|
||||
// zz azerty T Alphabet (AZERTY) in system locale
|
||||
|
||||
@Nonnull
|
||||
private static String getReplacementString(@Nonnull final InputMethodSubtype subtype,
|
||||
@Nonnull final Locale displayLocale) {
|
||||
@NonNull
|
||||
private static String getReplacementString(@NonNull final InputMethodSubtype subtype,
|
||||
@NonNull final Locale displayLocale) {
|
||||
if (subtype.containsExtraValueKey(UNTRANSLATABLE_STRING_IN_SUBTYPE_NAME)) {
|
||||
return subtype.getExtraValueOf(UNTRANSLATABLE_STRING_IN_SUBTYPE_NAME);
|
||||
}
|
||||
return getSubtypeLocaleDisplayNameInternal(subtype.getLocale(), displayLocale);
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@NonNull
|
||||
public static String getSubtypeDisplayNameInSystemLocale(
|
||||
@Nonnull final InputMethodSubtype subtype) {
|
||||
@NonNull final InputMethodSubtype subtype) {
|
||||
final Locale displayLocale = sResources.getConfiguration().locale;
|
||||
return getSubtypeDisplayNameInternal(subtype, displayLocale);
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@NonNull
|
||||
public static String getSubtypeNameForLogging(@Nullable final InputMethodSubtype subtype) {
|
||||
if (subtype == null) {
|
||||
return "<null subtype>";
|
||||
|
@ -280,9 +280,9 @@ public final class SubtypeLocaleUtils {
|
|||
return getSubtypeLocale(subtype) + "/" + getKeyboardLayoutSetName(subtype);
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
private static String getSubtypeDisplayNameInternal(@Nonnull final InputMethodSubtype subtype,
|
||||
@Nonnull final Locale displayLocale) {
|
||||
@NonNull
|
||||
private static String getSubtypeDisplayNameInternal(@NonNull final InputMethodSubtype subtype,
|
||||
@NonNull final Locale displayLocale) {
|
||||
final String replacementString = getReplacementString(subtype, displayLocale);
|
||||
// TODO: rework this for multi-lingual subtypes
|
||||
final int nameResId = subtype.getNameResId();
|
||||
|
@ -307,25 +307,25 @@ public final class SubtypeLocaleUtils {
|
|||
getSubtypeName.runInLocale(sResources, displayLocale), displayLocale);
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
public static Locale getSubtypeLocale(@Nonnull final InputMethodSubtype subtype) {
|
||||
@NonNull
|
||||
public static Locale getSubtypeLocale(@NonNull final InputMethodSubtype subtype) {
|
||||
final String localeString = subtype.getLocale();
|
||||
return LocaleUtils.constructLocaleFromString(localeString);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public static String getKeyboardLayoutSetDisplayName(
|
||||
@Nonnull final InputMethodSubtype subtype) {
|
||||
@NonNull final InputMethodSubtype subtype) {
|
||||
final String layoutName = getKeyboardLayoutSetName(subtype);
|
||||
return getKeyboardLayoutSetDisplayName(layoutName);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public static String getKeyboardLayoutSetDisplayName(@Nonnull final String layoutName) {
|
||||
public static String getKeyboardLayoutSetDisplayName(@NonNull final String layoutName) {
|
||||
return sKeyboardLayoutToDisplayNameMap.get(layoutName);
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@NonNull
|
||||
public static String getKeyboardLayoutSetName(final InputMethodSubtype subtype) {
|
||||
String keyboardLayoutSet = subtype.getExtraValueOf(KEYBOARD_LAYOUT_SET);
|
||||
if (keyboardLayoutSet == null) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue