aboutsummaryrefslogtreecommitdiffstats
path: root/java/src/com/android/inputmethod/latin
diff options
context:
space:
mode:
Diffstat (limited to 'java/src/com/android/inputmethod/latin')
-rw-r--r--java/src/com/android/inputmethod/latin/BinaryDictionaryFileDumper.java28
-rw-r--r--java/src/com/android/inputmethod/latin/BinaryDictionaryGetter.java15
-rw-r--r--java/src/com/android/inputmethod/latin/SettingsFragment.java5
-rw-r--r--java/src/com/android/inputmethod/latin/setup/SetupActivity.java11
4 files changed, 31 insertions, 28 deletions
diff --git a/java/src/com/android/inputmethod/latin/BinaryDictionaryFileDumper.java b/java/src/com/android/inputmethod/latin/BinaryDictionaryFileDumper.java
index 4a2c3bb80..a9b58de44 100644
--- a/java/src/com/android/inputmethod/latin/BinaryDictionaryFileDumper.java
+++ b/java/src/com/android/inputmethod/latin/BinaryDictionaryFileDumper.java
@@ -210,7 +210,7 @@ public final class BinaryDictionaryFileDumper {
* to the cache file name designated by its id and locale, overwriting it if already present
* and creating it (and its containing directory) if necessary.
*/
- private static AssetFileAddress cacheWordList(final String wordlistId, final String locale,
+ private static void cacheWordList(final String wordlistId, final String locale,
final ContentProviderClient providerClient, final Context context) {
final int COMPRESSED_CRYPTED_COMPRESSED = 0;
final int CRYPTED_COMPRESSED = 1;
@@ -228,7 +228,7 @@ public final class BinaryDictionaryFileDumper {
providerClient, QUERY_PATH_DATAFILE, wordlistId /* extraPath */);
} catch (RemoteException e) {
Log.e(TAG, "Can't communicate with the dictionary pack", e);
- return null;
+ return;
}
final String finalFileName =
DictionaryInfoUtils.getCacheFileName(wordlistId, locale, context);
@@ -237,11 +237,11 @@ public final class BinaryDictionaryFileDumper {
tempFileName = BinaryDictionaryGetter.getTempFileName(wordlistId, context);
} catch (IOException e) {
Log.e(TAG, "Can't open the temporary file", e);
- return null;
+ return;
}
for (int mode = MODE_MIN; mode <= MODE_MAX; ++mode) {
- InputStream originalSourceStream = null;
+ final InputStream originalSourceStream;
InputStream inputStream = null;
InputStream uncompressedStream = null;
InputStream decryptedStream = null;
@@ -254,7 +254,7 @@ public final class BinaryDictionaryFileDumper {
// Open input.
afd = openAssetFileDescriptor(providerClient, wordListUri);
// If we can't open it at all, don't even try a number of times.
- if (null == afd) return null;
+ if (null == afd) return;
originalSourceStream = afd.createInputStream();
// Open output.
outputFile = new File(tempFileName);
@@ -305,7 +305,7 @@ public final class BinaryDictionaryFileDumper {
}
BinaryDictionaryGetter.removeFilesWithIdExcept(context, wordlistId, finalFile);
// Success! Close files (through the finally{} clause) and return.
- return AssetFileAddress.makeFromFileName(finalFileName);
+ return;
} catch (Exception e) {
if (DEBUG) {
Log.i(TAG, "Can't open word list in mode " + mode, e);
@@ -320,7 +320,7 @@ public final class BinaryDictionaryFileDumper {
} finally {
// Ignore exceptions while closing files.
try {
- // inputStream.close() will close afd, we should not call afd.close().
+ if (null != afd) afd.close();
if (null != inputStream) inputStream.close();
if (null != uncompressedStream) uncompressedStream.close();
if (null != decryptedStream) decryptedStream.close();
@@ -350,7 +350,6 @@ public final class BinaryDictionaryFileDumper {
} catch (RemoteException e) {
Log.e(TAG, "In addition, communication with the dictionary provider was cut", e);
}
- return null;
}
/**
@@ -359,30 +358,23 @@ public final class BinaryDictionaryFileDumper {
* This will query a content provider for word list data for a given locale, and copy the
* files locally so that they can be mmap'ed. This may overwrite previously cached word lists
* with newer versions if a newer version is made available by the content provider.
- * @returns the addresses of the word list 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 List<AssetFileAddress> cacheWordListsFromContentProvider(final Locale locale,
+ public static void cacheWordListsFromContentProvider(final Locale locale,
final Context context, final boolean hasDefaultWordList) {
final ContentProviderClient providerClient = context.getContentResolver().
acquireContentProviderClient(getProviderUriBuilder("").build());
if (null == providerClient) {
Log.e(TAG, "Can't establish communication with the dictionary provider");
- return CollectionUtils.newArrayList();
+ return;
}
try {
final List<WordListInfo> idList = getWordListWordListInfos(locale, context,
hasDefaultWordList);
- final ArrayList<AssetFileAddress> fileAddressList = CollectionUtils.newArrayList();
for (WordListInfo id : idList) {
- final AssetFileAddress afd =
- cacheWordList(id.mId, id.mLocale, providerClient, context);
- if (null != afd) {
- fileAddressList.add(afd);
- }
+ cacheWordList(id.mId, id.mLocale, providerClient, context);
}
- return fileAddressList;
} finally {
providerClient.release();
}
diff --git a/java/src/com/android/inputmethod/latin/BinaryDictionaryGetter.java b/java/src/com/android/inputmethod/latin/BinaryDictionaryGetter.java
index ddd72f18e..98eadcacb 100644
--- a/java/src/com/android/inputmethod/latin/BinaryDictionaryGetter.java
+++ b/java/src/com/android/inputmethod/latin/BinaryDictionaryGetter.java
@@ -95,8 +95,16 @@ final class BinaryDictionaryGetter {
+ fallbackResId);
return null;
}
- return AssetFileAddress.makeFromFileNameAndOffset(
- context.getApplicationInfo().sourceDir, afd.getStartOffset(), afd.getLength());
+ try {
+ return AssetFileAddress.makeFromFileNameAndOffset(
+ context.getApplicationInfo().sourceDir, afd.getStartOffset(), afd.getLength());
+ } finally {
+ try {
+ afd.close();
+ } catch (IOException e) {
+ // Ignored
+ }
+ }
}
private static final class DictPackSettings {
@@ -282,9 +290,6 @@ final class BinaryDictionaryGetter {
final Context context) {
final boolean hasDefaultWordList = DictionaryFactory.isDictionaryAvailable(context, locale);
- // cacheWordListsFromContentProvider returns the list of files it copied to local
- // storage, but we don't really care about what was copied NOW: what we want is the
- // list of everything we ever cached, so we ignore the return value.
// TODO: The development-only-diagnostic version is not supported by the Dictionary Pack
// Service yet
if (!ProductionFlag.USES_DEVELOPMENT_ONLY_DIAGNOSTICS) {
diff --git a/java/src/com/android/inputmethod/latin/SettingsFragment.java b/java/src/com/android/inputmethod/latin/SettingsFragment.java
index 830cae9b8..835ef7b46 100644
--- a/java/src/com/android/inputmethod/latin/SettingsFragment.java
+++ b/java/src/com/android/inputmethod/latin/SettingsFragment.java
@@ -420,10 +420,6 @@ public final class SettingsFragment extends InputMethodSettingsFragment
// not present or disabled. In this case we need to remove the preference.
getPreferenceScreen().removePreference(userDictionaryPreference);
} else if (localeList.size() <= 1) {
- final Intent intent =
- new Intent(UserDictionaryList.USER_DICTIONARY_SETTINGS_INTENT_ACTION);
- userDictionaryPreference.setTitle(R.string.user_dict_single_settings_title);
- userDictionaryPreference.setIntent(intent);
userDictionaryPreference.setFragment(UserDictionarySettings.class.getName());
// If the size of localeList is 0, we don't set the locale parameter in the
// extras. This will be interpreted by the UserDictionarySettings class as
@@ -436,7 +432,6 @@ public final class SettingsFragment extends InputMethodSettingsFragment
userDictionaryPreference.getExtras().putString("locale", locale);
}
} else {
- userDictionaryPreference.setTitle(R.string.user_dict_multiple_settings_title);
userDictionaryPreference.setFragment(UserDictionaryList.class.getName());
}
}
diff --git a/java/src/com/android/inputmethod/latin/setup/SetupActivity.java b/java/src/com/android/inputmethod/latin/setup/SetupActivity.java
index 651fea6ab..044180bd6 100644
--- a/java/src/com/android/inputmethod/latin/setup/SetupActivity.java
+++ b/java/src/com/android/inputmethod/latin/setup/SetupActivity.java
@@ -26,6 +26,7 @@ import android.net.Uri;
import android.os.Bundle;
import android.os.Message;
import android.provider.Settings;
+import android.util.Log;
import android.view.View;
import android.view.inputmethod.InputMethodInfo;
import android.view.inputmethod.InputMethodManager;
@@ -44,6 +45,8 @@ import java.util.ArrayList;
// TODO: Use Fragment to implement welcome screen and setup steps.
public final class SetupActivity extends Activity implements View.OnClickListener {
+ private static final String TAG = SetupActivity.class.getSimpleName();
+
private View mWelcomeScreen;
private View mSetupScreen;
private Uri mWelcomeVideoUri;
@@ -198,6 +201,14 @@ public final class SetupActivity extends Activity implements View.OnClickListene
mWelcomeVideoView.setBackgroundResource(0);
}
});
+ mWelcomeVideoView.setOnErrorListener(new MediaPlayer.OnErrorListener() {
+ @Override
+ public boolean onError(final MediaPlayer mp, final int what, final int extra) {
+ Log.e(TAG, "Playing welcome video causes error: what=" + what + " extra=" + extra);
+ mWelcomeVideoView.setVisibility(View.GONE);
+ return true;
+ }
+ });
mActionStart = findViewById(R.id.setup_start_label);
mActionStart.setOnClickListener(this);