Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
LatinIME
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
keyboard
LatinIME
Commits
ee7daefd
Commit
ee7daefd
authored
13 years ago
by
Jean Chalard
Browse files
Options
Downloads
Patches
Plain Diff
Check the main dict id to be able to fallback.
Bug: 5095140 Change-Id: I02032923ca2a65bd8fbabc0abbe6a476f7542187
parent
89fdb827
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
java/src/com/android/inputmethod/latin/BinaryDictionaryGetter.java
+20
-7
20 additions, 7 deletions
...com/android/inputmethod/latin/BinaryDictionaryGetter.java
with
20 additions
and
7 deletions
java/src/com/android/inputmethod/latin/BinaryDictionaryGetter.java
+
20
−
7
View file @
ee7daefd
...
...
@@ -213,6 +213,13 @@ class BinaryDictionaryGetter {
return
cacheFiles
;
}
/**
* Returns the id of the main dict for a specified locale.
*/
private
static
String
getMainDictId
(
final
Locale
locale
)
{
return
locale
.
toString
();
}
/**
* Returns a list of file addresses for a given locale, trying relevant methods in order.
*
...
...
@@ -234,12 +241,18 @@ class BinaryDictionaryGetter {
BinaryDictionaryFileDumper
.
cacheDictionariesFromContentProvider
(
locale
,
context
);
final
File
[]
cachedDictionaryList
=
getCachedDictionaryList
(
locale
,
context
);
final
String
mainDictId
=
getMainDictId
(
locale
);
final
DictPackSettings
dictPackSettings
=
new
DictPackSettings
(
context
);
boolean
foundMainDict
=
false
;
final
ArrayList
<
AssetFileAddress
>
fileList
=
new
ArrayList
<
AssetFileAddress
>();
// cachedDictionaryList may not be null, see doc for getCachedDictionaryList
for
(
final
File
f
:
cachedDictionaryList
)
{
final
String
wordListId
=
getWordListIdFromFileName
(
f
.
getName
());
if
(
wordListId
.
equals
(
mainDictId
))
{
foundMainDict
=
true
;
}
if
(!
dictPackSettings
.
isWordListActive
(
wordListId
))
continue
;
if
(
f
.
canRead
())
{
fileList
.
add
(
AssetFileAddress
.
makeFromFileName
(
f
.
getPath
()));
...
...
@@ -248,14 +261,14 @@ class BinaryDictionaryGetter {
}
}
if
(!
fileList
.
isEmpty
())
{
return
fileList
;
if
(!
foundMainDict
&&
dictPackSettings
.
isWordListActive
(
mainDictId
))
{
final
AssetFileAddress
fallbackAsset
=
loadFallbackResource
(
context
,
fallbackResId
,
locale
);
if
(
null
!=
fallbackAsset
)
{
fileList
.
add
(
fallbackAsset
);
}
}
// If the list is empty, fall through and return the fallback
final
AssetFileAddress
fallbackAsset
=
loadFallbackResource
(
context
,
fallbackResId
,
locale
);
if
(
null
==
fallbackAsset
)
return
null
;
return
Arrays
.
asList
(
fallbackAsset
);
return
fileList
;
}
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment