From 18f91cf617462cf213818be5f0003512eb48a8be Mon Sep 17 00:00:00 2001 From: Keisuke Kuroyanagi Date: Wed, 26 Feb 2014 19:03:27 +0900 Subject: [PATCH] Add a method to create dict with additional attributes. Bug: 13197276 Change-Id: I80311a51d9e98bfeb8c0dd9cd4adde93af366d54 --- .../DecayingExpandableBinaryDictionaryBase.java | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/java/src/com/android/inputmethod/latin/personalization/DecayingExpandableBinaryDictionaryBase.java b/java/src/com/android/inputmethod/latin/personalization/DecayingExpandableBinaryDictionaryBase.java index d3734d693..8c358cd50 100644 --- a/java/src/com/android/inputmethod/latin/personalization/DecayingExpandableBinaryDictionaryBase.java +++ b/java/src/com/android/inputmethod/latin/personalization/DecayingExpandableBinaryDictionaryBase.java @@ -50,6 +50,7 @@ public abstract class DecayingExpandableBinaryDictionaryBase extends ExpandableB public final Locale mLocale; private final String mDictName; + private Map mAdditionalAttributeMap = null; protected DecayingExpandableBinaryDictionaryBase(final Context context, final String dictName, final Locale locale, final String dictionaryType, @@ -78,7 +79,10 @@ public abstract class DecayingExpandableBinaryDictionaryBase extends ExpandableB @Override protected Map getHeaderAttributeMap() { - HashMap attributeMap = new HashMap(); + final Map attributeMap = new HashMap(); + if (mAdditionalAttributeMap != null) { + attributeMap.putAll(mAdditionalAttributeMap); + } attributeMap.put(DictionaryHeader.USES_FORGETTING_CURVE_KEY, DictionaryHeader.ATTRIBUTE_VALUE_TRUE); attributeMap.put(DictionaryHeader.HAS_HISTORICAL_INFO_KEY, @@ -152,6 +156,13 @@ public abstract class DecayingExpandableBinaryDictionaryBase extends ExpandableB asyncFlushBinaryDictionary(); } + @UsedForTesting + public void clearAndFlushDictionaryWithAdditionalAttributes( + final Map attributeMap) { + mAdditionalAttributeMap = attributeMap; + clearAndFlushDictionary(); + } + /* package */ void decayIfNeeded() { runGCIfRequired(false /* mindsBlockByGC */); }