aboutsummaryrefslogtreecommitdiffstats
path: root/java/src/com/android/inputmethod/latin/BinaryDictionaryFileDumper.java
diff options
context:
space:
mode:
authorJean Chalard <jchalard@google.com>2011-04-27 23:13:11 +0900
committerJean Chalard <jchalard@google.com>2011-04-28 16:16:46 +0900
commitd8f52a4f18d22aa150846b01017410ce70bbad6f (patch)
tree596b3ee1c0ea36647a234c5ecdd5aef0e3afe78e /java/src/com/android/inputmethod/latin/BinaryDictionaryFileDumper.java
parent3bf6fbb6b8765a90e19199e5dfeb7df26d04bb68 (diff)
downloadlatinime-d8f52a4f18d22aa150846b01017410ce70bbad6f.tar.gz
latinime-d8f52a4f18d22aa150846b01017410ce70bbad6f.tar.xz
latinime-d8f52a4f18d22aa150846b01017410ce70bbad6f.zip
Improve the architecture to support multiple dictionaries.
This change enables the interface to get multiple dictionaries from a dictionary pack. It only implements it to the end in the case of the proprietary method, as the open method needs still some working out, and the "inside the package" method does not need it. This change goes together with Iaa95bf36, and breaks the build without it. Bug: 1752028 Change-Id: I3ccfd696e8ef083ef9c074e1c3e4bb0bf2fcfd23
Diffstat (limited to 'java/src/com/android/inputmethod/latin/BinaryDictionaryFileDumper.java')
-rw-r--r--java/src/com/android/inputmethod/latin/BinaryDictionaryFileDumper.java21
1 files changed, 14 insertions, 7 deletions
diff --git a/java/src/com/android/inputmethod/latin/BinaryDictionaryFileDumper.java b/java/src/com/android/inputmethod/latin/BinaryDictionaryFileDumper.java
index a78ff7e84..76a230f82 100644
--- a/java/src/com/android/inputmethod/latin/BinaryDictionaryFileDumper.java
+++ b/java/src/com/android/inputmethod/latin/BinaryDictionaryFileDumper.java
@@ -28,6 +28,8 @@ import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
+import java.util.Arrays;
+import java.util.List;
import java.util.Locale;
/**
@@ -79,27 +81,32 @@ public class BinaryDictionaryFileDumper {
}
/**
- * Queries a content provider for dictionary data for some locale and returns it as a file name.
+ * Queries a content provider for dictionary data for some locale and returns the file addresses
*
* This will query a content provider for dictionary data for a given locale, and return
- * the name of a file suitable to be mmap'ed. It will copy it to local storage if needed.
- * It should also check the dictionary version to avoid unnecessary copies but this is
+ * the addresses of a file set the members of which are suitable to be mmap'ed. It will copy
+ * them to local storage if needed.
+ * It should also check the dictionary versions to avoid unnecessary copies but this is
* still in TODO state.
* This will make the data from the content provider the cached dictionary for this locale,
* overwriting any previous cached data.
- * @returns the name of the file, or null if no data could be obtained.
+ * @returns the addresses of the files, or null if no data could be obtained.
* @throw FileNotFoundException if the provider returns non-existent data.
* @throw IOException if the provider-returned data could not be read.
*/
- public static String getDictionaryFileFromContentProvider(Locale locale, Context context)
- throws FileNotFoundException, IOException {
+ public static List<AssetFileAddress> getDictSetFromContentProvider(Locale locale,
+ Context context) throws FileNotFoundException, IOException {
// TODO: check whether the dictionary is the same or not and if it is, return the cached
// file.
+ // TODO: This should be able to read a number of files from the dictionary pack, copy
+ // them all and return them.
final ContentResolver resolver = context.getContentResolver();
final Uri dictionaryPackUri = getProviderUri(locale);
final AssetFileDescriptor afd = resolver.openAssetFileDescriptor(dictionaryPackUri, "r");
if (null == afd) return null;
- return copyFileTo(afd.createInputStream(), getCacheFileNameForLocale(locale, context));
+ final String fileName =
+ copyFileTo(afd.createInputStream(), getCacheFileNameForLocale(locale, context));
+ return Arrays.asList(AssetFileAddress.makeFromFileName(fileName));
}
/**