Allow downloadable dictionaries in development builds

Bug: 9305379

Change-Id: Iab32753070a056d3861a45aa898911b7ab67dfb6
main
Kurt Partridge 2013-06-05 22:11:20 -07:00
parent 9c440d1373
commit efd26bb319
3 changed files with 17 additions and 34 deletions

View File

@ -290,16 +290,12 @@ final class BinaryDictionaryGetter {
final Context context) { final Context context) {
final boolean hasDefaultWordList = DictionaryFactory.isDictionaryAvailable(context, locale); final boolean hasDefaultWordList = DictionaryFactory.isDictionaryAvailable(context, locale);
// TODO: The development-only-diagnostic version is not supported by the Dictionary Pack // We need internet access to do the following. Only do this if the package actually
// Service yet // has the permission.
if (!ProductionFlag.USES_DEVELOPMENT_ONLY_DIAGNOSTICS) { if (context.checkCallingOrSelfPermission(android.Manifest.permission.INTERNET)
// We need internet access to do the following. Only do this if the package actually == PackageManager.PERMISSION_GRANTED) {
// has the permission. BinaryDictionaryFileDumper.cacheWordListsFromContentProvider(locale, context,
if (context.checkCallingOrSelfPermission(android.Manifest.permission.INTERNET) hasDefaultWordList);
== PackageManager.PERMISSION_GRANTED) {
BinaryDictionaryFileDumper.cacheWordListsFromContentProvider(locale, context,
hasDefaultWordList);
}
} }
final File[] cachedWordLists = getCachedWordLists(locale.toString(), context); final File[] cachedWordLists = getCachedWordLists(locale.toString(), context);
final String mainDictId = DictionaryInfoUtils.getMainDictId(locale); final String mainDictId = DictionaryInfoUtils.getMainDictId(locale);

View File

@ -179,11 +179,8 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
private int mDisplayOrientation; private int mDisplayOrientation;
// Object for reacting to adding/removing a dictionary pack. // Object for reacting to adding/removing a dictionary pack.
// TODO: The development-only-diagnostic version is not supported by the Dictionary Pack
// Service yet.
private BroadcastReceiver mDictionaryPackInstallReceiver = private BroadcastReceiver mDictionaryPackInstallReceiver =
ProductionFlag.USES_DEVELOPMENT_ONLY_DIAGNOSTICS new DictionaryPackInstallBroadcastReceiver(this);
? null : new DictionaryPackInstallBroadcastReceiver(this);
// Keeps track of most recently inserted text (multi-character key) for reverting // Keeps track of most recently inserted text (multi-character key) for reverting
private String mEnteredText; private String mEnteredText;
@ -458,19 +455,15 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
filter.addAction(AudioManager.RINGER_MODE_CHANGED_ACTION); filter.addAction(AudioManager.RINGER_MODE_CHANGED_ACTION);
registerReceiver(mReceiver, filter); registerReceiver(mReceiver, filter);
// TODO: The development-only-diagnostic version is not supported by the Dictionary Pack final IntentFilter packageFilter = new IntentFilter();
// Service yet. packageFilter.addAction(Intent.ACTION_PACKAGE_ADDED);
if (!ProductionFlag.USES_DEVELOPMENT_ONLY_DIAGNOSTICS) { packageFilter.addAction(Intent.ACTION_PACKAGE_REMOVED);
final IntentFilter packageFilter = new IntentFilter(); packageFilter.addDataScheme(SCHEME_PACKAGE);
packageFilter.addAction(Intent.ACTION_PACKAGE_ADDED); registerReceiver(mDictionaryPackInstallReceiver, packageFilter);
packageFilter.addAction(Intent.ACTION_PACKAGE_REMOVED);
packageFilter.addDataScheme(SCHEME_PACKAGE);
registerReceiver(mDictionaryPackInstallReceiver, packageFilter);
final IntentFilter newDictFilter = new IntentFilter(); final IntentFilter newDictFilter = new IntentFilter();
newDictFilter.addAction(DictionaryPackConstants.NEW_DICTIONARY_INTENT_ACTION); newDictFilter.addAction(DictionaryPackConstants.NEW_DICTIONARY_INTENT_ACTION);
registerReceiver(mDictionaryPackInstallReceiver, newDictFilter); registerReceiver(mDictionaryPackInstallReceiver, newDictFilter);
}
} }
// Has to be package-visible for unit tests // Has to be package-visible for unit tests
@ -587,11 +580,7 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
if (ProductionFlag.USES_DEVELOPMENT_ONLY_DIAGNOSTICS) { if (ProductionFlag.USES_DEVELOPMENT_ONLY_DIAGNOSTICS) {
ResearchLogger.getInstance().onDestroy(); ResearchLogger.getInstance().onDestroy();
} }
// TODO: The development-only-diagnostic version is not supported by the Dictionary Pack unregisterReceiver(mDictionaryPackInstallReceiver);
// Service yet.
if (!ProductionFlag.USES_DEVELOPMENT_ONLY_DIAGNOSTICS) {
unregisterReceiver(mDictionaryPackInstallReceiver);
}
LatinImeLogger.commit(); LatinImeLogger.commit();
LatinImeLogger.onDestroy(); LatinImeLogger.onDestroy();
super.onDestroy(); super.onDestroy();

View File

@ -190,9 +190,7 @@ public final class SettingsFragment extends InputMethodSettingsFragment
final Intent intent = dictionaryLink.getIntent(); final Intent intent = dictionaryLink.getIntent();
intent.setClassName(context.getPackageName(), DictionarySettingsActivity.class.getName()); intent.setClassName(context.getPackageName(), DictionarySettingsActivity.class.getName());
final int number = context.getPackageManager().queryIntentActivities(intent, 0).size(); final int number = context.getPackageManager().queryIntentActivities(intent, 0).size();
// TODO: The development-only-diagnostic version is not supported by the Dictionary Pack if (0 >= number) {
// Service yet
if (ProductionFlag.USES_DEVELOPMENT_ONLY_DIAGNOSTICS || 0 >= number) {
textCorrectionGroup.removePreference(dictionaryLink); textCorrectionGroup.removePreference(dictionaryLink);
} }