aboutsummaryrefslogtreecommitdiffstats
path: root/java/src/com/android/inputmethod/latin/utils
diff options
context:
space:
mode:
Diffstat (limited to 'java/src/com/android/inputmethod/latin/utils')
-rw-r--r--java/src/com/android/inputmethod/latin/utils/AsyncResultHolder.java6
-rw-r--r--java/src/com/android/inputmethod/latin/utils/AutoCorrectionUtils.java1
-rw-r--r--java/src/com/android/inputmethod/latin/utils/CollectionUtils.java5
-rw-r--r--java/src/com/android/inputmethod/latin/utils/CursorAnchorInfoUtils.java3
-rw-r--r--java/src/com/android/inputmethod/latin/utils/DistracterFilterCheckingIsInDictionary.java5
-rw-r--r--java/src/com/android/inputmethod/latin/utils/ExecutorUtils.java6
-rw-r--r--java/src/com/android/inputmethod/latin/utils/LanguageModelParam.java1
-rw-r--r--java/src/com/android/inputmethod/latin/utils/NgramContextUtils.java6
-rw-r--r--java/src/com/android/inputmethod/latin/utils/SpannableStringUtils.java2
-rw-r--r--java/src/com/android/inputmethod/latin/utils/SubtypeLocaleUtils.java5
-rw-r--r--java/src/com/android/inputmethod/latin/utils/SuggestionResults.java3
11 files changed, 16 insertions, 27 deletions
diff --git a/java/src/com/android/inputmethod/latin/utils/AsyncResultHolder.java b/java/src/com/android/inputmethod/latin/utils/AsyncResultHolder.java
index d12aad639..952ac2a62 100644
--- a/java/src/com/android/inputmethod/latin/utils/AsyncResultHolder.java
+++ b/java/src/com/android/inputmethod/latin/utils/AsyncResultHolder.java
@@ -59,11 +59,7 @@ public class AsyncResultHolder<E> {
*/
public E get(final E defaultValue, final long timeOut) {
try {
- if (mLatch.await(timeOut, TimeUnit.MILLISECONDS)) {
- return mResult;
- } else {
- return defaultValue;
- }
+ return mLatch.await(timeOut, TimeUnit.MILLISECONDS) ? mResult : defaultValue;
} catch (InterruptedException e) {
return defaultValue;
}
diff --git a/java/src/com/android/inputmethod/latin/utils/AutoCorrectionUtils.java b/java/src/com/android/inputmethod/latin/utils/AutoCorrectionUtils.java
index cba769521..120cffbde 100644
--- a/java/src/com/android/inputmethod/latin/utils/AutoCorrectionUtils.java
+++ b/java/src/com/android/inputmethod/latin/utils/AutoCorrectionUtils.java
@@ -24,7 +24,6 @@ import com.android.inputmethod.latin.define.DebugFlags;
public final class AutoCorrectionUtils {
private static final boolean DBG = DebugFlags.DEBUG_ENABLED;
private static final String TAG = AutoCorrectionUtils.class.getSimpleName();
- private static final int MINIMUM_SAFETY_NET_CHAR_LENGTH = 4;
private AutoCorrectionUtils() {
// Purely static class: can't instantiate.
diff --git a/java/src/com/android/inputmethod/latin/utils/CollectionUtils.java b/java/src/com/android/inputmethod/latin/utils/CollectionUtils.java
index fb36b7c50..d0df72479 100644
--- a/java/src/com/android/inputmethod/latin/utils/CollectionUtils.java
+++ b/java/src/com/android/inputmethod/latin/utils/CollectionUtils.java
@@ -18,9 +18,6 @@ package com.android.inputmethod.latin.utils;
import java.util.ArrayList;
import java.util.Collection;
-import java.util.Collections;
-import java.util.Map;
-import java.util.TreeMap;
public final class CollectionUtils {
private CollectionUtils() {
@@ -47,7 +44,7 @@ public final class CollectionUtils {
* @param c Collection to test.
* @return Whether c contains no elements.
*/
- public static boolean isNullOrEmpty(final Collection c) {
+ public static boolean isNullOrEmpty(final Collection<?> c) {
return c == null || c.isEmpty();
}
}
diff --git a/java/src/com/android/inputmethod/latin/utils/CursorAnchorInfoUtils.java b/java/src/com/android/inputmethod/latin/utils/CursorAnchorInfoUtils.java
index e05618901..6c1449cee 100644
--- a/java/src/com/android/inputmethod/latin/utils/CursorAnchorInfoUtils.java
+++ b/java/src/com/android/inputmethod/latin/utils/CursorAnchorInfoUtils.java
@@ -24,6 +24,7 @@ import android.inputmethodservice.InputMethodService;
import android.os.Build;
import android.text.Layout;
import android.text.Spannable;
+import android.text.Spanned;
import android.view.View;
import android.view.ViewParent;
import android.view.inputmethod.CursorAnchorInfo;
@@ -149,7 +150,7 @@ public final class CursorAnchorInfoUtils {
final Object[] spans = spannable.getSpans(0, text.length(), Object.class);
for (Object span : spans) {
final int spanFlag = spannable.getSpanFlags(span);
- if ((spanFlag & Spannable.SPAN_COMPOSING) != 0) {
+ if ((spanFlag & Spanned.SPAN_COMPOSING) != 0) {
composingTextStart = Math.min(composingTextStart,
spannable.getSpanStart(span));
composingTextEnd = Math.max(composingTextEnd, spannable.getSpanEnd(span));
diff --git a/java/src/com/android/inputmethod/latin/utils/DistracterFilterCheckingIsInDictionary.java b/java/src/com/android/inputmethod/latin/utils/DistracterFilterCheckingIsInDictionary.java
index df6e97028..4c99fed9f 100644
--- a/java/src/com/android/inputmethod/latin/utils/DistracterFilterCheckingIsInDictionary.java
+++ b/java/src/com/android/inputmethod/latin/utils/DistracterFilterCheckingIsInDictionary.java
@@ -41,10 +41,9 @@ public class DistracterFilterCheckingIsInDictionary implements DistracterFilter
// This filter treats entries that are already in the dictionary as non-distracters
// because they have passed the filtering in the past.
return false;
- } else {
- return mDistracterFilter.isDistracterToWordsInDictionaries(
- ngramContext, testedWord, locale);
}
+ return mDistracterFilter.isDistracterToWordsInDictionaries(
+ ngramContext, testedWord, locale);
}
@Override
diff --git a/java/src/com/android/inputmethod/latin/utils/ExecutorUtils.java b/java/src/com/android/inputmethod/latin/utils/ExecutorUtils.java
index 61da1b789..e77f6fd40 100644
--- a/java/src/com/android/inputmethod/latin/utils/ExecutorUtils.java
+++ b/java/src/com/android/inputmethod/latin/utils/ExecutorUtils.java
@@ -27,7 +27,7 @@ import java.util.concurrent.ThreadFactory;
* Utilities to manage executors.
*/
public class ExecutorUtils {
- private static final ConcurrentHashMap<String, ExecutorService> sExecutorMap =
+ static final ConcurrentHashMap<String, ExecutorService> sExecutorMap =
new ConcurrentHashMap<>();
private static class ThreadFactoryWithId implements ThreadFactory {
@@ -49,7 +49,7 @@ public class ExecutorUtils {
public static ExecutorService getExecutor(final String id) {
ExecutorService executor = sExecutorMap.get(id);
if (executor == null) {
- synchronized(sExecutorMap) {
+ synchronized (sExecutorMap) {
executor = sExecutorMap.get(id);
if (executor == null) {
executor = Executors.newSingleThreadExecutor(new ThreadFactoryWithId(id));
@@ -65,7 +65,7 @@ public class ExecutorUtils {
*/
@UsedForTesting
public static void shutdownAllExecutors() {
- synchronized(sExecutorMap) {
+ synchronized (sExecutorMap) {
for (final ExecutorService executor : sExecutorMap.values()) {
executor.execute(new Runnable() {
@Override
diff --git a/java/src/com/android/inputmethod/latin/utils/LanguageModelParam.java b/java/src/com/android/inputmethod/latin/utils/LanguageModelParam.java
index 5560d2f36..3e5cb33ca 100644
--- a/java/src/com/android/inputmethod/latin/utils/LanguageModelParam.java
+++ b/java/src/com/android/inputmethod/latin/utils/LanguageModelParam.java
@@ -20,7 +20,6 @@ import android.util.Log;
import com.android.inputmethod.annotations.UsedForTesting;
import com.android.inputmethod.latin.Dictionary;
-import com.android.inputmethod.latin.DictionaryFacilitator;
import com.android.inputmethod.latin.NgramContext;
import com.android.inputmethod.latin.settings.SpacingAndPunctuations;
import com.android.inputmethod.latin.utils.DistracterFilter.HandlingType;
diff --git a/java/src/com/android/inputmethod/latin/utils/NgramContextUtils.java b/java/src/com/android/inputmethod/latin/utils/NgramContextUtils.java
index 34eeac2c2..95a1f0fb2 100644
--- a/java/src/com/android/inputmethod/latin/utils/NgramContextUtils.java
+++ b/java/src/com/android/inputmethod/latin/utils/NgramContextUtils.java
@@ -74,20 +74,20 @@ public final class NgramContextUtils {
}
// If we can't find (n + i) words, the context is beginning-of-sentence.
if (focusedWordIndex < 0) {
- prevWordsInfo[i] = WordInfo.BEGINNING_OF_SENTENCE;
+ prevWordsInfo[i] = WordInfo.BEGINNING_OF_SENTENCE_WORD_INFO;
break;
}
final String focusedWord = w[focusedWordIndex];
// If the word is, the context is beginning-of-sentence.
final int length = focusedWord.length();
if (length <= 0) {
- prevWordsInfo[i] = WordInfo.BEGINNING_OF_SENTENCE;
+ prevWordsInfo[i] = WordInfo.BEGINNING_OF_SENTENCE_WORD_INFO;
break;
}
// If ends in a sentence separator, the context is beginning-of-sentence.
final char lastChar = focusedWord.charAt(length - 1);
if (spacingAndPunctuations.isSentenceSeparator(lastChar)) {
- prevWordsInfo[i] = WordInfo.BEGINNING_OF_SENTENCE;
+ prevWordsInfo[i] = WordInfo.BEGINNING_OF_SENTENCE_WORD_INFO;
break;
}
// If ends in a word separator or connector, the context is unclear.
diff --git a/java/src/com/android/inputmethod/latin/utils/SpannableStringUtils.java b/java/src/com/android/inputmethod/latin/utils/SpannableStringUtils.java
index 38164cb36..cea1d1d58 100644
--- a/java/src/com/android/inputmethod/latin/utils/SpannableStringUtils.java
+++ b/java/src/com/android/inputmethod/latin/utils/SpannableStringUtils.java
@@ -51,7 +51,7 @@ public final class SpannableStringUtils {
// of a word. But the spans have been split into two by the getText{Before,After}Cursor
// methods, so after concatenation they may end in the middle of a word.
// Since we don't use them, we can just remove them and avoid crashing.
- fl &= ~Spannable.SPAN_PARAGRAPH;
+ fl &= ~Spanned.SPAN_PARAGRAPH;
int st = source.getSpanStart(spans[i]);
int en = source.getSpanEnd(spans[i]);
diff --git a/java/src/com/android/inputmethod/latin/utils/SubtypeLocaleUtils.java b/java/src/com/android/inputmethod/latin/utils/SubtypeLocaleUtils.java
index 61661cd52..352d6cdef 100644
--- a/java/src/com/android/inputmethod/latin/utils/SubtypeLocaleUtils.java
+++ b/java/src/com/android/inputmethod/latin/utils/SubtypeLocaleUtils.java
@@ -39,7 +39,7 @@ import java.util.Locale;
*/
// TODO: consolidate this into RichInputMethodSubtype
public final class SubtypeLocaleUtils {
- private static final String TAG = SubtypeLocaleUtils.class.getSimpleName();
+ static final String TAG = SubtypeLocaleUtils.class.getSimpleName();
// This reference class {@link Constants} must be located in the same package as LatinIME.java.
private static final String RESOURCE_PACKAGE_NAME = Constants.class.getPackage().getName();
@@ -245,9 +245,8 @@ public final class SubtypeLocaleUtils {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN
&& subtype.containsExtraValueKey(UNTRANSLATABLE_STRING_IN_SUBTYPE_NAME)) {
return subtype.getExtraValueOf(UNTRANSLATABLE_STRING_IN_SUBTYPE_NAME);
- } else {
- return getSubtypeLocaleDisplayNameInternal(subtype.getLocale(), displayLocale);
}
+ return getSubtypeLocaleDisplayNameInternal(subtype.getLocale(), displayLocale);
}
public static String getSubtypeDisplayNameInSystemLocale(final InputMethodSubtype subtype) {
diff --git a/java/src/com/android/inputmethod/latin/utils/SuggestionResults.java b/java/src/com/android/inputmethod/latin/utils/SuggestionResults.java
index 4e2e396c2..b319aeb8a 100644
--- a/java/src/com/android/inputmethod/latin/utils/SuggestionResults.java
+++ b/java/src/com/android/inputmethod/latin/utils/SuggestionResults.java
@@ -66,8 +66,7 @@ public final class SuggestionResults extends TreeSet<SuggestedWordInfo> {
return super.addAll(e);
}
- private static final class SuggestedWordInfoComparator
- implements Comparator<SuggestedWordInfo> {
+ static final class SuggestedWordInfoComparator implements Comparator<SuggestedWordInfo> {
// This comparator ranks the word info with the higher frequency first. That's because
// that's the order we want our elements in.
@Override