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