Fix a bug with multiple word insertion.
Bug: 7903831 Change-Id: I5202bc529a570292dd78d8503d8e2cc93b43d354
This commit is contained in:
@@ -57,6 +57,8 @@ public class UserDictionaryAddWordContents {
|
||||
private String mLocale;
|
||||
private final String mOldWord;
|
||||
private final String mOldShortcut;
|
||||
private String mSavedWord;
|
||||
private String mSavedShortcut;
|
||||
|
||||
/* package */ UserDictionaryAddWordContents(final View view, final Bundle args) {
|
||||
mWordEditText = (EditText)view.findViewById(R.id.user_dictionary_add_word_text);
|
||||
@@ -78,6 +80,16 @@ public class UserDictionaryAddWordContents {
|
||||
updateLocale(args.getString(EXTRA_LOCALE));
|
||||
}
|
||||
|
||||
/* package */ UserDictionaryAddWordContents(final View view,
|
||||
final UserDictionaryAddWordContents oldInstanceToBeEdited) {
|
||||
mWordEditText = (EditText)view.findViewById(R.id.user_dictionary_add_word_text);
|
||||
mShortcutEditText = (EditText)view.findViewById(R.id.user_dictionary_add_shortcut);
|
||||
mMode = MODE_EDIT;
|
||||
mOldWord = oldInstanceToBeEdited.mSavedWord;
|
||||
mOldShortcut = oldInstanceToBeEdited.mSavedShortcut;
|
||||
updateLocale(mLocale);
|
||||
}
|
||||
|
||||
// locale may be null, this means default locale
|
||||
// It may also be the empty string, which means "all locales"
|
||||
/* package */ void updateLocale(final String locale) {
|
||||
@@ -128,6 +140,8 @@ public class UserDictionaryAddWordContents {
|
||||
// If the word is somehow empty, don't insert it.
|
||||
return UserDictionaryAddWordActivity.CODE_CANCEL;
|
||||
}
|
||||
mSavedWord = newWord;
|
||||
mSavedShortcut = newShortcut;
|
||||
// If there is no shortcut, and the word already exists in the database, then we
|
||||
// should not insert, because either A. the word exists with no shortcut, in which
|
||||
// case the exact same thing we want to insert is already there, or B. the word
|
||||
|
||||
Reference in New Issue
Block a user