aboutsummaryrefslogtreecommitdiffstats
path: root/java/src/com/android/inputmethod/latin/DictionaryFactory.java
diff options
context:
space:
mode:
authorsatok <satok@google.com>2011-05-13 21:11:19 +0900
committersatok <satok@google.com>2011-05-13 21:11:19 +0900
commitdef6b35a9ed78d128d4cb5e8414c865503ec4192 (patch)
tree77491cd71b65419fa63d1aacc28288e7e9f8aa99 /java/src/com/android/inputmethod/latin/DictionaryFactory.java
parent55f38adab99937eef97626136f57520ebe9c04a9 (diff)
parent96e822c94c50c548d64e86e0c2c52022a63cc319 (diff)
downloadlatinime-def6b35a9ed78d128d4cb5e8414c865503ec4192.tar.gz
latinime-def6b35a9ed78d128d4cb5e8414c865503ec4192.tar.xz
latinime-def6b35a9ed78d128d4cb5e8414c865503ec4192.zip
Merge remote-tracking branch 'goog/master' into merge
Conflicts: java/res/xml/method.xml Change-Id: I455cb689f3a1baca7cc8b8ef88d9dbcdca8128a3
Diffstat (limited to 'java/src/com/android/inputmethod/latin/DictionaryFactory.java')
-rw-r--r--java/src/com/android/inputmethod/latin/DictionaryFactory.java19
1 files changed, 19 insertions, 0 deletions
diff --git a/java/src/com/android/inputmethod/latin/DictionaryFactory.java b/java/src/com/android/inputmethod/latin/DictionaryFactory.java
index 605676d70..bba331868 100644
--- a/java/src/com/android/inputmethod/latin/DictionaryFactory.java
+++ b/java/src/com/android/inputmethod/latin/DictionaryFactory.java
@@ -142,6 +142,25 @@ public class DictionaryFactory {
return hasDictionary;
}
+ // TODO: Do not use the size of the dictionary as an unique dictionary ID.
+ public static Long getDictionaryId(Context context, Locale locale) {
+ final Resources res = context.getResources();
+ final Locale saveLocale = Utils.setSystemLocale(res, locale);
+
+ final int resourceId = Utils.getMainDictionaryResourceId(res);
+ final AssetFileDescriptor afd = res.openRawResourceFd(resourceId);
+ final Long size = (afd != null && afd.getLength() > PLACEHOLDER_LENGTH)
+ ? afd.getLength()
+ : null;
+ try {
+ if (null != afd) afd.close();
+ } catch (java.io.IOException e) {
+ }
+
+ Utils.setSystemLocale(res, saveLocale);
+ return size;
+ }
+
// TODO: Find the Right Way to find out whether the resource is a placeholder or not.
// Suggestion : strip the locale, open the placeholder file and store its offset.
// Upon opening the file, if it's the same offset, then it's the placeholder.