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
091bbf85
Commit
091bbf85
authored
13 years ago
by
Jean Chalard
Committed by
Android (Google) Code Review
13 years ago
Browse files
Options
Downloads
Plain Diff
Merge "Factor dict pack settings reading into a static inner class"
parents
961453c3
c11c4fd6
No related branches found
Branches containing commit
No related tags found
Tags containing commit
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
+37
-14
37 additions, 14 deletions
...com/android/inputmethod/latin/BinaryDictionaryGetter.java
with
37 additions
and
14 deletions
java/src/com/android/inputmethod/latin/BinaryDictionaryGetter.java
+
37
−
14
View file @
091bbf85
...
@@ -158,6 +158,41 @@ class BinaryDictionaryGetter {
...
@@ -158,6 +158,41 @@ class BinaryDictionaryGetter {
context
.
getApplicationInfo
().
sourceDir
,
afd
.
getStartOffset
(),
afd
.
getLength
());
context
.
getApplicationInfo
().
sourceDir
,
afd
.
getStartOffset
(),
afd
.
getLength
());
}
}
static
private
class
DictPackSettings
{
final
SharedPreferences
mDictPreferences
;
public
DictPackSettings
(
final
Context
context
)
{
Context
dictPackContext
=
null
;
try
{
final
String
dictPackName
=
context
.
getString
(
R
.
string
.
dictionary_pack_package_name
);
dictPackContext
=
context
.
createPackageContext
(
dictPackName
,
0
);
}
catch
(
NameNotFoundException
e
)
{
// The dictionary pack is not installed...
// TODO: fallback on the built-in dict, see the TODO above
Log
.
e
(
TAG
,
"Could not find a dictionary pack"
);
}
mDictPreferences
=
null
==
dictPackContext
?
null
:
dictPackContext
.
getSharedPreferences
(
COMMON_PREFERENCES_NAME
,
Context
.
MODE_WORLD_READABLE
|
Context
.
MODE_MULTI_PROCESS
);
}
public
boolean
isWordListActive
(
final
String
dictId
)
{
if
(
null
==
mDictPreferences
)
{
// If we don't have preferences it basically means we can't find the dictionary
// pack - either it's not installed, or it's disabled, or there is some strange
// bug. Either way, a word list with no settings should be on by default: default
// dictionaries in LatinIME are on if there is no settings at all, and if for some
// reason some dictionaries have been installed BUT the dictionary pack can't be
// found anymore it's safer to actually supply installed dictionaries.
return
true
;
}
else
{
// The default is true here for the same reasons as above. We got the dictionary
// pack but if we don't have any settings for it it means the user has never been
// to the settings yet. So by default, the main dictionaries should be on.
return
mDictPreferences
.
getBoolean
(
dictId
,
true
);
}
}
}
/**
/**
* Returns the list of cached files for a specific locale.
* Returns the list of cached files for a specific locale.
*
*
...
@@ -173,24 +208,12 @@ class BinaryDictionaryGetter {
...
@@ -173,24 +208,12 @@ class BinaryDictionaryGetter {
// not present or disabled, then return an empty list.
// not present or disabled, then return an empty list.
if
(
null
==
cacheFiles
)
return
null
;
if
(
null
==
cacheFiles
)
return
null
;
final
SharedPreferences
dictPackSettings
;
final
DictPackSettings
dictPackSettings
=
new
DictPackSettings
(
context
);
try
{
final
String
dictPackName
=
context
.
getString
(
R
.
string
.
dictionary_pack_package_name
);
final
Context
dictPackContext
=
context
.
createPackageContext
(
dictPackName
,
0
);
dictPackSettings
=
dictPackContext
.
getSharedPreferences
(
COMMON_PREFERENCES_NAME
,
Context
.
MODE_WORLD_READABLE
|
Context
.
MODE_MULTI_PROCESS
);
}
catch
(
NameNotFoundException
e
)
{
// The dictionary pack is not installed...
// TODO: fallback on the built-in dict, see the TODO above
Log
.
e
(
TAG
,
"Could not find a dictionary pack"
);
return
null
;
}
final
ArrayList
<
AssetFileAddress
>
fileList
=
new
ArrayList
<
AssetFileAddress
>();
final
ArrayList
<
AssetFileAddress
>
fileList
=
new
ArrayList
<
AssetFileAddress
>();
for
(
File
f
:
cacheFiles
)
{
for
(
File
f
:
cacheFiles
)
{
final
String
wordListId
=
getWordListIdFromFileName
(
f
.
getName
());
final
String
wordListId
=
getWordListIdFromFileName
(
f
.
getName
());
final
boolean
isActive
=
dictPackSettings
.
getBoolean
(
wordListId
,
true
);
if
(!
dictPackSettings
.
isWordListActive
(
wordListId
))
continue
;
if
(!
isActive
)
continue
;
if
(
f
.
canRead
())
{
if
(
f
.
canRead
())
{
fileList
.
add
(
AssetFileAddress
.
makeFromFileName
(
f
.
getPath
()));
fileList
.
add
(
AssetFileAddress
.
makeFromFileName
(
f
.
getPath
()));
}
else
{
}
else
{
...
...
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