aboutsummaryrefslogtreecommitdiffstats
path: root/java
diff options
context:
space:
mode:
Diffstat (limited to 'java')
-rw-r--r--java/res/values-fr/strings.xml6
-rw-r--r--java/res/values-ja/strings.xml2
-rw-r--r--java/res/values/dictionary-pack.xml23
-rw-r--r--java/res/values/donottranslate.xml2
-rw-r--r--java/src/com/android/inputmethod/latin/BinaryDictionaryFileDumper.java18
-rw-r--r--java/src/com/android/inputmethod/latin/DictionaryInfoUtils.java55
6 files changed, 84 insertions, 22 deletions
diff --git a/java/res/values-fr/strings.xml b/java/res/values-fr/strings.xml
index f20cd2d1b..c552a7f6c 100644
--- a/java/res/values-fr/strings.xml
+++ b/java/res/values-fr/strings.xml
@@ -125,12 +125,12 @@
<string name="keyboard_layout" msgid="8451164783510487501">"Thème du clavier"</string>
<string name="subtype_en_GB" msgid="88170601942311355">"Anglais (Royaume-Uni)"</string>
<string name="subtype_en_US" msgid="6160452336634534239">"Anglais (États-Unis)"</string>
- <string name="subtype_es_US" msgid="5583145191430180200">"Espagnol, États-Unis"</string>
+ <string name="subtype_es_US" msgid="5583145191430180200">"Espagnol (États-Unis)"</string>
<string name="subtype_with_layout_en_GB" msgid="2179097748724725906">"Anglais (Royaume-Uni) (<xliff:g id="LAYOUT">%s</xliff:g>)"</string>
<string name="subtype_with_layout_en_US" msgid="1362581347576714579">"Anglais (États-Unis) (<xliff:g id="LAYOUT">%s</xliff:g>)"</string>
- <string name="subtype_with_layout_es_US" msgid="6261791057007890189">"Espagnol, États-Unis (<xliff:g id="LAYOUT">%s</xliff:g>)"</string>
+ <string name="subtype_with_layout_es_US" msgid="6261791057007890189">"Espagnol (États-Unis) (<xliff:g id="LAYOUT">%s</xliff:g>)"</string>
<string name="subtype_no_language" msgid="141420857808801746">"Aucune langue"</string>
- <string name="subtype_no_language_qwerty" msgid="2956121451616633133">"Pas de langue (QWERTY)"</string>
+ <string name="subtype_no_language_qwerty" msgid="2956121451616633133">"Aucune langue (QWERTY)"</string>
<string name="subtype_no_language_qwertz" msgid="1177848172397202890">"Aucune langue (QWERTZ)"</string>
<string name="subtype_no_language_azerty" msgid="8721460968141187394">"Aucune langue (AZERTY)"</string>
<string name="subtype_no_language_dvorak" msgid="3122976737669823935">"Aucune langue (Dvorak)"</string>
diff --git a/java/res/values-ja/strings.xml b/java/res/values-ja/strings.xml
index 2c6a5e361..9aedb6d9a 100644
--- a/java/res/values-ja/strings.xml
+++ b/java/res/values-ja/strings.xml
@@ -45,7 +45,7 @@
<string name="key_preview_popup_dismiss_no_delay" msgid="2096123151571458064">"すぐに消去"</string>
<string name="key_preview_popup_dismiss_default_delay" msgid="2166964333903906734">"デフォルト"</string>
<string name="abbreviation_unit_milliseconds" msgid="8700286094028323363">"<xliff:g id="MILLISECONDS">%s</xliff:g>ミリ秒"</string>
- <string name="use_contacts_dict" msgid="4435317977804180815">"候補の連絡先名を表示"</string>
+ <string name="use_contacts_dict" msgid="4435317977804180815">"連絡先の名前を候補に表示"</string>
<string name="use_contacts_dict_summary" msgid="6599983334507879959">"連絡先の名前を使用して候補表示や自動修正を行います"</string>
<string name="use_double_space_period" msgid="8781529969425082860">"ダブルスペースピリオド"</string>
<string name="use_double_space_period_summary" msgid="6532892187247952799">"スペースバーをダブルタップするとピリオドとスペースを挿入できます"</string>
diff --git a/java/res/values/dictionary-pack.xml b/java/res/values/dictionary-pack.xml
new file mode 100644
index 000000000..8ed543c8a
--- /dev/null
+++ b/java/res/values/dictionary-pack.xml
@@ -0,0 +1,23 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+/*
+**
+** Copyright 2013, The Android Open Source Project
+**
+** Licensed under the Apache License, Version 2.0 (the "License");
+** you may not use this file except in compliance with the License.
+** You may obtain a copy of the License at
+**
+** http://www.apache.org/licenses/LICENSE-2.0
+**
+** Unless required by applicable law or agreed to in writing, software
+** distributed under the License is distributed on an "AS IS" BASIS,
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+** See the License for the specific language governing permissions and
+** limitations under the License.
+*/
+-->
+<resources xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
+ <string name="dictionary_pack_client_id">com.android.inputmethod.latin</string>
+ <string name="dictionary_pack_metadata_uri"></string>
+</resources>
diff --git a/java/res/values/donottranslate.xml b/java/res/values/donottranslate.xml
index bed3f70aa..edf615acc 100644
--- a/java/res/values/donottranslate.xml
+++ b/java/res/values/donottranslate.xml
@@ -213,7 +213,5 @@
<!-- dictionary pack package name /settings activity (for shared prefs and settings) -->
<string name="dictionary_pack_package_name">com.google.android.inputmethod.latin.dictionarypack</string>
<string name="dictionary_pack_settings_activity">com.google.android.inputmethod.latin.dictionarypack.DictionarySettingsActivity</string>
- <string name="dictionary_pack_client_id">com.android.inputmethod.latin</string>
- <string name="dictionary_pack_metadata_uri"></string>
<string name="settings_warning_researcher_mode">Attention! You are using the special keyboard for research purposes.</string>
</resources>
diff --git a/java/src/com/android/inputmethod/latin/BinaryDictionaryFileDumper.java b/java/src/com/android/inputmethod/latin/BinaryDictionaryFileDumper.java
index 8ade1ac52..4a8752e43 100644
--- a/java/src/com/android/inputmethod/latin/BinaryDictionaryFileDumper.java
+++ b/java/src/com/android/inputmethod/latin/BinaryDictionaryFileDumper.java
@@ -25,6 +25,8 @@ import android.net.Uri;
import android.text.TextUtils;
import android.util.Log;
+import com.android.inputmethod.latin.DictionaryInfoUtils.DictionaryInfo;
+
import java.io.BufferedInputStream;
import java.io.BufferedOutputStream;
import java.io.File;
@@ -33,6 +35,7 @@ import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.util.Arrays;
+import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Locale;
@@ -359,6 +362,19 @@ public final class BinaryDictionaryFileDumper {
metadataValues.put(INSERT_METADATA_CLIENT_ID_COLUMN, clientId);
metadataValues.put(INSERT_METADATA_METADATA_URI_COLUMN, metadataFileUri);
resolver.insert(metadataContentUri, metadataValues);
- // TODO: Update the versions of the dictionaries
+
+ // Update the dictionary list.
+ final Uri dictionaryContentUriBase = getProviderUriBuilder(clientId)
+ .appendPath(QUERY_PATH_DICT_INFO)
+ .appendQueryParameter(QUERY_PARAMETER_PROTOCOL, QUERY_PARAMETER_PROTOCOL_VALUE)
+ .build();
+ final ArrayList<DictionaryInfo> dictionaryList =
+ DictionaryInfoUtils.getCurrentDictionaryFileNameAndVersionInfo(context);
+ final int length = dictionaryList.size();
+ for (int i = 0; i < length; ++i) {
+ final DictionaryInfo info = dictionaryList.get(i);
+ resolver.insert(Uri.withAppendedPath(dictionaryContentUriBase, info.mId),
+ info.toContentValues());
+ }
}
}
diff --git a/java/src/com/android/inputmethod/latin/DictionaryInfoUtils.java b/java/src/com/android/inputmethod/latin/DictionaryInfoUtils.java
index 8f16a8e4d..d2a946bf5 100644
--- a/java/src/com/android/inputmethod/latin/DictionaryInfoUtils.java
+++ b/java/src/com/android/inputmethod/latin/DictionaryInfoUtils.java
@@ -16,9 +16,11 @@
package com.android.inputmethod.latin;
+import android.content.ContentValues;
import android.content.Context;
import android.content.res.AssetManager;
import android.content.res.Resources;
+import android.text.format.DateUtils;
import android.util.Log;
import com.android.inputmethod.latin.makedict.BinaryDictIOUtils;
@@ -39,19 +41,40 @@ public class DictionaryInfoUtils {
private static final String RESOURCE_PACKAGE_NAME =
DictionaryInfoUtils.class.getPackage().getName();
private static final String DEFAULT_MAIN_DICT = "main";
+ private static final String ID_CATEGORY_SEPARATOR =
+ BinaryDictionaryGetter.ID_CATEGORY_SEPARATOR;
private static final String MAIN_DICT_PREFIX = "main_";
// 6 digits - unicode is limited to 21 bits
private static final int MAX_HEX_DIGITS_FOR_CODEPOINT = 6;
public static class DictionaryInfo {
+ private static final String LOCALE_COLUMN = "locale";
+ private static final String WORDLISTID_COLUMN = "id";
+ private static final String LOCAL_FILENAME_COLUMN = "filename";
+ private static final String DATE_COLUMN = "date";
+ private static final String FILESIZE_COLUMN = "filesize";
+ private static final String VERSION_COLUMN = "version";
public final Locale mLocale;
public final AssetFileAddress mFileAddress;
public final int mVersion;
+ public final String mId;
public DictionaryInfo(final Locale locale, final AssetFileAddress fileAddress,
final int version) {
mLocale = locale;
mFileAddress = fileAddress;
mVersion = version;
+ mId = DEFAULT_MAIN_DICT + ID_CATEGORY_SEPARATOR + mLocale;
+ }
+ public ContentValues toContentValues() {
+ final ContentValues values = new ContentValues();
+ values.put(WORDLISTID_COLUMN, mId);
+ values.put(LOCALE_COLUMN, mLocale.toString());
+ values.put(LOCAL_FILENAME_COLUMN, mFileAddress.mFilename);
+ values.put(DATE_COLUMN,
+ new File(mFileAddress.mFilename).lastModified() / DateUtils.SECOND_IN_MILLIS);
+ values.put(FILESIZE_COLUMN, mFileAddress.mLength);
+ values.put(VERSION_COLUMN, mVersion);
+ return values;
}
}
@@ -284,21 +307,23 @@ public class DictionaryInfoUtils {
// Retrieve downloaded dictionaries
final File[] directoryList = getCachedDirectoryList(context);
- for (final File directory : directoryList) {
- final String localeString = getWordListIdFromFileName(directory.getName());
- File[] dicts = BinaryDictionaryGetter.getCachedWordLists(localeString, context);
- for (final File dict : dicts) {
- final String wordListId = getWordListIdFromFileName(dict.getName());
- if (!DictionaryInfoUtils.isMainWordListId(wordListId)) continue;
- final Locale locale = LocaleUtils.constructLocaleFromString(localeString);
- final AssetFileAddress fileAddress = AssetFileAddress.makeFromFile(dict);
- final DictionaryInfo dictionaryInfo =
- createDictionaryInfoFromFileAddress(fileAddress);
- // Protect against cases of a less-specific dictionary being found, like an
- // en dictionary being used for an en_US locale. In this case, the en dictionary
- // should be used for en_US but discounted for listing purposes.
- if (!dictionaryInfo.mLocale.equals(locale)) continue;
- addOrUpdateDictInfo(dictList, dictionaryInfo);
+ if (null != directoryList) {
+ for (final File directory : directoryList) {
+ final String localeString = getWordListIdFromFileName(directory.getName());
+ File[] dicts = BinaryDictionaryGetter.getCachedWordLists(localeString, context);
+ for (final File dict : dicts) {
+ final String wordListId = getWordListIdFromFileName(dict.getName());
+ if (!DictionaryInfoUtils.isMainWordListId(wordListId)) continue;
+ final Locale locale = LocaleUtils.constructLocaleFromString(localeString);
+ final AssetFileAddress fileAddress = AssetFileAddress.makeFromFile(dict);
+ final DictionaryInfo dictionaryInfo =
+ createDictionaryInfoFromFileAddress(fileAddress);
+ // Protect against cases of a less-specific dictionary being found, like an
+ // en dictionary being used for an en_US locale. In this case, the en dictionary
+ // should be used for en_US but discounted for listing purposes.
+ if (!dictionaryInfo.mLocale.equals(locale)) continue;
+ addOrUpdateDictInfo(dictList, dictionaryInfo);
+ }
}
}