diff options
Diffstat (limited to 'java')
4 files changed, 53 insertions, 6 deletions
diff --git a/java/AndroidManifest.xml b/java/AndroidManifest.xml index 7e77e77d1..f58c401c7 100644 --- a/java/AndroidManifest.xml +++ b/java/AndroidManifest.xml @@ -38,8 +38,7 @@ <application android:label="@string/english_ime_name" android:icon="@drawable/ic_launcher_keyboard" android:supportsRtl="true" - android:allowBackup="true" - android:usesCleartextTraffic="false"> + android:allowBackup="true"> <!-- Services --> <service android:name="LatinIME" diff --git a/java/src/com/android/inputmethod/latin/DictionaryStats.java b/java/src/com/android/inputmethod/latin/DictionaryStats.java index 19769717e..46eaff67f 100644 --- a/java/src/com/android/inputmethod/latin/DictionaryStats.java +++ b/java/src/com/android/inputmethod/latin/DictionaryStats.java @@ -31,6 +31,7 @@ public class DictionaryStats { public final String mDictFileName; public final long mDictFileSize; public final int mContentVersion; + public final int mWordCount; public DictionaryStats( @Nonnull final Locale locale, @@ -43,6 +44,19 @@ public class DictionaryStats { mDictFileSize = (dictFile == null || !dictFile.exists()) ? 0 : dictFile.length(); mDictFileName = dictFileName; mContentVersion = contentVersion; + mWordCount = -1; + } + + public DictionaryStats( + @Nonnull final Locale locale, + @Nonnull final String dictType, + final int wordCount) { + mLocale = locale; + mDictType = dictType; + mDictFileSize = wordCount; + mDictFileName = null; + mContentVersion = 0; + mWordCount = wordCount; } public String getFileSizeString() { @@ -67,9 +81,14 @@ public class DictionaryStats { builder.append(")"); } builder.append(": "); - builder.append(mDictFileName); - builder.append(" / "); - builder.append(getFileSizeString()); + if (mWordCount > -1) { + builder.append(mWordCount); + builder.append(" words"); + } else { + builder.append(mDictFileName); + builder.append(" / "); + builder.append(getFileSizeString()); + } return builder.toString(); } diff --git a/java/src/com/android/inputmethod/latin/UserDictionaryLookup.java b/java/src/com/android/inputmethod/latin/UserDictionaryLookup.java index 2569723b0..1eed3d79c 100644 --- a/java/src/com/android/inputmethod/latin/UserDictionaryLookup.java +++ b/java/src/com/android/inputmethod/latin/UserDictionaryLookup.java @@ -33,6 +33,7 @@ import com.android.inputmethod.latin.utils.ExecutorUtils; import java.io.Closeable; import java.util.ArrayList; import java.util.HashMap; +import java.util.List; import java.util.Locale; import java.util.concurrent.atomic.AtomicBoolean; import java.util.concurrent.ScheduledFuture; @@ -186,6 +187,8 @@ public class UserDictionaryLookup implements Closeable { */ private volatile ScheduledFuture<?> mReloadFuture; + private volatile List<DictionaryStats> mDictionaryStats; + /** * @param context the context from which to obtain content resolver */ @@ -195,11 +198,18 @@ public class UserDictionaryLookup implements Closeable { Log.i(mTag, "create()"); mServiceName = serviceName; + mDictionaryStats = new ArrayList<DictionaryStats>(); + mDictionaryStats.add(new DictionaryStats(ANY_LOCALE, Dictionary.TYPE_USER, 0)); + mDictionaryStats.add(new DictionaryStats(ANY_LOCALE, Dictionary.TYPE_USER_SHORTCUT, 0)); // Obtain a content resolver. mResolver = context.getContentResolver(); } + public List<DictionaryStats> getDictionaryStats() { + return mDictionaryStats; + } + public void open() { Log.i(mTag, "open()"); @@ -506,6 +516,15 @@ public class UserDictionaryLookup implements Closeable { } } + List<DictionaryStats> stats = new ArrayList<>(); + stats.add(new DictionaryStats(ANY_LOCALE, Dictionary.TYPE_USER, dictWords.size())); + int numShortcuts = 0; + for (HashMap<String, String> shortcuts : shortcutsPerLocale.values()) { + numShortcuts += shortcuts.size(); + } + stats.add(new DictionaryStats(ANY_LOCALE, Dictionary.TYPE_USER_SHORTCUT, numShortcuts)); + mDictionaryStats = stats; + // Atomically replace the copy of mDictWords and mShortcuts. mDictWords = dictWords; mShortcutsPerLocale = shortcutsPerLocale; @@ -513,6 +532,7 @@ public class UserDictionaryLookup implements Closeable { // Allow other calls to loadUserDictionary to execute now. mIsLoading.set(false); - Log.i(mTag, "loadUserDictionary() : Loaded " + mDictWords.size() + " words"); + Log.i(mTag, "loadUserDictionary() : Loaded " + mDictWords.size() + + " words and " + numShortcuts + " shortcuts"); } } diff --git a/java/src/com/android/inputmethod/latin/inputlogic/InputLogic.java b/java/src/com/android/inputmethod/latin/inputlogic/InputLogic.java index 9ceb37145..4bee94ad4 100644 --- a/java/src/com/android/inputmethod/latin/inputlogic/InputLogic.java +++ b/java/src/com/android/inputmethod/latin/inputlogic/InputLogic.java @@ -1420,6 +1420,11 @@ public final class InputLogic { public void performUpdateSuggestionStripSync(final SettingsValues settingsValues, final int inputStyle) { + long startTimeMillis = 0; + if (DebugFlags.DEBUG_ENABLED) { + startTimeMillis = System.currentTimeMillis(); + Log.d(TAG, "performUpdateSuggestionStripSync()"); + } // Check if we have a suggestion engine attached. if (!settingsValues.needsToLookupSuggestions()) { if (mWordComposer.isComposingWord()) { @@ -1466,6 +1471,10 @@ public final class InputLogic { if (suggestedWords != null) { mSuggestionStripViewAccessor.showSuggestionStrip(suggestedWords); } + if (DebugFlags.DEBUG_ENABLED) { + long runTimeMillis = System.currentTimeMillis() - startTimeMillis; + Log.d(TAG, "performUpdateSuggestionStripSync() : " + runTimeMillis + " ms to finish"); + } } /** |