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
371d76ff
Commit
371d76ff
authored
10 years ago
by
Jean Chalard
Committed by
Android (Google) Code Review
10 years ago
Browse files
Options
Downloads
Plain Diff
Merge "[ML12] Add a getPrimaryLocale function and some refactoring"
parents
7e561452
1c0876dc
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
java/src/com/android/inputmethod/latin/DictionaryFacilitator.java
+36
-0
36 additions, 0 deletions
.../com/android/inputmethod/latin/DictionaryFacilitator.java
java/src/com/android/inputmethod/latin/LatinIME.java
+16
-17
16 additions, 17 deletions
java/src/com/android/inputmethod/latin/LatinIME.java
with
52 additions
and
17 deletions
java/src/com/android/inputmethod/latin/DictionaryFacilitator.java
+
36
−
0
View file @
371d76ff
...
...
@@ -98,6 +98,30 @@ public class DictionaryFacilitator {
Arrays
.
copyOfRange
(
DICT_TYPES_ORDERED_TO_GET_SUGGESTIONS
,
1
/* start */
,
DICT_TYPES_ORDERED_TO_GET_SUGGESTIONS
.
length
);
/**
* Returns whether this facilitator is exactly for this list of locales.
* @param locales the list of locales to test against
* @return true if this facilitator handles exactly this list of locales, false otherwise
*/
public
boolean
isForLocales
(
final
Locale
[]
locales
)
{
if
(
locales
.
length
!=
mDictionaryGroups
.
length
)
{
return
false
;
}
for
(
final
Locale
locale
:
locales
)
{
boolean
found
=
false
;
for
(
final
DictionaryGroup
group
:
mDictionaryGroups
)
{
if
(
locale
.
equals
(
group
.
mLocale
))
{
found
=
true
;
break
;
}
}
if
(!
found
)
{
return
false
;
}
}
return
true
;
}
/**
* A group of dictionaries that work together for a single language.
*/
...
...
@@ -199,6 +223,18 @@ public class DictionaryFacilitator {
return
mDictionaryGroups
[
0
].
mLocale
;
}
/**
* Returns the primary locale among all currently active locales. BE CAREFUL using this.
*
* DO NOT USE THIS just because it's convenient. Use it when it's correct, for example when
* choosing what dictionary to put a word in, or when changing the capitalization of a typed
* string.
* @return the primary active locale
*/
public
Locale
getPrimaryLocale
()
{
return
mDictionaryGroups
[
0
].
mLocale
;
}
private
static
ExpandableBinaryDictionary
getSubDict
(
final
String
dictType
,
final
Context
context
,
final
Locale
locale
,
final
File
dictFile
,
final
String
dictNamePrefix
)
{
...
...
This diff is collapsed.
Click to expand it.
java/src/com/android/inputmethod/latin/LatinIME.java
+
16
−
17
View file @
371d76ff
...
...
@@ -89,7 +89,6 @@ import com.android.inputmethod.latin.utils.CapsModeUtils;
import
com.android.inputmethod.latin.utils.CoordinateUtils
;
import
com.android.inputmethod.latin.utils.CursorAnchorInfoUtils
;
import
com.android.inputmethod.latin.utils.DialogUtils
;
import
com.android.inputmethod.latin.utils.DistracterFilterCheckingExactMatchesAndSuggestions
;
import
com.android.inputmethod.latin.utils.ImportantNoticeUtils
;
import
com.android.inputmethod.latin.utils.IntentUtils
;
import
com.android.inputmethod.latin.utils.JniUtils
;
...
...
@@ -253,7 +252,7 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
// We need to re-evaluate the currently composing word in case the script has
// changed.
postWaitForDictionaryLoad
();
latinIme
.
reset
Suggest
();
latinIme
.
reset
DictionaryFacilitatorIfNecessary
();
break
;
case
MSG_UPDATE_TAIL_BATCH_INPUT_COMPLETED:
latinIme
.
mInputLogic
.
onUpdateTailBatchInputCompleted
(
...
...
@@ -537,9 +536,10 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
mHandler
.
onCreate
();
DEBUG
=
DebugFlags
.
DEBUG_ENABLED
;
// TODO: Resolve mutual dependencies of {@link #loadSettings()} and {@link #initSuggest()}.
// TODO: Resolve mutual dependencies of {@link #loadSettings()} and
// {@link #resetDictionaryFacilitatorIfNecessary()}.
loadSettings
();
reset
Suggest
();
reset
DictionaryFacilitatorIfNecessary
();
// Register to receive ringer mode change and network state change.
// Also receive installation and removal of a dictionary pack.
...
...
@@ -580,7 +580,7 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
// been displayed. Opening dictionaries never affects responsivity as dictionaries are
// asynchronously loaded.
if
(!
mHandler
.
hasPendingReopenDictionaries
())
{
reset
Suggest
ForLocale
(
locale
);
reset
DictionaryFacilitator
ForLocale
(
locale
);
}
mDictionaryFacilitator
.
updateEnabledSubtypes
(
mRichImm
.
getMyEnabledInputMethodSubtypeList
(
true
/* allowsImplicitlySelectedSubtypes */
));
...
...
@@ -621,8 +621,11 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
}
}
private
void
reset
Suggest
()
{
private
void
reset
DictionaryFacilitatorIfNecessary
()
{
final
Locale
switcherSubtypeLocale
=
mSubtypeSwitcher
.
getCurrentSubtypeLocale
();
if
(
mDictionaryFacilitator
.
isForLocales
(
new
Locale
[]
{
switcherSubtypeLocale
}))
{
return
;
}
final
String
switcherLocaleStr
=
switcherSubtypeLocale
.
toString
();
final
Locale
subtypeLocale
;
if
(
TextUtils
.
isEmpty
(
switcherLocaleStr
))
{
...
...
@@ -637,15 +640,16 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
}
else
{
subtypeLocale
=
switcherSubtypeLocale
;
}
reset
Suggest
ForLocale
(
subtypeLocale
);
reset
DictionaryFacilitator
ForLocale
(
subtypeLocale
);
}
/**
* Reset
suggest
by loading dictionaries for the locale and the current settings values.
* Reset
the facilitator
by loading dictionaries for the locale and the current settings values.
*
* @param locale the locale
*/
private
void
resetSuggestForLocale
(
final
Locale
locale
)
{
// TODO: make sure the current settings always have the right locale, and read from them
private
void
resetDictionaryFacilitatorForLocale
(
final
Locale
locale
)
{
final
SettingsValues
settingsValues
=
mSettings
.
getCurrent
();
mDictionaryFacilitator
.
resetDictionaries
(
this
/* context */
,
locale
,
settingsValues
.
mUseContactsDict
,
settingsValues
.
mUsePersonalizedDicts
,
...
...
@@ -901,12 +905,7 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
mInputLogic
.
startInput
(
mSubtypeSwitcher
.
getCombiningRulesExtraValueOfCurrentSubtype
(),
currentSettingsValues
);
// Note: the following does a round-trip IPC on the main thread: be careful
final
Locale
currentLocale
=
mSubtypeSwitcher
.
getCurrentSubtypeLocale
();
if
(
null
!=
currentLocale
&&
!
currentLocale
.
equals
(
suggest
.
getLocale
()))
{
// TODO: Do this automatically.
resetSuggest
();
}
resetDictionaryFacilitatorIfNecessary
();
// TODO[IL]: Can the following be moved to InputLogic#startInput?
if
(!
mInputLogic
.
mConnection
.
resetCachesUponCursorMoveAndReturnSuccess
(
...
...
@@ -1554,7 +1553,7 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
}
final
String
wordToShow
;
if
(
CapsModeUtils
.
isAutoCapsMode
(
mInputLogic
.
mLastComposedWord
.
mCapitalizedMode
))
{
wordToShow
=
word
.
toLowerCase
(
m
SubtypeSwitcher
.
getCurrentSubtype
Locale
());
wordToShow
=
word
.
toLowerCase
(
m
DictionaryFacilitator
.
getPrimary
Locale
());
}
else
{
wordToShow
=
word
;
}
...
...
@@ -1840,7 +1839,7 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
public
void
dumpDictionaryForDebug
(
final
String
dictName
)
{
if
(
mDictionaryFacilitator
.
getLocale
()
==
null
)
{
reset
Suggest
();
reset
DictionaryFacilitatorIfNecessary
();
}
mDictionaryFacilitator
.
dumpDictionaryForDebug
(
dictName
);
}
...
...
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